rest_model 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,7 +4,7 @@ RestModel::Configuration.configure do |c|
4
4
  c.true_value = "X"
5
5
  c.false_value = ""
6
6
  c.date_format = "%Y%m%d"
7
- c.datetime_format = "%a %b %d %H:%M:%S %Y"
7
+ c.date_time_format = "%a %b %d %H:%M:%S %Y"
8
8
  end
9
9
 
10
10
  class Customer < RestModel
@@ -38,12 +38,12 @@ class RestModel
38
38
  @date_format = format
39
39
  end
40
40
 
41
- def datetime_format
42
- @datetime_format
41
+ def date_time_format
42
+ @date_time_format
43
43
  end
44
44
 
45
- def datetime_format=(format)
46
- @datetime_format = format
45
+ def date_time_format=(format)
46
+ @date_time_format = format
47
47
  end
48
48
 
49
49
  def configure
@@ -4,15 +4,15 @@ class RestModel
4
4
  def self.serialize(value)
5
5
  ::DateTime.parse value
6
6
  rescue ArgumentError
7
- raise SerializationError, "value '#{value}' is an invalid datetime"
7
+ raise SerializationError, "value '#{value}' is an invalid date time"
8
8
  end
9
9
 
10
10
  def self.desserialize(value)
11
- datetime = value.kind_of?(::DateTime) ? value : ::DateTime.parse(value)
12
- format = RestModel::Configuration.datetime_format
13
- format ? datetime.strftime(format) : datetime.to_s
11
+ date_time = value.kind_of?(::DateTime) ? value : ::DateTime.parse(value)
12
+ format = RestModel::Configuration.date_time_format
13
+ format ? date_time.strftime(format) : date_time.to_s
14
14
  rescue ArgumentError
15
- raise SerializationError, "value '#{value}' is an invalid datetime"
15
+ raise SerializationError, "value '#{value}' is an invalid date time"
16
16
  end
17
17
  end
18
18
  end
@@ -1,3 +1,3 @@
1
1
  class RestModel
2
- VERSION = "0.1.7"
2
+ VERSION = "0.1.8"
3
3
  end
data/lib/rest_model.rb CHANGED
@@ -15,7 +15,7 @@ require "rest_model/source/sender"
15
15
  require "rest_model/response"
16
16
  require "rest_model/serialization/boolean"
17
17
  require "rest_model/serialization/date"
18
- require "rest_model/serialization/datetime"
18
+ require "rest_model/serialization/date_time"
19
19
  require "rest_model/serialization/enumerable"
20
20
  require "rest_model/serialization/float"
21
21
  require "rest_model/serialization/integer"
@@ -1,13 +1,13 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe RestModel::Serialization::DateTime do
4
- it "converts to datetime" do
4
+ it "converts to date time" do
5
5
  subject.class.serialize('2011-07-01T10:20:30').should == DateTime.new(2011, 07, 01, 10, 20, 30)
6
6
  end
7
7
 
8
8
  context "when an invalid value is serialized" do
9
9
  it "raises an error" do
10
- expect {subject.class.serialize("not a datetime")}.to raise_error
10
+ expect {subject.class.serialize("not a date time")}.to raise_error
11
11
  end
12
12
  end
13
13
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rest_model
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -15,7 +15,7 @@ date: 2011-11-03 00:00:00.000000000Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: activesupport
18
- requirement: &70151888329840 !ruby/object:Gem::Requirement
18
+ requirement: &70284000781440 !ruby/object:Gem::Requirement
19
19
  none: false
20
20
  requirements:
21
21
  - - ~>
@@ -23,10 +23,10 @@ dependencies:
23
23
  version: '3.0'
24
24
  type: :runtime
25
25
  prerelease: false
26
- version_requirements: *70151888329840
26
+ version_requirements: *70284000781440
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: i18n
29
- requirement: &70151882162800 !ruby/object:Gem::Requirement
29
+ requirement: &70284000801400 !ruby/object:Gem::Requirement
30
30
  none: false
31
31
  requirements:
