lib/rake_dependencies/tasks/extract.rb in rake_dependencies-2.14.0.pre.1 vs lib/rake_dependencies/tasks/extract.rb in rake_dependencies-3.0.0.pre.2

- old
+ new

@@ -1,7 +1,8 @@ require 'rake_factory' require 'zip' +require 'rubygems' require_relative '../template' require_relative '../extractors' module RakeDependencies @@ -11,14 +12,14 @@ default_description RakeFactory::DynamicValue.new { |t| "Extract #{t.dependency} archive" } parameter :type, default: :zip - parameter :os_ids, default: { - mac: 'mac', - linux: 'linux' - } + + parameter :platform_cpu_names, default: PlatformNames::CPU + parameter :platform_os_names, default: PlatformNames::OS + parameter :extractors, default: { zip: Extractors::ZipExtractor, tar_gz: Extractors::TarGzExtractor, tgz: Extractors::TarGzExtractor, uncompressed: Extractors::UncompressedExtractor @@ -37,11 +38,12 @@ action do parameters = { version: version, platform: platform, - os_id: os_id, + platform_cpu_name: platform_cpu_name, + platform_os_name: platform_os_name, ext: ext } distribution_file_name = Template.new(file_name_template) .with_parameters(parameters) @@ -79,19 +81,23 @@ def extractor_for_extension extractors[resolved_type] end - def os_id - os_ids[platform] + def platform + Gem::Platform.local end - def platform - RUBY_PLATFORM =~ /darwin/ ? :mac : :linux + def platform_os_name + platform_os_names[platform.os.to_sym] end + def platform_cpu_name + platform_cpu_names[platform.cpu.to_sym] + end + def resolved_type - type.is_a?(Hash) ? type[platform].to_sym : type.to_sym + type.is_a?(Hash) ? type[platform.os.to_sym].to_sym : type.to_sym end def ext case resolved_type when :tar_gz then