traktr 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8d5f0dcce3cca0cf1333a85e496065c0ee81b366
4
- data.tar.gz: d7a7cad3e5617f2b4e1f020cfe4984f6493e0699
3
+ metadata.gz: d2be4dc41f9bdab35ee6efd4c32496d80d9c72ac
4
+ data.tar.gz: 4af66c432614436188985df65bc85475db044fe2
5
5
  SHA512:
6
- metadata.gz: 787108900829e1623626de13d16a7ed4f7979c4e88ab7e6638e4eeb33bcbe4e9027c7f007143c8f45d8d2f39a487c6b99ec99b42388141b9461a6e92effb1d7d
7
- data.tar.gz: 25f25e8cbf059fe19e85794b9f85f57a5ea0503923c6c2960c5cacfb41862ad4f8833d6b2b4e6f6f7b92851f42502bfa8d97e89631237f07d4ccae1b3a7722c5
6
+ metadata.gz: 370a936cb1b8cfc021fd173dd6eff26bca9d6b7fb5b3e8f66d6311fd02cb8c40ef9a4311892dc6b89ff30706b7ca6a47ae207f0719efb1f2cb6f00f64afae064
7
+ data.tar.gz: 740e0274f5783d6ada811e4acfc4241b0dfd0e8f76579afccde14caa5cbf244bde4bd8c72d0125c503d8cca316d64d992d02ce6f0622ac3b8e666cd5ed920b93
data/lib/traktr.rb CHANGED
@@ -13,6 +13,8 @@ require 'traktr/version'
13
13
 
14
14
  require 'traktr/account'
15
15
  require 'traktr/movie'
16
+ require 'traktr/movies'
16
17
  require 'traktr/search'
17
18
  require 'traktr/show'
19
+ require 'traktr/shows'
18
20
  require 'traktr/user'
@@ -0,0 +1,26 @@
1
+ module Traktr
2
+ module Movies
3
+ include HTTParty
4
+ base_uri File.join(Traktr.base_uri, 'movies')
5
+
6
+ ##
7
+ ## movies GET methods
8
+ ##
9
+ def self.trending
10
+ response = self.get('/' + File.join('trending.json', Traktr.api_key))
11
+ raise ResponseError.new(response) if response.code != 200
12
+
13
+ response.parsed_response.collect do |movie|
14
+ Mash.new(movie)
15
+ end
16
+ end
17
+
18
+ def self.updated(timestamp)
19
+ response = self.get('/' + File.join('updated.json', Traktr.api_key, timestamp.to_i.to_s))
20
+ raise ResponseError.new(response) if response.code != 200
21
+
22
+ Mash.new(response.parsed_response)
23
+ end
24
+
25
+ end
26
+ end
@@ -0,0 +1,26 @@
1
+ module Traktr
2
+ module Shows
3
+ include HTTParty
4
+ base_uri File.join(Traktr.base_uri, 'shows')
5
+
6
+ ##
7
+ ## movies GET methods
8
+ ##
9
+ def self.trending
10
+ response = self.get('/' + File.join('trending.json', Traktr.api_key))
11
+ raise ResponseError.new(response) if response.code != 200
12
+
13
+ response.parsed_response.collect do |show|
14
+ Mash.new(show)
15
+ end
16
+ end
17
+
18
+ def self.updated(timestamp)
19
+ response = self.get('/' + File.join('updated.json', Traktr.api_key, timestamp.to_i.to_s))
20
+ raise ResponseError.new(response) if response.code != 200
21
+
22
+ Mash.new(response.parsed_response)
23
+ end
24
+
25
+ end
26
+ end
@@ -1,3 +1,3 @@
1
1
  module Traktr
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+
3
+ describe Traktr::Movies do
4
+ context 'GET methods' do
5
+ context 'with valid api_key' do
6
+ before :all do
7
+ Traktr.api_key = API_KEY
8
+ end
9
+
10
+ after :all do
11
+ Traktr.api_key = ''
12
+ end
13
+
14
+ it '#trending' do
15
+ movies = Traktr::Movies.trending
16
+ expect(movies.size).to be > 0
17
+ end
18
+
19
+ it '#updated' do
20
+ movies = Traktr::Movies.updated(Time.now - 3600 * 24)
21
+ expect(movies.size).to be > 0
22
+ end
23
+ end
24
+
25
+ context 'without valid api_key' do
26
+ it '#trending' do
27
+ expect { Traktr::Movies.trending }.to raise_error(Traktr::ResponseError)
28
+ end
29
+
30
+ it '#updated' do
31
+ expect { Traktr::Movies.updated(Time.now - 3600 * 24) }.to raise_error(Traktr::ResponseError)
32
+ end
33
+ end
34
+ end
35
+ end
data/spec/search_spec.rb CHANGED
@@ -13,27 +13,27 @@ describe Traktr::Search do
13
13
 
