musix_match 0.1.3 → 0.1.4
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.
- data/README.rdoc +4 -0
- data/lib/musix_match/instant_lyrics.rb +4 -4
- data/lib/musix_match/lyrics_find_result.rb +3 -3
- data/lib/musix_match/track_find_result.rb +1 -1
- data/spec/{api_base_spec.rb → api/base_spec.rb} +3 -3
- data/spec/{finder_spec.rb → api/finder_spec.rb} +3 -3
- data/spec/{search_spec.rb → api/search_spec.rb} +1 -1
- data/spec/lyrics_find_result_spec.rb +21 -0
- data/spec/{lyrics_spec.rb → models/lyrics_spec.rb} +1 -1
- data/spec/{track_spec.rb → models/track_spec.rb} +1 -1
- data/spec/musix_match_spec.rb +1 -1
- data/spec/spec_helper.rb +9 -1
- data/spec/track_find_result_spec.rb +21 -0
- metadata +18 -14
data/README.rdoc
CHANGED
@@ -71,6 +71,10 @@ Available options for the search_track methods are:
|
|
71
71
|
puts "#{track.track_name} (#{track.artist_name})"
|
72
72
|
puts "Lyrics id: #{track.lyrics_id}"
|
73
73
|
end
|
74
|
+
|
75
|
+
=== Are you feeling lucky?
|
76
|
+
|
77
|
+
puts MusixMatch.i_m_feeling_lucky("Guns'n'Roses - Welcome to the jungle")
|
74
78
|
|
75
79
|
== Lyrics
|
76
80
|
|
@@ -18,14 +18,14 @@ module MusixMatch
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def start
|
21
|
-
lyrics_id =
|
21
|
+
lyrics_id = search_track
|
22
22
|
lyrics = find_lyrics(lyrics_id) if lyrics_id
|
23
23
|
Result.new(lyrics)
|
24
24
|
end
|
25
25
|
|
26
|
-
def
|
27
|
-
result = MusixMatch.
|
28
|
-
if result.status_code == 200 && lyrics = result.
|
26
|
+
def search_track
|
27
|
+
result = MusixMatch.search_track(:q => @q, :f_has_lyrics => 1)
|
28
|
+
if result.status_code == 200 && lyrics = result.track_list.first
|
29
29
|
lyrics.lyrics_id
|
30
30
|
end
|
31
31
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module MusixMatch
|
2
|
-
class LyricsFindResult
|
2
|
+
class LyricsFindResult
|
3
3
|
attr_reader :status_code, :execute_time, :lyrics
|
4
4
|
|
5
5
|
def initialize(response)
|
@@ -20,8 +20,8 @@ module MusixMatch
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def parse_response_body(response)
|
23
|
-
if status_code == 200
|
24
|
-
@lyrics = Models::Lyrics.new(response['message']['body']['lyrics_list']['lyrics'])
|
23
|
+
if status_code == 200
|
24
|
+
@lyrics = Models::Lyrics.new(response['message']['body']['lyrics_list'].first['lyrics'])
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
@@ -21,7 +21,7 @@ module MusixMatch
|
|
21
21
|
|
22
22
|
def parse_response_body(response)
|
23
23
|
if status_code == 200
|
24
|
-
@track = Models::Track.new(response['message']['body']['track_list']['track'])
|
24
|
+
@track = Models::Track.new(response['message']['body']['track_list'].first['track'])
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
@@ -1,13 +1,13 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe MusixMatch::API::Base do
|
4
4
|
it "should always use JSON as format" do
|
5
|
-
expected_url = MusixMatch::API::Base::API_URL + '/lyrics.get?
|
5
|
+
expected_url = MusixMatch::API::Base::API_URL + '/lyrics.get?format=json&apikey='
|
6
6
|
MusixMatch::API::Base.url_for('lyrics.get', :format => 'xml').should == expected_url
|
7
7
|
end
|
8
8
|
|
9
9
|
it "should use JSON as format even if the format key is a string" do
|
10
|
-
expected_url = MusixMatch::API::Base::API_URL + '/lyrics.get?
|
10
|
+
expected_url = MusixMatch::API::Base::API_URL + '/lyrics.get?format=json&apikey='
|
11
11
|
MusixMatch::API::Base.url_for('lyrics.get', 'format' => 'xml').should == expected_url
|
12
12
|
end
|
13
13
|
|
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe MusixMatch::API::Finder do
|
4
4
|
|
5
|
-
lyrics_find_response = {'message' => {'body' => {'lyrics_list' => {'lyrics' => {}}}, 'header' => { 'status_code' => 200, 'execute_time' => 1 }}}
|
6
|
-
track_find_response = {'message' => {'body' => {'track_list'
|
5
|
+
lyrics_find_response = {'message' => {'body' => {'lyrics_list' => [{'lyrics' => {}}]}, 'header' => { 'status_code' => 200, 'execute_time' => 1 }}}
|
6
|
+
track_find_response = {'message' => {'body' => {'track_list' => [{'track' => {}}] }, 'header' => { 'status_code' => 200, 'execute_time' => 1 }}}
|
7
7
|
|
8
8
|
it "should initialize a new Finder object and call find_lyrics" do
|
9
9
|
finder = mock(MusixMatch::API::Finder)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe MusixMatch::API::Search do
|
4
4
|
|
5
5
|
lyrics_search_response = {'message' => {'body' => {'lyrics_list' => []}, 'header' => { 'status_code' => 200, 'execute_time' => 1, 'available' => 10 }}}
|
6
6
|
track_search_response = {'message' => {'body' => {'track_list' => [] }, 'header' => { 'status_code' => 200, 'execute_time' => 1, 'available' => 10 }}}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe MusixMatch::LyricsFindResult do
|
4
|
+
it 'should set status_code' do
|
5
|
+
response = load_fixture('lyrics.get')
|
6
|
+
result = MusixMatch::LyricsFindResult.new(response)
|
7
|
+
result.status_code.should == 200
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should set execute_time' do
|
11
|
+
response = load_fixture('lyrics.get')
|
12
|
+
result = MusixMatch::LyricsFindResult.new(response)
|
13
|
+
result.execute_time.should == 0.025208044052
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should initialize a new lyrics with the first lyrics of lyrics_list' do
|
17
|
+
response = load_fixture('lyrics.get')
|
18
|
+
MusixMatch::Models::Lyrics.should_receive(:new).with(response['message']['body']['lyrics_list'].first['lyrics'])
|
19
|
+
MusixMatch::LyricsFindResult.new(response)
|
20
|
+
end
|
21
|
+
end
|
data/spec/musix_match_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1 +1,9 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../lib/musix_match'
|
1
|
+
require File.dirname(__FILE__) + '/../lib/musix_match'
|
2
|
+
|
3
|
+
Spec::Runner.configure do |config|
|
4
|
+
def load_fixture(name)
|
5
|
+
File.open(File.dirname(__FILE__) + "/fixtures/#{name}.json") do |file|
|
6
|
+
JSON.parse(file.read)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe MusixMatch::TrackFindResult do
|
4
|
+
it 'should set status_code' do
|
5
|
+
response = load_fixture('track.get')
|
6
|
+
result = MusixMatch::TrackFindResult.new(response)
|
7
|
+
result.status_code.should == 200
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should set execute_time' do
|
11
|
+
response = load_fixture('track.get')
|
12
|
+
result = MusixMatch::TrackFindResult.new(response)
|
13
|
+
result.execute_time.should == 0.0110709667206
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should initialize a new track with the first track of track_list' do
|
17
|
+
response = load_fixture('track.get')
|
18
|
+
MusixMatch::Models::Track.should_receive(:new).with(response['message']['body']['track_list'].first['track'])
|
19
|
+
MusixMatch::TrackFindResult.new(response)
|
20
|
+
end
|
21
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: musix_match
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 4
|
10
|
+
version: 0.1.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Andrea Franz
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-09-
|
18
|
+
date: 2010-09-28 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -73,13 +73,15 @@ files:
|
|
73
73
|
- lib/musix_match/models/track.rb
|
74
74
|
- lib/musix_match/track_find_result.rb
|
75
75
|
- lib/musix_match/track_search_result.rb
|
76
|
-
- spec/
|
77
|
-
- spec/finder_spec.rb
|
78
|
-
- spec/
|
76
|
+
- spec/api/base_spec.rb
|
77
|
+
- spec/api/finder_spec.rb
|
78
|
+
- spec/api/search_spec.rb
|
79
|
+
- spec/lyrics_find_result_spec.rb
|
80
|
+
- spec/models/lyrics_spec.rb
|
81
|
+
- spec/models/track_spec.rb
|
79
82
|
- spec/musix_match_spec.rb
|
80
|
-
- spec/search_spec.rb
|
81
83
|
- spec/spec_helper.rb
|
82
|
-
- spec/
|
84
|
+
- spec/track_find_result_spec.rb
|
83
85
|
has_rdoc: true
|
84
86
|
homepage: http://github.com/pilu/musix_match
|
85
87
|
licenses: []
|
@@ -116,10 +118,12 @@ signing_key:
|
|
116
118
|
specification_version: 3
|
117
119
|
summary: API wrapper for musixmatch.com API's
|
118
120
|
test_files:
|
119
|
-
- spec/
|
120
|
-
- spec/finder_spec.rb
|
121
|
-
- spec/
|
121
|
+
- spec/api/base_spec.rb
|
122
|
+
- spec/api/finder_spec.rb
|
123
|
+
- spec/api/search_spec.rb
|
124
|
+
- spec/lyrics_find_result_spec.rb
|
125
|
+
- spec/models/lyrics_spec.rb
|
126
|
+
- spec/models/track_spec.rb
|
122
127
|
- spec/musix_match_spec.rb
|
123
|
-
- spec/search_spec.rb
|
124
128
|
- spec/spec_helper.rb
|
125
|
-
- spec/
|
129
|
+
- spec/track_find_result_spec.rb
|