lyrics_finder 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 87caaf1a92687f124d09bfd2cfe69420841c1468
4
- data.tar.gz: f938b5851c7dca280eeb144ccd34da99f50a9c43
3
+ metadata.gz: 7687aa59df44d91c4cd3f53290eae5a53125f25a
4
+ data.tar.gz: 08de33c09c38c33264cfdc5e4ba592843f2e3d31
5
5
  SHA512:
6
- metadata.gz: 7f7d8db6f81bb41b3dec0d573c31640cc1a528da8d3270bd732e6b60b4ccd198ef0ee36efb41b7cc20d2514cc85890af0e39d2e55c1624751d704fc08b2f9165
7
- data.tar.gz: 586ce2f585563bd46c861ba324a4db732cc3afa75620827f74b792ca5ea2af54942865cfeca75f631760a1917bf42b4ceacc202e9ac1a0ee93cb92d13ac83742
6
+ metadata.gz: 046b9bbc64a9c059b6f92c584d18ff340afb1dad91c8342815d614d6face705fab414da93c0c4b9c20b18761fee1851d15e7ffc758c58f34a119bf45f5470901
7
+ data.tar.gz: 4121f9282103d2889b7e8e378347a797edc801efe651c579673f7e2544640a14cbb49b8130629e0314a7628338235313250b0ed71de125c00c61d3f0590479fb
data/lib/lyrics_finder.rb CHANGED
@@ -5,27 +5,28 @@ require 'i18n'
5
5
  I18n.enforce_available_locales = false
6
6
  require_relative 'lyrics_finder/version'
7
7
  require_relative 'lyrics_finder/song'
8
- require_relative 'lyrics_finder/providers'
8
+ require_relative 'lyrics_finder/provider'
9
+
10
+ require 'pry'
11
+ require 'pry-byebug'
12
+ require 'awesome_print'
9
13
 
10
14
 
11
15
  module LyricsFinder
16
+
12
17
  def self.search(author, title)
13
- Providers.list.each do |provider|
14
- url = Providers.provider_url_for_song(provider, Song.new(author, title))
15
- data = perform_request(url)
16
- result = Providers.extract_lyric_from_data(data) unless data.nil?
17
- return result unless result.nil?
18
+ begin
19
+ Provider.list.each do |provider|
20
+ url = Provider.url_for_song(provider, Song.new(author, title))
21
+ data = open(url)
22
+ result = Provider.extract_lyric_from_data(data) unless data.nil?
23
+ return result unless result.nil?
24
+ end
25
+ rescue SocketError => ex
26
+ puts "LyricsFinder can't connect to the internet"
27
+ rescue OpenURI::HTTPError => ex
28
+ puts "LyricsFinder can't find any matching lyrics for that song"
18
29
  end
19
- return nil # song not found
20
30
  end
21
31
 
22
- private
23
-
24
- def self.perform_request(url)
25
- begin
26
- open(url)
27
- rescue Exception => ex
28
- # puts "ERROR: " + ex.message
29
- end
30
- end
31
32
  end
@@ -3,12 +3,11 @@ require 'lyrics_finder'
3
3
 
4
4
  module LyricsFinder
5
5
  class CLI < Thor
6
- desc 'search -a Author -t Song Title', 'Search the lyrics for the specified author and title'
6
+ desc 'search -a "author" -t "song"', 'Search the lyrics for the specified author and song'
7
7
  method_option 'author', :aliases => '-a', :type => :string
8
8
  method_option 'title', :aliases => '-t', :type => :string
9
9
  def search
10
- result = LyricsFinder.search(options[:author], options[:title])
11
- puts result.nil? ? "Song not found." : result
10
+ puts LyricsFinder.search(options[:author], options[:title])
12
11
  end
13
12
  end
14
13
  end
@@ -1,10 +1,10 @@
1
1
  module LyricsFinder
2
- module Providers
2
+ module Provider
3
3
  def self.list
4
4
  [LyricsWikia, LyricsMania, SongLyrics, Azlyrics]
5
5
  end
6
6
 
