Class: Babushka::Renderable

Inherits:
Object show all
Includes:
RunHelpers, ShellHelpers
Defined in:
lib/babushka/renderable.rb

Constant Summary

SEAL_REGEXP =
/# Generated by babushka-[\d\.]+ at [a-zA-Z\d\-\:\s+]+, from [0-9a-f]{40}+\. [0-9a-f]{40}/

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Methods included from RunHelpers

#_by_babushka, #added_by_babushka, #append_to_file, #babushka_config?, #bundle_rake, #change_line, #change_with_sed, #check_file, #edited_by_babushka, #erb_path_for, #grep, #hostname, #insert_into_file, #log_and_open, #mysql, #rake, #sed, #yaml

Methods included from PathHelpers

#cd, #in_build_dir, #in_dir, #in_download_dir

Methods included from ShellHelpers

#cmd_dir, #failable_shell, #log_shell, #login_shell, #raw_shell, #shell, #shell!, #shell?, #sudo, #which

Methods included from LogHelpers

#debug, #log, #log_block, #log_error, #log_ok, #log_verbose, #log_warn

Constructor Details

- (Renderable) initialize(path)

A new instance of Renderable



9
10
11
# File 'lib/babushka/renderable.rb', line 9

def initialize path
  @path = path
end

Instance Attribute Details

- (Object) path (readonly)

Returns the value of attribute path



8
9
10
# File 'lib/babushka/renderable.rb', line 8

def path
  @path
end

Instance Method Details

- (Boolean) clean?

Returns:

  • (Boolean)


28
29
30
# File 'lib/babushka/renderable.rb', line 28

def clean?
  Inkan.legitimate? path
end

- (Boolean) exists?

Returns:

  • (Boolean)


24
25
26
# File 'lib/babushka/renderable.rb', line 24

def exists?
  path.p.exists?
end

- (Boolean) from?(source)

Returns:

  • (Boolean)


32
33
34
# File 'lib/babushka/renderable.rb', line 32

def from? source
  exists? && source_sha == sha_of(source)
end

- (Object) render(source, opts = {})



13
14
15
16
17
18
19
20
21
22
# File 'lib/babushka/renderable.rb', line 13

def render source, opts = {}
  shell("cat > '#{path}'",
    :input => inkan_output_for(source, opts),
    :sudo => opts[:sudo]
  ).tap {|result|
    if result
      sudo "chmod #{opts[:perms]} '#{path}'" if opts[:perms]
    end
  }
end