bike_reg 0.1.1 → 0.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 852a99aa2cac58d8adc6d21bd8ff97a9c43cd1145479a1737d8d7c4269c11742
4
- data.tar.gz: 33a4b446175345941d7888e7fa89dbc2780dad0543e3e5a00178cac33c9fe294
3
+ metadata.gz: 1337681dd224a76ac08af86e576838501b14cfa3350e4a18f7f796e1e7924c04
4
+ data.tar.gz: 1e27723d5bca5446a57400ffdcd528aa0cd8f07aab4b356ea4764d900098403a
5
5
  SHA512:
6
- metadata.gz: 828f11a693ace6bfaf2ea51ddd19133585a09f887411734ae603ab23a246286d69838c3244f86e5bc87e53cc81dd01b9d8672a48c299ce283fe2cdc7bc472f61
7
- data.tar.gz: a8026b1ab21bbcd60e751bfcbfdb87e7f9ce851847e44b13a5336f60d2e584b116903acceacfa7d2b0912a35de4a5380dbe79d7c0343e441054ddb0dd6d74a9d
6
+ metadata.gz: 8aaf2caa0f3e115af9fa0e68453bbd3066e1d411f5ac0f87fec16d07d57fac4fb60d618f4ea9b3f95f388c24488411ab6ffcfa46173ae0906fc1cdf1d0e598e1
7
+ data.tar.gz: 7be60d3a4108e0be7d195fd67e7a5ff5ca45b312e2b33520d9ab466f426db658109c72e70bcd6915ea36f72f7ccd0d2469e938bd4a3c26ece8dba8a626ec1fb7
data/.rubocop.yml CHANGED
@@ -1,4 +1,7 @@
1
1
  AllCops:
2
+ NewCops: enable
3
+ Exclude:
4
+ - lib/bike_reg/scraper.rb
2
5
  TargetRubyVersion: 2.5
3
6
 
4
7
  Layout/LineLength:
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [0.2.0] - 2021-11-13
2
+
3
+ - Adds ability to scrape registrations
4
+
1
5
  ## [0.1.1] - 2021-09-15
2
6
 
3
7
  - Fixes Homepage URL to repo from rubygems.org
data/Gemfile CHANGED
@@ -9,6 +9,9 @@ gem 'pry'
9
9
  gem 'pry-nav'
10
10
  gem 'rake', '~> 13.0'
11
11
  gem 'rspec', '~> 3.0'
12
- gem 'rubocop', '~> 1.7'
12
+ gem 'rubocop', '~> 1.22.3'
13
+ gem 'rubocop-discourse'
14
+ gem 'rubocop-rake'
15
+ gem 'rubocop-rspec'
13
16
  gem 'vcr'
14
17
  gem 'webmock'
data/Gemfile.lock CHANGED
@@ -1,20 +1,46 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bike_reg (0.1.1)
4
+ bike_reg (0.2.0)
5
5
  faraday (~> 1.7)
6
6
  faraday_middleware (~> 1.1)
7
+ kimurai (= 1.4)
7
8
 
8
9
  GEM
9
10
  remote: https://rubygems.org/
10
11
  specs:
12
+ activesupport (6.1.4.1)
13
+ concurrent-ruby (~> 1.0, >= 1.0.2)
14
+ i18n (>= 1.6, < 2)
15
+ minitest (>= 5.1)
16
+ tzinfo (~> 2.0)
17
+ zeitwerk (~> 2.3)
11
18
  addressable (2.8.0)
12
19
  public_suffix (>= 2.0.2, < 5.0)
13
20
  ast (2.4.2)
21
+ capybara (3.36.0)
22
+ addressable
23
+ matrix
24
+ mini_mime (>= 0.1.3)
25
+ nokogiri (~> 1.8)
26
+ rack (>= 1.6.0)
27
+ rack-test (>= 0.6.3)
28
+ regexp_parser (>= 1.5, < 3.0)
29
+ xpath (~> 3.2)
30
+ capybara-mechanize (1.11.0)
31
+ capybara (>= 2.4.4, < 4)
32
+ mechanize (~> 2.7.0)
33
+ childprocess (4.1.0)
34
+ chronic (0.10.2)
35
+ cliver (0.3.2)
14
36
  coderay (1.1.3)
37
+ concurrent-ruby (1.1.9)
38
+ connection_pool (2.2.5)
15
39
  crack (0.4.5)
16
40
  rexml
17
41
  diff-lcs (1.4.4)
42
+ domain_name (0.5.20190701)
43
+ unf (>= 0.0.5, < 1.0.0)
18
44
  faraday (1.7.1)
