Class: Shoes::Swt::Packager

Inherits:
Object
  • Object
show all
Defined in:
shoes-swt/lib/shoes/swt/packager.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dsl) ⇒ Packager

Returns a new instance of Packager


8
9
10
11
12
# File 'shoes-swt/lib/shoes/swt/packager.rb', line 8

def initialize(dsl)
  @dsl  = dsl
  @gems = []
  @packages = []
end

Instance Attribute Details

#gemsObject

Returns the value of attribute gems


6
7
8
# File 'shoes-swt/lib/shoes/swt/packager.rb', line 6

def gems
  @gems
end

Instance Method Details

#optionsObject


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'shoes-swt/lib/shoes/swt/packager.rb', line 14

def options
  OptionParser.new do |opts|
    opts.on('--jar', 'Package as executable JAR file') do
      @packages << :jar
    end

    opts.on('--mac', 'Package as OS X application') do
      @packages << :mac
    end

    opts.on('--windows', 'Package as Windows application') do
      @packages << :windows
    end

    opts.on('--linux', 'Package as Linux application') do
      @packages << :linux
    end
  end
end

#run(path) ⇒ Object


34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'shoes-swt/lib/shoes/swt/packager.rb', line 34

def run(path)
  if @packages.empty?
    puts "You must select at least one packaging format.\n\n#{::Shoes::UI::CLI::PackageCommand.new.help}"
    return
  end

  begin
    require 'shoes/package'
    require 'shoes/package/configuration'
    config = ::Shoes::Package::Configuration.load(path)
    config.gems.concat(@gems)
  rescue Errno::ENOENT => e
    abort "shoes: #{e.message}"
  end

  @packages.each do |package_type|
    puts "Packaging #{package_type}..."
    packager = ::Shoes::Package.create_packager(config, package_type)
    packager.package
  end
end