Skip to content

Commit

Permalink
refactor code formatting and improve readability
Browse files Browse the repository at this point in the history
  • Loading branch information
dorianmariecom committed Sep 6, 2024
1 parent 6aa8158 commit 7bec0eb
Showing 1 changed file with 21 additions and 16 deletions.
37 changes: 21 additions & 16 deletions lib/dorian/bin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,11 @@ def command_dir

def command_submodules
puts(
File.read(".gitmodules").lines.grep(/path = /).map do |path|
path.split("=").last.strip
end
File
.read(".gitmodules")
.lines
.grep(/path = /)
.map { |path| path.split("=").last.strip }
)

puts "." if self?
Expand All @@ -287,17 +289,18 @@ def self?
def command_compare
file_1, file_2 = files
key_1, key_2 = arguments
read_1, read_2 = files.map.with_index do |file, index|
read = reads(File.read(file))

if arguments[index] && read.from_deep_struct.has_key?(arguments[index])
read[arguments[index]]
elsif arguments[index]
nil
else
read
read_1, read_2 =
files.map.with_index do |file, index|
read = reads(File.read(file))

if arguments[index] && read.from_deep_struct.key?(arguments[index])
read[arguments[index]]
elsif arguments[index]
nil
else
read
end
end
end

compare(read_1, read_2, file_1:, file_2:)
end
Expand Down Expand Up @@ -813,7 +816,7 @@ def post(url, headers: {}, body: {})
http.request(request).body
end

def compare(content_1, content_2, path: ".", file_1:, file_2:)
def compare(content_1, content_2, file_1:, file_2:, path: ".")
content_1 = content_1.from_deep_struct
content_2 = content_2.from_deep_struct

Expand All @@ -830,7 +833,8 @@ def compare(content_1, content_2, path: ".", file_1:, file_2:)
end

compare(
content_1[key], content_2[key],
content_1[key],
content_2[key],
path: new_path,
file_1:,
file_2:
Expand All @@ -848,7 +852,8 @@ def compare(content_1, content_2, path: ".", file_1:, file_2:)
end

compare(
content_1[index], content_2[index],
content_1[index],
content_2[index],
path: new_path,
file_1:,
file_2:
Expand Down

0 comments on commit 7bec0eb

Please sign in to comment.