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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/run_signup/data_coercion.rb +18 -16
- data/lib/run_signup/race.rb +4 -30
- data/lib/run_signup/version.rb +3 -0
- data/lib/run_signup_api/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f0caebba99a7760a13cb70da2fa0c7edf4b59f95f5e4a6b8d472c1db359ce32
|
4
|
+
data.tar.gz: 286a9eb781b7332aba38cf818ebd24162024e3fb1c2807ab50775b75c2481863
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07ce4be4675c5c79ed2e050328ca37bed75bf6f6d26c87a3355d8405b5e7e3c139e4c438ceec56650b77ab3e65a30dce182c5e694cea05894b1942669fa92375
|
7
|
+
data.tar.gz: 1f104cb19d93843807d35796740d7d962534040434218a069e6d33e3646fe175e0a983a77c76fee33a2afd46d69bf94abbb60b88a3d8a01404af6ef049a37bbb
|
data/Gemfile.lock
CHANGED
@@ -1,30 +1,32 @@
|
|
1
1
|
module RunSignup
|
2
2
|
module DataCoercion
|
3
3
|
def coerce_hash_values hash
|
4
|
-
hash
|
5
|
-
hash
|
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
|
-
|
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
|
-
|
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
|
data/lib/run_signup/race.rb
CHANGED
@@ -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
|
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
|
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.
|
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
|