openfooty 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +6 -4
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/openfooty/client.rb +79 -0
- data/openfooty.gemspec +63 -0
- data/pkg/openfooty-0.1.0.gem +0 -0
- data/test/fixtures/league_fixtures.json +1 -0
- data/test/fixtures/match_stats.json +1 -0
- data/test/fixtures/team_squad.json +1 -0
- metadata +10 -3
data/README.md
CHANGED
@@ -31,11 +31,13 @@ Sign up for a Openfooty API key: [http://www.footytube.com/openfooty/signup.php]
|
|
31
31
|
#### Examples
|
32
32
|
|
33
33
|
>> openfooty = Openfooty::Client.new
|
34
|
-
>> openfooty.
|
35
|
-
|
34
|
+
>> fixtures = openfooty.league("getFixtures", :league_id => 72).openfooty.fixtures.match
|
35
|
+
>> fixtures.first.home_team.cdata
|
36
|
+
=> "South Africa"
|
36
37
|
|
37
|
-
>> openfooty.match("getStats", :match_id =>
|
38
|
-
|
38
|
+
>> stats = openfooty.match("getStats", :match_id => 781512).openfooty.match
|
39
|
+
>> stats.home_team.assists.assist.last.player_name
|
40
|
+
=> "T. Cahill"
|
39
41
|
|
40
42
|
|
41
43
|
## Copyright
|
data/Rakefile
CHANGED
@@ -7,7 +7,7 @@ begin
|
|
7
7
|
Jeweler::Tasks.new do |gem|
|
8
8
|
gem.name = "openfooty"
|
9
9
|
gem.summary = %Q{Ruby wrapper for the Openfooty API}
|
10
|
-
gem.description = %Q{Ruby wrapper for the
|
10
|
+
gem.description = %Q{Ruby wrapper for the Openfooty API}
|
11
11
|
gem.email = "johnnyn@gmail.com"
|
12
12
|
gem.homepage = "http://github.com/phuphighter/openfooty"
|
13
13
|
gem.authors = ["Johnny Khai Nguyen"]
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
@@ -0,0 +1,79 @@
|
|
1
|
+
module Openfooty
|
2
|
+
|
3
|
+
class Client
|
4
|
+
include HTTParty
|
5
|
+
base_uri "http://api.openfooty.org/1.0"
|
6
|
+
format :json
|
7
|
+
|
8
|
+
attr_reader :api_key
|
9
|
+
|
10
|
+
# Usage
|
11
|
+
# openfooty = Openfooty::Client.new
|
12
|
+
# openfooty.team("getFixtures", :team_id => "id")
|
13
|
+
# openfooty.match("getStats", :match_id => "id")
|
14
|
+
|
15
|
+
# Other API methods here: http://www.footytube.com/openfooty/karma.php
|
16
|
+
|
17
|
+
def initialize(options={})
|
18
|
+
@api_key = options[:api_key] || Openfooty.api_key
|
19
|
+
end
|
20
|
+
|
21
|
+
def auth(method, options={})
|
22
|
+
mashup(self.class.get("/auth.#{method}", :query => options.merge(self.default_options)))
|
23
|
+
end
|
24
|
+
|
25
|
+
def betting(method, options={})
|
26
|
+
mashup(self.class.get("/betting.#{method}", :query => options.merge(self.default_options)))
|
27
|
+
end
|
28
|
+
|
29
|
+
def channel(method, options={})
|
30
|
+
mashup(self.class.get("/channel.#{method}", :query => options.merge(self.default_options)))
|
31
|
+
end
|
32
|
+
|
33
|
+
def community(method, options={})
|
34
|
+
mashup(self.class.get("/community.#{method}", :query => options.merge(self.default_options)))
|
35
|
+
end
|
36
|
+
|
37
|
+
def league(method, options={})
|
38
|
+
mashup(self.class.get("/league.#{method}", :query => options.merge(self.default_options)))
|
39
|
+
end
|
40
|
+
|
41
|
+
def match(method, options={})
|
42
|
+
mashup(self.class.get("/match.#{method}", :query => options.merge(self.default_options)))
|
43
|
+
end
|
44
|
+
|
45
|
+
def player(method, options={})
|
46
|
+
mashup(self.class.get("/player.#{method}", :query => options.merge(self.default_options)))
|
47
|
+
end
|
48
|
+
|
49
|
+
def team(method, options={})
|
50
|
+
mashup(self.class.get("/team.#{method}", :query => options.merge(self.default_options)))
|
51
|
+
end
|
52
|
+
|
53
|
+
def video(method, options={})
|
54
|
+
mashup(self.class.get("/video.#{method}", :query => options.merge(self.default_options)))
|
55
|
+
end
|
56
|
+
|
57
|
+
protected
|
58
|
+
|
59
|
+
def default_options
|
60
|
+
{:api_key => @api_key, :format => :json}
|
61
|
+
end
|
62
|
+
|
63
|
+
def mashup(response)
|
64
|
+
case response.code
|
65
|
+
when 200
|
66
|
+
if response.is_a?(Hash)
|
67
|
+
Hashie::Mash.new(response)
|
68
|
+
else
|
69
|
+
if response.first.is_a?(Hash)
|
70
|
+
response.map{|item| Hashie::Mash.new(item)}
|
71
|
+
else
|
72
|
+
response
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
data/openfooty.gemspec
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{openfooty}
|
8
|
+
s.version = "0.2.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Johnny Khai Nguyen"]
|
12
|
+
s.date = %q{2010-06-08}
|
13
|
+
s.description = %q{Ruby wrapper for the Openfooty API}
|
14
|
+
s.email = %q{johnnyn@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"README.md"
|
17
|
+
]
|
18
|
+
s.files = [
|
19
|
+
"MIT-LICENSE",
|
20
|
+
"README.md",
|
21
|
+
"Rakefile",
|
22
|
+
"VERSION",
|
23
|
+
"init.rb",
|
24
|
+
"install.rb",
|
25
|
+
"lib/openfooty.rb",
|
26
|
+
"lib/openfooty/client.rb",
|
27
|
+
"openfooty.gemspec",
|
28
|
+
"pkg/openfooty-0.1.0.gem",
|
29
|
+
"tasks/openfooty_tasks.rake",
|
30
|
+
"test/fixtures/league_fixtures.json",
|
31
|
+
"test/fixtures/match_stats.json",
|
32
|
+
"test/fixtures/team_squad.json",
|
33
|
+
"test/helper.rb",
|
34
|
+
"test/openfooty_test.rb",
|
35
|
+
"uninstall.rb"
|
36
|
+
]
|
37
|
+
s.homepage = %q{http://github.com/phuphighter/openfooty}
|
38
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
39
|
+
s.require_paths = ["lib"]
|
40
|
+
s.rubygems_version = %q{1.3.6}
|
41
|
+
s.summary = %q{Ruby wrapper for the Openfooty API}
|
42
|
+
s.test_files = [
|
43
|
+
"test/helper.rb",
|
44
|
+
"test/openfooty_test.rb"
|
45
|
+
]
|
46
|
+
|
47
|
+
if s.respond_to? :specification_version then
|
48
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
49
|
+
s.specification_version = 3
|
50
|
+
|
51
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
52
|
+
s.add_runtime_dependency(%q<httparty>, [">= 0.5.0"])
|
53
|
+
s.add_runtime_dependency(%q<hashie>, [">= 0.1.3"])
|
54
|
+
else
|
55
|
+
s.add_dependency(%q<httparty>, [">= 0.5.0"])
|
56
|
+
s.add_dependency(%q<hashie>, [">= 0.1.3"])
|
57
|
+
end
|
58
|
+
else
|
59
|
+
s.add_dependency(%q<httparty>, [">= 0.5.0"])
|
60
|
+
s.add_dependency(%q<hashie>, [">= 0.1.3"])
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
{"openfooty":{"version":"1.0","response":{"status":"ok"},"fixtures":{"hasMorePages":"true","nextPage":2,"match":[{"match_id":"878771","league":{"id":"72","season_id":"4770","cdata":"World Cup"},"home_team":{"team_id":"2014","cdata":"South Africa"},"away_team":{"team_id":"1497","cdata":"Mexico"},"date":{"ts":"1276264800","cdata":"2010-06-11 14:00:00"},"status":{"cdata":"Fixture"},"ft_score":{"cdata":null},"winner":{"cdata":null}},{"match_id":"878772","league":{"id":"72","season_id":"4770","cdata":"World Cup"}},{"match_id":"878778","league":{"id":"72","season_id":"4770","cdata":"World Cup"}},{"match_id":"878777","league":{"id":"72","season_id":"4770","cdata":"World Cup"}},{"match_id":"878783","league":{"id":"72","season_id":"4770","cdata":"World Cup"}},{"match_id":"878784","league":{"id":"72","season_id":"4770","cdata":"World Cup"}},{"match_id":"878790","league":{"id":"72","season_id":"4770","cdata":"World Cup"}},{"match_id":"878789","league":{"id":"72","season_id":"4770","cdata":"World Cup"}},{"match_id":"878795","league":{"id":"72","season_id":"4770","cdata":"World Cup"}},{"match_id":"878796","league":{"id":"72","season_id":"4770","cdata":"World Cup"}},{"match_id":"878801","league":{"id":"72","season_id":"4770","cdata":"World Cup"}},{"match_id":"878802","league":{"id":"72","season_id":"4770","cdata":"World Cup"}},{"match_id":"878808","league":{"id":"72","season_id":"4770","cdata":"World Cup"}},{"match_id":"878807","league":{"id":"72","season_id":"4770","cdata":"World Cup"}},{"match_id":"878814","league":{"id":"72","season_id":"4770","cdata":"World Cup"}},{"match_id":"878813","league":{"id":"72","season_id":"4770","cdata":"World Cup"}},{"match_id":"878773","league":{"id":"72","season_id":"4770","cdata":"World Cup"}},{"match_id":"878779","league":{"id":"72","season_id":"4770","cdata":"World Cup"}},{"match_id":"878780","league":{"id":"72","season_id":"4770","cdata":"World Cup"}},{"match_id":"878774","league":{"id":"72","season_id":"4770","cdata":"World Cup"}}]}}}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"openfooty"=>{"version"=>"1.0", "match"=>{"home_team"=>{"name"=>{"cdata"=>"Everton"}, "goals"=>{"goal"=>[{"player_name"=>"C. Smalling", "time"=>49, "player_id"=>79474, "type"=>"owngoal"}, {"player_name"=>"M. Arteta", "time"=>90, "player_id"=>2876, "type"=>"penalty"}], "count"=>2}, "cards"=>{"count"=>0}, "assists"=>{"count"=>2, "assist"=>[{"player_name"=>"V. Anichebe", "time"=>49, "player_id"=>2886}, {"player_name"=>"T. Cahill", "time"=>90, "player_id"=>709}]}, "id"=>"674", "lineup"=>{"player"=>[{"cdata"=>"T. Howard", "id"=>632}, {"cdata"=>"S. Distin", "id"=>2846}, {"cdata"=>"T. Hibbert", "id"=>2868}, {"cdata"=>"P. Jagielka", "id"=>2600}, {"cdata"=>"L. Baines", "id"=>2672}, {"cdata"=>"M. Arteta", "id"=>2876}, {"cdata"=>"D. Bilyaletdinov", "id"=>6472}, {"cdata"=>"S. Pienaar", "id"=>1960}, {"cdata"=>"P. Neville", "id"=>2874}, {"cdata"=>"T. Cahill", "id"=>709}, {"cdata"=>"A. Yakubu", "id"=>2839}], "substitution"=>[{"cdata"=>"V. Anichebe for D. Bilyaletdinov (45)", "player_id_on"=>"2886", "player_id_off"=>"6472"}, {"cdata"=>"L. Saha for P. Neville (60)", "player_id_on"=>"552", "player_id_off"=>"2874"}, {"cdata"=>"J. Baxter for A. Yakubu (87)", "player_id_on"=>"55559", "player_id_off"=>"2839"}]}}, "winner"=>{"cdata"=>"674"}, "date"=>{"cdata"=>"2010-04-25 14:00:00"}, "away_team"=>{"name"=>{"cdata"=>"Fulham"}, "goals"=>{"goal"=>{"player_name"=>"E. Nevland", "time"=>36, "player_id"=>2288, "type"=>"normal"}, "count"=>1}, "cards"=>{"card"=>{"player_name"=>"J. Paintsil", "time"=>39, "player_id"=>611, "type"=>"yellow"}, "count"=>1}, "assists"=>{"count"=>0}, "id"=>"667", "lineup"=>{"player"=>[{"cdata"=>"M. Schwarzer", "id"=>702}, {"cdata"=>"C. Baird", "id"=>15481}, {"cdata"=>"C. Smalling", "id"=>79474}, {"cdata"=>"J. Paintsil", "id"=>611}, {"cdata"=>"N. Shorey", "id"=>2568}, {"cdata"=>"K. Dikgacoi", "id"=>21660}, {"cdata"=>"C. Dempsey", "id"=>664}, {"cdata"=>"J. Greening", "id"=>15429}, {"cdata"=>"B. Riise", "id"=>7773}, {"cdata"=>"E. Nevland", "id"=>2288}, {"cdata"=>"S. Okaka Chuka", "id"=>18418}], "substitution"=>[{"cdata"=>"D. Elm for E. Nevland (78)", "player_id_on"=>"6275", "player_id_off"=>"2288"}, {"cdata"=>"F. Stoor for S. Okaka Chuka (89)", "player_id_on"=>"7905", "player_id_off"=>"18418"}]}}, "status"=>{"cdata"=>"Played"}, "score"=>{"cdata"=>"2-1"}, "ht_score"=>{"cdata"=>"0-1"}}}}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"openfooty"=>{"players"=>{"player"=>[{"position"=>"", "cdata"=>"B. Bradley", "id"=>"130156"}, {"position"=>"Goalkeeper", "cdata"=>"B. Guzan", "id"=>"6912"}, {"position"=>"Goalkeeper", "cdata"=>"M. Hahnemann", "id"=>"629"}, {"position"=>"Goalkeeper", "cdata"=>"T. Howard", "id"=>"632"}, {"position"=>"Defender", "cdata"=>"C. Bocanegra", "id"=>"643"}, {"position"=>"Defender", "cdata"=>"J. Bornstein", "id"=>"6906"}, {"position"=>"Defender", "cdata"=>"S. Cherundolo", "id"=>"104666"}, {"position"=>"Defender", "cdata"=>"J. DeMerit", "id"=>"2541"}, {"position"=>"Defender", "cdata"=>"C. Goodson", "id"=>"7261"}, {"position"=>"Defender", "cdata"=>"C. Marshall", "id"=>"7214"}, {"position"=>"Defender", "cdata"=>"O. Onyewu", "id"=>"655"}, {"position"=>"Defender", "cdata"=>"H. Pearce", "id"=>"16404"}, {"position"=>"Defender", "cdata"=>"J. Spector", "id"=>"2712"}, {"position"=>"Midfielder", "cdata"=>"D. Beasley", "id"=>"659"}, {"position"=>"Midfielder", "cdata"=>"A. Bedoya", "id"=>"76707"}, {"position"=>"Midfielder", "cdata"=>"M. Bradley", "id"=>"2304"}, {"position"=>"Midfielder", "cdata"=>"R. Clark", "id"=>"10049"}, {"position"=>"Midfielder", "cdata"=>"C. Dempsey", "id"=>"664"}, {"position"=>"Midfielder", "cdata"=>"L. Donovan", "id"=>"666"}, {"position"=>"Midfielder", "cdata"=>"M. Edu", "id"=>"7452"}, {"position"=>"Midfielder", "cdata"=>"B. Feilhaber", "id"=>"2008"}, {"position"=>"Midfielder", "cdata"=>"S. Holden", "id"=>"7305"}, {"position"=>"Midfielder", "cdata"=>"S. Kljestan", "id"=>"6915"}, {"position"=>"Midfielder", "cdata"=>"R. Rogers", "id"=>"7226"}, {"position"=>"Midfielder", "cdata"=>"J. Torres", "id"=>"14359"}, {"position"=>"Attacker", "cdata"=>"J. Altidore", "id"=>"7422"}, {"position"=>"Attacker", "cdata"=>"E. Buddle", "id"=>"7445"}, {"position"=>"Attacker", "cdata"=>"B. Ching", "id"=>"673"}, {"position"=>"Attacker", "cdata"=>"R. Findley", "id"=>"7345"}, {"position"=>"Attacker", "cdata"=>"H. Gómez", "id"=>"6937"}, {"position"=>"Attacker", "cdata"=>"E. Johnson", "id"=>"674"}], "team_id"=>"2281"}, "response"=>{"status"=>"ok"}, "version"=>"1.0"}}
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
7
|
+
- 2
|
8
8
|
- 0
|
9
|
-
version: 0.
|
9
|
+
version: 0.2.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Johnny Khai Nguyen
|
@@ -45,7 +45,7 @@ dependencies:
|
|
45
45
|
version: 0.1.3
|
46
46
|
type: :runtime
|
47
47
|
version_requirements: *id002
|
48
|
-
description: Ruby wrapper for the
|
48
|
+
description: Ruby wrapper for the Openfooty API
|
49
49
|
email: johnnyn@gmail.com
|
50
50
|
executables: []
|
51
51
|
|
@@ -61,7 +61,14 @@ files:
|
|
61
61
|
- init.rb
|
62
62
|
- install.rb
|
63
63
|
- lib/openfooty.rb
|
64
|
+
- lib/openfooty/client.rb
|
65
|
+
- openfooty.gemspec
|
66
|
+
- pkg/openfooty-0.1.0.gem
|
64
67
|
- tasks/openfooty_tasks.rake
|
68
|
+
- test/fixtures/league_fixtures.json
|
69
|
+
- test/fixtures/match_stats.json
|
70
|
+
- test/fixtures/team_squad.json
|
71
|
+
- test/helper.rb
|
65
72
|
- test/openfooty_test.rb
|
66
73
|
- uninstall.rb
|
67
74
|
has_rdoc: true
|