xmlstats 1.3.1 → 1.4.1

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: 5a1505e84e00c67227a36951d0ed280af7056ad9
4
- data.tar.gz: eca920e8520c0736618bf0de0c24063e94876cab
3
+ metadata.gz: 4ed1a581a8a2b0e684c7b5a6a3e0241d8ad781ec
4
+ data.tar.gz: 6401b4b833f5d06354c05f683361252ecddffef5
5
5
  SHA512:
6
- metadata.gz: befc00208d3e6b07a7a79aade812b57c325d383cdb2fbef7a8228d636eae218119472321ee6e51854ecba91501909494be2a5e6255f63694ae8912082a65c838
7
- data.tar.gz: 9cf9b25ae4803cac920bb7cd2692d4094b6891d7b79d5a15e59670a84d55126a296e9affccbea2a2cd4284fdfc5a7514c9e4c5cd42013c347c810da4be08750a
6
+ metadata.gz: ee0994512d1d0efd7948c166748fbb202ce5e8763601988658757687429aa23a727bd6439f3da3d829f39a92e76d52c76ff0cb134c0fc2b4a8cea55503c79a5d
7
+ data.tar.gz: 25266d5b45f67c3cddad7842fb62ca10c929705e9b4de51f90620d8d9ffefeddfa2862d7b76abd167d4bf3f859c41252ff7f56e4051341943eecf8a6e18972dd
data/README.md CHANGED
@@ -165,6 +165,19 @@ To query the current leaders for points per game:
165
165
 
166
166
  Xmlstats.nba_leaders(:points_per_game)
167
167
 
168
+ ### NBA Roster ###
169
+
170
+ https://erikberg.com/api/issues/135
171
+
172
+ To query the current roster for an MLB team:
173
+
174
+ Xmlstats.nba_roster("detroit-pistons")
175
+
176
+ This method returns an array of **Player** objects with the following fields:
177
+
178
+ [:last_name, :first_name, :display_name, :birthdate, :age, :position,
179
+ :height_in, :height_cm, :weight_lb, :weight_kg, :height_formatted]
180
+
168
181
  Examples
169
182
  --------
170
183
 
@@ -21,6 +21,7 @@ require "xmlstats/objects/mlb_box_score"
21
21
  require "xmlstats/objects/nba_box_score"
22
22
  require "xmlstats/objects/team_result"
23
23
  require "xmlstats/objects/nba_leader"
24
+ require "xmlstats/objects/player"
24
25
 
25
26
  require "xmlstats/cachers/memory"
26
27
  require "xmlstats/cachers/redis"
@@ -38,6 +39,7 @@ require "xmlstats/endpoints/nba_teams"
38
39
  require "xmlstats/endpoints/mlb_team_results"
39
40
  require "xmlstats/endpoints/nba_team_results"
40
41
  require "xmlstats/endpoints/nba_leaders"
42
+ require "xmlstats/endpoints/nba_roster"
41
43
 
42
44
  module Xmlstats
43
45
 
@@ -134,6 +136,10 @@ module Xmlstats
134
136
  Xmlstats::Endpoints::NbaLeaders.fetch *args
135
137
  end
136
138
 
139
+ def nba_roster *args
140
+ Xmlstats::Endpoints::NbaRoster.fetch *args
141
+ end
142
+
137
143
  end
138
144
 
139
145
  end
@@ -0,0 +1,13 @@
1
+ class Xmlstats::Endpoints::NbaRoster
2
+
3
+ include Xmlstats::Endpoint
4
+
5
+ def self.fetch(team_id = nil)
6
+ raise "please specify team_id as detailed in https://erikberg.com/api/issues/135" unless team_id
7
+ response = fetch_json("nba/team/#{team_id}/roster")
8
+ [ response ].flatten.map do |result|
9
+ Xmlstats::Objects::Player.new result["player"]
10
+ end
11
+ end
12
+
13
+ end
@@ -27,6 +27,13 @@ module Xmlstats
27
27
  time = Time.parse(val)
28
28
  instance_variable_set(ivar, time)
29
29
  end
30
+
31
+ self.class.object_dates.each do |field_name|
32
+ ivar = "@#{field_name}"
33
+ val = instance_variable_get(ivar)
34
+ time = Date.parse(val)
35
+ instance_variable_set(ivar, time)
36
+ end
30
37
  end
31
38
 
32
39
  def fields
@@ -40,8 +47,7 @@ module Xmlstats
40
47
  end
41
48
 
42
49
  def self.reference field_name, field_type
43
- @object_references ||= []
44
- @object_references << [ field_name, field_type ]
50
+ object_references << [ field_name, field_type ]
45
51
  end
46
52
 
47
53
  def self.object_references
@@ -49,14 +55,21 @@ module Xmlstats
49
55
  end
50
56
 
51
57
  def self.time field_name
52
- @object_times ||= []
53
- @object_times << field_name
58
+ object_times << field_name
54
59
  end
55
60
 
56
61
  def self.object_times
57
62
  @object_times ||= []
58
63
  end
59
64
 
65
+ def self.date field_name
66
+ object_dates << field_name
67
+ end
68
+
69
+ def self.object_dates
70
+ @object_dates ||= []
71
+ end
72
+
60
73
  end
61
74
 
62
75
  module Objects
@@ -0,0 +1,5 @@
1
+ class Xmlstats::Objects::Player < Xmlstats::Object
2
+
3
+ date :birthdate
4
+
5
+ end
@@ -1,3 +1,3 @@
1
1
  module Xmlstats
2
- VERSION = "1.3.1"
2
+ VERSION = "1.4.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xmlstats
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex McHale
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-22 00:00:00.000000000 Z
11
+ date: 2013-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -63,6 +63,7 @@ files:
63
63
  - lib/xmlstats/endpoints/mlb_wild_card_standing.rb
64
64
  - lib/xmlstats/endpoints/nba_box_score.rb
65
65
  - lib/xmlstats/endpoints/nba_leaders.rb
66
+ - lib/xmlstats/endpoints/nba_roster.rb
66
67
  - lib/xmlstats/endpoints/nba_standing.rb
67
68
  - lib/xmlstats/endpoints/nba_team_results.rb
68
69
  - lib/xmlstats/endpoints/nba_teams.rb
@@ -77,6 +78,7 @@ files:
77
78
  - lib/xmlstats/objects/nba_leader.rb
78
79
  - lib/xmlstats/objects/official.rb
79
80
  - lib/xmlstats/objects/pitcher.rb
81
+ - lib/xmlstats/objects/player.rb
80
82
  - lib/xmlstats/objects/site.rb
81
83
  - lib/xmlstats/objects/standing.rb
82
84
  - lib/xmlstats/objects/team.rb