19
45
  faraday-em_http (~> 1.0)
20
46
  faraday-em_synchrony (~> 1.0)
@@ -37,19 +63,74 @@ GEM
37
63
  faraday_middleware (1.1.0)
38
64
  faraday (~> 1.0)
39
65
  hashdiff (1.0.1)
66
+ headless (2.3.1)
67
+ http-cookie (1.0.4)
68
+ domain_name (~> 0.5)
69
+ i18n (1.8.11)
70
+ concurrent-ruby (~> 1.0)
71
+ kimurai (1.4.0)
72
+ activesupport
73
+ capybara (>= 2.15, < 4.0)
74
+ capybara-mechanize
75
+ cliver
76
+ headless
77
+ murmurhash3
78
+ nokogiri
79
+ pmap
80
+ poltergeist
81
+ pry
82
+ rbcat (~> 0.2)
83
+ selenium-webdriver
84
+ thor
85
+ whenever
86
+ matrix (0.4.2)
87
+ mechanize (2.7.7)
88
+ domain_name (~> 0.5, >= 0.5.1)
89
+ http-cookie (~> 1.0)
90
+ mime-types (>= 1.17.2)
91
+ net-http-digest_auth (~> 1.1, >= 1.1.1)
92
+ net-http-persistent (>= 2.5.2)
93
+ nokogiri (~> 1.6)
94
+ ntlm-http (~> 0.1, >= 0.1.1)
95
+ webrick (~> 1.7)
96
+ webrobots (>= 0.0.9, < 0.2)
40
97
  method_source (0.9.2)
98
+ mime-types (3.3.1)
99
+ mime-types-data (~> 3.2015)
100
+ mime-types-data (3.2021.0901)
101
+ mini_mime (1.1.2)
102
+ minitest (5.14.4)
41
103
  multipart-post (2.1.1)
42
- parallel (1.20.1)
104
+ murmurhash3 (0.1.6)
105
+ net-http-digest_auth (1.4.1)
106
+ net-http-persistent (4.0.1)
107
+ connection_pool (~> 2.2)
108
+ nokogiri (1.12.5-arm64-darwin)
109
+ racc (~> 1.4)
110
+ nokogiri (1.12.5-x86_64-linux)
111
+ racc (~> 1.4)
112
+ ntlm-http (0.1.1)
113
+ parallel (1.21.0)
43
114
  parser (3.0.2.0)
44
115
  ast (~> 2.4.1)
116
+ pmap (1.1.1)
117
+ poltergeist (1.18.1)
118
+ capybara (>= 2.1, < 4)
119
+ cliver (~> 0.3.1)
120
+ websocket-driver (>= 0.2.0)
45
121
  pry (0.12.2)
46
122
  coderay (~> 1.1.0)
47
123
  method_source (~> 0.9.0)
48
124
  pry-nav (0.3.0)
49
125
  pry (>= 0.9.10, < 0.13.0)
50
126
  public_suffix (4.0.6)
127
+ racc (1.6.0)
128
+ rack (2.2.3)
129
+ rack-test (1.1.0)
130
+ rack (>= 1.0, < 3)
51
131
  rainbow (3.0.0)
52
132
  rake (13.0.6)
133
+ rbcat (0.2.1)
53
134
  regexp_parser (2.1.1)
54
135
  rexml (3.2.5)
55
136
  rspec (3.10.0)
@@ -65,25 +146,53 @@ GEM
65
146
  diff-lcs (>= 1.2.0, < 2.0)
66
147
  rspec-support (~> 3.10.0)
67
148
  rspec-support (3.10.2)
68
- rubocop (1.20.0)
149
+ rubocop (1.22.3)
69
150
  parallel (~> 1.10)
70
151
  parser (>= 3.0.0.0)
71
152
  rainbow (>= 2.2.2, < 4.0)
72
153
  regexp_parser (>= 1.8, < 3.0)
73
154
  rexml
74
- rubocop-ast (>= 1.9.1, < 2.0)
155
+ rubocop-ast (>= 1.12.0, < 2.0)
75
156
  ruby-progressbar (~> 1.7)
76
157
  unicode-display_width (>= 1.4.0, < 3.0)
77
- rubocop-ast (1.11.0)
158
+ rubocop-ast (1.13.0)
78
159
  parser (>= 3.0.1.1)
160
+ rubocop-discourse (2.4.2)
161
+ rubocop (>= 1.1.0)
162
+ rubocop-rspec (>= 2.0.0)
163
+ rubocop-rake (0.6.0)
164
+ rubocop (~> 1.0)
165
+ rubocop-rspec (2.6.0)
166
+ rubocop (~> 1.19)
79
167
  ruby-progressbar (1.11.0)