14
14
  it '#episodes' do
15
15
  results = Traktr::Search.episodes('warfare')
16
- expect(results.size).to eql(30)
16
+ expect(results.size).to be > 0
17
17
  end
18
18
 
19
19
  it '#movies' do
20
20
  results = Traktr::Search.movies('Batman')
21
- expect(results.size).to eql(29)
21
+ expect(results.size).to be > 0
22
22
  end
23
23
 
24
24
  it '#people' do
25
25
  results = Traktr::Search.people('christian bale')
26
- expect(results.size).to eql(30)
26
+ expect(results.size).to be > 0
27
27
  end
28
28
 
29
29
  it '#shows' do
30
30
  results = Traktr::Search.shows('big bang theory')
31
- expect(results.size).to eql(29)
31
+ expect(results.size).to be > 0
32
32
  end
33
33
 
34
34
  it '#users' do
35
35
  results = Traktr::Search.users('justin')
36
- expect(results.size).to eql(22)
36
+ expect(results.size).to be > 0
37
37
  end
38
38
  end
39
39
 
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+
3
+ describe Traktr::Shows do
4
+ context 'GET methods' do
5
+ context 'with valid api_key' do
6
+ before :all do
7
+ Traktr.api_key = API_KEY
8
+ end
9
+
10
+ after :all do
11
+ Traktr.api_key = ''
12
+ end
13
+
14
+ it '#trending' do
15
+ shows = Traktr::Shows.trending
16
+ expect(shows.size).to be > 0
17
+ end
18
+
19
+ it '#updated' do
20
+ shows = Traktr::Shows.updated(Time.now - 3600 * 24)
21
+ expect(shows.size).to be > 0
22
+ end
23
+ end
24
+
25
+ context 'without valid api_key' do
26
+ it '#trending' do
27
+ expect { Traktr::Shows.trending }.to raise_error(Traktr::ResponseError)
28
+ end
29
+
30
+ it '#updated' do
31
+ expect { Traktr::Shows.updated(Time.now - 3600 * 24) }.to raise_error(Traktr::ResponseError)
32
+ end
33
+ end
34
+ end
35
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: traktr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe Lanford
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-13 00:00:00.000000000 Z
11
+ date: 2013-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -111,10 +111,12 @@ files:
111
111
  - lib/traktr/account.rb
112
112
  - lib/traktr/authentication.rb
113
113
  - lib/traktr/movie.rb
114
+ - lib/traktr/movies.rb
114
115
  - lib/traktr/search.rb
115
116
  - lib/traktr/show.rb
116
117
  - lib/traktr/show/episode.rb
117
118
  - lib/traktr/show/season.rb
119
+ - lib/traktr/shows.rb
118
120
  - lib/traktr/user.rb
119
121
  - lib/traktr/user/calendar.rb
120
122
  - lib/traktr/user/library.rb
@@ -127,10 +129,12 @@ files:
127
129
  - lib/traktr/version.rb
128
130
  - spec/account_spec.rb
129
131
  - spec/movie_spec.rb
132
+ - spec/movies_spec.rb
130
133
  - spec/search_spec.rb
131
134
  - spec/show_episode_spec.rb
132
135
  - spec/show_season_spec.rb
133
136
  - spec/show_spec.rb
137
+ - spec/shows_spec.rb
134
138
  - spec/spec_helper.rb
135
139
  - traktr.gemspec
136
140
  homepage: https://github.com/joelanford/traktr
@@ -160,8 +164,10 @@ summary: Implementation of the track.tv REST API
160
164
  test_files:
161
165
  - spec/account_spec.rb
162
166
  - spec/movie_spec.rb
167
+ - spec/movies_spec.rb
163
168
  - spec/search_spec.rb
164
169
  - spec/show_episode_spec.rb
165
170
  - spec/show_season_spec.rb
166
171
  - spec/show_spec.rb
172
+ - spec/shows_spec.rb
167
173
  - spec/spec_helper.rb