xmlstats 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b31c84b7c1f9671819850ab76351b19c8efa673c
4
- data.tar.gz: fe6157c6daf19ec7ff3e65f2b492333b820dd707
3
+ metadata.gz: 7f588cd5dfc99679e6be5ae6d0aa13432a281989
4
+ data.tar.gz: debca1c193278a183cc0b340fecd1a0b0fa2079c
5
5
  SHA512:
6
- metadata.gz: 4b4b3a9ceaaa0d3fa8da0a04273196c48e7c37881f85bf1a0f5cc1576a62c440d0e5a70675585cc3cfe5193154954a53f764591832c6ce300f5bab38a91929dc
7
- data.tar.gz: f1ba997f1c0905e52620d6ed526fb29cbe0aa1adb10d1a6e46e1dfa5057267df79160775cadeb8d0a64f8b6c397ec33d1fd52b916fd022c7526eea8b8700cb08
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::VERIFY_NONE
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})"
@@ -1,3 +1,3 @@
1
1
  module Xmlstats
2
- VERSION = "1.2.0"
2
+ VERSION = "1.3.0"
3
3
  end
data/lib/xmlstats.rb CHANGED
@@ -41,82 +41,96 @@ require "xmlstats/endpoints/nba_leaders"
41
41
 
42
42
  module Xmlstats
43
43
 
44
- def self.api_key
45
- @api_key ||= ENV["XMLSTATS_API_KEY"]
46
- end
44
+ class << self
47
45
 
48
- def self.api_key= api_key
49
- @api_key = api_key
50
- end
46
+ # Manage api key
51
47
 
52
- def self.contact_info
53
- error = "specify user-agent contact info with: Xmlstats.contact_info = 'you@example.com'"
54
- @contact_info ||= ENV["XMLSTATS_CONTACT_INFO"]
55
- @contact_info or raise(error)
56
- end
48
+ def api_key
49
+ @api_key ||= ENV["XMLSTATS_API_KEY"]
50
+ end
57
51
 
58
- def self.contact_info= contact_info
59
- @contact_info = contact_info
60
- end
52
+ def api_key= api_key
53
+ @api_key = api_key
54
+ end
61
55
 
62
- def self.http_getter
63
- @http_getter || Xmlstats::HttpGetters::NetHttp.new
64
- end
56
+ # Manage contact info
65
57
 
66
- def self.http_getter= http_getter
67
- @http_getter = http_getter
68
- end
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
- def self.cacher
71
- @cacher || Xmlstats::Cachers::Memory.new
72
- end
64
+ def contact_info= contact_info
65
+ @contact_info = contact_info
66
+ end
73
67
 
74
- def self.cacher= cacher
75
- @cacher = cacher
76
- end
68
+ # Manage http getter
77
69
 
78
- def self.events *args
79
- Xmlstats::Endpoints::Events.fetch *args
80
- end
70
+ def http_getter
71
+ @http_getter || Xmlstats::HttpGetters::NetHttp.new
72
+ end
81
73
 
82
- def self.mlb_box_score *args
83
- Xmlstats::Endpoints::MlbBoxScore.fetch *args
84
- end
74
+ def http_getter= http_getter
75
+ @http_getter = http_getter
76
+ end
85
77
 
86
- def self.nba_box_score *args
87
- Xmlstats::Endpoints::NbaBoxScore.fetch *args
88
- end
78
+ # Manage cacher
89
79
 
90
- def self.mlb_standing *args
91
- Xmlstats::Endpoints::MlbStanding.fetch *args
92
- end
80
+ def cacher
81
+ @cacher || Xmlstats::Cachers::Memory.new
82
+ end
93
83
 
94
- def self.nba_standing *args
95
- Xmlstats::Endpoints::NbaStanding.fetch *args
96
- end
84
+ def cacher= cacher
85
+ @cacher = cacher
86
+ end
97
87
 
98
- def self.mlb_wild_card_standing *args
99
- Xmlstats::Endpoints::MlbWildCardStanding.fetch *args
100
- end
88
+ # Wrapper methods to each endpoint
101
89
 
102
- def self.mlb_team_results *args
103
- Xmlstats::Endpoints::MlbTeamResults.fetch *args
104
- end
90
+ def events *args
91
+ Xmlstats::Endpoints::Events.fetch *args
92
+ end
105
93
 
106
- def self.nba_team_results *args
107
- Xmlstats::Endpoints::NbaTeamResults.fetch *args
108
- end
94
+ def mlb_box_score *args
95
+ Xmlstats::Endpoints::MlbBoxScore.fetch *args
96
+ end
109
97
 
110
- def self.mlb_teams *args
111
- Xmlstats::Endpoints::MlbTeams.fetch *args
112
- end
98
+ def nba_box_score *args
99
+ Xmlstats::Endpoints::NbaBoxScore.fetch *args
100
+ end
113
101
 
114
- def self.nba_teams *args
115
- Xmlstats::Endpoints::NbaTeams.fetch *args
116
- end
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xmlstats
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex McHale