Sha256: 0603f6396eedce1e4c45352938481cf86d0b3439bc247efa31dbdd3320935467

Contents?: true

Size: 992 Bytes

Versions: 13

Compression:

Stored size: 992 Bytes

Contents

require "foreman/export"
require "foreman/utils"

class Foreman::Export::Base

  attr_reader :engine

  def initialize(engine)
    @engine = engine
  end

  def export
    raise "export method must be overridden"
  end

private ######################################################################

  def error(message)
    raise Foreman::Export::Exception.new(message)
  end

  def say(message)
    puts "[foreman export] %s" % message
  end

  def export_template(exporter, file, template_root)
    if template_root && File.exist?(file_path = File.join(template_root, file))
      File.read(file_path)
    elsif File.exist?(file_path = File.expand_path(File.join("~/.foreman/templates", file)))
      File.read(file_path)
    else
      File.read(File.expand_path("../../../../data/export/#{exporter}/#{file}", __FILE__))
    end
  end

  def write_file(filename, contents)
    say "writing: #{filename}"

    File.open(filename, "w") do |file|
      file.puts contents
    end
  end

end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
foreman-0.37.0.pre3-mingw32 lib/foreman/export/base.rb
foreman-0.37.0.pre3-java lib/foreman/export/base.rb
foreman-0.37.0.pre3 lib/foreman/export/base.rb
foreman-0.37.0.pre2-java lib/foreman/export/base.rb
foreman-0.37.0.pre2 lib/foreman/export/base.rb
foreman-0.37.0.pre1-java lib/foreman/export/base.rb
foreman-0.37.0.pre1 lib/foreman/export/base.rb
foreman-0.36.1 lib/foreman/export/base.rb
foreman-0.36.0 lib/foreman/export/base.rb
foreman-0.35.0 lib/foreman/export/base.rb
foreman-0.34.1 lib/foreman/export/base.rb
foreman-0.34.0 lib/foreman/export/base.rb
foreman-0.33.1 lib/foreman/export/base.rb