lx_data_validation 0.0.6 → 0.0.7

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: 1b8f0c3775062f5b47c7b04662dcd3a9841e96b9
4
- data.tar.gz: fcbe2e175c963495e725a7f9204cf5fa2509ef37
3
+ metadata.gz: f7d1360b98bf511978dedb618feac1a7eaa9222b
4
+ data.tar.gz: 62f16aff299c6d951469fb8d32f2a45ad8cdd1e7
5
5
  SHA512:
6
- metadata.gz: 0f6799754bb9077081ad1d35f24193f7d81ec3a35340e48b37640bcadc6f6a16cff47896d37fc95f0682b6ff466fbfff32488e164b1ff121ba407da93efb206d
7
- data.tar.gz: 33779c94c8db7d0aaeabcfc0b2041f2e08fa0b3bab8799291c2f52a2d3510c7e39b2b4ef959e3417b7f6c39f57e7c27b9aa2ae6a3ccdfd45f4c338cb3978cef9
6
+ metadata.gz: a63b5a8185e595b3e39a12c93e96b0dbbcc0340c092a01abb8f918d975bec8d57454d9bef848bae3f041224662550ce41645b9073ebd383c5996ae7c6ffaae85
7
+ data.tar.gz: fb22665b5a4558712763ffa0d4a25438fa9b09fb6791ccbeaeb638f8aba826f293e4ff0c6e958697492e6408c0368e4a9cc3007012a401c7ddbc75270b635418
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'data_validation'
4
+
5
+ season = '17'
6
+ if ARGV[0]
7
+ season = ARGV[0]
8
+ end
9
+
10
+ DataValidation.compare_national season
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
24
24
 
25
25
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
26
  spec.bindir = "bin"
27
- spec.executables = ["compare", "compare_url"]
27
+ spec.executables = ["compare", "compare_url", "compare_national"]
28
28
  spec.require_paths = ["lib"]
29
29
 
30
30
  spec.add_runtime_dependency 'nokogiri', '1.6.6.2'
@@ -22,7 +22,12 @@ module DataValidation
22
22
  data_access = DataValidation::DataAccess.new(web_url, DataValidation.api_request_host + api_path, determine_request_body_and_logger_name)
23
23
 
24
24
  puts 'requesting web page...'
25
- web_data = data_access.get_main_table_data
25
+ if web_url.match /rating[a-z]+.php/
26
+ web_data = data_access.get_regional_rating_table_data
27
+ else
28
+ web_data = data_access.get_main_table_data
29
+ end
30
+
26
31
  puts 'requesting mobile api data: ' + DataValidation.api_request_host + api_path
27
32
  api_data = data_access.get_response_from_mobile_api
28
33
 
@@ -130,6 +135,28 @@ module DataValidation
130
135
 
131
136
  end
132
137
 
