seed 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1,75 +1,9 @@
1
1
  require 'rubygems'
2
+ require 'active_record'
2
3
  require 'rake/gempackagetask'
3
4
  require 'rubygems/specification'
4
5
  require 'rake/rdoctask'
5
6
  require 'rspec/core/rake_task'
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::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::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::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
7
 
74
8
  desc "Run all examples"
75
9
  RSpec::Core::RakeTask.new(:spec) do |t|
@@ -79,8 +13,8 @@ namespace :spec do
79
13
  desc "Run all examples with RCov"
80
14
  RSpec::Core::RakeTask.new(:rcov) do |t|
81
15
  t.rcov = true
82
- end
16
+ end
83
17
  end
84
18
 
85
19
  desc 'Default: run unit tests.'
86
- task :default => 'spec'
20
+ task :default => 'spec'
@@ -1,3 +1,7 @@
1
- require File.join(File.dirname(__FILE__), 'seed', 'railtie') if defined?(Rails)
1
+ require File.join(File.dirname(__FILE__), 'seed', 'railtie') if defined?(Rails::Railtie)
2
2
  require File.join(File.dirname(__FILE__), 'seed', 'base')
3
- require File.join(File.dirname(__FILE__), 'seed', 'version')
3
+ require File.join(File.dirname(__FILE__), 'seed', 'version')
4
+
5
+ class MissingRowError < StandardError; end
6
+ class MissingSeedError < StandardError; end
7
+ class SeedOverwriteError < StandardError; end
@@ -3,7 +3,7 @@ module Seed
3
3
  @seeds = {}
4
4
 
5
5
  def self.plant(klass, name, attributes={}, &block)
6
- raise RuntimeError, "You cannot overwrite an existing seed" if self.planted?(klass, name)
6
+ raise SeedOverwriteError, "You cannot overwrite an existing seed" if self.planted?(klass, name)
7
7
 
8
8
  if block_given?
9
9
  @seeds[klass][name] = klass.create!(&block)
@@ -18,7 +18,7 @@ module Seed
18
18
  end
19
19
 
20
20
  def self.retrieve(klass, name)
21
- self.planted?(klass, name) || raise(RuntimeError, "No seed #{name} for #{klass}")
21
+ self.planted?(klass, name) || raise(MissingSeedError, "No seed #{name} for #{klass}")
22
22
  end
23
23
 
24
24
  def self.planted?(klass, name)
@@ -27,7 +27,7 @@ module Seed
27
27
  end
28
28
 
29
29
  def self.row(klass)
30
- @seeds[klass]
30
+ @seeds[klass] || raise(MissingRowError, "No row of seeds for #{self}")
31
31
  end
32
32
  end
33
33
  end
@@ -46,6 +46,6 @@ class ActiveRecord::Base
46
46
  end
47
47
 
48
48
  def self.seeds
49
- Seed::Base.row(self) || raise(RuntimeError, "No row of seeds for #{self}")
49
+ Seed::Base.row(self)
50
50
  end
51
51
  end
@@ -1,3 +1,3 @@
1
1
  module Seed
2
- VERSION = '1.1.1'
2
+ VERSION = '1.1.2'
3
3
  end
@@ -32,11 +32,11 @@ describe Seed do
32
32
  end
33
33
 
34
34
  describe "planting a seed" do
35
- it "should raise a RuntimeError when trying to overwrite a seed" do
35
+ it "should raise a SeedOverwriteError when trying to overwrite a seed" do
36
36
  User.seed(:first, :email => 'test@testing.com')
37
37
  lambda do
38
38
  User.seed(:first, :email => 'testing@test.com')
39
- end.should raise_error(RuntimeError)
39
+ end.should raise_error(SeedOverwriteError)
40
40
  end
41
41
 
42
42
  it "should create a new seed given valid attributes" do
@@ -71,10 +71,10 @@ describe Seed do
71
71
  end
72
72
 
73
73
  describe "retrieving a seed" do
74
- it "should raise a RuntimeError when trying to retrieve an invalid seed" do
74
+ it "should raise a MissingSeedError when trying to retrieve an invalid seed" do
75
75
  lambda do
76
76
  User.seed(:invalid_user)
77
- end.should raise_error(RuntimeError)
77
+ end.should raise_error(MissingSeedError)
78
78
  end
79
79
 
80
80
  it "should return a seed" do
@@ -84,10 +84,10 @@ describe Seed do
84
84
  end
85
85
 
86
86
  describe "retrieving a row" do
87
- it "should raise a RuntimeError when retrieving an invalid row" do
87
+ it "should raise a MissingRowError when retrieving an invalid row" do
88
88
  lambda do
89
89
  Admin.seeds
90
- end.should raise_error(RuntimeError)
90
+ end.should raise_error(MissingRowError)
91
91
  end
92
92
 
93
93
  it "should return a row of seeds" do
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: seed
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ prerelease: false
5
+ segments:
6
+ - 1
7
+ - 1
8
+ - 2
9
+ version: 1.1.2
5
10
  platform: ruby
6
11
  authors:
7
12
  - Jeremy Durham
@@ -9,7 +14,7 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2010-11-19 00:00:00 -05:00
17
+ date: 2010-12-03 00:00:00 -05:00
13
18
  default_executable:
14
19
  dependencies: []
15
20
 
@@ -45,21 +50,27 @@ rdoc_options: []
45
50
  require_paths:
46
51
  - lib
47
52
  required_ruby_version: !ruby/object:Gem::Requirement
53
+ none: false
48
54
  requirements:
49
55
  - - ">="
50
56
  - !ruby/object:Gem::Version
57
+ segments:
58
+ - 0
51
59
  version: "0"
52
- version:
53
60
  required_rubygems_version: !ruby/object:Gem::Requirement
61
+ none: false
54
62
  requirements:
55
63
  - - ">="
56
64
  - !ruby/object:Gem::Version
65
+ segments:
66
+ - 1
67
+ - 3
68
+ - 6
57
69
  version: 1.3.6
58
- version:
59
70
  requirements: []
60
71
 
61
72
  rubyforge_project:
62
- rubygems_version: 1.3.5
73
+ rubygems_version: 1.3.7
63
74
  signing_key:
64
75
  specification_version: 3
65
76
  summary: Another simple seeding library