Class: Bagboy::Chef::DataBags::Bag
- Inherits:
-
Object
- Object
- Bagboy::Chef::DataBags::Bag
- Defined in:
- lib/bagboy/chef/data_bags/bag.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #create ⇒ Object
-
#initialize(opts = {}) ⇒ Bag
constructor
A new instance of Bag.
- #item(name) ⇒ Object
- #items ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Bag
Returns a new instance of Bag.
8 9 10 11 12 13 14 |
# File 'lib/bagboy/chef/data_bags/bag.rb', line 8 def initialize( opts = {} ) @path = opts[:path] || '' @name = opts[:name] || '' @file = opts[:file] || Core::FileHelper.instance @scm = opts[:scm] || Core::SCMHelper.instance @knife = opts[:knife] || Bagboy::Chef::Knife.instance end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/bagboy/chef/data_bags/bag.rb', line 6 def name @name end |
Instance Method Details
#create ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/bagboy/chef/data_bags/bag.rb', line 26 def create pull if unique? Dir.mkdir @path sync true else false end end |
#item(name) ⇒ Object
20 21 22 23 24 |
# File 'lib/bagboy/chef/data_bags/bag.rb', line 20 def item( name ) name = name.gsub(/[^\w\-]/, '_') path = item_path( name + '.json' ) Item.new( {path: path, name: name, bag: @name} ) end |
#items ⇒ Object
16 17 18 |
# File 'lib/bagboy/chef/data_bags/bag.rb', line 16 def items get_items @file.get_files( @path ) end |