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 +4 -4
- data/.coveralls.yml +1 -0
- data/README.md +28 -0
- data/lib/tanemaki.rb +1 -1
- data/lib/tanemaki/version.rb +1 -1
- data/tanemaki.gemspec +1 -0
- metadata +16 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 015971083b14c3b96b6232d121037f7c09fcfbfe
|
4
|
+
data.tar.gz: 70ec8e2ea4e6acbb9203de1cf0484e0b8c643067
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 810fa516a87142923bcf7a20ea797d54c8590b862cb7ad2ed2653f93497714ee1f3a47ed7bd27661d68bba58e0406db672c1bab72075d70e609f2aa2f76a67ab
|
7
|
+
data.tar.gz: 8863c5d583c5b25084085e049825212a7cbbfbfa26e2e041b2d7157ceecd7ea882680f18db6852d02698e1263e533f380207d08def6c9b2433198f48a9576d9a
|
data/.coveralls.yml
ADDED
@@ -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から必要なカラムのみ使います。
|
data/lib/tanemaki.rb
CHANGED
data/lib/tanemaki/version.rb
CHANGED
data/tanemaki.gemspec
CHANGED
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.
|
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
|