squash_matrix 1.0.1 → 1.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/Gemfile.lock +1 -1
- data/lib/squash_matrix/client.rb +4 -4
- data/lib/squash_matrix/constants.rb +1 -1
- data/lib/squash_matrix/nokogiri-parser.rb +2 -2
- data/lib/squash_matrix/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e8c848420ef0f941bdaeb1f28133e3c298961e7fd8a5e7ff9ae0eba5fa9501a3
|
4
|
+
data.tar.gz: 84900d15bcfd2498449e5a4427c179a5569ad06414e5550de7d17ec048919baf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0148ad96b316a74a9c186864234566755375e95f4903a3f954c0a3478ad251b3151dfe27e4120591546d7c6535873bfb3cc1156b618069b144a2505f8404610
|
7
|
+
data.tar.gz: 1e39568edeaa1f761484bd893f9e66cf4ea3c4b99b898a7221c6f6adcd23d5ee0a112e741dfcd81e0168a85d13a30baf28fcb34dc79e0a638e63b2508377b545
|
data/Gemfile.lock
CHANGED
data/lib/squash_matrix/client.rb
CHANGED
@@ -70,7 +70,7 @@ module SquashMatrix
|
|
70
70
|
# @return [Hash] hash object containing club information
|
71
71
|
|
72
72
|
def get_club_info(id = nil)
|
73
|
-
return
|
73
|
+
return unless id.to_i.positive?
|
74
74
|
uri = URI::HTTP.build(
|
75
75
|
host: SquashMatrix::Constants::SQUASH_MATRIX_URL,
|
76
76
|
path: SquashMatrix::Constants::CLUB_PATH.gsub(':id', id.to_s)
|
@@ -87,7 +87,7 @@ module SquashMatrix
|
|
87
87
|
# @return [Array<Hash>] Array of player match results
|
88
88
|
|
89
89
|
def get_player_results(id = nil)
|
90
|
-
return
|
90
|
+
return unless id.to_i.positive?
|
91
91
|
uri = URI::HTTP.build(
|
92
92
|
host: SquashMatrix::Constants::SQUASH_MATRIX_URL,
|
93
93
|
path: SquashMatrix::Constants::PLAYER_RESULTS_PATH.gsub(':id', id.to_s),
|
@@ -105,7 +105,7 @@ module SquashMatrix
|
|
105
105
|
# @return [Hash] hash object containing player information
|
106
106
|
|
107
107
|
def get_player_info(id = nil)
|
108
|
-
return
|
108
|
+
return unless id.to_i.positive?
|
109
109
|
uri = URI::HTTP.build(
|
110
110
|
host: SquashMatrix::Constants::SQUASH_MATRIX_URL,
|
111
111
|
path: SquashMatrix::Constants::PLAYER_HOME_PATH.gsub(':id', id.to_s)
|
@@ -124,7 +124,7 @@ module SquashMatrix
|
|
124
124
|
def get_search_results(query = nil,
|
125
125
|
squash_only: false,
|
126
126
|
racquetball_only: false)
|
127
|
-
return if query.
|
127
|
+
return if query.to_s.empty?
|
128
128
|
uri = URI::HTTP.build(
|
129
129
|
host: SquashMatrix::Constants::SQUASH_MATRIX_URL,
|
130
130
|
path: SquashMatrix::Constants::SEARCH_RESULTS_PATH
|
@@ -7,7 +7,7 @@ module SquashMatrix
|
|
7
7
|
PLAYER_RESULTS_PATH = '/Home/PlayerResults/:id'
|
8
8
|
PLAYER_HOME_PATH = '/Home/Player/:id'
|
9
9
|
CLUB_PATH = '/Home/Club/:id'
|
10
|
-
SEARCH_RESULTS_PATH = '/Home/
|
10
|
+
SEARCH_RESULTS_PATH = '/Home/Search'
|
11
11
|
PLAYER_RSULTS_QUERY = 'max=0&X-Requested-With=XMLHttpRequest'
|
12
12
|
SET_COOKIE_HEADER = 'set-cookie'
|
13
13
|
COOKIE_HEADER = 'cookie'
|
@@ -6,7 +6,7 @@ require_relative 'constants'
|
|
6
6
|
module SquashMatrix
|
7
7
|
class NokogiriParser
|
8
8
|
class << self
|
9
|
-
def
|
9
|
+
def get_player_results(body)
|
10
10
|
rtn = Nokogiri::HTML(body)&.xpath('//table[@id="results"]//tbody//tr')&.map do |r|
|
11
11
|
date = r.at_css('td[1]')&.content
|
12
12
|
opponent_id = r.at_css('td[10]//a')&.attribute('href')&.content
|
@@ -122,7 +122,7 @@ module SquashMatrix
|
|
122
122
|
name: tr.css('td[1]')&.text,
|
123
123
|
club_name: tr.css('td[2]')&.text
|
124
124
|
}
|
125
|
-
rtn[:id] = SquashMatrix::Constants::PLAYER_FROM_PATH_REGEX.match(id)[1].to_i if id
|
125
|
+
rtn[:id] = SquashMatrix::Constants::PLAYER_FROM_PATH_REGEX.match(id)[1].to_i if id
|
126
126
|
rtn[:rating] = rating.to_f if rating
|
127
127
|
rtn
|
128
128
|
end
|