scrobbler-ng-utils 2.0.3 → 2.0.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.
@@ -33,8 +33,11 @@ module Scrobbler
33
33
  def has?(params={})
34
34
  # Check if there is a matching chache entry with no extra parameters
35
35
  found = false
36
- @collection.find(params).each do |doc|
37
- if verify(doc, params) then
36
+ options = params.merge({})
37
+ options.delete :api_key
38
+ options.delete 'api_key'
39
+ @collection.find(options).each do |doc|
40
+ if verify(doc, options) then
38
41
  @hits += 1
39
42
  found = true
40
43
  break
@@ -52,8 +55,11 @@ module Scrobbler
52
55
  # @param [Hash] params
53
56
  # @return [void]
54
57
  def set(data, params={})
55
- if not has?(params) then
56
- @collection.insert(params.merge({:xml => data, :timestamp => Time.now.to_i}))
58
+ options = params.merge({})
59
+ options.delete :api_key
60
+ options.delete 'api_key'
61
+ if not has?(options) then
62
+ @collection.insert(options.merge({:xml => data, :timestamp => Time.now.to_i}))
57
63
  end
58
64
  end
59
65
 
@@ -63,8 +69,11 @@ module Scrobbler
63
69
  # @return [String]
64
70
  def get(params={})
65
71
  found = nil
66
- @collection.find(params).each do |doc|
67
- if verify(doc, params) then
72
+ options = params.merge({})
73
+ options.delete :api_key
74
+ options.delete 'api_key'
75
+ @collection.find(options).each do |doc|
76
+ if verify(doc, options) then
68
77
  found = doc['xml']
69
78
  break
70
79
  end
@@ -80,7 +89,7 @@ module Scrobbler
80
89
  def verify(doc, params={})
81
90
  matches = true
82
91
  doc.each do |k,v|
83
- next if ['xml', 'timestamp', '_id'].include?(k)
92
+ next if ['xml', 'timestamp', '_id', 'api_key'].include?(k)
84
93
  matches &&= (not (params[k].nil? && params[k.to_sym].nil?))
85
94
  end
86
95
  matches
@@ -98,4 +107,4 @@ module Scrobbler
98
107
  end
99
108
  end
100
109
  end
101
- end
110
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scrobbler-ng-utils
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
4
+ hash: 7
5
5
  prerelease: false
6
6
  segments:
7
7
  - 2
8
8
  - 0
9
- - 3
10
- version: 2.0.3
9
+ - 4
10
+ version: 2.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Uwe L. Korn
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-08-06 00:00:00 +02:00
18
+ date: 2010-08-25 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -63,8 +63,8 @@ files:
63
63
  - lib/scrobbler-ng-utils/misc/rate-limiter.rb
64
64
  - LICENSE
65
65
  - README.rdoc
66
- - spec/spec_helper.rb
67
66
  - spec/scrobbler-ng-utils_spec.rb
67
+ - spec/spec_helper.rb
68
68
  has_rdoc: true
69
69
  homepage: http://github.com/xhochy/scrobbler-ng-utils
70
70
  licenses: []
@@ -100,5 +100,5 @@ signing_key:
100
100
  specification_version: 3
101
101
  summary: Utilities for usage in combination with the scrobbler-ng gem
102
102
  test_files:
103
- - spec/spec_helper.rb
104
103
  - spec/scrobbler-ng-utils_spec.rb
104
+ - spec/spec_helper.rb