Sha256: 16fb6802c7af3a9c4969f82b9a692ea019d48d7563a170f8593fe0d801a2807d

Contents?: true

Size: 1.71 KB

Versions: 1

Compression:

Stored size: 1.71 KB

Contents

module Ore
  #
  # Additional actions for the {Generator}.
  #
  # @api semipublic
  #
  # @since 0.9.0
  #
  module Actions
    protected

    #
    # Runs a command.
    #
    # @param [String] command
    #   The command to execute.
    #
    # @param [Hash] config
    #   Additional options.
    #
    # @see http://rubydoc.info/gems/thor/Thor/Actions#run-instance_method
    #
    def run(command,config={})
      super(command,config.merge(capture: true))
    end

    #
    # Generates an empty directory.
    #
    # @param [String] dest
    #   The uninterpolated destination path.
    #
    # @return [String]
    #   The destination path of the directory.
    #
    # @since 0.7.1
    #
    def generate_dir(dest)
      return if @generated_dirs.has_key?(dest)

      path = interpolate(dest)
      empty_directory path

      @generated_dirs[dest] = path
      return path
    end

    #
    # Generates a file.
    #
    # @param [String] dest
    #   The uninterpolated destination path.
    #
    # @param [String] file
    #   The source file or template.
    #
    # @param [Hash] options
    #   Additional options.
    #
    # @option options [Boolean] :template
    #   Specifies that the file is a template, and should be rendered.
    #
    # @return [String]
    #   The destination path of the file.
    #
    # @since 0.7.1
    #
    def generate_file(dest,file,options={})
      return if @generated_files.has_key?(dest)

      path = interpolate(dest)

      if options[:template]
        @current_template_dir = File.dirname(dest)
        template file, path
        @current_template_dir = nil
      else
        copy_file file, path
      end

      @generated_files[dest] = path
      return path
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ore-0.11.0 lib/ore/actions.rb