undertexter 0.1.1 → 0.1.2

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/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- undertexter (0.1.0)
4
+ undertexter (0.1.1)
5
5
  levenshteinish
6
6
  mimer_plus
7
7
  nokogiri
@@ -32,9 +32,5 @@ PLATFORMS
32
32
  ruby
33
33
 
34
34
  DEPENDENCIES
35
- levenshteinish
36
- mimer_plus
37
- nokogiri
38
- rest-client
39
35
  rspec
40
36
  undertexter!
@@ -2,12 +2,27 @@ require 'levenshteinish'
2
2
 
3
3
  class Array
4
4
  def based_on(string, args = {})
5
- self.any? ? self.map do|s|
5
+ result = self.any? ? self.map do|s|
6
6
  [Levenshtein.distance(s.title, string, args[:limit] || 0.4), s]
7
7
  end.reject do |value|
8
8
  value.first.nil?
9
9
  end.sort_by do |value|
10
10
  value.first
11
11
  end.map(&:last).first : nil
12
+
13
+ return if result.nil?
14
+
15
+ # If the string contains a release date, then the results should do it to
16
+ if result.title =~ /(s\d{2}e\d{2})/i
17
+ return unless string.match(/#{$1}/i)
18
+ end
19
+
20
+ # If the {string} contains a year, then the found movie should return one to
21
+ if result.title =~ /((19|20)\d{2})/
22
+ return unless string.match(/#{$1}/)
23
+ end
24
+
25
+ # Yes i know, return isn't needed
26
+ return result
12
27
  end
13
28
  end
data/spec/array_spec.rb CHANGED
@@ -40,4 +40,12 @@ describe Array do
40
40
  it "should be an array" do
41
41
  @subtitles.should be_an_instance_of(Array)
42
42
  end
43
+
44
+ it "should return nil due to the release date {S09E12}" do
45
+ Undertexter.find("tt0313043").based_on("CSI.Miami.S09E12.HDTV.XviD-LOL").should be_nil
46
+ end
47
+
48
+ it "should not return anything due to the wrong year" do
49
+ @subtitles.based_on("The Town EXTENDED 1999 480p BRRip XviD AC3 FLAWL3SS").should be_nil
50
+ end
43
51
  end
data/undertexter.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 = "undertexter"
6
- s.version = "0.1.1"
6
+ s.version = "0.1.2"
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.authors = ["Linus Oleander"]
9
9
  s.email = ["linus@oleander.nu"]
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 1
9
- version: 0.1.1
8
+ - 2
9
+ version: 0.1.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Linus Oleander
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-01-31 00:00:00 +01:00
17
+ date: 2011-02-01 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency