class Dandelion::Changeset
Public Class Methods
new(tree, commit, options = {})
click to toggle source
# File lib/dandelion/changeset.rb, line 5 def initialize(tree, commit, options = {}) @tree = tree @commit = commit @options = options end
Public Instance Methods
diff()
click to toggle source
# File lib/dandelion/changeset.rb, line 11 def diff Diff.new(@commit, @tree.commit) end
each() { |change| ... }
click to toggle source
# File lib/dandelion/changeset.rb, line 19 def each diff.each do |change| if applicable?(change.path) path = transform_path(change.path) if change.type == :delete yield Change.new(path, change.type) else read = -> { @tree.data(change.path) } if @tree.symlink?(change.path) yield Change.new(path, :symlink, read) else yield Change.new(path, change.type, read) end end end end end
empty?()
click to toggle source
# File lib/dandelion/changeset.rb, line 15 def empty? diff.empty? end
Private Instance Methods
applicable?(path)
click to toggle source
# File lib/dandelion/changeset.rb, line 49 def applicable?(path) expand_path(path).start_with?(expand_path(local_path)) end
expand_path(path)
click to toggle source
# File lib/dandelion/changeset.rb, line 41 def expand_path(path) File.expand_path(path).to_s end
local_path()
click to toggle source
# File lib/dandelion/changeset.rb, line 45 def local_path expand_path(@options[:local_path] || '') end
transform_path(path)
click to toggle source
# File lib/dandelion/changeset.rb, line 53 def transform_path(path) trimmed = expand_path(path)[expand_path(local_path).length..-1] trimmed = trimmed[1..-1] if trimmed[0] == File::SEPARATOR trimmed end