7
- def self.provider_url_for_song(provider, song)
7
+ def self.url_for_song(provider, song)
8
8
  @current_provider = provider.new(song)
9
9
  @current_provider.format_url
10
10
  end
@@ -1,3 +1,3 @@
1
1
  module LyricsFinder
2
- VERSION = "0.2.5"
2
+ VERSION = "0.2.6"
3
3
  end
@@ -24,12 +24,12 @@ Gem::Specification.new do |spec|
24
24
  spec.add_development_dependency 'vcr', '~> 2.9.2'
25
25
  spec.add_development_dependency 'webmock', '~> 1.19.0'
26
26
  spec.add_development_dependency 'coveralls', '~> 0.7.0'
27
- # spec.add_development_dependency 'pry', '~> 0.10'
28
- # spec.add_development_dependency 'pry-byebug', '~> 2.0.0'
29
- # spec.add_development_dependency 'awesome_print', '~> 1.2.0'
27
+ spec.add_development_dependency 'pry', '~> 0.10.1'
28
+ spec.add_development_dependency 'pry-byebug', '~> 2.0.0'
29
+ spec.add_development_dependency 'awesome_print', '~> 1.6.1'
30
30
 
31
31
  spec.add_dependency 'nokogiri', '~> 1.6.0'
32
- spec.add_dependency 'activesupport', '~> 4.1.0'
33
- spec.add_dependency 'i18n', '~> 0.6.9'
32
+ spec.add_dependency 'activesupport', '~> 4.1.0' # Not working with activesupport 4.2
33
+ spec.add_dependency 'i18n', '~> 0.6'
34
34
  spec.add_dependency 'thor', '~> 0.19.1'
35
35
  end
@@ -3,7 +3,7 @@ describe LyricsFinder do
3
3
 
4
4
  context 'With LyricsWikia as the provider' do
5
5
  before :each do
6
- allow(LyricsFinder::Providers).to receive(:list).and_return([LyricsFinder::Providers::LyricsWikia])
6
+ allow(LyricsFinder::Provider).to receive(:list).and_return([LyricsFinder::Provider::LyricsWikia])
7
7
  VCR.use_cassette 'LyricsWikia 200 search' do
8
8
  @song = LyricsFinder.search("american authors", "best day of my life")
9
9
  end
@@ -20,7 +20,7 @@ describe LyricsFinder do
20
20
 
21
21
  context 'With LyricsMania as the provider' do
22
22
  before :each do
23
- allow(LyricsFinder::Providers).to receive(:list).and_return([LyricsFinder::Providers::LyricsMania])
23
+ allow(LyricsFinder::Provider).to receive(:list).and_return([LyricsFinder::Provider::LyricsMania])
24
24
  VCR.use_cassette 'LyricsMania 200 search' do
25
25
  @song = LyricsFinder.search("american authors", "best day of my life")
26
26
  end
@@ -37,7 +37,7 @@ describe LyricsFinder do
37
37
 
38
38
  context 'With SongLyrics as the provider' do
39
39
  before :each do
40
- allow(LyricsFinder::Providers).to receive(:list).and_return([LyricsFinder::Providers::SongLyrics])
40
+ allow(LyricsFinder::Provider).to receive(:list).and_return([LyricsFinder::Provider::SongLyrics])
41
41
  VCR.use_cassette 'SongLyrics 200 search' do
42
42
  @song = LyricsFinder.search("american authors", "best day of my life")
43
43
  end
@@ -54,7 +54,7 @@ describe LyricsFinder do
54
54
 
55
55
  context 'With Azlyrics as the provider' do
56
56
  before :each do
57
- allow(LyricsFinder::Providers).to receive(:list).and_return([LyricsFinder::Providers::Azlyrics])
57
+ allow(LyricsFinder::Provider).to receive(:list).and_return([LyricsFinder::Provider::Azlyrics])
58
58
  VCR.use_cassette 'Azlyrics 200 search' do
59
59
  @song = LyricsFinder.search("american authors", "best day of my life")
60
60
  end
@@ -69,17 +69,29 @@ describe LyricsFinder do
69
69
  end
70
70
  end
71
71
 
