run_signup_api 0.0.2 → 0.0.3

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
  SHA256:
3
- metadata.gz: d341a9eaf792d436e9c7c2e69911da9c6f7403ee32b7e7910c0439de66fc2522
4
- data.tar.gz: f1af6caa4709f3a6547857185222d2ba4b97ad0cf0e09d64f5211f5d4f756dce
3
+ metadata.gz: 7f0caebba99a7760a13cb70da2fa0c7edf4b59f95f5e4a6b8d472c1db359ce32
4
+ data.tar.gz: 286a9eb781b7332aba38cf818ebd24162024e3fb1c2807ab50775b75c2481863
5
5
  SHA512:
6
- metadata.gz: 7c6a01d66ae5f49535e9c9ad0231f6e23e686e8fd8ec6411f008747e36abd115240736217084d79c03cb727641f00c1cc674b8eecdeace1ebabd79902580afab
7
- data.tar.gz: 3e386e40022e88900261ed592770e5aec1e5856f6dee8e8d57db71a11f0831ba512a66979c8bb21ec01dc6cbeaa2b91dfa4eaca72cf9c92889472716b5726332
6
+ metadata.gz: 07ce4be4675c5c79ed2e050328ca37bed75bf6f6d26c87a3355d8405b5e7e3c139e4c438ceec56650b77ab3e65a30dce182c5e694cea05894b1942669fa92375
7
+ data.tar.gz: 1f104cb19d93843807d35796740d7d962534040434218a069e6d33e3646fe175e0a983a77c76fee33a2afd46d69bf94abbb60b88a3d8a01404af6ef049a37bbb
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- run_signup_api (0.0.1)
4
+ run_signup_api (0.0.2)
5
5
  httparty
6
6
 
7
7
  GEM
@@ -1,30 +1,32 @@
1
1
  module RunSignup
2
2
  module DataCoercion
3
3
  def coerce_hash_values hash
4
- hash.each do |k, v|
5
- hash[k] = coerce_value(v)
4
+ if hash
5
+ hash.each do |k, v|
6
+ hash[k] = coerce_value(v)
7
+ end
6
8
  end
7
9
  hash
8
10
  end
9
11
 
10
12
  def coerce_value v
11
- case v
12
- when 'T'
13
- true
14
- when 'F'
15
- false
16
- when /^\d{2}\/\d{2}\/\d{4} \d{2}:\d{2}$/
17
- DateTime.strptime(v, '%m/%d/%Y %H:%M')
18
- when /^\d{2}\/\d{2}\/\d{4}$/
19
- Date.strptime(v, '%m/%d/%Y')
20
- when /^\d{1,2}\/\d{1,2}\/\d{4}$/
21
- Date.strptime(v, '%-m/%-d/%Y')
22
- when v.is_a?(Array)
13
+ if v.is_a?(Array)
23
14
  v.map { |v1| coerce_value(v1) }
24
- when v.is_a?(Hash)
15
+ elsif v.is_a?(Hash)
25
16
  coerce_hash_values(v)
26
17
  else
27
- v
18
+ case v
19
+ when 'T'
20
+ true
21
+ when 'F'
22
+ false
23
+ when /^\d{1,2}\/\d{1,2}\/\d{4} \d{2}:\d{2}$/
24
+ DateTime.strptime(v, '%m/%d/%Y %H:%M').to_s
25
+ when /^\d{1,2}\/\d{1,2}\/\d{4}$/
26
+ Date.strptime(v, '%m/%d/%Y').to_s
27
+ else
28
+ v
29
+ end
28
30
  end
29
31
  end
30
32
  end
@@ -1,39 +1,13 @@
1
1
  require 'ostruct'
2
+ require 'run_signup/data_coercion'
2
3
 
3
4
  # Wrap the API results for a race in an class, and do some data coercion
4
5
  module RunSignup
5
- class Race < OpenStruct;
6
+ class Race < OpenStruct
7
+ include RunSignup::DataCoercion
6
8
 
7
9
  def initialize hash = nil
8
- super self.class.coerce_hash_values hash
9
- end
10
-
11
- def self.coerce_hash_values hash
12
- hash.each do |k, v|
13
- hash[k] = coerce_value(v)
14
- end
15
- hash
16
- end
17
-
18
- def self.coerce_value v
19
- if v.is_a?(Array)
20
- v.map { |v1| coerce_value(v1) }
21
- elsif v.is_a?(Hash)
22
- coerce_hash_values(v)
23
- else
24
- case v
25
- when 'T'
26
- true
27
- when 'F'
28
- false
29
- when /^\d{1,2}\/\d{1,2}\/\d{4} \d{2}:\d{2}$/
30
- DateTime.strptime(v, '%m/%d/%Y %H:%M').to_s
31
- when /^\d{1,2}\/\d{1,2}\/\d{4}$/
32
- Date.strptime(v, '%m/%d/%Y').to_s
33
- else
34
- v
35
- end
36
- end
10
+ super coerce_hash_values hash
37
11
  end
38
12
  end
39
13
  end
@@ -0,0 +1,3 @@
1
+ module RunSignupApi
2
+ VERSION = '0.0.3'
3
+ end
@@ -1,3 +1,3 @@
1
1
  module RunSignupApi
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: run_signup_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - dbwinger
@@ -80,6 +80,7 @@ files:
80
80
  - bin/console
81
81
  - lib/run_signup/data_coercion.rb
82
82
  - lib/run_signup/race.rb
83
+ - lib/run_signup/version.rb
83
84
  - lib/run_signup_api.rb
84
85
  - lib/run_signup_api/client.rb
85
86
  - lib/run_signup_api/version.rb