Class: Bundler::Diff::Tool
- Inherits:
-
Object
- Object
- Bundler::Diff::Tool
- Defined in:
- lib/bundler/diff/tool.rb
Instance Attribute Summary collapse
-
#a_dir ⇒ Object
Returns the value of attribute a_dir.
-
#a_output_dir ⇒ Object
Returns the value of attribute a_output_dir.
-
#b_dir ⇒ Object
Returns the value of attribute b_dir.
-
#b_output_dir ⇒ Object
Returns the value of attribute b_output_dir.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#a_dir ⇒ Object
Returns the value of attribute a_dir.
6 7 8 |
# File 'lib/bundler/diff/tool.rb', line 6 def a_dir @a_dir end |
#a_output_dir ⇒ Object
Returns the value of attribute a_output_dir.
7 8 9 |
# File 'lib/bundler/diff/tool.rb', line 7 def a_output_dir @a_output_dir end |
#b_dir ⇒ Object
Returns the value of attribute b_dir.
9 10 11 |
# File 'lib/bundler/diff/tool.rb', line 9 def b_dir @b_dir end |
#b_output_dir ⇒ Object
Returns the value of attribute b_output_dir.
10 11 12 |
# File 'lib/bundler/diff/tool.rb', line 10 def b_output_dir @b_output_dir end |
Class Method Details
.diff(a_spec, b_spec) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/bundler/diff/tool.rb', line 12 def self.diff(a_spec, b_spec) tool = new tool.a_dir = Pathname(a_spec.gem_dir) tool.a_output_dir = Pathname(a_spec.full_name) tool.b_dir = Pathname(b_spec.gem_dir) tool.b_output_dir = Pathname(b_spec.full_name) tool.diff_entries end |
Instance Method Details
#diff(a_path, b_path) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/bundler/diff/tool.rb', line 33 def diff(a_path, b_path) null = '/dev/null' command = ['diff -u'] command_for_output = ['diff'] if a_path command.concat [a_dir.join(a_path), '--label', Pathname('a').join(a_path)] command_for_output << a_output_dir.join(a_path) else command << null command_for_output << null end if b_path command.concat [b_dir.join(b_path), '--label', Pathname('b').join(b_path)] command_for_output << b_output_dir.join(b_path) else command << null command_for_output << null end output = `#{command.join(' ')}` return if output.empty? puts command_for_output.join(' ') puts output end |
#diff_entries ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/bundler/diff/tool.rb', line 21 def diff_entries a_files = file_list(a_dir) b_files = file_list(b_dir) (a_files + b_files).uniq.sort.each do |path| a_path = a_files.include?(path) ? path : nil b_path = b_files.include?(path) ? path : nil diff(a_path, b_path) end end |