infostrada 0.0.1 → 0.0.9
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/lib/infostrada/base_request.rb +21 -2
- data/lib/infostrada/competition.rb +13 -13
- data/lib/infostrada/edition.rb +3 -1
- data/lib/infostrada/edition_request.rb +3 -1
- data/lib/infostrada/match.rb +118 -0
- data/lib/infostrada/match_event.rb +34 -0
- data/lib/infostrada/match_event_list.rb +22 -0
- data/lib/infostrada/nation.rb +7 -0
- data/lib/infostrada/person_info.rb +3 -1
- data/lib/infostrada/phase.rb +57 -0
- data/lib/infostrada/player.rb +11 -12
- data/lib/infostrada/referee.rb +13 -0
- data/lib/infostrada/squad.rb +3 -1
- data/lib/infostrada/team.rb +33 -18
- data/lib/infostrada/team_info.rb +6 -2
- data/lib/infostrada/team_request.rb +4 -2
- data/lib/infostrada/version.rb +1 -1
- data/lib/infostrada.rb +5 -1
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a4cb72e08b9e4d09f02497612a54a0734521bfd9
|
4
|
+
data.tar.gz: 52471df74223d184f91240e5c8a9b9af68a7ce29
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4629ca8db63754ef1c2aa47dab651edfcbe96406a89edfa05b3a0b4f368cc48b7c4520bfa29624dad9ff037fb70b7996e6496015c9654c87a0fc8d165e1f603f
|
7
|
+
data.tar.gz: 2136d24be6c40c5e93f132078afe595a62bae73f2f4770b319bba4ba4b313ccf3613ea46e565556cb3462e6dd8d906e0d4d4b6b7966a0cef98020caba81f477c
|
@@ -5,10 +5,13 @@ module Infostrada
|
|
5
5
|
class BaseRequest
|
6
6
|
include HTTParty
|
7
7
|
|
8
|
+
# How many times should we retry the request if Timeout::Error is raised?
|
9
|
+
RETRIES = 5
|
10
|
+
|
8
11
|
# Uncomment to debug HTTParty calls.
|
9
12
|
# debug_output $stdout
|
10
13
|
|
11
|
-
basic_auth 'APIdemo', '
|
14
|
+
basic_auth 'APIdemo', 'saTo1991W&dy'
|
12
15
|
|
13
16
|
# The default format of the requests. Used on HTTP header 'Content-Type'.
|
14
17
|
format :json
|
@@ -26,11 +29,27 @@ module Infostrada
|
|
26
29
|
# Disable the use of rails query string format.
|
27
30
|
#
|
28
31
|
# With rails query string format enabled:
|
29
|
-
# => get '/', :query => {:
|
32
|
+
# => get '/', :query => { selected_ids: [1,2,3] }
|
30
33
|
#
|
31
34
|
# Would translate to this:
|
32
35
|
# => /?selected_ids[]=1&selected_ids[]=2&selected_ids[]=3
|
33
36
|
#
|
34
37
|
disable_rails_query_string_format
|
38
|
+
|
39
|
+
# Used with Timeout::Error rescue so we can keep trying to fetch the information after timeout.
|
40
|
+
def self.get!(path, options = {}, &block)
|
41
|
+
attempts = 1
|
42
|
+
result = nil
|
43
|
+
|
44
|
+
begin
|
45
|
+
result = get(path, options, &block)
|
46
|
+
rescue Timeout::Error => error
|
47
|
+
puts "Timeout! Retrying... (#{attempts})"
|
48
|
+
attempts += 1
|
49
|
+
retry unless attempts > RETRIES
|
50
|
+
end
|
51
|
+
|
52
|
+
result
|
53
|
+
end
|
35
54
|
end
|
36
55
|
end
|
@@ -1,4 +1,16 @@
|
|
1
1
|
module Infostrada
|
2
|
+
# n_CompetitionSet is an indicator for the type of Competition:
|
3
|
+
#
|
4
|
+
# 1 = domestic league
|
5
|
+
# 2 = domestic cup
|
6
|
+
# 3 = international club competition (e.g. Champions League)
|
7
|
+
# 4 = country competition (e.g. World Cup)
|
8
|
+
#
|
9
|
+
# n_CompetitionLevel is an indicator for the level of a domestic competition:
|
10
|
+
#
|
11
|
+
# 1 = highest level (e.g. German Bundesliga)
|
12
|
+
# 2 = 2nd highest level (e.g. German 2. Bundesliga)
|
13
|
+
# 3 = 3rd highest level and so on
|
2
14
|
class Competition
|
3
15
|
attr_accessor :id, :name, :set, :level, :nation
|
4
16
|
|
@@ -6,19 +18,7 @@ module Infostrada
|
|
6
18
|
@id = hash.delete('n_CompetitionID')
|
7
19
|
@name = hash.delete('c_Competition')
|
8
20
|
|
9
|
-
@nation = Nation.new
|
10
|
-
set_nation_attributes(hash)
|
11
|
-
end
|
12
|
-
|
13
|
-
private
|
14
|
-
|
15
|
-
def set_nation_attributes(hash)
|
16
|
-
hash.each do |key, value|
|
17
|
-
if key =~ /[cn]_\w+Natio.*/
|
18
|
-
method = "#{key.snake_case.gsub(/[cn]_competition_?/, '')}="
|
19
|
-
@nation.send(method, value)
|
20
|
-
end
|
21
|
-
end
|
21
|
+
@nation = Nation.new(hash, 'competition')
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
data/lib/infostrada/edition.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'forwardable'
|
2
|
+
|
1
3
|
module Infostrada
|
2
4
|
class Edition
|
3
5
|
extend Forwardable
|
@@ -15,7 +17,7 @@ module Infostrada
|
|
15
17
|
@id = hash.delete('n_EditionID')
|
16
18
|
@season = hash.delete('c_Season')
|
17
19
|
@start_date = Formatter.format_date(hash.delete('d_EditionStartDate'))
|
18
|
-
@end_date = hash.delete('d_EditionEndDate')
|
20
|
+
@end_date = Formatter.format_date(hash.delete('d_EditionEndDate'))
|
19
21
|
|
20
22
|
@competition = Competition.new(hash)
|
21
23
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'infostrada/base_request'
|
2
|
+
|
1
3
|
module Infostrada
|
2
4
|
class EditionRequest < Infostrada::BaseRequest
|
3
5
|
URLS = {
|
@@ -5,7 +7,7 @@ module Infostrada
|
|
5
7
|
}
|
6
8
|
|
7
9
|
def self.get_list
|
8
|
-
list = get(URLS[:list])
|
10
|
+
list = get!(URLS[:list])
|
9
11
|
|
10
12
|
editions = []
|
11
13
|
list.each do |edition_hash|
|
@@ -0,0 +1,118 @@
|
|
1
|
+
require 'infostrada/referee'
|
2
|
+
require 'infostrada/match_event_list'
|
3
|
+
|
4
|
+
module Infostrada
|
5
|
+
class Match < Infostrada::BaseRequest
|
6
|
+
extend Forwardable
|
7
|
+
|
8
|
+
attr_accessor :id, :date, :rescheduled, :round, :home_team, :away_team, :phase, :status_short
|
9
|
+
attr_accessor :stadium_id, :stadium_name, :goals, :match_status, :finished, :awarded
|
10
|
+
attr_accessor :postponed, :referee, :spectators, :leg, :knockout_phase, :first_leg_score
|
11
|
+
attr_accessor :aggregate_winner_id, :current_period_started_at, :status, :started_at, :started
|
12
|
+
attr_accessor :competition
|
13
|
+
|
14
|
+
# Check if the live score, live goals and live lineups are already available
|
15
|
+
attr_accessor :live, :live_score, :live_goals, :live_lineup
|
16
|
+
|
17
|
+
# Lineup
|
18
|
+
attr_accessor :lineup_provisional, :lineup_official
|
19
|
+
|
20
|
+
def_delegator :@referee, :name, :referee_name
|
21
|
+
def_delegator :@phase, :name, :phase_name
|
22
|
+
def_delegator :@goals, :away_goals, :away_goals
|
23
|
+
def_delegator :@goals, :home_goals, :home_goals
|
24
|
+
|
25
|
+
# We can get all matches for a given edition (very heavy payload). Or we can just get the match
|
26
|
+
# information on a single match.
|
27
|
+
URLS = {
|
28
|
+
list: '/GetMatchList_Edition',
|
29
|
+
single: '/GetMatchInfo'
|
30
|
+
}
|
31
|
+
|
32
|
+
def self.where(options = {})
|
33
|
+
list = get_match_list(options)
|
34
|
+
|
35
|
+
matches = []
|
36
|
+
list.each do |match_hash|
|
37
|
+
matches << Match.new(match_hash)
|
38
|
+
end
|
39
|
+
|
40
|
+
matches.size > 1 ? matches : matches.first
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.get_match_list(options)
|
44
|
+
edition_id = options.delete(:edition_id)
|
45
|
+
match_id = options.delete(:id)
|
46
|
+
|
47
|
+
list = get!(URLS[:list], query: { editionid: edition_id.to_i }) if edition_id
|
48
|
+
list = get!(URLS[:single], query: { matchid: match_id.to_i }) if match_id
|
49
|
+
|
50
|
+
list
|
51
|
+
end
|
52
|
+
|
53
|
+
def initialize(hash)
|
54
|
+
@id = hash['n_MatchID']
|
55
|
+
@date = Formatter.format_date(hash['d_DateUTC'])
|
56
|
+
@rescheduled = hash['b_RescheduledToBeResumed']
|
57
|
+
@round = hash['round']
|
58
|
+
|
59
|
+
@aggregate_winner_id = hash['n_WinnerOnAggregateTeamID']
|
60
|
+
@current_period_started_at = Formatter.format_date(hash['d_CurrentPeriodStartTime'])
|
61
|
+
@status = hash['c_MatchStatus']
|
62
|
+
@status_short = hash['c_MatchStatusShort']
|
63
|
+
@leg = hash['n_Leg']
|
64
|
+
@started_at = Formatter.format_date(hash['d_MatchStartTime'])
|
65
|
+
|
66
|
+
@stadium_id = hash['n_StadiumGeoID']
|
67
|
+
@stadium_name = hash['c_Stadium']
|
68
|
+
|
69
|
+
@live = hash['b_Live']
|
70
|
+
@started = hash['b_Started']
|
71
|
+
@finished = hash['b_Finished']
|
72
|
+
@awarded = hash['b_Awarded']
|
73
|
+
|
74
|
+
@live = hash['b_Live']
|
75
|
+
@live_score = hash['b_DataEntryLiveScore']
|
76
|
+
@live_goals = hash['b_DataEntryLiveGoal']
|
77
|
+
@live_lineup = hash['b_DataEntryLiveLineup']
|
78
|
+
|
79
|
+
@lineup_provisional = hash['b_LineupProvisional']
|
80
|
+
@lineup_official = hash['b_LineupOfficial']
|
81
|
+
|
82
|
+
@referee = Referee.new(hash)
|
83
|
+
@phase = Phase.new(hash)
|
84
|
+
|
85
|
+
@home_team = Team.new(hash, 'home')
|
86
|
+
@away_team = Team.new(hash, 'away')
|
87
|
+
|
88
|
+
@goals = Goals.new(hash)
|
89
|
+
|
90
|
+
@competition = Competition.new(hash)
|
91
|
+
|
92
|
+
self
|
93
|
+
end
|
94
|
+
|
95
|
+
def live_event_list
|
96
|
+
event_list = MatchEventList.where(match_id: self.id)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
class Goals
|
101
|
+
attr_accessor :home_goals, :away_goals, :home_goals_half_time, :away_goals_half_time,
|
102
|
+
:home_goals_90_mins, :away_goals_90_mins, :home_goals_105_mins, :away_goals_150_mins,
|
103
|
+
:home_goals_shootout, :away_goals_shootout
|
104
|
+
|
105
|
+
def initialize(hash)
|
106
|
+
@home_goals = hash['n_HomeGoals']
|
107
|
+
@away_goals = hash['n_AwayGoals']
|
108
|
+
@home_goals_half_time = hash['n_HomeGoalsHalftime']
|
109
|
+
@away_goals_half_time = hash['n_AwayGoalsHalftime']
|
110
|
+
@home_goals_90_mins = hash['n_HomeGoals90mins']
|
111
|
+
@away_goals_90_mins = hash['n_AwayGoals90mins']
|
112
|
+
@home_goals_105_mins = hash['n_HomeGoals105mins']
|
113
|
+
@away_goals_105_mins = hash['n_AwayGoals105mins']
|
114
|
+
@home_goals_shootout = hash['n_HomeGoalsShootout']
|
115
|
+
@away_goald_shootout = hash['n_AwayGoalsShootout']
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Infostrada
|
2
|
+
class MatchEvent
|
3
|
+
attr_accessor :id, :description, :short_description, :period, :period_short, :time, :home_goals
|
4
|
+
attr_accessor :away_goals, :home_event, :team_id, :team_name, :team_short_name, :person_id
|
5
|
+
attr_accessor :person_name, :person_short_name, :reason, :info, :person2_id, :person2_name
|
6
|
+
attr_accessor :person2_short_name, :minute
|
7
|
+
|
8
|
+
def initialize(hash)
|
9
|
+
@id = hash['n_ActionID']
|
10
|
+
@description = hash['c_Action']
|
11
|
+
@short_description = hash['c_ActionShort']
|
12
|
+
@period = hash['c_Period']
|
13
|
+
@period_short = hash['c_PeriodShort']
|
14
|
+
@time = hash['n_ActionTime']
|
15
|
+
@home_goals = hash['n_HomeGoals']
|
16
|
+
@away_goals = hash['n_AwayGoals']
|
17
|
+
@home_event = (hash['n_HomeOrAway'] == 1) ? true : false
|
18
|
+
@team_id = hash['n_TeamID']
|
19
|
+
@team_name = hash['c_Team']
|
20
|
+
@team_short_name = hash['c_TeamShort']
|
21
|
+
@person_id = hash['n_PersonID']
|
22
|
+
@person_name = hash['c_Person']
|
23
|
+
@person_short_name = hash['c_PersonShort']
|
24
|
+
@reason = hash['c_ActionReason']
|
25
|
+
@info = hash['c_ActionInfo']
|
26
|
+
@person2_id = hash['n_SubPersonID']
|
27
|
+
@person2_name = hash['c_SubPerson']
|
28
|
+
@person2_short_name = hash['c_SubPersonShort']
|
29
|
+
@minute = hash['c_ActionMinute']
|
30
|
+
|
31
|
+
self
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'infostrada/match_event'
|
2
|
+
|
3
|
+
module Infostrada
|
4
|
+
class MatchEventList < Infostrada::BaseRequest
|
5
|
+
URL = '/GetMatchActionList_All'
|
6
|
+
|
7
|
+
attr_accessor :events
|
8
|
+
|
9
|
+
def self.where(options = {})
|
10
|
+
match_id = options.delete(:match_id)
|
11
|
+
|
12
|
+
list = get!(URL, query: { matchid: match_id.to_i })
|
13
|
+
|
14
|
+
events = []
|
15
|
+
list.each do |event_hash|
|
16
|
+
events << MatchEvent.new(event_hash)
|
17
|
+
end
|
18
|
+
|
19
|
+
events
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/infostrada/nation.rb
CHANGED
@@ -2,6 +2,13 @@ module Infostrada
|
|
2
2
|
class Nation
|
3
3
|
attr_accessor :id, :name, :short_name
|
4
4
|
|
5
|
+
def initialize(hash, prefix)
|
6
|
+
hash.each do |key, value|
|
7
|
+
match = key.snake_case.match(/[cn]_#{prefix}_?(natio\w*)$/)
|
8
|
+
self.send("#{$1}=", value) if match
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
5
12
|
def natio_geo_id=(id)
|
6
13
|
self.id = id
|
7
14
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'infostrada/base_request'
|
2
|
+
|
1
3
|
module Infostrada
|
2
4
|
class PersonInfo < Infostrada::BaseRequest
|
3
5
|
URL = '/GetPersonInfo'
|
@@ -7,7 +9,7 @@ module Infostrada
|
|
7
9
|
|
8
10
|
def self.where(options)
|
9
11
|
id = options.delete(:person_id)
|
10
|
-
info = get(URL, query: { personid: id }).first
|
12
|
+
info = get!(URL, query: { personid: id }).first
|
11
13
|
self.new(id, info)
|
12
14
|
end
|
13
15
|
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module Infostrada
|
2
|
+
# Phase of a given edition.
|
3
|
+
# The only thing that can be confusing is the current and currents boolean variables. Here's an
|
4
|
+
# explanation from the Infostrada API website:
|
5
|
+
#
|
6
|
+
# * b_Current: this boolean field describes the current phase. This field can be True for only
|
7
|
+
# one phase.
|
8
|
+
#
|
9
|
+
# * b_Currents: this boolean field describes the current phases. More than one phases can be
|
10
|
+
# True, e.g. multiple groups in the Champions League.
|
11
|
+
#
|
12
|
+
# You can only get a list of phases on Infostradas GetPhaseList endpoint.
|
13
|
+
class Phase < Infostrada::BaseRequest
|
14
|
+
URL = '/GetPhaseList'
|
15
|
+
|
16
|
+
# Short name is only set outside GetPhaseList endpoint. For example on match list.
|
17
|
+
attr_accessor :id, :name, :phase1_id, :phase1_name, :phase2_id, :phase2_name, :phase3_id
|
18
|
+
attr_accessor :phase3_name, :table, :current, :currents, :start_date, :end_date, :short_name
|
19
|
+
|
20
|
+
def self.where(options = {})
|
21
|
+
edition_id = options.delete(:edition_id)
|
22
|
+
|
23
|
+
list = get!(URL, query: { editionid: edition_id.to_i })
|
24
|
+
|
25
|
+
phases = []
|
26
|
+
list.each do |phase_hash|
|
27
|
+
phases << Phase.new(phase_hash)
|
28
|
+
end
|
29
|
+
|
30
|
+
phases
|
31
|
+
end
|
32
|
+
|
33
|
+
def initialize(hash)
|
34
|
+
@id = hash['n_PhaseID']
|
35
|
+
@name = hash['c_Phase']
|
36
|
+
@short_name = hash['c_PhaseShort']
|
37
|
+
@phase1_id = hash['n_Phase1ID']
|
38
|
+
@phase1_name = hash['c_Phase1']
|
39
|
+
@phase2_id = hash['n_Phase2ID']
|
40
|
+
@phase2_name = hash['c_Phase2']
|
41
|
+
@phase3_id = hash['n_Phase3ID']
|
42
|
+
@phase3_name = hash['c_Phase3']
|
43
|
+
@table = hash['b_Table']
|
44
|
+
@current = hash['b_Current']
|
45
|
+
@currents = hash['b_Currents']
|
46
|
+
|
47
|
+
# On GetPhaseList endpoint dates are just yyymmdd. Example: 20100629 (which translates to
|
48
|
+
# 2010-06-29).
|
49
|
+
if hash['n_DateStart'] && hash['n_DateEnd']
|
50
|
+
@start_date = Date.parse(hash['n_DateStart'].to_s)
|
51
|
+
@end_date = Date.parse(hash['n_DateEnd'].to_s)
|
52
|
+
end
|
53
|
+
|
54
|
+
self
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
data/lib/infostrada/player.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Infostrada
|
2
2
|
class Player
|
3
3
|
attr_accessor :person_id, :name, :short_name, :birthdate, :function, :shirt_number
|
4
|
-
attr_accessor :season_stats, :nation
|
4
|
+
attr_accessor :season_stats, :nation, :contract_starts_at, :contract_ends_at
|
5
5
|
|
6
6
|
def initialize(hash)
|
7
7
|
@person_id = hash['n_PersonID']
|
@@ -15,11 +15,19 @@ module Infostrada
|
|
15
15
|
@function = hash['c_Function']
|
16
16
|
@shirt_number = hash['n_ShirtNr']
|
17
17
|
|
18
|
+
@contract_starts_at = Formatter.format_date(hash['d_ContractStartDate'])
|
19
|
+
@contract_ends_at = Formatter.format_date(hash['d_ContractEndDate'])
|
20
|
+
|
18
21
|
# Season statistics
|
19
22
|
set_season_stats(hash)
|
20
23
|
|
21
|
-
@nation = Nation.new
|
22
|
-
|
24
|
+
@nation = Nation.new(hash, 'person')
|
25
|
+
|
26
|
+
self
|
27
|
+
end
|
28
|
+
|
29
|
+
def name?
|
30
|
+
@name && !@name.empty?
|
23
31
|
end
|
24
32
|
|
25
33
|
private
|
@@ -40,15 +48,6 @@ module Infostrada
|
|
40
48
|
@season_stats[:cards_red_direct] = hash['n_CardsRedDirect']
|
41
49
|
@season_stats[:cards_red_from_yellow] = hash['n_CardsRed2Yellow']
|
42
50
|
end
|
43
|
-
|
44
|
-
def set_nation_attributes(hash)
|
45
|
-
hash.each do |key, value|
|
46
|
-
if key =~ /[cn]_\w+Natio.*/
|
47
|
-
method = "#{key.snake_case.gsub(/[cn]_person_?/, '')}="
|
48
|
-
@nation.send(method, value)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
51
|
end
|
53
52
|
end
|
54
53
|
|
data/lib/infostrada/squad.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'infostrada/base_request'
|
2
|
+
|
1
3
|
module Infostrada
|
2
4
|
class Squad < Infostrada::BaseRequest
|
3
5
|
URL = '/GetSquad'
|
@@ -6,7 +8,7 @@ module Infostrada
|
|
6
8
|
edition_id = options.delete(:edition_id)
|
7
9
|
team_id = options.delete(:team_id)
|
8
10
|
|
9
|
-
list = get(URL, query: { editionid: edition_id, teamid: team_id })
|
11
|
+
list = get!(URL, query: { editionid: edition_id, teamid: team_id })
|
10
12
|
|
11
13
|
players = []
|
12
14
|
list.each do |player_hash|
|
data/lib/infostrada/team.rb
CHANGED
@@ -1,34 +1,49 @@
|
|
1
1
|
module Infostrada
|
2
2
|
class Team
|
3
|
+
extend Forwardable
|
4
|
+
|
5
|
+
def_delegator :@nation, :id, :nation_id
|
6
|
+
def_delegator :@nation, :name, :nation_name
|
7
|
+
def_delegator :@nation, :short_name, :nation_short_name
|
8
|
+
|
3
9
|
attr_accessor :id, :name, :short_name, :nation, :edition_id
|
4
10
|
|
5
|
-
def self.
|
11
|
+
def self.where(options = {})
|
12
|
+
edition_id = options.delete(:edition_id)
|
6
13
|
teams = TeamRequest.get_edition(edition_id.to_i)
|
7
14
|
end
|
8
15
|
|
9
|
-
def initialize(hash)
|
10
|
-
@
|
11
|
-
|
12
|
-
|
13
|
-
|
16
|
+
def initialize(hash, prefix)
|
17
|
+
@edition_id = hash['edition_id']
|
18
|
+
|
19
|
+
hash.each do |key, value|
|
20
|
+
case key.snake_case
|
21
|
+
when /^[cn]\w+#{prefix}_?team_id$/
|
22
|
+
self.send('team_id=', value)
|
23
|
+
when /^[cn]\w+#{prefix}_?team$/
|
24
|
+
self.send('team_name=', value)
|
25
|
+
when /^[cn]\w+#{prefix}_?team_short$/
|
26
|
+
self.send('team_short=', value)
|
27
|
+
end
|
28
|
+
end
|
14
29
|
|
15
|
-
@nation = Nation.new
|
16
|
-
set_nation_attributes(hash)
|
30
|
+
@nation = Nation.new(hash, "#{prefix}_team")
|
17
31
|
end
|
18
32
|
|
19
|
-
def
|
20
|
-
|
33
|
+
def team_id=(id)
|
34
|
+
@id = id
|
21
35
|
end
|
22
36
|
|
23
|
-
|
37
|
+
def team_name=(name)
|
38
|
+
@name = name
|
39
|
+
end
|
24
40
|
|
25
|
-
def
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
end
|
41
|
+
def team_short=(short_name)
|
42
|
+
@short_name = short_name
|
43
|
+
end
|
44
|
+
|
45
|
+
def details
|
46
|
+
info ||= TeamInfo.fetch(self)
|
32
47
|
end
|
33
48
|
end
|
34
49
|
end
|
data/lib/infostrada/team_info.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
+
require 'infostrada/base_request'
|
2
|
+
|
1
3
|
module Infostrada
|
2
|
-
class TeamInfo < BaseRequest
|
4
|
+
class TeamInfo < Infostrada::BaseRequest
|
3
5
|
attr_accessor :official_name, :official_short_name, :public_name, :public_short_name, :nickname
|
4
6
|
attr_accessor :foundation_date, :official_stadium_name, :stadium_name, :stadium_capacity
|
5
7
|
attr_accessor :url, :city
|
@@ -7,7 +9,7 @@ module Infostrada
|
|
7
9
|
URL = '/GetTeamInfo'
|
8
10
|
|
9
11
|
def self.fetch(team_id)
|
10
|
-
info_hash = get(URL, query: { teamid: team_id.to_i })
|
12
|
+
info_hash = get!(URL, query: { teamid: team_id.to_i })
|
11
13
|
|
12
14
|
self.new(info_hash.first)
|
13
15
|
end
|
@@ -24,6 +26,8 @@ module Infostrada
|
|
24
26
|
@stadium_capacity = hash['n_StadiumCapacity']
|
25
27
|
@url = hash['c_URL']
|
26
28
|
@city = hash['c_City']
|
29
|
+
|
30
|
+
self
|
27
31
|
end
|
28
32
|
end
|
29
33
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'infostrada/base_request'
|
2
|
+
|
1
3
|
module Infostrada
|
2
4
|
class TeamRequest < Infostrada::BaseRequest
|
3
5
|
URLS = {
|
@@ -5,11 +7,11 @@ module Infostrada
|
|
5
7
|
}
|
6
8
|
|
7
9
|
def self.get_edition(edition_id)
|
8
|
-
list = get(URLS[:list], query: { editionid: edition_id.to_i })
|
10
|
+
list = get!(URLS[:list], query: { editionid: edition_id.to_i })
|
9
11
|
|
10
12
|
teams = []
|
11
13
|
list.each do |team_hash|
|
12
|
-
teams << Team.new(team_hash.merge('edition_id' => edition_id.to_i))
|
14
|
+
teams << Team.new(team_hash.merge('edition_id' => edition_id.to_i), '')
|
13
15
|
end
|
14
16
|
|
15
17
|
teams
|
data/lib/infostrada/version.rb
CHANGED
data/lib/infostrada.rb
CHANGED
@@ -4,7 +4,6 @@ require 'httparty'
|
|
4
4
|
|
5
5
|
require 'infostrada/core_ext/string'
|
6
6
|
|
7
|
-
require 'infostrada/base_request'
|
8
7
|
require 'infostrada/competition'
|
9
8
|
|
10
9
|
require 'infostrada/edition'
|
@@ -14,10 +13,15 @@ require 'infostrada/errors'
|
|
14
13
|
|
15
14
|
require 'infostrada/nation'
|
16
15
|
|
16
|
+
require 'infostrada/formatter'
|
17
|
+
|
17
18
|
require 'infostrada/team'
|
18
19
|
require 'infostrada/team_request'
|
19
20
|
require 'infostrada/team_info'
|
20
21
|
|
22
|
+
require 'infostrada/match'
|
23
|
+
require 'infostrada/phase'
|
24
|
+
|
21
25
|
require 'infostrada/squad'
|
22
26
|
require 'infostrada/player'
|
23
27
|
require 'infostrada/person_info'
|
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.9
|
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-
|
11
|
+
date: 2014-04-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -130,9 +130,14 @@ files:
|
|
130
130
|
- lib/infostrada/edition_request.rb
|
131
131
|
- lib/infostrada/errors.rb
|
132
132
|
- lib/infostrada/formatter.rb
|
133
|
+
- lib/infostrada/match.rb
|
134
|
+
- lib/infostrada/match_event.rb
|
135
|
+
- lib/infostrada/match_event_list.rb
|
133
136
|
- lib/infostrada/nation.rb
|
134
137
|
- lib/infostrada/person_info.rb
|
138
|
+
- lib/infostrada/phase.rb
|
135
139
|
- lib/infostrada/player.rb
|
140
|
+
- lib/infostrada/referee.rb
|
136
141
|
- lib/infostrada/squad.rb
|
137
142
|
- lib/infostrada/team.rb
|
138
143
|
- lib/infostrada/team_info.rb
|