Sha256: 09ac5b819d5527b085e8add4dd803d17613d0797d3e9d52ca8089faff237d4cc

Contents?: true

Size: 1.1 KB

Versions: 2

Compression:

Stored size: 1.1 KB

Contents

require 'rake_dependencies'
require 'rake_leiningen/version'

module RakeLeiningen
  def self.define_installation_tasks(opts = {})
    namespace = opts[:namespace] || :leiningen
    version = opts[:version] || '2.9.1'
    path = opts[:path] || File.join('vendor', 'leiningen')

    RakeDependencies::Tasks::All.new do |t|
      t.namespace = namespace
      t.dependency = 'lein'
      t.version = version
      t.path = path
      t.type = :uncompressed

      t.uri_template = "https://raw.githubusercontent.com/technomancy/leiningen/<%= @version %>/bin/lein"
      t.file_name_template = "lein"

      t.needs_fetch = lambda do |parameters|
        binary = File.join(parameters[:path], parameters[:binary_directory], 'lein')
        version_string = StringIO.new

        if File.exist?(binary)
          Lino::CommandLineBuilder.for_command(binary)
              .with_flag('-version')
              .build
              .execute(stdout: version_string)

          if version_string.string.lines.first =~ /#{version}/
            return false
          end
        end

        return true
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rake_leiningen-0.2.0 lib/rake_leiningen.rb
rake_leiningen-0.1.0.pre.1 lib/rake_leiningen.rb