seat_geek 0.1.2 → 0.2.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: ea41a101294062bebeb0f73563c0efe3a60934e0
4
- data.tar.gz: ae3e79442c6242bea62389bd24e143e00cc25086
3
+ metadata.gz: 2948f960f825823a7598c6eae02d7d2475db8b79
4
+ data.tar.gz: 84d75b6802dfe4a40f1630e697b6de185ce9079f
5
5
  SHA512:
6
- metadata.gz: 965a6bad3577dcc0d253105533f921c30172b450fb08b30a164b4cc594845bae24655220b5257d29c0fab3b11dfa8d4ca1b8dc9716529f38cbce7348d0bb9cea
7
- data.tar.gz: d32ee77fa59dfdc0212bb15267e26429d6e1ab0c773701deb77baa35b9c6799ad8b2e460ba6110568f7bddcedb89b58669475c1696e801790744af4eafbc080a
6
+ metadata.gz: 89e068f2610a4dd3a0b48b44a2a7bc1afaa960445acbed6f5b566e89b302e47ff97006b103cb84b08c09bd8fd949ec99809ddd6b2fa2539b5d6b05e038dcf01f
7
+ data.tar.gz: d9433e8a40128f3cbad0062ea5e57a686a069e33944393ba767f9bbbb04bda648b046e6711396afdd2f1f0685b05b8eedd5c1b218551b182e67e816d319c0e62
data/.gitignore CHANGED
@@ -7,3 +7,5 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ /seat_geek-/
11
+ /byebug_history/
@@ -0,0 +1,55 @@
1
+ module SeatGeek
2
+ class BuildQuery
3
+
4
+ def self.build(options)
5
+ query = ""
6
+ if options[:month_of_the_year]
7
+ query = month_query(month_of_the_year)
8
+ end
9
+ if options[:state]
10
+ query = '?' unless query.match(/\?/)
11
+ query = query + location_query(state)
12
+ end
13
+ if options[:attendee_count]
14
+ query = '?' unless query.match(/\?/)
15
+ query = query + attendee_count_query(attendee_count)
16
+ end
17
+ if options[:event_type]
18
+ query = '?' unless query.match(/\?/)
19
+ query = query + event_type_query(event_type)
20
+ end
21
+ options[:base_url] + query
22
+ end
23
+
24
+ private
25
+
26
+ # Events in April 2012
27
+ # $ curl 'http://api.seatgeek.com/2/events?datetime_utc.gte=2012-04-01&datetime_utc.lte=2012-04-30'
28
+ def month_query(year_month)
29
+ year, month = year_month.split('-')
30
+ year = year.to_i
31
+ month = month.to_i
32
+ first_day_of_month = Date.civil(year, month, 1).strftime('%F')
33
+ last_day_of_month = Date.civil(year, month, -1).strftime('%F')
34
+
35
+ "?datetime_utc.gte=#{first_day_of_month}&datetime_utc.lte=#{last_day_of_month}"
36
+ end
37
+
38
+ # Events in NY state
39
+ # $ curl 'http://api.seatgeek.com/2/events?venue.state=NY'
40
+ def location_query(location)
41
+ "&venue.state=#{location}"
42
+ end
43
+
44
+ # GET http://api.seatgeek.com/2/events?listing_count.gt=0
45
+ def attendee_count_query(count)
46
+ "&listing_count.gt=#{count}"
47
+ end
48
+
49
+ # Sporting Events
50
+ # $ curl 'http://api.seatgeek.com/2/events?taxonomies.name=sports'
51
+ def event_type_query(type)
52
+ "&taxonomies.name=#{type}"
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,6 @@
1
+ module SeatGeek
2
+ class Event
3
+ def initialize
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,4 @@
1
+ module SeatGeek
2
+ class EventType
3
+ end
4
+ end
File without changes
@@ -1,3 +1,3 @@
1
1
  module SeatGeek
2
- VERSION = "0.1.2"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/seat_geek.rb CHANGED
@@ -1,73 +1,61 @@
1
1
  require "seat_geek/version"
2
+ require "seat_geek/build_query"
3
+ require 'byebug'
4
+ require 'typhoeus'
5
+ require 'oj'
2
6
 
3
7
  module SeatGeek
4
- SEATGEEK_BASE_URL = 'http://api.seatgeek.com/2/events'
5
- def self.find_events(base_url: nil, month_of_the_year: nil, state: nil, attendee_count: nil, event_type: nil)
6
- @base_url = base_url || SEATGEEK_BASE_URL
8
+ extend self
9
+
10
+ def get_events(base_url: nil, month_of_the_year: nil, state: nil, attendee_count: nil, event_type: nil)
11
+ @base_url = base_url || seatgeek_base_url
7
12
  @month_of_the_year = month_of_the_year
8
13
  @state = state
9
14
  @attendee_count = attendee_count
10
15
  @event_type = event_type
11
16
 
12
- url = base_url + build_query
13
- request = Typhoeus::Request.new(url,
14
- method: :get,
15
- headers: { Accept: "json" }
16
- ).run
17
+ parse_response(typhoeus_request.body)
18
+ end
19
+
20
+ def get_venues
21
+ @base_url = seatgeek_taxonomies_url
22
+ parse_response(typhoeus_request.body)['taxonomies']
17
23
  end
18
24
 
19
25
  private
20
26
 
21
27
  attr_accessor :month_of_the_year, :state, :attendee_count, :event_type, :base_url
