Class: Hippo::Manifest

Inherits:
Object
  • Object
show all
Defined in:
lib/hippo/manifest.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options, root) ⇒ Manifest

Returns a new instance of Manifest.



26
27
28
29
# File 'lib/hippo/manifest.rb', line 26

def initialize(options, root)
  @options = options
  @root = File.expand_path(root)
end

Instance Attribute Details

#rootObject (readonly)

Returns the value of attribute root.



24
25
26
# File 'lib/hippo/manifest.rb', line 24

def root
  @root
end

Class Method Details

.load_from_file(path) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/hippo/manifest.rb', line 14

def load_from_file(path)
  unless File.file?(path)
    raise Error, "Hippofile file not found at #{path}"
  end

  root = File.dirname(path)
  new(Util.load_yaml_from_file(path).first, root)
end

Instance Method Details

#bootstrapObject



47
48
49
50
51
52
53
54
55
56
# File 'lib/hippo/manifest.rb', line 47

def bootstrap
  @bootstrap ||= begin
    bootstrap_file = File.join(@root, 'bootstrap.yaml')
    if File.file?(bootstrap_file)
      YAML.load_file(bootstrap_file)
    else
      {}
    end
  end
end

#commandsObject



39
40
41
# File 'lib/hippo/manifest.rb', line 39

def commands
  @options['commands'] || {}
end

#configObject



43
44
45
# File 'lib/hippo/manifest.rb', line 43

def config
  @options['config'] || {}
end

#consoleObject



35
36
37
# File 'lib/hippo/manifest.rb', line 35

def console
  @options['console']
end

#imagesObject



76
77
78
79
80
# File 'lib/hippo/manifest.rb', line 76

def images
  return {} unless @options['images'].is_a?(Hash)

  @options['images']
end

#nameObject



31
32
33
# File 'lib/hippo/manifest.rb', line 31

def name
  @options['name'] || 'app'
end

#objects(path, decorator: nil) ⇒ Array<Hash>

Load all YAML objects at a given path and return them.

Parameters:

  • path (String)
  • decorator (Proc) (defaults to: nil)

    an optional parser to run across the raw YAML file

Returns:



87
88
89
# File 'lib/hippo/manifest.rb', line 87

def objects(path, decorator: nil)
  Util.load_objects_from_path(File.join(@root, path, '*.{yaml,yml}'), decorator: decorator)
end

#readmeObject



58
59
60
61
62
63
64
65
66
67
68
# File 'lib/hippo/manifest.rb', line 58

def readme
  return @readme if instance_variable_defined?('@readme')

  path = File.join(@root, 'readme.txt')
  unless File.file?(path)
    @readme = nil
    return
  end

  @readme = File.read(path)
end

#template_varsObject



70
71
72
73
74
# File 'lib/hippo/manifest.rb', line 70

def template_vars
  {
    'name' => name
  }
end