Skip to content

Commit

Permalink
Improve diff module OutputBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
hahwul committed Jul 20, 2024
1 parent d78dd0f commit 3240fdd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion spec/unit_test/utils/yaml_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ describe "yaml" do
it "true" do
valid_yaml?("a: 1").should eq(true)
end

it "false" do
valid_yaml?("key: \"value").should eq(false)
end
Expand Down
3 changes: 0 additions & 3 deletions src/models/noir.cr
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,6 @@ class NoirRunner
when "json"
builder.print_json @endpoints, diff_app
else
# Print default output
report()

# Print diff output
builder.print @endpoints, diff_app
end
Expand Down
17 changes: 10 additions & 7 deletions src/output_builder/diff.cr
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require "../models/output_builder"
require "./diff"
require "../models/endpoint"

require "json"
Expand Down Expand Up @@ -28,19 +29,21 @@ class OutputBuilderDiff < OutputBuilder
end

def print(endpoints : Array(Endpoint), diff_app : NoirRunner)
@logger.system "============== DIFF =============="
result = diff(endpoints, diff_app.endpoints)

result[:added].each do |endpoint|
@logger.info "Added: #{endpoint.url} #{endpoint.method}"
if result[:added].size > 0
@logger.puts "============== Added ================"
OutputBuilderCommon.new(@options).print(result[:added])
end

result[:removed].each do |endpoint|
@logger.info "Removed: #{endpoint.url} #{endpoint.method}"
if result[:removed].size > 0
@logger.puts "\n============== Removed =============="
OutputBuilderCommon.new(@options).print(result[:removed])
end

result[:changed].each do |endpoint|
@logger.info "Changed: #{endpoint.url} #{endpoint.method}"
if result[:changed].size > 0
@logger.puts "\n============== Changed =============="
OutputBuilderCommon.new(@options).print(result[:changed])
end
end

Expand Down

0 comments on commit 3240fdd

Please sign in to comment.