Module: DatabagVersion

Defined in:
lib/databag_version.rb

Overview

A simple module for working with “versioned” data bags. This relies on thor-scmversion to provide the version information. Any data bag item templates are then processed with Erubis to insert the version information.

Class Method Summary collapse

Class Method Details

.id(name) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/databag_version.rb', line 13

def id(name)
  scm_versioner = ThorSCMVersion.versioner
  tag = scm_versioner.from_path

  version = tag.to_s.gsub(/\./, '_')

  "#{name}_#{version}"
end

.process_all(quiet = true, path = 'data_bags') ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/databag_version.rb', line 22

def process_all(quiet = true, path = 'data_bags')
  @be_quiet = quiet
  Dir.foreach(path) do |dir|
    # Skip everything that isn't a sub-directory
    next unless File.directory?(dir)
    # Process every sub-directory (but not current & parent, natch)
    process_dir("#{path}/#{dir}") unless dir == '.' || dir == '..'
  end if File.exist?(path)
end