Class: Warbler::Traits::Shoes

Inherits:
Object
  • Object
show all
Includes:
PathmapHelper, Trait
Defined in:
lib/warbler/traits/shoes.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.detect?Boolean

Returns:

  • (Boolean)


14
15
16
17
# File 'lib/warbler/traits/shoes.rb', line 14

def self.detect?
  #File.exist? "app.yaml"
  true
end

.requires?(trait) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
22
23
24
# File 'lib/warbler/traits/shoes.rb', line 19

def self.requires?(trait)
  # Actually, it would be better to dump the NoGemspec trait, but since
  # we can't do that, we can at least make sure that this trait gets
  # processed later by declaring that it requires NoGemspec.
  [Traits::Jar, Traits::NoGemspec].include? trait
end

Instance Method Details

#after_configureObject



26
27
28
# File 'lib/warbler/traits/shoes.rb', line 26

def after_configure
  config.init_contents << StringIO.new("require 'shoes'\nShoes.configuration.backend = :swt\n")
end

#default_executableString

Uses the ‘@config.run` if it exists. Otherwise, looks in the application’s ‘bin` directory for an executable with the same name as the jar. If this also fails, defaults to the first executable (alphabetically) in the applications `bin` directory.

Returns:

  • (String)

    filename of the executable to run



42
43
44
45
46
47
48
# File 'lib/warbler/traits/shoes.rb', line 42

def default_executable
  return @config.run if @config.run
  exes = Dir['bin/*'].sort
  exe = exes.grep(/#{config.jar_name}/).first || exes.first
  raise "No executable script found" unless exe
  exe
end

#update_archive(jar) ⇒ Object



30
31
32
33
34
# File 'lib/warbler/traits/shoes.rb', line 30

def update_archive(jar)
  # Not sure why Warbler doesn't do this automatically
  jar.files.delete_if { |k, v| @config.excludes.include? k }
  add_main_rb(jar, apply_pathmaps(config, default_executable, :application))
end