32
32
  - - ! '>='
@@ -34,10 +34,10 @@ dependencies:
34
34
  version: '0.5'
35
35
  type: :runtime
36
36
  prerelease: false
37
- version_requirements: *70151882162800
37
+ version_requirements: *70284000801400
38
38
  - !ruby/object:Gem::Dependency
39
39
  name: rspec
40
- requirement: &70151882162340 !ruby/object:Gem::Requirement
40
+ requirement: &70284000800940 !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
43
  - - ~>
@@ -45,10 +45,10 @@ dependencies:
45
45
  version: '2.6'
46
46
  type: :development
47
47
  prerelease: false
48
- version_requirements: *70151882162340
48
+ version_requirements: *70284000800940
49
49
  - !ruby/object:Gem::Dependency
50
50
  name: guard
51
- requirement: &70151882161880 !ruby/object:Gem::Requirement
51
+ requirement: &70284000800480 !ruby/object:Gem::Requirement
52
52
  none: false
53
53
  requirements:
54
54
  - - ~>
@@ -56,10 +56,10 @@ dependencies:
56
56
  version: '0.5'
57
57
  type: :development
58
58
  prerelease: false
59
- version_requirements: *70151882161880
59
+ version_requirements: *70284000800480
60
60
  - !ruby/object:Gem::Dependency
61
61
  name: guard-rspec
62
- requirement: &70151882161420 !ruby/object:Gem::Requirement
62
+ requirement: &70284000800020 !ruby/object:Gem::Requirement
63
63
  none: false
64
64
  requirements:
65
65
  - - ~>
@@ -67,10 +67,10 @@ dependencies:
67
67
  version: '0.4'
68
68
  type: :development
69
69
  prerelease: false
70
- version_requirements: *70151882161420
70
+ version_requirements: *70284000800020
71
71
  - !ruby/object:Gem::Dependency
72
72
  name: growl
73
- requirement: &70151882160960 !ruby/object:Gem::Requirement
73
+ requirement: &70284000799560 !ruby/object:Gem::Requirement
74
74
  none: false
75
75
  requirements:
76
76
  - - ~>
@@ -78,7 +78,7 @@ dependencies:
78
78
  version: '1.0'
79
79
  type: :development
80
80
  prerelease: false
81
- version_requirements: *70151882160960
81
+ version_requirements: *70284000799560
82
82
  description: ''
83
83
  email:
84
84
  - victorcrodrigues@gmail.com
@@ -165,7 +165,7 @@ files:
165
165
  - lib/rest_model/response.rb
166
166
  - lib/rest_model/serialization/boolean.rb
167
167
  - lib/rest_model/serialization/date.rb
168
- - lib/rest_model/serialization/datetime.rb
168
+ - lib/rest_model/serialization/date_time.rb
169
169
  - lib/rest_model/serialization/enumerable.rb
170
170
  - lib/rest_model/serialization/float.rb
171
171
  - lib/rest_model/serialization/integer.rb
@@ -206,7 +206,7 @@ files:
206
206
  - spec/unit/rest_model_spec.rb
207
207
  - spec/unit/serialization/boolean_spec.rb
208
208
  - spec/unit/serialization/date_spec.rb
209
- - spec/unit/serialization/datetime_spec.rb
209
+ - spec/unit/serialization/date_time_spec.rb
210
210
  - spec/unit/serialization/float_spec.rb
211
211
  - spec/unit/serialization/integer_spec.rb
212
212
  - spec/unit/serialization/string_spec.rb
@@ -266,7 +266,7 @@ test_files:
266
266
  - spec/unit/rest_model_spec.rb
267
267
  - spec/unit/serialization/boolean_spec.rb
268
268
  - spec/unit/serialization/date_spec.rb
269
- - spec/unit/serialization/datetime_spec.rb
269
+ - spec/unit/serialization/date_time_spec.rb
270
270
  - spec/unit/serialization/float_spec.rb
271
271
  - spec/unit/serialization/integer_spec.rb
272
272
  - spec/unit/serialization/string_spec.rb