Class: DeployChanges::Path
- Inherits:
-
Object
- Object
- DeployChanges::Path
- Defined in:
- lib/deploy_changes/path.rb
Instance Attribute Summary collapse
-
#last_sha1 ⇒ Object
readonly
Returns the value of attribute last_sha1.
-
#repo ⇒ Object
readonly
Returns the value of attribute repo.
Instance Method Summary collapse
- #changed?(path) ⇒ Boolean
-
#initialize(repo, last_sha1) ⇒ Path
constructor
A new instance of Path.
Constructor Details
#initialize(repo, last_sha1) ⇒ Path
Returns a new instance of Path.
7 8 9 10 |
# File 'lib/deploy_changes/path.rb', line 7 def initialize(repo, last_sha1) @repo = repo @last_sha1 = last_sha1 end |
Instance Attribute Details
#last_sha1 ⇒ Object (readonly)
Returns the value of attribute last_sha1.
5 6 7 |
# File 'lib/deploy_changes/path.rb', line 5 def last_sha1 @last_sha1 end |
#repo ⇒ Object (readonly)
Returns the value of attribute repo.
5 6 7 |
# File 'lib/deploy_changes/path.rb', line 5 def repo @repo end |
Instance Method Details
#changed?(path) ⇒ Boolean
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/deploy_changes/path.rb', line 12 def changed?(path) return true if last_sha1.nil? diff = repo.index.diff(last_commit) diff.each_delta do |delta| files = [delta.old_file[:path], delta.new_file[:path]] return true if files.any? { |diff_path| diff_path =~ /^#{path}/ } end false end |