Class: Xcodeproj::Command::ProjectDiff

Inherits:
Xcodeproj::Command show all
Defined in:
lib/xcodeproj/command/project_diff.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ ProjectDiff

Returns a new instance of ProjectDiff.



25
26
27
28
29
30
# File 'lib/xcodeproj/command/project_diff.rb', line 25

def initialize(argv)
  @path_project1  = argv.shift_argument
  @path_project2  = argv.shift_argument
  @keys_to_ignore = argv.all_options('ignore')
  super
end

Class Method Details

.optionsObject



14
15
16
17
18
# File 'lib/xcodeproj/command/project_diff.rb', line 14

def self.options
  [
    ['--ignore=KEY', 'A key to ignore in the comparison. Can be specified multiple times.'],
  ].concat(super)
end

Instance Method Details

#runObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/xcodeproj/command/project_diff.rb', line 37

def run
  hash_1 = @project1.to_tree_hash.dup
  hash_2 = @project2.to_tree_hash.dup
  @keys_to_ignore.each do |key|
    Differ.clean_hash!(hash_1, key)
    Differ.clean_hash!(hash_2, key)
  end

  diff = Differ.project_diff(hash_1, hash_2, @path_project1, @path_project2)

  require 'yaml'
  yaml = diff.to_yaml
  yaml.gsub!(@path_project1, @path_project1.cyan)
  yaml.gsub!(@path_project2, @path_project2.magenta)
  yaml.gsub!(':diff:', 'diff:'.yellow)
  puts yaml
end

#validate!Object



32
33
34
35
# File 'lib/xcodeproj/command/project_diff.rb', line 32

def validate!
  super
  @project1, @project2 = open_project!(@path_project1, @path_project2)
end