Class: Gem::Portage::EbuildCommand

Inherits:
PortageCommand show all
Includes:
LocalRemoteOptions, GemSpecFetcher
Defined in:
lib/g-gem/portage_commands.rb

Overview

class PortageCommand

Instance Method Summary collapse

Methods included from GemSpecFetcher

LocalOrRemote, #LocalOrRemote, #fetch_local, #fetch_remote, #fetch_spec, #local_fetcher, #remote_fetcher, #spec_fetcher

Methods inherited from Command

class_command_options, #class_command_options, #defaults_str, has_option, has_options_from, #register, register

Constructor Details

#initialize(defaults = nil) ⇒ EbuildCommand

Returns a new instance of EbuildCommand.



28
29
30
31
# File 'lib/g-gem/portage_commands.rb', line 28

def initialize(defaults=nil)
  super('ebuild', 'Generate portage ebuilds from gem specification', defaults)
  add_local_remote_options
end

Instance Method Details

#argumentsObject



37
38
39
40
41
# File 'lib/g-gem/portage_commands.rb', line 37

def arguments
  return "  GEMNAME \n  ARGUMENTS\nend\n"

#executeObject



43
44
45
46
47
48
49
50
51
52
# File 'lib/g-gem/portage_commands.rb', line 43

def execute
  fail Gem::CommandLineError, show_help if options[:args].empty?
  fail "  Invalid ebuild commands: \#{ebuild_command.inspect}\n\n  Valid values are those listed on ebuild(1) and 'generate'\n  EOE\n  atoms = DependencyAtom.parse_list(options[:args])\n  execute_on(atoms)\nend\n" unless (ebuild_command - Gem::Portage::Ebuild::COMMANDS).empty?

#execute_on(atoms) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/g-gem/portage_commands.rb', line 54

def execute_on(atoms)
  specs = Gem::DependencyList.from_atoms(spec_fetcher, atoms)
  specs.include_dependencies(spec_fetcher) if dependencies?
  create = ebuild_command.delete('generate')
  specs.each_spec do |spec|
    ebuild = Ebuild.for(spec, portdir, category)
    if create and (overwrite? or not ebuild.exists?)
      say "Generating #{ebuild.file_path} ..."
      begin
        File.delete(ebuild.digest_file)
      rescue
      end
      ebuild.install_dir = File.expand_path(install_dir, Dir.pwd)
      ebuild.enable_test_phase if test_phase?
      ebuild.generate
      ebuild.execute(*ebuild_command)
    elsif force?
      ebuild.execute(*ebuild_command)
    end
  end
end

#usageObject



33
34
35
# File 'lib/g-gem/portage_commands.rb', line 33

def usage
  "#{program_name} GEM_NAME"
end