musix_match 0.1.4 → 0.1.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.
@@ -0,0 +1,14 @@
1
+ module MusixMatch
2
+ module API
3
+ class TrackChart < Base
4
+ def get_chart(options={})
5
+ response = get('track.chart.get', options)
6
+ TrackSearchResult.new(response)
7
+ end
8
+
9
+ def self.get_chart(options={})
10
+ TrackChart.new.get_chart(options)
11
+ end
12
+ end
13
+ end
14
+ end
@@ -4,6 +4,10 @@ module MusixMatch
4
4
  include Model
5
5
 
6
6
  model_with_attributes :track_id, :track_mbid, :lyrics_id, :track_name, :artist_id, :artist_mbid, :artist_name
7
+
8
+ def self.get_chart(options={})
9
+ API::TrackChart.get_chart(options)
10
+ end
7
11
  end
8
12
  end
9
13
  end
data/lib/musix_match.rb CHANGED
@@ -19,6 +19,7 @@ musix_match_path = File.dirname(__FILE__)
19
19
  'lyrics_find_result',
20
20
  'track_find_result',
21
21
  'api/finder',
22
+ 'api/track_chart',
22
23
  'models/track',
23
24
  'instant_lyrics'].each do |lib|
24
25
  require musix_match_path + '/musix_match/' + lib
@@ -41,8 +42,12 @@ module MusixMatch
41
42
  Models::Track.search(*args)
42
43
  end
43
44
 
45
+ def self.get_track_chart(*args)
46
+ Models::Track.get_chart(*args)
47
+ end
48
+
44
49
  def self.i_m_feeling_lucky(q)
45
50
  result = MusixMatch::InstantLyrics::Search.search(q)
46
51
  result.found? ? result.lyrics.lyrics_body : 'Lyrics not found'
47
- end
52
+ end
48
53
  end
@@ -2,12 +2,12 @@ require 'spec_helper'
2
2
 
3
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?format=json&apikey='
5
+ expected_url = MusixMatch::API::Base::API_URL + '/lyrics.get?apikey=&format=json'
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?format=json&apikey='
10
+ expected_url = MusixMatch::API::Base::API_URL + '/lyrics.get?apikey=&format=json'
11
11
  MusixMatch::API::Base.url_for('lyrics.get', 'format' => 'xml').should == expected_url
12
12
  end
13
13
 
@@ -0,0 +1,5 @@
1
+ require 'spec_helper'
2
+
3
+ describe MusixMatch::API::Search do
4
+ it
5
+ end
@@ -0,0 +1,4 @@
1
+ require 'spec_helper'
2
+
3
+ describe MusixMatch::LyricsSearchResult do
4
+ end
@@ -13,6 +13,12 @@ describe MusixMatch::Models::Track do
13
13
  MusixMatch::Models::Track.get(track_id)
14
14
  end
15
15
 
16
+ it "should call get_chart on TrackChart" do
17
+ params = { :country => 'it' }
18
+ MusixMatch::API::TrackChart.should_receive(:get_chart).with(params)
19
+ MusixMatch::Models::Track.get_chart(params)
20
+ end
21
+
16
22
  context 'when created' do
17
23
  it 'should have the search class method' do
18
24
  MusixMatch::Models::Track.should respond_to(:search)
@@ -25,6 +25,12 @@ describe MusixMatch do
25
25
  MusixMatch.search_track(params)
26
26
  end
27
27
 
28
+ it "should call get_chart on Track" do
29
+ params = { :country => 'it' }
30
+ MusixMatch::Models::Track.should_receive(:get_chart).with(params)
31
+ MusixMatch.get_track_chart(params)
32
+ end
33
+
28
34
  it "should call search on InstantLyrics::Search" do
29
35
  q = 'artist name track name'
30
36
  result = mock(MusixMatch::InstantLyrics::Result)
@@ -0,0 +1,5 @@
1
+ require 'spec_helper'
2
+
3
+ describe MusixMatch::TrackSearchResult do
4
+
5
+ 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: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 4
10
- version: 0.1.4
9
+ - 5
10
+ version: 0.1.5
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-28 00:00:00 +02:00
18
+ date: 2010-10-02 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -65,6 +65,7 @@ files:
65
65
  - lib/musix_match/api/base.rb
66
66
  - lib/musix_match/api/finder.rb
67
67
  - lib/musix_match/api/search.rb
68
+ - lib/musix_match/api/track_chart.rb
68
69
  - lib/musix_match/instant_lyrics.rb
69
70
  - lib/musix_match/lyrics_find_result.rb
70
71
  - lib/musix_match/lyrics_search_result.rb
@@ -76,12 +77,15 @@ files:
76
77
  - spec/api/base_spec.rb
77
78
  - spec/api/finder_spec.rb
78
79
  - spec/api/search_spec.rb
80
+ - spec/api/track_chart_spec.rb
79
81
  - spec/lyrics_find_result_spec.rb
82
+ - spec/lyrics_search_result_spec.rb
80
83
  - spec/models/lyrics_spec.rb
81
84
  - spec/models/track_spec.rb
82
85
  - spec/musix_match_spec.rb
83
86
  - spec/spec_helper.rb
84
87
  - spec/track_find_result_spec.rb
88
+ - spec/track_search_result_spec.rb
85
89
  has_rdoc: true
86
90
  homepage: http://github.com/pilu/musix_match
87
91
  licenses: []
@@ -121,9 +125,12 @@ test_files:
121
125
  - spec/api/base_spec.rb
122
126
  - spec/api/finder_spec.rb
123
127
  - spec/api/search_spec.rb
128
+ - spec/api/track_chart_spec.rb
124
129
  - spec/lyrics_find_result_spec.rb
130
+ - spec/lyrics_search_result_spec.rb
125
131
  - spec/models/lyrics_spec.rb
126
132
  - spec/models/track_spec.rb
127
133
  - spec/musix_match_spec.rb
128
134
  - spec/spec_helper.rb
129
135
  - spec/track_find_result_spec.rb
136
+ - spec/track_search_result_spec.rb