class Kamaze::Project::Tools::Vagrant::Composer

Compose “boxes“ data structure from files

Attributes

path[R]

Path to files describing boxes

defaults to “./vagrant“

@return [Pathname]

Public Class Methods

new(path) click to toggle source

Initialize from given path

@param [String] path

# File lib/kamaze/project/tools/vagrant/composer.rb, line 35
def initialize(path)
  @path = ::Pathname.new(path)
end

Public Instance Methods

boxes() click to toggle source

Get boxes

@return [Hash]

# File lib/kamaze/project/tools/vagrant/composer.rb, line 56
def boxes
  results = {}
  files.each { |file| results[file.name] = file.load }

  results
end
boxes?() click to toggle source

Denote existence of configured boxes

@return [Boolean]

# File lib/kamaze/project/tools/vagrant/composer.rb, line 49
def boxes?
  !boxes.empty?
end
dump() click to toggle source

Dump (boxes) config

@return [String]

# File lib/kamaze/project/tools/vagrant/composer.rb, line 42
def dump
  ::YAML.dump(boxes)
end
files() click to toggle source

Get files used to generate “boxes“

Files are indexed by “name“. Overrides and non-loablde files are excluded during listing.

@return [Array<File>]

# File lib/kamaze/project/tools/vagrant/composer.rb, line 69
def files
  Dir.glob("#{path}/*.yml")
     .delete_if { |file| /\.override.yml$/ =~ file }
     .map { |file| File.new(file) }
     .keep_if(&:loadable?)
     .freeze
end
sources() click to toggle source

Get files related to “box files”

Almost all files stored in “path“ are considered as “source“

@return [Array<Pathname>]

# File lib/kamaze/project/tools/vagrant/composer.rb, line 82
def sources
  Dir.glob("#{path}/**/**")
     .map { |path| ::Pathname.new(path) }
     .keep_if(&:file?)
     .sort_by(&:to_s).freeze
end