versioned_seeds 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.mdown +18 -1
- data/lib/versioned_seeds.rb +11 -4
- data/lib/versioned_seeds/version.rb +1 -1
- metadata +4 -4
data/README.mdown
CHANGED
@@ -10,7 +10,7 @@ Versioned Seeds provides a simple, conventions based, way to do that.
|
|
10
10
|
|
11
11
|
Add this line to your `Gemfile` :
|
12
12
|
|
13
|
-
gem 'versioned_seeds'
|
13
|
+
gem 'versioned_seeds'
|
14
14
|
|
15
15
|
If you're using Git, as you should, be sure to call this in your shell :
|
16
16
|
|
@@ -25,6 +25,23 @@ You can get the last imported seeds version :
|
|
25
25
|
$ rake vs:status
|
26
26
|
Last seeds: 0
|
27
27
|
|
28
|
+
### Configuration
|
29
|
+
|
30
|
+
VersionedSeeds can be configured using an initializer:
|
31
|
+
|
32
|
+
``` ruby
|
33
|
+
VersionedSeeds.configuration do |config|
|
34
|
+
# Path where are stored seed files
|
35
|
+
# VersionedSeeds will look for [root_path]/db/seeds/*.rb
|
36
|
+
# Defaults to Rails.root
|
37
|
+
config.root_path = '...'
|
38
|
+
|
39
|
+
# Path of the .versioned_seeds file where the list of
|
40
|
+
# already loaded seed files is stored
|
41
|
+
config.list_path = '...' #
|
42
|
+
end
|
43
|
+
```
|
44
|
+
|
28
45
|
### Generate a seeding script
|
29
46
|
|
30
47
|
The generator will simply generate a timestamped file where you can put anything you want :
|
data/lib/versioned_seeds.rb
CHANGED
@@ -64,16 +64,15 @@ module VersionedSeeds
|
|
64
64
|
|
65
65
|
# Writes the versions of the loaded script to the .versionned_seeds file
|
66
66
|
def write_loaded(loaded)
|
67
|
-
File.open(
|
67
|
+
File.open(list_path, 'a') do |f|
|
68
68
|
f.puts loaded.version
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
72
|
# Returns the list of already loaded scripts
|
73
73
|
def already_loaded
|
74
|
-
|
75
|
-
|
76
|
-
File.read(file).split(/\r?\n/)
|
74
|
+
return [0] unless File.exists?(list_path)
|
75
|
+
File.read(list_path).split(/\r?\n/)
|
77
76
|
end
|
78
77
|
|
79
78
|
def root_path
|
@@ -89,6 +88,14 @@ module VersionedSeeds
|
|
89
88
|
@root_path = path
|
90
89
|
@root_path += '/' unless @root_path.nil? || @root_path.end_with?('/')
|
91
90
|
end
|
91
|
+
|
92
|
+
def list_path
|
93
|
+
@list_path ||= root_path + '.versioned_seeds'
|
94
|
+
end
|
95
|
+
|
96
|
+
def list_path=(path)
|
97
|
+
@list_path = path
|
98
|
+
end
|
92
99
|
end
|
93
100
|
|
94
101
|
extend ClassMethods
|
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.5.
|
4
|
+
version: 0.5.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-09-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -100,7 +100,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
100
100
|
version: '0'
|
101
101
|
segments:
|
102
102
|
- 0
|
103
|
-
hash: -
|
103
|
+
hash: -72128960382056869
|
104
104
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
@@ -109,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
109
|
version: '0'
|
110
110
|
segments:
|
111
111
|
- 0
|
112
|
-
hash: -
|
112
|
+
hash: -72128960382056869
|
113
113
|
requirements: []
|
114
114
|
rubyforge_project:
|
115
115
|
rubygems_version: 1.8.24
|