sprig 0.1.7 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -1
- data/lib/sprig/planter.rb +1 -1
- data/lib/sprig/process_notifier.rb +4 -4
- data/lib/sprig/seed/entry.rb +8 -4
- data/lib/sprig/source.rb +10 -1
- data/lib/sprig/version.rb +1 -1
- data/spec/db/activerecord.db +0 -0
- data/spec/lib/sprig/process_notifier_spec.rb +4 -2
- data/spec/lib/sprig/seed/entry_spec.rb +2 -2
- data/spec/sprig_spec.rb +17 -0
- metadata +37 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a2500ec348b79679f29e89f4109b33ee91f11fd
|
4
|
+
data.tar.gz: c6248310b5089e1d03778caeb1d7e09a9e7d4c74
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d95948af8e4146673d3152e4e8e0a9de1e554641d86d404998dd2c794fc8aeb7f8cd73af9f68eabf115459e0cca08ebcaa5245dd461ac98f00e2010b9ef56822
|
7
|
+
data.tar.gz: f63975d16165e30e95fa7e72a5ee3fa0ab68c6e69b7b4d56507d49ee6f5ea3454de4bc8c5d480b5598e713e75f689c5f4b4d4f5737170e0f3effab6a360f84f0
|
data/README.md
CHANGED
@@ -10,6 +10,10 @@ Learn more about Sprig and view documentation at [http://vigetlabs.github.io/spr
|
|
10
10
|
|
11
11
|
## Installation
|
12
12
|
|
13
|
+
Add into your Gemfile
|
14
|
+
```ruby
|
15
|
+
gem "sprig"
|
16
|
+
```
|
13
17
|
Use `rails generate sprig:install` to create environment-specific seed directories.
|
14
18
|
|
15
19
|
##The Sprig Directive
|
@@ -152,7 +156,7 @@ require 'open-uri'
|
|
152
156
|
fanciness = {
|
153
157
|
:class => User,
|
154
158
|
:source => open('https://spreadsheets.google.com/feeds/list/somerandomtoken/1/public/values?alt=json'),
|
155
|
-
:parser => Sprig::
|
159
|
+
:parser => Sprig::Parser::GoogleSpreadsheetJson
|
156
160
|
}
|
157
161
|
|
158
162
|
sprig [
|
data/lib/sprig/planter.rb
CHANGED
@@ -10,6 +10,10 @@ module Sprig
|
|
10
10
|
@errors = []
|
11
11
|
end
|
12
12
|
|
13
|
+
def in_progress(seed)
|
14
|
+
log_debug seed.in_progress_text
|
15
|
+
end
|
16
|
+
|
13
17
|
def success(seed)
|
14
18
|
log_info seed.success_log_text
|
15
19
|
@success_count += 1
|
@@ -42,10 +46,6 @@ module Sprig
|
|
42
46
|
end
|
43
47
|
end
|
44
48
|
|
45
|
-
def in_progress
|
46
|
-
log_debug "Planting those seeds...\r"
|
47
|
-
end
|
48
|
-
|
49
49
|
private
|
50
50
|
|
51
51
|
def success_summary
|
data/lib/sprig/seed/entry.rb
CHANGED
@@ -34,12 +34,16 @@ module Sprig
|
|
34
34
|
SprigRecordStore.instance.save(record.orm_record, sprig_id)
|
35
35
|
end
|
36
36
|
|
37
|
-
def
|
38
|
-
"#{klass.name} with sprig_id #{sprig_id}
|
37
|
+
def in_progress_text
|
38
|
+
"Planting #{klass.name} with sprig_id #{sprig_id}"
|
39
39
|
end
|
40
40
|
|
41
|
-
def
|
42
|
-
record.existing?
|
41
|
+
def success_log_text
|
42
|
+
if record.existing?
|
43
|
+
"Updated"
|
44
|
+
else
|
45
|
+
"Saved"
|
46
|
+
end
|
43
47
|
end
|
44
48
|
|
45
49
|
def error_log_text
|
data/lib/sprig/source.rb
CHANGED
@@ -67,7 +67,7 @@ module Sprig
|
|
67
67
|
end
|
68
68
|
|
69
69
|
def file
|
70
|
-
File.new(
|
70
|
+
File.new(filepath)
|
71
71
|
end
|
72
72
|
|
73
73
|
private
|
@@ -78,6 +78,15 @@ module Sprig
|
|
78
78
|
available_files.detect {|name| name =~ /^#{table_name}\./ } || file_not_found
|
79
79
|
end
|
80
80
|
|
81
|
+
def filepath
|
82
|
+
path = seed_directory.join(filename)
|
83
|
+
if File.symlink?(path)
|
84
|
+
File.readlink(path)
|
85
|
+
else
|
86
|
+
path
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
81
90
|
def available_files
|
82
91
|
Dir.entries(seed_directory)
|
83
92
|
end
|
data/lib/sprig/version.rb
CHANGED
data/spec/db/activerecord.db
CHANGED
Binary file
|
@@ -79,10 +79,12 @@ describe Sprig::ProcessNotifier do
|
|
79
79
|
end
|
80
80
|
|
81
81
|
describe "#in_progress" do
|
82
|
+
let(:seed) { Sprig::Seed::Entry.new(Post, { title: "Hello World!", content: "Stuff", sprig_id: 1 }, {}) }
|
83
|
+
|
82
84
|
it "logs an in-progress message" do
|
83
|
-
log_should_receive(:debug, with: "Planting
|
85
|
+
log_should_receive(:debug, with: "Planting Post with sprig_id 1")
|
84
86
|
|
85
|
-
subject.in_progress
|
87
|
+
subject.in_progress(seed)
|
86
88
|
end
|
87
89
|
end
|
88
90
|
end
|
@@ -7,7 +7,7 @@ describe Sprig::Seed::Entry do
|
|
7
7
|
subject = described_class.new(Post, { title: "Hello World!", content: "Stuff", sprig_id: 1 }, {})
|
8
8
|
subject.save_record
|
9
9
|
|
10
|
-
subject.success_log_text.should == "
|
10
|
+
subject.success_log_text.should == "Saved"
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
@@ -24,7 +24,7 @@ describe Sprig::Seed::Entry do
|
|
24
24
|
subject = described_class.new(Post, { title: "Existing title", content: "Existing content", sprig_id: 1 }, { find_existing_by: [:title] })
|
25
25
|
subject.save_record
|
26
26
|
|
27
|
-
subject.success_log_text.should == "
|
27
|
+
subject.success_log_text.should == "Updated"
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
data/spec/sprig_spec.rb
CHANGED
@@ -53,6 +53,23 @@ describe "Seeding an application" do
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
+
context "with a symlinked file" do
|
57
|
+
let(:env) { Rails.env }
|
58
|
+
|
59
|
+
around do |example|
|
60
|
+
`ln -s ./spec/fixtures/seeds/#{env}/posts.yml ./spec/fixtures/db/seeds/#{env}`
|
61
|
+
example.call
|
62
|
+
`rm ./spec/fixtures/db/seeds/#{env}/posts.yml`
|
63
|
+
end
|
64
|
+
|
65
|
+
it "seeds the db" do
|
66
|
+
sprig [Post]
|
67
|
+
|
68
|
+
Post.count.should == 1
|
69
|
+
Post.pluck(:title).should =~ ['Yaml title']
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
56
73
|
context "with a google spreadsheet" do
|
57
74
|
it "seeds the db", :vcr => { :cassette_name => 'google_spreadsheet_json_posts' } do
|
58
75
|
sprig [
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sprig
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lawson Kurtz
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-10-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: appraisal
|
@@ -101,6 +101,20 @@ dependencies:
|
|
101
101
|
- - ~>
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: 2.8.0
|
104
|
+
- !ruby/object:Gem::Dependency
|
105
|
+
name: test-unit
|
106
|
+
requirement: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ~>
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '3.0'
|
111
|
+
type: :development
|
112
|
+
prerelease: false
|
113
|
+
version_requirements: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ~>
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '3.0'
|
104
118
|
- !ruby/object:Gem::Dependency
|
105
119
|
name: pry
|
106
120
|
requirement: !ruby/object:Gem::Requirement
|
@@ -157,6 +171,20 @@ dependencies:
|
|
157
171
|
- - '>='
|
158
172
|
- !ruby/object:Gem::Version
|
159
173
|
version: '0'
|
174
|
+
- !ruby/object:Gem::Dependency
|
175
|
+
name: sqlite3
|
176
|
+
requirement: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - '>='
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
181
|
+
type: :development
|
182
|
+
prerelease: false
|
183
|
+
version_requirements: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - '>='
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
160
188
|
description: Sprig is a library for managing interconnected, environment-specific
|
161
189
|
seed data.
|
162
190
|
email:
|
@@ -166,11 +194,7 @@ executables: []
|
|
166
194
|
extensions: []
|
167
195
|
extra_rdoc_files: []
|
168
196
|
files:
|
169
|
-
- MIT-LICENSE
|
170
|
-
- README.md
|
171
|
-
- Rakefile
|
172
197
|
- lib/generators/sprig/install_generator.rb
|
173
|
-
- lib/sprig.rb
|
174
198
|
- lib/sprig/configuration.rb
|
175
199
|
- lib/sprig/data.rb
|
176
200
|
- lib/sprig/dependency.rb
|
@@ -181,24 +205,28 @@ files:
|
|
181
205
|
- lib/sprig/helpers.rb
|
182
206
|
- lib/sprig/logging.rb
|
183
207
|
- lib/sprig/null_record.rb
|
184
|
-
- lib/sprig/parser.rb
|
185
208
|
- lib/sprig/parser/base.rb
|
186
209
|
- lib/sprig/parser/csv.rb
|
187
210
|
- lib/sprig/parser/google_spreadsheet_json.rb
|
188
211
|
- lib/sprig/parser/json.rb
|
189
212
|
- lib/sprig/parser/yml.rb
|
213
|
+
- lib/sprig/parser.rb
|
190
214
|
- lib/sprig/planter.rb
|
191
215
|
- lib/sprig/process_notifier.rb
|
192
|
-
- lib/sprig/seed.rb
|
193
216
|
- lib/sprig/seed/attribute.rb
|
194
217
|
- lib/sprig/seed/attribute_collection.rb
|
195
218
|
- lib/sprig/seed/entry.rb
|
196
219
|
- lib/sprig/seed/factory.rb
|
197
220
|
- lib/sprig/seed/record.rb
|
221
|
+
- lib/sprig/seed.rb
|
198
222
|
- lib/sprig/source.rb
|
199
223
|
- lib/sprig/sprig_record_store.rb
|
200
224
|
- lib/sprig/tsortable_hash.rb
|
201
225
|
- lib/sprig/version.rb
|
226
|
+
- lib/sprig.rb
|
227
|
+
- MIT-LICENSE
|
228
|
+
- Rakefile
|
229
|
+
- README.md
|
202
230
|
- spec/adapters/active_record.rb
|
203
231
|
- spec/adapters/mongoid.rb
|
204
232
|
- spec/adapters/mongoid.yml
|
@@ -271,7 +299,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
271
299
|
version: '0'
|
272
300
|
requirements: []
|
273
301
|
rubyforge_project:
|
274
|
-
rubygems_version: 2.2
|
302
|
+
rubygems_version: 2.0.2
|
275
303
|
signing_key:
|
276
304
|
specification_version: 4
|
277
305
|
summary: Relational, environment-specific seeding for Rails apps.
|
@@ -328,4 +356,3 @@ test_files:
|
|
328
356
|
- spec/support/helpers/colored_text.rb
|
329
357
|
- spec/support/helpers/logger_mock.rb
|
330
358
|
- spec/support/shared_examples/a_logging_entity.rb
|
331
|
-
has_rdoc:
|