Class: Kamaze::Project::Tools::Vagrant::Composer
- Defined in:
- lib/kamaze/project/tools/vagrant/composer.rb,
lib/kamaze/project/tools/vagrant/composer.rb,
lib/kamaze/project/tools/vagrant/composer/file.rb
Overview
Compose boxes
data structure from files
Defined Under Namespace
Classes: File
Instance Attribute Summary collapse
-
#path ⇒ Pathname
readonly
Path to files describing boxes.
Instance Method Summary collapse
-
#boxes ⇒ Hash
Get boxes.
-
#boxes? ⇒ Boolean
Denote existence of configured boxes.
-
#dump ⇒ String
Dump (boxes) config.
-
#files ⇒ Array<File>
Get files used to generate
boxes
. -
#initialize(path) ⇒ Composer
constructor
Initialize from given path.
-
#sources ⇒ Array<Pathname>
Get files related to "box files".
Constructor Details
#initialize(path) ⇒ Composer
Initialize from given path
35 36 37 |
# File 'lib/kamaze/project/tools/vagrant/composer.rb', line 35 def initialize(path) @path = ::Pathname.new(path) end |
Instance Attribute Details
#path ⇒ Pathname (readonly)
Path to files describing boxes
defaults to ./vagrant
30 31 32 |
# File 'lib/kamaze/project/tools/vagrant/composer.rb', line 30 def path @path end |
Instance Method Details
#boxes ⇒ Hash
Get boxes
56 57 58 59 60 61 |
# File 'lib/kamaze/project/tools/vagrant/composer.rb', line 56 def boxes results = {} files.each { |file| results[file.name] = file.load } results end |
#boxes? ⇒ Boolean
Denote existence of configured boxes
49 50 51 |
# File 'lib/kamaze/project/tools/vagrant/composer.rb', line 49 def boxes? !boxes.empty? end |
#dump ⇒ String
Dump (boxes) config
42 43 44 |
# File 'lib/kamaze/project/tools/vagrant/composer.rb', line 42 def dump ::YAML.dump(boxes) end |
#files ⇒ Array<File>
Get files used to generate boxes
Files are indexed by name
.
Overrides and non-loablde files are excluded during listing.
69 70 71 72 73 74 75 |
# 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 ⇒ Array<Pathname>
Get files related to "box files"
Almost all files stored in path
are considered as source
82 83 84 85 86 87 |
# 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 |