Sha256: 2a8483c22707e118d3785e0a634c2fb1cb530f5bbf0a38ac02f474532cc9ce24

Contents?: true

Size: 845 Bytes

Versions: 6

Compression:

Stored size: 845 Bytes

Contents

require 'rake/tasklib'

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

    def initialize(name = :bin_path)
      @name = name
      @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[*@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

6 entries across 6 versions & 1 rubygems

Version Path
rake-funnel-0.0.6.pre lib/rake/funnel/tasks/bin_path.rb
rake-funnel-0.0.5.pre lib/rake/funnel/tasks/bin_path.rb
rake-funnel-0.0.4.pre lib/rake/funnel/tasks/bin_path.rb
rake-funnel-0.0.3.pre lib/rake/funnel/tasks/bin_path.rb
rake-funnel-0.0.2.pre lib/rake/funnel/tasks/bin_path.rb
rake-funnel-0.0.1.pre lib/rake/funnel/tasks/bin_path.rb