football_ruby 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/football_ruby.gemspec +2 -2
- data/lib/football_ruby.rb +7 -0
- data/lib/football_ruby/base.rb +8 -20
- data/lib/football_ruby/client.rb +7 -7
- data/lib/football_ruby/configuration.rb +12 -0
- data/lib/football_ruby/errors.rb +3 -8
- data/lib/football_ruby/version.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5aede82050753e7212b727656ac94ef0d905df7c
|
4
|
+
data.tar.gz: 4ea9926f9fd653da526c12eaffc3bc9f3a00e555
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d306d3dfa5008a27631c4f8a6d2683ac25d54ae779fff4688defc0494dc2755ceccf3949c3416a4a8051f136ef1e457347958d8fe95d4172e6abc21df507b536
|
7
|
+
data.tar.gz: bc45e56165a30bc5ec2afee39868d0d40ffb731c6ebc0d6f11e641af845a63688618f07c799d9d71b3c1ab58c328c09cf784140d44576d977c92e7a22487d509
|
data/README.md
CHANGED
data/football_ruby.gemspec
CHANGED
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ['Said Kaldybaev']
|
10
10
|
spec.email = ['said.kaldybaev@gmail.com']
|
11
11
|
|
12
|
-
spec.summary = %q{
|
13
|
-
spec.description = %q{
|
12
|
+
spec.summary = %q{football-data.org API wrapper in ruby}
|
13
|
+
spec.description = %q{football-data.org API wrapper in ruby}
|
14
14
|
spec.homepage = 'https://github.com/Saidbek/football_ruby'
|
15
15
|
spec.license = 'MIT'
|
16
16
|
|
data/lib/football_ruby.rb
CHANGED
data/lib/football_ruby/base.rb
CHANGED
@@ -1,32 +1,26 @@
|
|
1
|
-
require 'net/http'
|
2
|
-
require 'football_ruby/errors'
|
3
|
-
|
4
1
|
module FootballRuby
|
5
2
|
class Base
|
6
|
-
API_ENDPOINT = 'http://api.football-data.org'
|
7
|
-
API_VERSION = 'v1'
|
8
|
-
API_LIVE = 'http://soccer-cli.appspot.com'
|
9
|
-
|
10
3
|
def get(path, params={})
|
11
|
-
uri = URI("#{API_ENDPOINT}/#{
|
12
|
-
|
4
|
+
uri = URI("#{FootballRuby::Configuration::API_ENDPOINT}/#{path}")
|
13
5
|
request = build_request(uri, build_headers(params))
|
6
|
+
|
14
7
|
build_response(uri, request)
|
15
8
|
end
|
16
9
|
|
17
10
|
def get_live_scores
|
18
|
-
uri = URI("#{
|
19
|
-
|
11
|
+
uri = URI("#{FootballRuby::Configuration::LIVE_ENDPOINT}/")
|
20
12
|
request = build_request(uri)
|
13
|
+
|
21
14
|
build_response(uri, request)
|
22
15
|
end
|
23
16
|
|
24
17
|
private
|
25
18
|
|
26
19
|
def build_headers(params)
|
20
|
+
raise ApiTokenMissingError, 'Please set up your api token' if FootballRuby.api_token.nil?
|
21
|
+
|
27
22
|
{
|
28
|
-
'X-Auth-Token'
|
29
|
-
'X-Response-Control' => 'full'
|
23
|
+
'X-Auth-Token': FootballRuby.api_token
|
30
24
|
}.merge(params)
|
31
25
|
end
|
32
26
|
|
@@ -35,15 +29,9 @@ module FootballRuby
|
|
35
29
|
end
|
36
30
|
|
37
31
|
def build_response(uri, request)
|
38
|
-
|
32
|
+
Net::HTTP.start(uri.host, uri.port) do |http|
|
39
33
|
http.request(request)
|
40
34
|
end
|
41
|
-
|
42
|
-
if response.kind_of? Net::HTTPSuccess
|
43
|
-
response
|
44
|
-
else
|
45
|
-
raise FootballRuby::ResponseError.new(response)
|
46
|
-
end
|
47
35
|
end
|
48
36
|
end
|
49
37
|
end
|
data/lib/football_ruby/client.rb
CHANGED
@@ -12,7 +12,7 @@ module FootballRuby
|
|
12
12
|
|
13
13
|
# List all teams for a certain league.
|
14
14
|
def league_teams(id)
|
15
|
-
raise 'missing id' if id.nil?
|
15
|
+
raise IdMissingError, 'missing id' if id.nil?
|
16
16
|
|
17
17
|
json_response get("competitions/#{id}/teams")
|
18
18
|
end
|
@@ -23,7 +23,7 @@ module FootballRuby
|
|
23
23
|
# match_day=/\d+/
|
24
24
|
|
25
25
|
def league_table(id, opts={})
|
26
|
-
raise 'missing id' if id.nil?
|
26
|
+
raise IdMissingError, 'missing id' if id.nil?
|
27
27
|
|
28
28
|
match_day = opts[:match_day]
|
29
29
|
|
@@ -40,7 +40,7 @@ module FootballRuby
|
|
40
40
|
# match_day=/\d+/
|
41
41
|
|
42
42
|
def league_fixtures(id, opts={})
|
43
|
-
raise 'missing id' if id.nil?
|
43
|
+
raise IdMissingError, 'missing id' if id.nil?
|
44
44
|
|
45
45
|
time_frame = opts[:time_frame]
|
46
46
|
match_day = opts[:match_day]
|
@@ -75,7 +75,7 @@ module FootballRuby
|
|
75
75
|
# head2head=/\d+/
|
76
76
|
|
77
77
|
def fixture(id, opts={})
|
78
|
-
raise 'missing id' if id.nil?
|
78
|
+
raise IdMissingError, 'missing id' if id.nil?
|
79
79
|
|
80
80
|
head2head = opts[:head2head]
|
81
81
|
|
@@ -93,7 +93,7 @@ module FootballRuby
|
|
93
93
|
# venue=/home|away/
|
94
94
|
|
95
95
|
def team_fixtures(id, opts={})
|
96
|
-
raise 'missing id' if id.nil?
|
96
|
+
raise IdMissingError, 'missing id' if id.nil?
|
97
97
|
|
98
98
|
season = opts[:season]
|
99
99
|
time_frame = opts[:time_frame]
|
@@ -109,14 +109,14 @@ module FootballRuby
|
|
109
109
|
|
110
110
|
# Show one team.
|
111
111
|
def team(id)
|
112
|
-
raise 'missing id' if id.nil?
|
112
|
+
raise IdMissingError, 'missing id' if id.nil?
|
113
113
|
|
114
114
|
json_response get("teams/#{id}/")
|
115
115
|
end
|
116
116
|
|
117
117
|
# Show all players for a certain team.
|
118
118
|
def team_players(id)
|
119
|
-
raise 'missing team id' if id.nil?
|
119
|
+
raise IdMissingError, 'missing team id' if id.nil?
|
120
120
|
|
121
121
|
json_response get("teams/#{id}/players/")
|
122
122
|
end
|
data/lib/football_ruby/errors.rb
CHANGED
@@ -1,11 +1,6 @@
|
|
1
1
|
module FootballRuby
|
2
2
|
class Error < StandardError; end
|
3
|
-
|
4
|
-
class
|
5
|
-
|
6
|
-
|
7
|
-
def initialize(response)
|
8
|
-
@response = response
|
9
|
-
end
|
10
|
-
end
|
3
|
+
class ResponseError < Error; end
|
4
|
+
class ApiTokenMissingError < Error; end
|
5
|
+
class IdMissingError < Error; end
|
11
6
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: football_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Said Kaldybaev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-05-
|
11
|
+
date: 2017-05-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,7 +38,7 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
|
-
description:
|
41
|
+
description: football-data.org API wrapper in ruby
|
42
42
|
email:
|
43
43
|
- said.kaldybaev@gmail.com
|
44
44
|
executables: []
|
@@ -58,6 +58,7 @@ files:
|
|
58
58
|
- lib/football_ruby.rb
|
59
59
|
- lib/football_ruby/base.rb
|
60
60
|
- lib/football_ruby/client.rb
|
61
|
+
- lib/football_ruby/configuration.rb
|
61
62
|
- lib/football_ruby/errors.rb
|
62
63
|
- lib/football_ruby/version.rb
|
63
64
|
homepage: https://github.com/Saidbek/football_ruby
|
@@ -83,5 +84,5 @@ rubyforge_project:
|
|
83
84
|
rubygems_version: 2.5.1
|
84
85
|
signing_key:
|
85
86
|
specification_version: 4
|
86
|
-
summary:
|
87
|
+
summary: football-data.org API wrapper in ruby
|
87
88
|
test_files: []
|