Skip to content
This repository has been archived by the owner on Sep 27, 2019. It is now read-only.

Commit

Permalink
Merge pull request #8 from seatshare/feature/7-allow-string-dates
Browse files Browse the repository at this point in the history
Allow start/end dates to be passed in as strings
  • Loading branch information
stephenyeargin committed Oct 26, 2014
2 parents 5efa3d1 + 5a64eda commit dde34ff
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 9 deletions.
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,15 @@ gem 'soda_xml_team'

And then execute:

$ bundle
```bash
$ bundle
```

Or install it yourself as:

$ gem install soda_xml_team
```bash
$ gem install soda_xml_team
```

## Usage

Expand All @@ -34,8 +38,8 @@ listing = soda.content_finder({
league_id: 'l.nhl.com',
team_id: 'l.nhl.com-t.19',
type: 'schedule-single-team',
start_datetime: DateTime.parse('2010-01-01 00:00:00 CDT'),
end_datetime: DateTime.parse('2011-01-01 00:00:00 CDT')
start_datetime: '2010-01-01 00:00:00 CDT',
end_datetime: '2011-01-01 00:00:00 CDT'
})

# An array of documents matching your query
Expand Down Expand Up @@ -104,7 +108,6 @@ standings = SodaXmlTeam::Standings.parse_standings(standings_document)
puts standings.inspect
```


## Contributing

1. Fork it ( https://github.com/seatshare/soda_xml_team/fork )
Expand Down
10 changes: 8 additions & 2 deletions lib/soda_xml_team/address.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,18 @@ def self.build(method, options = {})
end

# Start date/time
if options[:start_datetime].is_a? DateTime
if options[:start_datetime].is_a? String
options[:start_datetime] = DateTime.parse(options[:start_datetime])
path << "earliest-date-time=#{options[:start_datetime].strftime('%Y%m%dT%H%M%S%z')}"
elsif options[:start_datetime].is_a? DateTime
path << "earliest-date-time=#{options[:start_datetime].strftime('%Y%m%dT%H%M%S%z')}"
end

# End date/time
if options[:end_datetime].is_a? DateTime
if options[:end_datetime].is_a? String
options[:end_datetime] = DateTime.parse(options[:end_datetime])
path << "latest-date-time=#{options[:end_datetime].strftime('%Y%m%dT%H%M%S%z')}"
elsif options[:end_datetime].is_a? DateTime
path << "latest-date-time=#{options[:end_datetime].strftime('%Y%m%dT%H%M%S%z')}"
end

Expand Down
2 changes: 1 addition & 1 deletion lib/soda_xml_team/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module SodaXmlTeam
VERSION = "1.3.0"
VERSION = "1.3.1"
end
2 changes: 1 addition & 1 deletion soda_xml_team.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
spec.authors = ["Stephen Yeargin"]
spec.email = ["[email protected]"]
spec.summary = %q{XML Team Sports On Demand API}
spec.description = %q{A basic layer for interacting XML Team's Sports On Demand API (SODA)}
spec.description = %q{A basic layer for interacting with XML Team's Sports On Demand API (SODA)}
spec.homepage = "https://github.com/seatshare/soda_xml_team"
spec.license = "MIT"

Expand Down
29 changes: 29 additions & 0 deletions spec/soda_xml_team_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,35 @@
expect(output[0][:team]).to eq "l.nhl.com-t.19"
end

let(:input) {
{
sandbox: true,
league_id: 'l.nhl.com',
team_id: 'l.nhl.com-t.19',
type: 'schedule-single-team',
start_datetime: '2010-01-01 00:00:00 CDT',
end_datetime: '2011-01-01 00:00:00 CDT'
}
}
let(:output) { subject.content_finder(input) }

it 'has seven items with string timestamp' do
expect(output.length).to eq 7
end

it 'has attributes that match with string timestamp' do
expect(output[1][:title]).to eq "2010 Nashville Predators Schedule"
expect(output[1][:link]).to eq "http://soda.xmlteam.com/api-trial/getDocuments?doc-ids=xt.10860136-nas-sked"
expect(output[1][:document_id]).to eq "xt.10860136-nas-sked"
expect(output[1][:date]).to eq DateTime.parse('February 12, 2010 22:49 PM CDT')
expect(output[1][:publisher]).to eq "sportsnetwork.com"
expect(output[1][:priority]).to eq "normal"
expect(output[1][:sport]).to eq "15031000"
expect(output[1][:league]).to eq "l.nhl.com"
expect(output[1][:conference]).to eq "c.western"
expect(output[1][:team]).to eq "l.nhl.com-t.19"
end

end

describe '.get_document' do
Expand Down

0 comments on commit dde34ff

Please sign in to comment.