tanemaki 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bdc41e1779ca067b789c12ce2fada5b86719d094
4
- data.tar.gz: fda55d2f676a52ac8d65e86dafe12b9ead144dcf
3
+ metadata.gz: 015971083b14c3b96b6232d121037f7c09fcfbfe
4
+ data.tar.gz: 70ec8e2ea4e6acbb9203de1cf0484e0b8c643067
5
5
  SHA512:
6
- metadata.gz: 3fd272cd160de9f426ad42b5f40407b212cd4ef2f9b6c5bf1b4cebf73c852ca7a1fe4ec2f18f1b3e8e671411f20d11fd2293f7cad6ac5cb6bb207345f96370e9
7
- data.tar.gz: 44f8af01d55abb92283eef0d2c89a821f0b85125a5745a465419a985e1502417e5394626dc1cbd66d1989e10acf4ecc1eff51f8fd3fffb078d75aa2868d58892
6
+ metadata.gz: 810fa516a87142923bcf7a20ea797d54c8590b862cb7ad2ed2653f93497714ee1f3a47ed7bd27661d68bba58e0406db672c1bab72075d70e609f2aa2f76a67ab
7
+ data.tar.gz: 8863c5d583c5b25084085e049825212a7cbbfbfa26e2e041b2d7157ceecd7ea882680f18db6852d02698e1263e533f380207d08def6c9b2433198f48a9576d9a
@@ -0,0 +1 @@
1
+ service_name: travis-ci
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
1
  [![Build Status](https://travis-ci.org/mmmpa/tanemaki.svg)](https://travis-ci.org/mmmpa/tanemaki)
2
+ [![Coverage Status](https://coveralls.io/repos/mmmpa/tanemaki/badge.svg?branch=master)](https://coveralls.io/r/mmmpa/tanemaki?branch=master)
2
3
 
3
4
  # Tanemaki
4
5
 
@@ -60,7 +61,9 @@ class AreaCode < ActiveRecord::Base {
60
61
  :updated_at => :datetime
61
62
  }
62
63
  ```
64
+
63
65
  `create`に必要なキーワード引数の**キーを一行目に書いたCSV**(例えば area_code.csv)を用意。
66
+
64
67
  ```csv
65
68
  ken_code,sityouson_code,tiiki_code,ken_name,sityouson_name1,sityouson_name2,sityouson_name3,yomigana
66
69
  27,0,27000,大阪府,,,,おおさかふ
@@ -70,11 +73,15 @@ ken_code,sityouson_code,tiiki_code,ken_name,sityouson_name1,sityouson_name2,sity
70
73
  # 略
71
74
  27,128,27128,大阪府,大阪市,,中央区,ちゅうおうく
72
75
  ```
76
+
73
77
  ゴー。
78
+
74
79
  ```ruby
75
80
  AreaCode.tanemaki('area_code.csv').seed
76
81
  ```
82
+
77
83
  内部的には各行においてこのようなことが起こります。
84
+
78
85
  ```ruby
79
86
  AreaCode.create({ken_code: 27, sityouson_code: 102, tiiki_code: 27102, ken_name: ,'大阪府', sityouson_name1: ,'大阪市', sityouson_name2: '', sityouson_name3: '都島区', yomigana: 'みやこじまく'})
80
87
  ```
@@ -86,6 +93,27 @@ AreaCode.create({ken_code: 27, sityouson_code: 102, tiiki_code: 27102, ken_name:
86
93
  AreaCode.tanemaki('area_code.csv', method: :create!).seed
87
94
  ```
88
95
 
96
+ ## 名前無し引数に使う
97
+
98
+ こういうのです。
99
+
100
+ FactoryGirl.build(:user, :invalid, name: 'MMMPA', name_reading: 'ンンンパ')
101
+
102
+ 名前無し引数のカラムの名前を省いたfactory.csvを用意します。
103
+
104
+ ```csv
105
+ ,name,name_reading,
106
+ :user,MMMPA,ンンンパ,:invalid
107
+ :user,o296sm,おふくろさま,:valid
108
+ ```
109
+
110
+ こうすると1列目([0])と4列目([3])は普通の引数としてメソッドに渡されます。カラムの位置にかかわらず、出現順に引数の頭に回されます。
111
+
112
+ 突然ですが`evaluate`に渡した名前のカラム、もしくは名前無しカラムのインデックスと一致するカラムは式として評価されます(この場合`Symbol`になる)。
113
+
114
+ FactoryGirl.tanemaki('factory.csv', method: :build).evaluate(0, 3).seed
115
+
116
+
89
117
  ## select
90
118
 
91
119
  CSVから必要なカラムのみ使います。
@@ -111,7 +111,7 @@ module Tanemaki
111
111
  Seeder.(@named_csv.map do |row|
112
112
  column_names.each_with_object({}) do |name, new_row|
113
113
  new_row[name] = row[name]
114
- end
114
+ end.merge(namelass_parameter_array: row[:namelass_parameter_array])
115
115
  end, for_chain)
116
116
  end
117
117
 
@@ -1,3 +1,3 @@
1
1
  module Tanemaki
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
@@ -22,4 +22,5 @@ Gem::Specification.new do |spec|
22
22
  spec.add_development_dependency "bundler", "~> 1.10"
23
23
  spec.add_development_dependency "rake", "~> 10.0"
24
24
  spec.add_development_dependency "rspec"
25
+ spec.add_development_dependency "coveralls"
25
26
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tanemaki
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - mmmpa
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: coveralls
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  description: Seeding with CSV having named column.
56
70
  email:
57
71
  - mmmpa.mmmpa@gmail.com
@@ -59,6 +73,7 @@ executables: []
59
73
  extensions: []
60
74
  extra_rdoc_files: []
61
75
  files:
76
+ - ".coveralls.yml"
62
77
  - ".gitignore"
63
78
  - ".travis.yml"
64
79
  - Gemfile