weatherzone 0.8.1 → 0.8.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/weatherzone/helpers/date_parser.rb +3 -1
- data/lib/weatherzone.rb +1 -1
- data/test/test_date_parser.rb +23 -0
- metadata +8 -35
@@ -7,7 +7,9 @@ module Weatherzone
|
|
7
7
|
def self.interpret_as_date(*methods)
|
8
8
|
methods.each do |method_name|
|
9
9
|
define_method method_name do
|
10
|
-
|
10
|
+
if value = instance_variable_get("@#{method_name}")
|
11
|
+
Date.parse(value)
|
12
|
+
end
|
11
13
|
end
|
12
14
|
end
|
13
15
|
end
|
data/lib/weatherzone.rb
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
|
3
|
+
class TestDateParser < Test::Unit::TestCase
|
4
|
+
|
5
|
+
class SomeResource
|
6
|
+
include Weatherzone::Helpers::DateParser
|
7
|
+
attr_writer :created_at
|
8
|
+
interpret_as_date :created_at
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_parses_date
|
12
|
+
resource = SomeResource.new
|
13
|
+
resource.created_at = "12/04/1972"
|
14
|
+
assert_equal Date.parse("12/04/1972"), resource.created_at
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_doesnt_bork_on_nils
|
18
|
+
resource = SomeResource.new
|
19
|
+
resource.created_at = nil
|
20
|
+
assert_equal nil, resource.created_at
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 8
|
8
|
-
-
|
9
|
-
version: 0.8.
|
8
|
+
- 2
|
9
|
+
version: 0.8.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Ben Askins
|
@@ -14,51 +14,23 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-05-
|
17
|
+
date: 2010-05-14 00:00:00 +10:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
|
-
name:
|
21
|
+
name: hoe
|
22
22
|
prerelease: false
|
23
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
segments:
|
28
|
-
-
|
28
|
+
- 1
|
29
|
+
- 8
|
29
30
|
- 0
|
30
|
-
|
31
|
-
version: 2.0.3
|
31
|
+
version: 1.8.0
|
32
32
|
type: :development
|
33
33
|
version_requirements: *id001
|
34
|
-
- !ruby/object:Gem::Dependency
|
35
|
-
name: gemcutter
|
36
|
-
prerelease: false
|
37
|
-
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
-
requirements:
|
39
|
-
- - ">="
|
40
|
-
- !ruby/object:Gem::Version
|
41
|
-
segments:
|
42
|
-
- 0
|
43
|
-
- 5
|
44
|
-
- 0
|
45
|
-
version: 0.5.0
|
46
|
-
type: :development
|
47
|
-
version_requirements: *id002
|
48
|
-
- !ruby/object:Gem::Dependency
|
49
|
-
name: hoe
|
50
|
-
prerelease: false
|
51
|
-
requirement: &id003 !ruby/object:Gem::Requirement
|
52
|
-
requirements:
|
53
|
-
- - ">="
|
54
|
-
- !ruby/object:Gem::Version
|
55
|
-
segments:
|
56
|
-
- 2
|
57
|
-
- 5
|
58
|
-
- 0
|
59
|
-
version: 2.5.0
|
60
|
-
type: :development
|
61
|
-
version_requirements: *id003
|
62
34
|
description: Ruby client for the weatherzone webservice.
|
63
35
|
email:
|
64
36
|
- ben.askins@gmail.com
|
@@ -155,6 +127,7 @@ test_files:
|
|
155
127
|
- test/test_connection.rb
|
156
128
|
- test/test_country.rb
|
157
129
|
- test/test_daily_observation.rb
|
130
|
+
- test/test_date_parser.rb
|
158
131
|
- test/test_district_forecast.rb
|
159
132
|
- test/test_exceptions.rb
|
160
133
|
- test/test_farenheit_conversion_factor.rb
|