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 CHANGED
@@ -0,0 +1,7 @@
1
+ == Seed Dump
2
+
3
+ == 0.2.3 / 2011-04-22
4
+
5
+ * properly quote any value (also fixes Time value generation)
6
+ * solve issue when specifying WITH_ID [David Guthu]
7
+
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.2
1
+ 0.2.3
@@ -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
- model_name = File.basename(f, '.*')
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
- create_hash = ""
28
+ create_hash = ""
30
29
 
31
- model = model_name.camelize.constantize
32
- arr = []
33
- arr = model.find(:all, ar_options) unless opts['no-data']
34
- arr = arr.empty? ? [model.new] : arr
35
- arr.each_with_index { |r,i|
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 = v.class == Time ? "\"#{v}\"" : v.inspect
41
- attr_s.push("#{k.to_sym.inspect} => #{v}") unless k == 'id' && !opts['with_id']
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 the gemspec command
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.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{2010-08-01}
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
- ".gitignore",
20
- "CHANGELOG.rdoc",
21
- "MIT-LICENSE",
22
- "README.rdoc",
23
- "Rakefile",
24
- "VERSION",
25
- "lib/seed_dump.rb",
26
- "lib/seed_dump/railtie.rb",
27
- "lib/tasks/seed_dump.rake",
28
- "seed_dump.gemspec",
29
- "test/seed_dump_test.rb",
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.3.7}
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
@@ -2,7 +2,7 @@ require 'test_helper'
2
2
 
3
3
  class SeedDumpTest < ActiveSupport::TestCase
4
4
  # Replace this with your real tests.
5
- test "the truth" do
5
+ test "test WITH_ID" do
6
6
  assert true
7
7
  end
8
8
  end
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
- prerelease: false
5
- segments:
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
- description: Dump (parts) of your database to db/seeds.rb to get a headstart creating a meaningful seeds.rb file
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
- - --charset=UTF-8
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
- segments:
57
- - 0
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
- segments:
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.3.7
55
+ rubygems_version: 1.6.2
71
56
  signing_key:
72
57
  specification_version: 3
73
- summary: "{Seed Dumper for Rails}"
74
- test_files:
75
- - test/test_helper.rb
76
- - test/seed_dump_test.rb
58
+ summary: ! '{Seed Dumper for Rails}'
59
+ test_files: []
data/.gitignore DELETED
@@ -1,21 +0,0 @@
1
- ## MAC OS
2
- .DS_Store
3
-
4
- ## TEXTMATE
5
- *.tmproj
6
- tmtags
7
-
8
- ## EMACS
9
- *~
10
- \#*
11
- .\#*
12
-
13
- ## VIM
14
- *.swp
15
-
16
- ## PROJECT::GENERAL
17
- coverage
18
- rdoc
19
- pkg
20
-
21
- ## PROJECT::SPECIFIC