run_signup_api 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -0
- data/lib/run_signup/data_coercion.rb +31 -0
- data/lib/run_signup/race.rb +35 -1
- data/lib/run_signup_api.rb +1 -0
- data/lib/run_signup_api/version.rb +1 -1
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d341a9eaf792d436e9c7c2e69911da9c6f7403ee32b7e7910c0439de66fc2522
|
4
|
+
data.tar.gz: f1af6caa4709f3a6547857185222d2ba4b97ad0cf0e09d64f5211f5d4f756dce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c6a01d66ae5f49535e9c9ad0231f6e23e686e8fd8ec6411f008747e36abd115240736217084d79c03cb727641f00c1cc674b8eecdeace1ebabd79902580afab
|
7
|
+
data.tar.gz: 3e386e40022e88900261ed592770e5aec1e5856f6dee8e8d57db71a11f0831ba512a66979c8bb21ec01dc6cbeaa2b91dfa4eaca72cf9c92889472716b5726332
|
data/Gemfile.lock
CHANGED
@@ -7,6 +7,7 @@ PATH
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
+
byebug (11.1.1)
|
10
11
|
diff-lcs (1.3)
|
11
12
|
dotenv (2.7.5)
|
12
13
|
httparty (0.17.3)
|
@@ -34,6 +35,7 @@ PLATFORMS
|
|
34
35
|
ruby
|
35
36
|
|
36
37
|
DEPENDENCIES
|
38
|
+
byebug
|
37
39
|
dotenv (~> 2.7)
|
38
40
|
rspec (~> 3.9)
|
39
41
|
run_signup_api!
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module RunSignup
|
2
|
+
module DataCoercion
|
3
|
+
def coerce_hash_values hash
|
4
|
+
hash.each do |k, v|
|
5
|
+
hash[k] = coerce_value(v)
|
6
|
+
end
|
7
|
+
hash
|
8
|
+
end
|
9
|
+
|
10
|
+
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)
|
23
|
+
v.map { |v1| coerce_value(v1) }
|
24
|
+
when v.is_a?(Hash)
|
25
|
+
coerce_hash_values(v)
|
26
|
+
else
|
27
|
+
v
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/run_signup/race.rb
CHANGED
@@ -1,5 +1,39 @@
|
|
1
1
|
require 'ostruct'
|
2
2
|
|
3
|
+
# Wrap the API results for a race in an class, and do some data coercion
|
3
4
|
module RunSignup
|
4
|
-
class Race < OpenStruct;
|
5
|
+
class Race < OpenStruct;
|
6
|
+
|
7
|
+
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
|
37
|
+
end
|
38
|
+
end
|
5
39
|
end
|
data/lib/run_signup_api.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- dbwinger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-01-
|
11
|
+
date: 2020-01-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '2.7'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: byebug
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: httparty
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -64,6 +78,7 @@ files:
|
|
64
78
|
- LICENSE.md
|
65
79
|
- README.md
|
66
80
|
- bin/console
|
81
|
+
- lib/run_signup/data_coercion.rb
|
67
82
|
- lib/run_signup/race.rb
|
68
83
|
- lib/run_signup_api.rb
|
69
84
|
- lib/run_signup_api/client.rb
|