soda_xml_team 1.3.1 → 1.4.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: 8790c17cc037ad47ab785a64c4d393c2131a48e5
4
- data.tar.gz: 61c0532a78e633d738530450ffd4917ee38534cb
3
+ metadata.gz: bdd088c94b73418807eb01eb8185d64da675b0f7
4
+ data.tar.gz: 358dc4c8fe43b05a03361a0f904416169f7c65b9
5
5
  SHA512:
6
- metadata.gz: 94043f2f2ee6ae3f5925efa822adf11c61adbcca5649fd8492c99d45b85c13e6f43ed1e9df1a46c500df3f20fca273ee353a054b38bb0d54f4843acf50b17776
7
- data.tar.gz: bd8fcbf0e862d1accf51ed8e90b4dcedbedab0f826c1920b5f9cd1d8728e432a4e2cbd17c2836e5f733731b74ed85b7220b95f8df949a702611f89188f2da50b
6
+ metadata.gz: 5d828d183ac7579722944ddbeed1ec4cc79651f565a26c51a4c9570aa554b9f44ad3a9225ec5bcd4474fc70e14a69450e4a8719b0dd7b20c92ec1846cdf16b72
7
+ data.tar.gz: fa15a7711f5c0b9393e046782bb46a0056b1315f48b3bc0d4879bff85b02644222bc29d297d32f31612b20d935ae9d2c0b34502baaa0406d3de22ac9afafe538
data/.rubocop.yml ADDED
@@ -0,0 +1,9 @@
1
+
2
+ inherit_from: .rubocop_todo.yml
3
+
4
+ AllCops:
5
+ Exclude:
6
+ - 'vendor/**/*'
7
+ - 'spec/fixtures/**/*'
8
+ - 'spec/spec_helper.rb'
9
+ - 'soda_xml_team.gemspec'
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,33 @@
1
+ # This configuration was generated by `rubocop --auto-gen-config`
2
+ # on 2014-12-07 21:50:37 -0600 using RuboCop version 0.27.1.
3
+ # The point is for the user to remove these configuration records
4
+ # one by one as the offenses are removed from the code base.
5
+ # Note that changes in the inspected code, or installation of new
6
+ # versions of RuboCop, may require this file to be generated again.
7
+
8
+ # Offense count: 5
9
+ Metrics/AbcSize:
10
+ Max: 80
11
+
12
+ # Offense count: 2
13
+ Metrics/CyclomaticComplexity:
14
+ Max: 20
15
+
16
+ # Offense count: 4
17
+ # Configuration parameters: AllowURI, URISchemes.
18
+ Metrics/LineLength:
19
+ Max: 133
20
+
21
+ # Offense count: 6
22
+ # Configuration parameters: CountComments.
23
+ Metrics/MethodLength:
24
+ Max: 61
25
+
26
+ # Offense count: 2
27
+ Metrics/PerceivedComplexity:
28
+ Max: 28
29
+
30
+ # Offense count: 1
31
+ # Configuration parameters: Exclude.
32
+ Style/FileName:
33
+ Enabled: false
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # SODA XML Team Gem
2
2
 
