-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DEPRECATED]: The key 'count' has been replaced with 'total'. #53
Comments
Hey there, thanks for the comments. This is a warning that the library produces when you use the "count" key in a response. This name conflicts with a Ruby native method and thus can cause conflicts. Are you using "count" anywhere in your app when dealing with responses from Discogs? If so, swap them out with "total" and the warnings will go away. Also note, these are warnings and will not break your app. |
I noticed that they don't break my application, I just used the source code posted above. Just thought I'll post it here, I have never had any issues with this wrapper, using it for small applications for my record store, thank you very much again! |
Okay, I've been playing around with this. While obviously the deprecated warning and the subsequent warnings about "count" from Hashie are expected in the current version, there is another clashing key, as alluded to in OP's output. Each track in the tracklist (itself a hash) has a "type_" key, which Hashie doesn't like. This should be easy enough to fix in that it's just another conflict to add to the def sanitize_hash(hash)
conflicts = {"count" => "total", "type_" => "kind"}
result = {}
for k, v in hash
safe_name = conflicts[k]
if safe_name
result[safe_name] = v
k = safe_name
else
result[k] = v
end
if v.is_a?(Hash)
result[k] = sanitize_hash(result[k])
end
end
result
end The recursive "sanitization" in The upshot is that as is the fix won't stop the warnings once you drop the temporary deprecation notice because any album for which there is a tracklist will trigger one warning per track. |
Thanks Jacob. I will pudate the sanitize_hash method and test it with the tracks. As for the recursive function, I will need to extend it to also account for arrays. |
Looks great guys, thank you very much! Recursive functions are definetely over the top for me, everything I learned about ruby is just what I googled to build applications for my personal needs. Thank you for your work, looking forward to the update! |
Hey guys, any updates on this issue being implemented to fix the warnings? |
I am a bit stuffed for time for the next week. I am open to PRs, of course. Otherwise, I plan to take a look at this in about one week. Thanks for the reminder! |
Hey everyone, I'm trying to build a CLI app using the Discogs Wrapper and I keep getting the following message filling up my terminal window.
Does anyone have some advice on how to ignore these messages from being put to the terminal? Would really appreciate any help, thanks! |
Are you certain you're using the latest version of the gem? It should be 2.5.1. My code that uses the wrapper requires that version, and don't see the deprecation warnings anymore. |
Hi there, I am using version 2.5.1. Every time I search the API for a specific release, I got one of the error messages for each number of tracks on that specific release. |
If you can narrow down your code to a script with a few lines, and post it here, I can try it on my end. (Don't post your user/token; I'll plug mine in instead.) |
I am also getting Hashie errors that seem to coincide with the 'DEPRECATED' warnings. |
Sigh. Yes, I'm getting the same errors that you are. Sorry, I thought I was immune, but I guess not. Maybe @buntine can weigh in? |
I appreciate you looking into it @jslabovitz - glad to know it's not just me though! |
Hi,
first of all, thanks for the great work you all, I really love this wrapper, using it for all my applications, makes it way easier for me. I'm just working with this piece of code:
require 'discogs-wrapper'
require 'pp'
aw = Discogs::Wrapper.new("My_Application", user_token: "My_Token")
path='Path to my CSV File with Label ID's of Records'
seperator = ','
values = File.open(path).map{|line| line.chop.split(seperator)}
temp_data=aw.search(values[0][0])["results"][0]
pp aw.get_release(temp_data['id'])['status']
Got this as return:
[DEPRECATED]: The key 'count' has been replaced with 'total'. When accessing, please use the latter. This message will be removed in the next major release.
W, [2018-01-15T19:29:26.463127 #12056] WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#count defined in Enumerable. This can cause unexpected behavior when accessing the key as a property. You can still access the key via the #[] method.
W, [2018-01-15T19:29:26.467639 #12056] WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#type_ defined in Hashie::Mash. This can cause unexpected behavior when accessing the key as a property. You can still access the key via the #[] method.
W, [2018-01-15T19:29:26.469200 #12056] WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#type_ defined in Hashie::Mash. This can cause unexpected behavior when accessing the key as a property. You can still access the key via the #[] method.
W, [2018-01-15T19:29:26.469642 #12056] WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#type_ defined in Hashie::Mash. This can cause unexpected behavior when accessing the key as a property. You can still access the key via the #[] method.
W, [2018-01-15T19:29:26.470643 #12056] WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#type_ defined in Hashie::Mash. This can cause unexpected behavior when accessing the key as a property. You can still access the key via the #[] method.
W, [2018-01-15T19:29:26.471159 #12056] WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#type_ defined in Hashie::Mash. This can cause unexpected behavior when accessing the key as a property. You can still access the key via the #[] method.
W, [2018-01-15T19:29:26.471644 #12056] WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#type_ defined in Hashie::Mash. This can cause unexpected behavior when accessing the key as a property. You can still access the key via the #[] method.
W, [2018-01-15T19:29:26.472192 #12056] WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#type_ defined in Hashie::Mash. This can cause unexpected behavior when accessing the key as a property. You can still access the key via the #[] method.
W, [2018-01-15T19:29:26.472653 #12056] WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#type_ defined in Hashie::Mash. This can cause unexpected behavior when accessing the key as a property. You can still access the key via the #[] method.
W, [2018-01-15T19:29:26.473155 #12056] WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#type_ defined in Hashie::Mash. This can cause unexpected behavior when accessing the key as a property. You can still access the key via the #[] method.
W, [2018-01-15T19:29:26.473653 #12056] WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#type_ defined in Hashie::Mash. This can cause unexpected behavior when accessing the key as a property. You can still access the key via the #[] method.
To be honest I'm not really sure what this means to me, I'm pretty new to ruby, but as far as I can see I did not mess with Syntax or Discogs own structure, or did I just get something wrong? Thank you very much!
Greetings, rtuz2th
The text was updated successfully, but these errors were encountered: