vagalume 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +73 -0
- data/Rakefile +2 -0
- data/VERSION +1 -1
- data/bin/vagalume +25 -0
- data/lib/vagalume.rb +15 -7
- data/lib/vagalume/core_ext/array.rb +1 -4
- data/lib/vagalume/lyric_formatter.rb +39 -0
- data/lib/vagalume/song.rb +2 -0
- data/spec/array_spec.rb +16 -0
- data/spec/assets/lyric_formatter/unforgiven_lyric.txt +86 -0
- data/spec/assets/lyric_formatter/unforgiven_lyric_with_translation.txt +86 -0
- data/spec/assets/unforgiven_lyric_with_translation.txt +88 -0
- data/spec/base_spec.rb +28 -30
- data/spec/lyric_formatter_spec.rb +25 -0
- data/vagalume.gemspec +12 -6
- metadata +26 -20
- data/README.rdoc +0 -19
- data/test/helper.rb +0 -18
- data/test/test_vagalume.rb +0 -7
data/README.md
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
## Vagalume
|
2
|
+
|
3
|
+
A simple ruby interface to the Vagalume API
|
4
|
+
|
5
|
+
## Install
|
6
|
+
|
7
|
+
You can add it to your Gemfile with:
|
8
|
+
```ruby
|
9
|
+
gem 'vagalume'
|
10
|
+
```
|
11
|
+
and run the bundle command to install it.
|
12
|
+
|
13
|
+
For non-Rails projects, you can simply install the gem with
|
14
|
+
```console
|
15
|
+
gem install 'vagalume'
|
16
|
+
```
|
17
|
+
|
18
|
+
## Usage
|
19
|
+
|
20
|
+
The usage of the vagalume gem is pretty simple:
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
require "vagalume"
|
24
|
+
|
25
|
+
result = Vagalume.find("Metallica", "The Unforgiven")
|
26
|
+
|
27
|
+
puts result.status # Can be "exact", "aprox", "song_notfound" or "notfound"
|
28
|
+
|
29
|
+
puts result.song.id
|
30
|
+
puts result.song.name
|
31
|
+
puts result.song.language
|
32
|
+
puts result.song.url
|
33
|
+
puts result.song.lyric
|
34
|
+
|
35
|
+
puts result.artist.id
|
36
|
+
puts result.artist.name
|
37
|
+
puts result.artist.url
|
38
|
+
|
39
|
+
puts result.translations.with_language(Vagalume::Language::PORTUGUESE) # return a Song object
|
40
|
+
```
|
41
|
+
|
42
|
+
You can also use it from the command line:
|
43
|
+
```console
|
44
|
+
vagalume Metallica - The Unforgiven
|
45
|
+
```
|
46
|
+
or passing the [-t] flag, to show the portuguese translation:
|
47
|
+
```console
|
48
|
+
vagalume -t Metallica - The Unforgiven
|
49
|
+
```
|
50
|
+
|
51
|
+
|
52
|
+
## License
|
53
|
+
|
54
|
+
Copyright (c) 2012 Brian Thomas Storti
|
55
|
+
|
56
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
57
|
+
a copy of this software and associated documentation files (the
|
58
|
+
"Software"), to deal in the Software without restriction, including
|
59
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
60
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
61
|
+
permit persons to whom the Software is furnished to do so, subject to
|
62
|
+
the following conditions:
|
63
|
+
|
64
|
+
The above copyright notice and this permission notice shall be
|
65
|
+
included in all copies or substantial portions of the Software.
|
66
|
+
|
67
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
68
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
69
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
70
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
71
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
72
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
73
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
CHANGED
@@ -20,6 +20,8 @@ Jeweler::Tasks.new do |gem|
|
|
20
20
|
gem.description = %Q{Ruby interface for the Vagalume API}
|
21
21
|
gem.email = "btstorti@gmail.com"
|
22
22
|
gem.authors = ["Brian Thomas Storti"]
|
23
|
+
gem.executables = ["vagalume"]
|
24
|
+
gem.default_executable = "vagalume"
|
23
25
|
gem.add_dependency "multi_json"
|
24
26
|
end
|
25
27
|
Jeweler::RubygemsDotOrgTasks.new
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/bin/vagalume
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'optparse'
|
5
|
+
require 'vagalume'
|
6
|
+
|
7
|
+
options = {}
|
8
|
+
optparse = OptionParser.new do |opts|
|
9
|
+
opts.banner = "Usage: vagalume [options] [artist] - [song]"
|
10
|
+
opts.banner += "\n vagalume Metallica - Unforgiven"
|
11
|
+
opts.banner += "\n vagalume -t Metallica - Unforgiven Shows portuguese translation"
|
12
|
+
|
13
|
+
options[:translation] = false
|
14
|
+
opts.on('-t', '--translation', 'Print translation') do
|
15
|
+
options[:translation] = true
|
16
|
+
end
|
17
|
+
|
18
|
+
opts.on('-h', '--help', '') do
|
19
|
+
puts opts
|
20
|
+
exit
|
21
|
+
end
|
22
|
+
end.parse!(ARGV)
|
23
|
+
|
24
|
+
artist, song = ARGV.join(" ").split("-")
|
25
|
+
Vagalume.print(artist, song, options)
|
data/lib/vagalume.rb
CHANGED
@@ -1,19 +1,27 @@
|
|
1
1
|
require "multi_json"
|
2
2
|
require "cgi"
|
3
3
|
require "open-uri"
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
4
|
+
require_relative "vagalume/core_ext/array"
|
5
|
+
require_relative "vagalume/search_result"
|
6
|
+
require_relative "vagalume/language"
|
7
|
+
require_relative "vagalume/song"
|
8
|
+
require_relative "vagalume/artist"
|
9
|
+
require_relative "vagalume/lyric_formatter"
|
10
|
+
require_relative "vagalume/status"
|
10
11
|
|
11
12
|
module Vagalume
|
13
|
+
extend self
|
14
|
+
|
12
15
|
BASE_URL = "http://www.vagalume.com.br/api/search.php?"
|
13
16
|
|
14
|
-
def
|
17
|
+
def find(artist, song)
|
15
18
|
request_url = BASE_URL + "art=#{CGI.escape(artist)}&mus=#{CGI.escape(song)}"
|
16
19
|
result_json = MultiJson.decode(open(request_url).read)
|
17
20
|
search_result = Vagalume::SearchResult.fetch(result_json)
|
18
21
|
end
|
22
|
+
|
23
|
+
def print(artist, song, options)
|
24
|
+
search = find(artist, song)
|
25
|
+
puts Vagalume::LyricFormatter.format(search, options)
|
26
|
+
end
|
19
27
|
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
class Vagalume::LyricFormatter
|
2
|
+
class << self
|
3
|
+
def format(search, options)
|
4
|
+
status = search.status
|
5
|
+
song = search.song
|
6
|
+
translated_song = search.translations.with_language(Vagalume::Language::PORTUGUESE)
|
7
|
+
output = "\n\n"
|
8
|
+
|
9
|
+
return "No lyric found" if status == Vagalume::Status::NOT_FOUND || status == Vagalume::Status::SONG_NOT_FOUND
|
10
|
+
return "\n\n#{song.name}\n\n#{song.lyric}" unless options[:translation]
|
11
|
+
|
12
|
+
bigger_line = bigger_line(song.lyric)
|
13
|
+
lyric_array = [song.name, ""]
|
14
|
+
translation_array = [translated_song.name, ""]
|
15
|
+
|
16
|
+
lyric_array += song.lyric.split("\n")
|
17
|
+
translation_array += translated_song.lyric.split("\n")
|
18
|
+
|
19
|
+
lyric_array.each_with_index do |lyric_line, index|
|
20
|
+
output += lyric_line + separator(bigger_line, lyric_line) + translation_array[index].to_s + "\n"
|
21
|
+
end
|
22
|
+
output
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def separator(bigger_line, lyric_line)
|
28
|
+
" " * (bigger_line - lyric_line.size) + " | "
|
29
|
+
end
|
30
|
+
|
31
|
+
def bigger_line(lyric)
|
32
|
+
bigger = 0
|
33
|
+
lyric.each_line do |line|
|
34
|
+
bigger = line.size if line.size > bigger
|
35
|
+
end
|
36
|
+
bigger
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/vagalume/song.rb
CHANGED
data/spec/array_spec.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#encoding: utf-8
|
2
|
+
|
3
|
+
require "spec_helper"
|
4
|
+
|
5
|
+
describe Array do
|
6
|
+
it "return song with selected language" do
|
7
|
+
right_song = double "Song"
|
8
|
+
right_song.stub!(:language).and_return(Vagalume::Language::PORTUGUESE)
|
9
|
+
|
10
|
+
wrong_song = double "Song"
|
11
|
+
wrong_song.stub!(:language).and_return(Vagalume::Language::ENGLISH)
|
12
|
+
|
13
|
+
songs = [right_song, wrong_song]
|
14
|
+
songs.with_language(Vagalume::Language::PORTUGUESE).should == right_song
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
The Unforgiven
|
4
|
+
|
5
|
+
New blood joins this earth
|
6
|
+
And quickly he's subdued
|
7
|
+
Through constant pained disgrace
|
8
|
+
The young boy learns their rules
|
9
|
+
|
10
|
+
With time the child draws in
|
11
|
+
This whipping boy done wrong
|
12
|
+
Deprived of all his thoughts
|
13
|
+
The young man struggles on and on he's known
|
14
|
+
A vow unto his own
|
15
|
+
That never from this day
|
16
|
+
His will they'll take away
|
17
|
+
|
18
|
+
What I've felt
|
19
|
+
What I've known
|
20
|
+
Never shined through in what I've shown
|
21
|
+
Never be
|
22
|
+
Never see
|
23
|
+
Won't see what might have been
|
24
|
+
|
25
|
+
What I've felt
|
26
|
+
What I've known
|
27
|
+
Never shined through in what I've shown
|
28
|
+
Never free
|
29
|
+
Never me
|
30
|
+
So I dub the unforgiven
|
31
|
+
|
32
|
+
They dedicate their lives
|
33
|
+
To running all of his
|
34
|
+
He tries to please them all
|
35
|
+
This bitter man he is
|
36
|
+
Throughout his life the same
|
37
|
+
He's battled constantly
|
38
|
+
This fight he cannot win
|
39
|
+
A tired man they see no longer cares
|
40
|
+
The old man then prepares
|
41
|
+
To die regretfully
|
42
|
+
That old man here is me
|
43
|
+
|
44
|
+
What I've felt
|
45
|
+
What I've known
|
46
|
+
Never shined through in what I've shown
|
47
|
+
Never be
|
48
|
+
Never see
|
49
|
+
Won't see what might have been
|
50
|
+
|
51
|
+
What I've felt
|
52
|
+
What I've known
|
53
|
+
Never shined through in what I've shown
|
54
|
+
Never free
|
55
|
+
Never me
|
56
|
+
So I dub the unforgiven
|
57
|
+
|
58
|
+
What I've felt
|
59
|
+
What I've known
|
60
|
+
Never shined through in what I've shown
|
61
|
+
Never be
|
62
|
+
Never see
|
63
|
+
Won't see what might have been
|
64
|
+
|
65
|
+
What I've felt
|
66
|
+
What I've known
|
67
|
+
Never shined through in what I've shown
|
68
|
+
Never free
|
69
|
+
Never me
|
70
|
+
So I dub the unforgiven
|
71
|
+
|
72
|
+
Never free
|
73
|
+
Never me
|
74
|
+
So I dub the unforgiven
|
75
|
+
|
76
|
+
You labeled me
|
77
|
+
I'll label you
|
78
|
+
So I dub the unforgiven
|
79
|
+
|
80
|
+
Never free
|
81
|
+
Never me
|
82
|
+
So I dub the unforgiven
|
83
|
+
|
84
|
+
You labeled me
|
85
|
+
I'll label you
|
86
|
+
So I dub the unforgiven
|
@@ -0,0 +1,86 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
The Unforgiven | Os Imperdoáveis
|
4
|
+
|
|
5
|
+
New blood joins this earth | Sangue novo se junta a esta terra
|
6
|
+
And quickly he's subdued | E rapidamente ele é subjugado
|
7
|
+
Through constant pained disgrace | Atravessando constante e dolorosa desgraça
|
8
|
+
The young boy learns their rules | O jovem garoto aprende suas regras
|
9
|
+
|
|
10
|
+
With time the child draws in | Com o tempo a criança é enganada
|
11
|
+
This whipping boy done wrong | Este rapaz subjugado fez errado
|
12
|
+
Deprived of all his thoughts | Desprovido de todos os seus pensamentos
|
13
|
+
The young man struggles on and on he's known | O jovem homem aguenta e aguenta, ele sabe
|
14
|
+
A vow unto his own | Um juramento para si mesmo
|
15
|
+
That never from this day | Que nunca a partir deste dia
|
16
|
+
His will they'll take away | Eles vão tirar o seu desejo
|
17
|
+
|
|
18
|
+
What I've felt | O que eu senti
|
19
|
+
What I've known | O que eu soube
|
20
|
+
Never shined through in what I've shown | Nunca transpareceu no que eu mostrei
|
21
|
+
Never be | Nunca ser
|
22
|
+
Never see | Nunca ver
|
23
|
+
Won't see what might have been | Não verei o que poderia ter sido
|
24
|
+
|
|
25
|
+
What I've felt | O que eu senti
|
26
|
+
What I've known | O que eu soube
|
27
|
+
Never shined through in what I've shown | Nunca transpareceu no que eu mostrei
|
28
|
+
Never free | Nunca livre
|
29
|
+
Never me | Nunca eu mesmo
|
30
|
+
So I dub the unforgiven | Então eu os nomeio imperdoáveis
|
31
|
+
|
|
32
|
+
They dedicate their lives | Eles dedicaram suas vidas
|
33
|
+
To running all of his | A tomar tudo deles
|
34
|
+
He tries to please them all | Ele tenta satisfazer a todos
|
35
|
+
This bitter man he is | Este homem amargo ele se torna
|
36
|
+
Throughout his life the same | Por toda a sua vida o mesmo
|
37
|
+
He's battled constantly | Ele lutou constantemente
|
38
|
+
This fight he cannot win | Esta luta ele não pode vencer
|
39
|
+
A tired man they see no longer cares | Um homem cansado eles vêem, não importa mais
|
40
|
+
The old man then prepares | O velho homem então se prepara
|
41
|
+
To die regretfully | Para morrer cheio de arrependimentos
|
42
|
+
That old man here is me | Este velho homem aqui sou eu
|
43
|
+
|
|
44
|
+
What I've felt | O que eu senti
|
45
|
+
What I've known | O que eu soube
|
46
|
+
Never shined through in what I've shown | Nunca apareceram no que eu mostrei
|
47
|
+
Never be | Nunca ser
|
48
|
+
Never see | Nunca ver
|
49
|
+
Won't see what might have been | Não ver o que poderia ter sido
|
50
|
+
|
|
51
|
+
What I've felt | O que eu senti
|
52
|
+
What I've known | O que eu soube
|
53
|
+
Never shined through in what I've shown | Nunca apareceram no que eu mostrei
|
54
|
+
Never free | Nunca livre
|
55
|
+
Never me | Nunca eu mesmo
|
56
|
+
So I dub the unforgiven | Então eu os nomeio imperdoáveis
|
57
|
+
|
|
58
|
+
What I've felt | O que eu senti
|
59
|
+
What I've known | O que eu soube
|
60
|
+
Never shined through in what I've shown | Nunca apareceram no que eu mostrei
|
61
|
+
Never be | Nunca ser
|
62
|
+
Never see | Nunca ver
|
63
|
+
Won't see what might have been | Não ver o que poderia ter sido
|
64
|
+
|
|
65
|
+
What I've felt | O que eu senti
|
66
|
+
What I've known | O que eu soube
|
67
|
+
Never shined through in what I've shown | Nunca apareceram no que eu mostrei
|
68
|
+
Never free | Nunca livre
|
69
|
+
Never me | Nunca eu mesmo
|
70
|
+
So I dub the unforgiven | Então eu os nomeio imperdoáveis
|
71
|
+
|
|
72
|
+
Never free | Nunca livre
|
73
|
+
Never me | Nunca eu mesmo
|
74
|
+
So I dub the unforgiven | Então eu os nomeio imperdoáveis
|
75
|
+
|
|
76
|
+
You labeled me | Vocês me rotularam
|
77
|
+
I'll label you | Eu rotularei vocês
|
78
|
+
So I dub the unforgiven | Então eu os nomeio imperdoáveis
|
79
|
+
|
|
80
|
+
Never free | Nunca livre
|
81
|
+
Never me | Nunca eu mesmo
|
82
|
+
So I dub the unforgiven | Então eu os nomeio imperdoáveis
|
83
|
+
|
|
84
|
+
You labeled me | Vocês me rotularam
|
85
|
+
I'll label you | Eu rotularei vocês
|
86
|
+
So I dub the unforgiven | Então eu os nomeio imperdoáveis
|
@@ -0,0 +1,88 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
The Unforgiven | Os Imperdoáveis
|
4
|
+
|
|
5
|
+
New blood joins this earth | Sangue novo se junta a esta terra
|
6
|
+
And quickly he's subdued | E rapidamente ele é subjugado
|
7
|
+
Through constant pained disgrace | Atravessando constante e dolorosa desgraça
|
8
|
+
The young boy learns their rules | O jovem garoto aprende suas regras
|
9
|
+
|
|
10
|
+
With time the child draws in | Com o tempo a criança é enganada
|
11
|
+
This whipping boy done wrong | Este rapaz subjugado fez errado
|
12
|
+
Deprived of all his thoughts | Desprovido de todos os seus pensamentos
|
13
|
+
The young man struggles on and on he's known | O jovem homem aguenta e aguenta, ele sabe
|
14
|
+
A vow unto his own | Um juramento para si mesmo
|
15
|
+
That never from this day | Que nunca a partir deste dia
|
16
|
+
His will they'll take away | Eles vão tirar o seu desejo
|
17
|
+
|
|
18
|
+
What I've felt | O que eu senti
|
19
|
+
What I've known | O que eu soube
|
20
|
+
Never shined through in what I've shown | Nunca transpareceu no que eu mostrei
|
21
|
+
Never be | Nunca ser
|
22
|
+
Never see | Nunca ver
|
23
|
+
Won't see what might have been | Não verei o que poderia ter sido
|
24
|
+
|
|
25
|
+
What I've felt | O que eu senti
|
26
|
+
What I've known | O que eu soube
|
27
|
+
Never shined through in what I've shown | Nunca transpareceu no que eu mostrei
|
28
|
+
Never free | Nunca livre
|
29
|
+
Never me | Nunca eu mesmo
|
30
|
+
So I dub the unforgiven | Então eu os nomeio imperdoáveis
|
31
|
+
|
|
32
|
+
They dedicate their lives | Eles dedicaram suas vidas
|
33
|
+
To running all of his | A tomar tudo deles
|
34
|
+
He tries to please them all | Ele tenta satisfazer a todos
|
35
|
+
This bitter man he is | Este homem amargo ele se torna
|
36
|
+
Throughout his life the same | Por toda a sua vida o mesmo
|
37
|
+
He's battled constantly | Ele lutou constantemente
|
38
|
+
This fight he cannot win | Esta luta ele não pode vencer
|
39
|
+
A tired man they see no longer cares | Um homem cansado eles vêem, não importa mais
|
40
|
+
The old man then prepares | O velho homem então se prepara
|
41
|
+
To die regretfully | Para morrer cheio de arrependimentos
|
42
|
+
That old man here is me | Este velho homem aqui sou eu
|
43
|
+
|
|
44
|
+
What I've felt | O que eu senti
|
45
|
+
What I've known | O que eu soube
|
46
|
+
Never shined through in what I've shown | Nunca apareceram no que eu mostrei
|
47
|
+
Never be | Nunca ser
|
48
|
+
Never see | Nunca ver
|
49
|
+
Won't see what might have been | Não ver o que poderia ter sido
|
50
|
+
|
|
51
|
+
What I've felt | O que eu senti
|
52
|
+
What I've known | O que eu soube
|
53
|
+
Never shined through in what I've shown | Nunca apareceram no que eu mostrei
|
54
|
+
Never free | Nunca livre
|
55
|
+
Never me | Nunca eu mesmo
|
56
|
+
So I dub the unforgiven | Então eu os nomeio imperdoáveis
|
57
|
+
|
|
58
|
+
What I've felt | O que eu senti
|
59
|
+
What I've known | O que eu soube
|
60
|
+
Never shined through in what I've shown | Nunca apareceram no que eu mostrei
|
61
|
+
Never be | Nunca ser
|
62
|
+
Never see | Nunca ver
|
63
|
+
Won't see what might have been | Não ver o que poderia ter sido
|
64
|
+
|
|
65
|
+
What I've felt | O que eu senti
|
66
|
+
What I've known | O que eu soube
|
67
|
+
Never shined through in what I've shown | Nunca apareceram no que eu mostrei
|
68
|
+
Never free | Nunca livre
|
69
|
+
Never me | Nunca eu mesmo
|
70
|
+
So I dub the unforgiven | Então eu os nomeio imperdoáveis
|
71
|
+
|
|
72
|
+
Never free | Nunca livre
|
73
|
+
Never me | Nunca eu mesmo
|
74
|
+
So I dub the unforgiven | Então eu os nomeio imperdoáveis
|
75
|
+
|
|
76
|
+
You labeled me | Vocês me rotularam
|
77
|
+
I'll label you | Eu rotularei vocês
|
78
|
+
So I dub the unforgiven | Então eu os nomeio imperdoáveis
|
79
|
+
|
|
80
|
+
Never free | Nunca livre
|
81
|
+
Never me | Nunca eu mesmo
|
82
|
+
So I dub the unforgiven | Então eu os nomeio imperdoáveis
|
83
|
+
|
|
84
|
+
You labeled me | Vocês me rotularam
|
85
|
+
I'll label you | Eu rotularei vocês
|
86
|
+
So I dub the unforgiven | Então eu os nomeio imperdoáveis
|
87
|
+
|
88
|
+
|
data/spec/base_spec.rb
CHANGED
@@ -2,28 +2,32 @@
|
|
2
2
|
|
3
3
|
require "spec_helper"
|
4
4
|
|
5
|
-
describe
|
6
|
-
|
5
|
+
describe Vagalume do
|
6
|
+
|
7
|
+
before(:each) do
|
7
8
|
VCR.use_cassette('vagalume') do
|
8
|
-
result = Vagalume.find("Metallica", "The Unforgiven")
|
9
|
-
song = result.song
|
10
|
-
artist = result.artist
|
11
|
-
lyric = File.read 'spec/assets/unforgiven_lyric.txt'
|
12
|
-
|
13
|
-
result.status.should == Vagalume::Status::EXACT
|
14
|
-
|
15
|
-
song.id.should == "3ade68b6g470deda3"
|
16
|
-
song.name.should == "The Unforgiven"
|
17
|
-
song.language.should == Vagalume::Language::ENGLISH
|
18
|
-
song.url.should == "http://www.vagalume.com.br/metallica/the-unforgiven.html"
|
19
|
-
song.lyric.should == lyric.chop!
|
20
|
-
|
21
|
-
artist.id.should == "3ade68b5g7257eda3"
|
22
|
-
artist.name.should == "Metallica"
|
23
|
-
artist.url.should == "http://www.vagalume.com.br/metallica/"
|
9
|
+
@result = Vagalume.find("Metallica", "The Unforgiven")
|
24
10
|
end
|
25
11
|
end
|
26
12
|
|
13
|
+
it "should bring song" do
|
14
|
+
song = @result.song
|
15
|
+
artist = @result.artist
|
16
|
+
lyric = File.read 'spec/assets/unforgiven_lyric.txt'
|
17
|
+
|
18
|
+
@result.status.should == Vagalume::Status::EXACT
|
19
|
+
|
20
|
+
song.id.should == "3ade68b6g470deda3"
|
21
|
+
song.name.should == "The Unforgiven"
|
22
|
+
song.language.should == Vagalume::Language::ENGLISH
|
23
|
+
song.url.should == "http://www.vagalume.com.br/metallica/the-unforgiven.html"
|
24
|
+
song.lyric.should == lyric.chop!
|
25
|
+
|
26
|
+
artist.id.should == "3ade68b5g7257eda3"
|
27
|
+
artist.name.should == "Metallica"
|
28
|
+
artist.url.should == "http://www.vagalume.com.br/metallica/"
|
29
|
+
end
|
30
|
+
|
27
31
|
it "should return result with song not found status" do
|
28
32
|
VCR.use_cassette('vagalume_song_not_found') do
|
29
33
|
result = Vagalume.find("Metallica", "Oops")
|
@@ -39,20 +43,14 @@ describe "Base" do
|
|
39
43
|
end
|
40
44
|
|
41
45
|
it "should have translations" do
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
lyric = File.read 'spec/assets/unforgiven_lyric_translation_pt.txt'
|
47
|
-
pt_translation.lyric.should == lyric.chop!
|
48
|
-
end
|
46
|
+
@result.translations.should_not be_empty
|
47
|
+
pt_translation = @result.translations.with_language(Vagalume::Language::PORTUGUESE)
|
48
|
+
lyric = File.read 'spec/assets/unforgiven_lyric_translation_pt.txt'
|
49
|
+
pt_translation.lyric.should == lyric.chop!
|
49
50
|
end
|
50
51
|
|
51
52
|
it "should get right song name for translations" do
|
52
|
-
|
53
|
-
|
54
|
-
translated_song = result.translations.with_language(Vagalume::Language::PORTUGUESE)
|
55
|
-
translated_song.name.should == "Os Imperdoáveis"
|
56
|
-
end
|
53
|
+
translated_song = @result.translations.with_language(Vagalume::Language::PORTUGUESE)
|
54
|
+
translated_song.name.should == "Os Imperdoáveis"
|
57
55
|
end
|
58
56
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
#encoding: utf-8
|
2
|
+
|
3
|
+
require "spec_helper"
|
4
|
+
|
5
|
+
describe Vagalume::LyricFormatter do
|
6
|
+
before(:each) do
|
7
|
+
VCR.use_cassette('vagalume') do
|
8
|
+
@search = Vagalume.find("Metallica", "The Unforgiven")
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should format song without translation" do
|
13
|
+
options = {:translation => false}
|
14
|
+
formatted_lyric = Vagalume::LyricFormatter.format(@search, options)
|
15
|
+
lyric = File.read 'spec/assets/lyric_formatter/unforgiven_lyric.txt'
|
16
|
+
formatted_lyric.should == lyric
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should format song with translation" do
|
20
|
+
options = {:translation => true}
|
21
|
+
formatted_lyric = Vagalume::LyricFormatter.format(@search, options)
|
22
|
+
lyric = File.read 'spec/assets/lyric_formatter/unforgiven_lyric_with_translation.txt'
|
23
|
+
formatted_lyric.should == lyric
|
24
|
+
end
|
25
|
+
end
|
data/vagalume.gemspec
CHANGED
@@ -5,41 +5,47 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "vagalume"
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.1"
|
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 = "2012-07-
|
12
|
+
s.date = "2012-07-12"
|
13
13
|
s.description = "Ruby interface for the Vagalume API"
|
14
14
|
s.email = "btstorti@gmail.com"
|
15
|
+
s.executables = ["vagalume"]
|
15
16
|
s.extra_rdoc_files = [
|
16
17
|
"LICENSE.txt",
|
17
|
-
"README.
|
18
|
+
"README.md"
|
18
19
|
]
|
19
20
|
s.files = [
|
20
21
|
".document",
|
21
22
|
"Gemfile",
|
22
23
|
"Gemfile.lock",
|
23
24
|
"LICENSE.txt",
|
24
|
-
"README.
|
25
|
+
"README.md",
|
25
26
|
"Rakefile",
|
26
27
|
"VERSION",
|
28
|
+
"bin/vagalume",
|
27
29
|
"lib/vagalume.rb",
|
28
30
|
"lib/vagalume/artist.rb",
|
29
31
|
"lib/vagalume/core_ext/array.rb",
|
30
32
|
"lib/vagalume/language.rb",
|
33
|
+
"lib/vagalume/lyric_formatter.rb",
|
31
34
|
"lib/vagalume/search_result.rb",
|
32
35
|
"lib/vagalume/song.rb",
|
33
36
|
"lib/vagalume/status.rb",
|
37
|
+
"spec/array_spec.rb",
|
38
|
+
"spec/assets/lyric_formatter/unforgiven_lyric.txt",
|
39
|
+
"spec/assets/lyric_formatter/unforgiven_lyric_with_translation.txt",
|
34
40
|
"spec/assets/unforgiven_lyric.txt",
|
35
41
|
"spec/assets/unforgiven_lyric_translation_pt.txt",
|
42
|
+
"spec/assets/unforgiven_lyric_with_translation.txt",
|
36
43
|
"spec/base_spec.rb",
|
37
44
|
"spec/fixtures/vcr_cassettes/vagalume.yml",
|
38
45
|
"spec/fixtures/vcr_cassettes/vagalume_not_found.yml",
|
39
46
|
"spec/fixtures/vcr_cassettes/vagalume_song_not_found.yml",
|
47
|
+
"spec/lyric_formatter_spec.rb",
|
40
48
|
"spec/spec_helper.rb",
|
41
|
-
"test/helper.rb",
|
42
|
-
"test/test_vagalume.rb",
|
43
49
|
"vagalume.gemspec"
|
44
50
|
]
|
45
51
|
s.homepage = "http://github.com/brianstorti/vagalume"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagalume
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-07-
|
12
|
+
date: 2012-07-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: multi_json
|
16
|
-
requirement: &
|
16
|
+
requirement: &2153482760 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2153482760
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: jeweler
|
27
|
-
requirement: &
|
27
|
+
requirement: &2153482260 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 1.8.4
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2153482260
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: vcr
|
38
|
-
requirement: &
|
38
|
+
requirement: &2153481700 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2153481700
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rspec
|
49
|
-
requirement: &
|
49
|
+
requirement: &2153480760 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *2153480760
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: webmock
|
60
|
-
requirement: &
|
60
|
+
requirement: &2153479720 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *2153479720
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: multi_json
|
71
|
-
requirement: &
|
71
|
+
requirement: &2153478860 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,38 +76,44 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *2153478860
|
80
80
|
description: Ruby interface for the Vagalume API
|
81
81
|
email: btstorti@gmail.com
|
82
|
-
executables:
|
82
|
+
executables:
|
83
|
+
- vagalume
|
83
84
|
extensions: []
|
84
85
|
extra_rdoc_files:
|
85
86
|
- LICENSE.txt
|
86
|
-
- README.
|
87
|
+
- README.md
|
87
88
|
files:
|
88
89
|
- .document
|
89
90
|
- Gemfile
|
90
91
|
- Gemfile.lock
|
91
92
|
- LICENSE.txt
|
92
|
-
- README.
|
93
|
+
- README.md
|
93
94
|
- Rakefile
|
94
95
|
- VERSION
|
96
|
+
- bin/vagalume
|
95
97
|
- lib/vagalume.rb
|
96
98
|
- lib/vagalume/artist.rb
|
97
99
|
- lib/vagalume/core_ext/array.rb
|
98
100
|
- lib/vagalume/language.rb
|
101
|
+
- lib/vagalume/lyric_formatter.rb
|
99
102
|
- lib/vagalume/search_result.rb
|
100
103
|
- lib/vagalume/song.rb
|
101
104
|
- lib/vagalume/status.rb
|
105
|
+
- spec/array_spec.rb
|
106
|
+
- spec/assets/lyric_formatter/unforgiven_lyric.txt
|
107
|
+
- spec/assets/lyric_formatter/unforgiven_lyric_with_translation.txt
|
102
108
|
- spec/assets/unforgiven_lyric.txt
|
103
109
|
- spec/assets/unforgiven_lyric_translation_pt.txt
|
110
|
+
- spec/assets/unforgiven_lyric_with_translation.txt
|
104
111
|
- spec/base_spec.rb
|
105
112
|
- spec/fixtures/vcr_cassettes/vagalume.yml
|
106
113
|
- spec/fixtures/vcr_cassettes/vagalume_not_found.yml
|
107
114
|
- spec/fixtures/vcr_cassettes/vagalume_song_not_found.yml
|
115
|
+
- spec/lyric_formatter_spec.rb
|
108
116
|
- spec/spec_helper.rb
|
109
|
-
- test/helper.rb
|
110
|
-
- test/test_vagalume.rb
|
111
117
|
- vagalume.gemspec
|
112
118
|
homepage: http://github.com/brianstorti/vagalume
|
113
119
|
licenses:
|
@@ -124,7 +130,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
124
130
|
version: '0'
|
125
131
|
segments:
|
126
132
|
- 0
|
127
|
-
hash: -
|
133
|
+
hash: -2214619298880552595
|
128
134
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
129
135
|
none: false
|
130
136
|
requirements:
|
data/README.rdoc
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
= vagalume
|
2
|
-
|
3
|
-
Description goes here.
|
4
|
-
|
5
|
-
== Contributing to vagalume
|
6
|
-
|
7
|
-
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
8
|
-
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
9
|
-
* Fork the project.
|
10
|
-
* Start a feature/bugfix branch.
|
11
|
-
* Commit and push until you are happy with your contribution.
|
12
|
-
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
-
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
-
|
15
|
-
== Copyright
|
16
|
-
|
17
|
-
Copyright (c) 2012 Brian Thomas Storti. See LICENSE.txt for
|
18
|
-
further details.
|
19
|
-
|
data/test/helper.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'bundler'
|
3
|
-
begin
|
4
|
-
Bundler.setup(:default, :development)
|
5
|
-
rescue Bundler::BundlerError => e
|
6
|
-
$stderr.puts e.message
|
7
|
-
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
-
exit e.status_code
|
9
|
-
end
|
10
|
-
require 'test/unit'
|
11
|
-
require 'shoulda'
|
12
|
-
|
13
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
15
|
-
require 'vagalume'
|
16
|
-
|
17
|
-
class Test::Unit::TestCase
|
18
|
-
end
|