songdrop 0.1.1 → 0.1.2

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: 92532eb8b2390ee5d6d0b851710c68ee0ee99a63
4
- data.tar.gz: 3993966de74f124dae889714e14b7785bcad94c1
3
+ metadata.gz: ad1635e165e3d9d321d7c04590e52d06ad9786fb
4
+ data.tar.gz: a2254f352f6d67f51a6f21d0b97ad466a8d28af6
5
5
  SHA512:
6
- metadata.gz: dbaa754abc921c3af9241fdcec39da114a4c4f6db7a36d2d44d638c5dc3e4fa611c84a67e3720e9859e9f883330fbf9f5692fe0f6630fb4ca226fcedad173a1b
7
- data.tar.gz: 7fc463fb2032cfb4d0cf58cbb80ee32588cb1b4db89b77ce59286e9c607a8c93dd7fd925bb559336653f755c8bfc145dc56d43a14e92fda88d3d625aa2b0a956
6
+ metadata.gz: 3fdf8914e9901929622dc9a41986f74e1ab9421dd0f7ff11c17abfe3a185e5d68bcc3b686575d9c39d2d89ee19cdd68087044ddf3e574c7b3ff58eae87a106d9
7
+ data.tar.gz: 73ab81fcc7f07d05bddbb28617280296d353b20b757e2ca3b9c6f4951013d37c67f0822805d1438c1510f52dd4b597bac7ddb2bac52e32cebe9084820dadade4
@@ -24,6 +24,7 @@ else
24
24
  require_relative './songdrop/objects/song'
25
25
  require_relative './songdrop/objects/mix'
26
26
  require_relative './songdrop/objects/artist'
27
+ require_relative './songdrop/objects/error'
27
28
  require_relative './songdrop/http/rest-client'
28
29
  require_relative './songdrop/json/json'
29
30
  end
@@ -50,7 +50,7 @@ module Songdrop
50
50
  JSON.parse(target) do |obj|
51
51
  res = Parser.parse(obj)
52
52
  res = res.first if res.is_a? Array and res.size == 1
53
- block.call res if block_given?
53
+ block.call res if block
54
54
  res
55
55
  end
56
56
  end
@@ -4,7 +4,7 @@ module Songdrop
4
4
  def login(params, &block)
5
5
  post('/session', params) do |user|
6
6
  @auth_token = user.auth_token
7
- block.call user if block_given?
7
+ block.call user if block
8
8
  user
9
9
  end
10
10
  end
@@ -25,14 +25,9 @@ module Songdrop
25
25
 
26
26
  BubbleWrap::HTTP.send(method, url, bw_options) do |response|
27
27
  if response.ok?
28
- begin #in case we don't receive JSON back, we don't want the app to crash:
29
- json = BubbleWrap::JSON.parse(response.body.to_str)
30
- block.call response, json
31
- rescue
32
- block.call response, nil
33
- end
28
+ block.call response.body.to_str, nil
34
29
  else
35
- block.call response, nil
30
+ block.call nil, response.body.to_str
36
31
  end
37
32
  end
38
33
  end
@@ -1,8 +1,10 @@
1
1
  module Songdrop
2
2
  class JSON
3
3
 
4
- def self.parse(response, &block)
5
- block.call ::BubbleWrap::JSON.parse(response.body.to_str)
4
+ def self.parse(json, &block)
5
+ result = ::BubbleWrap::JSON.parse(json)
6
+ block.call result if block
7
+ result
6
8
  end
7
9
 
8
10
  end
@@ -2,7 +2,9 @@ module Songdrop
2
2
  class JSON
3
3
 
4
4
  def self.parse(json, &block)
5
- block.call ::JSON.parse(json)
5
+ result = ::JSON.parse(json)
6
+ block.call result if block
7
+ result
6
8
  end
7
9
 
8
10
  end
@@ -60,6 +60,7 @@ module Songdrop
60
60
  when :song then Song.new(properties)
61
61
  when :mix then Mix.new(properties)
62
62
  when :artist then Artist.new(properties)
63
+ when :error then Error.new(properties)
63
64
  else "[Songdrop::Parser] Don't know how to objectize #{type}"
64
65
  end
65
66
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: songdrop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Taylor