soda_xml_team 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: a9f8fa36c2e6d37773826f697b638102b945c82b
4
- data.tar.gz: d2d478f2cb708dd7cd3f6e55f07dea0ea5820913
3
+ metadata.gz: 623f032e340989c1f062b6de1d9fa2408b1b0d0f
4
+ data.tar.gz: 40a86ea991e8c70e90739655b496a15dd40aa4a3
5
5
  SHA512:
6
- metadata.gz: ec866bb434c4cd918cfe52a49f7c712aea75f58c64a26030e450eafa8610666c7e8f121b16de62a7f2d0a7120792566142ef5d8f1ac4d9e35f18b647a88285be
7
- data.tar.gz: 7bba0c1a7bf79ddbd031fc0c30c3e7b354c2861e7133710178e25ece607c2b9828cc4bcca1f53e7121d1ec4e512582bedd50caa9d35eca657759bce72571a1d0
6
+ metadata.gz: f9ad840368ce8179ae12c5a9a60c12f92a4399323a57b4c31df98ebd847c9423fa6c7d21e8f3441a33c46494469ab60a29e5e3177e1d84c3222d5e71ade2d189
7
+ data.tar.gz: cdcf080fcf5946f18c7f22b3962b45cda11deaa25136d43ba462fd2be0bd9eec0e54cbb5aca327e7b6423b18b479fc98ad6f33f338e8f7cbbcda33d9316d81a6
data/README.md CHANGED
@@ -28,7 +28,7 @@ The SODA service works by keeping revisions of various documents (schedules, new
28
28
 
29
29
  ```ruby
30
30
  soda = SodaXmlTeam::Client.new('your_username', 'your_password')
31
- listing = soda.get_listing({
31
+ listing = soda.content_finder({
32
32
  # Set sandbox to true if you are browsing the trial dataset
33
33
  sandbox: false,
34
34
  league_id: 'l.nhl.com',
@@ -38,7 +38,7 @@ listing = soda.get_listing({
38
38
  end_datetime: DateTime.parse('2011-01-01 00:00:00 CDT')
39
39
  })
40
40
 
41
- # A Nokogiri XML representation of the document list
41
+ # An array of documents matching your query
42
42
  puts listing.inspect
43
43
  ```
44
44
 
@@ -10,7 +10,38 @@ module SodaXmlTeam
10
10
  @dir = File.dirname __FILE__
11
11
  end
12
12
 
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
+ feed = Nokogiri::XML(response.body)
16
+
17
+ documents = []
18
+ feed.css('item').each do |item|
19
+ record = {}
20
+
21
+ # Parse for document ID
22
+ link = item.css('link').inner_text
23
+ document_id = link.gsub /(.*)?doc-ids=/i, ''
24
+
25
+ record[:title] = item.css('title').inner_text
26
+ record[:link] = link
27
+ record[:document_id] = document_id
28
+ record[:date] = DateTime.parse(item.xpath('./dc:date').inner_text)
29
+ 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']
32
+ end
33
+ end
34
+
35
+ documents << record
36
+ end
37
+
38
+ return documents
39
+
40
+ end
41
+
42
+ # Deprecated: Please use `content_finder` instead
13
43
  def get_listing(options={})
44
+ warn "[DEPRECATION] `get_listing` is deprecated. Please use `content_finder` instead."
14
45
  response = HTTParty.get(SodaXmlTeam::Address.build("get_listing", options), :basic_auth => @auth, :ssl_ca_file => "#{@dir}/../ca-certificates.crt", :ssl_version => :SSLv3)
15
46
  Nokogiri::XML(response.body)
16
47
  end
@@ -1,3 +1,3 @@
1
1
  module SodaXmlTeam
2
- VERSION = "1.2.0"
2
+ VERSION = "1.3.0"
3
3
  end
@@ -4,7 +4,7 @@ describe "SodaXmlTeam" do
4
4
 
5
5
  subject { SodaXmlTeam::Client.new(ENV['SODA_USERNAME'], ENV['SODA_PASSWORD']) }
6
6
 
7
- describe '.get_listing' do
7
+ describe '.content_finder' do
8
8
 
9
9
  let(:input) {
10
10
  {
@@ -16,14 +16,23 @@ describe "SodaXmlTeam" do
16
16
  end_datetime: DateTime.parse('2011-01-01 00:00:00 CDT')
17
17
  }
18
18
  }
19
- let(:output) { subject.get_listing(input) }
19
+ let(:output) { subject.content_finder(input) }
20
20
 
21
21
  it 'has seven items' do
22
- expect(output.css('item').length).to eq 7
22
+ expect(output.length).to eq 7
23
23
  end
24
24
 
25
- it 'has a title that matches' do
26
- expect(output.css('item title').first.content).to eq "2010 Nashville Predators Schedule"
25
+ 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"
27
36
  end
28
37
 
29
38
  end
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.2.0
4
+ version: 1.3.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-02 00:00:00.000000000 Z
11
+ date: 2014-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler