Class: DataBagJob

Inherits:
Object
  • Object
show all
Defined in:
lib/guard/chef/data_bag_job.rb

Instance Method Summary collapse

Constructor Details

#initialize(base_dir, target) ⇒ DataBagJob

Returns a new instance of DataBagJob.



2
3
4
# File 'lib/guard/chef/data_bag_job.rb', line 2

def initialize(base_dir, target)
  @base_dir, @target = base_dir, target
end

Instance Method Details

#base_cmdObject



6
7
8
# File 'lib/guard/chef/data_bag_job.rb', line 6

def base_cmd
  "cd #{@base_dir}"
end

#targetObject



10
11
12
# File 'lib/guard/chef/data_bag_job.rb', line 10

def target
  @target
end

#updateObject



14
15
16
17
18
19
20
21
22
23
# File 'lib/guard/chef/data_bag_job.rb', line 14

def update
  puts "uploading changed databag. (#{target}) Please wait."
  if /Updated data_bag_item/ =~ `#{base_cmd} && rake databag:upload[#{target}]`
    puts "databag (#{target}) uploaded."
    true
  else
    puts "databag (#{target}) could not be uploaded."
    false
  end
end