Skip to content

Commit

Permalink
ファイル名を変更
Browse files Browse the repository at this point in the history
  • Loading branch information
hidenba committed Feb 16, 2012
1 parent 5e3ecb7 commit 9c3d70d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
5 changes: 2 additions & 3 deletions lib/millionaire/base.rb → lib/millionaire/csv.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require 'millionaire/column'
require 'millionaire/validations/csv_uniqness'

module Millionaire::Base
module Millionaire::Csv
extend ActiveSupport::Concern
include ActiveModel::Validations

Expand All @@ -24,7 +24,7 @@ def column(name, option={})
self.columns << column
option.each do |k,v|
case k
when :null; validates name, presence: true unless v
when :null; validates name, presence: v unless v
when :length; validates name, length: {maximum: v}
when :value; validates name, inclusion: {in: v}
when :constraint; validates name, v
Expand All @@ -49,7 +49,6 @@ def load(io)
self.csv_data << self.new(row.to_hash.slice(*self.column_names))
end

self.indexes[uniqness] = [] if uniqness.present?
self.indexes.keys.each do |k|
self.indexes[k] = self.csv_data.group_by{|v| v.send(k) }
end
Expand Down
10 changes: 5 additions & 5 deletions spec/millionaire/base_spec.rb → spec/millionaire/csv_spec.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# -*- coding: utf-8 -*-
require 'spec_helper'
require 'millionaire/base'
require 'millionaire/csv'

describe Millionaire::Base do
describe Millionaire::Csv do
describe '.column' do
class CsvLoad
include Millionaire::Base
include Millionaire::Csv
column :index , index: true
column :presence, null: false, index: true
column :length, length: 20
Expand Down Expand Up @@ -39,7 +39,7 @@ class CsvLoad

describe '.index' do
class Index
include Millionaire::Base
include Millionaire::Csv
column :index_a
column :index_b
index :index_a, :index_b
Expand All @@ -52,7 +52,7 @@ class Index

describe '.all' do
class AllLoad
include Millionaire::Base
include Millionaire::Csv
column :str, index: true
end

Expand Down

0 comments on commit 9c3d70d

Please sign in to comment.