Sha256: e15ddb6a591f82a3ee162e5a9822b8c7afabdf7ee546d6cb11437ba63b28e7ee

Contents?: true

Size: 1.32 KB

Versions: 1

Compression:

Stored size: 1.32 KB

Contents

require 'fast_gettext'
require 'gettext_i18n_rails'
require 'fog/opennebula'

module ForemanOne
  #Inherit from the Rails module of the parent app (Foreman), not the plugin.
  #Thus, inherits from ::Rails::Engine and not from Rails::Engine
  class Engine < ::Rails::Engine

    initializer 'foreman_one.register_gettext', :after => :load_config_initializers do |app|
      locale_dir = File.join(File.expand_path('../../..', __FILE__), 'locale')
      locale_domain = 'one'

      Foreman::Gettext::Support.add_text_domain locale_domain, locale_dir
    end

    initializer 'foreman_one.register_plugin', :after=> :finisher_hook do |app|
      Foreman::Plugin.register :foreman_one do
        requires_foreman '>= 1.8'
        # Register OpenNebula compute resource in foreman
        compute_resource ForemanOne::One
      end
    end

    config.to_prepare do
      begin
        # extend fog opennebula server/
        require 'fog/opennebula/models/compute/server'
        require File.expand_path('../../../app/models/concerns/fog_extensions/opennebula/server', __FILE__)

        Fog::Compute::OpenNebula::Server.send(:include, ::FogExtensions::OpenNebula::Server)
        ::HostsHelper.send(:include, ForemanOne::HostHelperExtensions)
      rescue => e
        puts "Foreman-One: skipping engine hook (#{e.to_s})"
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
foreman_one-0.4 lib/foreman_one/engine.rb