intown 0.1.6 → 0.2
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.
- checksums.yaml +4 -4
- data/lib/intown/client.rb +6 -0
- data/lib/intown/errors.rb +1 -0
- data/lib/intown/version.rb +1 -1
- data/spec/intown/artist_spec.rb +15 -5
- metadata +19 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0030e781c6a26fd9819153511a2087bb0448cbe0
|
4
|
+
data.tar.gz: 982672bae31dff8cbc5fd90e97db4e4324642c04
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 554f6621add57ffa1d288468125eb881c1adf9e67e7e876cb87a1de2e464fb1e2981d0505cd28a1a4996e8d4a8ac703c132efcebe66676ebf1d3e2e10da497f1
|
7
|
+
data.tar.gz: f563d18f0198a1e755f4c78303139be37cc4db97f7bf0d4bc35cbca785d74f4d0588677973f0f9d65fe73d4f5939d8cfaa6215fd706fb643c13632e9a3155a76
|
data/lib/intown/client.rb
CHANGED
@@ -35,6 +35,8 @@ module Intown
|
|
35
35
|
json_response
|
36
36
|
end
|
37
37
|
end
|
38
|
+
rescue JSON::ParserError => e
|
39
|
+
invalid_response_error(response)
|
38
40
|
end
|
39
41
|
|
40
42
|
def process_not_acceptable(response)
|
@@ -57,6 +59,10 @@ module Intown
|
|
57
59
|
raise Intown::BadGatewayError, "Bandsintown returned a 502 proxy error. Please retry this request later."
|
58
60
|
end
|
59
61
|
|
62
|
+
def invalid_response_error(response)
|
63
|
+
raise Intown::InvalidResponseError, "JSON parsing the Bandsintown response failed with: status_code: #{response.code}, body: #{response.body}"
|
64
|
+
end
|
65
|
+
|
60
66
|
def artist_identifier(params)
|
61
67
|
return musicbrainz_identifier(params[:mbid]) if params[:mbid]
|
62
68
|
return facebook_identifier(params[:fbid]) if params[:fbid]
|
data/lib/intown/errors.rb
CHANGED
data/lib/intown/version.rb
CHANGED
data/spec/intown/artist_spec.rb
CHANGED
@@ -28,14 +28,14 @@ describe Intown::Artist do
|
|
28
28
|
Intown::Artist.fetch(:name => "Foo Fighters")
|
29
29
|
end
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
32
|
context "searching by name with periods in the name" do
|
33
33
|
it "should URL encode the period" do
|
34
34
|
Intown::Artist.should_receive(:get).with(/\/artists\/Jr%2E%20Doc/, anything).and_return(response)
|
35
|
-
Intown::Artist.fetch(:name => "Jr. Doc")
|
35
|
+
Intown::Artist.fetch(:name => "Jr. Doc")
|
36
36
|
end
|
37
37
|
end
|
38
|
-
|
38
|
+
|
39
39
|
context "searching by name with a /" do
|
40
40
|
it "should double encode the slash" do
|
41
41
|
Intown::Artist.should_receive(:get).with(/\/artists\/Is%252FIs/, anything).and_return(response)
|
@@ -56,12 +56,12 @@ describe Intown::Artist do
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
end
|
59
|
-
|
59
|
+
|
60
60
|
describe "invalid response" do
|
61
61
|
let(:status_code) { nil }
|
62
62
|
let(:response_body) { '{"errors":["app_id param is required"]}' }
|
63
63
|
let(:response) {
|
64
|
-
stub(:body => response_body,
|
64
|
+
stub(:body => response_body,
|
65
65
|
:code => status_code)
|
66
66
|
}
|
67
67
|
|
@@ -88,6 +88,16 @@ describe Intown::Artist do
|
|
88
88
|
let(:status_code) { 406 }
|
89
89
|
it_behaves_like 'error', Intown::InvalidRequestError
|
90
90
|
end
|
91
|
+
|
92
|
+
context "Invalid JSON response" do
|
93
|
+
let(:status_code) { 200 }
|
94
|
+
let(:response_body) { "<html>Boom!</html>" }
|
95
|
+
it_behaves_like 'error', Intown::InvalidResponseError
|
96
|
+
|
97
|
+
it "should return a useful error" do
|
98
|
+
expect { Intown::Artist.fetch(:name => "Jr. Doc") }.to raise_error Intown::InvalidResponseError, "JSON parsing the Bandsintown response failed with: status_code: 200, body: <html>Boom!</html>"
|
99
|
+
end
|
100
|
+
end
|
91
101
|
end
|
92
102
|
|
93
103
|
end
|
metadata
CHANGED
@@ -1,97 +1,97 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: intown
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.2'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Scheirman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-04-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 2.12.0
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 2.12.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: vcr
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 2.4.0
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 2.4.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: webmock
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: 1.9.3
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 1.9.3
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: pry
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: httparty
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - ~>
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: 0.10.0
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - ~>
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 0.10.0
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: hashie
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: 1.2.0
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: 1.2.0
|
97
97
|
description: A client for the Bandsintown API.
|
@@ -101,8 +101,8 @@ executables: []
|
|
101
101
|
extensions: []
|
102
102
|
extra_rdoc_files: []
|
103
103
|
files:
|
104
|
-
- .gitignore
|
105
|
-
- .rspec
|
104
|
+
- ".gitignore"
|
105
|
+
- ".rspec"
|
106
106
|
- Gemfile
|
107
107
|
- LICENSE.txt
|
108
108
|
- README.md
|
@@ -141,17 +141,17 @@ require_paths:
|
|
141
141
|
- lib
|
142
142
|
required_ruby_version: !ruby/object:Gem::Requirement
|
143
143
|
requirements:
|
144
|
-
- -
|
144
|
+
- - ">="
|
145
145
|
- !ruby/object:Gem::Version
|
146
146
|
version: '0'
|
147
147
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
148
148
|
requirements:
|
149
|
-
- -
|
149
|
+
- - ">="
|
150
150
|
- !ruby/object:Gem::Version
|
151
151
|
version: '0'
|
152
152
|
requirements: []
|
153
153
|
rubyforge_project:
|
154
|
-
rubygems_version: 2.
|
154
|
+
rubygems_version: 2.2.2
|
155
155
|
signing_key:
|
156
156
|
specification_version: 4
|
157
157
|
summary: Supports Bandsintown API version 1.1
|