Sha256: 77e482b323921ba3de3d34df49c059a6527805f334ce93036d26fc76390f6988

Contents?: true

Size: 1.21 KB

Versions: 2

Compression:

Stored size: 1.21 KB

Contents

require 'rake_dependencies'
require 'rake_leiningen/version'

module RakeLeiningen
  def self.define_installation_tasks(opts = {})
    namespace = opts[:namespace] || :leiningen
    dependency = 'lein'
    version = opts[:version] || '2.9.1'
    path = opts[:path] || File.join('vendor', 'leiningen')
    type = :uncompressed
    uri_template = "https://raw.githubusercontent.com/technomancy/" +
        "leiningen/<%= @version %>/bin/lein"
    file_name_template = "lein"

    needs_fetch_checker = lambda do |t|
      binary = File.join(t.path, t.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

    RakeDependencies::TaskSets::All.define(
        namespace: namespace,
        dependency: dependency,
        version: version,
        path: path,
        type: type,
        uri_template: uri_template,
        file_name_template: file_name_template,
        needs_fetch: needs_fetch_checker)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rake_leiningen-0.4.0 lib/rake_leiningen.rb
rake_leiningen-0.3.0.pre.1 lib/rake_leiningen.rb