138
+ def determine_request_body_and_logger_name
139
+ @category = if web_url.match /bingrl/
140
+ 'GIRLS'
141
+ elsif web_url.match /binboy/
142
+ 'BOYS'
143
+ elsif web_url.match /binmen/
144
+ 'MEN'
145
+ elsif web_url.match /binwom/
146
+ 'WOMEN'
147
+ end
148
+
149
+ @season = "20#{web_url.match(/update(..)/)[1]}"
150
+
151
+ @division_id = web_url.match(/(\d+)\.php/)[1].to_i
152
+
153
+ operation = web_url.match(/\/([a-z]+)\d+.php/)[1]
154
+
155
+ @logger_name = "log/#{season}/#{category.downcase}/#{operation}/#{operation}_#{season}_#{category}_#{division_id}.log"
156
+
157
+ %Q|{"category":"#{category}","season":#{season},"divisionId":#{division_id},"currPage":1,"pageSize":1000}|
158
+ end
159
+
133
160
  private
134
161
 
135
162
  def logger
@@ -145,27 +172,7 @@ module DataValidation
145
172
  end
146
173
  end
147
174
 
148
- def determine_request_body_and_logger_name
149
- @category = if web_url.match /bingrl/
150
- 'GIRLS'
151
- elsif web_url.match /binboy/
152
- 'BOYS'
153
- elsif web_url.match /binmen/
154
- 'MEN'
155
- elsif web_url.match /binwom/
156
- 'WOMEN'
157
- end
158
-
159
- @season = "20#{web_url.match(/update(..)/)[1]}"
160
-
161
- @division_id = web_url.match(/(\d+)\.php/)[1].to_i
162
-
163
- operation = web_url.match(/\/([a-z]+)\d+.php/)[1]
164
175
 
165
- @logger_name = "log/#{season}/#{category.downcase}/#{operation}/#{operation}_#{season}_#{category}_#{division_id}.log"
166
-
167
- %Q|{"category":"#{category}","season":#{season},"divisionId":#{division_id},"currPage":1,"pageSize":1000}|
168
- end
169
176
  end
170
177
  end
171
178
  end
@@ -8,6 +8,14 @@ require 'data_validation/comparison/ranking_table_mw_trend_comparison'
8
8
  require 'data_validation/comparison/ranking_table_mw_tsi_comparison'
9
9
  require 'data_validation/comparison/ranking_table_mw_pr_comparison'
10
10
  require 'data_validation/comparison/ranking_table_pro_pr_comparison'
11
+ require 'data_validation/comparison/ranking_table_hs_crr_comparison'
12
+ require 'data_validation/comparison/ranking_table_hs_poll_comparison'
13
+ require 'data_validation/comparison/ranking_table_hs_rating_comparison'
14
+ require 'data_validation/comparison/ranking_table_hs_sos_comparison'
15
+ require 'data_validation/comparison/ranking_table_hs_rpi_comparison'
16
+ require 'data_validation/comparison/ranking_table_hs_qwf_comparison'
17
+ require 'data_validation/comparison/ranking_table_hs_wl_comparison'
18
+ require 'data_validation/comparison/state_ranking_comparison'
11
19
 
12
20
  module DataValidation
13
21
  module Comparison
@@ -17,6 +25,8 @@ module DataValidation
17
25
  return DivRankingPrComparison.new url
18
26
  elsif url.match /update\d\d\/bin\S+\/rating\d+.php/ # division Computer Rating page for men and women
19
27
  return RankingTableMwPrComparison.new url
28
+ elsif url.match /update\d\d\/bin\S+\/rating[a-z]+.php/ # Regional Ratings
29
+ return StateRankingComparison.new url
20
30
  elsif url.match /update\d\d\/bin\S+\/sos\d+.php/ # division Strength of Schedule page for boys/girls
21
31
  return RankingTableMwSosComparison.new url
22
32
  elsif url.match /update\d\d\/bin\S+\/rpi\d+.php/ # division RPI Rankings page for boys/girls
@@ -33,6 +43,20 @@ module DataValidation
33
43
  return RankingTableMwTsiComparison.new url
34
44
  elsif url.match /\.com\/(mll|nll)/ # Pro ranking page
35
45
  return RankingTableProPrComparison.new url
46
+ elsif url.match /update\d\d\/bin\S+\/natlccr.php/ # National Coaches/Computer Ratings
47
+ return RankingTableHsCrrComparison.new url
48
+ elsif url.match /update\d\d\/bin\S+\/natlpoll.php/ # National Poll
49
+ return RankingTableHsPollComparison.new url
50
+ elsif url.match /update\d\d\/bin\S+\/natlrating.php/ # National Computer Ratings
51
+ return RankingTableHsRatingComparison.new url
52
+ elsif url.match /update\d\d\/bin\S+\/natlsos.php/ # National Strength of Schedule
53
+ return RankingTableHsSosComparison.new url
54
+ elsif url.match /update\d\d\/bin\S+\/natlrpi.php/ # National Ratings Percentage Index
55
+ return RankingTableHsRpiComparison.new url
56
+ elsif url.match /update\d\d\/bin\S+\/natlqwf.php/ # National Quality Win Factor
57
+ return RankingTableHsQwfComparison.new url
58
+ elsif url.match /update\d\d\/bin\S+\/natl-wl.php/ # National Quality Win Factor
59
+ return RankingTableHsWlComparison.new url
36
60
  end
37
61
  end
38
62
  end
@@ -0,0 +1,32 @@
1
+ require 'data_validation/comparison/comparison_base'
2
+
3
+ module DataValidation
4
+ module Comparison
5
+ class RankingTableHsComparisonBase < ComparisonBase
6
+
7
+ def api_path
8
+ '/rest/LaxPower/rankingTableHS'
9
+ end
10
+
11
+ def determine_request_body_and_logger_name
12
+ @category = if web_url.match /bingrl/
13
+ 'GIRLS'
14
+ elsif web_url.match /binboy/
15
+ 'BOYS'
16
+ elsif web_url.match /binmen/
17
+ 'MEN'
18
+ elsif web_url.match /binwom/
19
+ 'WOMEN'
20
+ end
21
+
22
+ @season = "20#{web_url.match(/update(..)/)[1]}"
23
+
24
+ metric = web_url.match(/\/natl([a-z]+).php/)[1]
25
+
26
+ @logger_name = "log/#{season}/#{category.downcase}/natl#{metric}_#{season}_#{category}.log"
27
+
28
+ %Q|{"category":"#{category}","season":#{season}, "type": "#{metric.upcase}", "currPage":1,"pageSize":5000}|
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,13 @@
1
+ require 'data_validation/comparison/ranking_table_hs_comparison_base'
2
+
3
+ module DataValidation
4
+ module Comparison
5
+ class RankingTableHsCrrComparison < RankingTableHsComparisonBase
6
+
7
+ def field_array
8
+ ['rank', 'teamName', 'state', 'totalWins', 'totalLosses', 'totalTies', 'ccr', 'pollPoint', 'powerRating']
9
+ end
10
+
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ require 'data_validation/comparison/ranking_table_hs_comparison_base'
2
+
3
+ module DataValidation
4
+ module Comparison
5
+ class RankingTableHsPollComparison < RankingTableHsComparisonBase
6
+
7
+ def field_array
8
+ ['rank', 'teamName', 'state', 'totalWins', 'totalLosses', 'totalTies', 'pollPoint', 'pollFirst']
9
+ end
10
+
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,32 @@
1
+ require 'data_validation/comparison/ranking_table_hs_comparison_base'
2
+
3
+ module DataValidation
4
+ module Comparison
5
+ class RankingTableHsQwfComparison < RankingTableHsComparisonBase
6
+
7
+ def field_array
8
+ ['rank', 'teamName', 'region', 'gameScheduled', 'qwf', 'totalWins', 'totalLosses', 'totalTies']
9
+ end
10
+
11
+ def determine_request_body_and_logger_name
12
+ @category = if web_url.match /bingrl/
13
+ 'GIRLS'
14
+ elsif web_url.match /binboy/
15
+ 'BOYS'
16
+ elsif web_url.match /binmen/
17
+ 'MEN'
18
+ elsif web_url.match /binwom/
19
+ 'WOMEN'
20
+ end
21
+
22
+ @season = "20#{web_url.match(/update(..)/)[1]}"
23
+
24
+ metric = web_url.match(/\/natl([a-z]+).php/)[1]
25
+
26
+ @logger_name = "log/#{season}/#{category.downcase}/natl#{metric}_#{season}_#{category}.log"
27
+
28
+ %Q|{"category":"#{category}","season":#{season}, "type": "QWR", "currPage":1,"pageSize":5000}|
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,35 @@
1
+ require 'data_validation/comparison/ranking_table_hs_comparison_base'
2
+
3
+ module DataValidation
4
+ module Comparison
5
+ class RankingTableHsRatingComparison < RankingTableHsComparisonBase
6
+
7
+ def field_array
8
+ ['rank', 'teamName', 'state', 'powerRating', 'pollRank', 'sos', 'winLossTotal', 'totalWins', 'totalLosses', 'totalTies']
9
+ end
10
+
11
+ def empty_field
12
+ 'pollRank'
13
+ end
14
+
15
+ def determine_request_body_and_logger_name
16
+ @category = if web_url.match /bingrl/
17
+ 'GIRLS'
18
+ elsif web_url.match /binboy/
19
+ 'BOYS'
20
+ elsif web_url.match /binmen/
21
+ 'MEN'
22
+ elsif web_url.match /binwom/
23
+ 'WOMEN'
24
+ end
25
+
26
+ @season = "20#{web_url.match(/update(..)/)[1]}"
27
+
28
+ @logger_name = "log/#{season}/#{category.downcase}/natlrating_#{season}_#{category}.log"
29
+
30
+ %Q|{"category":"#{category}","season":#{season}, "type": "PR", "currPage":1,"pageSize":1000}|
31
+ end
32
+
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,13 @@
1
+ require 'data_validation/comparison/ranking_table_hs_comparison_base'
2
+
3
+ module DataValidation
4
+ module Comparison
5
+ class RankingTableHsRpiComparison < RankingTableHsComparisonBase
6
+
7
+ def field_array
8
+ ['rank', 'teamName', 'region', 'gameScheduled', 'rpi', 'totalWins', 'totalLosses', 'totalTies']
9
+ end
10
+
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ require 'data_validation/comparison/ranking_table_hs_comparison_base'
2
+
3
+ module DataValidation
4
+ module Comparison
5
+ class RankingTableHsSosComparison < RankingTableHsComparisonBase
6
+
7
+ def field_array
8
+ ['rank', 'teamName', 'region', 'gameScheduled', 'sos', 'totalWins', 'totalLosses', 'totalTies']
9
+ end
10
+
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,33 @@
1
+ require 'data_validation/comparison/ranking_table_hs_comparison_base'
2
+
3
+ module DataValidation
4
+ module Comparison
5
+ class RankingTableHsWlComparison < RankingTableHsComparisonBase
6
+
7
+ def field_array
8
+ ['rank', 'teamName', 'region', 'gameScheduled', 'winLossTotal', 'winLossState', 'winLossDate', 'winLossSite', 'totalWins', 'totalLosses', 'totalTies']
9
+ end
10
+
11
+ def determine_request_body_and_logger_name
12
+ @category = if web_url.match /bingrl/
13
+ 'GIRLS'
14
+ elsif web_url.match /binboy/
15
+ 'BOYS'
16
+ elsif web_url.match /binmen/
17
+ 'MEN'
18
+ elsif web_url.match /binwom/
19
+ 'WOMEN'
20
+ end
21
+
22
+ @season = "20#{web_url.match(/update(..)/)[1]}"
23
+
24
+ metric = 'wl'
25
+
26
+ @logger_name = "log/#{season}/#{category.downcase}/natl#{metric}_#{season}_#{category}.log"
27
+
28
+ %Q|{"category":"#{category}","season":#{season}, "type": "#{metric.upcase}", "currPage":1,"pageSize":5000}|
29
+ end
30
+
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,37 @@
1
+ require 'data_validation/comparison/comparison_base'
2
+
3
+ module DataValidation
4
+ module Comparison
5
+ class StateRankingComparison < ComparisonBase
6
+
7
+ def api_path
8
+ '/rest/LaxPower/stateRanking'
9
+ end
10
+
11
+ def field_array
12
+ ['rank', 'teamName', 'powerRating', 'sosRank', %w|record wins|, %w|record losses|, %w|record ties|, 'state']
13
+ end
14
+
15
+ def determine_request_body_and_logger_name
16
+ @category = if web_url.match /bingrl/
17
+ 'GIRLS'
18
+ elsif web_url.match /binboy/
19
+ 'BOYS'
20
+ elsif web_url.match /binmen/
21
+ 'MEN'
22
+ elsif web_url.match /binwom/
23
+ 'WOMEN'
24
+ end
25
+
26
+ @season = "20#{web_url.match(/update(..)/)[1]}"
27
+
28
+ state = web_url.match(/\/rating([a-z]+).php/)[1]
29
+
30
+ @logger_name = "log/#{season}/#{category.downcase}/rating/rating_#{season}_#{category}_#{state}.log"
31
+
32
+ %Q|{"category":"#{category}","season":#{season},"state":"#{state.upcase}","currPage":1,"pageSize":1000}|
33
+ end
34
+
35
+ end
36
+ end
37
+ end
@@ -16,7 +16,7 @@ module DataValidation
16
16
  def get_main_table_data
17
17
  doc = Nokogiri::HTML(open(html_url))
18
18
 
19
- if html_url.match /rating/
19
+ if html_url.match /rating\d+/
20
20
  extract_conf_standing_data(doc)
21
21
  end
22
22
 
@@ -26,8 +26,31 @@ module DataValidation
26
26
 
27
27
  index = 0
28
28
  doc.search('div.cs1 div.cs1').text.lines.map do |line|
29
- if /^\s*(?<rank>\d+)\s+(?<rest>.*)/ =~ line
29
+ if /^\s*(?<rank>\d+)\s+(?<region>[a-zA-Z][a-zA-Z\/\d-]*\s([a-zA-Z\/\d-]+\s)*)?(?<rest>.*)/ =~ line
30
30
  data_array = ([rank] << team_names[index])
31
+ data_array << region.strip unless region.nil? || region.strip.empty?
32
+ rest_parts = rest.split(' ')
33
+ rest_parts.each do |item|
34
+ if item.match /^\d+-/ # win-loss-tie value
35
+ data_array += item.split('-')
36
+ else
37
+ data_array << item
38
+ end
39
+ end
40
+ index += 1
41
+ data_array
42
+ end
43
+ end.compact
44
+ end
45
+
46
+ def get_regional_rating_table_data
47
+ doc = Nokogiri::HTML(open(html_url))
48
+ index = 0
49
+
50
+ doc.search('div.cs1').text.lines.map do |line|
51
+ if /^\s*(?<rank>\d+)\s+(?<name>[a-zA-Z][a-zA-Z\/\d-]*\s([a-zA-Z\/\d-]+\s)*)?(?<rest>.*)/ =~ line
52
+ data_array = [rank]
53
+ data_array << name.strip unless name.nil? || name.strip.empty?
31
54
  rest_parts = rest.split(' ')
32
55
  rest_parts.each do |item|
33
56
  if item.match /^\d+-/ # win-loss-tie value
@@ -1,3 +1,3 @@
1
1
  module DataValidation
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -35,6 +35,17 @@ module DataValidation
35
35
  puts "Complete validation of web url: #{url}"
36
36
  puts '=============================='
37
37
  end
38
+
39
+ def compare_national(season = '17')
40
+ categories = %w|boy grl|
41
+ metrics = %w|ccr poll rating sos rpi qwf -wl|
42
+
43
+ categories.each do |category|
44
+ metrics.each do |metric|
45
+ compare_with_url "http://php.admin.laxpower.com/update#{season}/bin#{category}/natl#{metric}.php"
46
+ end
47
+ end
48
+ end
38
49
  end
39
50
 
40
51
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lx_data_validation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roger Tong
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-01 00:00:00.000000000 Z
11
+ date: 2017-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -46,6 +46,7 @@ email:
46
46
  executables:
47
47
  - compare
48
48
  - compare_url
49
+ - compare_national
49
50
  extensions: []
50
51
  extra_rdoc_files: []
51
52
  files:
@@ -57,6 +58,7 @@ files:
57
58
  - README.md
58
59
  - Rakefile
59
60
  - bin/compare
61
+ - bin/compare_national
60
62
  - bin/compare_url
61
63
  - data_validation.gemspec
62
64
  - lib/data_validation.rb
@@ -65,6 +67,14 @@ files:
65
67
  - lib/data_validation/comparison/conference_ranking_table_comparison.rb
66
68
  - lib/data_validation/comparison/div_ranking_pr_comparison.rb
67
69
  - lib/data_validation/comparison/div_ranking_wl_comparison.rb
70
+ - lib/data_validation/comparison/ranking_table_hs_comparison_base.rb
71
+ - lib/data_validation/comparison/ranking_table_hs_crr_comparison.rb
72
+ - lib/data_validation/comparison/ranking_table_hs_poll_comparison.rb
73
+ - lib/data_validation/comparison/ranking_table_hs_qwf_comparison.rb
74
+ - lib/data_validation/comparison/ranking_table_hs_rating_comparison.rb
75
+ - lib/data_validation/comparison/ranking_table_hs_rpi_comparison.rb
76
+ - lib/data_validation/comparison/ranking_table_hs_sos_comparison.rb
77
+ - lib/data_validation/comparison/ranking_table_hs_wl_comparison.rb
68
78
  - lib/data_validation/comparison/ranking_table_mw_poll_comparison.rb
69
79
  - lib/data_validation/comparison/ranking_table_mw_pr_comparison.rb
70
80
  - lib/data_validation/comparison/ranking_table_mw_qw_comparison.rb
@@ -73,6 +83,7 @@ files:
73
83
  - lib/data_validation/comparison/ranking_table_mw_trend_comparison.rb
74
84
  - lib/data_validation/comparison/ranking_table_mw_tsi_comparison.rb
75
85
  - lib/data_validation/comparison/ranking_table_pro_pr_comparison.rb
86
+ - lib/data_validation/comparison/state_ranking_comparison.rb
76
87
  - lib/data_validation/data_access.rb
77
88
  - lib/data_validation/version.rb
78
89
  homepage: https://gitlab.dev.activenetwork.com/rtong/data-validation-for-laxpower