seed 1.1.0.pre → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +7 -13
- data/lib/seed.rb +1 -0
- data/lib/seed/base.rb +6 -2
- data/lib/seed/version.rb +3 -0
- data/seed.gemspec +22 -0
- data/spec/seed_spec.rb +7 -1
- metadata +17 -15
data/Rakefile
CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
|
|
2
2
|
require 'rake/gempackagetask'
|
3
3
|
require 'rubygems/specification'
|
4
4
|
require 'rake/rdoctask'
|
5
|
-
require '
|
5
|
+
require 'rspec/core/rake_task'
|
6
6
|
require 'active_record'
|
7
7
|
require File.join(File.dirname(__FILE__), 'lib', 'seed')
|
8
8
|
|
@@ -19,7 +19,7 @@ PROJECT_SUMMARY = SUMMARY
|
|
19
19
|
PROJECT_DESCRIPTION = SUMMARY
|
20
20
|
|
21
21
|
PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
|
22
|
-
GEM_VERSION = Seed::
|
22
|
+
GEM_VERSION = Seed::VERSION + PKG_BUILD
|
23
23
|
RELEASE_NAME = "REL #{GEM_VERSION}"
|
24
24
|
#
|
25
25
|
# ==== Gemspec and installation
|
@@ -27,7 +27,7 @@ RELEASE_NAME = "REL #{GEM_VERSION}"
|
|
27
27
|
|
28
28
|
spec = Gem::Specification.new do |s|
|
29
29
|
s.name = NAME
|
30
|
-
s.version = Seed::
|
30
|
+
s.version = Seed::VERSION
|
31
31
|
s.platform = Gem::Platform::RUBY
|
32
32
|
s.has_rdoc = true
|
33
33
|
s.extra_rdoc_files = ["README.md", "LICENSE"]
|
@@ -46,7 +46,7 @@ end
|
|
46
46
|
|
47
47
|
desc "install the gem locally"
|
48
48
|
task :install => [:clean, :package] do
|
49
|
-
sh %{sudo gem install pkg/#{NAME}-#{Seed::
|
49
|
+
sh %{sudo gem install pkg/#{NAME}-#{Seed::VERSION} --no-update-sources}
|
50
50
|
end
|
51
51
|
|
52
52
|
desc "create a gemspec file"
|
@@ -71,22 +71,16 @@ task :rcov do
|
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
74
|
-
file_list = FileList['spec/**/*_spec.rb']
|
75
|
-
|
76
74
|
desc "Run all examples"
|
77
|
-
|
78
|
-
t.spec_files = file_list
|
75
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
79
76
|
end
|
80
77
|
|
81
78
|
namespace :spec do
|
82
79
|
desc "Run all examples with RCov"
|
83
|
-
|
84
|
-
t.spec_files = file_list
|
80
|
+
RSpec::Core::RakeTask.new(:rcov) do |t|
|
85
81
|
t.rcov = true
|
86
|
-
t.rcov_dir = "doc/coverage"
|
87
|
-
t.rcov_opts = ['--exclude', 'spec']
|
88
82
|
end
|
89
83
|
end
|
90
84
|
|
91
85
|
desc 'Default: run unit tests.'
|
92
|
-
task :default => 'spec'
|
86
|
+
task :default => 'spec'
|
data/lib/seed.rb
CHANGED
data/lib/seed/base.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
module Seed
|
2
2
|
class Base
|
3
|
-
VERSION = '1.1.0.pre'
|
4
3
|
@seeds = {}
|
5
4
|
|
6
5
|
def self.plant(klass, name, attributes={}, &block)
|
@@ -9,7 +8,12 @@ module Seed
|
|
9
8
|
if block_given?
|
10
9
|
@seeds[klass][name] = klass.create!(&block)
|
11
10
|
else
|
12
|
-
|
11
|
+
seed = klass.new
|
12
|
+
attributes.each do |attribute, value|
|
13
|
+
seed.send(:"#{attribute}=", value)
|
14
|
+
end
|
15
|
+
seed.save!
|
16
|
+
@seeds[klass][name] = seed
|
13
17
|
end
|
14
18
|
end
|
15
19
|
|
data/lib/seed/version.rb
ADDED
data/seed.gemspec
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib/', __FILE__)
|
3
|
+
$:.unshift lib unless $:.include?(lib)
|
4
|
+
|
5
|
+
require 'seed/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = "seed"
|
9
|
+
s.version = Seed::VERSION
|
10
|
+
s.platform = Gem::Platform::RUBY
|
11
|
+
s.authors = ['Jeremy Durham']
|
12
|
+
s.email = ['jeremydurham@gmail.com']
|
13
|
+
s.homepage = 'http://www.onemanwonder.com/projects/seed'
|
14
|
+
s.summary = 'Another simple seeding library'
|
15
|
+
s.description = 'Another simple seeding library'
|
16
|
+
|
17
|
+
s.required_rubygems_version = ">= 1.3.7"
|
18
|
+
|
19
|
+
s.files = `git ls-files`.split("\n")
|
20
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
21
|
+
s.require_paths = ["lib"]
|
22
|
+
end
|
data/spec/seed_spec.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'rubygems'
|
2
|
-
require '
|
2
|
+
require 'rspec'
|
3
3
|
require 'active_record'
|
4
4
|
require 'seed'
|
5
5
|
|
@@ -44,6 +44,11 @@ describe Seed do
|
|
44
44
|
User.seed(:tester, :email => 'test@testing.com')
|
45
45
|
end.should change(User, :count).by(1)
|
46
46
|
end
|
47
|
+
|
48
|
+
it "should set a protected attribute" do
|
49
|
+
User.seed(:another_tester, :email => 'another_tester@testing.com', :roles => [Role.seed(:user, :name => 'User', :role => 'user')])
|
50
|
+
User.seed(:another_tester).roles.should_not be_nil
|
51
|
+
end
|
47
52
|
|
48
53
|
describe "given a block" do
|
49
54
|
it "should create a new seed" do
|
@@ -60,6 +65,7 @@ describe Seed do
|
|
60
65
|
user.email = 'user_with_role@example.com'
|
61
66
|
user.roles = [Role.seed(:system_administrator)]
|
62
67
|
end
|
68
|
+
User.seed(:user_with_role).roles.should_not be_nil
|
63
69
|
end
|
64
70
|
end
|
65
71
|
end
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: seed
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
4
|
+
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
|
10
|
-
version: 1.1.0.pre
|
9
|
+
version: 1.1.0
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Jeremy Durham
|
@@ -15,32 +14,34 @@ autorequire:
|
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date: 2010-
|
17
|
+
date: 2010-11-19 00:00:00 -05:00
|
19
18
|
default_executable:
|
20
19
|
dependencies: []
|
21
20
|
|
22
21
|
description: Another simple seeding library
|
23
|
-
email:
|
22
|
+
email:
|
23
|
+
- jeremydurham@gmail.com
|
24
24
|
executables: []
|
25
25
|
|
26
26
|
extensions: []
|
27
27
|
|
28
|
-
extra_rdoc_files:
|
29
|
-
|
30
|
-
- LICENSE
|
28
|
+
extra_rdoc_files: []
|
29
|
+
|
31
30
|
files:
|
32
31
|
- LICENSE
|
33
32
|
- README.md
|
34
33
|
- Rakefile
|
34
|
+
- lib/seed.rb
|
35
35
|
- lib/seed/base.rb
|
36
36
|
- lib/seed/railtie.rb
|
37
37
|
- lib/seed/task.rb
|
38
|
-
- lib/seed.rb
|
38
|
+
- lib/seed/version.rb
|
39
|
+
- seed.gemspec
|
39
40
|
- spec/db/schema.rb
|
40
41
|
- spec/seed_spec.rb
|
41
42
|
- tasks/seeds.rake
|
42
43
|
has_rdoc: true
|
43
|
-
homepage:
|
44
|
+
homepage: http://www.onemanwonder.com/projects/seed
|
44
45
|
licenses: []
|
45
46
|
|
46
47
|
post_install_message:
|
@@ -59,13 +60,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
59
60
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
61
|
none: false
|
61
62
|
requirements:
|
62
|
-
- - "
|
63
|
+
- - ">="
|
63
64
|
- !ruby/object:Gem::Version
|
64
65
|
segments:
|
65
66
|
- 1
|
66
67
|
- 3
|
67
|
-
-
|
68
|
-
version: 1.3.
|
68
|
+
- 7
|
69
|
+
version: 1.3.7
|
69
70
|
requirements: []
|
70
71
|
|
71
72
|
rubyforge_project:
|
@@ -73,5 +74,6 @@ rubygems_version: 1.3.7
|
|
73
74
|
signing_key:
|
74
75
|
specification_version: 3
|
75
76
|
summary: Another simple seeding library
|
76
|
-
test_files:
|
77
|
-
|
77
|
+
test_files:
|
78
|
+
- spec/db/schema.rb
|
79
|
+
- spec/seed_spec.rb
|