xmlstats 1.2.0 → 1.3.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.
- checksums.yaml +4 -4
- data/README.md +38 -3
- data/lib/xmlstats/http_getters/net_http.rb +1 -1
- data/lib/xmlstats/version.rb +1 -1
- data/lib/xmlstats.rb +72 -58
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f588cd5dfc99679e6be5ae6d0aa13432a281989
|
4
|
+
data.tar.gz: debca1c193278a183cc0b340fecd1a0b0fa2079c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a89b5bbddf16bf7572d6f7af4d2df1e3bce9815a0825e01063bfccb718913832aef4d156e554c923515a0a5486d82e72e7e0d3e40ae04d545df36e3ca5c540cc
|
7
|
+
data.tar.gz: d206fcd1c65df6ab74135f74f37f12d8daf4c8db6fb6fd65edc9edcc62922445e8a78c030e975fc28533a730a6e85cc60fdbfbbb68c2d1d1993298a1334a0d73
|
data/README.md
CHANGED
@@ -1,9 +1,7 @@
|
|
1
1
|
xmlstats-ruby
|
2
2
|
=============
|
3
3
|
|
4
|
-
A ruby client for xmlstats, an easy to use API for obtaining MLB and NBA statistics in XML or JSON.
|
5
|
-
|
6
|
-
See xmlstats here: https://erikberg.com/api
|
4
|
+
A ruby client for [xmlstats](https://erikberg.com/api), an easy to use API for obtaining MLB and NBA statistics in XML or JSON.
|
7
5
|
|
8
6
|
Installation
|
9
7
|
------------
|
@@ -166,6 +164,43 @@ Examples
|
|
166
164
|
|
167
165
|
See https://github.com/alexmchale/xmlstats-ruby/tree/master/examples
|
168
166
|
|
167
|
+
Troubleshooting
|
168
|
+
---------------
|
169
|
+
|
170
|
+
### Certificate Error on OSX ###
|
171
|
+
|
172
|
+
On OSX you may see the following exception when trying to use xmlstats:
|
173
|
+
|
174
|
+
/Users/alexmchale/.rbenv-osx/versions/2.0.0-p247/lib/ruby/2.0.0/net/http.rb:918:in `connect': SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (OpenSSL::SSL::SSLError)
|
175
|
+
from /Users/alexmchale/.rbenv-osx/versions/2.0.0-p247/lib/ruby/2.0.0/net/http.rb:918:in `block in connect'
|
176
|
+
from /Users/alexmchale/.rbenv-osx/versions/2.0.0-p247/lib/ruby/2.0.0/timeout.rb:52:in `timeout'
|
177
|
+
from /Users/alexmchale/.rbenv-osx/versions/2.0.0-p247/lib/ruby/2.0.0/net/http.rb:918:in `connect'
|
178
|
+
from /Users/alexmchale/.rbenv-osx/versions/2.0.0-p247/lib/ruby/2.0.0/net/http.rb:862:in `do_start'
|
179
|
+
from /Users/alexmchale/.rbenv-osx/versions/2.0.0-p247/lib/ruby/2.0.0/net/http.rb:851:in `start'
|
180
|
+
from /Users/alexmchale/.rbenv-osx/versions/2.0.0-p247/lib/ruby/2.0.0/net/http.rb:1367:in `request'
|
181
|
+
from /Users/alexmchale/src/anticlever/xmlstats/lib/xmlstats/http_getters/net_http.rb:21:in `get'
|
182
|
+
from /Users/alexmchale/src/anticlever/xmlstats/lib/xmlstats/endpoint.rb:41:in `http_get'
|
183
|
+
from /Users/alexmchale/src/anticlever/xmlstats/lib/xmlstats/endpoint.rb:52:in `fetch_json'
|
184
|
+
from /Users/alexmchale/src/anticlever/xmlstats/lib/xmlstats/endpoints/events.rb:8:in `fetch'
|
185
|
+
from /Users/alexmchale/src/anticlever/xmlstats/lib/xmlstats.rb:91:in `events'
|
186
|
+
from test.rb:19:in `<main>'
|
187
|
+
|
188
|
+
To get around this, install the curl-ca-bundle in [Homebrew](http://brew.sh):
|
189
|
+
|
190
|
+
[zeus ~/src/anticlever/xmlstats]$ brew install curl-ca-bundle
|
191
|
+
==> Downloading https://downloads.sourceforge.net/project/machomebrew/mirror/curl-ca-bundle-1.87.tar.bz2
|
192
|
+
######################################################################## 100.0%
|
193
|
+
==> Caveats
|
194
|
+
To use these certificates with OpenSSL:
|
195
|
+
|
196
|
+
export SSL_CERT_FILE=/usr/local/opt/curl-ca-bundle/share/ca-bundle.crt
|
197
|
+
==> Summary
|
198
|
+
🍺 /usr/local/Cellar/curl-ca-bundle/1.87: 2 files, 256K, built in 2 seconds
|
199
|
+
|
200
|
+
Finally, add the following to your environment before your application starts:
|
201
|
+
|
202
|
+
export SSL_CERT_FILE=/usr/local/opt/curl-ca-bundle/share/ca-bundle.crt
|
203
|
+
|
169
204
|
Contributing
|
170
205
|
------------
|
171
206
|
|
@@ -7,7 +7,7 @@ module Xmlstats
|
|
7
7
|
def get(uri)
|
8
8
|
http = Net::HTTP.new(uri.host, uri.port)
|
9
9
|
http.use_ssl = true
|
10
|
-
http.verify_mode = OpenSSL::SSL::
|
10
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
11
11
|
headers = {}
|
12
12
|
api_key = Xmlstats.api_key
|
13
13
|
headers["User-Agent"] = "xmlstats-ruby/#{Xmlstats::VERSION} (#{Xmlstats.contact_info})"
|
data/lib/xmlstats/version.rb
CHANGED
data/lib/xmlstats.rb
CHANGED
@@ -41,82 +41,96 @@ require "xmlstats/endpoints/nba_leaders"
|
|
41
41
|
|
42
42
|
module Xmlstats
|
43
43
|
|
44
|
-
|
45
|
-
@api_key ||= ENV["XMLSTATS_API_KEY"]
|
46
|
-
end
|
44
|
+
class << self
|
47
45
|
|
48
|
-
|
49
|
-
@api_key = api_key
|
50
|
-
end
|
46
|
+
# Manage api key
|
51
47
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
@contact_info or raise(error)
|
56
|
-
end
|
48
|
+
def api_key
|
49
|
+
@api_key ||= ENV["XMLSTATS_API_KEY"]
|
50
|
+
end
|
57
51
|
|
58
|
-
|
59
|
-
|
60
|
-
|
52
|
+
def api_key= api_key
|
53
|
+
@api_key = api_key
|
54
|
+
end
|
61
55
|
|
62
|
-
|
63
|
-
@http_getter || Xmlstats::HttpGetters::NetHttp.new
|
64
|
-
end
|
56
|
+
# Manage contact info
|
65
57
|
|
66
|
-
|
67
|
-
|
68
|
-
|
58
|
+
def contact_info
|
59
|
+
error = "specify user-agent contact info with: Xmlstats.contact_info = 'you@example.com'"
|
60
|
+
@contact_info ||= ENV["XMLSTATS_CONTACT_INFO"]
|
61
|
+
@contact_info or raise(error)
|
62
|
+
end
|
69
63
|
|
70
|
-
|
71
|
-
|
72
|
-
|
64
|
+
def contact_info= contact_info
|
65
|
+
@contact_info = contact_info
|
66
|
+
end
|
73
67
|
|
74
|
-
|
75
|
-
@cacher = cacher
|
76
|
-
end
|
68
|
+
# Manage http getter
|
77
69
|
|
78
|
-
|
79
|
-
|
80
|
-
|
70
|
+
def http_getter
|
71
|
+
@http_getter || Xmlstats::HttpGetters::NetHttp.new
|
72
|
+
end
|
81
73
|
|
82
|
-
|
83
|
-
|
84
|
-
|
74
|
+
def http_getter= http_getter
|
75
|
+
@http_getter = http_getter
|
76
|
+
end
|
85
77
|
|
86
|
-
|
87
|
-
Xmlstats::Endpoints::NbaBoxScore.fetch *args
|
88
|
-
end
|
78
|
+
# Manage cacher
|
89
79
|
|
90
|
-
|
91
|
-
|
92
|
-
|
80
|
+
def cacher
|
81
|
+
@cacher || Xmlstats::Cachers::Memory.new
|
82
|
+
end
|
93
83
|
|
94
|
-
|
95
|
-
|
96
|
-
|
84
|
+
def cacher= cacher
|
85
|
+
@cacher = cacher
|
86
|
+
end
|
97
87
|
|
98
|
-
|
99
|
-
Xmlstats::Endpoints::MlbWildCardStanding.fetch *args
|
100
|
-
end
|
88
|
+
# Wrapper methods to each endpoint
|
101
89
|
|
102
|
-
|
103
|
-
|
104
|
-
|
90
|
+
def events *args
|
91
|
+
Xmlstats::Endpoints::Events.fetch *args
|
92
|
+
end
|
105
93
|
|
106
|
-
|
107
|
-
|
108
|
-
|
94
|
+
def mlb_box_score *args
|
95
|
+
Xmlstats::Endpoints::MlbBoxScore.fetch *args
|
96
|
+
end
|
109
97
|
|
110
|
-
|
111
|
-
|
112
|
-
|
98
|
+
def nba_box_score *args
|
99
|
+
Xmlstats::Endpoints::NbaBoxScore.fetch *args
|
100
|
+
end
|
113
101
|
|
114
|
-
|
115
|
-
|
116
|
-
|
102
|
+
def mlb_standing *args
|
103
|
+
Xmlstats::Endpoints::MlbStanding.fetch *args
|
104
|
+
end
|
105
|
+
|
106
|
+
def nba_standing *args
|
107
|
+
Xmlstats::Endpoints::NbaStanding.fetch *args
|
108
|
+
end
|
109
|
+
|
110
|
+
def mlb_wild_card_standing *args
|
111
|
+
Xmlstats::Endpoints::MlbWildCardStanding.fetch *args
|
112
|
+
end
|
113
|
+
|
114
|
+
def mlb_team_results *args
|
115
|
+
Xmlstats::Endpoints::MlbTeamResults.fetch *args
|
116
|
+
end
|
117
|
+
|
118
|
+
def nba_team_results *args
|
119
|
+
Xmlstats::Endpoints::NbaTeamResults.fetch *args
|
120
|
+
end
|
121
|
+
|
122
|
+
def mlb_teams *args
|
123
|
+
Xmlstats::Endpoints::MlbTeams.fetch *args
|
124
|
+
end
|
125
|
+
|
126
|
+
def nba_teams *args
|
127
|
+
Xmlstats::Endpoints::NbaTeams.fetch *args
|
128
|
+
end
|
129
|
+
|
130
|
+
def nba_leaders *args
|
131
|
+
Xmlstats::Endpoints::NbaLeaders.fetch *args
|
132
|
+
end
|
117
133
|
|
118
|
-
def self.nba_leaders *args
|
119
|
-
Xmlstats::Endpoints::NbaLeaders.fetch *args
|
120
134
|
end
|
121
135
|
|
122
136
|
end
|