imdb 0.6.3 → 0.6.4

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.3
1
+ 0.6.4
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{imdb}
8
- s.version = "0.6.3"
8
+ s.version = "0.6.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Ariejan de Vroom"]
@@ -50,6 +50,7 @@ Gem::Specification.new do |s|
50
50
  "spec/fixtures/tt0330508",
51
51
  "spec/fixtures/tt1352369",
52
52
  "spec/imdb/cli_spec.rb",
53
+ "spec/imdb/imdb_spec.rb",
53
54
  "spec/imdb/movie_spec.rb",
54
55
  "spec/imdb/search_spec.rb",
55
56
  "spec/imdb/top_250_spec.rb",
@@ -65,6 +66,7 @@ Gem::Specification.new do |s|
65
66
  s.summary = %q{Easily access the publicly available information on IMDB.}
66
67
  s.test_files = [
67
68
  "spec/imdb/cli_spec.rb",
69
+ "spec/imdb/imdb_spec.rb",
68
70
  "spec/imdb/movie_spec.rb",
69
71
  "spec/imdb/search_spec.rb",
70
72
  "spec/imdb/top_250_spec.rb",
@@ -12,5 +12,5 @@ require 'imdb/top_250'
12
12
  require 'imdb/string_extensions'
13
13
 
14
14
  module Imdb
15
- VERSION = '0.6.3'
15
+ VERSION = File.open(File.join(File.dirname(__FILE__), '..', 'VERSION'), 'r') { |f| f.read.strip }
16
16
  end
@@ -33,6 +33,11 @@ module Imdb
33
33
  def genres
34
34
  document.search("h5[text()='Genre:'] ~ a[@href*=/Sections/Genres/']").map { |link| link.innerHTML.strip.imdb_unescape_html } rescue []
35
35
  end
36
+
37
+ # Returns an array of languages as strings.
38
+ def languages
39
+ document.search("h5[text()='Language:'] ~ a[@href*=/Sections/Languages/']").map { |link| link.innerHTML.strip.imdb_unescape_html } rescue []
40
+ end
36
41
 
37
42
  # Returns the duration of the movie in minutes as an integer.
38
43
  def length
@@ -59,6 +64,11 @@ module Imdb
59
64
  document.search("h5[text()='Tagline:'] ~ div").first.innerHTML.gsub(/<.+>.+<\/.+>/, '').strip.imdb_unescape_html rescue nil
60
65
  end
61
66
 
67
+ # Returns a string containing the mpaa rating and reason for rating
68
+ def mpaa_rating
69
+ document.search("h5[text()='MPAA:'] ~ div").first.innerHTML.strip.imdb_unescape_html rescue nil
70
+ end
71
+
62
72
  # Returns a string containing the title
63
73
  def title(force_refresh = false)
64
74
  if @title && !force_refresh
@@ -0,0 +1,10 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper.rb'
2
+
3
+ describe "Imdb" do
4
+
5
+ it "should report the right version" do
6
+ current_version = File.open(File.join(File.dirname(__FILE__), '..', '..', 'VERSION'), 'r') { |f| f.read.strip }
7
+ Imdb::VERSION.should eql(current_version)
8
+ end
9
+
10
+ end
@@ -38,7 +38,17 @@ describe "Imdb::Movie" do
38
38
  genres.should include('Drama')
39
39
  genres.should include('Thriller')
40
40
  end
41
-
41
+
42
+ it "should find the languages" do
43
+ languages = @movie.languages
44
+
45
+ languages.should be_an(Array)
46
+ languages.size.should eql(3)
47
+ languages.should include('English')
48
+ languages.should include('German')
49
+ languages.should include('Italian')
50
+ end
51
+
42
52
  it "should find the length (in minutes)" do
43
53
  @movie.length.should eql(131)
44
54
  end
@@ -105,6 +115,18 @@ describe "Imdb::Movie" do
105
115
  end
106
116
  end
107
117
 
118
+ describe "mpaa rating" do
119
+ it "should find the mpaa rating when present" do
120
+ movie = Imdb::Movie.new("0111161")
121
+ movie.mpaa_rating.should == "Rated R for language and prison violence."
122
+ end
123
+
124
+ it "should be nil when not present" do
125
+ movie = Imdb::Movie.new("0095016")
126
+ movie.mpaa_rating.should be_nil
127
+ end
128
+ end
129
+
108
130
  describe "with no submitted poster" do
109
131
 
110
132
  before(:each) do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.3
4
+ version: 0.6.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ariejan de Vroom
@@ -93,6 +93,7 @@ files:
93
93
  - spec/fixtures/tt0330508
94
94
  - spec/fixtures/tt1352369
95
95
  - spec/imdb/cli_spec.rb
96
+ - spec/imdb/imdb_spec.rb
96
97
  - spec/imdb/movie_spec.rb
97
98
  - spec/imdb/search_spec.rb
98
99
  - spec/imdb/top_250_spec.rb
@@ -130,6 +131,7 @@ specification_version: 3
130
131
  summary: Easily access the publicly available information on IMDB.
131
132
  test_files:
132
133
  - spec/imdb/cli_spec.rb
134
+ - spec/imdb/imdb_spec.rb
133
135
  - spec/imdb/movie_spec.rb
134
136
  - spec/imdb/search_spec.rb
135
137
  - spec/imdb/top_250_spec.rb