seed 1.0.3 → 1.1.0.pre

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/LICENSE ADDED
@@ -0,0 +1,23 @@
1
+ LICENSE
2
+
3
+ The MIT License
4
+
5
+ Copyright (c) 2008-2009 Jeremy Durham
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ of this software and associated documentation files (the "Software"), to deal
9
+ in the Software without restriction, including without limitation the rights
10
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the Software is
12
+ furnished to do so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in
15
+ all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
+ THE SOFTWARE.
data/README.md CHANGED
@@ -6,6 +6,11 @@ Another seeding library for Ruby
6
6
  Usage
7
7
  -----
8
8
 
9
+ Rails 3 and Ruby 1.9
10
+ --------------------
11
+
12
+ Seed is Rails 3 and Ruby 1.9 compatible
13
+
9
14
  Planting a seed
10
15
  ---------------
11
16
 
@@ -31,6 +36,8 @@ Attempting to retrieve a non-existent seed will result in an error.
31
36
  Rake Task
32
37
  ---------
33
38
 
39
+ **NOTE**: This step is only needed for Rails 2.x
40
+
34
41
  Seed comes with a rake task to make creating multiple "seeds" easier. In your Rakefile, add the following:
35
42
 
36
43
  require 'seed/task'
data/Rakefile ADDED
@@ -0,0 +1,92 @@
1
+ require 'rubygems'
2
+ require 'rake/gempackagetask'
3
+ require 'rubygems/specification'
4
+ require 'rake/rdoctask'
5
+ require 'spec/rake/spectask'
6
+ require 'active_record'
7
+ require File.join(File.dirname(__FILE__), 'lib', 'seed')
8
+
9
+ NAME = "seed"
10
+ AUTHOR = "Jeremy Durham"
11
+ EMAIL = "jeremydurham@gmail.com"
12
+ HOMEPAGE = ""
13
+ SUMMARY = "Another simple seeding library"
14
+
15
+ # Used by release task
16
+ GEM_NAME = NAME
17
+ PROJECT_URL = HOMEPAGE
18
+ PROJECT_SUMMARY = SUMMARY
19
+ PROJECT_DESCRIPTION = SUMMARY
20
+
21
+ PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
22
+ GEM_VERSION = Seed::Base::VERSION + PKG_BUILD
23
+ RELEASE_NAME = "REL #{GEM_VERSION}"
24
+ #
25
+ # ==== Gemspec and installation
26
+ #
27
+
28
+ spec = Gem::Specification.new do |s|
29
+ s.name = NAME
30
+ s.version = Seed::Base::VERSION
31
+ s.platform = Gem::Platform::RUBY
32
+ s.has_rdoc = true
33
+ s.extra_rdoc_files = ["README.md", "LICENSE"]
34
+ s.summary = SUMMARY
35
+ s.description = s.summary
36
+ s.author = AUTHOR
37
+ s.email = EMAIL
38
+ s.homepage = HOMEPAGE
39
+ s.require_path = 'lib'
40
+ s.files = %w(LICENSE README.md Rakefile) + Dir.glob("{lib,spec,tasks}/**/*")
41
+ end
42
+
43
+ Rake::GemPackageTask.new(spec) do |pkg|
44
+ pkg.gem_spec = spec
45
+ end
46
+
47
+ desc "install the gem locally"
48
+ task :install => [:clean, :package] do
49
+ sh %{sudo gem install pkg/#{NAME}-#{Seed::Base::VERSION} --no-update-sources}
50
+ end
51
+
52
+ desc "create a gemspec file"
53
+ task :make_spec do
54
+ File.open("#{GEM_NAME}.gemspec", "w") do |file|
55
+ file.puts spec.to_ruby
56
+ end
57
+ end
58
+
59
+ desc "Run coverage suite"
60
+ task :rcov do
61
+ require 'fileutils'
62
+ FileUtils.rm_rf("coverage") if File.directory?("coverage")
63
+ FileUtils.mkdir("coverage")
64
+ path = File.expand_path(Dir.pwd)
65
+ files = Dir["spec/**/*_spec.rb"]
66
+ files.each do |spec|
67
+ puts "Getting coverage for #{File.expand_path(spec)}"
68
+ command = %{rcov #{File.expand_path(spec)} --aggregate #{path}/coverage/data.data}
69
+ command += " --no-html" unless spec == files.last
70
+ `#{command} 2>&1`
71
+ end
72
+ end
73
+
74
+ file_list = FileList['spec/**/*_spec.rb']
75
+
76
+ desc "Run all examples"
77
+ Spec::Rake::SpecTask.new('spec') do |t|
78
+ t.spec_files = file_list
79
+ end
80
+
81
+ namespace :spec do
82
+ desc "Run all examples with RCov"
83
+ Spec::Rake::SpecTask.new('rcov') do |t|
84
+ t.spec_files = file_list
85
+ t.rcov = true
86
+ t.rcov_dir = "doc/coverage"
87
+ t.rcov_opts = ['--exclude', 'spec']
88
+ end
89
+ end
90
+
91
+ desc 'Default: run unit tests.'
92
+ task :default => 'spec'
data/lib/seed.rb CHANGED
@@ -1,46 +1,2 @@
1
- class Seed
2
- VERSION = '1.0.3'
3
- @seeds = {}
4
-
5
- def self.plant(klass, name, attributes={}, &block)
6
- raise RuntimeError, "You cannot overwrite an existing seed" if self.planted?(klass, name)
7
-
8
- if block_given?
9
- @seeds[klass][name] = klass.create!(&block)
10
- else
11
- @seeds[klass][name] = klass.create!(attributes)
12
- end
13
- end
14
-
15
- def self.retrieve(klass, name)
16
- self.planted?(klass, name) || raise(RuntimeError, "No seed #{name} for #{klass}")
17
- end
18
-
19
- def self.planted?(klass, name)
20
- @seeds[klass] ||= {}
21
- @seeds[klass][name]
22
- end
23
-
24
- def self.row(klass)
25
- @seeds[klass]
26
- end
27
-
28
- end
29
-
30
- class ActiveRecord::Base
31
- def self.seed(*options, &block)
32
- if block_given?
33
- Seed.plant(self, options.first, &block)
34
- else
35
- if options.length > 1
36
- Seed.plant(self, options.first, options.last)
37
- else
38
- Seed.retrieve(self, options.first)
39
- end
40
- end
41
- end
42
-
43
- def self.seeds
44
- Seed.row(self) || raise(RuntimeError, "No row of seeds for #{self}")
45
- end
46
- end
1
+ require File.join(File.dirname(__FILE__), 'seed', 'railtie') if defined?(Rails)
2
+ require File.join(File.dirname(__FILE__), 'seed', 'base')
data/lib/seed/base.rb ADDED
@@ -0,0 +1,47 @@
1
+ module Seed
2
+ class Base
3
+ VERSION = '1.1.0.pre'
4
+ @seeds = {}
5
+
6
+ def self.plant(klass, name, attributes={}, &block)
7
+ raise RuntimeError, "You cannot overwrite an existing seed" if self.planted?(klass, name)
8
+
9
+ if block_given?
10
+ @seeds[klass][name] = klass.create!(&block)
11
+ else
12
+ @seeds[klass][name] = klass.create!(attributes)
13
+ end
14
+ end
15
+
16
+ def self.retrieve(klass, name)
17
+ self.planted?(klass, name) || raise(RuntimeError, "No seed #{name} for #{klass}")
18
+ end
19
+
20
+ def self.planted?(klass, name)
21
+ @seeds[klass] ||= {}
22
+ @seeds[klass][name]
23
+ end
24
+
25
+ def self.row(klass)
26
+ @seeds[klass]
27
+ end
28
+ end
29
+ end
30
+
31
+ class ActiveRecord::Base
32
+ def self.seed(*options, &block)
33
+ if block_given?
34
+ Seed::Base.plant(self, options.first, &block)
35
+ else
36
+ if options.length > 1
37
+ Seed::Base.plant(self, options.first, options.last)
38
+ else
39
+ Seed::Base.retrieve(self, options.first)
40
+ end
41
+ end
42
+ end
43
+
44
+ def self.seeds
45
+ Seed::Base.row(self) || raise(RuntimeError, "No row of seeds for #{self}")
46
+ end
47
+ end
@@ -0,0 +1,7 @@
1
+ module Seed
2
+ class Railtie < Rails::Railtie
3
+ rake_tasks do
4
+ load File.join(File.dirname(__FILE__), '..', '..', 'tasks/seeds.rake')
5
+ end
6
+ end
7
+ end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: seed
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
4
+ prerelease: true
5
5
  segments:
6
6
  - 1
7
+ - 1
7
8
  - 0
8
- - 3
9
- version: 1.0.3
9
+ - pre
10
+ version: 1.1.0.pre
10
11
  platform: ruby
11
12
  authors:
12
13
  - Jeremy Durham
@@ -14,27 +15,32 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-06-12 00:00:00 -04:00
18
+ date: 2010-08-23 00:00:00 -04:00
18
19
  default_executable:
19
20
  dependencies: []
20
21
 
21
- description:
22
+ description: Another simple seeding library
22
23
  email: jeremydurham@gmail.com
23
24
  executables: []
24
25
 
25
26
  extensions: []
26
27
 
27
- extra_rdoc_files: []
28
-
28
+ extra_rdoc_files:
29
+ - README.md
30
+ - LICENSE
29
31
  files:
32
+ - LICENSE
33
+ - README.md
34
+ - Rakefile
35
+ - lib/seed/base.rb
36
+ - lib/seed/railtie.rb
30
37
  - lib/seed/task.rb
31
38
  - lib/seed.rb
32
- - tasks/seeds.rake
33
39
  - spec/db/schema.rb
34
40
  - spec/seed_spec.rb
35
- - README.md
41
+ - tasks/seeds.rake
36
42
  has_rdoc: true
37
- homepage: http://www.jeremydurham.com
43
+ homepage: ""
38
44
  licenses: []
39
45
 
40
46
  post_install_message:
@@ -43,6 +49,7 @@ rdoc_options: []
43
49
  require_paths:
44
50
  - lib
45
51
  required_ruby_version: !ruby/object:Gem::Requirement
52
+ none: false
46
53
  requirements:
47
54
  - - ">="
48
55
  - !ruby/object:Gem::Version
@@ -50,18 +57,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
50
57
  - 0
51
58
  version: "0"
52
59
  required_rubygems_version: !ruby/object:Gem::Requirement
60
+ none: false
53
61
  requirements:
54
- - - ">="
62
+ - - ">"
55
63
  - !ruby/object:Gem::Version
56
64
  segments:
57
- - 0
58
- version: "0"
65
+ - 1
66
+ - 3
67
+ - 1
68
+ version: 1.3.1
59
69
  requirements: []
60
70
 
61
71
  rubyforge_project:
62
- rubygems_version: 1.3.6
72
+ rubygems_version: 1.3.7
63
73
  signing_key:
64
74
  specification_version: 3
65
- summary: Another simple seeding library for Rails
75
+ summary: Another simple seeding library
66
76
  test_files: []
67
77