Class: Guard::Chef::Base

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

Direct Known Subclasses

CookbookJob, DataBagJob, EnvironmentJob, RoleJob

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target, name) ⇒ Base

Returns a new instance of Base.



4
5
6
# File 'lib/guard/chef/base.rb', line 4

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

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#targetObject (readonly)

Returns the value of attribute target.



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

def target
  @target
end

Class Method Details

.accepts?(path, extension) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/guard/chef/base.rb', line 8

def self.accepts?(path, extension)
  true
end

Instance Method Details

#kindObject



12
13
14
# File 'lib/guard/chef/base.rb', line 12

def kind
  self.class.to_s.gsub(/Job/, '').downcase
end

#updateObject



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/guard/chef/base.rb', line 16

def update
  puts "uploading changed #{kind} '#{target}'. Please wait."
  output = `#{command}`
  if output =~ sentinel_re
    puts "#{kind} '#{name}' uploaded."
    true
  else
    puts "#{kind} '#{name}' could not be uploaded."
    false
  end
end