72
- context 'with a sound that does not exist yet in any provider' do
72
+ context 'with a song that does not exist yet in any provider' do
73
+ # it 'raises HTTP Error' do
74
+ # expect{
75
+ # LyricsFinder.search('asdfqwerty', 'poiulkj')
76
+ # }.to raise_error(OpenURI::HTTPError)
77
+ # end
78
+
73
79
  it 'returns nil' do
74
- expect(LyricsFinder.search("","")).to eq nil
80
+ expect(LyricsFinder.search('', '')).to eq nil
75
81
  end
76
82
  end
77
83
 
78
84
  context 'with invalid parameters' do
85
+ # it 'raises HTTP Error' do
86
+ # expect{
87
+ # LyricsFinder.search('', '')
88
+ # }.to raise_error(OpenURI::HTTPError)
89
+ # end
90
+
79
91
  it 'returns nil' do
80
- expect(LyricsFinder.search("","")).to eq nil
92
+ expect(LyricsFinder.search('', '')).to eq nil
81
93
  end
82
94
  end
83
95
 
84
- end # '#search'
96
+ end
85
97
  end
@@ -1,10 +1,10 @@
1
1
  # encoding: UTF-8
2
- describe LyricsFinder::Providers::Azlyrics do
2
+ describe LyricsFinder::Provider::Azlyrics do
3
3
 
4
4
  describe '.format_url' do
5
5
  context 'with valid author and title' do
6
6
  let(:song) { Song.new("amêricàn authors", "best day of my life") }
7
- let(:az_lyrics) { LyricsFinder::Providers::Azlyrics.new(song) }
7
+ let(:az_lyrics) { LyricsFinder::Provider::Azlyrics.new(song) }
8
8
  let(:valid_url) { "http://www.azlyrics.com/lyrics/americanauthors/bestdayofmylife.html" }
9
9
 
10
10
  it 'returns a properly formatted url' do
@@ -1,10 +1,10 @@
1
1
  # encoding: UTF-8
2
- describe LyricsFinder::Providers::LyricsMania do
2
+ describe LyricsFinder::Provider::LyricsMania do
3
3
 
4
4
  describe '.format_url' do
5
5
  context 'with valid author and title' do
6
6
  let(:song) { Song.new("amêricàn authors", "best day of my life") }
7
- let(:lyrics_mania) { LyricsFinder::Providers::LyricsMania.new(song) }
7
+ let(:lyrics_mania) { LyricsFinder::Provider::LyricsMania.new(song) }
8
8
  let(:valid_url) { "http://www.lyricsmania.com/best_day_of_my_life_lyrics_american_authors.html" }
9
9
 
10
10
  it 'returns a properly formatted url' do
@@ -1,10 +1,10 @@
1
1
  # encoding: UTF-8
2
- describe LyricsFinder::Providers::LyricsWikia do
2
+ describe LyricsFinder::Provider::LyricsWikia do
3
3
 
4
4
  describe '.format_url' do
5
5
  context 'with valid author and title' do
6
6
  let(:song) { Song.new("amëricán authòrs", "best day of my life") }
7
- let(:lyrics_wikia) { LyricsFinder::Providers::LyricsWikia.new(song) }
7
+ let(:lyrics_wikia) { LyricsFinder::Provider::LyricsWikia.new(song) }
8
8
  let(:valid_url) { "http://lyrics.wikia.com/american_authors:best_day_of_my_life" }
9
9
 
10
10
  it 'returns a properly formatted url' do
@@ -1,10 +1,10 @@
1
1
  # encoding: UTF-8
2
- describe LyricsFinder::Providers::SongLyrics do
2
+ describe LyricsFinder::Provider::SongLyrics do
3
3
 
4
4
  describe '.format_url' do
5
5
  context 'with valid author and title' do
6
6
  let(:song) { Song.new("amêricàn authors", "best day of my life") }
7
- let(:song_lyrics) { LyricsFinder::Providers::SongLyrics.new(song) }
7
+ let(:song_lyrics) { LyricsFinder::Provider::SongLyrics.new(song) }
8
8
  let(:valid_url) { "http://www.songlyrics.com/american-authors/best-day-of-my-life-lyrics/" }
