seatgeek 0.1.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 7ea02bcbb451f64c78d3298bc0d9a580b80f0f4229955ec3b8e1a92248492580
4
+ data.tar.gz: 164188c7662ebabfb0f3719fd923ed8e6cf31afd0bc4898b9f6bef6c00b393d6
5
+ SHA512:
6
+ metadata.gz: 4d7670113e4596d936c93ff9e2e619770f5398354cf133f61a187e310131961d154700fd183770674456b0fa48ea6a5e69cbbd0595c6a8ecf34948ba6b332eb4
7
+ data.tar.gz: b382ea251fc3baa64fd0b66446922a1dcae28651b7355dec2b9c594bc35be5bcb8d097398ab1bbe54625acb8938e07d25b8e2f44a0b83828e44d2d6a20890a77
data/.gitignore CHANGED
@@ -1,5 +1,33 @@
1
1
  .DS_Store
2
- *.swp
3
- *.swo
4
- pkg
2
+
3
+ *.gem
4
+ *.rbc
5
+ /.config
6
+ /coverage/
7
+ /InstalledFiles
8
+ /pkg/
9
+ /spec/reports/
10
+ /spec/examples.txt
11
+ /test/tmp/
12
+ /test/version_tmp/
13
+ /tmp/
14
+
15
+ ## Documentation cache and generated files:
16
+ /.yardoc/
17
+ /_yardoc/
18
+ /doc/
19
+ /rdoc/
20
+
21
+ ## Environment normalization:
22
+ /.bundle/
23
+ /vendor/bundle
24
+ /lib/bundler/man/
25
+
26
+ # for a library or gem, you might want to ignore these files since the code is
27
+ # intended to run in multiple environments; otherwise, check them in:
28
+ # Gemfile.lock
29
+ .ruby-version
30
+ .ruby-gemset
31
+
32
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
5
33
  .rvmrc
@@ -1,8 +1,14 @@
1
- bundler_args: --without no_travis
2
1
  language: ruby
2
+ dist: xenial
3
+ os: linux
4
+
3
5
  rvm:
4
- - ree
5
- - 1.8.7
6
- - 1.9.2
7
- gemfile:
8
- - Gemfile
6
+ - 2.5.3
7
+
8
+ before_install:
9
+ - gem install bundler
10
+
11
+ install: bundle install --retry=3
12
+
13
+ notifications:
14
+ email: false
data/Gemfile CHANGED
@@ -1,17 +1,16 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'faraday'
4
- gem 'multi_json'
5
- gem 'rake'
6
- gem 'yajl-ruby'
3
+ gem 'faraday', '~> 0.8.11'
4
+ gem 'multi_json', '~> 1.3.5'
5
+ gem 'rake', '~> 13.0.1'
6
+ gem 'yajl-ruby', '~> 1.3.1'
7
7
 
8
8
  group :test do
9
- gem 'rspec'
9
+ gem 'rspec', '~> 3.4.0'
10
10
  end
11
11
 
12
12
  group :no_travis do
13
- gem 'awesome_print'
14
- RUBY_VERSION =~ /^1\.9/ ? gem('ruby-debug19') : gem('ruby-debug')
13
+ gem 'awesome_print', '~> 1.8.0'
15
14
  end
16
15
 
17
16
  gemspec
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- seatgeek (0.1.1)
4
+ seatgeek (1.0.2)
5
5
  faraday
6
6
  multi_json
7
7
  rake
@@ -10,46 +10,39 @@ PATH
10
10
  GEM
11
11
  remote: https://rubygems.org/
12
12
  specs:
13
- archive-tar-minitar (0.5.2)
14
- awesome_print (1.0.2)
15
- columnize (0.3.6)
16
- diff-lcs (1.1.3)
17
- faraday (0.8.0)
18
- multipart-post (~> 1.1)
19
- linecache19 (0.5.12)
20
- ruby_core_source (>= 0.1.4)
21
- multi_json (1.3.5)
22
- multipart-post (1.1.5)
23
- rake (0.9.2.2)
24
- rspec (2.10.0)
25
- rspec-core (~> 2.10.0)
26
- rspec-expectations (~> 2.10.0)
27
- rspec-mocks (~> 2.10.0)
28
- rspec-core (2.10.0)
29
- rspec-expectations (2.10.0)
30
- diff-lcs (~> 1.1.3)
31
- rspec-mocks (2.10.1)
32
- ruby-debug-base19 (0.11.25)
33
- columnize (>= 0.3.1)
34
- linecache19 (>= 0.5.11)
35
- ruby_core_source (>= 0.1.4)
36
- ruby-debug19 (0.11.6)
37
- columnize (>= 0.3.1)
38
- linecache19 (>= 0.5.11)
39
- ruby-debug-base19 (>= 0.11.19)
40
- ruby_core_source (0.1.5)
41
- archive-tar-minitar (>= 0.5.2)
42
- yajl-ruby (1.1.0)
13
+ awesome_print (1.8.0)
14
+ diff-lcs (1.4.4)
15
+ faraday (0.8.11)
16
+ multipart-post (~> 1.2.0)
17
+ multi_json (1.3.7)
18
+ multipart-post (1.2.0)
19
+ rake (13.0.1)
20
+ rspec (3.4.0)
21
+ rspec-core (~> 3.4.0)
22
+ rspec-expectations (~> 3.4.0)
23
+ rspec-mocks (~> 3.4.0)
24
+ rspec-core (3.4.4)
25
+ rspec-support (~> 3.4.0)
26
+ rspec-expectations (3.4.0)
27
+ diff-lcs (>= 1.2.0, < 2.0)
28
+ rspec-support (~> 3.4.0)
29
+ rspec-mocks (3.4.1)
30
+ diff-lcs (>= 1.2.0, < 2.0)
31
+ rspec-support (~> 3.4.0)
32
+ rspec-support (3.4.1)
33
+ yajl-ruby (1.3.1)
43
34
 
