Sha256: 9f08a61528dfe7013b40ce24796cdfe30b5c8b4b3fecc08f73e6dbfa07acc574

Contents?: true

Size: 944 Bytes

Versions: 3

Compression:

Stored size: 944 Bytes

Contents

# coding: utf-8

require "milc"

require 'erb'
require 'yaml'

require 'logger_pipe'

def YAML.load_file_with_erb(yaml_path)
  erb = ERB.new(IO.read(yaml_path))
  erb.filename = yaml_path
  text = erb.result
  YAML.load(text)
end

module Milc
  module Base

    def logger
      Milc.logger
    end

    def execute(cmd, options = {})
      options[:dry_run] = Milc.dry_run
      res = LoggerPipe.run(logger, cmd, options)
      block_given? ? yield(res) : res
    end

    attr_accessor :config
    attr_reader :project

    def dry_run
      Milc.dry_run
    end

    # overriden
    def load_config
      @project = config['PROJECT'] || ENV['PROJECT']
    end

    # overriden
    def help_message
      ## スクリプト名
      cmdname = File.basename($0) # $PROGRAM_NAME を推奨
      ## シェルスクリプトのUsage
      "Usage: #{cmdname} -c CONF_FILE"
    end

    # overriden
    def load_options(options)
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
milc-0.2.2 lib/milc/base.rb
milc-0.2.1 lib/milc/base.rb
milc-0.2.0 lib/milc/base.rb