jishan_fast_track_gem 0.1.5 → 0.1.6
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/lib/files_check.rb +48 -56
- data/lib/jishan_fast_track_gem.rb +1 -1
- data/lib/jishan_fast_track_gem/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: 5ec4f39f10b769ad26c77963227d7ff17dd00725d9b0ce024ae743dd25ab7c87
|
4
|
+
data.tar.gz: 56a26de9b2674c9fc7a1b5633b150bf96b432944d7f25d83cd1acb56f9c12eb7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 96c31b631f28cd44466bb41ff8356adeae0669bc2d3a83931abf04996cfbf05018d73aed3ff6bd0a224da26b33a78105e80948a37cd26cae660153fac272ed01
|
7
|
+
data.tar.gz: 369d2495e09b5c05782b4878e2c861b1df76611973a15826bd6418f13cd385ab0e02177184a2853b70552676db585c47c89a71f8fdda3190e0596120e4dd15e6
|
data/lib/files_check.rb
CHANGED
@@ -1,29 +1,19 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
|
1
|
+
require "uri"
|
2
|
+
require "csv"
|
3
|
+
require "colorize"
|
4
|
+
require "table_print"
|
6
5
|
|
7
6
|
class Provided_files_check
|
8
7
|
def initialize(name)
|
9
8
|
@name = name
|
10
9
|
end
|
11
|
-
|
10
|
+
|
12
11
|
def income_proof
|
13
12
|
puts "provide the proof of income document URL (only .pdf or .doc): ".colorize(:light_blue)
|
14
13
|
url = gets.chomp
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
end
|
19
|
-
|
20
|
-
file_type = File.extname(URI.parse(url).path)
|
21
|
-
if file_type == ".pdf" || file_type == ".doc"
|
22
|
-
puts "File upload succeeded."
|
23
|
-
two_forms_of_identity
|
24
|
-
else
|
25
|
-
puts "upload failed. please provide .pdf or .doc document."
|
26
|
-
end
|
14
|
+
return unless valid_file_check(url)
|
15
|
+
return unless file_type_check(url)
|
16
|
+
two_forms_of_identity
|
27
17
|
end
|
28
18
|
|
29
19
|
def two_forms_of_identity
|
@@ -31,56 +21,58 @@ class Provided_files_check
|
|
31
21
|
loop do
|
32
22
|
puts "provide identity documents' URL (only .pdf or .doc): "
|
33
23
|
url = gets.chomp
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
end
|
39
|
-
|
40
|
-
file_type = File.extname(URI.parse(url).path)
|
41
|
-
if file_type == ".pdf" || file_type == ".doc"
|
42
|
-
file_arr << file_type
|
43
|
-
puts "file upload succeeded."
|
44
|
-
else
|
45
|
-
puts "upload failed. please provide .pdf or .doc document."
|
46
|
-
end
|
47
|
-
break if file_arr.size == 2
|
24
|
+
return unless valid_file_check(url)
|
25
|
+
return unless file_type_check(url)
|
26
|
+
file_arr << url
|
27
|
+
break if file_arr.size == 2
|
48
28
|
end
|
49
29
|
retailer_quote
|
50
30
|
end
|
51
31
|
|
32
|
+
|
33
|
+
|
52
34
|
def retailer_quote
|
53
35
|
puts "Provide the eligible quote URL (only .pdf or .doc): "
|
54
36
|
url = gets.chomp
|
55
37
|
file_type = File.extname(URI.parse(url).path)
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
puts "It's not a valid file URL."
|
60
|
-
end
|
38
|
+
return unless valid_file_check(url)
|
39
|
+
return unless file_type_check(url)
|
40
|
+
end
|
61
41
|
|
62
|
-
if file_type == ".pdf" || file_type == ".doc"
|
63
|
-
puts "file upload succeeded."
|
64
|
-
eligible_quote(url)
|
65
|
-
else
|
66
|
-
puts "upload failed. please provide .pdf or .doc document."
|
67
|
-
end
|
68
|
-
end
|
69
42
|
def eligible_quote(url)
|
70
43
|
retailer = URI.parse(url).host
|
71
|
-
csv_text = File.read(
|
44
|
+
csv_text = File.read("cec_approved_retailers.csv")
|
72
45
|
csv = CSV.parse(csv_text, headers: true)
|
73
|
-
|
74
|
-
|
46
|
+
|
47
|
+
result = csv.find do |web|
|
75
48
|
web_address = web.to_hash
|
76
|
-
retailer == web_address[
|
77
|
-
|
49
|
+
retailer == web_address["URL"]
|
50
|
+
end
|
78
51
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
end
|
52
|
+
if result != nil
|
53
|
+
puts "Eligible retailer."
|
54
|
+
else
|
55
|
+
puts "Not Eligible retailer. Please check the provided list of CEC approved retailers below"
|
56
|
+
tp csv.map { |row| row.to_hash }, { :NAME => { display_name: "Company Name" } }, { :URL => { width: 35 } }
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def valid_file_check(url)
|
61
|
+
if url =~ URI::regexp
|
62
|
+
return true
|
63
|
+
else
|
64
|
+
puts "It's not a valid file URL."
|
65
|
+
return false
|
66
|
+
end
|
67
|
+
end
|
68
|
+
def file_type_check(url)
|
69
|
+
file_type = File.extname(URI.parse(url).path)
|
70
|
+
if file_type == ".pdf" || file_type == ".doc"
|
71
|
+
puts "File upload succeeded."
|
72
|
+
return true
|
73
|
+
else
|
74
|
+
puts "upload failed. please provide .pdf or .doc document."
|
75
|
+
return false
|
76
|
+
end
|
77
|
+
end
|
86
78
|
end
|
@@ -11,7 +11,7 @@ ruby = Solar_panel_rebate_egilibility_check.new("Ruby")
|
|
11
11
|
# ruby.ower_of_the_property
|
12
12
|
|
13
13
|
john_files = Provided_files_check.new("john_files")
|
14
|
-
john_files.
|
14
|
+
john_files.two_forms_of_identity
|
15
15
|
john_rebate = Rebate_calculator.new
|
16
16
|
# john_rebate.stc_postcode_rating(3000)
|
17
17
|
# john_rebate.stc_calculator(5, 5)
|