80
168
  ruby2_keywords (0.0.5)
81
- unicode-display_width (2.0.0)
169
+ rubyzip (2.3.2)
170
+ selenium-webdriver (4.0.3)
171
+ childprocess (>= 0.5, < 5.0)
172
+ rexml (~> 3.2, >= 3.2.5)
173
+ rubyzip (>= 1.2.2)
174
+ thor (1.1.0)
175
+ tzinfo (2.0.4)
176
+ concurrent-ruby (~> 1.0)
177
+ unf (0.1.4)
178
+ unf_ext
179
+ unf_ext (0.0.8)
180
+ unicode-display_width (2.1.0)
82
181
  vcr (6.0.0)
83
182
  webmock (3.14.0)
84
183
  addressable (>= 2.8.0)
85
184
  crack (>= 0.3.2)
86
185
  hashdiff (>= 0.4.0, < 2.0.0)
186
+ webrick (1.7.0)
187
+ webrobots (0.1.2)
188
+ websocket-driver (0.7.5)
189
+ websocket-extensions (>= 0.1.0)
190
+ websocket-extensions (0.1.5)
191
+ whenever (1.0.0)
192
+ chronic (>= 0.6.3)
193
+ xpath (3.2.0)
194
+ nokogiri (~> 1.8)
195
+ zeitwerk (2.5.1)
87
196
 
88
197
  PLATFORMS
89
198
  arm64-darwin-20
@@ -95,9 +204,12 @@ DEPENDENCIES
95
204
  pry-nav
96
205
  rake (~> 13.0)
97
206
  rspec (~> 3.0)
98
- rubocop (~> 1.7)
207
+ rubocop (~> 1.22.3)
208
+ rubocop-discourse
209
+ rubocop-rake
210
+ rubocop-rspec
99
211
  vcr
100
212
  webmock
101
213
 
102
214
  BUNDLED WITH
103
- 2.2.19
215
+ 2.2.30
data/README.md CHANGED
@@ -25,8 +25,12 @@ Or install it yourself as:
25
25
 
26
26
  ```ruby
27
27
  client = BikeReg::Client.new
28
+ ```
29
+
30
+ ### Events
28
31
 
29
- events = client.event.search
32
+ ```ruby
33
+ events = client.event.search(states: 'IA', eventtype: 'cyclocross')
30
34
  #=> BikeReg::Collection
31
35
 
32
36
  events.total
@@ -34,7 +38,28 @@ events.total
34
38
 
35
39
  events.data
36
40
  #=> [#<BikeReg::Event>, #<BikeReg::Event>]
37
- ````
41
+
42
+ events.data[0].EventName
43
+ #=> 'The Grand'
44
+ ```
45
+
46
+ ### Registrations
47
+
48
+ You need both the event id and category id.
49
+
50
+ ```ruby
51
+ registrations = client.registrations.all(event_id: 123, category_id: 456)
52
+ #=> BikeReg::Collection
53
+
54
+ registrations.total
55
+ #=> 43
56
+
57
+ registrations.data
58
+ #=> [#<BikeReg::Registration>, #<BikeReg::Registration>]
59
+
60
+ registrations.data[0].name
61
+ #=> 'Lance Armstrong'
62
+ ```
38
63
 
39
64
  ## Development
40
65
 