9
9
 
10
10
  it 'returns a properly formatted url' do
@@ -95,46 +95,60 @@ LYRICS_MANIA_EXAMPLE = ["Wo-o-o-o-o-oh Wooh",
95
95
  "This is gonna be the best day of my life",
96
96
  "My li-i-i-i-i-ife"]
97
97
 
98
- SONG_LYRICS_EXAMPLE = ["I had a dream so big and loud",
98
+ SONG_LYRICS_EXAMPLE = ["(Ooh, Ooh-Ooh, Ooh)",
99
+ "I had a dream so big and loud",
99
100
  "I jumped so high I touched the clouds",
100
- "Wo-o-o-o-o-oh, wo-o-o-o-o-oh",
101
+ "Whoa-Oh-Oh-Oh-Oh-Oh-Oh (Whoa-Oh-Oh-Oh-Oh-Oh-Oh)",
101
102
  "I stretched my hands out to the sky",
102
- "We danced with Angels through the night",
103
- "Wo-o-o-o-o-oh, wo-o-o-o-o-oh",
104
- "I'm never gonna look back",
105
- "Woah, never gonna give it up",
106
- "No, please don't wake me now",
103
+ "We danced with monsters through the night",
104
+ "Whoa-Oh-Oh-Oh-Oh-Oh-Oh (Whoa-Oh-Oh-Oh-Oh-Oh-Oh)",
105
+ "I'm never gonna look back, Whoa-Oh",
106
+ "Never gonna give it up, No-Oh",
107
+ "Please don't wake me now",
108
+ "(Ooh, Ooh-Ooh, Ooh)",
107
109
  "This is gonna be the best day of my life",
108
- "My li-i-i-i-i-ife",
110
+ "(Ooh, Ooh-Ooh, Ooh) My li-i-i-i-i-i-ife",
111
+ "(Ooh, Ooh-Ooh, Ooh)",
109
112
  "This is gonna be the best day of my life",
110
- "My li-i-i-i-i-ife",
111
- "I hailed at the moon with friends",
112
- "And then the sun came shinning in",
113
- "Wo-o-o-o-o-oh, wo-o-o-o-o-oh",
113
+ "(Ooh, Ooh-Ooh, Ooh) My li-i-i-i-i-i-ife",
114
+ "(Ooh, Ooh-Ooh, Ooh) Whoo",
115
+ "(Ooh, Ooh-Ooh, Ooh)",
116
+ "I howled at the moon with my friends",
117
+ "And then the sun came crashing in",
118
+ "Whoa-Oh-Oh-Oh-Oh-Oh-Oh (Whoa-Oh-Oh-Oh-Oh-Oh-Oh)",
114
119
  "But all the possibilities",
115
120
  "No limits just epiphanies",
116
- "Wo-o-o-o-o-oh, wo-o-o-o-o-oh",
117
- "I'm never gonna look back",
118
- "Woah, never gonna give it up",
119
- "No, just don't wake me now",
121
+ "Whoa-Oh-Oh-Oh-Oh-Oh-Oh (Whoa-Oh-Oh-Oh-Oh-Oh-Oh)",
122
+ "I'm never gonna look back, Whoa-Oh",
123
+ "Never gonna give it up, No-Oh",
124
+ "Just don't wake me now",
125
+ "(Ooh, Ooh-Ooh, Ooh)",
120
126
  "This is gonna be the best day of my life",
121
- "My li-i-i-i-i-ife",
127
+ "(Ooh, Ooh-Ooh, Ooh) My li-i-i-i-i-i-ife",
128
+ "(Ooh, Ooh-Ooh, Ooh)",
122
129
  "This is gonna be the best day of my life",
123
- "My li-i-i-i-i-ife",
124
- "I hear it calling outside my window",
125
- "I feel it in my soul (soul)",
126
- "The stars were flashing so bright",
127
- "The sun was out 'til midnight",
128
- "I say we gained control (control)",
130
+ "(Ooh, Ooh-Ooh, Ooh) My li-i-i-i-i-i-ife",
131
+ "(Ooh, Ooh-Ooh, Ooh)",
132
+ "(Ooh, Ooh-Ooh, Ooh)",
133
+ "I hear it calling",
134
+ "Outside my window",
135
+ "I feel it in my soul (Soul)",
136
+ "The stars were burning so bright",
137
+ "The sun was out 'till midnight",
138
+ "I say we lose control (Control)",
139
+ "(Ooh, Ooh-Ooh, Ooh)",
140
+ "(Ooh, Ooh-Ooh, Ooh)",
129
141
  "This is gonna be the best day of my life",
130
- "My li-i-i-i-i-ife",
142
+ "(Ooh, Ooh-Ooh, Ooh) My li-i-i-i-i-i-ife",
143
+ "(Ooh, Ooh-Ooh, Ooh)",
131
144
  "This is gonna be the best day of my life",
132
- "My li-i-i-i-i-ife",
133
- "This is gonna be, this is gonna be, this is gonna be",
134
- "The best day of my life",
145
+ "(Ooh, Ooh-Ooh, Ooh) My li-i-i-i-i-i-ife",
146
+ "(Ooh, Ooh-Ooh, Ooh) This is gonna be, this is gonna be",
147
+ "This has gotta be, the best day of my life (Ooh, Ooh-Ooh, Ooh)",
135
148
  "Everything is looking up, everybody up now",
136
- "This is gonna be the best day of my life",
137
- "My li-i-i-i-i-ife"]
149
+ "(Ooh, Ooh-Ooh, Ooh)",
150
+ "This is gonna be the best day of my liife",
151
+ "(Ooh, Ooh-Ooh, Ooh) My li-i-i-i-i-ife"]
138
152
 
