maddox-newzcache 0.2.1 → 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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.3.0
@@ -7,6 +7,7 @@ require File.join(directory, 'newzcache', 'season')
7
7
  require File.join(directory, 'newzcache', 'episode')
8
8
  require File.join(directory, 'newzcache', 'movie')
9
9
  require File.join(directory, 'newzcache', 'genre')
10
+ require File.join(directory, 'newzcache', 'nzb')
10
11
 
11
12
 
12
13
 
@@ -16,6 +16,11 @@ module Newzcache
16
16
  def episodes
17
17
  @episodes ||= client.get_episodes(self)
18
18
  end
19
+
20
+ def nzbs
21
+ @nzbs ||= client.get_nzbs_from_episode(self)
22
+ end
23
+
19
24
  end
20
25
  end
21
26
 
@@ -0,0 +1,34 @@
1
+ module Newzcache
2
+ class Movie
3
+ attr_reader :client
4
+ attr_accessor :id, :title, :description, :tagline, :mpaa_rating, :imbd_rating, :runtime, :imdb_id, :release_date,
5
+ :poster_url, :poster_thumb_url, :trailer_url, :hot, :recommended, :actors, :writers, :directors, :genres, :nzbs
6
+
7
+ def initialize(client, options={})
8
+ @client = client
9
+ @id = options["id"]
10
+ @title = options["title"]
11
+ @description = options["description"]
12
+ @tagline = options["tagline"]
13
+ @mpaa_rating = options["mpaa_rating"]
14
+ @imdb_rating = options["imdb_rating"]
15
+ @runtime = options["runtime"]
16
+ @imdb_id = options["imdb_id"]
17
+ @release_date = options["release_date"]
18
+ @poster_url = options["poster_url"]
19
+ @poster_thumb_url = options["poster_thumb_url"]
20
+ @trailer_url = options["trailer_url"]
21
+ @hot = options["hot"]
22
+ @recommended = options["recommended"]
23
+ @actors = options["actors"]
24
+ @writers = options["writers"]
25
+ @directors = options["directors"]
26
+ @genres = options["genres"].map{|result| Genre.new(result["genre"])}
27
+ end
28
+
29
+ def nzbs
30
+ @nzbs ||= client.get_nzbs_from_movie(self)
31
+ end
32
+
33
+ end
34
+ end
@@ -0,0 +1,22 @@
1
+ module Newzcache
2
+ class Nzb
3
+ attr_reader :client
4
+ attr_accessor :id, :title, :content_type, :group_id, :newzbin_id, :pub_date, :size_in_bytes, :is_hd, :meta_attributes, :info_url, :content
5
+
6
+ def initialize(client, content, options={})
7
+ @client = client
8
+ @content = content
9
+ @id = options["id"]
10
+ @title = options["title"]
11
+ @content_type = options["content_type"]
12
+ @group_id = options["group_id"]
13
+ @newzbin_id = options["newzbin_id"]
14
+ @pub_date = options["pub_date"]
15
+ @size_in_bytes = options["size_in_bytes"]
16
+ @is_hd = options["is_hd"]
17
+ @meta_attributes = options["meta_attributes"]
18
+ @info_url = options["info_url"]
19
+ end
20
+
21
+ end
22
+ end
@@ -7,23 +7,38 @@ module Newzcache
7
7
  @auth = {:username => u, :password => p}
8
8
  end
9
9
 
10
+ def find_movie_by_title(title, options={})
11
+ options.merge!({:basic_auth => @auth, :query => {:q => title}})
12
+ results = self.class.get("/movies.json", options)
13
+ results.map{|result| Movie.new(self, result["movie"])}
14
+ end
15
+
10
16
  def find_series_by_title(title, options={})
11
- puts "finding series"
12
17
  options.merge!({:basic_auth => @auth, :query => {:q => title}})
13
18
  results = self.class.get("/series.json", options)
14
19
  results.map{|result| Series.new(self, result["series"])}
15
20
  end
16
21
 
17
22
  def get_seasons(series)
18
- puts "getting seasons"
19
23
  results = self.class.get("/series/#{series.id}/seasons.json", {:basic_auth => @auth})
20
24
  results.map{|result| Season.new(self, series, result["season"])}
21
25
  end
22
26
 
23
27
  def get_episodes(season)
24
- puts "getting episodes"
25
28
  results = self.class.get("/series/#{season.series.id}/seasons/#{season.id}/episodes.json", {:basic_auth => @auth})
26
29
  results.map{|result| Episode.new(self, season, result["episode"])}
27
30
  end
31
+
32
+ def get_nzbs_from_movie(movie)
33
+ results = self.class.get("/movies/#{movie.id}/nzbs.json", {:basic_auth => @auth})
34
+ # results = self.class.get("/series/#{episode.season.series.id}/seasons/#{episode.season.id}/episodes/#{episode.id}/nzbs.json", {:basic_auth => @auth})
35
+ results.map{|result| Nzb.new(self, movie, result["nzb"])}
36
+ end
37
+
38
+ def get_nzbs_from_episode(episode)
39
+ results = self.class.get("/series/#{episode.season.series.id}/seasons/#{episode.season.id}/episodes/#{episode.id}/nzbs.json", {:basic_auth => @auth})
40
+ results.map{|result| Nzb.new(self, episode, result["nzb"])}
41
+ end
42
+
28
43
  end
29
44
  end
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{newzcache}
8
- s.version = "0.2.1"
8
+ s.version = "0.3.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jon Maddox"]
@@ -25,11 +25,14 @@ Gem::Specification.new do |s|
25
25
  "lib/newzcache/episode.rb",
