Skip to content

Commit

Permalink
It should respect ''
Browse files Browse the repository at this point in the history
  • Loading branch information
oleander committed Jun 26, 2012
1 parent e0323db commit d0917b3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/spot/clean.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ def process
/\.[a-z0-9]{2,3}$/,
/\[[^\]]*\]/,
/".*"/,
/'.*'[^s]/,
/(\s+|^)'.*'(\s+|$)/,
/[&|\/|\+][^\z]*/,
/^(\d+.*?[^a-z]+?)/i
].each do |reg|
string = string.gsub(reg, '').strip
string = string.gsub(reg, ' ').strip
end

[
Expand Down
8 changes: 8 additions & 0 deletions spec/clean_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
Spot::Clean.new("Song A \"abc def\"").process.should eq("song a")
end

it "Sweet Child O' Mine by Guns N' Roses => sweet child o' mine by guns n' roses" do
Spot::Clean.new("Sweet Child O' Mine by Guns N' Roses").process.should eq("sweet child o' mine by guns n' roses")
end

it "Song - A [B + C] => Song - A" do
Spot::Clean.new("Song - A [B + C]").process.should eq("song a")
end
Expand Down Expand Up @@ -103,6 +107,10 @@
Spot::Clean.new("Knockin' On Heaven's Door").process.should eq("knockin' on heaven's door")
end

it "I Love Rock'n'roll => i love rock'n'roll" do
Spot::Clean.new("I Love Rock'n'roll").process.should eq("i love rock'n'roll")
end

it "Jason Derulo - Undefeated" do
Spot::Clean.new("Undefeated").process.should eq("undefeated")
end
Expand Down

0 comments on commit d0917b3

Please sign in to comment.