lastfm 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.0
1
+ 1.1.1
@@ -6,7 +6,7 @@ class Lastfm
6
6
  write_method :ban, [:artist, :track]
7
7
  write_method :love, [:artist, :track]
8
8
  write_method :share, [:artist, :track, :recipient], [[:message, nil]]
9
- write_method :scrobble, [:artist, :track], [[:timestamp, Time.now.utc.to_i], [:album, nil], [:trackNumber, nil], [:mbid, nil], [:duration, nil], [:albumArtist, nil]]
9
+ write_method :scrobble, [:artist, :track], [[:timestamp, Proc.new { Time.now.utc.to_i }], [:album, nil], [:trackNumber, nil], [:mbid, nil], [:duration, nil], [:albumArtist, nil]]
10
10
  write_method :update_now_playing, [:artist, :track], [[:album, nil], [:trackNumber, nil], [:mbid, nil], [:duration, nil], [:albumArtist, nil]]
11
11
 
12
12
  regular_method :get_info, [:artist, :track], [[:username, nil]] do |response|
@@ -13,7 +13,11 @@ class Lastfm
13
13
  end
14
14
 
15
15
  optional.each_with_index do |name, index|
16
- options[name[0]] = args[index + mandatory.size] || name[1]
16
+ value = name[1]
17
+ if value.kind_of?(Proc)
18
+ value = value.call
19
+ end
20
+ options[name[0]] = args[index + mandatory.size] || value
17
21
  end
18
22
 
19
23
  options
@@ -0,0 +1,32 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe Lastfm::Util do
4
+ subject do
5
+ Lastfm::Util
6
+ end
7
+
8
+ describe '.build_options' do
9
+ it 'should build options' do
10
+ subject.build_options(
11
+ ['foo', nil],
12
+ [:foo],
13
+ [[:bar, 'xxx'], [:baz, nil]
14
+ ]).should eql({
15
+ :foo => 'foo',
16
+ :bar => 'xxx',
17
+ :baz => nil,
18
+ })
19
+ end
20
+
21
+ it 'should use proc object to set optional value' do
22
+ subject.build_options(
23
+ ['foo', nil],
24
+ [:foo],
25
+ [[:bar, Proc.new { 'xxx' }]
26
+ ]).should eql({
27
+ :foo => 'foo',
28
+ :bar => 'xxx',
29
+ })
30
+ end
31
+ end
32
+ end
metadata CHANGED
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 1
8
- - 0
8
+ - 1
9
9
  segments_generated: true
10
- version: 1.1.0
10
+ version: 1.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - youpy
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-01-23 00:00:00 +09:00
18
+ date: 2012-01-24 00:00:00 +09:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -156,6 +156,7 @@ files:
156
156
  - spec/method_category_spec.rb
157
157
  - spec/response_spec.rb
158
158
  - spec/spec_helper.rb
159
+ - spec/util_spec.rb
159
160
  has_rdoc: true
160
161
  homepage: http://github.com/youpy/ruby-lastfm
161
162
  licenses: []