data/bike_reg.gemspec ADDED
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/bike_reg/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'bike_reg'
7
+ spec.version = BikeReg::VERSION
8
+ spec.authors = ['Scott Olsen']
9
+ spec.email = ['solsen300@gmail.com']
10
+ spec.homepage = 'https://github.com/scottolsen/bike_reg'
11
+ spec.summary = 'Gem to hit the BikeReg.com API'
12
+ spec.description = 'Gem to hit the BikeReg.com API. BikeReg API docs here https://www.bikereg.com/api/EventSearchDoc.aspx'
13
+ spec.license = 'MIT'
14
+
15
+ # Specify which files should be added to the gem when it is released.
16
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
17
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
18
+ `git ls-files -z`.split("\x0").reject do |f|
19
+ (f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
20
+ end
21
+ end
22
+ spec.bindir = 'exe'
23
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
24
+ spec.require_paths = ['lib']
25
+
26
+ spec.required_ruby_version = '>= 2.5'
27
+
28
+ spec.add_dependency 'faraday', '~> 1.7'
29
+ spec.add_dependency 'faraday_middleware', '~> 1.1'
30
+ spec.add_dependency 'kimurai', '1.4'
31
+ end
@@ -8,6 +8,10 @@ module BikeReg
8
8
  EventResource.new(self)
9
9
  end
10
10
 
11
+ def registrations
12
+ RegistrationResource.new(self)
13
+ end
14
+
11
15
  def connection
12
16
  @connection ||= Faraday.new(BASE_URL) do |conn|
13
17
  conn.request :json
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BikeReg
4
+ class Registration < Object
5
+ end
6
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BikeReg
4
+ class RegistrationResource < Resource
5
+ def all(**params)
6
+ reg_url = "https://www.bikereg.com/Registration/ConfirmedSingleRace.aspx?eid=&team=&RaceRecID=#{params[:category_id]}&EventID=#{params[:event_id]}"
7
+
8
+ response = Scraper.parse!(:parse, url: reg_url)
9
+
10
+ Collection.from_response(response, key: 'riders', type: Registration, start_page: params[:startpage])
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'kimurai'
4
+ class Scraper < Kimurai::Base
5
+ @name = 'github_spider'
6
+ @engine = :mechanize
7
+ @start_urls = ["https://example.com/"]
8
+
9
+ def parse(response, url: '', data: {})
10
+ riders = []
11
+ trs = response.css('tr.event-participant')
12
+ trs.each do |tr|
13
+ state = tr.css('.state').text
14
+ last_name = tr.css('.lastname').text
15
+ name = "#{tr.css('#tdFirstName').text} #{last_name}"
16
+ team = tr.css('.team div').text.gsub("\r", '').gsub("\n", '').strip
17
+ riders << { name: name, team: team, state: state }
18
+ end
19
+
20
+ OpenStruct
21
+ .new(
22
+ body: {
23
+ riders: riders,
24
+ ResultCount: riders.count
25
+ }.with_indifferent_access
26
+ )
27
+ end
28
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BikeReg
4
- VERSION = '0.1.1'
4
+ VERSION = '0.2.0'
5
5
  end
data/lib/bike_reg.rb CHANGED
@@ -10,8 +10,11 @@ module BikeReg
10
10
  autoload :Error, 'bike_reg/error'
11
11
  autoload :Object, 'bike_reg/object'
12
12
  autoload :Resource, 'bike_reg/resource'
13
+ autoload :Scraper, 'bike_reg/scraper'
13
14
 
14
15
  autoload :EventResource, 'bike_reg/resources/event_resource'
16
+ autoload :RegistrationResource, 'bike_reg/resources/registration_resource'
15
17
 
16
18
  autoload :Event, 'bike_reg/objects/event'
19
+ autoload :Registration, 'bike_reg/objects/registration'
17
20
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bike_reg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Olsen
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-09-15 00:00:00.000000000 Z
11
+ date: 2021-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: kimurai
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '='
46
+ - !ruby/object:Gem::Version
47
+ version: '1.4'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: '1.4'
41
55
  description: Gem to hit the BikeReg.com API. BikeReg API docs here https://www.bikereg.com/api/EventSearchDoc.aspx
42
56
  email:
43
57
  - solsen300@gmail.com
@@ -53,6 +67,7 @@ files:
53
67
  - LICENSE.txt
54
68
  - README.md
55
69
  - Rakefile
70
+ - bike_reg.gemspec
56
71
  - bin/console
57
72
  - bin/setup
58
73
  - lib/bike_reg.rb
@@ -61,14 +76,17 @@ files:
61
76
  - lib/bike_reg/error.rb
62
77
  - lib/bike_reg/object.rb
63
78
  - lib/bike_reg/objects/event.rb
79
+ - lib/bike_reg/objects/registration.rb
64
80
  - lib/bike_reg/resource.rb
65
81
  - lib/bike_reg/resources/event_resource.rb
82
+ - lib/bike_reg/resources/registration_resource.rb
83
+ - lib/bike_reg/scraper.rb
66
84
  - lib/bike_reg/version.rb
67
85
  homepage: https://github.com/scottolsen/bike_reg
68
86
  licenses:
69
87
  - MIT
70
88
  metadata: {}
71
- post_install_message:
89
+ post_install_message:
72
90
  rdoc_options: []
73
91
  require_paths:
74
92
  - lib
@@ -83,8 +101,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
83
101
  - !ruby/object:Gem::Version
84
102
  version: '0'
85
103
  requirements: []
86
- rubygems_version: 3.1.6
87
- signing_key:
104
+ rubygems_version: 3.2.31
105
+ signing_key:
88
106
  specification_version: 4
89
107
  summary: Gem to hit the BikeReg.com API
90
108
  test_files: []