versioned_seeds 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -11,6 +11,12 @@ namespace :vs do
11
11
  VersionedSeeds.next
12
12
  end
13
13
 
14
+ desc "Load the specified seeding script (specify version w/ SEED=012345678901)"
15
+ task :load => :environment do
16
+ version = ENV['SEED']
17
+ VersionedSeeds.load_one(version) if version
18
+ end
19
+
14
20
  desc "Load all seeding scripts that haven't been loaded yet"
15
21
  task :all => :environment do
16
22
  VersionedSeeds.all
@@ -9,6 +9,12 @@ module VersionedSeeds
9
9
  yield self
10
10
  end
11
11
 
12
+ # Loads seeding script with the given version
13
+ def load_one(version)
14
+ seed = all_seeds([]).select { |seed| seed.version == version }.first
15
+ load seed, false
16
+ end
17
+
12
18
  # Loads the next seeding script
13
19
  def next(loaded=already_loaded)
14
20
  load next_seed(loaded)
@@ -35,11 +41,11 @@ module VersionedSeeds
35
41
  end
36
42
 
37
43
  # Loads a list of seeding scripts and updates the .versioned_seeds file
38
- def load(seeds)
44
+ def load(seeds, write=true)
39
45
  [*seeds].each do |seed|
40
46
  puts "Loading: #{File.basename seed.file}"
41
47
  require seed.file
42
- write_loaded seed
48
+ write_loaded seed if write
43
49
  end
44
50
  end
45
51
 
@@ -1,3 +1,3 @@
1
1
  module VersionedSeeds
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
@@ -102,6 +102,11 @@ module VersionedSeeds
102
102
  @tester.should_receive(:write_loaded)
103
103
  @tester.load file1
104
104
  end
105
+
106
+ it "should not write the loaded scripts to .versioned_file if write is false" do
107
+ @tester.should_not_receive(:write_loaded)
108
+ @tester.load file1, false
109
+ end
105
110
  end
106
111
 
107
112
  describe 'seeds' do
@@ -111,12 +116,12 @@ module VersionedSeeds
111
116
  end
112
117
 
113
118
  describe 'write_loaded' do
114
- it "should write the versions of the loaded scripts to the .versioned_seeds file" do
119
+ it "should write the versions of the loaded script to the .versioned_seeds file" do
115
120
  seed_file = remove_seed_file
116
121
  file = mock('file')
117
122
  File.should_receive(:open).with(seed_file, 'a').and_yield(file)
118
123
  file.should_receive(:puts).with(file1.version.to_s)
119
- @tester.write_loaded [file1]
124
+ @tester.write_loaded file1
120
125
  end
121
126
  end
122
127
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: versioned_seeds
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-11 00:00:00.000000000 Z
12
+ date: 2012-04-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
- requirement: &70119511455460 !ruby/object:Gem::Requirement
16
+ requirement: &70335895300540 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0.9'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70119511455460
24
+ version_requirements: *70335895300540
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &70119511454960 !ruby/object:Gem::Requirement
27
+ requirement: &70335895299880 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '2'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70119511454960
35
+ version_requirements: *70335895299880
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rails
38
- requirement: &70119511454500 !ruby/object:Gem::Requirement
38
+ requirement: &70335895299360 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '3'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70119511454500
46
+ version_requirements: *70335895299360
47
47
  description: Manage your seed scripts by versioning them
48
48
  email:
49
49
  - scourtois@cubyx.fr