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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bb4214e64bca77866967b848fb88c40eabe0a999d03e1ba88e47500662314b44
4
- data.tar.gz: de2aa37269d3fc2d22904a1535a2d8e6308f011baae82fd352ee853def74f4d4
3
+ metadata.gz: a6fe6c5fff5f5d93506024349027d89d5ae0331b22f1dc15c94aaf72b18d1c8a
4
+ data.tar.gz: b8c7f47b3602949beb64b5b7e9fa7f859b2fc3020f5c1a3d91fa9a6309a1ad8a
5
5
  SHA512:
6
- metadata.gz: 72685470cd73d2f13d6e0d5894980d7603787204bcd5d454f339f81d105f96f0276b9d32026e3485e02abeb9001fcfe25648d64686fa804c0f57fc5a9df3ec0d
7
- data.tar.gz: 786f78f51f7c02605b235c4306b972f67c33cd31c537a1af0ec41b363f5b8c340baee5648f40a3ae9006dc3561783d8dab6086d4412e4844da0515ff5d6175d8
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
- SvPlan + PlannedEndpoint.new(filename)
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
@@ -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].length - b[0].length }.each do |endpoint, methods|
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FileSv
4
- VERSION = "0.1.5"
4
+ VERSION = "0.1.6"
5
5
  end
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.5
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-08 00:00:00.000000000 Z
11
+ date: 2021-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faker