3
- [![Build Status](https://travis-ci.org/seatshare/soda_xml_team.png)](https://travis-ci.org/seatshare/soda_xml_team)
3
+ [![Gem Version](https://badge.fury.io/rb/soda_xml_team.svg)](http://badge.fury.io/rb/soda_xml_team) [![Build Status](https://travis-ci.org/seatshare/soda_xml_team.png)](https://travis-ci.org/seatshare/soda_xml_team)
4
4
 
5
5
  This [gem](http://rubygems.org/gems/soda_xml_team) serves as an interface to the [SODA (Sports On Demand API) from XML Team](http://www.xmlteam.com/soda/). It uses [HTTParty](http://johnnunemaker.com/httparty/) and [Nokogiri](http://nokogiri.org/) to retrieve and parse the data.
6
6
 
@@ -108,6 +108,15 @@ standings = SodaXmlTeam::Standings.parse_standings(standings_document)
108
108
  puts standings.inspect
109
109
  ```
110
110
 
111
+ ### League Directory File Parser
112
+
113
+ This gem includes an executable for parsing files from the [SODA League Directory](http://private.xmlteam.com/league-directory/), which is useful for handling a particular sports league.
114
+
115
+ ```bash
116
+ $ soda-league-directory ~/Downloads/xt.20140505T114154-0400.l.afa.ar.primera-leaguedir.xml
117
+ [{:import_key=>"o.afa.ar-t.113", :entity_name=>"Argentinos Juniors ", :status=>1, :entity_type=>"l.afa.ar.primera"}, {:import_key=>"o.afa.ar-t.92", :entity_name=>"Arsenal de Sarandi ", :status=>1, :entity_type=>"l.afa.ar.primera"}, ... ]
118
+ ```
119
+
111
120
  ## Contributing
112
121
 
113
122
  1. Fork it ( https://github.com/seatshare/soda_xml_team/fork )
data/Rakefile CHANGED
@@ -1,3 +1,6 @@
1
- require "bundler/gem_tasks"
1
+ require 'bundler/gem_tasks'
2
2
 
3
- Dir.glob('tasks/**/*.rake').each(&method(:import))
3
+ Dir.glob('tasks/**/*.rake').each(&method(:import))
4
+
5
+ # Default to running rspec
6
+ task default: [:spec]
@@ -0,0 +1,61 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'nokogiri'
4
+
5
+ # Arguments
6
+ file = "#{ARGV[0]}" || nil
7
+
8
+ if file.nil? || file == ''
9
+ puts 'Usage: soda-league-directory path-to-file.xml'
10
+ Kernel.exit(false)
11
+ end
12
+
13
+ unless File.exist? file
14
+ puts 'File does not exist.'
15
+ Kernel.exit(false)
16
+ end
17
+
18
+ File.open("#{ARGV[0]}", 'r') do |io|
19
+
20
+ document = Nokogiri::XML(io)
21
+
22
+ fail 'Invalid XML league directory.' unless document.is_a? Nokogiri::XML::Document
23
+
24
+ output = []
25
+
26
+ entity_type = ''
27
+ document.css('sports-content-codes sports-content-code[code-type="league"]').each do |sportscontentcode|
28
+ entity_type = sportscontentcode['code-key']
29
+ end
30
+
31
+ document.css('team').each do |team|
32
+
33
+ row = {}
34
+
35
+ team.css('team-metadata').each do |teammeta|
36
+ row[:team_key] = teammeta['team-key']
37
+ team.css('name').each do |namemeta|
38
+ row[:name] = namemeta['full']
39
+ end
40
+ end
41
+
42
+ output << row
43
+ end
44
+
45
+ final_output = []
46
+ # Export a create statement
47
+ output.each do |team|
48
+ next if ['', 'TBA'].include? team[:name].strip
49
+ next if team[:team_key].strip == ''
50
+ object = {
51
+ import_key: team[:team_key],
52
+ entity_name: team[:name],
53
+ status: 1,
54
+ entity_type: entity_type
55
+ }
56
+ final_output << object
57
+ end
58
+
59
+ puts final_output.to_s
60
+
61
+ end
data/lib/soda_xml_team.rb CHANGED
@@ -1,11 +1,12 @@
1
- require "soda_xml_team/version"
2
- require "soda_xml_team/client"
3
- require "soda_xml_team/base"
4
- require "soda_xml_team/address"
5
- require "soda_xml_team/schedule"
6
- require "soda_xml_team/news"
7
- require "soda_xml_team/standings"
1
+ require 'soda_xml_team/version'
2
+ require 'soda_xml_team/client'
3
+ require 'soda_xml_team/base'
4
+ require 'soda_xml_team/address'
5
+ require 'soda_xml_team/schedule'
6
+ require 'soda_xml_team/news'
7
+ require 'soda_xml_team/standings'
8
8
 
9
+ ##
10
+ # SODA XML Team
9
11
  module SodaXmlTeam
10
-
11
12
  end
@@ -1,53 +1,57 @@
1
+ ##
2
+ # SODA XML Team module
1
3
  module SodaXmlTeam
4
+ ##
5
+ # Address class
2
6
  class Address < Client
3
-
7
+ ##
8
+ # Builds the query address against the API
4
9
  def self.build(method, options = {})
5
-
6
10
  path = []
7
11
 
8
- if !["get_listing", "get_document"].include? method
9
- raise "Invalid method."
10
- end
12
+ fail 'Invalid method.' unless %w(get_listing get_document).include? method
11
13
 
12
14
  # Get a listing of documents
13
- if method === 'get_listing'
15
+ if method == 'get_listing'
14
16
  endpoint = '/getListings?'
15
17
 
16
- if options[:league_id].nil? && options[:team_id].nil?
17
- raise "Must specify a `league_id` (league-keys) or `team_id` (team-keys)."
18
- end
18
+ fail 'Must specify `league_id` (league-keys) or `team_id` (team-keys).' if options[:league_id].nil? && options[:team_id].nil?
19
19
 
20
20
  # League identifier
21
- if options[:league_id]
22
- path << "league-keys=#{options[:league_id]}"
23
- end
21
+ path << "league-keys=#{options[:league_id]}" if options[:league_id]
24
22
 
25
23
  # Team identifier
26
- if options[:team_id]
27
- path << "team-keys=#{options[:team_id]}"
28
- end
24
+ path << "team-keys=#{options[:team_id]}" if options[:team_id]
29
25
 
30
26
  # Document type
31
27
  if options[:type]
32
28
  path << "fixture-keys=#{options[:type]}"
33
29
  else
34
- raise "Must specify the `type` (fixture-keys)"
30
+ fail 'Must specify the `type` (fixture-keys)'
35
31
  end
36
32
 
37
33
  # Start date/time
38
34
  if options[:start_datetime].is_a? String
39
35
  options[:start_datetime] = DateTime.parse(options[:start_datetime])
40
- path << "earliest-date-time=#{options[:start_datetime].strftime('%Y%m%dT%H%M%S%z')}"
36
+ path << "earliest-date-time=#{options[:start_datetime].strftime(
37
+ '%Y%m%dT%H%M%S%z'
38
+ )}"
41
39
  elsif options[:start_datetime].is_a? DateTime
42
- path << "earliest-date-time=#{options[:start_datetime].strftime('%Y%m%dT%H%M%S%z')}"
40
+ path << "earliest-date-time=#{options[:start_datetime].strftime(
41
+ '%Y%m%dT%H%M%S%z'
42
+ )}"
43
43
  end
44
44
 
45
45
  # End date/time
46
46
  if options[:end_datetime].is_a? String
47
47
  options[:end_datetime] = DateTime.parse(options[:end_datetime])
48
- path << "latest-date-time=#{options[:end_datetime].strftime('%Y%m%dT%H%M%S%z')}"
48
+ path << "latest-date-time=#{options[:end_datetime].strftime(
49
+ '%Y%m%dT%H%M%S%z'
50
+ )}"
49
51
  elsif options[:end_datetime].is_a? DateTime
50
- path << "latest-date-time=#{options[:end_datetime].strftime('%Y%m%dT%H%M%S%z')}"
52
+ path << "latest-date-time=#{options[:end_datetime].strftime(
53
+ '%Y%m%dT%H%M%S%z'
54
+ )}"
51
55
  end
52
56
 
53
57
  # Use a date window
@@ -59,23 +63,21 @@ module SodaXmlTeam
59
63
  if !options[:limit].nil? && options[:limit] > 0 && options[:limit] <= 50
60
64
  path << "max-result-count=#{options[:limit]}"
61
65
  else
62
- path << "max-result-count=10"
66
+ path << 'max-result-count=10'
63
67
  end
64
68
 
65
69
  # Priority
66
- if options[:priority]
67
- path << "priorities=#{options[:priority]}"
68
- end
70
+ path << "priorities=#{options[:priority]}" if options[:priority]
69
71
 
70
72
  # Which document revisions to return
71
- if options[:revisions] === 'all'
72
- path << "revision-control=all"
73
+ if options[:revisions] == 'all'
74
+ path << 'revision-control=all'
73
75
  else
74
- path << "revision-control=latest-only"
76
+ path << 'revision-control=latest-only'
75
77
  end
76
78
 
77
79
  # Always return the XML listing
78
- path << "stylesheet=sportsml2rss-1.0-s"
80
+ path << 'stylesheet=sportsml2rss-1.0-s'
79
81
 
80
82
  # Get a specific document
81
83
  else
@@ -83,21 +85,19 @@ module SodaXmlTeam
83
85
  if options[:document_id]
84
86
  path << "doc-ids=#{options[:document_id]}"
85
87
  else
86
- raise "Missing `document_id` (doc-ids)"
88
+ fail 'Missing `document_id` (doc-ids)'
87
89
  end
88
90
  end
89
91
 
90
92
  # Concatenate it together
91
- path = path.join "&"
93
+ path = path.join '&'
92
94
 
93
95
  # Use sandbox hostname or production
94
- if options[:sandbox] === true
96
+ if options[:sandbox] == true
95
97
  return SodaXmlTeam::API_SANDBOX_URL + endpoint + path
96
98
  else
97
99
  return SodaXmlTeam::API_BASE_URL + endpoint + path
98
100
  end
99
-
100
101
  end
101
-
102
102
  end
103
- end
103
+ end
@@ -1,4 +1,6 @@
1
+ ##
2
+ # SODA XML Team module
1
3
  module SodaXmlTeam
2
- API_BASE_URL = "https://soda.xmlteam.com/api"
3
- API_SANDBOX_URL = "https://soda.xmlteam.com/api-trial"
4
+ API_BASE_URL = 'https://soda.xmlteam.com/api'
5
+ API_SANDBOX_URL = 'https://soda.xmlteam.com/api-trial'
4
6
  end
@@ -1,17 +1,29 @@
1
+ ##
2
+ # SODA XML Team module
1
3
  module SodaXmlTeam
2
-
3
4
  require 'httparty'
4
5
  require 'nokogiri'
5
6
 
7
+ ##
8
+ # Client for interacting with API
6
9
  class Client
7
-
8
10
  def initialize(username, password)
9
- @auth = {:username => username, :password => password}
11
+ @auth = { username: username, password: password }
10
12
  @dir = File.dirname __FILE__
11
13
  end
12
14
 
13
- def content_finder(options={})
14
- response = HTTParty.get(SodaXmlTeam::Address.build("get_listing", options), :basic_auth => @auth, :ssl_ca_file => "#{@dir}/../ca-certificates.crt", :ssl_version => :SSLv3)
15
+ ##
16
+ # Content Finder retrieves an RSS feed of desired data
17
+ def content_finder(options = {})
18
+ response = HTTParty.get(
19
+ SodaXmlTeam::Address.build(
20
+ 'get_listing',
21
+ options
22
+ ),
23
+ basic_auth: @auth,
24
+ ssl_ca_file: "#{@dir}/../ca-certificates.crt",
25
+ ssl_version: :SSLv3
26
+ )
15
27
  feed = Nokogiri::XML(response.body)
16
28
 
17
29
  documents = []
@@ -20,36 +32,53 @@ module SodaXmlTeam
20
32
 
21
33
  # Parse for document ID
22
34
  link = item.css('link').inner_text
23
- document_id = link.gsub /(.*)?doc-ids=/i, ''
35
+ document_id = link.gsub(/(.*)?doc-ids=/i, '')
24
36
 
25
37
  record[:title] = item.css('title').inner_text
26
38
  record[:link] = link
27
39
  record[:document_id] = document_id
28
40
  record[:date] = DateTime.parse(item.xpath('./dc:date').inner_text)
29
41
  item.xpath('./sportsml:sports-content-codes').each do |sportscontent|
30
- sportscontent.xpath('./sportsml:sports-content-code').each do |content|
31
- record[content['code-type'].to_sym] = content['code-key']
42
+ sportscontent.xpath('./sportsml:sports-content-code').each do |c|
43
+ record[c['code-type'].to_sym] = c['code-key']
32
44
  end
33
45
  end
34
46
 
35
47
  documents << record
36
48
  end
37
49
 
38
- return documents
39
-
50
+ documents
40
51
  end
41
52
 
53
+ ##
42
54
  # Deprecated: Please use `content_finder` instead
43
- def get_listing(options={})
44
- warn "[DEPRECATION] `get_listing` is deprecated. Please use `content_finder` instead."
45
- response = HTTParty.get(SodaXmlTeam::Address.build("get_listing", options), :basic_auth => @auth, :ssl_ca_file => "#{@dir}/../ca-certificates.crt", :ssl_version => :SSLv3)
55
+ def get_listing(options = {})
56
+ warn '[DEPRECATION] `get_listing` is deprecated. Please use `content_finder` instead.'
57
+ response = HTTParty.get(
58
+ SodaXmlTeam::Address.build(
59
+ 'get_listing',
60
+ options
61
+ ),
62
+ basic_auth: @auth,
63
+ ssl_ca_file: "#{@dir}/../ca-certificates.crt",
64
+ ssl_version: :SSLv3
65
+ )
46
66
  Nokogiri::XML(response.body)
47
67
  end
48
68
 
49
- def get_document(options={})
50
- response = HTTParty.get(SodaXmlTeam::Address.build("get_document", options), :basic_auth => @auth, :ssl_ca_file => "#{@dir}/../ca-certificates.crt", :ssl_version => :SSLv3)
69
+ ##
70
+ # Get Document retrieves a parsed XML instance of a given document
71
+ def get_document(options = {})
72
+ response = HTTParty.get(
73
+ SodaXmlTeam::Address.build(
74
+ 'get_document',
75
+ options
76
+ ),
77
+ basic_auth: @auth,
78
+ ssl_ca_file: "#{@dir}/../ca-certificates.crt",
79
+ ssl_version: :SSLv3
80
+ )
51
81
  Nokogiri::XML(response.body)
52
82
  end
53
-
54
83
  end
55
84
  end
@@ -1,39 +1,41 @@
1
+ ##
2
+ # SODA XML Team module
1
3
  module SodaXmlTeam
2
-
3
4
  require 'nokogiri'
4
5
 
6
+ ##
7
+ # News class
5
8
  class News
6
-
7
- def self.parse_news(document={})
8
-
9
+ ##
10
+ # Parses news documents into hashes
11
+ # - document: a Nokegiri::XML::Document
12
+ def self.parse_news(document = {})
9
13
  output = []
10
14
 
11
- unless document.is_a? Nokogiri::XML::Document
12
- raise "Invalid XML news."
13
- end
15
+ fail 'Invalid XML news.' unless document.is_a? Nokogiri::XML::Document
14
16
 
15
17
  output = {}
16
18
 
17
19
  # Article meta data
18
20
  document.css('sports-content').each do |metadata|
19
21
  output[:title] = metadata.css('sports-title').first.content
20
- if !metadata.css('byline person').empty?
22
+ unless metadata.css('byline person').empty?
21
23
  output[:author] = metadata.css('byline person').first.content
22
24
  end
23
25
  output[:author_title] = metadata.css('byline byttl').first.content
24
26
  output[:headline] = metadata.css('article hedline hl1').first.content
25
- output[:abstract] = metadata.css('article abstract').first.content.gsub(/\n/, "").strip
27
+ output[:abstract] = metadata.css('article abstract')
28
+ .first.content.gsub(/\n/, '').strip
26
29
  end
27
30
 
28
31
  # Article content
29
- document.xpath('/xts:sports-content-set/sports-content/article/nitf/body/body.content').each do |article_body|
30
- output[:body] = article_body.css('*').to_s.gsub(/\n/, "").strip
32
+ document.xpath(
33
+ '/xts:sports-content-set/sports-content/article/nitf/body/body.content'
34
+ ).each do |article_body|
35
+ output[:body] = article_body.css('*').to_s.gsub(/\n/, '').strip
31
36
  end
32
37
 
33
- return output
34
-
38
+ output
35
39
  end
36
-
37
40
  end
38
-
39
- end
41
+ end
@@ -1,16 +1,18 @@
1
+ ##
2
+ # SODA XML Team module
1
3
  module SodaXmlTeam
2
-
3
4
  require 'nokogiri'
4
5
 
6
+ ##
7
+ # Schedule class
5
8
  class Schedule
6
-
7
- def self.parse_schedule(document={})
8
-
9
+ ##
10
+ # Parses schedule documents into hashes
11
+ # - document: a Nokegiri::XML::Document
12
+ def self.parse_schedule(document = {})
9
13
  output = []
10
14
 
11
- unless document.is_a? Nokogiri::XML::Document
12
- raise "Invalid XML schedule."
13
- end
15
+ fail 'Invalid XML schedule.' unless document.is_a? Nokogiri::XML::Document
14
16
 
15
17
  document.css('schedule sports-event').each do |event|
16
18
 
@@ -37,10 +39,7 @@ module SodaXmlTeam
37
39
  output << row
38
40
  end
39
41
 
40
- return output
41
-
42
+ output
42
43
  end
43
-
44
44
  end
45
-
46
- end
45
+ end
@@ -1,23 +1,28 @@
1
+ ##
2
+ # SODA XML Team module
1
3
  module SodaXmlTeam
2
-
3
4
  require 'nokogiri'
4
5
 
6
+ ##
7
+ # Standings class
5
8
  class Standings
6
-
7
- def self.parse_standings(document={})
8
-
9
+ ##
10
+ # Parses standings documents into hashes
11
+ # - document: a Nokegiri::XML::Document
12
+ def self.parse_standings(document = {})
9
13
  output = []
10
14
 
11
- unless document.is_a? Nokogiri::XML::Document
12
- raise "Invalid XML standings."
13
- end
15
+ fail 'Invalid XML standings.' unless
16
+ document.is_a? Nokogiri::XML::Document
14
17
 
15
18
  document.css('sports-content standing').each do |division|
16
19
 
17
20
  row = {}
18
21
  row[:division] = division['content-label']
19
22
 
20
- division.css('standing-metadata sports-content-codes sports-content-code[code-type="conference"]').each do |standingmetadata|
23
+ division.css(
24
+ 'sports-content-codes sports-content-code[code-type="conference"]'
25
+ ).each do |standingmetadata|
21
26
  row[:conference] = standingmetadata['code-name']
22
27
  end
23
28
 
@@ -27,8 +32,8 @@ module SodaXmlTeam
27
32
 
28
33
  team_record = {}
29
34
 
30
- team.css('team-metadata name').each do |teammetaname|
31
- team_record[:name] = "#{teammetaname[:first]} #{teammetaname[:last]}"
35
+ team.css('team-metadata name').each do |tmn|
36
+ team_record[:name] = "#{tmn[:first]} #{tmn[:last]}"
32
37
  end
33
38
 
34
39
  team.css('team-stats').each do |teamstats|
@@ -36,18 +41,22 @@ module SodaXmlTeam
36
41
  team_record[:standing_points] = teamstats['standing-points'].to_i
37
42
  end
38
43
 
39
- team.css('team-stats rank').each do |teamstatsrank|
40
- team_record[:division_rank] = teamstatsrank[:value].to_i
41
- team_record[:conference_rank] = teamstatsrank['xts:conference-rank'].to_i
44
+ team.css('team-stats rank').each do |tsr|
45
+ team_record[:division_rank] = tsr[:value].to_i
46
+ team_record[:conference_rank] = tsr['xts:conference-rank'].to_i
42
47
  end
43
48
 
44
- team.css('team-stats outcome-totals').each do |outcometotals|
45
- next if outcometotals['competition-scope'] != "league"
46
- next if outcometotals['date-coverage-type'] != "season-regular"
47
- next if !outcometotals['duration-scope'].nil?
48
- next if !outcometotals['alignment-scope'].nil?
49
- outcometotals.keys.each do |outcometotalskey|
50
- team_record[outcometotalskey] = outcometotals[outcometotalskey].to_i if Float(outcometotals[outcometotalskey]) rescue team_record[outcometotalskey] = outcometotals[outcometotalskey]
49
+ team.css('team-stats outcome-totals').each do |ot|
50
+ next if ot['competition-scope'] != 'league'
51
+ next if ot['date-coverage-type'] != 'season-regular'
52
+ next unless ot['duration-scope'].nil?
53
+ next unless ot['alignment-scope'].nil?
54
+ ot.keys.each do |otk|
55
+ begin
56
+ team_record[otk] = ot[otk].to_i if Float(ot[otk])
57
+ rescue
58
+ team_record[otk] = ot[otk]
59
+ end
51
60
  end
52
61
  end
53
62
 
@@ -58,10 +67,7 @@ module SodaXmlTeam
58
67
  output << row
59
68
  end
60
69
 
61
- return output
62
-
70
+ output
63
71
  end
64
-
65
72
  end
66
-
67
- end
73
+ end
@@ -1,3 +1,5 @@
1
+ ##
2
+ # SODA XML Team module
1
3
  module SodaXmlTeam
2
- VERSION = "1.3.1"
4
+ VERSION = '1.4.0'
3
5
  end
@@ -4,25 +4,25 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'soda_xml_team/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "soda_xml_team"
7
+ spec.name = 'soda_xml_team'
8
8
  spec.version = SodaXmlTeam::VERSION
9
- spec.authors = ["Stephen Yeargin"]
10
- spec.email = ["stephen@seatsha.re"]
11
- spec.summary = %q{XML Team Sports On Demand API}
12
- spec.description = %q{A basic layer for interacting with XML Team's Sports On Demand API (SODA)}
13
- spec.homepage = "https://github.com/seatshare/soda_xml_team"
14
- spec.license = "MIT"
9
+ spec.authors = ['Stephen Yeargin']
10
+ spec.email = ['stephen@seatsha.re']
11
+ spec.summary = 'XML Team Sports On Demand API'
12
+ spec.description = "A basic layer for interacting with XML Team's Sports On Demand API (SODA)"
13
+ spec.homepage = 'https://github.com/seatshare/soda_xml_team'
14
+ spec.license = 'MIT'
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0")
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
19
+ spec.require_paths = ['lib']
20
20
 
21
- spec.add_development_dependency "bundler", "~> 1.6"
22
- spec.add_development_dependency "rake", "~> 10.0"
23
- spec.add_development_dependency "rspec"
24
- spec.add_development_dependency "webmock"
21
+ spec.add_development_dependency 'bundler', '~> 1.6'
22
+ spec.add_development_dependency 'rake', '~> 10.0'
23
+ spec.add_development_dependency 'rspec'
24
+ spec.add_development_dependency 'webmock'
25
25
 
26
- spec.add_dependency "nokogiri", ">= 1.6.3"
27
- spec.add_dependency "httparty", ">= 0.13"
26
+ spec.add_dependency 'nokogiri', '>= 1.6.3'
27
+ spec.add_dependency 'httparty', '>= 0.13'
28
28
  end
@@ -1,25 +1,27 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "SodaXmlTeamNews" do
3
+ describe 'SodaXmlTeamNews' do
4
4
 
5
5
  subject { SodaXmlTeam::News }
6
6
 
7
7
  describe '.parse_news' do
8
8
 
9
- let(:input) {
10
- SodaXmlTeam::Client.new(ENV['SODA_USERNAME'], ENV['SODA_PASSWORD']).get_document({
9
+ let(:input) do
10
+ SodaXmlTeam::Client.new(
11
+ ENV['SODA_USERNAME'], ENV['SODA_PASSWORD']
12
+ ).get_document(
11
13
  sandbox: true,
12
14
  document_id: 'xt.3329967-NAS-2005-OUTLOOK'
13
- })
14
- }
15
+ )
16
+ end
15
17
  let(:output) { subject.parse_news(input) }
16
18
 
17
19
  it 'has a article that matches' do
18
20
  expect(output[:title]).to eq '2005-06 Nashville Predators Preview'
19
21
  expect(output[:headline]).to eq '2005-06 Nashville Predators Preview'
20
- expect(output[:abstract]).to eq 'The Nashville Predators were the surprise playoff club in 2003-04, and now the team hopes to get back to the postseason and take things a step further.'
21
- expect(output[:body]).to eq %q{<p>(Sports Network) - The Nashville Predators were the surprise playoff club in 2003-04, and now the team hopes to get back to the postseason and take things a step further.</p><p>During the offseason the club's big splash was the signing of Paul Kariya, who hopes to return to a superstar level after a down year with the Colorado Avalanche.</p><p>The team also bolstered its defense with the acquisition of Danny Markov from Philadelphia, and re-signed many of its key cogs.</p><p>Head coach Barry Trotz is the only bench boss the team has had since its inception in 1998, and in 03-04 he finally put things together on the ice. The Preds were a gritty bunch that wasn't intimidated by the upper echelon clubs. This was evident by its rivalry with Detroit during the regular season, and a valiant effort in the first round.</p><p>That grit and gumption now has a bona fide star to lead its effort, spurring hope for a second straight postseason berth.</p><p>FORWARDS - Kariya and Teemu Selanne went to Colorado as a package deal before the last NHL season, and the whole thing was a bust. Kariya battled injury during the campaign, tallying only 11 goals and 25 assists in 51 games. The seven-time All-Star posted 25 goals and 56 assists in a full season for Anaheim in 02-03, eventually leading the Ducks to the Stanley Cup Finals.</p><p>Kariya is a terrific lead horse for a stable of young forwards who have really been without a leader. David Legwand is a prime talent who had been an enigma for his first few seasons. In 03-04 he tallied 18 goals and 28 assists, including five game-winning goals.</p><p>Scott Walker is a guy who has been injury-prone throughout his career, but came through with a career effort last time out (25g, 42a). Walker is only 5-10, 196 pounds but plays tougher than his size. Greg Johnson returns to supply leadership and stability, while former first-rounder Scott Hartnell hopes to escape the obscurity of fourth-line duty.</p><p>Veteran speedster Steve Sullivan hopes to get back on track after being injured for most of the last two seasons. He was a 25-35-goal scorers a few years back with Chicago, and the Preds could sure use that spark. You have to wonder if all those years as an undersized NHL forward are finally taking a toll.</p><p>The Predators have a nice amount of toughness up front as well, with Darcy Hordichuk, Scott Nichol and the wild Jordin Tootoo in the fold.</p><p>DEFENSE - Markov became available when the Philadelphia Flyers needed to clear some cap space. He combined for six goals and 13 assists in 78 games for the Flyers and Hurricanes last time out, and is a guy who can log quality minutes in every situation. Markov is a tough guy to play against, as he is quick on his skates and plays physically.</p><p>Kimmo Timonen is the team's puck mover and power-play QB, having tallied 12 goals and 32 assists in 77 games back in 03-04. Timonen has bagged at least 12 scores on three occasions during his six-season career.</p><p>Marek Zdlicky is another offensive blueliner, netting 14 goals with 39 assists in 82 games as a rookie in 03-04. Acquired in the Mike Dunham trade with New York a few years back, Zdlicky especially lifted the Preds' power-play unit, accounting for nine goals and 26 assists with the man advantage.</p><p>Former first-round pick Dan Hamhius stepped in and made an impact in 03-04, and the club hopes for the same from Ryan Suter. Suter, who has a family pedigree, was the club's top choice in 2003. He played collegiately at Wisconsin and went pro last season, posting seven goals, 16 assists and 70 penalty minutes in 63 games for the Milwaukee Admirals of the AHL.</p><p>GOALTENDING - Tomas Vokoun has emerged as a viable workhorse goaltender for the Preds, as he started 73 games in 03-04. The Czech went 34-29-10 with a 2.53 goals-against average and .909 save percentage. Vokoun played well in the first-round series against Detroit too, holding the Red Wings to 12 goals in six games.</p><p>Chris Mason will likely serve as Vokoun's backup, after appearing in 17 games (nine starts) during 03-04. He went 4-4-1 with a 2.18 GAA and .926 SP.</p><p>WHEN ALL IS SAID AND DONE - The Predators caught teams by surprise in 03-04 with their hard-nosed, no-fear play. Teams will expect it this time around, so the onus will be on the skill players to raise their games. This begins with Kariya, who hopes to have a rebound season for a club that has many of its key parts returning. The Nashville brass has been patient with its young players, and it has paid off to this point.</p>}
22
+ expect(output[:abstract]).to include 'The Nashville Predators were the'
23
+ expect(output[:body]).to include '<p>(Sports Network) - The Nashville'
22
24
  end
23
25
 
24
26
  end
25
- end
27
+ end
@@ -6,12 +6,14 @@ describe SodaXmlTeam do
6
6
 
7
7
  describe '.parse_schedule' do
8
8
 
9
- let(:input) {
10
- SodaXmlTeam::Client.new(ENV['SODA_USERNAME'], ENV['SODA_PASSWORD']).get_document({
9
+ let(:input) do
10
+ SodaXmlTeam::Client.new(
11
+ ENV['SODA_USERNAME'], ENV['SODA_PASSWORD']
12
+ ).get_document(
11
13
  sandbox: true,
12
14
  document_id: 'xt.10875359-nas-sked'
13
- })
14
- }
15
+ )
16
+ end
15
17
  let(:output) { subject.parse_schedule(input) }
16
18
 
17
19
  it 'has 82 games in a season' do
@@ -27,7 +29,9 @@ describe SodaXmlTeam do
27
29
  end
28
30
 
29
31
  it 'has expected start date/time' do
30
- expect(output[1][:start_date_time]).to eq DateTime.parse('October 8, 2009 7:00 PM CDT')
32
+ expect(output[1][:start_date_time]).to eq DateTime.parse(
33
+ 'October 8, 2009 7:00 PM CDT'
34
+ )
31
35
  end
32
36
 
33
37
  it 'has expected site' do
@@ -40,4 +44,4 @@ describe SodaXmlTeam do
40
44
 
41
45
  end
42
46
 
43
- end
47
+ end
@@ -1,12 +1,16 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "SodaXmlTeam" do
3
+ describe 'SodaXmlTeam' do
4
4
 
5
- subject { SodaXmlTeam::Client.new(ENV['SODA_USERNAME'], ENV['SODA_PASSWORD']) }
5
+ subject do
6
+ SodaXmlTeam::Client.new(
7
+ ENV['SODA_USERNAME'], ENV['SODA_PASSWORD']
8
+ )
9
+ end
6
10
 
7
11
  describe '.content_finder' do
8
12
 
9
- let(:input) {
13
+ let(:input) do
10
14
  {
11
15
  sandbox: true,
12
16
  league_id: 'l.nhl.com',
@@ -15,7 +19,7 @@ describe "SodaXmlTeam" do
15
19
  start_datetime: DateTime.parse('2010-01-01 00:00:00 CDT'),
16
20
  end_datetime: DateTime.parse('2011-01-01 00:00:00 CDT')
17
21
  }
18
- }
22
+ end
19
23
  let(:output) { subject.content_finder(input) }
20
24
 
21
25
  it 'has seven items' do
@@ -23,19 +27,21 @@ describe "SodaXmlTeam" do
23
27
  end
24
28
 
25
29
  it 'has attributes that match' do
26
- expect(output[0][:title]).to eq "2010 Nashville Predators Schedule"
27
- expect(output[0][:link]).to eq "http://soda.xmlteam.com/api-trial/getDocuments?doc-ids=xt.10875359-nas-sked"
28
- expect(output[0][:document_id]).to eq "xt.10875359-nas-sked"
29
- expect(output[0][:date]).to eq DateTime.parse('February 14, 2010 16:14 PM CDT')
30
- expect(output[0][:publisher]).to eq "sportsnetwork.com"
31
- expect(output[0][:priority]).to eq "normal"
32
- expect(output[0][:sport]).to eq "15031000"
33
- expect(output[0][:league]).to eq "l.nhl.com"
34
- expect(output[0][:conference]).to eq "c.western"
35
- expect(output[0][:team]).to eq "l.nhl.com-t.19"
30
+ expect(output[0][:title]).to eq '2010 Nashville Predators Schedule'
31
+ expect(output[0][:link]).to eq 'http://soda.xmlteam.com/api-trial/getDocuments?doc-ids=xt.10875359-nas-sked'
32
+ expect(output[0][:document_id]).to eq 'xt.10875359-nas-sked'
33
+ expect(output[0][:date]).to eq DateTime.parse(
34
+ 'February 14, 2010 16:14 PM CDT'
35
+ )
36
+ expect(output[0][:publisher]).to eq 'sportsnetwork.com'
37
+ expect(output[0][:priority]).to eq 'normal'
38
+ expect(output[0][:sport]).to eq '15031000'
39
+ expect(output[0][:league]).to eq 'l.nhl.com'
40
+ expect(output[0][:conference]).to eq 'c.western'
41
+ expect(output[0][:team]).to eq 'l.nhl.com-t.19'
36
42
  end
37
43
 
38
- let(:input) {
44
+ let(:input) do
39
45
  {
40
46
  sandbox: true,
41
47
  league_id: 'l.nhl.com',
@@ -44,7 +50,7 @@ describe "SodaXmlTeam" do
44
50
  start_datetime: '2010-01-01 00:00:00 CDT',
45
51
  end_datetime: '2011-01-01 00:00:00 CDT'
46
52
  }
47
- }
53
+ end
48
54
  let(:output) { subject.content_finder(input) }
49
55
 
50
56
  it 'has seven items with string timestamp' do
@@ -52,28 +58,30 @@ describe "SodaXmlTeam" do
52
58
  end
53
59
 
54
60
  it 'has attributes that match with string timestamp' do
55
- expect(output[1][:title]).to eq "2010 Nashville Predators Schedule"
56
- expect(output[1][:link]).to eq "http://soda.xmlteam.com/api-trial/getDocuments?doc-ids=xt.10860136-nas-sked"
57
- expect(output[1][:document_id]).to eq "xt.10860136-nas-sked"
58
- expect(output[1][:date]).to eq DateTime.parse('February 12, 2010 22:49 PM CDT')
59
- expect(output[1][:publisher]).to eq "sportsnetwork.com"
60
- expect(output[1][:priority]).to eq "normal"
61
- expect(output[1][:sport]).to eq "15031000"
62
- expect(output[1][:league]).to eq "l.nhl.com"
63
- expect(output[1][:conference]).to eq "c.western"
64
- expect(output[1][:team]).to eq "l.nhl.com-t.19"
61
+ expect(output[1][:title]).to eq '2010 Nashville Predators Schedule'
62
+ expect(output[1][:link]).to eq 'http://soda.xmlteam.com/api-trial/getDocuments?doc-ids=xt.10860136-nas-sked'
63
+ expect(output[1][:document_id]).to eq 'xt.10860136-nas-sked'
64
+ expect(output[1][:date]).to eq DateTime.parse(
65
+ 'February 12, 2010 22:49 PM CDT'
66
+ )
67
+ expect(output[1][:publisher]).to eq 'sportsnetwork.com'
68
+ expect(output[1][:priority]).to eq 'normal'
69
+ expect(output[1][:sport]).to eq '15031000'
70
+ expect(output[1][:league]).to eq 'l.nhl.com'
71
+ expect(output[1][:conference]).to eq 'c.western'
72
+ expect(output[1][:team]).to eq 'l.nhl.com-t.19'
65
73
  end
66
74
 
67
75
  end
68
76
 
69
77
  describe '.get_document' do
70
78
 
71
- let(:input) {
79
+ let(:input) do
72
80
  {
73
81
  sandbox: true,
74
82
  document_id: 'xt.10875359-nas-sked'
75
83
  }
76
- }
84
+ end
77
85
  let(:output) { subject.get_document(input) }
78
86
 
79
87
  it 'has one schedule node' do
@@ -86,4 +94,4 @@ describe "SodaXmlTeam" do
86
94
 
87
95
  end
88
96
 
89
- end
97
+ end
@@ -6,12 +6,14 @@ describe SodaXmlTeam do
6
6
 
7
7
  describe '.parse_standings' do
8
8
 
9
- let(:input) {
10
- SodaXmlTeam::Client.new(ENV['SODA_USERNAME'], ENV['SODA_PASSWORD']).get_document({
9
+ let(:input) do
10
+ SodaXmlTeam::Client.new(
11
+ ENV['SODA_USERNAME'], ENV['SODA_PASSWORD']
12
+ ).get_document(
11
13
  sandbox: true,
12
14
  document_id: 'xt.10878197-standings'
13
- })
14
- }
15
+ )
16
+ end
15
17
  let(:output) { subject.parse_standings(input) }
16
18
 
17
19
  it 'has a division name' do
@@ -36,4 +38,4 @@ describe SodaXmlTeam do
36
38
 
37
39
  end
38
40
 
39
- end
41
+ end
data/spec/spec_helper.rb CHANGED
@@ -9,17 +9,17 @@ RSpec.configure do |config|
9
9
  ENV['SODA_PASSWORD'] = 'testpassword'
10
10
  end
11
11
 
12
- stub_request(:get, "https://#{ENV['SODA_USERNAME']}:#{ENV['SODA_PASSWORD']}@soda.xmlteam.com/api-trial/getListings?earliest-date-time=20100101T000000-0500&fixture-keys=schedule-single-team&latest-date-time=20110101T000000-0500&league-keys=l.nhl.com&max-result-count=10&revision-control=latest-only&stylesheet=sportsml2rss-1.0-s&team-keys=l.nhl.com-t.19").
13
- to_return(:status => 200, :body => File.new("spec/fixtures/get_listing_schedule.xml").read, :headers => {})
12
+ stub_request(:get, "https://#{ENV['SODA_USERNAME']}:#{ENV['SODA_PASSWORD']}@soda.xmlteam.com/api-trial/getListings?earliest-date-time=20100101T000000-0500&fixture-keys=schedule-single-team&latest-date-time=20110101T000000-0500&league-keys=l.nhl.com&max-result-count=10&revision-control=latest-only&stylesheet=sportsml2rss-1.0-s&team-keys=l.nhl.com-t.19")
13
+ .to_return(status: 200, body: File.new('spec/fixtures/get_listing_schedule.xml').read, headers: {})
14
14
 
15
- stub_request(:get, "https://#{ENV['SODA_USERNAME']}:#{ENV['SODA_PASSWORD']}@soda.xmlteam.com/api-trial/getDocuments?doc-ids=xt.10875359-nas-sked").
16
- to_return(:status => 200, :body => File.new("spec/fixtures/get_document_schedule.xml").read, :headers => {})
15
+ stub_request(:get, "https://#{ENV['SODA_USERNAME']}:#{ENV['SODA_PASSWORD']}@soda.xmlteam.com/api-trial/getDocuments?doc-ids=xt.10875359-nas-sked")
16
+ .to_return(status: 200, body: File.new('spec/fixtures/get_document_schedule.xml').read, headers: {})
17
17
 
18
- stub_request(:get, "https://#{ENV['SODA_USERNAME']}:#{ENV['SODA_PASSWORD']}@soda.xmlteam.com/api-trial/getDocuments?doc-ids=xt.3329967-NAS-2005-OUTLOOK").
19
- to_return(:status => 200, :body => File.new("spec/fixtures/get_document_news.xml").read, :headers => {})
18
+ stub_request(:get, "https://#{ENV['SODA_USERNAME']}:#{ENV['SODA_PASSWORD']}@soda.xmlteam.com/api-trial/getDocuments?doc-ids=xt.3329967-NAS-2005-OUTLOOK")
19
+ .to_return(status: 200, body: File.new('spec/fixtures/get_document_news.xml').read, headers: {})
20
20
 
21
- stub_request(:get, "https://#{ENV['SODA_USERNAME']}:#{ENV['SODA_PASSWORD']}@soda.xmlteam.com/api-trial/getDocuments?doc-ids=xt.10878197-standings").
22
- to_return(:status => 200, :body => File.new("spec/fixtures/get_document_standings.xml").read, :headers => {})
21
+ stub_request(:get, "https://#{ENV['SODA_USERNAME']}:#{ENV['SODA_PASSWORD']}@soda.xmlteam.com/api-trial/getDocuments?doc-ids=xt.10878197-standings")
22
+ .to_return(status: 200, body: File.new('spec/fixtures/get_document_standings.xml').read, headers: {})
23
23
 
24
24
  end
25
- end
25
+ end
data/tasks/rspec.rake CHANGED
@@ -1,3 +1,3 @@
1
1
  require 'rspec/core/rake_task'
2
2
 
3
- RSpec::Core::RakeTask.new(:spec)
3
+ RSpec::Core::RakeTask.new(:spec)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: soda_xml_team
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Yeargin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-26 00:00:00.000000000 Z
11
+ date: 2014-12-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -97,16 +97,20 @@ dependencies:
97
97
  description: A basic layer for interacting with XML Team's Sports On Demand API (SODA)
98
98
  email:
99
99
  - stephen@seatsha.re
100
- executables: []
100
+ executables:
101
+ - soda-league-directory
101
102
  extensions: []
102
103
  extra_rdoc_files: []
103
104
  files:
104
105
  - ".gitignore"
106
+ - ".rubocop.yml"
107
+ - ".rubocop_todo.yml"
105
108
  - ".travis.yml"
106
109
  - Gemfile
107
110
  - LICENSE.txt
108
111
  - README.md
109
112
  - Rakefile
113
+ - bin/soda-league-directory
110
114
  - lib/ca-certificates.crt
111
115
  - lib/soda_xml_team.rb
112
116
  - lib/soda_xml_team/address.rb