Skip to content

Commit

Permalink
feat: replace term-ansicolor with rainbow
Browse files Browse the repository at this point in the history
Because of potential for namespace clashes with the word "Term"
  • Loading branch information
Benjaminpjacobs authored Mar 4, 2022
1 parent 76f5ed6 commit e8b6ada
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
6 changes: 2 additions & 4 deletions lib/pact/matchers/embedded_diff_formatter.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
require 'pact/shared/active_support_support'
require 'term/ansicolor'
require 'rainbow'

module Pact
module Matchers
class EmbeddedDiffFormatter

include Pact::ActiveSupportSupport
C = ::Term::ANSIColor


EXPECTED = /"EXPECTED([A-Z_]*)":/

Expand Down Expand Up @@ -53,7 +51,7 @@ def colourise line
end

def coloured_key match, colour
'"' + C.color(colour, match.downcase.gsub(/^"|":$/,'')) + '":'
'"' + Rainbow(match.downcase.gsub(/^"|":$/,'')).send(colour) + '":'
end

end
Expand Down
4 changes: 2 additions & 2 deletions lib/tasks/pact.rake
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ namespace :pact do

desc "Verifies the pact at the given URI against this service provider."
task 'verify:at', :pact_uri do | t, args |
require 'term/ansicolor'
require 'rainbow'
require 'pact/tasks/task_helper'

include Pact::TaskHelper

abort(::Term::ANSIColor.red("Please provide a pact URI. eg. rake pact:verify:at[../my-consumer/spec/pacts/my_consumer-my_provider.json]")) unless args[:pact_uri]
abort(Rainbow("Please provide a pact URI. eg. rake pact:verify:at[../my-consumer/spec/pacts/my_consumer-my_provider.json]").red) unless args[:pact_uri]
handle_verification_failure do
execute_pact_verify args[:pact_uri]
end
Expand Down
2 changes: 1 addition & 1 deletion pact-support.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
spec.files = `git ls-files lib CHANGELOG.md LICENSE.txt README.md`.split($RS)
spec.require_paths = ["lib"]

spec.add_runtime_dependency "term-ansicolor", "~> 1.0"
spec.add_runtime_dependency "rainbow", "~> 3.1.1"
spec.add_runtime_dependency "awesome_print", "~> 1.9"
spec.add_runtime_dependency "diff-lcs", "~> 1.4"
spec.add_runtime_dependency "expgen", "~> 0.1"
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/pact/matchers/embedded_diff_formatter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ module Matchers
subject { EmbeddedDiffFormatter.call(diff, options) }

let(:options) { { colour: colour }}
let(:expected_coloured) { '"' + ::Term::ANSIColor.red("expected_type") + '":'}
let(:actual_coloured) { '"' + ::Term::ANSIColor.green("actual_type") + '":'}
let(:expected_coloured) { '"' + Rainbow("expected_type").red + '":'}
let(:actual_coloured) { '"' + Rainbow("actual_type").green + '":'}

describe ".call" do

Expand Down

0 comments on commit e8b6ada

Please sign in to comment.