seed 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/seed.rb +2 -2
- data/lib/seed/task.rb +1 -0
- data/tasks/seeds.rake +12 -0
- metadata +11 -12
- data/LICENSE +0 -23
- data/Rakefile +0 -92
data/lib/seed.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
class Seed
|
2
|
-
VERSION = '1.0.
|
2
|
+
VERSION = '1.0.2'
|
3
3
|
|
4
4
|
def self.plant(klass, name, attributes={}, &block)
|
5
5
|
raise RuntimeError, "You cannot overwrite an existing seed" if self.planted?(klass, name)
|
@@ -34,4 +34,4 @@ class ActiveRecord::Base
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|
37
|
-
end
|
37
|
+
end
|
data/lib/seed/task.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
load File.join(File.dirname(__FILE__), '..', '..', 'tasks', 'seeds.rake')
|
data/tasks/seeds.rake
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
namespace :db do
|
2
|
+
namespace :seed do
|
3
|
+
Dir[File.join(Rails.root, 'db', 'seeds', '*.rb')].each do |seed_file|
|
4
|
+
task_name = File.basename(seed_file, '.rb')
|
5
|
+
desc "Load the seed data from db/seeds/#{task_name}.rb"
|
6
|
+
task task_name => :environment do
|
7
|
+
require 'seed'
|
8
|
+
load(seed_file) if File.exist?(seed_file)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 1.0.
|
8
|
+
- 2
|
9
|
+
version: 1.0.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Jeremy Durham
|
@@ -14,28 +14,27 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-04-07 00:00:00 -04:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|
21
|
-
description:
|
21
|
+
description:
|
22
22
|
email: jeremydurham@gmail.com
|
23
23
|
executables: []
|
24
24
|
|
25
25
|
extensions: []
|
26
26
|
|
27
|
-
extra_rdoc_files:
|
28
|
-
|
29
|
-
- LICENSE
|
27
|
+
extra_rdoc_files: []
|
28
|
+
|
30
29
|
files:
|
31
|
-
-
|
32
|
-
- README
|
33
|
-
- Rakefile
|
30
|
+
- lib/seed/task.rb
|
34
31
|
- lib/seed.rb
|
32
|
+
- tasks/seeds.rake
|
35
33
|
- spec/db/schema.rb
|
36
34
|
- spec/seed_spec.rb
|
35
|
+
- README
|
37
36
|
has_rdoc: true
|
38
|
-
homepage:
|
37
|
+
homepage: http://www.jeremydurham.com
|
39
38
|
licenses: []
|
40
39
|
|
41
40
|
post_install_message:
|
@@ -63,6 +62,6 @@ rubyforge_project:
|
|
63
62
|
rubygems_version: 1.3.6
|
64
63
|
signing_key:
|
65
64
|
specification_version: 3
|
66
|
-
summary: Another simple seeding library
|
65
|
+
summary: Another simple seeding library for Rails
|
67
66
|
test_files: []
|
68
67
|
|
data/LICENSE
DELETED
@@ -1,23 +0,0 @@
|
|
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/Rakefile
DELETED
@@ -1,92 +0,0 @@
|
|
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::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", "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 Rakefile) + Dir.glob("{lib,spec}/**/*")
|
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
|
-
|
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'
|