Sha256: bc679329342df214034b6ee8a37bc291abbd77391036e13083110b37ec429ea4

Contents?: true

Size: 884 Bytes

Versions: 1

Compression:

Stored size: 884 Bytes

Contents

class Upstart::Exporter
  module ExporterHelpers
    def export_cmd_helper(cmd_name, cmd, binds={})
      helper_script_cont = Templates.helper append_cmd(cmd, binds)
      File.open(helper_cmd_conf(cmd_name), 'w') do |f|
        f.write(helper_script_cont)
      end
    end

    def app_name
      @options[:prefix] + @options[:app_name]
    end

    def app_cmd(cmd_name)
      "#{app_name}-#{cmd_name}"
    end

    def upstart_cmd_conf(cmd_name)
      File.join(@options[:upstart_dir], "#{app_cmd(cmd_name)}.conf")
    end

    def helper_cmd_conf(cmd_name)
      File.join(@options[:helper_dir], "#{app_cmd(cmd_name)}.sh")
    end

    private

    def append_cmd(cmd, binds)
      return binds unless cmd

      parts = cmd.split /\s*(&&|\|\|)\s*/
      parts.last.gsub!(/\A(exec\s*|\s*)/, "exec ")
      cmd = parts.join(" ")

      binds.merge(:cmd => cmd)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
upstart-exporter-2.1.1 lib/upstart-exporter/exporter_helpers.rb