versioned_seeds 0.1.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.travis.yml ADDED
@@ -0,0 +1 @@
1
+ rvm: 1.9.2
data/README.mdown CHANGED
@@ -1,4 +1,4 @@
1
- # Versioned Seeds
1
+ # Versioned Seeds [![Build Status](https://secure.travis-ci.org/[YOUR_GITHUB_USERNAME]/[YOUR_PROJECT_NAME].png)](http://travis-ci.org/[YOUR_GITHUB_USERNAME]/[YOUR_PROJECT_NAME])
2
2
 
3
3
  Versioned Seeds is an alternative to Rails seeds. It allows to store your seeds in several files and prevent from re-seeding.
4
4
 
@@ -5,6 +5,10 @@ module VersionedSeeds
5
5
  require "versioned_seeds/railtie" if defined?(Rails)
6
6
 
7
7
  module ClassMethods # :nodoc:
8
+ def configure
9
+ yield self
10
+ end
11
+
8
12
  # Loads the next seeding script
9
13
  def next(loaded=already_loaded)
10
14
  load next_seed(loaded)
@@ -43,9 +47,9 @@ module VersionedSeeds
43
47
  write_loaded loaded
44
48
  end
45
49
 
46
- # Returns the files located in the rails_root/db/seeds folder sorted by version
50
+ # Returns the files located in the <root_path>/db/seeds folder sorted by version
47
51
  def seeds
48
- Dir[Rails.root + 'db/seeds/*.rb'].inject([]) { |list, file|
52
+ Dir[root_path + 'db/seeds/*.rb'].inject([]) { |list, file|
49
53
  filename = File.basename(file)
50
54
  version = filename[/^(\d+)_/, 1]
51
55
 
@@ -59,7 +63,7 @@ module VersionedSeeds
59
63
  # Writes the versions of the loaded script to the .versionned_seeds file
60
64
  def write_loaded(loaded)
61
65
  if loaded.any?
62
- File.open(Rails.root + '.versioned_seeds', 'a') do |f|
66
+ File.open(root_path + '.versioned_seeds', 'a') do |f|
63
67
  loaded.each { |seed| f.puts seed.version }
64
68
  end
65
69
  else
@@ -69,10 +73,24 @@ module VersionedSeeds
69
73
 
70
74
  # Returns the list of already loaded scripts
71
75
  def already_loaded
72
- file = Rails.root + '.versioned_seeds'
76
+ file = root_path + '.versioned_seeds'
73
77
  return [0] unless File.exists?(file)
74
78
  File.read(file).split(/\r?\n/)
75
79
  end
80
+
81
+ def root_path
82
+ @root_path ||= Rails.root if defined?(Rails)
83
+ return @root_path if @root_path
84
+ raise "VersionedSeeds.root_path is not set.\n" \
85
+ "VersionedSeeds.configure do |config|\n" \
86
+ " config.root_path = '/root/of/your/app/'\n" \
87
+ "end"
88
+ end
89
+
90
+ def root_path=(path)
91
+ @root_path = path
92
+ @root_path += '/' unless @root_path.end_with?('/')
93
+ end
76
94
  end
77
95
 
78
96
  extend ClassMethods
@@ -1,3 +1,3 @@
1
1
  module VersionedSeeds
2
- VERSION = "0.1.2"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -17,4 +17,5 @@ Gem::Specification.new do |gem|
17
17
 
18
18
  gem.add_development_dependency 'rake', '~> 0.9'
19
19
  gem.add_development_dependency 'rspec', '>= 2'
20
+ gem.add_development_dependency 'rails', '>= 3'
20
21
  end
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.1.2
4
+ version: 0.2.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: 2011-12-05 00:00:00.000000000Z
12
+ date: 2012-04-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
- requirement: &70116700821940 !ruby/object:Gem::Requirement
16
+ requirement: &70256828457620 !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: *70116700821940
24
+ version_requirements: *70256828457620
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &70116700821220 !ruby/object:Gem::Requirement
27
+ requirement: &70256828457120 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,18 @@ dependencies:
32
32
  version: '2'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70116700821220
35
+ version_requirements: *70256828457120
36
+ - !ruby/object:Gem::Dependency
37
+ name: rails
38
+ requirement: &70256823956720 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '3'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70256823956720
36
47
  description: Manage your seed scripts by versioning them
37
48
  email:
38
49
  - scourtois@cubyx.fr
@@ -42,6 +53,7 @@ extra_rdoc_files: []
42
53
  files:
43
54
  - .gitignore
44
55
  - .rspec
56
+ - .travis.yml
45
57
  - Gemfile
46
58
  - README.mdown
47
59
  - Rakefile
@@ -77,7 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
77
89
  version: '0'
78
90
  requirements: []
79
91
  rubyforge_project:
80
- rubygems_version: 1.8.10
92
+ rubygems_version: 1.8.15
81
93
  signing_key:
82
94
  specification_version: 3
83
95
  summary: Versioned Seeds provides a very simple way to manage your seed scripts by
@@ -88,3 +100,4 @@ test_files:
88
100
  - spec/rails_root/db/seeds/20111203000002_file2.rb
89
101
  - spec/rails_root/db/seeds/20111203000003_file3.rb
90
102
  - spec/versioned_seeds_spec.rb
103
+ has_rdoc: