Class: Manifestly::Diff
- Inherits:
-
Object
- Object
- Manifestly::Diff
- Defined in:
- lib/manifestly/diff.rb
Defined Under Namespace
Classes: File
Instance Attribute Summary collapse
-
#files ⇒ Object
readonly
Returns the value of attribute files.
Instance Method Summary collapse
- #[](index) ⇒ Object
- #has_file?(filename) ⇒ Boolean
-
#initialize(diff_string) ⇒ Diff
constructor
A new instance of Diff.
- #num_files ⇒ Object
Constructor Details
#initialize(diff_string) ⇒ Diff
Returns a new instance of Diff.
49 50 51 52 53 54 |
# File 'lib/manifestly/diff.rb', line 49 def initialize(diff_string) file_strings = diff_string.split("diff --git ") file_strings.reject!(&:blank?) file_strings.reject!{|str| str.starts_with?("commit ")} # from 'git show' output @files = file_strings.collect{|file_string| File.new(file_string)} end |
Instance Attribute Details
#files ⇒ Object (readonly)
Returns the value of attribute files.
56 57 58 |
# File 'lib/manifestly/diff.rb', line 56 def files @files end |
Instance Method Details
#[](index) ⇒ Object
66 67 68 |
# File 'lib/manifestly/diff.rb', line 66 def [](index) files[index] end |
#has_file?(filename) ⇒ Boolean
58 59 60 |
# File 'lib/manifestly/diff.rb', line 58 def has_file?(filename) files.any?{|file| file.to_name == filename || file.from_name == filename} end |
#num_files ⇒ Object
62 63 64 |
# File 'lib/manifestly/diff.rb', line 62 def num_files files.length end |