lyrics_finder 0.0.4 → 0.0.5

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 24d30590b3b2ea3bca2df02b6f094d6765b567c8
4
- data.tar.gz: 9958bc037c98e13ae04be1c389f94b537cbde463
3
+ metadata.gz: 9e959892dc2ad4be082f5e0e5825fae580c9f29e
4
+ data.tar.gz: db0dda2962c066efc636568399ff2d192582df66
5
5
  SHA512:
6
- metadata.gz: 56c43572f530c4beffc7420eb077e008abfd6eb46e30cb185e845da7d763089a30e44e7d3f455efa3783105f5f64cd11101101dd683fe03bff947ba934a46b54
7
- data.tar.gz: 9931a17d85fba8980ef222de6d1ed8cc53a2339e389015875b681153d4ecbfc42a31aaf89cc48c259cc813e3cd858fd4272f8e89a6e20dd847ff1bf95dbe14db
6
+ metadata.gz: 7c7a7e8961e6a25b8ee20af60f6911c3e53dc1d581adb893d626ac3cb8c0d2c222aa3ea42350e3522b3fb9e911e193ca34ecd9dad80bdb8302f0d48fcb841412
7
+ data.tar.gz: 82c7b89bb4ec654935c4bf659daefcf5d88d3aa73f07d63380bd17beaa1d173f62c6cfba36dc25dc516556116e6d24ed15ca3d054f13122d2aef32e9aa9d74f3
data/README.md CHANGED
@@ -46,6 +46,12 @@ You can choose among the following:
46
46
  - AZLyrics (`:azlyrics`)
47
47
  - LyricsMania (`:lyrics_mania`)
48
48
 
49
+ You can see the websites you are using as lyrics providers with:
50
+
51
+ ```ruby
52
+ Finder.selected_providers
53
+ ```
54
+
49
55
  ## Example
50
56
 
51
57
  In your ruby apps:
@@ -4,6 +4,18 @@ module Lyrics
4
4
  module Providers
5
5
  include Contracts
6
6
 
7
+ def self.providers_list
8
+ [:lyrics_wikia, :lyrics_mania, :song_lyrics, :azlyrics]
9
+ end
10
+
11
+ def self.filter_providers(providers)
12
+ valid_providers = []
13
+ providers.each do |provider|
14
+ valid_providers << provider if providers_list.include?(provider)
15
+ end
16
+ valid_providers.any? ? valid_providers : providers_list
17
+ end
18
+
7
19
  Contract Symbol => Module
8
20
  def self.build_klass(provider)
9
21
  klass = "Lyrics::Providers::" + provider.to_s.camelize
@@ -1,3 +1,3 @@
1
1
  module LyricsFinder
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
data/lib/lyrics_finder.rb CHANGED
@@ -3,23 +3,18 @@ require_relative 'lyrics_finder/dependencies'
3
3
  module Lyrics
4
4
  class Finder
5
5
  include Contracts
6
- PROVIDERS_LIST = [:lyrics_wikia, :lyrics_mania, :song_lyrics, :azlyrics]
7
6
 
8
7
  def initialize(*args)
9
- @providers = filter_providers(args)
8
+ @providers = Providers.filter_providers(args)
10
9
  end
11
10
 
12
11
  def selected_providers
13
12
  @providers
14
13
  end
15
14
 
15
+ Contract String, String => Or[Array, nil]
16
16
  def search(author, title)
17
- song = Song.new(author, title)
18
- perform_search(song)
19
- end
20
-
21
- Contract Lyrics::Song => Or[Array, nil]
22
- def perform_search(song)
17
+ song = set_song(author, title)
23
18
  song_lyric = catch(:song_lyric) {
24
19
  @providers.each do |provider|
25
20
  klass = Providers.build_klass(provider)
@@ -34,12 +29,9 @@ module Lyrics
34
29
 
35
30
  private
36
31
 
37
- def filter_providers(providers)
38
- valid_providers = []
39
- providers.each do |provider|
40
- valid_providers << provider if PROVIDERS_LIST.include?(provider)
41
- end
42
- valid_providers.any? ? valid_providers : PROVIDERS_LIST
32
+ Contract String, String => Lyrics::Song
33
+ def set_song(author, title)
34
+ Song.new(author, title)
43
35
  end
44
36
 
45
37
  def perform_request(url)
@@ -4,7 +4,7 @@ describe Lyrics::Finder do
4
4
  let(:finder) { Lyrics::Finder.new }
5
5
 
6
6
  it 'sets @providers to default PROVIDERS_LIST' do
7
- expect(finder.selected_providers).to eq Lyrics::Finder::PROVIDERS_LIST
7
+ expect(finder.selected_providers).to eq Lyrics::Providers.providers_list
8
8
  end
9
9
  end
10
10
 
@@ -21,7 +21,7 @@ describe Lyrics::Finder do
21
21
  let(:finder) { Lyrics::Finder.new(:bad_songs, :invalid_songs) }
22
22
 
23
23
  it 'sets @providers to default PROVIDERS_LIST' do
24
- expect(finder.selected_providers).to eq Lyrics::Finder::PROVIDERS_LIST
24
+ expect(finder.selected_providers).to eq Lyrics::Providers.providers_list
25
25
  end
26
26
  end
27
27
  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.0.4
4
+ version: 0.0.5
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-06-30 00:00:00.000000000 Z
11
+ date: 2014-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler