Sha256: 9fee7529cf906bec48b782adf16b8e587d2a015cfcc20d0e038fbaf2880244b2

Contents?: true

Size: 1.07 KB

Versions: 8

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true

require 'chamber/instance'
require 'chamber/commands/base'
require 'chamber/commands/comparable'

module  Chamber
module  Commands
class   Compare < Chamber::Commands::Base
  include Chamber::Commands::Comparable

  attr_accessor :first_settings_instance,
                :second_settings_instance

  def self.call(options = {})
    new(options).call
  end

  def initialize(options = {})
    super

    first_settings_options        = options.merge(namespaces: options[:first])
    self.first_settings_instance  = Chamber::Instance.new(first_settings_options)

    second_settings_options       = options.merge(namespaces: options[:second])
    self.second_settings_instance = Chamber::Instance.new(second_settings_options)
  end

  protected

  def first_settings_data
    settings_data(first_settings_instance)
  end

  def second_settings_data
    settings_data(second_settings_instance)
  end

  def settings_data(instance)
    if keys_only
      instance.to_environment.keys.join("\n")
    else
      instance.to_s(pair_separator: "\n")
    end
  end
end
end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
chamber-2.13.1 lib/chamber/commands/compare.rb
chamber-2.13.0 lib/chamber/commands/compare.rb
chamber-2.12.5 lib/chamber/commands/compare.rb
chamber-2.12.3 lib/chamber/commands/compare.rb
chamber-2.12.2 lib/chamber/commands/compare.rb
chamber-2.12.1 lib/chamber/commands/compare.rb
chamber-2.12.0 lib/chamber/commands/compare.rb
chamber-2.11.0 lib/chamber/commands/compare.rb