ruby-tmdb 0.0.20 → 0.0.21

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.20
1
+ 0.0.21
@@ -3,6 +3,7 @@ class Tmdb
3
3
  require 'net/http'
4
4
  require 'uri'
5
5
  require 'cgi'
6
+ require 'yaml'
6
7
 
7
8
  @@api_key = ""
8
9
  @@api_response = {}
@@ -20,6 +21,7 @@ class Tmdb
20
21
  end
21
22
 
22
23
  def self.api_call(method, data, language = "en")
24
+ raise ArgumentError, "Tmdb.api_key must be set before using the API" if(Tmdb.api_key.nil? || Tmdb.api_key.empty?)
23
25
  url = Tmdb.base_api_url + method + '/' + language + '/yaml/' + Tmdb.api_key + '/' + CGI::escape(data.to_s)
24
26
  response = @@api_response[url] ||= begin
25
27
  Tmdb.get_url(url)
data/ruby-tmdb.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ruby-tmdb}
8
- s.version = "0.0.20"
8
+ s.version = "0.0.21"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Aaron Gough"]
@@ -36,9 +36,11 @@ Gem::Specification.new do |s|
36
36
  "test/fixtures/person_get_info.txt",
37
37
  "test/fixtures/person_search.txt",
38
38
  "test/setup/.gitignore",
39
+ "test/setup/setup_api_key.rb",
39
40
  "test/setup/test_unit_extensions.rb",
40
41
  "test/setup/url_mocks.rb",
41
42
  "test/test_helper.rb",
43
+ "test/unit/test_direct_require.rb",
42
44
  "test/unit/tmdb_cast_test.rb",
43
45
  "test/unit/tmdb_movie_test.rb",
44
46
  "test/unit/tmdb_test.rb"
@@ -49,9 +51,11 @@ Gem::Specification.new do |s|
49
51
  s.rubygems_version = %q{1.3.7}
50
52
  s.summary = %q{An ActiveRecord-style API wrapper for TheMovieDB.org}
51
53
  s.test_files = [
52
- "test/setup/test_unit_extensions.rb",
54
+ "test/setup/setup_api_key.rb",
55
+ "test/setup/test_unit_extensions.rb",
53
56
  "test/setup/url_mocks.rb",
54
57
  "test/test_helper.rb",
58
+ "test/unit/test_direct_require.rb",
55
59
  "test/unit/tmdb_cast_test.rb",
56
60
  "test/unit/tmdb_movie_test.rb",
57
61
  "test/unit/tmdb_test.rb"
@@ -0,0 +1,3 @@
1
+ File.open(File.join(File.dirname(__FILE__), 'tmdb_api_key.txt')) do |file|
2
+ Tmdb.api_key = file.read
3
+ end
data/test/test_helper.rb CHANGED
@@ -2,8 +2,6 @@ TEST_LIVE_API = false
2
2
 
3
3
  require 'rubygems'
4
4
  require 'test/unit'
5
- require 'yaml'
6
- require 'net/http'
7
5
 
8
6
  unless(TEST_LIVE_API)
9
7
  require 'webmock/test_unit'
@@ -18,6 +16,5 @@ require_files.each do |file|
18
16
  require File.expand_path(file)
19
17
  end
20
18
 
21
- File.open(File.join(File.dirname(__FILE__), 'setup', 'tmdb_api_key.txt')) do |file|
22
- Tmdb.api_key = file.read
23
- end
19
+ #load(File.join('unit', 'test_direct_require.rb'), true)
20
+ system('ruby ' + File.expand_path(File.join(File.dirname(__FILE__), 'unit', 'test_direct_require.rb')))
@@ -0,0 +1,25 @@
1
+ require "test/unit"
2
+
3
+ require_files = []
4
+ require_files << File.join(File.dirname(__FILE__), "..", "..", "lib", "ruby-tmdb.rb")
5
+ require_files.concat Dir[File.join(File.dirname(__FILE__), '..', 'setup', '*.rb')]
6
+
7
+ require_files.each do |file|
8
+ require File.expand_path(file)
9
+ end
10
+
11
+ class DirectRequireTest < Test::Unit::TestCase
12
+
13
+ test "TmdbMovie should not raise exception when directly required without using rubygems" do
14
+ assert_nothing_raised do
15
+ TmdbMovie.find(:id => 187)
16
+ end
17
+ end
18
+
19
+ test "TmdbCast should not raise exception when directly required without using rubygems" do
20
+ assert_nothing_raised do
21
+ TmdbCast.find(:id => 287)
22
+ end
23
+ end
24
+
25
+ end
@@ -28,6 +28,15 @@ class TmdbTest < Test::Unit::TestCase
28
28
  assert_equal 404, test_response.code.to_i
29
29
  end
30
30
 
31
+ test "api_call should raise exception if api_key is not set" do
32
+ old_api_key = Tmdb.api_key
33
+ Tmdb.api_key = ""
34
+ assert_raises ArgumentError do
35
+ Tmdb.api_call('Movie.search', 'Transformers')
36
+ end
37
+ Tmdb.api_key = old_api_key
38
+ end
39
+
31
40
  test "should perform Movie.search API call and return array of results" do
32
41
  movies = Tmdb.api_call('Movie.search', 'Transformers')
33
42
  assert_kind_of Array, movies
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-tmdb
3
3
  version: !ruby/object:Gem::Version
4
- hash: 55
4
+ hash: 53
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 20
10
- version: 0.0.20
9
+ - 21
10
+ version: 0.0.21
11
11
  platform: ruby
12
12
  authors:
13
13
  - Aaron Gough
@@ -61,9 +61,11 @@ files:
61
61
  - test/fixtures/person_get_info.txt
62
62
  - test/fixtures/person_search.txt
63
63
  - test/setup/.gitignore
64
+ - test/setup/setup_api_key.rb
64
65
  - test/setup/test_unit_extensions.rb
65
66
  - test/setup/url_mocks.rb
66
67
  - test/test_helper.rb
68
+ - test/unit/test_direct_require.rb
67
69
  - test/unit/tmdb_cast_test.rb
68
70
  - test/unit/tmdb_movie_test.rb
69
71
  - test/unit/tmdb_test.rb
@@ -104,9 +106,11 @@ signing_key:
104
106
  specification_version: 3
105
107
  summary: An ActiveRecord-style API wrapper for TheMovieDB.org
106
108
  test_files:
109
+ - test/setup/setup_api_key.rb
107
110
  - test/setup/test_unit_extensions.rb
108
111
  - test/setup/url_mocks.rb
109
112
  - test/test_helper.rb
113
+ - test/unit/test_direct_require.rb
110
114
  - test/unit/tmdb_cast_test.rb
111
115
  - test/unit/tmdb_movie_test.rb
112
116
  - test/unit/tmdb_test.rb