Skip to content

Commit

Permalink
fix syntax errors from rubocop autocorrect
Browse files Browse the repository at this point in the history
  • Loading branch information
elg0nz committed Sep 25, 2024
1 parent 654639d commit 2b5bfc6
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 12 deletions.
6 changes: 6 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ require:
AllCops:
NewCops: enable

Exclude:
- 'lib/hawksi.rb'

Style/HashSyntax:
Enabled: false

Layout/HeredocIndentation:
Exclude:
- 'lib/hawksi.rb'
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ group :development, :test do
gem 'bundler'
gem 'rake'
gem 'rspec', '~> 3.13'
gem 'rubocop'
gem 'rubocop', '1.66.1'
gem 'rubocop-rake'
gem 'rubocop-rspec'
gem 'ruby-lsp'
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ DEPENDENCIES
rack-test (~> 1.1)
rake
rspec (~> 3.13)
rubocop
rubocop (= 1.66.1)
rubocop-rake
rubocop-rspec
ruby-lsp
Expand Down
2 changes: 1 addition & 1 deletion lib/command_executor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def execute_command(command, params) # rubocop:disable Metrics/MethodLength
def build_request_body(command, params)
{
client_id: client_uuid,
command:,
command: command,
instructions: params.join(' ')
}.to_json
end
Expand Down
10 changes: 4 additions & 6 deletions lib/hawksi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
require 'cli'
require 'request_interceptor'


BANNER = <<~BANNER
_ _
/\ /\__ ___ _| | _____(_)
/ /_/ / _` \ \ /\ / / |/ / __| |
/ __ / (_| |\ V V /| <\__ \ |
\/ /_/ \__,_| \_/\_/ |_|\_\___/_|
/\\ /\\__ ___ _| | _____(_)
/ /_/ / _` \\ \\ /\\ / / |/ / __| |
/ __ / (_| |\\ V V /| <\\__ \\ |
\\/ /_/ \\__,_| \\_/\\_/ |_|\\_\\___/_|
BANNER


puts BANNER
10 changes: 7 additions & 3 deletions lib/mocksi_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ class << self
def fetch_mocksi_server_url
mocksi_server_url = Hawksi.configuration.mocksi_server
raise 'Mocksi server URL not configured' if mocksi_server_url.nil? || mocksi_server_url.empty?

mocksi_server_url
end

def prep_headers((request))
def prep_headers(request)
headers = {}
request.env.each do |key, value|
if key.start_with?('HTTP_')
Expand Down Expand Up @@ -57,7 +59,7 @@ def handle(request) # rubocop:disable Metrics/MethodLength,Metrics/AbcSize
headers['Cookie'] = request.cookies.map { |k, v| "#{k}=#{v}" }.join('; ') if request.cookies.any?

# Initialize httpx with headers
http_client = HTTPX.with(headers:)
http_client = HTTPX.with(headers: headers)

# Forward the body content if it's a POST or PUT request
body = nil
Expand All @@ -66,7 +68,9 @@ def handle(request) # rubocop:disable Metrics/MethodLength,Metrics/AbcSize
body = request.body.read
end

response = http_client.request(request.request_method.downcase.to_sym, target_uri, body:)
response = http_client.request(request.request_method.downcase.to_sym, target_uri, body: body)
response_body = build_response_body(response)
response_headers = response.headers.to_h

# Return the response in a format compatible with Rack
[response.status, response_headers, [response_body]]
Expand Down

0 comments on commit 2b5bfc6

Please sign in to comment.