itriagetestrail 1.0.31 → 1.0.36
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/itriagetestrail.rb +1 -1
- data/lib/itriagetestrail/testrail_binding.rb +30 -29
- data/lib/itriagetestrail/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: 7d3fb08d0333d280c30606a5cd177b439f668a94a8683bf0099c47dac4b563cc
|
4
|
+
data.tar.gz: 9dd89450a238a488c46783754df2ca4c312301e2e9dd807b31d30f01b80430e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64729b306598a415b93d91869a57d0be086772f39fe235159be11b17ea3e88c48186189207fe125ab0d93d9d9640db9de0da1817a829e210de94c89c4e41ce6d
|
7
|
+
data.tar.gz: ed2d5d73ea6c95e07d56f0b8355e0ec73b9d09420c083517e92f7500efa10f9971bc1822c96daf8d8b94834f272b393d33c986659251151bcfeacfe2d99e2db9
|
data/lib/itriagetestrail.rb
CHANGED
@@ -49,7 +49,7 @@ module Itriagetestrail
|
|
49
49
|
# This is the very first call to TestRail
|
50
50
|
make_connection
|
51
51
|
projects
|
52
|
-
if @client.response_code == '200'
|
52
|
+
if @client.response_code == '200' || @client.response_code.nil?
|
53
53
|
true
|
54
54
|
else
|
55
55
|
puts "**** TESTRAIL IS OFFLINE for maintenance or other reason with status code #{@client.response_code}"
|
@@ -133,7 +133,7 @@ module TestRail
|
|
133
133
|
_error_check(response, result)
|
134
134
|
|
135
135
|
if write_cache
|
136
|
-
cache_to_file(
|
136
|
+
cache_to_file(uri, result)
|
137
137
|
end
|
138
138
|
|
139
139
|
result
|
@@ -146,39 +146,40 @@ module TestRail
|
|
146
146
|
file.write("#{Time.now},#{endpoint}\n")
|
147
147
|
file.close
|
148
148
|
end
|
149
|
-
end
|
150
149
|
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
150
|
+
def cache_to_file(url, content)
|
151
|
+
payload = {'response' => content}
|
152
|
+
Dir.mkdir('./tmp') unless File.exist?('./tmp')
|
153
|
+
filename = sanitize_filename(url)
|
154
|
+
file = File.open("./tmp/#{filename}", 'w')
|
155
|
+
file.write(payload.to_json)
|
156
|
+
file.close
|
157
|
+
end
|
158
158
|
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
159
|
+
def read_cache(url)
|
160
|
+
filename = sanitize_filename(url)
|
161
|
+
return unless File.exist?("./tmp/#{filename}")
|
162
|
+
file = File.open("./tmp/#{filename}", 'r')
|
163
|
+
content = JSON.parse(file.read)
|
164
|
+
file.close
|
165
|
+
content[:response]
|
166
|
+
end
|
167
167
|
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
168
|
+
def sanitize_filename(filename)
|
169
|
+
# Split the name when finding a period which is preceded by some
|
170
|
+
# character, and is followed by some character other than a period,
|
171
|
+
# if there is no following period that is followed by something
|
172
|
+
# other than a period (yeah, confusing, I know)
|
173
|
+
fn = filename.split /(?<=.)\.(?=[^.])(?!.*\.[^.])/m
|
174
174
|
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
175
|
+
# We now have one or two parts (depending on whether we could find
|
176
|
+
# a suitable period). For each of these parts, replace any unwanted
|
177
|
+
# sequence of characters with an underscore
|
178
|
+
fn.map! { |s| s.gsub /[^a-z0-9\-]+/i, '_' }
|
179
179
|
|
180
|
-
|
181
|
-
|
180
|
+
# Finally, join the parts with a period and return the result
|
181
|
+
return fn.join '.'
|
182
|
+
end
|
182
183
|
end
|
183
184
|
|
184
185
|
class APIError < StandardError
|