Class: Jack::Config::Diff
- Inherits:
-
Object
- Object
- Jack::Config::Diff
- Defined in:
- lib/jack/config/diff.rb
Instance Attribute Summary collapse
-
#transmit ⇒ Object
readonly
Returns the value of attribute transmit.
Instance Method Summary collapse
- #cleanup_files ⇒ Object
- #compute_diff(current, local) ⇒ Object
- #diff_command ⇒ Object
-
#initialize(options = {}) ⇒ Diff
constructor
A new instance of Diff.
- #run ⇒ Object
Constructor Details
Instance Attribute Details
#transmit ⇒ Object (readonly)
Returns the value of attribute transmit.
4 5 6 |
# File 'lib/jack/config/diff.rb', line 4 def transmit @transmit end |
Instance Method Details
#cleanup_files ⇒ Object
34 35 36 37 |
# File 'lib/jack/config/diff.rb', line 34 def cleanup_files return false if @options[:dirty] @download.clean(mute=true) end |
#compute_diff(current, local) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/jack/config/diff.rb', line 19 def compute_diff(current, local) # the diff command returns 0 when there is no difference and returns 1 when there is a difference pretty_current_path = @download.current_path.sub(/.*\.elasticbeanstalk/,'.elasticbeanstalk') command = "#{diff_command} #{pretty_current_path} #{@download.local_config_path}" UI.say("=> #{command}") return if @options[:noop] sorter = YamlFormatter.new sorter.process(current) sorter.process(local) no_difference = system(command) !no_difference end |
#diff_command ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/jack/config/diff.rb', line 39 def diff_command return ENV['JACK_DIFF'] if ENV['JACK_DIFF'] if system("type colordiff > /dev/null 2>&1") "colordiff" else "diff" end end |
#run ⇒ Object
12 13 14 15 16 17 |
# File 'lib/jack/config/diff.rb', line 12 def run @download.get_current_cfg difference = compute_diff(@download.current_path, @download.local_config_path) cleanup_files difference end |