class Bagboy::Chef::DataBagsHelper

Public Class Methods

new() click to toggle source
# File lib/bagboy/chef/data_bags_helper.rb, line 10
def initialize
  @file = Core::FileHelper.instance
end

Public Instance Methods

data_bag( bag_name ) click to toggle source
# File lib/bagboy/chef/data_bags_helper.rb, line 18
def data_bag ( bag_name )
  DataBags::Bag.new( {path: data_bag_directory( bag_name ), name: bag_name} )
end
data_bag_directory( bag ) click to toggle source
# File lib/bagboy/chef/data_bags_helper.rb, line 30
def data_bag_directory( bag )
  File.join( Bagboy.chef_repo, 'data_bags', bag )
end
data_bags() click to toggle source
# File lib/bagboy/chef/data_bags_helper.rb, line 22
def data_bags
  get_data_bags data_bags_directory
end
data_bags_directory() click to toggle source
# File lib/bagboy/chef/data_bags_helper.rb, line 26
def data_bags_directory
  File.join( Bagboy.chef_repo, 'data_bags' )
end
setup( opts ) click to toggle source
# File lib/bagboy/chef/data_bags_helper.rb, line 14
def setup( opts )
  @file = opts[:file] if opts[:file]
end

Private Instance Methods

get_data_bags( path ) click to toggle source
# File lib/bagboy/chef/data_bags_helper.rb, line 36
def get_data_bags( path )
  files = @file.get_directories( path )
  bags  = []
  files.each do |file|
    bag = data_bag( file )
    bags << bag
  end
  bags
end