infostrada 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +11 -2
- data/infostrada.gemspec +2 -0
- data/infostrada.pstore +1 -0
- data/lib/infostrada/base_request.rb +28 -3
- data/lib/infostrada/call_refresh.rb +89 -0
- data/lib/infostrada/edition.rb +7 -0
- data/lib/infostrada/endpoint_manager.rb +12 -0
- data/lib/infostrada/errors.rb +3 -0
- data/lib/infostrada/formatter.rb +4 -4
- data/lib/infostrada/match.rb +69 -8
- data/lib/infostrada/phase.rb +11 -1
- data/lib/infostrada/player.rb +15 -2
- data/lib/infostrada/table.rb +50 -0
- data/lib/infostrada/version.rb +1 -1
- data/lib/infostrada.rb +9 -2
- metadata +34 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba919a27af5c409be645ab783d4e798541c0e530
|
4
|
+
data.tar.gz: 53e9434a6e1227844068e20916d658d2748ed1d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f328878a653683b9d4bfcaae26fd6e5807a765d20e8e5663dc91e02937c12288adb505fc4a11cc744bdf966ed49df96fc4101e7d37269775ff7a2d7da370e836
|
7
|
+
data.tar.gz: effc38fcb37763919235a9125114e2c9f669cd9b8a5b5b8486affd7a5c199e3be73ad5996c9e19817ff9026ad8ff5e36ba7b68bf50062cab488ab4ca62cb6ea5
|
data/Gemfile.lock
CHANGED
@@ -1,25 +1,32 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
infostrada (0.0.
|
4
|
+
infostrada (0.0.9)
|
5
5
|
colored
|
6
6
|
httparty (~> 0.12)
|
7
7
|
rb-readline
|
8
|
+
tzinfo
|
8
9
|
|
9
10
|
GEM
|
10
11
|
remote: https://rubygems.org/
|
11
12
|
specs:
|
12
13
|
ast (1.1.0)
|
14
|
+
coderay (1.1.0)
|
13
15
|
colored (1.2)
|
14
|
-
httparty (0.
|
16
|
+
httparty (0.13.0)
|
15
17
|
json (~> 1.8)
|
16
18
|
multi_xml (>= 0.5.2)
|
17
19
|
json (1.8.1)
|
20
|
+
method_source (0.8.2)
|
18
21
|
multi_xml (0.5.5)
|
19
22
|
parser (2.1.4)
|
20
23
|
ast (~> 1.1)
|
21
24
|
slop (~> 3.4, >= 3.4.5)
|
22
25
|
powerpack (0.0.9)
|
26
|
+
pry (0.9.12.6)
|
27
|
+
coderay (~> 1.0)
|
28
|
+
method_source (~> 0.8)
|
29
|
+
slop (~> 3.4)
|
23
30
|
rainbow (2.0.0)
|
24
31
|
rake (10.1.1)
|
25
32
|
rb-readline (0.5.1)
|
@@ -39,6 +46,7 @@ GEM
|
|
39
46
|
sexp_processor (~> 4.1)
|
40
47
|
sexp_processor (4.4.1)
|
41
48
|
slop (3.4.7)
|
49
|
+
tzinfo (0.3.39)
|
42
50
|
|
43
51
|
PLATFORMS
|
44
52
|
ruby
|
@@ -46,6 +54,7 @@ PLATFORMS
|
|
46
54
|
DEPENDENCIES
|
47
55
|
bundler (~> 1.5)
|
48
56
|
infostrada!
|
57
|
+
pry
|
49
58
|
rake
|
50
59
|
reek
|
51
60
|
rubocop
|
data/infostrada.gemspec
CHANGED
data/infostrada.pstore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{:last_updateIu: Time
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'infostrada/endpoint_manager'
|
2
|
+
|
1
3
|
module Infostrada
|
2
4
|
# This is the class that every class making API requests must descend from. It includes HTTParty
|
3
5
|
# to easily support every type of HTTP request. The basic_auth is set up from the
|
@@ -21,10 +23,19 @@ module Infostrada
|
|
21
23
|
base_uri 'demo.api.infostradasports.com/svc/Football.svc/json/'
|
22
24
|
|
23
25
|
# Which default parameters we can send in every request?
|
26
|
+
#
|
27
|
+
# languageCode can be one of the following:
|
28
|
+
# 1 = dutch
|
29
|
+
# 2 = english
|
30
|
+
# 4 = french
|
31
|
+
# 8 = german
|
32
|
+
# 128 = norwegian
|
33
|
+
# 256 = swedish
|
34
|
+
# 1024 = danish
|
24
35
|
default_params languageCode: 2
|
25
36
|
|
26
37
|
# Default request timeout in seconds. This can be overriden by module configuration.
|
27
|
-
default_timeout
|
38
|
+
default_timeout 15
|
28
39
|
|
29
40
|
# Disable the use of rails query string format.
|
30
41
|
#
|
@@ -36,6 +47,16 @@ module Infostrada
|
|
36
47
|
#
|
37
48
|
disable_rails_query_string_format
|
38
49
|
|
50
|
+
class << self
|
51
|
+
attr_accessor :endpoint
|
52
|
+
|
53
|
+
def register_endpoint(endpoint)
|
54
|
+
self.endpoint = endpoint
|
55
|
+
|
56
|
+
EndpointManager.register(endpoint => self)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
39
60
|
# Used with Timeout::Error rescue so we can keep trying to fetch the information after timeout.
|
40
61
|
def self.get!(path, options = {}, &block)
|
41
62
|
attempts = 1
|
@@ -43,10 +64,14 @@ module Infostrada
|
|
43
64
|
|
44
65
|
begin
|
45
66
|
result = get(path, options, &block)
|
46
|
-
rescue Timeout::Error =>
|
67
|
+
rescue Timeout::Error => e
|
47
68
|
puts "Timeout! Retrying... (#{attempts})"
|
48
69
|
attempts += 1
|
49
|
-
|
70
|
+
if attempts > RETRIES
|
71
|
+
raise Infostrada::RequestError.new, 'Request timeout'
|
72
|
+
else
|
73
|
+
retry
|
74
|
+
end
|
50
75
|
end
|
51
76
|
|
52
77
|
result
|
@@ -0,0 +1,89 @@
|
|
1
|
+
require 'pstore'
|
2
|
+
require 'tzinfo'
|
3
|
+
|
4
|
+
module Infostrada
|
5
|
+
class CallRefresh < Infostrada::BaseRequest
|
6
|
+
URL = '/GetAPICallRefresh_Module'
|
7
|
+
|
8
|
+
# The API timezone. This is very important since all the dates passed as argument to the refresh
|
9
|
+
# call must be in the correct timezone.
|
10
|
+
TIMEZONE = 'Europe/Amsterdam'
|
11
|
+
|
12
|
+
# This is the only method on Infostrada API that don't use /Football.svc but /Utility.svc
|
13
|
+
# instead, so we have to replace that on the default base_uri.
|
14
|
+
Infostrada::CallRefresh.base_uri Infostrada::CallRefresh.base_uri.gsub(/Football/, 'Utility')
|
15
|
+
|
16
|
+
# Which languages are you interested in? The GetAPICallRefresh_Module call can return multiple
|
17
|
+
# endpoints for the same thing if multiple languages are available.
|
18
|
+
#
|
19
|
+
# languageCode can be one of the following:
|
20
|
+
# 1 = dutch
|
21
|
+
# 2 = english
|
22
|
+
# 4 = french
|
23
|
+
# 8 = german
|
24
|
+
# 128 = norwegian
|
25
|
+
# 256 = swedish
|
26
|
+
# 1024 = danish
|
27
|
+
LANGUAGE_CODES = [2]
|
28
|
+
|
29
|
+
# The outputType parameter can be one of the following:
|
30
|
+
# 1 = xml
|
31
|
+
# 2 = json
|
32
|
+
# 3 = soap
|
33
|
+
OUTPUT_TYPE = 2
|
34
|
+
|
35
|
+
# How to format the date. This string will be used on a Date#strftime. Infostrada will work with
|
36
|
+
# formats like this: 2013-09-21T22:22:22.
|
37
|
+
DATE_FORMAT = '%FT%T'
|
38
|
+
|
39
|
+
def self.store
|
40
|
+
@store ||= PStore.new('infostrada.pstore')
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.last_update
|
44
|
+
store.transaction { store[:last_update] }
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.last_update=(date)
|
48
|
+
store.transaction { store[:last_update] = date }
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.api_time(date)
|
52
|
+
@timezone ||= TZInfo::Timezone.get(TIMEZONE)
|
53
|
+
@timezone.utc_to_local(date.utc)
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.get_latest
|
57
|
+
updated_endpoints = since(last_update || api_time(Time.now))
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.since(date)
|
61
|
+
date = date.strftime(DATE_FORMAT)
|
62
|
+
|
63
|
+
list = get!(URL, query: { from: date, outputType: OUTPUT_TYPE, module: 'football' })
|
64
|
+
|
65
|
+
self.last_update = api_time(Time.now)
|
66
|
+
|
67
|
+
endpoints = []
|
68
|
+
list.each do |hash|
|
69
|
+
lang = hash['c_QueryString'].scan(/languagecode=(\d+)/).flatten.first.to_i
|
70
|
+
|
71
|
+
endpoints << Endpoint.new(hash) if LANGUAGE_CODES.include?(lang)
|
72
|
+
end
|
73
|
+
|
74
|
+
endpoints
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
class Endpoint
|
79
|
+
attr_accessor :method, :last_modified, :query_string
|
80
|
+
|
81
|
+
def initialize(hash)
|
82
|
+
@method = hash['c_Method']
|
83
|
+
@last_modified = Formatter.format_date(hash['d_LastModified'])
|
84
|
+
@query_string = hash['c_QueryString']
|
85
|
+
|
86
|
+
self
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
data/lib/infostrada/edition.rb
CHANGED
@@ -20,10 +20,17 @@ module Infostrada
|
|
20
20
|
@end_date = Formatter.format_date(hash.delete('d_EditionEndDate'))
|
21
21
|
|
22
22
|
@competition = Competition.new(hash)
|
23
|
+
|
24
|
+
self
|
23
25
|
end
|
24
26
|
|
25
27
|
def teams
|
26
28
|
Team.all(id)
|
27
29
|
end
|
30
|
+
|
31
|
+
# Get phases for this edition
|
32
|
+
def phases
|
33
|
+
Phase.where(edition_id: id)
|
34
|
+
end
|
28
35
|
end
|
29
36
|
end
|
data/lib/infostrada/errors.rb
CHANGED
data/lib/infostrada/formatter.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Infostrada
|
2
|
-
# This class is used to format types that come from
|
2
|
+
# This class is used to format types that come from Infostrada like dates.
|
3
3
|
class Formatter
|
4
|
-
# Formats the
|
4
|
+
# Formats the strange date format from Infostrada.
|
5
5
|
def self.format_date(date)
|
6
6
|
if date && match = date.match(/\/Date\(([0-9]+)([\+\-])([0-9]+)\)\//i)
|
7
7
|
# The date was in miliseconds since Unix epoch
|
@@ -12,9 +12,9 @@ module Infostrada
|
|
12
12
|
|
13
13
|
final = stamp.send(match[2], offset)
|
14
14
|
|
15
|
-
Time.at(final).
|
15
|
+
Time.at(final).utc
|
16
16
|
else
|
17
|
-
Time.now.
|
17
|
+
Time.now.utc
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
data/lib/infostrada/match.rb
CHANGED
@@ -2,6 +2,15 @@ require 'infostrada/referee'
|
|
2
2
|
require 'infostrada/match_event_list'
|
3
3
|
|
4
4
|
module Infostrada
|
5
|
+
# You can get the information about a single game, about all games in an edition or about all
|
6
|
+
# games in a day.
|
7
|
+
#
|
8
|
+
# Examples:
|
9
|
+
#
|
10
|
+
# Infostrada::Match.where(edition_id: 2398) # all matches for edition 2398
|
11
|
+
# Infostrada::Match.where(date: Time.now) # all matches for current date (live info)
|
12
|
+
# Infostrada::Match.where(date: Date.today+1.day) # all matches for tomorrow (live info)
|
13
|
+
# Infostrada::Match.where(id: 1337) # information about the match 1337
|
5
14
|
class Match < Infostrada::BaseRequest
|
6
15
|
extend Forwardable
|
7
16
|
|
@@ -9,7 +18,7 @@ module Infostrada
|
|
9
18
|
attr_accessor :stadium_id, :stadium_name, :goals, :match_status, :finished, :awarded
|
10
19
|
attr_accessor :postponed, :referee, :spectators, :leg, :knockout_phase, :first_leg_score
|
11
20
|
attr_accessor :aggregate_winner_id, :current_period_started_at, :status, :started_at, :started
|
12
|
-
attr_accessor :
|
21
|
+
attr_accessor :edition
|
13
22
|
|
14
23
|
# Check if the live score, live goals and live lineups are already available
|
15
24
|
attr_accessor :live, :live_score, :live_goals, :live_lineup
|
@@ -17,17 +26,51 @@ module Infostrada
|
|
17
26
|
# Lineup
|
18
27
|
attr_accessor :lineup_provisional, :lineup_official
|
19
28
|
|
29
|
+
# period is taken from Infostradas n_PeriodSort, that can have one of these values:
|
30
|
+
#
|
31
|
+
# 1 = Not started
|
32
|
+
# 2 = 1st Half
|
33
|
+
# 3 = Halftime
|
34
|
+
# 4 = 2nd Half
|
35
|
+
# 5 = 90 mins
|
36
|
+
# 6 = 1st Extra Time
|
37
|
+
# 7 = 105 mins
|
38
|
+
# 8 = 2nd Extra Time
|
39
|
+
# 9 = 120 mins
|
40
|
+
# 10 = Penalty Shootout
|
41
|
+
# 11 = End
|
42
|
+
attr_accessor :period
|
43
|
+
|
44
|
+
# status_code is taken from Infostradas n_MatchStatusCode, that can have on of these values:
|
45
|
+
#
|
46
|
+
# 2 = Line-up
|
47
|
+
# 4 = Not Started
|
48
|
+
# 8 = In Progress
|
49
|
+
# 16 = Interval
|
50
|
+
# 32 = Suspended (during the match)
|
51
|
+
# 128 = Finished (official result)
|
52
|
+
# 192 = Finished (unofficial result). This is a combination of code 64 and 128.
|
53
|
+
# 512 = Abandoned
|
54
|
+
# 1024 = Postponed
|
55
|
+
# 2048 = Delayed
|
56
|
+
#
|
57
|
+
# If a match is stopped temporarily, n_MatchStatusCode is set to 32 (=Suspended).
|
58
|
+
# If it becomes clear that the match, after being suspended, will not be restarted on the same
|
59
|
+
# day, n_MatchStatusCode is set to 512 (=Abandoned).
|
60
|
+
attr_accessor :status_code
|
61
|
+
|
20
62
|
def_delegator :@referee, :name, :referee_name
|
21
63
|
def_delegator :@phase, :name, :phase_name
|
22
64
|
def_delegator :@goals, :away_goals, :away_goals
|
23
65
|
def_delegator :@goals, :home_goals, :home_goals
|
66
|
+
def_delegator :@edition, :id, :edition_id
|
24
67
|
|
25
68
|
# We can get all matches for a given edition (very heavy payload). Or we can just get the match
|
26
69
|
# information on a single match.
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
}
|
70
|
+
register_endpoint 'GetMatchList_Edition'
|
71
|
+
# single: '/GetMatchInfo',
|
72
|
+
# live_list: '/GetMatchLiveList_Date'
|
73
|
+
#}
|
31
74
|
|
32
75
|
def self.where(options = {})
|
33
76
|
list = get_match_list(options)
|
@@ -43,9 +86,12 @@ module Infostrada
|
|
43
86
|
def self.get_match_list(options)
|
44
87
|
edition_id = options.delete(:edition_id)
|
45
88
|
match_id = options.delete(:id)
|
89
|
+
date = options.delete(:date)
|
90
|
+
date = date.strftime('%Y%m%d') if date
|
46
91
|
|
47
92
|
list = get!(URLS[:list], query: { editionid: edition_id.to_i }) if edition_id
|
48
93
|
list = get!(URLS[:single], query: { matchid: match_id.to_i }) if match_id
|
94
|
+
list = get!(URLS[:live_list], query: { date: date }) if date
|
49
95
|
|
50
96
|
list
|
51
97
|
end
|
@@ -54,10 +100,11 @@ module Infostrada
|
|
54
100
|
@id = hash['n_MatchID']
|
55
101
|
@date = Formatter.format_date(hash['d_DateUTC'])
|
56
102
|
@rescheduled = hash['b_RescheduledToBeResumed']
|
57
|
-
@round = hash['
|
103
|
+
@round = hash['n_RoundNr']
|
58
104
|
|
59
105
|
@aggregate_winner_id = hash['n_WinnerOnAggregateTeamID']
|
60
106
|
@current_period_started_at = Formatter.format_date(hash['d_CurrentPeriodStartTime'])
|
107
|
+
@status_code = hash['n_MatchStatusCode']
|
61
108
|
@status = hash['c_MatchStatus']
|
62
109
|
@status_short = hash['c_MatchStatusShort']
|
63
110
|
@leg = hash['n_Leg']
|
@@ -65,13 +112,13 @@ module Infostrada
|
|
65
112
|
|
66
113
|
@stadium_id = hash['n_StadiumGeoID']
|
67
114
|
@stadium_name = hash['c_Stadium']
|
115
|
+
@spectators = hash['n_Spectators']
|
68
116
|
|
69
117
|
@live = hash['b_Live']
|
70
118
|
@started = hash['b_Started']
|
71
119
|
@finished = hash['b_Finished']
|
72
120
|
@awarded = hash['b_Awarded']
|
73
121
|
|
74
|
-
@live = hash['b_Live']
|
75
122
|
@live_score = hash['b_DataEntryLiveScore']
|
76
123
|
@live_goals = hash['b_DataEntryLiveGoal']
|
77
124
|
@live_lineup = hash['b_DataEntryLiveLineup']
|
@@ -79,6 +126,8 @@ module Infostrada
|
|
79
126
|
@lineup_provisional = hash['b_LineupProvisional']
|
80
127
|
@lineup_official = hash['b_LineupOfficial']
|
81
128
|
|
129
|
+
@period = hash['n_PeriodSort']
|
130
|
+
|
82
131
|
@referee = Referee.new(hash)
|
83
132
|
@phase = Phase.new(hash)
|
84
133
|
|
@@ -87,11 +136,23 @@ module Infostrada
|
|
87
136
|
|
88
137
|
@goals = Goals.new(hash)
|
89
138
|
|
90
|
-
@
|
139
|
+
@edition = Edition.new(hash)
|
91
140
|
|
92
141
|
self
|
93
142
|
end
|
94
143
|
|
144
|
+
def live_score?
|
145
|
+
@live_score || false
|
146
|
+
end
|
147
|
+
|
148
|
+
def live_goals?
|
149
|
+
@live_goals || false
|
150
|
+
end
|
151
|
+
|
152
|
+
def live_lineup?
|
153
|
+
@live_lineup || false
|
154
|
+
end
|
155
|
+
|
95
156
|
def live_event_list
|
96
157
|
event_list = MatchEventList.where(match_id: self.id)
|
97
158
|
end
|
data/lib/infostrada/phase.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
module Infostrada
|
2
2
|
# Phase of a given edition.
|
3
|
+
#
|
3
4
|
# The only thing that can be confusing is the current and currents boolean variables. Here's an
|
4
5
|
# explanation from the Infostrada API website:
|
5
6
|
#
|
@@ -30,6 +31,11 @@ module Infostrada
|
|
30
31
|
phases
|
31
32
|
end
|
32
33
|
|
34
|
+
# Get the classification table for this phase.
|
35
|
+
def table
|
36
|
+
Table.where(phase_id: id)
|
37
|
+
end
|
38
|
+
|
33
39
|
def initialize(hash)
|
34
40
|
@id = hash['n_PhaseID']
|
35
41
|
@name = hash['c_Phase']
|
@@ -40,7 +46,7 @@ module Infostrada
|
|
40
46
|
@phase2_name = hash['c_Phase2']
|
41
47
|
@phase3_id = hash['n_Phase3ID']
|
42
48
|
@phase3_name = hash['c_Phase3']
|
43
|
-
@
|
49
|
+
@has_table = hash['b_Table']
|
44
50
|
@current = hash['b_Current']
|
45
51
|
@currents = hash['b_Currents']
|
46
52
|
|
@@ -53,5 +59,9 @@ module Infostrada
|
|
53
59
|
|
54
60
|
self
|
55
61
|
end
|
62
|
+
|
63
|
+
def has_table?
|
64
|
+
@has_table
|
65
|
+
end
|
56
66
|
end
|
57
67
|
end
|
data/lib/infostrada/player.rb
CHANGED
@@ -3,6 +3,18 @@ module Infostrada
|
|
3
3
|
attr_accessor :person_id, :name, :short_name, :birthdate, :function, :shirt_number
|
4
4
|
attr_accessor :season_stats, :nation, :contract_starts_at, :contract_ends_at
|
5
5
|
|
6
|
+
# The function_type variable maps Infostradas n_FunctionType and can have one of these values:
|
7
|
+
#
|
8
|
+
# 1 = Keeper
|
9
|
+
# 2 = Defender
|
10
|
+
# 4 = Midfielder
|
11
|
+
# 8 = Forward
|
12
|
+
# 16 = Trainer
|
13
|
+
# 64 = Referee
|
14
|
+
# 128 = Linesman
|
15
|
+
# 1073741824 = 4th Official
|
16
|
+
attr_accessor :function_type
|
17
|
+
|
6
18
|
def initialize(hash)
|
7
19
|
@person_id = hash['n_PersonID']
|
8
20
|
@name = hash['c_Person']
|
@@ -10,9 +22,10 @@ module Infostrada
|
|
10
22
|
|
11
23
|
@birthdate = Formatter.format_date(hash['d_BirthDate'])
|
12
24
|
|
13
|
-
# Function
|
14
|
-
#
|
25
|
+
# Function is one string like "Goalkeeper", "Defender", "Midfielder", "Forward", "Coach"...
|
26
|
+
# Infostrada doesn't document the function strings so you should rely on function_type
|
15
27
|
@function = hash['c_Function']
|
28
|
+
@function_type = hash['n_FunctionType']
|
16
29
|
@shirt_number = hash['n_ShirtNr']
|
17
30
|
|
18
31
|
@contract_starts_at = Formatter.format_date(hash['d_ContractStartDate'])
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Infostrada
|
2
|
+
class Table < Infostrada::BaseRequest
|
3
|
+
include Enumerable
|
4
|
+
|
5
|
+
attr_accessor :edition_id, :phase_id, :entries
|
6
|
+
|
7
|
+
URL = '/GetTable'
|
8
|
+
|
9
|
+
def self.where(options = {})
|
10
|
+
phase_id = options.delete(:phase_id)
|
11
|
+
|
12
|
+
list = get!(URL, query: { phaseid: phase_id })
|
13
|
+
|
14
|
+
table = Table.new(phase_id, list)
|
15
|
+
end
|
16
|
+
|
17
|
+
def initialize(phase_id, table_list)
|
18
|
+
@phase_id = phase_id
|
19
|
+
|
20
|
+
@entries = []
|
21
|
+
table_list.each do |hash|
|
22
|
+
@edition_id ||= hash['n_EditionID']
|
23
|
+
@entries << TableEntry.new(hash)
|
24
|
+
end
|
25
|
+
|
26
|
+
self
|
27
|
+
end
|
28
|
+
|
29
|
+
def each(&block)
|
30
|
+
@entries.each(&block)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
class TableEntry
|
35
|
+
attr_accessor :team_id, :rank, :matches, :matches_won, :matches_drawn
|
36
|
+
attr_accessor :matches_lost, :points, :goals_for, :goals_against
|
37
|
+
|
38
|
+
def initialize(hash)
|
39
|
+
@team_id = hash['n_TeamID']
|
40
|
+
@rank = hash['n_RankSort']
|
41
|
+
@matches = hash['n_Matches']
|
42
|
+
@matches_won = hash['n_MatchesWon']
|
43
|
+
@matches_drawn = hash['n_MatchesDrawn']
|
44
|
+
@matches_lost = hash['n_MatchesLost']
|
45
|
+
@points = hash['n_Points']
|
46
|
+
@goals_for = hash['n_GoalsFor']
|
47
|
+
@goals_against = hash['n_GoalsAgainst']
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
data/lib/infostrada/version.rb
CHANGED
data/lib/infostrada.rb
CHANGED
@@ -21,18 +21,21 @@ require 'infostrada/team_info'
|
|
21
21
|
|
22
22
|
require 'infostrada/match'
|
23
23
|
require 'infostrada/phase'
|
24
|
+
require 'infostrada/table'
|
24
25
|
|
25
26
|
require 'infostrada/squad'
|
26
27
|
require 'infostrada/player'
|
27
28
|
require 'infostrada/person_info'
|
28
29
|
|
30
|
+
require 'infostrada/call_refresh'
|
31
|
+
|
29
32
|
require 'infostrada/version'
|
30
33
|
|
31
34
|
module Infostrada
|
32
35
|
# The configuration of the API requests. This configuration is also shared by
|
33
36
|
# <Infostrada::BaseRequest> where the HTTParty configuration is done.
|
34
37
|
class Configuration
|
35
|
-
attr_reader :user, :password, :timeout
|
38
|
+
attr_reader :user, :password, :timeout, :timezone
|
36
39
|
|
37
40
|
def initialize
|
38
41
|
BaseRequest.default_options[:basic_auth] ||= {}
|
@@ -58,7 +61,11 @@ module Infostrada
|
|
58
61
|
end
|
59
62
|
|
60
63
|
def self.configuration
|
61
|
-
@configuration ||=
|
64
|
+
@configuration ||= Configuration.new
|
65
|
+
end
|
66
|
+
|
67
|
+
def self.endpoints
|
68
|
+
@endpoints ||= []
|
62
69
|
end
|
63
70
|
|
64
71
|
def self.configure
|
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.0.
|
4
|
+
version: 0.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ricardo Otero
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -108,6 +108,34 @@ dependencies:
|
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: tzinfo
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: pry
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
111
139
|
description: Infostrada Football API wrapper.
|
112
140
|
email:
|
113
141
|
- oterosantos@gmail.com
|
@@ -121,13 +149,16 @@ files:
|
|
121
149
|
- README.md
|
122
150
|
- bin/strada
|
123
151
|
- infostrada.gemspec
|
152
|
+
- infostrada.pstore
|
124
153
|
- lib/infostrada.rb
|
125
154
|
- lib/infostrada/base_request.rb
|
155
|
+
- lib/infostrada/call_refresh.rb
|
126
156
|
- lib/infostrada/commands.rb
|
127
157
|
- lib/infostrada/competition.rb
|
128
158
|
- lib/infostrada/core_ext/string.rb
|
129
159
|
- lib/infostrada/edition.rb
|
130
160
|
- lib/infostrada/edition_request.rb
|
161
|
+
- lib/infostrada/endpoint_manager.rb
|
131
162
|
- lib/infostrada/errors.rb
|
132
163
|
- lib/infostrada/formatter.rb
|
133
164
|
- lib/infostrada/match.rb
|
@@ -139,6 +170,7 @@ files:
|
|
139
170
|
- lib/infostrada/player.rb
|
140
171
|
- lib/infostrada/referee.rb
|
141
172
|
- lib/infostrada/squad.rb
|
173
|
+
- lib/infostrada/table.rb
|
142
174
|
- lib/infostrada/team.rb
|
143
175
|
- lib/infostrada/team_info.rb
|
144
176
|
- lib/infostrada/team_request.rb
|