Sha256: d3c32d8ec492956a8d7aebb146d9d839db6690f94755681c35efcde42971b715
Contents?: true
Size: 1.85 KB
Versions: 2
Compression:
Stored size: 1.85 KB
Contents
module EacLauncher module Ruby module Gem class Build include ::EacRubyUtils::Console::Speaker def initialize(original_gem_root) @original_gem_root = original_gem_root end def output_file return nil unless @gem_root @gem_root.find_files_with_extension('.gem').first end def builded? output_file.present? && ::File.exist?(output_file) end def build return if builded? copy_gem_files build_gem check_gem end def close ::FileUtils.remove_entry(@gem_root) if ::File.directory?(@gem_root) @gem_root = nil end private def copy_gem_files @gem_root = ::EacLauncher::Path.new(::Dir.mktmpdir) FileUtils.cp_r "#{@original_gem_root}/.", @gem_root end def build_gem info("Building gemspec #{gemspec_file}...") clear_gems Dir.chdir @gem_root do EacRubyUtils::Envs.local.command('gem', 'build', gemspec_file).execute! end end def check_gem Dir.mktmpdir do |dir| Dir.chdir dir do EacRubyUtils::Envs.local.command('gem', 'unpack', gem).system gs = File.join(dir, File.basename(gem, '.gem')) if (Dir.entries(gs) - %w[. ..]).empty? raise "\"#{dir}\" (Unpacked from #{gem}) has no source code" end end end end def clear_gems @gem_root.find_files_with_extension('.gem').each do |f| FileUtils.rm_rf(f) end end def gemspec_file @gem_root.find_file_with_extension('.gemspec') end def gem @gem_root.find_file_with_extension('.gem') end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
eac_launcher-0.1.3 | lib/eac_launcher/ruby/gem/build.rb |
eac_launcher-0.1.4 | lib/eac_launcher/ruby/gem/build.rb |