139
153
  AZ_LYRICS_EXAMPLE = ["I had a dream so big and loud",
140
154
  "I jumped so high I touched the clouds",
@@ -1,4 +1,5 @@
1
1
  VCR.configure do |c|
2
2
  c.cassette_library_dir = 'spec/vcr_cassettes'
3
3
  c.hook_into :webmock
4
+ c.allow_http_connections_when_no_cassette = true
4
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lyrics_finder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Romero
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-19 00:00:00.000000000 Z
11
+ date: 2015-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -94,6 +94,48 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: 0.7.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: pry
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 0.10.1
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 0.10.1
111
+ - !ruby/object:Gem::Dependency
112
+ name: pry-byebug
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 2.0.0
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 2.0.0
125
+ - !ruby/object:Gem::Dependency
126
+ name: awesome_print
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: 1.6.1
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: 1.6.1
97
139
  - !ruby/object:Gem::Dependency
98
140
  name: nokogiri
99
141
  requirement: !ruby/object:Gem::Requirement
@@ -128,14 +170,14 @@ dependencies:
128
170
  requirements:
129
171
  - - "~>"
130
172
  - !ruby/object:Gem::Version
131
- version: 0.6.9
173
+ version: '0.6'
132
174
  type: :runtime
133
175
  prerelease: false
134
176
  version_requirements: !ruby/object:Gem::Requirement
135
177
  requirements:
136
178
  - - "~>"
137
179
  - !ruby/object:Gem::Version
138
- version: 0.6.9
180
+ version: '0.6'
139
181
  - !ruby/object:Gem::Dependency
140
182
  name: thor
141
183
  requirement: !ruby/object:Gem::Requirement
@@ -170,7 +212,7 @@ files:
170
212
  - bin/lyricsfinder
171
213
  - lib/lyrics_finder.rb
172
214
  - lib/lyrics_finder/cli.rb
173
- - lib/lyrics_finder/providers.rb
215
+ - lib/lyrics_finder/provider.rb
174
216
  - lib/lyrics_finder/song.rb
175
217
  - lib/lyrics_finder/version.rb
176
218
  - lyrics_finder.gemspec
@@ -202,7 +244,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
202
244
  version: '0'
203
245
  requirements: []
204
246
  rubyforge_project:
205
- rubygems_version: 2.2.2
247
+ rubygems_version: 2.4.5
206
248
  signing_key:
207
249
  specification_version: 4
208
250
  summary: Solution for finding song lyrics