opta_sd 1.0.0

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.
Files changed (49) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +1 -0
  3. data/.rspec +3 -0
  4. data/Gemfile +22 -0
  5. data/Gemfile.lock +63 -0
  6. data/MIT-LICENSE +20 -0
  7. data/README.md +400 -0
  8. data/Rakefile +1 -0
  9. data/config/opta_sd.yml +2 -0
  10. data/config/parameters.yml +74 -0
  11. data/errors.yml +21 -0
  12. data/lib/opta_sd.rb +42 -0
  13. data/lib/opta_sd/core.rb +119 -0
  14. data/lib/opta_sd/error.rb +31 -0
  15. data/lib/opta_sd/soccer/commentary.rb +21 -0
  16. data/lib/opta_sd/soccer/match.rb +20 -0
  17. data/lib/opta_sd/soccer/match_event.rb +13 -0
  18. data/lib/opta_sd/soccer/match_facts.rb +14 -0
  19. data/lib/opta_sd/soccer/match_preview.rb +14 -0
  20. data/lib/opta_sd/soccer/match_statistics.rb +14 -0
  21. data/lib/opta_sd/soccer/pass_matrix.rb +14 -0
  22. data/lib/opta_sd/soccer/player_career.rb +15 -0
  23. data/lib/opta_sd/soccer/possession.rb +13 -0
  24. data/lib/opta_sd/soccer/rankings.rb +14 -0
  25. data/lib/opta_sd/soccer/seasonal_stats.rb +14 -0
  26. data/lib/opta_sd/soccer/soccer.rb +19 -0
  27. data/lib/opta_sd/soccer/squads.rb +14 -0
  28. data/lib/opta_sd/soccer/team_standings.rb +22 -0
  29. data/lib/opta_sd/soccer/tournament_calendar.rb +24 -0
  30. data/lib/opta_sd/soccer/tournament_schedule.rb +14 -0
  31. data/lib/opta_sd/version.rb +3 -0
  32. data/opta_sd.gemspec +27 -0
  33. data/spec/commentary_spec.rb +39 -0
  34. data/spec/match_event_spec.rb +26 -0
  35. data/spec/match_facts_spec.rb +14 -0
  36. data/spec/match_preview_spec.rb +15 -0
  37. data/spec/match_spec.rb +32 -0
  38. data/spec/match_statistics_spec.rb +43 -0
  39. data/spec/pass_matrix_spec.rb +27 -0
  40. data/spec/player_career_spec.rb +38 -0
  41. data/spec/possession_spec.rb +23 -0
  42. data/spec/rankings_spec.rb +14 -0
  43. data/spec/seasonal_stats_spec.rb +26 -0
  44. data/spec/spec_helper.rb +15 -0
  45. data/spec/squads.rb +40 -0
  46. data/spec/team_standings_spec.rb +61 -0
  47. data/spec/tournament_schedule_spec.rb +13 -0
  48. data/spec/tournament_spec.rb +48 -0
  49. metadata +169 -0
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ describe OptaSD::Soccer::SeasonalStats do
4
+
5
+ before do
6
+ @valid_competition_id = "722fdbecxzcq9788l6jqclzlw"
7
+ @valid_tournament_id = "408bfjw6uz5k19zk4am50ykmh"
8
+ @valid_contestant_id = "884uzyf1wosc7ykji6e18gifp"
9
+ end
10
+
11
+ it "get seasonal stats by tournament and contestant" do
12
+ match = OptaSD::Soccer::SeasonalStats.new.tournament(@valid_tournament_id).contestant(@valid_contestant_id).get
13
+
14
+ expect(match.data).to include("contestant")
15
+ expect(match.data).to include("player")
16
+ end
17
+
18
+ it "get seasonal stats by competition and contestant" do
19
+ # match = OptaSD::Soccer::SeasonalStats.new.competition(@valid_competition_id).contestant(@valid_contestant_id).get
20
+
21
+ # expect(match.data).to include("contestant")
22
+ # expect(match.data).to include("player")
23
+ # sdapidocumentation Account not Authorised for this request
24
+ end
25
+
26
+ end
@@ -0,0 +1,15 @@
1
+ require "./lib/opta_sd"
2
+ require "byebug"
3
+
4
+ RSpec.configure do |config|
5
+ config.expect_with :rspec do |expectations|
6
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
7
+ end
8
+
9
+ config.mock_with :rspec do |mocks|
10
+ mocks.verify_partial_doubles = true
11
+ end
12
+
13
+ config.shared_context_metadata_behavior = :apply_to_host_groups
14
+
15
+ end
@@ -0,0 +1,40 @@
1
+ require 'spec_helper'
2
+
3
+ describe OptaSD::Soccer::Squads do
4
+
5
+ before do
6
+ @valid_tournament_id = "408bfjw6uz5k19zk4am50ykmh"
7
+ @valid_contestant_id = "884uzyf1wosc7ykji6e18gifp"
8
+ end
9
+
10
+ it "gets squads based on tournament" do
11
+ squads = OptaSD::Soccer::Squads.new.tournament(@valid_tournament_id).get
12
+ expect(squads.data).to include("squad")
13
+ end
14
+
15
+ it "gets squads based on contestant" do
16
+ squads = OptaSD::Soccer::Squads.new.contestant(@valid_contestant_id).get
17
+ expect(squads.data).to include("squad")
18
+ end
19
+
20
+ it "gets detailed squads" do
21
+ squads = OptaSD::Soccer::Squads.new.tournament(@valid_tournament_id).detailed.get
22
+ expect(squads.data).to include("squad")
23
+ expect(squads.data['squad'][0]['type']).to eq("squad")
24
+ expect(squads.data['squad'][0]['person'][0]).to include("dateOfBirth")
25
+ end
26
+
27
+ it "gets people squads" do
28
+ squads = OptaSD::Soccer::Squads.new.tournament(@valid_tournament_id).people.get
29
+ expect(squads.data).to include("squad")
30
+ expect(squads.data['squad'][0]).to_not include("type")
31
+ expect(squads.data['squad'][0]['person'][0]).to_not include("dateOfBirth")
32
+ end
33
+
34
+ it "raise exception on using detailed abd people params togather" do
35
+ expect{
36
+ squads = OptaSD::Soccer::Squads.new.tournament(@valid_tournament_id).detailed.people.get
37
+ }.to raise_error(OptaSD::Error, "Ambiguous/Invalid request parameters")
38
+ end
39
+
40
+ end
@@ -0,0 +1,61 @@
1
+ require 'spec_helper'
2
+
3
+ describe OptaSD::Soccer::TeamStandings do
4
+
5
+ # OptaSD Not Authorising TeamStandings API for sdapidocumentation
6
+ # the test only cover Building the urls
7
+
8
+ before do
9
+ @tournament = "408bfjw6uz5k19zk4am50ykmh"
10
+ @team = OptaSD::Soccer::TeamStandings.new
11
+ end
12
+
13
+ it "it build team standings with tournament calendar id" do
14
+ team = @team.tournament(@tournament)
15
+ url = team.send(:build_uri).to_s
16
+
17
+ expect(url).to include("tmcl=#{@tournament}")
18
+ end
19
+
20
+ it "it build team standings with tournament calendar id and stage id" do
21
+ team = @team.tournament(@tournament).stage('123')
22
+ url = team.send(:build_uri).to_s
23
+
24
+ expect(url).to include("tmcl=#{@tournament}")
25
+ expect(url).to include("stg=123")
26
+ end
27
+
28
+ it "it build team standings with live param" do
29
+ team = @team.tournament(@tournament).live
30
+ url = team.send(:build_uri).to_s
31
+
32
+ expect(url).to include("live=yes")
33
+ end
34
+
35
+ it "it build team standings with types" do
36
+ team_1 = @team.tournament(@tournament).total
37
+ url_1 = team_1.send(:build_uri).to_s
38
+ expect(url_1).to include("type=total")
39
+
40
+ team_2 = @team.tournament(@tournament).home
41
+ url_2 = team_2.send(:build_uri).to_s
42
+ expect(url_2).to include("type=home")
43
+
44
+ team_3 = @team.tournament(@tournament).away
45
+ url_3 = team_3.send(:build_uri).to_s
46
+ expect(url_3).to include("type=away")
47
+
48
+ team_4 = @team.tournament(@tournament).form_total
49
+ url_4 = team_4.send(:build_uri).to_s
50
+ expect(url_4).to include("type=form-total")
51
+
52
+ team_5 = @team.tournament(@tournament).form_home
53
+ url_5 = team_5.send(:build_uri).to_s
54
+ expect(url_5).to include("type=form-home")
55
+
56
+ team_6 = @team.tournament(@tournament).form_away
57
+ url_6 = team_6.send(:build_uri).to_s
58
+ expect(url_6).to include("type=form-away")
59
+ end
60
+
61
+ end
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ describe OptaSD::Soccer::TournamentSchedule do
4
+
5
+ before do
6
+ @tournament_id = "bnni2f2e6ii20b1wmzcsbpj2o"
7
+ end
8
+
9
+ it "get match_facts by resource" do
10
+ ranking = OptaSD::Soccer::TournamentSchedule.new.resource(@tournament_id)#.get
11
+ # sdapidocumentation Account not Authorised for this request
12
+ end
13
+ end
@@ -0,0 +1,48 @@
1
+ require 'spec_helper'
2
+
3
+ describe OptaSD::Soccer::TournamentCalendar do
4
+
5
+ before do
6
+ @valid_competition_id = "722fdbecxzcq9788l6jqclzlw"
7
+ end
8
+
9
+ it "gets all tournaments" do
10
+ match = OptaSD::Soccer::TournamentCalendar.new.get
11
+
12
+ url = match.send(:build_uri).to_s
13
+ expect(url).to include('tournamentcalendar')
14
+ expect(url).to_not include('active')
15
+ expect(url).to_not include('authorized')
16
+ expect(match.data).to include("competition")
17
+ end
18
+
19
+ it "gets only active tournaments" do
20
+ match = OptaSD::Soccer::TournamentCalendar.new.active.get
21
+
22
+ url = match.send(:build_uri).to_s
23
+ expect(url).to include('tournamentcalendar')
24
+ expect(url).to include('active')
25
+ expect(url).to_not include('authorized')
26
+ expect(match.data).to include("competition")
27
+ end
28
+
29
+ it "gets only active and authorized for the user tournaments" do
30
+ match = OptaSD::Soccer::TournamentCalendar.new.active.authorized.get
31
+
32
+ url = match.send(:build_uri).to_s
33
+ expect(url).to include('tournamentcalendar')
34
+ expect(url).to include('active')
35
+ expect(url).to include('authorized')
36
+ expect(match.data).to include("competition")
37
+ end
38
+
39
+ it "gets tournament calendars by competition uuid" do
40
+ match = OptaSD::Soccer::TournamentCalendar.new.competition(@valid_competition_id).get
41
+
42
+ url = match.send(:build_uri).to_s
43
+ expect(url).to include('tournamentcalendar')
44
+ expect(url).to include("comp=#{@valid_competition_id}")
45
+ expect(match.data).to include("competition")
46
+ end
47
+
48
+ end
metadata ADDED
@@ -0,0 +1,169 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: opta_sd
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Ali Al-Sheiba
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-02-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.5'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.5'
41
+ - !ruby/object:Gem::Dependency
42
+ name: nokogiri
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.7'
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: 1.7.0.1
51
+ type: :runtime
52
+ prerelease: false
53
+ version_requirements: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - "~>"
56
+ - !ruby/object:Gem::Version
57
+ version: '1.7'
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: 1.7.0.1
61
+ - !ruby/object:Gem::Dependency
62
+ name: json
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ type: :runtime
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ description: OPTA SD is a library to Integrate and Utilize Opta Sports Data Apis.
76
+ email:
77
+ - ali.alsheiba@gmail.com
78
+ executables: []
79
+ extensions: []
80
+ extra_rdoc_files: []
81
+ files:
82
+ - ".gitignore"
83
+ - ".rspec"
84
+ - Gemfile
85
+ - Gemfile.lock
86
+ - MIT-LICENSE
87
+ - README.md
88
+ - Rakefile
89
+ - config/opta_sd.yml
90
+ - config/parameters.yml
91
+ - errors.yml
92
+ - lib/opta_sd.rb
93
+ - lib/opta_sd/core.rb
94
+ - lib/opta_sd/error.rb
95
+ - lib/opta_sd/soccer/commentary.rb
96
+ - lib/opta_sd/soccer/match.rb
97
+ - lib/opta_sd/soccer/match_event.rb
98
+ - lib/opta_sd/soccer/match_facts.rb
99
+ - lib/opta_sd/soccer/match_preview.rb
100
+ - lib/opta_sd/soccer/match_statistics.rb
101
+ - lib/opta_sd/soccer/pass_matrix.rb
102
+ - lib/opta_sd/soccer/player_career.rb
103
+ - lib/opta_sd/soccer/possession.rb
104
+ - lib/opta_sd/soccer/rankings.rb
105
+ - lib/opta_sd/soccer/seasonal_stats.rb
106
+ - lib/opta_sd/soccer/soccer.rb
107
+ - lib/opta_sd/soccer/squads.rb
108
+ - lib/opta_sd/soccer/team_standings.rb
109
+ - lib/opta_sd/soccer/tournament_calendar.rb
110
+ - lib/opta_sd/soccer/tournament_schedule.rb
111
+ - lib/opta_sd/version.rb
112
+ - opta_sd.gemspec
113
+ - spec/commentary_spec.rb
114
+ - spec/match_event_spec.rb
115
+ - spec/match_facts_spec.rb
116
+ - spec/match_preview_spec.rb
117
+ - spec/match_spec.rb
118
+ - spec/match_statistics_spec.rb
119
+ - spec/pass_matrix_spec.rb
120
+ - spec/player_career_spec.rb
121
+ - spec/possession_spec.rb
122
+ - spec/rankings_spec.rb
123
+ - spec/seasonal_stats_spec.rb
124
+ - spec/spec_helper.rb
125
+ - spec/squads.rb
126
+ - spec/team_standings_spec.rb
127
+ - spec/tournament_schedule_spec.rb
128
+ - spec/tournament_spec.rb
129
+ homepage: https://github.com/ali-sheiba/opta_sd
130
+ licenses:
131
+ - MIT
132
+ metadata: {}
133
+ post_install_message:
134
+ rdoc_options: []
135
+ require_paths:
136
+ - lib
137
+ required_ruby_version: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - ">="
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ required_rubygems_version: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - ">="
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
147
+ requirements: []
148
+ rubyforge_project:
149
+ rubygems_version: 2.6.8
150
+ signing_key:
151
+ specification_version: 4
152
+ summary: Opta Sports Data Soccer API.
153
+ test_files:
154
+ - spec/commentary_spec.rb
155
+ - spec/match_event_spec.rb
156
+ - spec/match_facts_spec.rb
157
+ - spec/match_preview_spec.rb
158
+ - spec/match_spec.rb
159
+ - spec/match_statistics_spec.rb
160
+ - spec/pass_matrix_spec.rb
161
+ - spec/player_career_spec.rb
162
+ - spec/possession_spec.rb
163
+ - spec/rankings_spec.rb
164
+ - spec/seasonal_stats_spec.rb
165
+ - spec/spec_helper.rb
166
+ - spec/squads.rb
167
+ - spec/team_standings_spec.rb
168
+ - spec/tournament_schedule_spec.rb
169
+ - spec/tournament_spec.rb