Sha256: 96b83e7cf59bb9b754483120c08b974ef899ed356528d173b56fe00cc0665163

Contents?: true

Size: 866 Bytes

Versions: 1

Compression:

Stored size: 866 Bytes

Contents

require 'rake/tasklib'

module Rake::Funnel::Tasks
  class BinPath < Rake::TaskLib
    attr_accessor :name, :search_pattern

    def initialize(name = :bin_path)
      @name = name
      @search_pattern = %w(tools/* tools/*/bin packages/**/tools)

      yield self if block_given?
      define
    end

    private
    def define
      task @name do
        Rake.rake_output_message 'Added the following paths to the PATH environment variable:'
        add_pattern_to_path_environment.each do |p|
          Rake.rake_output_message "  - #{p}"
        end
      end

      self
    end

    def add_pattern_to_path_environment
      bin_paths = Dir[*@search_pattern].map { |path| File.expand_path(path) }.sort

      ENV['PATH'] = ([] << bin_paths << ENV['PATH']).flatten.join(File::PATH_SEPARATOR)
      bin_paths
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rake-funnel-0.1.0.pre lib/rake/funnel/tasks/bin_path.rb