seed_dump 0.3.3 → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG.rdoc CHANGED
@@ -1,5 +1,14 @@
1
1
  == Seed Dump
2
2
 
3
+ == 0.3.4 / 2011-07-14
4
+
5
+ * Skip models that aren't Derived from ActiveRecord [iconoclast]
6
+ * override the AR version of attribute_for_inspect to NOT truncate strings [sc0ttman]
7
+
8
+ == 0.3.3 / 2011-07-14
9
+
10
+ * solve sorting issue
11
+
3
12
  == 0.3.2 / 2011-04-22
4
13
 
5
14
  * fix broken APPEND option
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.3
1
+ 0.3.4
@@ -32,7 +32,7 @@ module SeedDump
32
32
  end
33
33
 
34
34
  def dumpAttribute(a_s,r,k,v)
35
- v = r.attribute_for_inspect(k)
35
+ v = attribute_for_inspect(r,k)
36
36
  if k == 'id' && @opts['with_id']
37
37
  @id_set_string = "{ |c| c.#{k} = #{v} }.save"
38
38
  else
@@ -66,8 +66,13 @@ module SeedDump
66
66
  def dumpModels
67
67
  @seed_rb = ""
68
68
  @models.sort.each do |model|
69
- puts "Adding #{model} seeds." if @verbose
70
- @seed_rb << dumpModel(model.constantize) << "\n\n"
69
+ m = model.constantize
70
+ if m.ancestors.include?(ActiveRecord::Base)
71
+ puts "Adding #{model} seeds." if @verbose
72
+ @seed_rb << dumpModel(m) << "\n\n"
73
+ else
74
+ puts "Skipping non-ActiveRecord model #{model}..." if @verbose
75
+ end
71
76
  end
72
77
  end
73
78
 
@@ -78,6 +83,19 @@ module SeedDump
78
83
  }
79
84
  end
80
85
 
86
+ #override the rails version of this function to NOT truncate strings
87
+ def attribute_for_inspect(r,k)
88
+ value = r.attributes[k]
89
+
90
+ if value.is_a?(String) && value.length > 50
91
+ "#{value}".inspect
92
+ elsif value.is_a?(Date) || value.is_a?(Time)
93
+ %("#{value.to_s(:db)}")
94
+ else
95
+ value.inspect
96
+ end
97
+ end
98
+
81
99
  def run(env)
82
100
 
83
101
  setup env
data/seed_dump.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{seed_dump}
8
- s.version = "0.3.3"
8
+ s.version = "0.3.4"
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"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: seed_dump
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: