torrents 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -233,7 +233,8 @@ module Container
233
233
  # Read more about it here: https://github.com/oleander/Undertexter
234
234
  # Return type: A single Undertexter object or nil
235
235
  def subtitle(option = :english)
236
- @subtitle ||= Undertexter.find(self.imdb_id, language: option).based_on(self.title)
236
+ @subtitle = {} unless @subtitle
237
+ @subtitle[option] ||= Undertexter.find(self.imdb_id, language: option).based_on(self.title)
237
238
  end
238
239
 
239
240
  # Returns the torrent for the torrent
data/spec/torrent_spec.rb CHANGED
@@ -170,6 +170,17 @@ describe Container::Torrent do
170
170
 
171
171
  torrent.subtitle(:swedish).title.should eq("a subtitle")
172
172
  end
173
+
174
+ it "should be able to cache a subtitle" do
175
+ torrent = create_torrent
176
+ torrent.should_receive(:imdb_id).any_number_of_times.times.and_return("tt0990407")
177
+ torrent.should_receive(:title).any_number_of_times.and_return("a subtitle")
178
+ Undertexter.should_receive(:find).with("tt0990407", language: :swedish).exactly(1).times.and_return([Struct.new(:title).new("a subtitle")])
179
+ Undertexter.should_receive(:find).with("tt0990407", language: :english).exactly(1).times.and_return([Struct.new(:title).new("a subtitle")])
180
+
181
+ 10.times { torrent.subtitle(:swedish).title.should eq("a subtitle") }
182
+ 10.times { torrent.subtitle(:english).title.should eq("a subtitle") }
183
+ end
173
184
  end
174
185
 
175
186
 
data/torrents.gemspec CHANGED
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "torrents"
6
- s.version = "1.0.1"
6
+ s.version = "1.0.2"
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.authors = ["Linus Oleander"]
9
9
  s.email = ["linus@oleander.nu"]
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: torrents
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.0.1
5
+ version: 1.0.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Linus Oleander