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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e9deb6a8c1f64f83ed2fbeb9c4c7a7de28a90be5
4
- data.tar.gz: 38ab2e9a1eee0cd9a43f5578cd5a049859ae6a21
3
+ metadata.gz: 9a2500ec348b79679f29e89f4109b33ee91f11fd
4
+ data.tar.gz: c6248310b5089e1d03778caeb1d7e09a9e7d4c74
5
5
  SHA512:
6
- metadata.gz: b0dcb9273bb4bffb8cef23386f31e23bdfbbb5484a194a1809565514137b95ca6076927526d99d6f83779c280197c1c2d228dd9f94660869cbcaed8996870535
7
- data.tar.gz: afbc6277ada442ce7bd424b33abd4b7d38f8e02c7112c0e1281f5fdeac8c3ed0a45533746e04168664c5110875c87eece488d43a7b61835c3732d21d57ccc0be
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::Data::Parser::GoogleSpreadsheetJson
159
+ :parser => Sprig::Parser::GoogleSpreadsheetJson
156
160
  }
157
161
 
158
162
  sprig [
@@ -25,7 +25,7 @@ module Sprig
25
25
  end
26
26
 
27
27
  def plant(seed)
28
- notifier.in_progress
28
+ notifier.in_progress(seed)
29
29
  seed.before_save
30
30
 
31
31
  if seed.save_record
@@ -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
@@ -34,12 +34,16 @@ module Sprig
34
34
  SprigRecordStore.instance.save(record.orm_record, sprig_id)
35
35
  end
36
36
 
37
- def success_log_text
38
- "#{klass.name} with sprig_id #{sprig_id} successfully #{success_log_status_text}."
37
+ def in_progress_text
38
+ "Planting #{klass.name} with sprig_id #{sprig_id}"
39
39
  end
40
40
 
41
- def success_log_status_text
42
- record.existing? ? "updated" : "saved"
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
@@ -67,7 +67,7 @@ module Sprig
67
67
  end
68
68
 
69
69
  def file
70
- File.new(seed_directory.join(filename))
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
@@ -1,3 +1,3 @@
1
1
  module Sprig
2
- VERSION = "0.1.7"
2
+ VERSION = "0.1.9"
3
3
  end
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 those seeds...\r")
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 == "Post with sprig_id 1 successfully saved."
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 == "Post with sprig_id 1 successfully updated."
27
+ subject.success_log_text.should == "Updated"
28
28
  end
29
29
  end
30
30
  end
@@ -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.7
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-03-20 00:00:00.000000000 Z
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.1
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: