seed_dump 3.0.1 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0e74d0530b68a21db364e020b3b9fb049f219b3d
4
- data.tar.gz: 40996a973be8ce7e38b00640656207f745ac6c67
3
+ metadata.gz: a0b00614503dc059aec841b50bfdcdfb8a2c5251
4
+ data.tar.gz: 0fa97c98fb72a40a0cabb63f3880a820c6599ffd
5
5
  SHA512:
6
- metadata.gz: 01607738795403a50cefaae252e9e281ffb35efa48cd37b00e0f3335b59af201ca414a7144cde7a1b8fea314b059343627241bb854d4434bc8abe8f6f21805a1
7
- data.tar.gz: 18cede62be65f661943ff54442d71be8a503101adbd3a1dab27d8796c1bb32c03d5d83bacfa31ffd7533425a05bd4f2015260ead253c15c849a14737ebfaf358
6
+ metadata.gz: 74bc375add9785597f932cf72b3f71f47c915ee3fdb1623b3e24c62f7dd801ebd196f5798cb31344edfe792df7b6a5c572c2548a8b8d542fdd374dc34b6ee1e1
7
+ data.tar.gz: 9a14b0769f18890e25b5d85daa6f414b70573afef27d18e74f57bcd390286ddaf6a9e2260ae8b4c2d22180b7cf2a9848252b7b61024befe7efa5370fd0d379d7
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.0.1
1
+ 3.1.0
@@ -40,6 +40,8 @@ class SeedDump
40
40
  value.to_s
41
41
  when Date, Time, DateTime
42
42
  value.to_s(:db)
43
+ when Range
44
+ range_to_string(value)
43
45
  else
44
46
  value
45
47
  end
@@ -47,6 +49,12 @@ class SeedDump
47
49
  value.inspect
48
50
  end
49
51
 
52
+ def range_to_string(object)
53
+ from = object.begin.respond_to?(:infinite?) && object.begin.infinite? ? '' : object.begin
54
+ to = object.end.respond_to?(:infinite?) && object.end.infinite? ? '' : object.end
55
+ "[#{from},#{to}#{object.exclude_end? ? ')' : ']'}"
56
+ end
57
+
50
58
  def open_io(options)
51
59
  if options[:file].present?
52
60
  mode = options[:append] ? 'a+' : 'w+'
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "seed_dump"
8
- s.version = "3.0.1"
8
+ s.version = "3.1.0"
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", "Ryan Oblak"]
12
- s.date = "2013-12-30"
12
+ s.date = "2014-01-09"
13
13
  s.description = "Dump (parts) of your database to db/seeds.rb to get a headstart creating a meaningful seeds.rb file"
14
14
  s.email = "rroblak@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -112,5 +112,25 @@ describe SeedDump do
112
112
  SeedDump.dump(Sample, exclude: [:id, :created_at, :updated_at, :string, :float, :datetime]).should eq(expected_output)
113
113
  end
114
114
  end
115
+
116
+ context 'Range' do
117
+ it 'should dump a class with ranges' do
118
+ expected_output = "RangeSample.create!([\n {range_with_end_included: \"[1,3]\", range_with_end_excluded: \"[1,3)\", positive_infinite_range: \"[1,]\", negative_infinite_range: \"[,1]\", infinite_range: \"[,]\"}\n])\n"
119
+
120
+ SeedDump.dump([RangeSample.new]).should eq(expected_output)
121
+ end
122
+ end
123
+ end
124
+ end
125
+
126
+ class RangeSample
127
+ def attributes
128
+ {
129
+ "range_with_end_included" => (1..3),
130
+ "range_with_end_excluded" => (1...3),
131
+ "positive_infinite_range" => (1..Float::INFINITY),
132
+ "negative_infinite_range" => (-Float::INFINITY..1),
133
+ "infinite_range" => (-Float::INFINITY..Float::INFINITY)
134
+ }
115
135
  end
116
136
  end
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: 3.0.1
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rob Halff
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-12-30 00:00:00.000000000 Z
12
+ date: 2014-01-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport