Sha256: 16874c74625f902988e54064f852426e514a0c4b10cbc25fc918a661fe3b7211

Contents?: true

Size: 845 Bytes

Versions: 5

Compression:

Stored size: 845 Bytes

Contents

module Take
  class Project

    # Handles actions that might be taken from within a build action;
    # used in {Convert}s and {Target}s.
    class Actionable

      attr_reader :data

      def initialize(&blk)
        @data = {}
        @block = blk
      end

      def run(command, arguments)
        runner = Command::Runner.new(command, arguments)
        runner.pass!
      end

      def call(project, data = {})
        @data = data.merge(
          :curdir => project.path,
          :env    => project.env)
        instance_exec(@block)
      end

      def method_missing(method, *args, &block)
        if @data.key?(method) && args.size == 0 && !block_given?
          @data[method]
        else
          super
        end
      end

      def respond_to_missing?(method, _)
        @data.key?(method)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
take-0.0.15 lib/take/project/actionable.rb
take-0.0.14 lib/take/project/actionable.rb
take-0.0.13 lib/take/project/actionable.rb
take-0.0.12 lib/take/project/actionable.rb
take-0.0.11 lib/take/project/actionable.rb