Class: Orats::Commands::Diff::Exec

Inherits:
Common
  • Object
show all
Includes:
Compare, Parse
Defined in:
lib/orats/commands/diff/exec.rb

Constant Summary

Constants inherited from Common

Common::RELATIVE_PATHS

Instance Attribute Summary collapse

Attributes inherited from Common

#local_paths, #remote_gem_version, #remote_paths

Instance Method Summary collapse

Methods included from Compare

#remote_gem_vs_yours, #remote_vs_yours

Methods included from Parse

#galaxyfile, #gem_version, #hosts, #inventory, #playbook

Methods inherited from Common

#base_path, copy_from_local_gem, #exit_if_path_exists, #exit_if_process, #file_to_string, #repo_path, #url_to_string

Methods included from UI

#git_commit, #log_error, #log_remote_info, #log_results, #log_status_bottom, #log_status_top, #log_task, #run_from

Constructor Details

#initialize(target_path = '', options = {}) ⇒ Exec

Returns a new instance of Exec.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/orats/commands/diff/exec.rb', line 15

def initialize(target_path = '', options = {})
  super

  @remote_galaxyfile = galaxyfile url_to_string(@remote_paths[:galaxyfile])
  @remote_playbook   = playbook url_to_string(@remote_paths[:playbook])
  @remote_hosts      = hosts url_to_string(@remote_paths[:hosts])
  @remote_inventory  = inventory url_to_string(@remote_paths[:inventory])

  galaxyfile_path = @options[:galaxyfile]
  playbook_path   = @options[:playbook]
  hosts_path      = @options[:hosts]
  inventory_path  = @options[:inventory]

  if !@options[:inventory].empty? && File.directory?(@options[:inventory])
    hosts_path     = File.join(inventory_path, 'hosts')
    inventory_path = File.join(inventory_path, 'group_vars/all.yml')
  end

  if !@options[:playbook].empty? && File.directory?(@options[:playbook])
    galaxyfile_path = File.join(playbook_path, 'Galaxyfile')
    playbook_path   = File.join(playbook_path, 'site.yml')
  end

  @your_galaxyfile = galaxyfile file_to_string (galaxyfile_path) unless galaxyfile_path.empty?
  @your_playbook   = playbook file_to_string(playbook_path) unless playbook_path.empty?
  @your_hosts      = hosts file_to_string(hosts_path) unless hosts_path.empty?
  @your_inventory  = inventory file_to_string(inventory_path) unless inventory_path.empty?

end

Instance Attribute Details

#diff_listObject

Returns the value of attribute diff_list.



13
14
15
# File 'lib/orats/commands/diff/exec.rb', line 13

def diff_list
  @diff_list
end

Instance Method Details

#initObject



45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/orats/commands/diff/exec.rb', line 45

def init
  remote_gem_vs_yours

  remote_vs_yours('galaxyfile', @remote_galaxyfile,
                  @your_galaxyfile, false) unless @your_galaxyfile.nil?
  remote_vs_yours('playbook', @remote_playbook,
                  @your_playbook, true) unless @your_playbook.nil?
  remote_vs_yours('hosts', @remote_hosts,
                  @your_hosts, true) unless @your_hosts.nil?
  remote_vs_yours('inventory', @remote_inventory,
                  @your_inventory, true) unless @your_inventory.nil?
end