file_sv 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/file_sv.rb +12 -0
- data/lib/file_sv/file_processor.rb +2 -1
- data/lib/file_sv/global_settings.rb +20 -0
- data/lib/file_sv/sv_plan.rb +1 -1
- data/lib/file_sv/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6fe6c5fff5f5d93506024349027d89d5ae0331b22f1dc15c94aaf72b18d1c8a
|
4
|
+
data.tar.gz: b8c7f47b3602949beb64b5b7e9fa7f859b2fc3020f5c1a3d91fa9a6309a1ad8a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b6521770efbd56f4b790650de3801668e80b4c197e995d3cdd1a97326013c58e241d265caf1735eeeae020050aa775ad44d7acb29b0c651aa3401b109bd7be0
|
7
|
+
data.tar.gz: ac3d6a6d948161f2b96f38090a148e3605927a9a43a690a05933b3a942905903f1c95b9e84ead1a204441b7edd66ef179be8aac3e30d6ddb2946a0330314d195
|
data/lib/file_sv.rb
CHANGED
@@ -49,4 +49,16 @@ def load_rest_method_config(config)
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
+
# Set global params based on ENV vars
|
53
|
+
def set_based_on_env_vars
|
54
|
+
GlobalSettings.instance_variables.each do |setting|
|
55
|
+
setting_name = setting.to_s[1..-1]
|
56
|
+
if ENV[setting_name]
|
57
|
+
puts "Setting #{setting_name} to #{ENV[setting_name]}"
|
58
|
+
GlobalSettings.send("#{setting_name}=", ENV[setting_name])
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
52
63
|
load_default_config CONFIG_FILE
|
64
|
+
set_based_on_env_vars
|
@@ -6,7 +6,8 @@ class FileProcessor
|
|
6
6
|
class << self
|
7
7
|
# Process file, adding it to plan
|
8
8
|
def process(filename)
|
9
|
-
|
9
|
+
endpoint = PlannedEndpoint.new(filename)
|
10
|
+
SvPlan + endpoint unless GlobalSettings.ignored_status? endpoint.status_code
|
10
11
|
end
|
11
12
|
end
|
12
13
|
end
|
@@ -9,6 +9,8 @@ class GlobalSettings
|
|
9
9
|
@ignore_files = "{*.md,Dockerfile,.*}"
|
10
10
|
|
11
11
|
@https = false
|
12
|
+
|
13
|
+
@ignore_status_codes = nil
|
12
14
|
class << self
|
13
15
|
# @return [String] Default REST method when none specified by filename
|
14
16
|
attr_accessor :default_method
|
@@ -22,9 +24,27 @@ class GlobalSettings
|
|
22
24
|
attr_accessor :cert
|
23
25
|
# @return [String] Path to HTTPS key
|
24
26
|
attr_accessor :key
|
27
|
+
# @return [Array] List of http status codes to ignore
|
28
|
+
attr_accessor :ignore_status_codes
|
29
|
+
|
30
|
+
# @param [Integer] status_code HTTP status code
|
31
|
+
# @return [Boolean] Whether status code is currently ignored
|
32
|
+
def ignored_status?(status_code)
|
33
|
+
return unless ignore_status_codes
|
34
|
+
|
35
|
+
ignore_status_codes.split(",").each do |code|
|
36
|
+
regex = Regexp.new code.to_s
|
37
|
+
result = status_code.to_s[regex]
|
38
|
+
next unless result
|
39
|
+
|
40
|
+
return true unless result.empty?
|
41
|
+
end
|
42
|
+
false
|
43
|
+
end
|
25
44
|
end
|
26
45
|
end
|
27
46
|
|
47
|
+
# Http settings that all HTTP method types inherit
|
28
48
|
module CommonHttpSettings
|
29
49
|
attr_accessor :default_status
|
30
50
|
end
|
data/lib/file_sv/sv_plan.rb
CHANGED
@@ -34,7 +34,7 @@ class SvPlan
|
|
34
34
|
# Show plan
|
35
35
|
def show
|
36
36
|
endpoint_desc = ""
|
37
|
-
endpoints.sort { |a, b| a[0].
|
37
|
+
endpoints.sort { |a, b| a[0].casecmp b[0] }.each do |endpoint, methods|
|
38
38
|
endpoint_desc += "#{endpoint} \n"
|
39
39
|
methods.each do |method_name, endpoints|
|
40
40
|
endpoint_desc += description_message method_name, endpoints
|
data/lib/file_sv/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: file_sv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Garratt
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-03-
|
11
|
+
date: 2021-03-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faker
|