Sha256: 27bafcca2b2ae005b3f37376f9b9dd6f88f0ed6a12edf9c4631de5b5e0a8b823

Contents?: true

Size: 1.67 KB

Versions: 19

Compression:

Stored size: 1.67 KB

Contents

require 'rake_factory'

module RakeDependencies
  module Tasks
    class Install < RakeFactory::Task
      default_name :install
      default_description RakeFactory::DynamicValue.new { |t|
        "Install #{t.dependency}"
      }

      parameter :os_ids, default: {
          mac: 'mac',
          linux: 'linux'
      }

      parameter :dependency, required: true
      parameter :version
      parameter :path, required: true
      parameter :type, default: :zip

      parameter :binary_directory, default: 'bin'
      parameter :binary_name_template, required: true

      parameter :installation_directory, required: true

      action do
        parameters = {
            version: version,
            platform: platform,
            os_id: os_id,
            ext: ext
        }

        binary_file_name = Template.new(binary_name_template)
            .with_parameters(parameters)
            .render
        binary_file_directory = File.join(path, binary_directory)
        binary_file_path = File.join(
            binary_file_directory, binary_file_name)

        mkdir_p installation_directory
        cp binary_file_path, installation_directory
      end

      def os_id
        os_ids[platform]
      end

      def platform
        RUBY_PLATFORM =~ /darwin/ ? :mac : :linux
      end

      def resolved_type
        type.is_a?(Hash) ? type[platform].to_sym : type.to_sym
      end

      def ext
        case resolved_type
        when :tar_gz then
          '.tar.gz'
        when :tgz then
          '.tgz'
        when :zip then
          '.zip'
        when :uncompressed then
          ''
        else
          raise "Unknown type: #{type}"
        end
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
rake_dependencies-2.14.0.pre.1 lib/rake_dependencies/tasks/install.rb
rake_dependencies-2.13.0 lib/rake_dependencies/tasks/install.rb
rake_dependencies-2.12.0.pre.3 lib/rake_dependencies/tasks/install.rb
rake_dependencies-2.12.0.pre.2 lib/rake_dependencies/tasks/install.rb
rake_dependencies-2.12.0.pre.1 lib/rake_dependencies/tasks/install.rb
rake_dependencies-2.11.0 lib/rake_dependencies/tasks/install.rb
rake_dependencies-2.10.0.pre.1 lib/rake_dependencies/tasks/install.rb
rake_dependencies-2.9.0 lib/rake_dependencies/tasks/install.rb
rake_dependencies-2.8.0.pre.1 lib/rake_dependencies/tasks/install.rb
rake_dependencies-2.7.0 lib/rake_dependencies/tasks/install.rb
rake_dependencies-2.6.0.pre.2 lib/rake_dependencies/tasks/install.rb
rake_dependencies-2.6.0.pre.1 lib/rake_dependencies/tasks/install.rb
rake_dependencies-2.5.0 lib/rake_dependencies/tasks/install.rb
rake_dependencies-2.4.0.pre.1 lib/rake_dependencies/tasks/install.rb
rake_dependencies-2.3.0 lib/rake_dependencies/tasks/install.rb
rake_dependencies-2.2.0.pre.1 lib/rake_dependencies/tasks/install.rb
rake_dependencies-2.1.0 lib/rake_dependencies/tasks/install.rb
rake_dependencies-2.0.0.pre.2 lib/rake_dependencies/tasks/install.rb
rake_dependencies-1.17.0.pre.1 lib/rake_dependencies/tasks/install.rb