Class: Puppetfactory

Inherits:
Sinatra::Base
  • Object
show all
Defined in:
lib/puppetfactory.rb,
lib/puppetfactory/cli.rb,
lib/puppetfactory/plugins.rb

Defined Under Namespace

Classes: Cli, Helpers, Plugins

Instance Method Summary collapse

Constructor Details

#initialize(app = nil) ⇒ Puppetfactory

Returns a new instance of Puppetfactory.



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/puppetfactory.rb', line 41

def initialize(app=nil)
  super(app)

  # lets us pretend that the settings object is a hash in our plugins
  def settings.[](opt)
    settings.send(opt) if settings.respond_to? opt
  end

  # Add a link back to the server so that plugins can add routes
  def settings.puppetfactory
    self
  end

  @loaded_plugins = settings.plugins.map do |plugin|
    require "puppetfactory/plugins/#{plugin.snake_case}"
    Puppetfactory::Plugins::const_get(plugin).new(settings)
  end
  @loaded_plugins = @loaded_plugins.sort_by { |plugin| plugin.weight }

  ensure_single_action(:users)
  ensure_single_action(:login)
#    ensure_single_action(:deploy) # TODO: maybe this shouldn't be limited like this.
                                #       But if not, we need a plugin.suitability() method.
end