Sha256: 0c3b2340382c1e5b2a6c8f2bb8a210ec26f83071e4b8c0e88aa6f16abcc2d9e4

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 KB

Contents

require "base64"
require "tempfile"
require "zip"

def extract_gradle(target)
  extract_zip(Radon::Environments.getTargetOf('gradle'), target)
end

def extract_java(target)
  extract_zip(Radon::Environments.getTargetOf('java'), target)
end

def extract_python(target)
  extract_zip(Radon::Environments.getTargetOf('python'), target)
end

def extract_ruby(target)
  extract_zip(Radon::Environments.getTargetOf('ruby'), target)
  find_and_replace_all(target, '{{NAME}}', projectify(target).split('-').collect(&:capitalize).join)
end

# Extracts some zip data to the passed destination
def extract_zip(file, destination)
  puts "Creating project under #{File.expand_path(destination)}" unless $quiet
  create(destination)
  FileUtils.mkdir_p(destination)

  Zip::File.open(file) do |zip_file|
    zip_file.each do |f|
      fname = f.name.gsub('{{NAME}}', projectify(destination))
      fpath = File.join(destination, fname)
      if File.exists?(fpath)
        skip(fpath)
      else
        create(fpath)
      end
      zip_file.extract(f, fpath) unless File.exist?(fpath)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
radon-0.1.0 lib/core/extract.rb