maddox-newzcache 0.1.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/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Jon Maddox
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,33 @@
1
+ h1. Newzcache gem!
2
+
3
+ h2. What?
4
+
5
+ use this gem to talk to Newzcache
6
+
7
+ h2. Why?
8
+
9
+ If you don't know, then it doesn't concern you
10
+
11
+ h2. How?
12
+
13
+ Its just doing series right now, but its a work in progress.
14
+
15
+ <code>n = Newzcache::Search.new("username", "password")</code>
16
+
17
+ <code>series = n.find_series_by_title("the west wing")</code>
18
+ => array of series
19
+
20
+ <code>west_wing = series.first</code>
21
+ <code>west_wing.seasons</code>
22
+ => array of seasons
23
+
24
+ <code>season = west_wing.season(4)</code>
25
+ => season 4
26
+
27
+
28
+ <code>season.episodes</code>
29
+ => array of episodes
30
+
31
+ <code>season = season.episode(18)</code>
32
+ => episode 18
33
+
@@ -0,0 +1,56 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "newzcache"
8
+ gem.summary = %Q{TODO: one-line summary of your gem}
9
+ gem.description = %Q{TODO: longer description of your gem}
10
+ gem.email = "jon@jonsthoughtsoneverything.com"
11
+ gem.homepage = "http://github.com/maddox/newzcache"
12
+ gem.authors = ["Jon Maddox"]
13
+ gem.add_development_dependency "thoughtbot-shoulda"
14
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
15
+ end
16
+ rescue LoadError
17
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
18
+ end
19
+
20
+ require 'rake/testtask'
21
+ Rake::TestTask.new(:test) do |test|
22
+ test.libs << 'lib' << 'test'
23
+ test.pattern = 'test/**/*_test.rb'
24
+ test.verbose = true
25
+ end
26
+
27
+ begin
28
+ require 'rcov/rcovtask'
29
+ Rcov::RcovTask.new do |test|
30
+ test.libs << 'test'
31
+ test.pattern = 'test/**/*_test.rb'
32
+ test.verbose = true
33
+ end
34
+ rescue LoadError
35
+ task :rcov do
36
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
37
+ end
38
+ end
39
+
40
+ task :test => :check_dependencies
41
+
42
+ task :default => :test
43
+
44
+ require 'rake/rdoctask'
45
+ Rake::RDocTask.new do |rdoc|
46
+ if File.exist?('VERSION')
47
+ version = File.read('VERSION')
48
+ else
49
+ version = ""
50
+ end
51
+
52
+ rdoc.rdoc_dir = 'rdoc'
53
+ rdoc.title = "newzcache #{version}"
54
+ rdoc.rdoc_files.include('README*')
55
+ rdoc.rdoc_files.include('lib/**/*.rb')
56
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,21 @@
1
+ module Newzcache
2
+ class Episode
3
+ attr_reader :client
4
+ attr_accessor :number, :id, :season, :title, :description, :date_aired
5
+
6
+ def initialize(client, season, options={})
7
+ @client = client
8
+ @season = season
9
+ @number = options["number"]
10
+ @title = options["title"]
11
+ @description = options["description"]
12
+ @date_aired = options["date_aired"]
13
+ @id = options["id"]
14
+ end
15
+
16
+ def episodes
17
+ @episodes ||= client.get_episodes(self)
18
+ end
19
+ end
20
+ end
21
+
@@ -0,0 +1,11 @@
1
+ module Newzcache
2
+ class Genre
3
+ attr_accessor :name, :id
4
+
5
+ def initialize(options={})
6
+ @name = options["name"]
7
+ @id = options["id"]
8
+ end
9
+ end
10
+ end
11
+
File without changes
@@ -0,0 +1,29 @@
1
+ module Newzcache
2
+ class Search
3
+ include HTTParty
4
+ base_uri 'newzcache.com'
5
+
6
+ def initialize(u, p)
7
+ @auth = {:username => u, :password => p}
8
+ end
9
+
10
+ def find_series_by_title(title, options={})
11
+ puts "finding series"
12
+ options.merge!({:basic_auth => @auth, :query => {:q => title}})
13
+ results = self.class.get("/series.json", options)
14
+ results.map{|result| Series.new(self, result["series"])}
15
+ end
16
+
17
+ def get_seasons(series)
18
+ puts "getting seasons"
19
+ results = self.class.get("/series/#{series.id}/seasons.json", {:basic_auth => @auth})
20
+ results.map{|result| Season.new(self, series, result["season"])}
21
+ end
22
+
23
+ def get_episodes(season)
24
+ puts "getting episodes"
25
+ results = self.class.get("/series/#{season.series.id}/seasons/#{season.id}/episodes.json", {:basic_auth => @auth})
26
+ results.map{|result| Episode.new(self, season, result["episode"])}
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,25 @@
1
+ module Newzcache
2
+ class Season
3
+ attr_reader :client
4
+ attr_accessor :poster_url, :number, :id, :poster_thumb_url, :episodes, :series
5
+
6
+ def initialize(client, series, options={})
7
+ @client = client
8
+ @series = series
9
+ @poster_url = options["poster_url"]
10
+ @poster_thumb_url = options["poster_thumb_url"]
11
+ @number = options["number"]
12
+ @id = options["id"]
13
+ end
14
+
15
+ def episodes
16
+ @episodes ||= client.get_episodes(self)
17
+ end
18
+
19
+ def episode(episode_number)
20
+ episodes.detect{|e| e.number == episode_number}
21
+ end
22
+
23
+ end
24
+ end
25
+
@@ -0,0 +1,33 @@
1
+ module Newzcache
2
+ class Series
3
+ attr_reader :client
4
+ attr_accessor :poster_url, :rating, :title, :first_aired, :id, :network, :recommended,
5
+ :poster_thumb_url, :banner_url, :description, :genres, :seasons, :runtime
6
+
7
+ def initialize(client, options={})
8
+ @client = client
9
+ @poster_url = options["poster_url"]
10
+ @runtime = options["runtime"]
11
+ @rating = options["rating"]
12
+ @title = options["title"]
13
+ @first_aired = options["first_aired"]
14
+ @id = options["id"]
15
+ @network = options["network"]
16
+ @recommended = options["recommended"]
17
+ @poster_thumb_url = options["poster_thumb_url"]
18
+ @banner_url = options["banner_url"]
19
+ @description = options["description"]
20
+ @genres = options["genres"].map{|result| Genre.new(result["genre"])}
21
+ end
22
+
23
+ def seasons
24
+ @seasons ||= client.get_seasons(self)
25
+ end
26
+
27
+ def season(season_number)
28
+ seasons.detect{|s| s.number == season_number}
29
+ end
30
+
31
+ end
32
+ end
33
+
@@ -0,0 +1,58 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{newzcache}
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Jon Maddox"]
12
+ s.date = %q{2009-08-28}
13
+ s.description = %q{TODO: longer description of your gem}
14
+ s.email = %q{jon@jonsthoughtsoneverything.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.textile"
18
+ ]
19
+ s.files = [
20
+ "LICENSE",
21
+ "README.textile",
22
+ "Rakefile",
23
+ "VERSION",
24
+ "lib/episode.rb",
25
+ "lib/genre.rb",
26
+ "lib/movie.rb",
27
+ "lib/search.rb",
28
+ "lib/season.rb",
29
+ "lib/series.rb",
30
+ "newzcache.gemspec",
31
+ "newzcache.rb",
32
+ "test/newzcache_test.rb",
33
+ "test/test_helper.rb"
34
+ ]
35
+ s.has_rdoc = true
36
+ s.homepage = %q{http://github.com/maddox/newzcache}
37
+ s.rdoc_options = ["--charset=UTF-8"]
38
+ s.require_paths = ["lib"]
39
+ s.rubygems_version = %q{1.3.1}
40
+ s.summary = %q{TODO: one-line summary of your gem}
41
+ s.test_files = [
42
+ "test/newzcache_test.rb",
43
+ "test/test_helper.rb"
44
+ ]
45
+
46
+ if s.respond_to? :specification_version then
47
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
48
+ s.specification_version = 2
49
+
50
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
51
+ s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
52
+ else
53
+ s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
54
+ end
55
+ else
56
+ s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
57
+ end
58
+ end
@@ -0,0 +1,13 @@
1
+ require 'rubygems'
2
+ require 'httparty'
3
+
4
+ directory = File.expand_path(File.dirname(__FILE__))
5
+ require File.join(directory, 'lib', 'search')
6
+ require File.join(directory, 'lib', 'series')
7
+ require File.join(directory, 'lib', 'season')
8
+ require File.join(directory, 'lib', 'episode')
9
+ require File.join(directory, 'lib', 'movie')
10
+ require File.join(directory, 'lib', 'genre')
11
+
12
+
13
+
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
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"
6
+ end
7
+ end
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
7
+ require 'newzcache'
8
+
9
+ class Test::Unit::TestCase
10
+ end
metadata ADDED
@@ -0,0 +1,77 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: maddox-newzcache
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jon Maddox
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-08-28 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: thoughtbot-shoulda
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ description: "TODO: longer description of your gem"
26
+ email: jon@jonsthoughtsoneverything.com
27
+ executables: []
28
+
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - LICENSE
33
+ - README.textile
34
+ files:
35
+ - LICENSE
36
+ - README.textile
37
+ - Rakefile
38
+ - VERSION
39
+ - lib/episode.rb
40
+ - lib/genre.rb
41
+ - lib/movie.rb
42
+ - lib/search.rb
43
+ - lib/season.rb
44
+ - lib/series.rb
45
+ - newzcache.gemspec
46
+ - newzcache.rb
47
+ - test/newzcache_test.rb
48
+ - test/test_helper.rb
49
+ has_rdoc: true
50
+ homepage: http://github.com/maddox/newzcache
51
+ post_install_message:
52
+ rdoc_options:
53
+ - --charset=UTF-8
54
+ require_paths:
55
+ - lib
56
+ required_ruby_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: "0"
61
+ version:
62
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: "0"
67
+ version:
68
+ requirements: []
69
+
70
+ rubyforge_project:
71
+ rubygems_version: 1.2.0
72
+ signing_key:
73
+ specification_version: 2
74
+ summary: "TODO: one-line summary of your gem"
75
+ test_files:
76
+ - test/newzcache_test.rb
77
+ - test/test_helper.rb