vagalume 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +27 -18
- data/VERSION +1 -1
- data/bin/vagalume +6 -1
- data/lib/vagalume/core_ext/array.rb +1 -1
- data/lib/vagalume/lyric_formatter.rb +1 -0
- data/lib/vagalume/search_result.rb +1 -1
- data/spec/base_spec.rb +2 -2
- data/spec/fixtures/vcr_cassettes/vagalume_with_no_translation_available.yml +81 -0
- data/spec/lyric_formatter_spec.rb +27 -14
- data/vagalume.gemspec +5 -4
- metadata +49 -35
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4de1924930bcaec6d295d05f8b1bcb6fe880d1a0
|
4
|
+
data.tar.gz: aa8b17474af99520f380b1268c2b64f53522844a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 861c5aea9ffa522caa0cef281ecb44603d7a38db42fe7d3b7babc62399fbefcef5b062bc018f6275435bde7d83cfe87a7eb42fcbeac7c7c1173bc0ec9f76200c
|
7
|
+
data.tar.gz: 589d8dccbd0ea44e11b55422f386e134fab06d8a305102220ccd5d7fbc9a214699b578836e0852048bd8c74442909b1f28b93aca92a7cf7f240fef3338a46f4f
|
data/README.md
CHANGED
@@ -1,45 +1,45 @@
|
|
1
1
|
## Vagalume
|
2
2
|
|
3
|
-
A simple ruby interface to the Vagalume API
|
3
|
+
A simple ruby interface to the Vagalume API. Also a command line utility to search song lyrics.
|
4
4
|
|
5
5
|
## Install
|
6
6
|
|
7
|
-
|
7
|
+
If you are using bundler, add it to your Gemfile:
|
8
8
|
```ruby
|
9
9
|
gem 'vagalume'
|
10
10
|
```
|
11
|
-
|
12
|
-
|
13
|
-
For non-Rails projects, you can simply install the gem with
|
11
|
+
or you can just install it with
|
14
12
|
```console
|
15
|
-
gem install
|
13
|
+
gem install vagalume
|
16
14
|
```
|
17
15
|
|
18
16
|
## Usage
|
19
17
|
|
20
|
-
The usage
|
18
|
+
The usage is pretty simple:
|
21
19
|
|
22
20
|
```ruby
|
23
21
|
require "vagalume"
|
24
22
|
|
25
23
|
result = Vagalume.find("Metallica", "The Unforgiven")
|
26
24
|
|
27
|
-
|
25
|
+
result.status # => Can be "exact", "aprox", "song_notfound" or "notfound"
|
28
26
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
27
|
+
song = result.song
|
28
|
+
song.id
|
29
|
+
song.name
|
30
|
+
song.language
|
31
|
+
song.url
|
32
|
+
song.lyric
|
34
33
|
|
35
|
-
|
36
|
-
|
37
|
-
|
34
|
+
artist = result.artist
|
35
|
+
artist.id
|
36
|
+
artist.name
|
37
|
+
artist.url
|
38
38
|
|
39
|
-
|
39
|
+
result.translations.with_language(Vagalume::Language::PORTUGUESE) # return a Song object
|
40
40
|
```
|
41
41
|
|
42
|
-
You can also use it from the command line:
|
42
|
+
You can also use it from the command line:
|
43
43
|
```console
|
44
44
|
vagalume Metallica - The Unforgiven
|
45
45
|
```
|
@@ -48,6 +48,15 @@ or passing the [-t] flag, to show the portuguese translation:
|
|
48
48
|
vagalume -t Metallica - The Unforgiven
|
49
49
|
```
|
50
50
|
|
51
|
+
It's also pretty good at finding approximations, so you can try something like that:
|
52
|
+
```console
|
53
|
+
vagalume metalica - unforgiven
|
54
|
+
```
|
55
|
+
And everything should work fine.
|
56
|
+
|
57
|
+
## Requirements
|
58
|
+
|
59
|
+
Ruby >= 1.8.7
|
51
60
|
|
52
61
|
## License
|
53
62
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
data/bin/vagalume
CHANGED
@@ -4,11 +4,16 @@ require 'rubygems'
|
|
4
4
|
require 'optparse'
|
5
5
|
require 'vagalume'
|
6
6
|
|
7
|
+
if ARGV.empty?
|
8
|
+
system "vagalume -h"
|
9
|
+
exit
|
10
|
+
end
|
11
|
+
|
7
12
|
options = {}
|
8
13
|
optparse = OptionParser.new do |opts|
|
9
14
|
opts.banner = "Usage: vagalume [options] [artist] - [song]"
|
10
15
|
opts.banner += "\n vagalume Metallica - Unforgiven"
|
11
|
-
opts.banner += "\n vagalume -t Metallica - Unforgiven Shows portuguese translation"
|
16
|
+
opts.banner += "\n vagalume -t Metallica - Unforgiven Shows portuguese translation\n\n"
|
12
17
|
|
13
18
|
options[:translation] = false
|
14
19
|
opts.on('-t', '--translation', 'Print translation') do
|
@@ -7,6 +7,7 @@ class Vagalume::LyricFormatter
|
|
7
7
|
output = "\n\n"
|
8
8
|
|
9
9
|
return "No lyric found" if status == Vagalume::Status::NOT_FOUND || status == Vagalume::Status::SONG_NOT_FOUND
|
10
|
+
return "No translation found" if translated_song.nil?
|
10
11
|
return "\n\n#{song.name}\n\n#{song.lyric}" unless options[:translation]
|
11
12
|
|
12
13
|
bigger_line = bigger_line(song.lyric)
|
@@ -12,7 +12,7 @@ module Vagalume
|
|
12
12
|
return result if result.status == Vagalume::Status::NOT_FOUND || result.status == Vagalume::Status::SONG_NOT_FOUND
|
13
13
|
song = result_json["mus"].first
|
14
14
|
artist = result_json["art"]
|
15
|
-
translations = song["translate"]
|
15
|
+
translations = song["translate"] || []
|
16
16
|
result.song = Vagalume::Song.fetch(song)
|
17
17
|
result.artist = Vagalume::Artist.fetch(artist)
|
18
18
|
|
data/spec/base_spec.rb
CHANGED
@@ -30,14 +30,14 @@ describe Vagalume do
|
|
30
30
|
|
31
31
|
it "should return result with song not found status" do
|
32
32
|
VCR.use_cassette('vagalume_song_not_found') do
|
33
|
-
result = Vagalume.find("Metallica", "Oops")
|
33
|
+
result = Vagalume.find("Metallica", "Oops")
|
34
34
|
result.status.should == Vagalume::Status::SONG_NOT_FOUND
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
38
|
it "should return result with not found status" do
|
39
39
|
VCR.use_cassette('vagalume_not_found') do
|
40
|
-
result = Vagalume.find("Oops", "Oops")
|
40
|
+
result = Vagalume.find("Oops", "Oops")
|
41
41
|
result.status.should == Vagalume::Status::NOT_FOUND
|
42
42
|
end
|
43
43
|
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://www.vagalume.com.br/api/search.php?art=Bruce%20Springsteen&mus=Ain't%20good%20enough%20for%20You
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- ! '*/*'
|
12
|
+
User-Agent:
|
13
|
+
- Ruby
|
14
|
+
response:
|
15
|
+
status:
|
16
|
+
code: 200
|
17
|
+
message: OK
|
18
|
+
headers:
|
19
|
+
Server:
|
20
|
+
- nginx
|
21
|
+
Content-Type:
|
22
|
+
- application/x-javascript; charset=UTF-8
|
23
|
+
Keep-Alive:
|
24
|
+
- timeout=60
|
25
|
+
Vary:
|
26
|
+
- Accept-Encoding
|
27
|
+
Expires:
|
28
|
+
- Sat, 14 Jul 2012 20:48:59 GMT
|
29
|
+
Cache-Control:
|
30
|
+
- max-age=30
|
31
|
+
Access-Control-Allow-Origin:
|
32
|
+
- ! '*'
|
33
|
+
X-Count:
|
34
|
+
- '10'
|
35
|
+
X-Powered-By:
|
36
|
+
- Vagalume
|
37
|
+
Transfer-Encoding:
|
38
|
+
- chunked
|
39
|
+
Date:
|
40
|
+
- Sat, 14 Jul 2012 20:48:29 GMT
|
41
|
+
X-Varnish:
|
42
|
+
- '2430257346'
|
43
|
+
Age:
|
44
|
+
- '0'
|
45
|
+
Via:
|
46
|
+
- 1.1 varnish
|
47
|
+
Connection:
|
48
|
+
- keep-alive
|
49
|
+
body:
|
50
|
+
encoding: US-ASCII
|
51
|
+
string: ! '{"type":"exact","art":{"id":"3ade68b5g01a8eda3","name":"Bruce Springsteen","url":"http:\/\/www.vagalume.com.br\/bruce-springsteen\/"},"mus":[{"id":"3ade68b8g567cdfa3","name":"Ain''t
|
52
|
+
Good Enough For You","url":"http:\/\/www.vagalume.com.br\/bruce-springsteen\/aint-good-enough-for-you.html","lang":2,"text":"Well
|
53
|
+
you don''t like, don''t like the way I walk\nAnd you don''t like, don''t like
|
54
|
+
the way I talk\nYou criticize about me endlessly\nLogic defies how you get
|
55
|
+
stuck with me\nAnd you complain about the clothes I wear\nAnd you explain
|
56
|
+
there''s other boys out there\nYou complain my car makes too much noise\nAnd
|
57
|
+
you cry I''m always out with the boys\n\nWhoa whoa (whoa whoa whoa whoa)\nI
|
58
|
+
give up little darling (whoa whoa little darling)\nYeah no matter what I do,
|
59
|
+
girl you know it''s true\nAin''t good enough for you\n\nYou complain the way
|
60
|
+
I love you at night\nYou explain I''m really not your type\nIf we go out,
|
61
|
+
you say I''m such a bore\nIf we stay in, you say what are we living for\nI
|
62
|
+
don''t understand, there''s nothing I can do\nThere ain''t no way I can satisfy
|
63
|
+
you\nEnd of the night I lean in for a kiss\nHere comes the pitch, a swing
|
64
|
+
and a miss\n\nWhoa whoa whoa whoa (whoa whoa whoa whoa)\nI quit little darling
|
65
|
+
(whoa whoa little darling)\nYeah no matter what I do, well you know it''s
|
66
|
+
true\nAin''t good enough for you, hey!\nHey!\n(Come on boys!)\n\nWhoa whoa
|
67
|
+
whoa whoa (whoa whoa whoa whoa)\nHey hey little darling (whoa whoa little
|
68
|
+
darling)\nNo matter what I do, girl you know it''s true\nAin''t good enough
|
69
|
+
for you\n\nI tried to change, I got a job in sales\nI bought a shirt uptown
|
70
|
+
in Bloomindales\nAnd babe I tried to make the latest scene\nHitting cool just
|
71
|
+
like Jimmy Iovine\nI bought a record with all the latest grooves\nA book of
|
72
|
+
love with all the latest moves\nI bought some flowers and I waited at your
|
73
|
+
door\nAnd you came out, didn''t want to see me no more\n\nWhoa whoa whoa (whoa
|
74
|
+
whoa whoa whoa)\nI quit little darling (whoa whoa little darling)\nYeah no
|
75
|
+
matter what I do, girl you know it''s true\nAin''t good enough for you\nHey!
|
76
|
+
Hey! Hey!\nNo matter what I do, girl you know it''s true\nAin''t good enough
|
77
|
+
for you\nAww no matter what I do, girl you know it''s true\nAin''t good enough
|
78
|
+
for you\nWhoaaa!"}]}'
|
79
|
+
http_version:
|
80
|
+
recorded_at: Sat, 14 Jul 2012 20:48:29 GMT
|
81
|
+
recorded_with: VCR 2.2.2
|
@@ -3,23 +3,36 @@
|
|
3
3
|
require "spec_helper"
|
4
4
|
|
5
5
|
describe Vagalume::LyricFormatter do
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
context "there is a translation available" do
|
7
|
+
before(:each) do
|
8
|
+
VCR.use_cassette('vagalume') do
|
9
|
+
@search = Vagalume.find("Metallica", "The Unforgiven")
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should format song without translation option" do
|
14
|
+
options = {:translation => false}
|
15
|
+
formatted_lyric = Vagalume::LyricFormatter.format(@search, options)
|
16
|
+
lyric = File.read 'spec/assets/lyric_formatter/unforgiven_lyric.txt'
|
17
|
+
formatted_lyric.should == lyric
|
9
18
|
end
|
10
|
-
end
|
11
19
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
20
|
+
it "should format song with translation" do
|
21
|
+
options = {:translation => true}
|
22
|
+
formatted_lyric = Vagalume::LyricFormatter.format(@search, options)
|
23
|
+
lyric = File.read 'spec/assets/lyric_formatter/unforgiven_lyric_with_translation.txt'
|
24
|
+
formatted_lyric.should == lyric
|
25
|
+
end
|
17
26
|
end
|
18
27
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
28
|
+
context "there is no translation available" do
|
29
|
+
it "should inform user there is no translation available" do
|
30
|
+
VCR.use_cassette('vagalume_with_no_translation_available') do
|
31
|
+
@search = Vagalume.find("Bruce Springsteen", "Ain't good enough for You")
|
32
|
+
options = {:translation => true}
|
33
|
+
output = Vagalume::LyricFormatter.format(@search, options)
|
34
|
+
output.should == "No translation found"
|
35
|
+
end
|
36
|
+
end
|
24
37
|
end
|
25
38
|
end
|
data/vagalume.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "vagalume"
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Brian Thomas Storti"]
|
12
|
-
s.date = "
|
12
|
+
s.date = "2013-08-05"
|
13
13
|
s.description = "Ruby interface for the Vagalume API"
|
14
14
|
s.email = "btstorti@gmail.com"
|
15
15
|
s.executables = ["vagalume"]
|
@@ -44,6 +44,7 @@ Gem::Specification.new do |s|
|
|
44
44
|
"spec/fixtures/vcr_cassettes/vagalume.yml",
|
45
45
|
"spec/fixtures/vcr_cassettes/vagalume_not_found.yml",
|
46
46
|
"spec/fixtures/vcr_cassettes/vagalume_song_not_found.yml",
|
47
|
+
"spec/fixtures/vcr_cassettes/vagalume_with_no_translation_available.yml",
|
47
48
|
"spec/lyric_formatter_spec.rb",
|
48
49
|
"spec/spec_helper.rb",
|
49
50
|
"vagalume.gemspec"
|
@@ -51,11 +52,11 @@ Gem::Specification.new do |s|
|
|
51
52
|
s.homepage = "http://github.com/brianstorti/vagalume"
|
52
53
|
s.licenses = ["MIT"]
|
53
54
|
s.require_paths = ["lib"]
|
54
|
-
s.rubygems_version = "
|
55
|
+
s.rubygems_version = "2.0.3"
|
55
56
|
s.summary = "Ruby interface for the Vagalume API"
|
56
57
|
|
57
58
|
if s.respond_to? :specification_version then
|
58
|
-
s.specification_version =
|
59
|
+
s.specification_version = 4
|
59
60
|
|
60
61
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
61
62
|
s.add_runtime_dependency(%q<multi_json>, [">= 0"])
|
metadata
CHANGED
@@ -1,82 +1,99 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagalume
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Brian Thomas Storti
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2013-08-05 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: multi_json
|
16
|
-
requirement:
|
17
|
-
none: false
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
|
-
version_requirements:
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
25
27
|
- !ruby/object:Gem::Dependency
|
26
28
|
name: jeweler
|
27
|
-
requirement:
|
28
|
-
none: false
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
29
30
|
requirements:
|
30
31
|
- - ~>
|
31
32
|
- !ruby/object:Gem::Version
|
32
33
|
version: 1.8.4
|
33
34
|
type: :development
|
34
35
|
prerelease: false
|
35
|
-
version_requirements:
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.8.4
|
36
41
|
- !ruby/object:Gem::Dependency
|
37
42
|
name: vcr
|
38
|
-
requirement:
|
39
|
-
none: false
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
40
44
|
requirements:
|
41
|
-
- -
|
45
|
+
- - '>='
|
42
46
|
- !ruby/object:Gem::Version
|
43
47
|
version: '0'
|
44
48
|
type: :development
|
45
49
|
prerelease: false
|
46
|
-
version_requirements:
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
47
55
|
- !ruby/object:Gem::Dependency
|
48
56
|
name: rspec
|
49
|
-
requirement:
|
50
|
-
none: false
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
51
58
|
requirements:
|
52
|
-
- -
|
59
|
+
- - '>='
|
53
60
|
- !ruby/object:Gem::Version
|
54
61
|
version: '0'
|
55
62
|
type: :development
|
56
63
|
prerelease: false
|
57
|
-
version_requirements:
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
58
69
|
- !ruby/object:Gem::Dependency
|
59
70
|
name: webmock
|
60
|
-
requirement:
|
61
|
-
none: false
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
62
72
|
requirements:
|
63
|
-
- -
|
73
|
+
- - '>='
|
64
74
|
- !ruby/object:Gem::Version
|
65
75
|
version: '0'
|
66
76
|
type: :development
|
67
77
|
prerelease: false
|
68
|
-
version_requirements:
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: multi_json
|
71
|
-
requirement:
|
72
|
-
none: false
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
73
86
|
requirements:
|
74
|
-
- -
|
87
|
+
- - '>='
|
75
88
|
- !ruby/object:Gem::Version
|
76
89
|
version: '0'
|
77
90
|
type: :runtime
|
78
91
|
prerelease: false
|
79
|
-
version_requirements:
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
80
97
|
description: Ruby interface for the Vagalume API
|
81
98
|
email: btstorti@gmail.com
|
82
99
|
executables:
|
@@ -112,35 +129,32 @@ files:
|
|
112
129
|
- spec/fixtures/vcr_cassettes/vagalume.yml
|
113
130
|
- spec/fixtures/vcr_cassettes/vagalume_not_found.yml
|
114
131
|
- spec/fixtures/vcr_cassettes/vagalume_song_not_found.yml
|
132
|
+
- spec/fixtures/vcr_cassettes/vagalume_with_no_translation_available.yml
|
115
133
|
- spec/lyric_formatter_spec.rb
|
116
134
|
- spec/spec_helper.rb
|
117
135
|
- vagalume.gemspec
|
118
136
|
homepage: http://github.com/brianstorti/vagalume
|
119
137
|
licenses:
|
120
138
|
- MIT
|
139
|
+
metadata: {}
|
121
140
|
post_install_message:
|
122
141
|
rdoc_options: []
|
123
142
|
require_paths:
|
124
143
|
- lib
|
125
144
|
required_ruby_version: !ruby/object:Gem::Requirement
|
126
|
-
none: false
|
127
145
|
requirements:
|
128
|
-
- -
|
146
|
+
- - '>='
|
129
147
|
- !ruby/object:Gem::Version
|
130
148
|
version: '0'
|
131
|
-
segments:
|
132
|
-
- 0
|
133
|
-
hash: -2214619298880552595
|
134
149
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
135
|
-
none: false
|
136
150
|
requirements:
|
137
|
-
- -
|
151
|
+
- - '>='
|
138
152
|
- !ruby/object:Gem::Version
|
139
153
|
version: '0'
|
140
154
|
requirements: []
|
141
155
|
rubyforge_project:
|
142
|
-
rubygems_version:
|
156
|
+
rubygems_version: 2.0.3
|
143
157
|
signing_key:
|
144
|
-
specification_version:
|
158
|
+
specification_version: 4
|
145
159
|
summary: Ruby interface for the Vagalume API
|
146
160
|
test_files: []
|