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 +4 -4
- data/README.md +2 -2
- data/lib/soda_xml_team/client.rb +31 -0
- data/lib/soda_xml_team/version.rb +1 -1
- data/spec/soda_xml_team_spec.rb +14 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 623f032e340989c1f062b6de1d9fa2408b1b0d0f
|
4
|
+
data.tar.gz: 40a86ea991e8c70e90739655b496a15dd40aa4a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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
|
-
#
|
41
|
+
# An array of documents matching your query
|
42
42
|
puts listing.inspect
|
43
43
|
```
|
44
44
|
|
data/lib/soda_xml_team/client.rb
CHANGED
@@ -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
|
data/spec/soda_xml_team_spec.rb
CHANGED
@@ -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 '.
|
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.
|
19
|
+
let(:output) { subject.content_finder(input) }
|
20
20
|
|
21
21
|
it 'has seven items' do
|
22
|
-
expect(output.
|
22
|
+
expect(output.length).to eq 7
|
23
23
|
end
|
24
24
|
|
25
|
-
it 'has
|
26
|
-
expect(output
|
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.
|
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-
|
11
|
+
date: 2014-10-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|