Module: KnifeTable::Helpers

Included in:
TableClear, TableOrder, TableServe, TableSet
Defined in:
lib/knife-table/helpers.rb

Instance Method Summary collapse

Instance Method Details

#cookbook_pathObject



7
8
9
# File 'lib/knife-table/helpers.rb', line 7

def cookbook_path
  Chef::Config[:cookbook_path].first
end

#discover_changed(type, first_commit, last_commit) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/knife-table/helpers.rb', line 11

def discover_changed(type, first_commit, last_commit)
  changed = []
  git.diff(first_commit, last_commit).stats[:files].keys.each do |path|
    if(path.start_with?(type.to_s))
      changed << path.sub(/^#{type.to_s}\/?/, '')
    end
  end
  changed.uniq
end

#gitObject



3
4
5
# File 'lib/knife-table/helpers.rb', line 3

def git
  @git ||= Git.open(File.dirname(cookbook_path))
end