22
28
 
23
- # def event_type
24
- # @seat_geek_service = SeatGeekService.new(base_url: SEATGEEK_BASE_URL)
25
- # @seat_geek_service.run['taxonomies']
26
- # end
27
-
28
- def self.build_query
29
- query = ""
30
- if month_of_the_year
31
- query = month_query(month_of_the_year)
32
- end
33
- if state
34
- query = query + location_query(state)
35
- end
36
- if attendee_count
37
- query = query + attendee_count_query(attendee_count)
38
- end
39
- if event_type
40
- query = query + event_type_query(event_type)
41
- end
42
- query
29
+ def build_url
30
+ BuildQuery.build(options)
43
31
  end
44
32
 
45
- # Events in April 2012
46
- # $ curl 'http://api.seatgeek.com/2/events?datetime_utc.gte=2012-04-01&datetime_utc.lte=2012-04-30'
47
- def self.month_query(year_month)
48
- year, month = year_month.split('-')
49
- year = year.to_i
50
- month = month.to_i
51
- first_day_of_month = Date.civil(year, month, 1).strftime('%F')
52
- last_day_of_month = Date.civil(year, month, -1).strftime('%F')
33
+ def typhoeus_request
34
+ request = Typhoeus::Request.new(build_url,
35
+ method: :get,
36
+ headers: { Accept: "json" }
37
+ ).run
38
+ end
53
39
 
54
- "?datetime_utc.gte=#{first_day_of_month}&datetime_utc.lte=#{last_day_of_month}"
40
+ def parse_response(json_string)
41
+ Oj.load(json_string)
55
42
  end
56
43
 
57
- # Events in NY state
58
- # $ curl 'http://api.seatgeek.com/2/events?venue.state=NY'
59
- def self.location_query(location)
60
- "&venue.state=#{location}"
44
+ def seatgeek_base_url
45
+ 'http://api.seatgeek.com/2/events'
61
46
  end
62
47
 
63
- # GET http://api.seatgeek.com/2/events?listing_count.gt=0
64
- def self.attendee_count_query(count)
65
- "&listing_count.gt=#{count}"
48
+ def seatgeek_taxonomies_url
49
+ 'http://api.seatgeek.com/2/taxonomies'
66
50
  end
67
51
 
68
- # Sporting Events
69
- # $ curl 'http://api.seatgeek.com/2/events?taxonomies.name=sports'
70
- def self.event_type_query(type)
71
- "&taxonomies.name=#{type}"
52
+ def options
53
+ {
54
+ base_url: base_url,
55
+ month_of_the_year: month_of_the_year,
56
+ state: state,
57
+ attendee_count: attendee_count,
58
+ event_type: event_type,
59
+ }
72
60
  end
73
61
  end
data/seat_geek.gemspec CHANGED
@@ -21,9 +21,10 @@ Gem::Specification.new do |spec|
21
21
  spec.add_development_dependency "bundler", "~> 1.10"
22
22
  spec.add_development_dependency "rake", "~> 10.0"
23
23
 
24
- spec.add_dependency "oj"
25
24
  spec.add_development_dependency "rspec"
26
25
  spec.add_development_dependency "pry-byebug"
27
- spec.add_development_dependency "typhoeus"
26
+
28
27
  spec.add_runtime_dependency "scoped_attr_accessor"
28
+ spec.add_dependency "typhoeus"
29
+ spec.add_dependency "oj"
29
30
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: seat_geek
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Moon
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-12-14 00:00:00.000000000 Z
11
+ date: 2015-12-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -39,13 +39,13 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: oj
42
+ name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
- type: :runtime
48
+ type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
@@ -53,7 +53,7 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: rspec
56
+ name: pry-byebug
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
@@ -67,13 +67,13 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: pry-byebug
70
+ name: scoped_attr_accessor
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
- type: :development
76
+ type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
@@ -87,7 +87,7 @@ dependencies:
87
87
  - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
- type: :development
90
+ type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
@@ -95,7 +95,7 @@ dependencies:
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
- name: scoped_attr_accessor
98
+ name: oj
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - ">="
@@ -125,14 +125,13 @@ files:
125
125
  - bin/console
126
126
  - bin/setup
127
127
  - lib/seat_geek.rb
128
- - lib/seat_geek/attendee_count.rb
129
- - lib/seat_geek/month_and_year.rb
130
- - lib/seat_geek/state.rb
128
+ - lib/seat_geek/build_query.rb
129
+ - lib/seat_geek/models/attendee_count.rb
130
+ - lib/seat_geek/models/event.rb
131
+ - lib/seat_geek/models/event_type.rb
132
+ - lib/seat_geek/models/month_and_year.rb
133
+ - lib/seat_geek/models/state.rb
131
134
  - lib/seat_geek/version.rb
132
- - seat_geek-0.0.0.gem
133
- - seat_geek-0.0.1.gem
134
- - seat_geek-0.1.0.gem
135
- - seat_geek-0.1.1.gem
136
135
  - seat_geek.gemspec
137
136
  homepage: https://github.com/jmoon90/seat_geek
138
137
  licenses:
data/seat_geek-0.0.0.gem DELETED
Binary file
data/seat_geek-0.0.1.gem DELETED
Binary file
data/seat_geek-0.1.0.gem DELETED
Binary file
data/seat_geek-0.1.1.gem DELETED
Binary file