Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto corrected by following Lint Ruby EmptyLine #41

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
fgt_rest_api (0.1.4)
fgt_rest_api (0.1.5)
httpclient
netaddr

Expand All @@ -22,4 +22,4 @@ DEPENDENCIES
rake (~> 10.0)

BUNDLED WITH
1.16.1
1.16.4
1 change: 1 addition & 0 deletions bin/fgt_policy2xlsx.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def add_row(
add_obj_xlsxreference(object) unless object.nil?
@cell.y_incr
return @sheet.ws.add_row(@headers, styles: styles, types: types, widths: widths) if row.nil?

@sheet.ws.add_row(row, styles: styles, types: types, widths: widths)
end

Expand Down
4 changes: 2 additions & 2 deletions lib/fgt_rest_api/ext/ipsec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ def ipsec_tunnel_children
end

def ipsec_incoming_bytes(tunnel_parent)
ipsec_tunnels.select { |t| t['parent'] == tunnel_parent || t['name'] == tunnel_parent }.map { |t2| t2['incoming_bytes'] }.inject(0){|sum,x| sum + x }
ipsec_tunnels.select { |t| t['parent'] == tunnel_parent || t['name'] == tunnel_parent }.map { |t2| t2['incoming_bytes'] }.inject(0) { |sum, x| sum + x }
end

def ipsec_outgoing_bytes(tunnel_parent)
ipsec_tunnels.select { |t| t['parent'] == tunnel_parent || t['name'] == tunnel_parent }.map { |t2| t2['outgoing_bytes'] }.inject(0){|sum,x| sum + x }
ipsec_tunnels.select { |t| t['parent'] == tunnel_parent || t['name'] == tunnel_parent }.map { |t2| t2['outgoing_bytes'] }.inject(0) { |sum, x| sum + x }
end
end
end
2 changes: 2 additions & 0 deletions lib/fgt_rest_api/ext/policy_and_object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class RestApi

def clear_cache_var(ivar)
return nil unless instance_variable_defined?(ivar) && @inst_var_refreshable.include?(ivar)

remove_instance_variable(ivar)
@inst_var_refreshable.tap { |a| a.delete(ivar) }
end
Expand Down Expand Up @@ -77,6 +78,7 @@ def find_group_for_object(object, vdom = use_vdom)
groups.each do |group|
grouped_groups = find_group_for_object(group[:name], vdom)
next if grouped_groups.empty?

groups += grouped_groups
end
groups.flatten.uniq.compact
Expand Down
10 changes: 10 additions & 0 deletions lib/fgt_rest_api/ext/ssl.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# frozen_string_literal: true

module FGT
class RestApi
def ssl_tunnels(tunnel_name = nil)
options = tunnel_name.yield_self { |t| t.nil? ? {} : { tunnel: tunnel_name } }
monitor_get('vpn/ssl/select', options).results.uniq
end
end
end
4 changes: 4 additions & 0 deletions lib/fgt_rest_api/fc_hash.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module FGT
class FCHash < ::Hash
def []=(key, value)
raise(ArgumentError, "key needs start with downcase letter: >>#{key}<<") unless key[0] == key[0].downcase

if key.is_a?(String)
super(key, value)
elsif key.is_a?(Symbol)
Expand All @@ -16,6 +17,7 @@ def []=(key, value)

def [](key)
raise(ArgumentError, "key needs start with downcase: >>#{key}<<") unless key.to_s[0] == key.to_s[0].downcase

if key.is_a?(String)
super(key)
elsif key.is_a?(Symbol)
Expand All @@ -36,6 +38,7 @@ def attribute_methods(key, value)
def getter_method(key)
method_name = key.to_s.tr('-', '_')
return true if respond_to?(method_name.to_sym)

define_singleton_method(method_name) do
begin
fetch(key)
Expand All @@ -48,6 +51,7 @@ def getter_method(key)
def setter_method(key)
method_name = key.to_s.tr('-', '_') + '='
return true if respond_to?(method_name.to_sym)

define_singleton_method(method_name) { |v| store(key, v) }
end
end
Expand Down
3 changes: 3 additions & 0 deletions lib/fgt_rest_api/rest_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def proxy=(pxy)
%w[get post].each do |request_method|
define_method('monitor_' + request_method) do |path, params = {}|
raise(SafeModeActiveError) if request_method != 'get' && safe_mode

url_path = "api/#{api_version}/monitor/#{path.gsub(/\/*$/, '')}/"
params[:vdom] = use_vdom unless params.key?(:vdom)
request(request_method, url_path, params)
Expand All @@ -91,6 +92,7 @@ def proxy=(pxy)
def memoize_results(key)
(@inst_var_refreshable || @inst_var_refreshable = Set.new) << key
return instance_variable_get(key) if instance_variable_defined?(key)

instance_variable_set(key, yield)
end

Expand Down Expand Up @@ -122,6 +124,7 @@ def cmdb(request_method: 'get', path:, name:, mkey: '', child_name: '', child_mk
raise(CMDBMKeyError) unless /^[^\/]*$/.match?(mkey)
raise(CMDBChildNameError) unless /^[^\/]*$/.match?(child_name)
raise(CMDBChildMKeyError) unless /^[^\/]*$/.match?(child_mkey)

url_path = "api/#{api_version}/cmdb/#{path}/#{name}/"
unless mkey.empty?
url_path += "#{mkey}/"
Expand Down
2 changes: 1 addition & 1 deletion lib/fgt_rest_api/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module FgtRestApi
VERSION = '0.1.5'
VERSION = '0.1.6'
end