gh 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -111,6 +111,7 @@ I hope so, we use it in production for [Travis CI](http://travis-ci.org/). The w
111
111
 
112
112
  ## History
113
113
 
114
+ * 2012-04-10: 0.2.3 - better normalization
114
115
  * 2012-04-10: 0.2.2 - improved link following
115
116
  * 2012-04-10: 0.2.1 - bug fix release
116
117
  * 2012-04-10: 0.2.0 - added link following plus bug fixes (mainly encoding issues)
@@ -48,7 +48,12 @@ module GH
48
48
  end
49
49
 
50
50
  def modify_time(hash, key, value)
51
- hash['date'] = Time.at(value).xmlschema if key == 'timestamp'
51
+ return unless key == 'timestamp'
52
+ time = Time.at(value)
53
+ rescue TypeError
54
+ time = Time.parse(value.to_s)
55
+ ensure
56
+ hash['date'] = time.xmlschema if time
52
57
  end
53
58
 
54
59
  def modify_user(hash)
@@ -57,6 +62,15 @@ module GH
57
62
 
58
63
  hash['committer'] ||= hash['author'] if hash['author']
59
64
  hash['author'] ||= hash['committer'] if hash['committer']
65
+
66
+ modify_user_fields hash['owner']
67
+ modify_user_fields hash['user']
68
+ end
69
+
70
+ def modify_user_fields(hash)
71
+ return unless Hash === hash
72
+ hash['login'] = hash.delete('name') if hash['name']
73
+ set_link hash, 'self', "users/#{hash['login']}" unless links(hash).include? 'self'
60
74
  end
61
75
 
62
76
  def modify_url(hash, key, value)
@@ -73,20 +87,20 @@ module GH
73
87
 
74
88
  def modify_key(key, value = nil)
75
89
  case key
76
- when 'gravatar_url' then 'avatar_url'
77
- when 'org' then 'organization'
78
- when 'orgs' then 'organizations'
79
- when 'username' then 'login'
80
- when 'repo' then 'repository'
81
- when 'repos' then modify_key('repositories', value)
82
- when /^repos?_(.*)$/ then "repository_#{$1}"
83
- when /^(.*)_repo$/ then "#{$1}_repository"
84
- when /^(.*)_repos$/ then "#{$1}_repositories"
85
- when 'commit', 'commit_id' then value =~ /^\w{40}$/ ? 'sha' : key
86
- when 'comments' then Numeric === value ? 'comment_count' : key
87
- when 'forks' then Numeric === value ? 'fork_count' : key
88
- when 'repositories' then Numeric === value ? 'repository_count' : key
89
- when /^(.*)s_count$/ then "#{$1}_count"
90
+ when 'gravatar_url' then 'avatar_url'
91
+ when 'org' then 'organization'
92
+ when 'orgs' then 'organizations'
93
+ when 'username' then 'login'
94
+ when 'repo' then 'repository'
95
+ when 'repos' then modify_key('repositories', value)
96
+ when /^repos?_(.*)$/ then "repository_#{$1}"
97
+ when /^(.*)_repo$/ then "#{$1}_repository"
98
+ when /^(.*)_repos$/ then "#{$1}_repositories"
99
+ when 'commit', 'commit_id', 'id' then value =~ /^\w{40}$/ ? 'sha' : key
100
+ when 'comments' then Numeric === value ? 'comment_count' : key
101
+ when 'forks' then Numeric === value ? 'fork_count' : key
102
+ when 'repositories' then Numeric === value ? 'repository_count' : key
103
+ when /^(.*)s_count$/ then "#{$1}_count"
90
104
  else key
91
105
  end
92
106
  end
@@ -1,4 +1,4 @@
1
1
  module GH
2
2
  # Public: Library version.
3
- VERSION = "0.2.2"
3
+ VERSION = "0.2.3"
4
4
  end
@@ -205,6 +205,18 @@ describe GH::Normalizer do
205
205
  end
206
206
  end
207
207
 
208
+ context 'time' do
209
+ it 'transforms timestamps stored in "timestamp" to a date in "date"' do
210
+ normalize 'timestamp' => 1234
211
+ normalized['date'].should be == Time.at(1234).xmlschema
212
+ end
213
+
214
+ it 'transforms dates stored in "timestamp" to a date in "date"' do
215
+ normalize 'timestamp' => "2012-04-12T17:29:51+02:00"
216
+ normalized['date'].should be == Time.parse("2012-04-12T17:29:51+02:00").xmlschema
217
+ end
218
+ end
219
+
208
220
  context 'links' do
209
221
  it 'generates link entries from link headers' do
210
222
  pending
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gh
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-10 00:00:00.000000000 Z
12
+ date: 2012-04-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &70323064331020 !ruby/object:Gem::Requirement
16
+ requirement: &70266152433620 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70323064331020
24
+ version_requirements: *70266152433620
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: webmock
27
- requirement: &70323064330300 !ruby/object:Gem::Requirement
27
+ requirement: &70266152433160 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70323064330300
35
+ version_requirements: *70266152433160
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: faraday
38
- requirement: &70323064329600 !ruby/object:Gem::Requirement
38
+ requirement: &70266152432640 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0.7'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70323064329600
46
+ version_requirements: *70266152432640
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: backports
49
- requirement: &70323064329040 !ruby/object:Gem::Requirement
49
+ requirement: &70266152432140 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '2.3'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70323064329040
57
+ version_requirements: *70266152432140
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: multi_json
60
- requirement: &70323064328540 !ruby/object:Gem::Requirement
60
+ requirement: &70266152431660 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: '1.0'
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *70323064328540
68
+ version_requirements: *70266152431660
69
69
  description: multi-layer client for the github api v3
70
70
  email:
71
71
  - konstantin.mailinglists@googlemail.com