class PactBroker::Pacts::Diff::DiffDecorator
The next pact version after the previous distinct version. Eg. v1 (previous distinct) -> pactContentA
v2 (next pact) -> pactContentB v3 -> pactContentB v4 (current) -> pactContentB
If we are at v4, then the previous distinct pact version is v1, and the next pact after that is v2. The timestamps on v2 are the ones we want - that’s when the latest distinct version content was first created.
Attributes
Public Class Methods
Source
# File lib/pact_broker/pacts/diff.rb, line 51 def initialize(pact, comparison_pact, next_pact, base_url, options) @pact = pact @comparison_pact = comparison_pact @next_pact = next_pact @base_url = base_url @options = options end
Public Instance Methods
Source
# File lib/pact_broker/pacts/diff.rb, line 59 def to_text header + "\n\n" + diff + "\n\n" + links end
Private Instance Methods
Source
# File lib/pact_broker/pacts/diff.rb, line 105 def change_date_ago_in_words DateHelper.distance_of_time_in_words next_pact.created_at, now end
Source
# File lib/pact_broker/pacts/diff.rb, line 67 def change_date_in_words DateHelper.local_date_in_words next_pact.created_at end
Source
# File lib/pact_broker/pacts/diff.rb, line 101 def diff CreateFormattedDiff.(prepare_content(pact.json_content), prepare_content(comparison_pact.json_content)) end
Source
# File lib/pact_broker/pacts/diff.rb, line 75 def header title = "# Diff between versions #{comparison_pact.consumer_version_number} and #{pact.consumer_version_number} of the pact between #{pact.consumer.name} and #{pact.provider.name}" description = "The following changes were made #{change_date_ago_in_words} ago (#{change_date_in_words})" title + "\n\n" + description end
Source
# File lib/pact_broker/pacts/diff.rb, line 82 def links self_url = PactBroker::Api::PactBrokerUrls.pact_url(base_url, pact) previous_distinct_url = PactBroker::Api::PactBrokerUrls.pact_url(base_url, comparison_pact) links = { "pact-version" => { "title" => "Pact", "name" => pact.name, "href" => self_url }, "comparison-pact-version" => { "title" => "Pact", "name" => comparison_pact.name, "href" => previous_distinct_url } } "## Links\n" + YAML.dump(links).gsub(/---/,"") end
Source
# File lib/pact_broker/pacts/diff.rb, line 109 def prepare_content json_content if options[:raw] json_content else SortContent.call(Parse.call(json_content)).to_json end end