infostrada 0.1.23 → 0.1.24
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/infostrada/competition.rb +15 -5
- data/lib/infostrada/edition.rb +20 -4
- data/lib/infostrada/match.rb +105 -36
- data/lib/infostrada/nation.rb +13 -1
- data/lib/infostrada/phase.rb +36 -13
- data/lib/infostrada/referee.rb +12 -1
- data/lib/infostrada/team.rb +14 -2
- data/lib/infostrada/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MzE3NDBiNmMwMWIwNWI4ZTYzZDA0Y2UzMWI1OGZjYmVhMDMyMTM2NA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NmZmZDE4MzNiNjIzMmUxZDkyNzFjNGY1MTQwYjNmOTQyMGVjN2U4YQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NjM2NTY1MWU1YmJkMjY4MTIyYTYxYTUxMzk2Y2M3YmVkNjQ3N2ZlOTE3MjZh
|
10
|
+
YTY5MTNjOWQ5YjE1NGE3ODAxYTMzZjQzMjJhMDQxYmE1ZTc3MjdhNGRhMTk2
|
11
|
+
ZWI4YTk4ZTNjZjNhN2VmYzdmMDRiOWY2MDRkM2QzZGNhMWFjOTA=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZjQxNjgyZjQxMTJjZmM4NzdjMjQzYjExODgxZjFkODkyM2MxMjE0NzMzMGY2
|
14
|
+
NDEyM2UwNjkwNTc4YjQ5M2I5YjZlMWU3OWJlNmZmMTI0YmMyNzMxOTY2ZGIz
|
15
|
+
NDViZGUxOWM4MjQ1M2UyZmJiZjQxNDAyZTdkZDMzYzRkZjRlNmQ=
|
@@ -14,11 +14,21 @@ module Infostrada
|
|
14
14
|
class Competition
|
15
15
|
attr_accessor :id, :name, :set, :level, :nation
|
16
16
|
|
17
|
-
def
|
18
|
-
|
19
|
-
|
17
|
+
def self.from_json(json = {})
|
18
|
+
self.new do |competition|
|
19
|
+
competition.id = json['id']
|
20
|
+
competition.name = json['name']
|
21
|
+
competition.nation = Nation.from_json(json['nation'], 'competition') if json['nation']
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def initialize(hash = {}, &block)
|
26
|
+
@id = hash.delete('n_CompetitionID')
|
27
|
+
@name = hash.delete('c_Competition')
|
28
|
+
@nation = Nation.new(hash, 'competition') if hash.any?
|
20
29
|
|
21
|
-
|
30
|
+
block.call(self) if block_given?
|
31
|
+
self
|
22
32
|
end
|
23
33
|
end
|
24
|
-
end
|
34
|
+
end
|
data/lib/infostrada/edition.rb
CHANGED
@@ -4,7 +4,7 @@ module Infostrada
|
|
4
4
|
class Edition
|
5
5
|
extend Forwardable
|
6
6
|
|
7
|
-
attr_accessor :id, :competition, :season, :start_date, :end_date
|
7
|
+
attr_accessor :id, :competition, :season, :start_date, :end_date, :competition
|
8
8
|
|
9
9
|
def_delegator :@competition, :name, :competition_name
|
10
10
|
def_delegator :@competition, :id, :competition_id
|
@@ -13,14 +13,30 @@ module Infostrada
|
|
13
13
|
editions = EditionRequest.get_list
|
14
14
|
end
|
15
15
|
|
16
|
-
def
|
16
|
+
def self.from_json(json = {})
|
17
|
+
self.new do |edition|
|
18
|
+
edition.id = json['id']
|
19
|
+
edition.competition = json['competition']
|
20
|
+
edition.season = json['season']
|
21
|
+
edition.start_date = json['start_date']
|
22
|
+
edition.end_date = json['end_date']
|
23
|
+
edition.competition = Competition.from_json(json['competition'])
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def initialize(hash = {}, &block)
|
17
28
|
@id = hash.delete('n_EditionID')
|
18
29
|
@season = hash.delete('c_Season')
|
19
|
-
|
20
|
-
|
30
|
+
|
31
|
+
if hash['d_EditionStartDate']
|
32
|
+
@start_date = Formatter.format_date(hash.delete('d_EditionStartDate'))
|
33
|
+
end
|
34
|
+
|
35
|
+
@end_date = Formatter.format_date(hash.delete('d_EditionEndDate')) if hash['d_EditionEndDate']
|
21
36
|
|
22
37
|
@competition = Competition.new(hash)
|
23
38
|
|
39
|
+
block.call(self) if block_given?
|
24
40
|
self
|
25
41
|
end
|
26
42
|
|
data/lib/infostrada/match.rb
CHANGED
@@ -99,51 +99,102 @@ module Infostrada
|
|
99
99
|
list
|
100
100
|
end
|
101
101
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
102
|
+
|
103
|
+
# Useful method to get a Match object from a json serialized Match object.
|
104
|
+
def self.from_json(json = {})
|
105
|
+
self.new do |match|
|
106
|
+
match.id = json['id']
|
107
|
+
match.date = Time.parse(json['date']) if json['date']
|
108
|
+
match.rescheduled = json['rescheduled']
|
109
|
+
match.round = json['round']
|
110
|
+
match.time_unknown = json['time_unknown']
|
111
|
+
match.date_unknown = json['date_unknown']
|
112
|
+
match.aggregate_winner_id = json['aggregate_winner_id']
|
113
|
+
|
114
|
+
if json['current_period_started_at']
|
115
|
+
match.current_period_started_at = Time.parse(json['current_period_started_at'])
|
116
|
+
end
|
117
|
+
|
118
|
+
match.status_code = json['status_code']
|
119
|
+
match.status = json['status']
|
120
|
+
match.status_short = json['status_short']
|
121
|
+
match.leg = json['leg']
|
122
|
+
match.started_at = Time.parse(json['started_at']) if json['started_at']
|
123
|
+
|
124
|
+
match.stadium_id = json['stadium_id']
|
125
|
+
match.stadium_name = json['stadium_name']
|
126
|
+
match.spectators = json['spectators']
|
127
|
+
match.city = json['city']
|
128
|
+
|
129
|
+
match.live = json['live']
|
130
|
+
match.started = json['started']
|
131
|
+
match.finished = json['finished']
|
132
|
+
match.awarded = json['awarded']
|
133
|
+
|
134
|
+
match.live_score = json['live_score']
|
135
|
+
match.live_goals = json['live_goals']
|
136
|
+
match.live_lineup = json['live_lineup']
|
137
|
+
|
138
|
+
match.lineup_provisional = json['lineup_provisional']
|
139
|
+
match.lineup_official = json['lineup_official']
|
140
|
+
|
141
|
+
match.period = json['period']
|
142
|
+
|
143
|
+
match.referee = Referee.from_json(json['referee'])
|
144
|
+
match.phase = Phase.from_json(json['phase'])
|
145
|
+
match.home_team = Team.from_json(json['home_team'], 'home')
|
146
|
+
match.away_team = Team.from_json(json['away_team'], 'away')
|
147
|
+
match.goals = Goals.from_json(json['goals'])
|
148
|
+
match.edition = Edition.from_json(json['edition'])
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
def initialize(hash = {}, &block)
|
153
|
+
@id = hash['n_MatchID']
|
154
|
+
@date = Formatter.format_date(hash['d_DateUTC'])
|
155
|
+
@rescheduled = hash['b_RescheduledToBeResumed']
|
156
|
+
@round = hash['n_RoundNr']
|
157
|
+
@time_unknown = hash['b_TimeUnknown']
|
158
|
+
@date_unknown = hash['b_DateUnknown']
|
159
|
+
|
160
|
+
@aggregate_winner_id = hash['n_WinnerOnAggregateTeamID']
|
111
161
|
@current_period_started_at = Formatter.format_date(hash['d_CurrentPeriodStartTime'])
|
112
|
-
@status_code
|
113
|
-
@status
|
114
|
-
@status_short
|
115
|
-
@leg
|
116
|
-
@started_at
|
162
|
+
@status_code = hash['n_MatchStatusCode']
|
163
|
+
@status = hash['c_MatchStatus']
|
164
|
+
@status_short = hash['c_MatchStatusShort']
|
165
|
+
@leg = hash['n_Leg']
|
166
|
+
@started_at = Formatter.format_date(hash['d_MatchStartTime'])
|
117
167
|
|
118
|
-
@stadium_id
|
119
|
-
@stadium_name
|
120
|
-
@spectators
|
121
|
-
@city
|
168
|
+
@stadium_id = hash['n_StadiumGeoID']
|
169
|
+
@stadium_name = hash['c_Stadium']
|
170
|
+
@spectators = hash['n_Spectators']
|
171
|
+
@city = hash['c_City']
|
122
172
|
|
123
|
-
@live
|
124
|
-
@started
|
125
|
-
@finished
|
126
|
-
@awarded
|
173
|
+
@live = hash['b_Live']
|
174
|
+
@started = hash['b_Started']
|
175
|
+
@finished = hash['b_Finished']
|
176
|
+
@awarded = hash['b_Awarded']
|
127
177
|
|
128
|
-
@live_score
|
129
|
-
@live_goals
|
130
|
-
@live_lineup
|
178
|
+
@live_score = hash['b_DataEntryLiveScore']
|
179
|
+
@live_goals = hash['b_DataEntryLiveGoal']
|
180
|
+
@live_lineup = hash['b_DataEntryLiveLineup']
|
131
181
|
|
132
|
-
@lineup_provisional
|
133
|
-
@lineup_official
|
182
|
+
@lineup_provisional = hash['b_LineupProvisional']
|
183
|
+
@lineup_official = hash['b_LineupOfficial']
|
134
184
|
|
135
|
-
@period
|
185
|
+
@period = hash['n_PeriodSort']
|
136
186
|
|
137
|
-
@referee
|
138
|
-
@phase
|
187
|
+
@referee = Referee.new(hash)
|
188
|
+
@phase = Phase.new(hash)
|
139
189
|
|
140
|
-
@home_team
|
141
|
-
@away_team
|
190
|
+
@home_team = Team.new(hash, 'home')
|
191
|
+
@away_team = Team.new(hash, 'away')
|
142
192
|
|
143
|
-
@goals
|
193
|
+
@goals = Goals.new(hash)
|
144
194
|
|
145
|
-
@edition
|
195
|
+
@edition = Edition.new(hash)
|
146
196
|
|
197
|
+
block.call(self) if block_given?
|
147
198
|
self
|
148
199
|
end
|
149
200
|
|
@@ -166,10 +217,25 @@ module Infostrada
|
|
166
217
|
|
167
218
|
class Goals
|
168
219
|
attr_accessor :home_goals, :away_goals, :home_goals_half_time, :away_goals_half_time,
|
169
|
-
:home_goals_90_mins, :away_goals_90_mins, :home_goals_105_mins, :
|
220
|
+
:home_goals_90_mins, :away_goals_90_mins, :home_goals_105_mins, :away_goals_105_mins,
|
170
221
|
:home_goals_shootout, :away_goals_shootout
|
171
222
|
|
172
|
-
def
|
223
|
+
def self.from_json(json = {})
|
224
|
+
self.new do |goals|
|
225
|
+
goals.home_goals = json['home_goals']
|
226
|
+
goals.away_goals = json['away_goals']
|
227
|
+
goals.home_goals_half_time = json['home_goals_half_time']
|
228
|
+
goals.away_goals_half_time = json['away_goals_half_time']
|
229
|
+
goals.home_goals_90_mins = json['home_goals_90_mins']
|
230
|
+
goals.away_goals_90_mins = json['away_goals_90_mins']
|
231
|
+
goals.home_goals_105_mins = json['home_goals_105_mins']
|
232
|
+
goals.away_goals_105_mins = json['away_goals_105_mins']
|
233
|
+
goals.home_goals_shootout = json['home_goals_shootout']
|
234
|
+
goals.away_goals_shootout = json['away_goald_shootout']
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
238
|
+
def initialize(hash = {}, &block)
|
173
239
|
@home_goals = hash['n_HomeGoals']
|
174
240
|
@away_goals = hash['n_AwayGoals']
|
175
241
|
@home_goals_half_time = hash['n_HomeGoalsHalftime']
|
@@ -180,6 +246,9 @@ module Infostrada
|
|
180
246
|
@away_goals_105_mins = hash['n_AwayGoals105mins']
|
181
247
|
@home_goals_shootout = hash['n_HomeGoalsShootout']
|
182
248
|
@away_goald_shootout = hash['n_AwayGoalsShootout']
|
249
|
+
|
250
|
+
block.call(self) if block_given?
|
251
|
+
self
|
183
252
|
end
|
184
253
|
end
|
185
254
|
end
|
data/lib/infostrada/nation.rb
CHANGED
@@ -2,11 +2,23 @@ module Infostrada
|
|
2
2
|
class Nation
|
3
3
|
attr_accessor :id, :name, :short_name
|
4
4
|
|
5
|
-
|
5
|
+
|
6
|
+
def self.from_json(hash = {}, prefix)
|
7
|
+
self.new(prefix) do |nation|
|
8
|
+
nation.id = hash['id']
|
9
|
+
nation.name = hash['name']
|
10
|
+
nation.short_name = hash['short_name']
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize(hash = {}, prefix, &block)
|
6
15
|
hash.each do |key, value|
|
7
16
|
match = key.snake_case.match(/[cn]_#{prefix}_?(natio\w*)$/)
|
8
17
|
self.send("#{$1}=", value) if match
|
9
18
|
end
|
19
|
+
|
20
|
+
block.call(self) if block_given?
|
21
|
+
self
|
10
22
|
end
|
11
23
|
|
12
24
|
def natio_geo_id=(id)
|
data/lib/infostrada/phase.rb
CHANGED
@@ -15,8 +15,9 @@ module Infostrada
|
|
15
15
|
URL = '/GetPhaseList'
|
16
16
|
|
17
17
|
# Short name is only set outside GetPhaseList endpoint. For example on match list.
|
18
|
-
attr_accessor :id, :name, :phase1_id, :phase1_name, :phase2_id, :phase2_name, :phase3_id,
|
19
|
-
|
18
|
+
attr_accessor :id, :name, :phase1_id, :phase1_name, :phase2_id, :phase2_name, :phase3_id,
|
19
|
+
:level, :phase3_name, :table, :current, :currents, :start_date, :end_date,
|
20
|
+
:short_name, :has_table
|
20
21
|
|
21
22
|
def self.where(options = {})
|
22
23
|
edition_id = options.delete(:edition_id)
|
@@ -31,25 +32,46 @@ module Infostrada
|
|
31
32
|
phases
|
32
33
|
end
|
33
34
|
|
35
|
+
# Useful method to get a Phase object from a json serialized Phase object.
|
36
|
+
def self.from_json(json = {})
|
37
|
+
self.new do |phase|
|
38
|
+
phase.id = json['id']
|
39
|
+
phase.name = json['name']
|
40
|
+
phase.level = json['level']
|
41
|
+
phase.short_name = json['short_name']
|
42
|
+
phase.phase1_id = json['phase1_id']
|
43
|
+
phase.phase1_name = json['phase1_name']
|
44
|
+
phase.phase2_id = json['phase2_id']
|
45
|
+
phase.phase2_name = json['phase2_name']
|
46
|
+
phase.phase3_id = json['phase3_id']
|
47
|
+
phase.phase3_name = json['phase3_name']
|
48
|
+
phase.has_table = json['has_table']
|
49
|
+
phase.current = json['current']
|
50
|
+
phase.currents = json['currents']
|
51
|
+
phase.start_date = Date.parse(json['start_date']) if json['start_date']
|
52
|
+
phase.end_date = Date.parse(json['end_date']) if json['end_date']
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
34
56
|
# Get the classification table for this phase.
|
35
57
|
def table
|
36
58
|
Table.where(phase_id: id)
|
37
59
|
end
|
38
60
|
|
39
|
-
def initialize(hash)
|
40
|
-
@id
|
41
|
-
@name
|
42
|
-
@level
|
43
|
-
@short_name
|
44
|
-
@phase1_id
|
61
|
+
def initialize(hash = {}, &block)
|
62
|
+
@id = hash['n_PhaseID']
|
63
|
+
@name = hash['c_Phase']
|
64
|
+
@level = hash['n_PhaseLevel']
|
65
|
+
@short_name = hash['c_PhaseShort']
|
66
|
+
@phase1_id = hash['n_Phase1ID']
|
45
67
|
@phase1_name = hash['c_Phase1']
|
46
|
-
@phase2_id
|
68
|
+
@phase2_id = hash['n_Phase2ID']
|
47
69
|
@phase2_name = hash['c_Phase2']
|
48
|
-
@phase3_id
|
70
|
+
@phase3_id = hash['n_Phase3ID']
|
49
71
|
@phase3_name = hash['c_Phase3']
|
50
|
-
@has_table
|
51
|
-
@current
|
52
|
-
@currents
|
72
|
+
@has_table = hash['b_Table']
|
73
|
+
@current = hash['b_Current']
|
74
|
+
@currents = hash['b_Currents']
|
53
75
|
|
54
76
|
# On GetPhaseList endpoint dates are just yyymmdd. Example: 20100629 (which translates to
|
55
77
|
# 2010-06-29).
|
@@ -58,6 +80,7 @@ module Infostrada
|
|
58
80
|
@end_date = Date.parse(hash['n_DateEnd'].to_s)
|
59
81
|
end
|
60
82
|
|
83
|
+
block.call(self) if block_given?
|
61
84
|
self
|
62
85
|
end
|
63
86
|
|
data/lib/infostrada/referee.rb
CHANGED
@@ -2,12 +2,23 @@ module Infostrada
|
|
2
2
|
class Referee
|
3
3
|
attr_accessor :id, :name, :nation
|
4
4
|
|
5
|
-
def
|
5
|
+
def self.from_json(json = {})
|
6
|
+
self.new do |referee|
|
7
|
+
referee.id = json['id']
|
8
|
+
referee.name = json['name']
|
9
|
+
referee.nation = json['nation']
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def initialize(hash = {}, &block)
|
6
14
|
@id = hash.delete('n_RefereeID')
|
7
15
|
|
8
16
|
@name = hash.delete('c_Referee')
|
9
17
|
|
10
18
|
@nation = Nation.new(hash, 'referee')
|
19
|
+
|
20
|
+
block.call(self) if block_given?
|
21
|
+
self
|
11
22
|
end
|
12
23
|
end
|
13
24
|
end
|
data/lib/infostrada/team.rb
CHANGED
@@ -13,7 +13,17 @@ module Infostrada
|
|
13
13
|
teams = TeamRequest.get_edition(edition_id.to_i)
|
14
14
|
end
|
15
15
|
|
16
|
-
def
|
16
|
+
def self.from_json(json = {}, prefix)
|
17
|
+
self.new(prefix) do |team|
|
18
|
+
team.id = json['id']
|
19
|
+
team.name = json['name']
|
20
|
+
team.short_name = json['short_name']
|
21
|
+
team.nation = Nation.from_json(json['nation'], "#{prefix}_team") if json['nation']
|
22
|
+
team.edition_id = json['edition_id']
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def initialize(hash = {}, prefix, &block)
|
17
27
|
@edition_id = hash['edition_id']
|
18
28
|
|
19
29
|
hash.each do |key, value|
|
@@ -26,8 +36,10 @@ module Infostrada
|
|
26
36
|
self.send('team_short=', value)
|
27
37
|
end
|
28
38
|
end
|
29
|
-
|
30
39
|
@nation = Nation.new(hash, "#{prefix}_team")
|
40
|
+
|
41
|
+
block.call(self) if block_given?
|
42
|
+
self
|
31
43
|
end
|
32
44
|
|
33
45
|
def team_id=(id)
|
data/lib/infostrada/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: infostrada
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.24
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ricardo Otero
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|