Sha256: 4e8ab0636bc0f7c848c42d008644ed30edf21f23a03fafeeb35c9a7b7c53e5a3

Contents?: true

Size: 1.77 KB

Versions: 6

Compression:

Stored size: 1.77 KB

Contents

# frozen_string_literal: true

require 'rake_dependencies'
require 'ruby_easy_rsa'
require 'rake_easy_rsa/version'
require 'rake_easy_rsa/tasks'
require 'rake_easy_rsa/task_sets'

module RakeEasyRSA
  def self.define_installation_tasks(opts = {})
    RubyEasyRSA.configure do |c|
      c.binary = File.join(path(opts), 'easyrsa')
    end

    RakeDependencies::TaskSets::All.define(
      installation_task_set_opts(opts)
    )
  end

  def self.define_pki_tasks(opts = {}, &)
    RakeEasyRSA::TaskSets::PKI.define(opts, &)
  end

  class << self
    private

    def installation_task_set_opts(opts)
      { namespace: namespace(opts),
        dependency: dependency(opts),
        version: version(opts),
        path: path(opts),
        type: type(opts),
        binary_directory: binary_directory(opts),
        uri_template: uri_template(opts),
        file_name_template: file_name_template(opts),
        strip_path_template: strip_path_template(opts),
        needs_fetch: needs_fetch_check_lambda(opts) }
    end

    def namespace(opts)
      opts[:namespace] || :easy_rsa
    end

    def dependency(_)
      'easy-rsa'
    end

    def version(opts)
      opts[:version] || '3.0.7'
    end

    def path(opts)
      opts[:path] || File.join('vendor', 'easy-rsa')
    end

    def type(_)
      :tgz
    end

    def uri_template(_)
      'https://github.com/OpenVPN/easy-rsa/releases/' \
        'download/v<%= @version %>/' \
        'EasyRSA-<%= @version %>.tgz'
    end

    def binary_directory(_)
      ''
    end

    def file_name_template(_)
      'EasyRSA-<%= @version %>.tgz'
    end

    def strip_path_template(_)
      'EasyRSA-<%= @version %>'
    end

    def needs_fetch_check_lambda(_)
      lambda { |t|
        !File.exist?(File.join(t.path, 'easyrsa'))
      }
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rake_easy_rsa-0.16.0.pre.2 lib/rake_easy_rsa.rb
rake_easy_rsa-0.16.0.pre.1 lib/rake_easy_rsa.rb
rake_easy_rsa-0.15.0 lib/rake_easy_rsa.rb
rake_easy_rsa-0.14.0.pre.7 lib/rake_easy_rsa.rb
rake_easy_rsa-0.14.0.pre.6 lib/rake_easy_rsa.rb
rake_easy_rsa-0.14.0.pre.5 lib/rake_easy_rsa.rb