discogs-wrapper 2.2.2 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4654ad8d85f69444831ce09b6c2960ba2e598fed
|
4
|
+
data.tar.gz: fa37e9987c31c5763df41d822c0b3c08929b29e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b54ec185f2dcf2415721a7b88008f5a8a1c20860e8af6e456614ccb246855618cea55ca332744266bd14ccdb96cdd4c7aa5eadf9204d4c41bb8f8c979c12215
|
7
|
+
data.tar.gz: b1d6c9e76a7f988429386fae10ae74ee7c8140555058c2c0c9c5beee4c734fbfff42dd03425cbb2493da7506e2c09bfa7f9816381ec297777f2bc273f34b3abe
|
data/lib/wrapper/wrapper.rb
CHANGED
@@ -733,7 +733,7 @@ class Discogs::Wrapper
|
|
733
733
|
|
734
734
|
if data != ""
|
735
735
|
hash = JSON.parse(data)
|
736
|
-
Hashie::Mash.new(hash)
|
736
|
+
Hashie::Mash.new(sanitize_hash(hash))
|
737
737
|
else
|
738
738
|
Hashie::Mash.new
|
739
739
|
end
|
@@ -793,13 +793,41 @@ class Discogs::Wrapper
|
|
793
793
|
|
794
794
|
# Stringifies keys and sorts.
|
795
795
|
def prepare_hash(h)
|
796
|
+
result = Hash[
|
797
|
+
h.map do |k, v|
|
798
|
+
[k.to_s, v]
|
799
|
+
end
|
800
|
+
]
|
801
|
+
|
802
|
+
result.sort
|
803
|
+
end
|
804
|
+
|
805
|
+
# Replaces known conflicting keys with safe names in a nested hash structure.
|
806
|
+
def sanitize_hash(hash)
|
807
|
+
conflicts = {"count" => "total"}
|
796
808
|
result = {}
|
797
809
|
|
798
|
-
|
799
|
-
|
810
|
+
for k, v in hash
|
811
|
+
safe_name = conflicts[k]
|
812
|
+
|
813
|
+
if safe_name
|
814
|
+
# BC: Temporary set original key for backwards-compatibility.
|
815
|
+
warn "[DEPRECATED]: The key '#{k}' has been replaced with '#{safe_name}'. When accessing, please use the latter. This message will be removed in the next major release."
|
816
|
+
result[k] = v
|
817
|
+
# End BC
|
818
|
+
|
819
|
+
result[safe_name] = v
|
820
|
+
k = safe_name
|
821
|
+
else
|
822
|
+
result[k] = v
|
823
|
+
end
|
824
|
+
|
825
|
+
if v.is_a?(Hash)
|
826
|
+
result[k] = sanitize_hash(result[k])
|
827
|
+
end
|
800
828
|
end
|
801
829
|
|
802
|
-
result
|
830
|
+
result
|
803
831
|
end
|
804
832
|
|
805
833
|
def raise_unknown_resource(path="")
|
@@ -30,6 +30,15 @@ describe Discogs::Wrapper do
|
|
30
30
|
expect(@release.master_id).to eq(5427)
|
31
31
|
end
|
32
32
|
|
33
|
+
it "should have a community/rating attribute" do
|
34
|
+
expect(@release.community.rating).to be_instance_of(Hashie::Mash)
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should have sanitized the rating count attribute" do
|
38
|
+
expect(@release.community.rating.total).to eq(91)
|
39
|
+
expect(@release.community.rating.count).to eq(2 + 1) # Original method - count returns number of key/value pairs. Plus one to be removed after backwards-compatibility fix has been removed.
|
40
|
+
end
|
41
|
+
|
33
42
|
it "should have one or more extra artists" do
|
34
43
|
expect(@release.extraartists).to be_instance_of(Hashie::Array)
|
35
44
|
expect(@release.extraartists[0].id).to eq(239)
|
@@ -22,7 +22,12 @@ describe Discogs::Wrapper do
|
|
22
22
|
expect(@user_folder.name).to eq("Uncategorized")
|
23
23
|
end
|
24
24
|
|
25
|
-
it "should have
|
25
|
+
it "should have sanitized count" do
|
26
|
+
expect(@user_folder.total).to eq(20)
|
27
|
+
expect(@user_folder.count).to eq(4 + 1) # Plus one to be removed after backwards-compatibility fix has been removed.
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should have a backwards-compatible count" do
|
26
31
|
expect(@user_folder[:count]).to eq(20)
|
27
32
|
end
|
28
33
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: discogs-wrapper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Buntine
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-03-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: pry
|