44
35
  PLATFORMS
45
36
  ruby
46
37
 
47
38
  DEPENDENCIES
48
- awesome_print
49
- faraday
50
- multi_json
51
- rake
52
- rspec
53
- ruby-debug19
39
+ awesome_print (~> 1.8.0)
40
+ faraday (~> 0.8.11)
41
+ multi_json (~> 1.3.5)
42
+ rake (~> 13.0.1)
43
+ rspec (~> 3.4.0)
54
44
  seatgeek!
55
- yajl-ruby
45
+ yajl-ruby (~> 1.3.1)
46
+
47
+ BUNDLED WITH
48
+ 2.1.4
@@ -1,4 +1,4 @@
1
- SeatGeek [![Build Status](https://secure.travis-ci.org/bluefocus/seatgeek.png)](http://travis-ci.org/bluefocus/seatgeek)
1
+ SeatGeek [![Build Status](https://secure.travis-ci.org/seatshare/seatgeek.png)](http://travis-ci.org/seatshare/seatgeek)
2
2
  ========
3
3
  SeatGeek maintains a canonical directory of live events in the United States. The SeatGeek Platform makes it easy to construct applications that help users find and discover events by exposing the wealth of data and powerful search behind SeatGeek.com in an easy-to-consume format.
4
4
 
@@ -9,8 +9,7 @@ For more information, including a detailed description of the functionality avai
9
9
  **Rubies supported**
10
10
 
11
11
  - 1.9.2
12
- - 1.8.7
13
- - ree
12
+ - 2.1.0
14
13
 
15
14
  Installation
16
15
  ------------
@@ -32,6 +31,10 @@ NOTE: Unless it is already defined in your application, SG will be defined as a
32
31
 
33
32
  SeatGeek::Connection is where all the meat is.
34
33
 
34
+ You will first need to provide the `client_id` for your application. For assistance registering and locating your `client_id`, please see [the platform documentation](http://platform.seatgeek.com/#authentication).
35
+
36
+ SeatGeek::Connection.client_id = 'some_client_id'
37
+
35
38
  Each of the four endpoints can be accessed with a class method reflecting the endpoint's name.
36
39
 
37
40
  SeatGeek::Connection.events
@@ -57,12 +60,12 @@ SeatGeek::Connection objects can be instantiated before calls. Any parameters pa
57
60
 
58
61
  There are a number of class level options that can be overridden.
59
62
 
60
- - SeatGeek::Connection.adapter - the Faraday adapter to use (default: :net_http)
61
- - SeatGeek::Connection.logger - a Logger object for logging requests (default: nil)
62
- - SeatGeek::Connection.protocol - http or https (default: :http)
63
- - SeatGeek::Connection.response_format - ruby, json, jsonp or xml (default: ruby)
64
- - SeatGeek::Connection.url - api.seatgeek::Connection.com [Advanced tuning]
65
- - SeatGeek::Connection.version - 2 [Forward thinking]
63
+ SeatGeek::Connection.adapter # the Faraday adapter to use (default: :net_http)
64
+ SeatGeek::Connection.logger # a Logger object for logging requests (default: nil)
65
+ SeatGeek::Connection.protocol # http or https (default: :http)
66
+ SeatGeek::Connection.response_format # ruby, json, jsonp or xml (default: ruby)
67
+ SeatGeek::Connection.url # api.seatgeek.com [Advanced tuning]
68
+ SeatGeek::Connection.version # 2 [Forward thinking]
66
69
 
67
70
  Example:
68
71
 
@@ -105,4 +108,3 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
105
108
  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
106
109
 
107
110
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
108
-
@@ -1,44 +1,95 @@
1
1
  require 'faraday'
2
2
 
3
+ ##
4
+ # Module: SeatGeek
3
5
  module SeatGeek
6
+ ##
7
+ # Class: Connection
4
8
  class Connection
5
9
  class << self; self; end.class_eval do
6
- def adapter; @@adapter ||= :net_http; end
7
- def adapter=(input); @@adapter = input; end
10
+ def adapter
11
+ @@adapter ||= :net_http
12
+ end
13
+
14
+ def adapter=(input)
15
+ @@adapter = input
16
+ end
17
+
18
+ def events(*args)
19
+ new.events(*args)
20
+ end
8
21
 
9
- def events(*args); new.events(*args); end
22
+ def logger
23
+ @@logger ||= nil
24
+ end
10
25
 
11
- def logger; @@logger ||= nil; end
12
- def logger=(input); @@logger = input; end
26
+ def logger=(input)
27
+ @@logger = input
28
+ end
13
29
 
14
30
  def options
15
31
  {
16
- :adapter => adapter,
17
- :logger => logger,
18
- :protocol => protocol,
19
- :response_format => response_format,
20
- :url => url,
21
- :version => version
32
+ adapter: adapter,
33
+ logger: logger,
34
+ protocol: protocol,
35
+ response_format: response_format,
36
+ url: url,
37
+ version: version,
38
+ client_id: client_id
22
39
  }
23
40
  end
24
41
 
25
- def performers(*args); new.performers(*args); end
42
+ def performers(*args)
43
+ new.performers(*args)
44
+ end
45
+
46
+ def protocol
47
+ @@protocol ||= :https
48
+ end
26
49
 
27
- def protocol; @@protocol ||= :http; end
28
- def protocol=(input); @@protocol = input; end
50
+ def protocol=(input)
51
+ @@protocol = input
52
+ end
29
53
 
30
- def response_format; @@response_format ||= :ruby; end
31
- def response_format=(input); @@response_format = input; end
54
+ def response_format
55
+ @@response_format ||= :ruby
56
+ end
32
57
 
33
- def taxonomies(*args); new.taxonomies(*args); end
58
+ def response_format=(input)
59
+ @@response_format = input
60
+ end
34
61
 
35
- def url; @@url ||= "api.seatgeek.com"; end
36
- def url=(input); @@url = input; end
62
+ def taxonomies(*args)
63
+ new.taxonomies(*args)
64
+ end
37
65
 
38
- def venues(*args); new.venues(*args); end
66
+ def url
67
+ @@url ||= 'api.seatgeek.com'
68
+ end
39
69
 
40
- def version; @@version ||= 2; end
41
- def version=(input); @@version = input; end
70
+ def url=(input)
71
+ @@url = input
72
+ end
73
+
74
+ def venues(*args)
75
+ new.venues(*args)
76
+ end
77
+
78
+ def version
79
+ @@version ||= 2
80
+ end
81
+
82
+ def version=(input)
83
+ @@version = input
84
+ end
85
+
86
+ def client_id
87
+ @@client_id ||= nil
88
+ end
89
+
90
+ def client_id=(input)
91
+ @@client_id = input
92
+ end
42
93
  end
43
94
 
44
95
  def initialize(options = {})
@@ -54,26 +105,25 @@ module SeatGeek
54
105
  end
55
106
 
56
107
  def handle_response(response)
57
- if response_format == :ruby and response.status == 200
108
+ if response_format == :ruby && response.status == 200
58
109
  MultiJson.decode(response.body)
59
110
  else
60
- {:status => response.status, :body => response.body}
111
+ { status: response.status, body: response.body }
61
112
  end
62
113
  end
63
114
 
64
- # Ruby 1.8.7 / ree compatibility
65
- def id
66
- @options[:id]
67
- end
68
-
69
115
  def performers(params = {})
70
116
  request('/performers', params)
71
117
  end
72
118
 
73
119
  def request(url, params)
120
+ raise 'You must provide a `client_id` for SeatGeek' unless client_id || params[:client_id]
74
121
  handle_response(Faraday.new(*builder(url, params.clone)) do |build|
75
- build.adapter adapter
122
+ if client_id
123
+ build.use Faraday::Request::BasicAuthentication, client_id, nil
124
+ end
76
125
  build.use Faraday::Response::VerboseLogger, logger unless logger.nil?
126
+ build.adapter adapter
77
127
  end.get)
78
128
  end
79
129
 
@@ -100,15 +150,14 @@ module SeatGeek
100
150
  end
101
151
 
102
152
  def builder(uri_segment, params)
103
- return [
153
+ [
104
154
  uri([].tap do |part|
105
- part << "/events"
155
+ part << uri_segment
106
156
  part << "/#{params.delete(:id)}" unless params[:id].nil?
107
157
  end.join),
108
158
  {
109
- :params => custom_options.merge((
110
- [:jsonp, :xml].include?(response_format) ? \
111
- params.merge(:format => response_format) : params))
159
+ params: custom_options.merge((
160
+ [:jsonp, :xml].include?(response_format) ? params.merge(format: response_format) : params))
112
161
  }
113
162
  ]
114
163
  end
@@ -1,3 +1,5 @@
1
+ ##
2
+ # Module: SeatGeek
1
3
  module SeatGeek
2
- VERSION = "0.1.1"
4
+ VERSION = '1.0.2'
3
5
  end
@@ -0,0 +1 @@
1
+ {"meta":{"per_page":1,"total":63188,"page":1,"took":4,"geolocation":null},"events":[{"stats":{"listing_count":0,"average_price":0,"lowest_price":null,"highest_price":null},"relative_url":"/palm-beach-cardinals-at-jupiter-hammerheads-tickets/minor-league-baseball/2012-05-14/798459/","title":"Palm Beach Cardinals at Jupiter Hammerheads","url":"https://seatgeek.com/palm-beach-cardinals-at-jupiter-hammerheads-tickets/minor-league-baseball/2012-05-14/798459/","datetime_local":"2012-05-14T10:35:00","performers":[{"away_team":true,"name":"Palm Beach Cardinals","url":"https://seatgeek.com/palm-beach-cardinals-tickets/","image":null,"short_name":"Palm Beach Cardinals","slug":"palm-beach-cardinals","score":0,"images":[],"type":"minor_league_baseball","id":9420},{"home_team":true,"name":"Jupiter Hammerheads","url":"https://seatgeek.com/jupiter-hammerheads-tickets/","image":null,"short_name":"Jupiter Hammerheads","primary":true,"slug":"jupiter-hammerheads","score":0,"images":[],"type":"minor_league_baseball","id":9421}],"venue":{"city":"Jupiter","name":"Roger Dean Stadium","url":"https://seatgeek.com/roger-dean-stadium-tickets/","country":"US","state":"FL","score":16592,"postal_code":"33468","location":{"lat":26.8936,"lon":-80.1156},"extended_address":null,"address":"4751 Main St","id":3927},"short_title":"Palm Beach Cardinals at Jupiter Hammerheads","datetime_utc":"2012-05-14T14:35:00","score":0,"taxonomies":[{"parent_id":null,"id":1000000,"name":"sports"},{"parent_id":1000000,"id":1010000,"name":"baseball"},{"parent_id":1010000,"id":1010300,"name":"minor_league_baseball"}],"type":"minor_league_baseball","id":798459}]}
@@ -3,280 +3,339 @@ require 'ostruct'
3
3
 
4
4
  describe SeatGeek::Connection do
5
5
  let(:klass) { SeatGeek::Connection }
6
- let(:instance) { klass.new }
6
+ let(:instance) { klass.new(client_id: 'foobar') }
7
7
 
8
- describe ".adapter" do
8
+ describe '.adapter' do
9
9
  subject { klass.adapter }
10
10
  let(:default) { :net_http }
11
11
 
12
12
  it { should == default }
13
- it "should be writable" do
13
+ it 'should be writable' do
14
14
  klass.adapter = :typhoeus
15
- klass.adapter.should == :typhoeus
15
+ expect(klass.adapter).to eq(:typhoeus)
16
16
  end
17
17
 
18
18
  after { klass.adapter = default }
19
19
  end
20
20
 
21
- describe ".events" do
22
- it "proxies to #events" do
23
- klass.any_instance.should_receive(:events).and_return(nil)
21
+ describe '.events' do
22
+ it 'proxies to #events' do
23
+ expect_any_instance_of(klass).to receive(:events).and_return(nil)
24
24
  klass.events
25
25
  end
26
26
 
27
- it "passes any attributes to #events" do
28
- klass.any_instance.should_receive(:events).with(1, 2).and_return(nil)
27
+ it 'passes any attributes to #events' do
28
+ expect_any_instance_of(klass).to receive(:events).with(1, 2)
29
+ .and_return(nil)
29
30
  klass.events(1, 2)
30
31
  end
31
32
  end
32
33
 
33
- describe ".logger" do
34
+ describe '.logger' do
34
35
  subject { klass.logger }
35
36
  let(:default) { nil }
36
37
  let(:logger) { Logger.new(STDOUT) }
37
38
 
38
39
  it { should == default }
39
- it "should be writable" do
40
+ it 'should be writable' do
40
41
  klass.logger = logger
41
- klass.logger.should == logger
42
+ expect(klass.logger).to eq(logger)
42
43
  end
43
44
 
44
45
  after { klass.logger = default }
45
46
  end
46
47
 
47
- describe ".options" do
48
- it "should return a hash of all of the class level settings" do
49
- klass.options.should == {
50
- :adapter => :net_http,
51
- :logger => nil,
52
- :protocol => :http,
53
- :response_format => :ruby,
54
- :url => "api.seatgeek.com",
55
- :version => 2
56
- }
48
+ describe '.options' do
49
+ it 'should return a hash of all of the class level settings' do
50
+ expect(klass.options).to eq(
51
+ adapter: :net_http,
52
+ logger: nil,
53
+ protocol: :https,
54
+ response_format: :ruby,
55
+ url: 'api.seatgeek.com',
56
+ version: 2,
57
+ client_id: nil
58
+ )
57
59
  end
58
60
  end
59
61
 
60
- describe ".performers" do
61
- it "proxies to #performers" do
62
- klass.any_instance.should_receive(:performers).and_return(nil)
62
+ describe '.performers' do
63
+ it 'proxies to #performers' do
64
+ expect_any_instance_of(klass).to receive(:performers).and_return(nil)
63
65
  klass.performers
64
66
  end
65
67
 
66
- it "passes any attributes to #performers" do
67
- klass.any_instance.should_receive(:performers).with(1, 2).and_return(nil)
68
+ it 'passes any attributes to #performers' do
69
+ expect_any_instance_of(klass).to receive(:performers).with(1, 2)
70
+ .and_return(nil)
68
71
  klass.performers(1, 2)
69
72
  end
70
73
  end
71
74
 
72
- describe ".protocol" do
75
+ describe '.protocol' do
73
76
  subject { klass.protocol }
74
- let(:default) { :http }
77
+ let(:default) { :https }
75
78
 
76
79
  it { should == default }
77
- it "should be writable" do
80
+ it 'should be writable' do
78
81
  klass.protocol = :https
79
- klass.protocol.should == :https
82
+ expect(klass.protocol).to eq(:https)
80
83
  end
81
84
 
82
85
  after { klass.protocol = default }
83
86
  end
84
87
 
85
- describe ".response_format" do
88
+ describe '.client_id' do
89
+ subject { klass.client_id }
90
+ let(:default) { nil }
91
+
92
+ it { should == default }
93
+ it 'should be writable' do
94
+ klass.client_id = 'some_client_id'
95
+ expect(klass.client_id).to eq('some_client_id')
96
+ end
97
+
98
+ after { klass.client_id = default }
99
+ end
100
+
101
+ describe '.response_format' do
86
102
  subject { klass.response_format }
87
103
  let(:default) { :ruby }
88
104
 
89
105
  it { should == default }
90
- it "should be writable" do
106
+ it 'should be writable' do
91
107
  klass.response_format = :jsonp
92
- klass.response_format.should == :jsonp
108
+ expect(klass.response_format).to eq(:jsonp)
93
109
  end
94
110
 
95
111
  after { klass.response_format = default }
96
112
  end
97
113
 
98
- describe ".taxonomies" do
99
- it "proxies to #taxonomies" do
100
- klass.any_instance.should_receive(:taxonomies).and_return(nil)
114
+ describe '.taxonomies' do
115
+ it 'proxies to #taxonomies' do
116
+ expect_any_instance_of(klass).to receive(:taxonomies).and_return(nil)
101
117
  klass.taxonomies
102
118
  end
103
119
 
104
- it "passes any attributes to #taxonomies" do
105
- klass.any_instance.should_receive(:taxonomies).with(1, 2).and_return(nil)
120
+ it 'passes any attributes to #taxonomies' do
121
+ expect_any_instance_of(klass).to receive(:taxonomies).with(1, 2)
122
+ .and_return(nil)
106
123
  klass.taxonomies(1, 2)
107
124
  end
108
125
  end
109
126
 
110
- describe ".url" do
127
+ describe '.url' do
111
128
  subject { klass.url }
112
- let(:default) { "api.seatgeek.com" }
129
+ let(:default) { 'api.seatgeek.com' }
113
130
 
114
131
  it { should == default }
115
- it "should be writable" do
116
- klass.url = "ticketevolution.com"
117
- klass.url.should == "ticketevolution.com"
132
+ it 'should be writable' do
133
+ klass.url = 'ticketevolution.com'
134
+ expect(klass.url).to eq('ticketevolution.com')
118
135
  end
119
136
 
120
137
  after { klass.url = default }
121
138
  end
122
139
 
123
- describe ".venues" do
124
- it "proxies to #venues" do
125
- klass.any_instance.should_receive(:venues).and_return(nil)
140
+ describe '.venues' do
141
+ it 'proxies to #venues' do
142
+ expect_any_instance_of(klass).to receive(:venues).and_return(nil)
126
143
  klass.venues
127
144
  end
128
145
 
129
- it "passes any attributes to #venues" do
130
- klass.any_instance.should_receive(:venues).with(1, 2).and_return(nil)
146
+ it 'passes any attributes to #venues' do
147
+ expect_any_instance_of(klass).to receive(:venues).with(1, 2)
148
+ .and_return(nil)
131
149
  klass.venues(1, 2)
132
150
  end
133
151
  end
134
152
 
135
- describe ".version" do
153
+ describe '.version' do
136
154
  subject { klass.version }
137
155
  let(:default) { 2 }
138
156
 
139
157
  it { should == 2 }
140
- it "should be writable" do
158
+ it 'should be writable' do
141
159
  klass.version = 1
142
- klass.version.should == 1
160
+ expect(klass.version).to eq(1)
143
161
  end
144
162
 
145
163
  after { klass.version = default }
146
164
  end
147
165
 
148
- describe "#initialize" do
166
+ describe '#initialize' do
149
167
  let(:expected) { klass.options.merge(options) }
150
- let(:options) { { :testing => 123, :clone => :hello } }
151
- let(:str_options) { {}.tap{|o| options.each{|k, v| o[k.to_s] = v}} }
168
+ let(:options) { { testing: 123, clone: 'hello', client_id: 'some_data' } }
169
+ let(:str_options) { {}.tap { |o| options.each { |k, v| o[k.to_s] = v } } }
152
170
  let(:instance) { klass.new(options) }
153
171
 
154
- it "should take options passed and store them on top of the class options hash" do
155
- instance.instance_eval('@options').should == expected
172
+ it 'should take options passed and store '\
173
+ 'them on top of the class options hash' do
174
+ expect(instance.instance_eval('@options')).to eq(expected)
156
175
  end
157
176
 
158
- it "should convert the keys passed to symbols" do
159
- klass.new(str_options).instance_eval('@options').should == expected
177
+ it 'should convert the keys passed to symbols' do
178
+ expect(klass.new(str_options).instance_eval('@options')).to eq(expected)
160
179
  end
161
180
 
162
- it "should serve options up via read accessor methods unless the methods already exist" do
163
- instance.testing.should == options[:testing]
164
- instance.clone.should_not == options[:clone]
181
+ it 'should serve options up via read accessor '\
182
+ 'methods unless the methods already exist' do
183
+ expect(instance.testing).to eq(options[:testing])
184
+ expect(instance.clone).not_to eq(options[:clone])
165
185
  end
166
186
  end
167
187
 
168
- describe "#events" do
169
- let(:url) { '/events'}
170
- let(:params) { {:test => 123} }
188
+ describe '#events' do
189
+ let(:url) { '/events' }
190
+ let(:params) { { test: 123 } }
171
191
 
172
- it "should call #request with the correct url segment and the params passed" do
173
- instance.should_receive(:request).with(url, params)
192
+ it 'should call #request with the correct'\
193
+ 'url segment and the params passed' do
194
+ expect(instance).to receive(:request).with(url, params)
174
195
  instance.events(params)
175
196
  end
176
197
  end
177
198
 
178
- describe "#handle_response" do
179
- let(:response) { double(Faraday::Response, :status => status, :body => body)}
199
+ describe '#handle_response' do
200
+ let(:response) { double(Faraday::Response, status: status, body: body) }
180
201
 
181
- context "when response_format is set to ruby" do
182
- context "and the request was successful" do
202
+ context 'when response_format is set to ruby' do
203
+ context 'and the request was successful' do
183
204
  let(:status) { 200 }
184
- let(:body) { "{\"meta\":{\"per_page\":1,\"total\":63188,\"page\":1,\"took\":4,\"geolocation\":null},\"events\":[{\"stats\":{\"listing_count\":0,\"average_price\":0,\"lowest_price\":null,\"highest_price\":null},\"relative_url\":\"/palm-beach-cardinals-at-jupiter-hammerheads-tickets/minor-league-baseball/2012-05-14/798459/\",\"title\":\"Palm Beach Cardinals at Jupiter Hammerheads\",\"url\":\"http://seatgeek.com/palm-beach-cardinals-at-jupiter-hammerheads-tickets/minor-league-baseball/2012-05-14/798459/\",\"datetime_local\":\"2012-05-14T10:35:00\",\"performers\":[{\"away_team\":true,\"name\":\"Palm Beach Cardinals\",\"url\":\"http://seatgeek.com/palm-beach-cardinals-tickets/\",\"image\":null,\"short_name\":\"Palm Beach Cardinals\",\"slug\":\"palm-beach-cardinals\",\"score\":0,\"images\":[],\"type\":\"minor_league_baseball\",\"id\":9420},{\"home_team\":true,\"name\":\"Jupiter Hammerheads\",\"url\":\"http://seatgeek.com/jupiter-hammerheads-tickets/\",\"image\":null,\"short_name\":\"Jupiter Hammerheads\",\"primary\":true,\"slug\":\"jupiter-hammerheads\",\"score\":0,\"images\":[],\"type\":\"minor_league_baseball\",\"id\":9421}],\"venue\":{\"city\":\"Jupiter\",\"name\":\"Roger Dean Stadium\",\"url\":\"http://seatgeek.com/roger-dean-stadium-tickets/\",\"country\":\"US\",\"state\":\"FL\",\"score\":16592,\"postal_code\":\"33468\",\"location\":{\"lat\":26.8936,\"lon\":-80.1156},\"extended_address\":null,\"address\":\"4751 Main St\",\"id\":3927},\"short_title\":\"Palm Beach Cardinals at Jupiter Hammerheads\",\"datetime_utc\":\"2012-05-14T14:35:00\",\"score\":0,\"taxonomies\":[{\"parent_id\":null,\"id\":1000000,\"name\":\"sports\"},{\"parent_id\":1000000,\"id\":1010000,\"name\":\"baseball\"},{\"parent_id\":1010000,\"id\":1010300,\"name\":\"minor_league_baseball\"}],\"type\":\"minor_league_baseball\",\"id\":798459}]}" }
205
+ let(:body) { File.read('spec/fixtures/handle_response.json') }
185
206
 
186
- it "should parse the json returned and respond with a ruby object" do
187
- instance.handle_response(response).should == MultiJson.decode(body)
207
+ it 'should parse the json returned and respond with a ruby object' do
208
+ expect(instance.handle_response(response))
209
+ .to eq(MultiJson.decode(body))
188
210
  end
189
211
  end
190
212
 
191
- context "and the request was not successful" do
213
+ context 'and the request was not successful' do
192
214
  let(:status) { 500 }
193
- let(:body) { "Internal Server Error" }
215
+ let(:body) { 'Internal Server Error' }
194
216
 
195
- it "should return the status code and exact result body" do
196
- instance.handle_response(response).should == {:status => status, :body => body}
217
+ it 'should return the status code and exact result body' do
218
+ expect(instance.handle_response(response))
219
+ .to eq(status: status, body: body)
197
220
  end
198
221
  end
199
222
  end
200
223
 
201
- context "when response format is not set to ruby" do
224
+ context 'when response format is not set to ruby' do
202
225
  let(:status) { 200 }
203
- let(:body) { "{\"meta\":{\"per_page\":1,\"total\":63188,\"page\":1,\"took\":4,\"geolocation\":null},\"events\":[{\"stats\":{\"listing_count\":0,\"average_price\":0,\"lowest_price\":null,\"highest_price\":null},\"relative_url\":\"/palm-beach-cardinals-at-jupiter-hammerheads-tickets/minor-league-baseball/2012-05-14/798459/\",\"title\":\"Palm Beach Cardinals at Jupiter Hammerheads\",\"url\":\"http://seatgeek.com/palm-beach-cardinals-at-jupiter-hammerheads-tickets/minor-league-baseball/2012-05-14/798459/\",\"datetime_local\":\"2012-05-14T10:35:00\",\"performers\":[{\"away_team\":true,\"name\":\"Palm Beach Cardinals\",\"url\":\"http://seatgeek.com/palm-beach-cardinals-tickets/\",\"image\":null,\"short_name\":\"Palm Beach Cardinals\",\"slug\":\"palm-beach-cardinals\",\"score\":0,\"images\":[],\"type\":\"minor_league_baseball\",\"id\":9420},{\"home_team\":true,\"name\":\"Jupiter Hammerheads\",\"url\":\"http://seatgeek.com/jupiter-hammerheads-tickets/\",\"image\":null,\"short_name\":\"Jupiter Hammerheads\",\"primary\":true,\"slug\":\"jupiter-hammerheads\",\"score\":0,\"images\":[],\"type\":\"minor_league_baseball\",\"id\":9421}],\"venue\":{\"city\":\"Jupiter\",\"name\":\"Roger Dean Stadium\",\"url\":\"http://seatgeek.com/roger-dean-stadium-tickets/\",\"country\":\"US\",\"state\":\"FL\",\"score\":16592,\"postal_code\":\"33468\",\"location\":{\"lat\":26.8936,\"lon\":-80.1156},\"extended_address\":null,\"address\":\"4751 Main St\",\"id\":3927},\"short_title\":\"Palm Beach Cardinals at Jupiter Hammerheads\",\"datetime_utc\":\"2012-05-14T14:35:00\",\"score\":0,\"taxonomies\":[{\"parent_id\":null,\"id\":1000000,\"name\":\"sports\"},{\"parent_id\":1000000,\"id\":1010000,\"name\":\"baseball\"},{\"parent_id\":1010000,\"id\":1010300,\"name\":\"minor_league_baseball\"}],\"type\":\"minor_league_baseball\",\"id\":798459}]}" }
226
+ let(:body) { File.read('spec/fixtures/handle_response.json') }
204
227
 
205
- it "should return the status code and exact result body" do
206
- klass.new(:response_format => :json).\
207
- handle_response(response).should == {:status => status, :body => body}
228
+ it 'should return the status code and exact result body' do
229
+ expect(klass.new(response_format: :json).handle_response(response))
230
+ .to eq(status: status, body: body)
208
231
  end
209
232
  end
210
233
  end
211
234
 
212
- describe "#performers" do
213
- let(:url) { '/performers'}
214
- let(:params) { {:test => 123} }
235
+ describe '#performers' do
236
+ let(:url) { '/performers' }
237
+ let(:params) { { test: 123 } }
215
238
 
216
- it "should call #request with the correct url segment and the params passed" do
217
- instance.should_receive(:request).with(url, params)
239
+ it 'should call #request with the correct '\
240
+ 'url segment and the params passed' do
241
+ expect(instance).to receive(:request).with(url, params)
218
242
  instance.performers(params)
219
243
  end
220
244
  end
221
245
 
222
- describe "#request" do
223
- let(:url) { 'http://api.seatgeek.com/2/events' }
246
+ describe '#request' do
247
+ let(:uri_segment) { '/venues' }
248
+ let(:url) { "https://api.seatgeek.com/2#{uri_segment}" }
224
249
  let(:params) { {} }
225
- let(:faraday) { mock(:faraday, :get => OpenStruct.new({:status => 200, :body => "[]"})) }
250
+ let(:faraday) { double(:faraday, get: OpenStruct.new(status: 200, body: '[]')) }
251
+
252
+ context 'when .client_id is not set as class property' do
253
+ let(:instance) { klass.new }
254
+ let(:expected_params) { { params: params.merge(format: :jsonp) } }
255
+
256
+ it 'should throw an exception' do
257
+ expect { instance.request(uri_segment, params) }
258
+ .to raise_error('You must provide a `client_id` for SeatGeek')
259
+ end
260
+
261
+ it 'should not throw an exception if provided in paramters' do
262
+ expect {
263
+ params[:client_id] = 'foobar'
264
+ instance.request(uri_segment, params)
265
+ }.to_not raise_error
266
+ end
267
+ end
268
+
269
+ context 'when .response_format is jsonp' do
270
+ let(:instance) { klass.new(response_format: :jsonp, client_id: 'foobar') }
271
+ let(:expected_params) { { params: params.merge(format: :jsonp) } }
272
+
273
+ it 'should set the format param to jsonp' do
274
+ expect(Faraday).to receive(:new).with(url, expected_params)
275
+ .and_return(faraday)
276
+ instance.request(uri_segment, params)
277
+ end
278
+ end
226
279
 
227
- context "when .response_format is jsonp" do
228
- let(:instance) { klass.new({:response_format => :jsonp}) }
229
- let(:expected_params) { {:params => params.merge({:format => :jsonp})} }
280
+ context 'when .response_format is xml' do
281
+ let(:instance) { klass.new(response_format: :xml, client_id: 'foobar') }
282
+ let(:expected_params) { { params: params.merge(format: :xml) } }
230
283
 
231
- it "should set the format param to jsonp" do
232
- Faraday.should_receive(:new).with(url, expected_params).and_return(faraday)
233
- instance.request(url, params)
284
+ it 'should set the format param to xml' do
285
+ expect(Faraday).to receive(:new).with(url, expected_params)
286
+ .and_return(faraday)
287
+ instance.request(uri_segment, params)
234
288
  end
235
289
  end
236
290
 
237
- context "when .response_format is xml" do
238
- let(:instance) { klass.new({:response_format => :xml}) }
239
- let(:expected_params) { {:params => params.merge({:format => :xml})} }
291
+ context 'when additional parameters were passed to #initialize' do
292
+ let(:instance) { klass.new(response_format: :jsonp, testing: 123, client_id: 'foobar') }
293
+ let(:expected_params) { { params: params.merge(format: :jsonp, testing: 123)} }
240
294
 
241
- it "should set the format param to xml" do
242
- Faraday.should_receive(:new).with(url, expected_params).and_return(faraday)
243
- instance.request(url, params)
295
+ it 'should add those parameters to the request params' do
296
+ expect(Faraday).to receive(:new).with(url, expected_params)
297
+ .and_return(faraday)
298
+ instance.request(uri_segment, params)
244
299
  end
245
300
  end
246
301
 
247
- context "when additional parameters were passed to #initialize" do
248
- let(:instance) { klass.new({:response_format => :jsonp, :testing => 123}) }
249
- let(:expected_params) { {:params => params.merge({:format => :jsonp, :testing => 123})} }
302
+ context 'when client_id was passed as a parameter' do
303
+ let(:instance) { klass.new }
304
+ let(:params) { { client_id: 'foobar' } }
305
+ let(:expected_params) { { params: params.merge(client_id: 'foobar') } }
250
306
 
251
- it "should add those parameters to the request params" do
252
- Faraday.should_receive(:new).with(url, expected_params).and_return(faraday)
253
- instance.request(url, params)
307
+ it 'should make the request with the client_id parameter set' do
308
+ expect(Faraday).to receive(:new).with(url, expected_params)
309
+ .and_return(faraday)
310
+ instance.request(uri_segment, params)
254
311
  end
255
312
  end
256
313
  end
257
314
 
258
- describe "#taxonomies" do
259
- let(:url) { '/taxonomies'}
260
- let(:params) { {:test => 123} }
315
+ describe '#taxonomies' do
316
+ let(:url) { '/taxonomies' }
317
+ let(:params) { { test: 123 } }
261
318
 
262
- it "should call #request with the correct url segment and the params passed" do
263
- instance.should_receive(:request).with(url, params)
319
+ it 'should call #request with the correct '\
320
+ 'url segment and the params passed' do
321
+ expect(instance).to receive(:request).with(url, params)
264
322
  instance.taxonomies(params)
265
323
  end
266
324
  end
267
325
 
268
- describe "#uri" do
269
- it "should take in a path and combine it with protocol, url and version" do
270
- instance.uri('/events').should == "http://api.seatgeek.com/2/events"
326
+ describe '#uri' do
327
+ it 'should take in a path and combine it with protocol, url and version' do
328
+ expect(instance.uri('/events')).to eq('https://api.seatgeek.com/2/events')
271
329
  end
272
330
  end
273
331
 
274
- describe "#venues" do
275
- let(:url) { '/venues'}
276
- let(:params) { {:test => 123} }
332
+ describe '#venues' do
333
+ let(:url) { '/venues' }
334
+ let(:params) { { test: 123 } }
277
335
 
278
- it "should call #request with the correct url segment and the params passed" do
279
- instance.should_receive(:request).with(url, params)
336
+ it 'should call #request with the correct '\
337
+ 'url segment and the params passed' do
338
+ expect(instance).to receive(:request).with(url, params)
280
339
  instance.venues(params)
281
340
  end
282
341
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe SeatGeek::VERSION do
4
- it "should match a three segment version number format" do
5
- subject.should =~ /^\d+\.\d+\.\d+(rc\d+)?$/
4
+ it 'should match a three segment version number format' do
5
+ expect(subject).to match(/^\d+\.\d+\.\d+(rc\d+)?$/)
6
6
  end
7
7
  end
@@ -2,6 +2,6 @@ require 'spec_helper'
2
2
 
3
3
  describe SG do
4
4
  it "should be a subclass of SeatGeek::Connection" do
5
- SG.ancestors.should include SeatGeek::Connection
5
+ expect(SG.ancestors).to include(SeatGeek::Connection)
6
6
  end
7
7
  end
@@ -1,7 +1,6 @@
1
1
  require 'seatgeek'
2
2
 
3
3
  RSpec.configure do |config|
4
- config.treat_symbols_as_metadata_keys_with_true_values = true
5
4
  config.run_all_when_everything_filtered = true
6
5
  config.filter_run :focus
7
6
  end
metadata CHANGED
@@ -1,71 +1,85 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: seatgeek
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
5
- prerelease:
4
+ version: 1.0.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - Dan Matthews
9
- autorequire:
8
+ autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-05-15 00:00:00.000000000Z
11
+ date: 2020-07-13 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: faraday
16
- requirement: &70345881699200 !ruby/object:Gem::Requirement
17
- none: false
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
- version_requirements: *70345881699200
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
25
27
  - !ruby/object:Gem::Dependency
26
28
  name: multi_json
27
- requirement: &70345881697820 !ruby/object:Gem::Requirement
28
- none: false
29
+ requirement: !ruby/object:Gem::Requirement
29
30
  requirements:
30
- - - ! '>='
31
+ - - ">="
31
32
  - !ruby/object:Gem::Version
32
33
  version: '0'
33
34
  type: :runtime
34
35
  prerelease: false
35
- version_requirements: *70345881697820
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
36
41
  - !ruby/object:Gem::Dependency
37
42
  name: rake
38
- requirement: &70345881696440 !ruby/object:Gem::Requirement
39
- none: false
43
+ requirement: !ruby/object:Gem::Requirement
40
44
  requirements:
41
- - - ! '>='
45
+ - - ">="
42
46
  - !ruby/object:Gem::Version
43
47
  version: '0'
44
48
  type: :runtime
45
49
  prerelease: false
46
- version_requirements: *70345881696440
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
47
55
  - !ruby/object:Gem::Dependency
48
56
  name: yajl-ruby
49
- requirement: &70345881695420 !ruby/object:Gem::Requirement
50
- none: false
57
+ requirement: !ruby/object:Gem::Requirement
51
58
  requirements:
52
- - - ! '>='
59
+ - - ">="
53
60
  - !ruby/object:Gem::Version
54
61
  version: '0'
55
62
  type: :runtime
56
63
  prerelease: false
57
- version_requirements: *70345881695420
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
58
69
  - !ruby/object:Gem::Dependency
59
70
  name: rspec
60
- requirement: &70345881693420 !ruby/object:Gem::Requirement
61
- none: false
71
+ requirement: !ruby/object:Gem::Requirement
62
72
  requirements:
63
- - - ! '>='
73
+ - - ">="
64
74
  - !ruby/object:Gem::Version
65
75
  version: '0'
66
76
  type: :development
67
77
  prerelease: false
68
- version_requirements: *70345881693420
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  description: This gem provides Ruby functionality around the SeatGeek Platform API
70
84
  (http://platform.seatgeek.com). It is designed to be framework agnostic and was
71
85
  originally developed for use in my day job at Ticket Evolution.
@@ -75,54 +89,48 @@ executables: []
75
89
  extensions: []
76
90
  extra_rdoc_files: []
77
91
  files:
78
- - .gitignore
79
- - .rdebugrc
80
- - .rspec
81
- - .travis.yml
92
+ - ".gitignore"
93
+ - ".rdebugrc"
94
+ - ".rspec"
95
+ - ".travis.yml"
82
96
  - Gemfile
83
97
  - Gemfile.lock
84
- - README.markdown
98
+ - README.md
85
99
  - Rakefile
86
100
  - lib/faraday/response/verbose_logger.rb
87
101
  - lib/seat_geek/connection.rb
88
102
  - lib/seat_geek/version.rb
89
103
  - lib/seatgeek.rb
90
104
  - seatgeek.gemspec
105
+ - spec/fixtures/handle_response.json
91
106
  - spec/lib/seat_geek/connection_spec.rb
92
107
  - spec/lib/seat_geek/version_spec.rb
93
108
  - spec/lib/sg_spec.rb
94
109
  - spec/spec_helper.rb
95
110
  homepage: http://platform.seatgeek.com
96
111
  licenses: []
97
- post_install_message:
112
+ metadata: {}
113
+ post_install_message:
98
114
  rdoc_options: []
99
115
  require_paths:
100
116
  - lib
101
117
  required_ruby_version: !ruby/object:Gem::Requirement
102
- none: false
103
118
  requirements:
104
- - - ! '>='
119
+ - - ">="
105
120
  - !ruby/object:Gem::Version
106
121
  version: '0'
107
- segments:
108
- - 0
109
- hash: 2766271802599134346
110
122
  required_rubygems_version: !ruby/object:Gem::Requirement
111
- none: false
112
123
  requirements:
113
- - - ! '>='
124
+ - - ">="
114
125
  - !ruby/object:Gem::Version
115
126
  version: '0'
116
- segments:
117
- - 0
118
- hash: 2766271802599134346
119
127
  requirements: []
120
- rubyforge_project: seatgeek
121
- rubygems_version: 1.8.6
122
- signing_key:
123
- specification_version: 3
128
+ rubygems_version: 3.1.2
129
+ signing_key:
130
+ specification_version: 4
124
131
  summary: A Ruby wrapper for the SeatGeek Platform API.
125
132
  test_files:
133
+ - spec/fixtures/handle_response.json
126
134
  - spec/lib/seat_geek/connection_spec.rb
127
135
  - spec/lib/seat_geek/version_spec.rb
128
136
  - spec/lib/sg_spec.rb