seed_dump 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +7 -0
- data/VERSION +1 -1
- data/lib/tasks/seed_dump.rake +18 -14
- data/seed_dump.gemspec +15 -22
- data/test/seed_dump_test.rb +1 -1
- metadata +25 -42
- data/.gitignore +0 -21
data/CHANGELOG.rdoc
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.3
|
data/lib/tasks/seed_dump.rake
CHANGED
@@ -16,35 +16,39 @@ namespace :db do
|
|
16
16
|
models = opts['models'].split(',').collect {|x| x.underscore.singularize }
|
17
17
|
|
18
18
|
new_line = "\n"
|
19
|
-
|
20
19
|
puts "Appending seeds to #{opts['file']}." if opts['append']
|
21
20
|
|
22
21
|
seed_rb = ""
|
23
22
|
Dir['app/models/*.rb'].sort.each do |f|
|
24
|
-
|
23
|
+
model_name = File.basename(f, '.*')
|
25
24
|
if models.include?(model_name) || models.empty?
|
26
25
|
|
27
26
|
puts "Adding #{model_name.camelize} seeds."
|
28
27
|
|
29
|
-
|
28
|
+
create_hash = ""
|
30
29
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
30
|
+
model = model_name.camelize.constantize
|
31
|
+
arr = []
|
32
|
+
arr = model.find(:all, ar_options) unless opts['no-data']
|
33
|
+
arr = arr.empty? ? [model.new] : arr
|
34
|
+
arr.each_with_index { |r,i|
|
36
35
|
|
37
36
|
attr_s = [];
|
38
37
|
|
38
|
+
puts r.inspect
|
39
|
+
|
40
|
+
id_set_string = ''
|
39
41
|
r.attributes.each { |k,v|
|
40
|
-
v =
|
41
|
-
|
42
|
+
v = r.attribute_for_inspect(k)
|
43
|
+
if k == 'id' && opts['with_id']
|
44
|
+
id_set_string = "{ |c| c.#{k} = #{v} }.save"
|
45
|
+
else
|
46
|
+
attr_s.push("#{k.to_sym.inspect} => #{v}") unless k == 'id' && !opts['with_id']
|
47
|
+
end
|
42
48
|
}
|
43
|
-
|
44
|
-
create_hash << (i > 0 ? ",#{new_line}" : new_line) << indent << '{ ' << attr_s.join(', ') << ' }'
|
49
|
+
create_hash << (i > 0 ? "#{new_line}" : new_line) << "#{model_name.camelize}.create" << '( ' << attr_s.join(', ') << ' )' << id_set_string
|
45
50
|
}
|
46
|
-
|
47
|
-
seed_rb << "#{new_line}#{model_name.pluralize} = #{model_name.camelize}.create([#{create_hash}#{new_line}])#{new_line}"
|
51
|
+
seed_rb << "#{create_hash}#{new_line}#{new_line}"
|
48
52
|
end
|
49
53
|
end
|
50
54
|
|
data/seed_dump.gemspec
CHANGED
@@ -1,46 +1,39 @@
|
|
1
1
|
# Generated by jeweler
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{seed_dump}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Rob Halff"]
|
12
|
-
s.date = %q{
|
12
|
+
s.date = %q{2011-05-22}
|
13
13
|
s.description = %q{Dump (parts) of your database to db/seeds.rb to get a headstart creating a meaningful seeds.rb file}
|
14
14
|
s.email = %q{rob.halff@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"README.rdoc"
|
17
17
|
]
|
18
18
|
s.files = [
|
19
|
-
".
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
"test/test_helper.rb"
|
19
|
+
"CHANGELOG.rdoc",
|
20
|
+
"MIT-LICENSE",
|
21
|
+
"README.rdoc",
|
22
|
+
"Rakefile",
|
23
|
+
"VERSION",
|
24
|
+
"lib/seed_dump.rb",
|
25
|
+
"lib/seed_dump/railtie.rb",
|
26
|
+
"lib/tasks/seed_dump.rake",
|
27
|
+
"seed_dump.gemspec",
|
28
|
+
"test/seed_dump_test.rb",
|
29
|
+
"test/test_helper.rb"
|
31
30
|
]
|
32
31
|
s.homepage = %q{http://github.com/rhalff/seed_dump}
|
33
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
34
32
|
s.require_paths = ["lib"]
|
35
|
-
s.rubygems_version = %q{1.
|
33
|
+
s.rubygems_version = %q{1.6.2}
|
36
34
|
s.summary = %q{{Seed Dumper for Rails}}
|
37
|
-
s.test_files = [
|
38
|
-
"test/test_helper.rb",
|
39
|
-
"test/seed_dump_test.rb"
|
40
|
-
]
|
41
35
|
|
42
36
|
if s.respond_to? :specification_version then
|
43
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
44
37
|
s.specification_version = 3
|
45
38
|
|
46
39
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
data/test/seed_dump_test.rb
CHANGED
metadata
CHANGED
@@ -1,33 +1,25 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: seed_dump
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 2
|
8
|
-
- 2
|
9
|
-
version: 0.2.2
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.3
|
5
|
+
prerelease:
|
10
6
|
platform: ruby
|
11
|
-
authors:
|
7
|
+
authors:
|
12
8
|
- Rob Halff
|
13
9
|
autorequire:
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
|
-
|
17
|
-
date: 2010-08-01 00:00:00 +02:00
|
12
|
+
date: 2011-05-22 00:00:00.000000000 +02:00
|
18
13
|
default_executable:
|
19
14
|
dependencies: []
|
20
|
-
|
21
|
-
|
15
|
+
description: Dump (parts) of your database to db/seeds.rb to get a headstart creating
|
16
|
+
a meaningful seeds.rb file
|
22
17
|
email: rob.halff@gmail.com
|
23
18
|
executables: []
|
24
|
-
|
25
19
|
extensions: []
|
26
|
-
|
27
|
-
extra_rdoc_files:
|
20
|
+
extra_rdoc_files:
|
28
21
|
- README.rdoc
|
29
|
-
files:
|
30
|
-
- .gitignore
|
22
|
+
files:
|
31
23
|
- CHANGELOG.rdoc
|
32
24
|
- MIT-LICENSE
|
33
25
|
- README.rdoc
|
@@ -42,35 +34,26 @@ files:
|
|
42
34
|
has_rdoc: true
|
43
35
|
homepage: http://github.com/rhalff/seed_dump
|
44
36
|
licenses: []
|
45
|
-
|
46
37
|
post_install_message:
|
47
|
-
rdoc_options:
|
48
|
-
|
49
|
-
require_paths:
|
38
|
+
rdoc_options: []
|
39
|
+
require_paths:
|
50
40
|
- lib
|
51
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
41
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
52
42
|
none: false
|
53
|
-
requirements:
|
54
|
-
- -
|
55
|
-
- !ruby/object:Gem::Version
|
56
|
-
|
57
|
-
|
58
|
-
version: "0"
|
59
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
48
|
none: false
|
61
|
-
requirements:
|
62
|
-
- -
|
63
|
-
- !ruby/object:Gem::Version
|
64
|
-
|
65
|
-
- 0
|
66
|
-
version: "0"
|
49
|
+
requirements:
|
50
|
+
- - ! '>='
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
67
53
|
requirements: []
|
68
|
-
|
69
54
|
rubyforge_project:
|
70
|
-
rubygems_version: 1.
|
55
|
+
rubygems_version: 1.6.2
|
71
56
|
signing_key:
|
72
57
|
specification_version: 3
|
73
|
-
summary:
|
74
|
-
test_files:
|
75
|
-
- test/test_helper.rb
|
76
|
-
- test/seed_dump_test.rb
|
58
|
+
summary: ! '{Seed Dumper for Rails}'
|
59
|
+
test_files: []
|