lx_data_validation 0.0.4 → 0.0.5

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: 3e194bf49037ed8424cf3dcf33f3fabf5cb52760
4
- data.tar.gz: 0647669d8cf15cb8f21e1c817c149ce4925f4225
3
+ metadata.gz: d375db47b73f839c7657154f711f7b91f008af0f
4
+ data.tar.gz: 2bc442e90cc560b35a4e8b6489da9c0fa035443a
5
5
  SHA512:
6
- metadata.gz: b165e44eea570728fb66fd5156eaf4136857ca877d6515279e90543dc70135935b55782231bd37cdab2c67b2da82453ac576cc3d791302d2f0974717e39e88e2
7
- data.tar.gz: 7671e8e28c54168f2a659b661f118a4900be3b4208049b7af391d94453ee776e7542eb7825a7d2157c91e874c5688fccd7e1a994c2ceb30154ada490ab8389ae
6
+ metadata.gz: d5114d8ee2f53f3c4f6a8b986703326b704fb72c89d972f59006d9464242479c2141558e5a935039dfda67bc77f13202d7739e5ed2605f6a6727fd11b9eb2905
7
+ data.tar.gz: 57de47bcd55eff91184b7d00e6c5a9ae13ba3d9dd8a21cb880308af353a160d7cfba0e723f0059f9ddbf0292c076fddc489630470127934bbb7fd872eb32a155
@@ -52,7 +52,7 @@ module DataValidation
52
52
  end
53
53
 
54
54
 
55
- unless (team_value.is_a?(String) && team_value.include?(item[i])) ||
55
+ unless (team_value.is_a?(String) && team_value.include?(item[i].strip)) ||
56
56
  (team_value.is_a?(Float) && team_value == item[i].to_f) ||
57
57
  (team_value.is_a?(Integer) && team_value == item[i].to_i)
58
58
 
@@ -68,9 +68,9 @@ module DataValidation
68
68
  def compare_conf_standings(api_data, data_access)
69
69
  puts 'Start to compare conf ranking tables'
70
70
  conf_standing_data = data_access.conf_standing_data
71
+
71
72
  conf_standing_data.each do |standing|
72
73
  full_conf = ''
73
- # puts standing.to_s
74
74
  standing.each_with_index do |record, i|
75
75
  if i == 0
76
76
  state = record[0]
@@ -9,7 +9,7 @@ module DataValidation
9
9
  end
10
10
 
11
11
  def field_array
12
- ['rank', 'teamName', %w|record wins|, %w|record losses|, %w|record ties|, 'pollPoint', 'pollFirst', 'lastWeek']
12
+ ['rank', 'teamName', %w|record wins|, %w|record losses|, %w|record ties|, 'pollPoint', 'pollFirst']
13
13
  end
14
14
 
15
15
  def empty_field
@@ -32,10 +32,8 @@ module DataValidation
32
32
  ## compare first table
33
33
  web_data.each_with_index do |item, index|
34
34
  team = api_data['results']['results']['teams'][index]
35
-
36
35
  i = 0
37
36
  field_array.each do |filed_name|
38
-
39
37
  if filed_name.is_a? String
40
38
  team_value = team[filed_name]
41
39
  elsif filed_name.is_a? Array
@@ -27,7 +27,15 @@ module DataValidation
27
27
  index = 0
28
28
  doc.search('div.cs1 div.cs1').text.lines.map do |line|
29
29
  if /^\s*(?<rank>\d+)\s+(?<rest>.*)/ =~ line
30
- data_array = ([rank] << team_names[index]) + rest.split(' ')
30
+ data_array = ([rank] << team_names[index])
31
+ rest_parts = rest.split(' ')
32
+ rest_parts.each do |item|
33
+ if item.match /^\d+-/ # win-loss-tie value
34
+ data_array += item.split('-')
35
+ else
36
+ data_array << item
37
+ end
38
+ end
31
39
  index += 1
32
40
  data_array
33
41
  end
@@ -59,25 +67,21 @@ module DataValidation
59
67
  conf_standing_record = []
60
68
  lines = doc.search('div.laxcs1, div.laxcss').text.lines
61
69
 
62
- conf_data_index = 0
63
70
  lines.each_with_index do |line, index|
64
- if line.match /^\s[A-Z]/
71
+ if /^\s(?<conf_full_name>[A-Z].*)Conference/ =~ line || /^\s(?<conf_full_name>[A-Z].*)Overall/ =~ line
65
72
  if conf_standing_record.length > 0 ## it's a new conf standing table
66
73
  @conf_standing_data << conf_standing_record
67
74
  conf_standing_record = []
68
75
  end
69
76
 
70
- conf = conf_data[conf_data_index]
71
-
72
- if conf.nil?
77
+ conf = get_conf(conf_full_name, conf_data)
78
+ if conf.nil? ## last standing table has no record, the response of "getConferences" api will not include this conference
73
79
  puts 'No independent conf data'
74
80
  @conf_standing_data << conf_standing_record
75
81
  break
76
82
  end
77
83
 
78
84
  conf_standing_record << [conf['state'], conf['teamClass'], conf['conference']]
79
-
80
- conf_data_index += 1
81
85
  elsif /^\s*\d+\s+/.match line
82
86
  conf_standing_record << line.split(' ')
83
87
  end
@@ -88,7 +92,10 @@ module DataValidation
88
92
  end
89
93
  end
90
94
 
91
-
95
+ def get_conf(conf_full_name, conf_data)
96
+ selected = conf_data.select { |conf| conf_full_name.include?("#{conf['state']}") && conf_full_name.include?("#{conf['teamClass']}") && conf_full_name.include?("#{conf['conference']}")}
97
+ selected.first if selected && selected.size > 0
98
+ end
92
99
 
93
100
  def get_response_from_mobile_api
94
101
  HTTParty.post(api_url, headers: {'Content-Type' => 'application/json'}, body: api_body)
@@ -1,3 +1,3 @@
1
1
  module DataValidation
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lx_data_validation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roger Tong
@@ -93,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
93
  version: '0'
94
94
  requirements: []
95
95
  rubyforge_project:
96
- rubygems_version: 2.4.6
96
+ rubygems_version: 2.6.7
97
97
  signing_key:
98
98
  specification_version: 4
99
99
  summary: Data validation for LaxPower