26
26
  "lib/newzcache/genre.rb",
27
27
  "lib/newzcache/movie.rb",
28
+ "lib/newzcache/nzb.rb",
28
29
  "lib/newzcache/search.rb",
29
30
  "lib/newzcache/season.rb",
30
31
  "lib/newzcache/series.rb",
31
32
  "newzcache.gemspec",
32
33
  "pkg/newzcache-0.1.1.gem",
34
+ "test/episode_test.rb",
35
+ "test/movie_test.rb",
33
36
  "test/newzcache_test.rb",
34
37
  "test/test_helper.rb"
35
38
  ]
@@ -40,7 +43,9 @@ Gem::Specification.new do |s|
40
43
  s.rubygems_version = %q{1.3.1}
41
44
  s.summary = %q{The Newzcache gem lets you talk to Newzcache}
42
45
  s.test_files = [
43
- "test/newzcache_test.rb",
46
+ "test/episode_test.rb",
47
+ "test/movie_test.rb",
48
+ "test/newzcache_test.rb",
44
49
  "test/test_helper.rb"
45
50
  ]
46
51
 
@@ -0,0 +1,24 @@
1
+ require 'test_helper'
2
+
3
+ class EpisodeTest < Test::Unit::TestCase
4
+ context "A movie" do
5
+ setup do
6
+ newzcache = Newzcache::Search.new("test", "test")
7
+ @episode = newzcache.find_series_by_title("west wing").first.season(1).episode(2)
8
+ end
9
+
10
+ context "when getting nzbs" do
11
+ setup do
12
+ @nzbs = @episode.nzbs
13
+ end
14
+
15
+ should "return a list" do
16
+ assert_equal Array, @nzbs.class
17
+ end
18
+
19
+ should "return nzbs" do
20
+ assert_equal Newzcache::Nzb, @nzbs.first.class
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,31 @@
1
+ require 'test_helper'
2
+
3
+ class MovieTest < Test::Unit::TestCase
4
+ context "A movie" do
5
+ setup do
6
+ newzcache = Newzcache::Search.new("test", "test")
7
+ @movie = newzcache.find_movie_by_title("Top Gun").first
8
+ end
9
+
10
+ should "have a title" do
11
+ assert_equal "Top Gun", @movie.title
12
+ end
13
+
14
+ context "when getting nzbs" do
15
+ setup do
16
+ @nzbs = @movie.nzbs
17
+ end
18
+
19
+ should "return a list" do
20
+ assert_equal Array, @nzbs.class
21
+ end
22
+
23
+ should "return nzbs" do
24
+ assert_equal Newzcache::Nzb, @nzbs.first.class
25
+ end
26
+
27
+ end
28
+
29
+
30
+ end
31
+ end
@@ -1,7 +1,37 @@
1
1
  require 'test_helper'
2
2
 
3
3
  class NewzcacheTest < Test::Unit::TestCase
4
- should "probably rename this file and start testing for real" do
5
- flunk "hey buddy, you should probably rename this file and start testing for real"
4
+ context "The newzcache client" do
5
+ setup do
6
+ @newzcache = Newzcache::Search.new("test", "test")
7
+ end
8
+
9
+ context "when searching movies" do
10
+ setup do
11
+ @movies = @newzcache.find_movie_by_title("Top Gun")
12
+ end
13
+
14
+ should "return a list" do
15
+ assert_equal Array, @movies.class
16
+ end
17
+
18
+ should "return a list of movies" do
19
+ assert_equal Newzcache::Movie, @movies.first.class
20
+ end
21
+ end
22
+
23
+ context "when searching series" do
24
+ setup do
25
+ @series = @newzcache.find_series_by_title("The West Wing")
26
+ end
27
+
28
+ should "return a list" do
29
+ assert_equal Array, @series.class
30
+ end
31
+
32
+ should "return a list of series" do
33
+ assert_equal Newzcache::Series, @series.first.class
34
+ end
35
+ end
6
36
  end
7
37
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maddox-newzcache
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Maddox
@@ -50,16 +50,18 @@ files:
50
50
  - lib/newzcache/episode.rb
51
51
  - lib/newzcache/genre.rb
52
52
  - lib/newzcache/movie.rb
53
+ - lib/newzcache/nzb.rb
53
54
  - lib/newzcache/search.rb
54
55
  - lib/newzcache/season.rb
55
56
  - lib/newzcache/series.rb
56
57
  - newzcache.gemspec
57
58
  - pkg/newzcache-0.1.1.gem
59
+ - test/episode_test.rb
60
+ - test/movie_test.rb
58
61
  - test/newzcache_test.rb
59
62
  - test/test_helper.rb
60
63
  has_rdoc: true
61
64
  homepage: http://github.com/maddox/newzcache
62
- licenses:
63
65
  post_install_message:
64
66
  rdoc_options:
65
67
  - --charset=UTF-8
@@ -80,10 +82,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
80
82
  requirements: []
81
83
 
82
84
  rubyforge_project:
83
- rubygems_version: 1.3.5
85
+ rubygems_version: 1.2.0
84
86
  signing_key:
85
87
  specification_version: 2
86
88
  summary: The Newzcache gem lets you talk to Newzcache
87
89
  test_files:
90
+ - test/episode_test.rb
91
+ - test/movie_test.rb
88
92
  - test/newzcache_test.rb
89
93
  - test/test_helper.rb