Module: Warbler::Trait

Overview

Each trait class includes this module to receive shared functionality.

Defined Under Namespace

Modules: ClassMethods

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



86
87
88
# File 'lib/warbler/traits.rb', line 86

def config
  @config
end

Class Method Details

.included(base) ⇒ Object



82
83
84
# File 'lib/warbler/traits.rb', line 82

def self.included(base)
  base.extend ClassMethods
end

Instance Method Details

#add_init_load_path(path) ⇒ Object



100
101
102
103
104
# File 'lib/warbler/traits.rb', line 100

def add_init_load_path(path)
  config.init_contents << StringIO.new("$LOAD_PATH.unshift File.expand_path(File.join('..', '..', '#{path}'), __FILE__)\n")
  # with __FILE__ = "uri:classloader:/META-INF/init.rb"
  # ...  will end up as "uri:classloader://xxx-gem/lib"
end

#add_main_rb(jar, bin_path, params = nil) ⇒ Object



106
107
108
109
110
111
# File 'lib/warbler/traits.rb', line 106

def add_main_rb(jar, bin_path, params = nil)
  binary = "".dup
  binary << "ARGV.unshift('#{params}')\n" if params
  binary << "load '#{bin_path}'"
  jar.files['META-INF/main.rb'] = StringIO.new(binary)
end

#after_configureObject



94
95
# File 'lib/warbler/traits.rb', line 94

def after_configure
end

#before_configureObject



91
92
# File 'lib/warbler/traits.rb', line 91

def before_configure
end

#initialize(config) ⇒ Object



87
88
89
# File 'lib/warbler/traits.rb', line 87

def initialize(config)
  @config = config
end

#jruby_jarsObject



124
125
126
127
# File 'lib/warbler/traits.rb', line 124

def jruby_jars
  require 'jruby-jars'
  FileList[JRubyJars.core_jar_path, JRubyJars.stdlib_jar_path]
end

#update_archive(jar) ⇒ Object



97
98
# File 'lib/warbler/traits.rb', line 97

def update_archive(jar)
end

#update_gem_path(default_gem_path) ⇒ Object



113
114
115
116
117
118
119
120
121
122
# File 'lib/warbler/traits.rb', line 113

def update_gem_path(default_gem_path)
  if config.gem_path != default_gem_path
    config.gem_path = "/#{config.gem_path}" unless config.gem_path =~ %r{^/}
    sub_gem_path = config.gem_path[1..-1]
    config.pathmaps.marshal_dump.keys.each do |pm|
      config.pathmaps.send(pm).each {|p| p.sub!(default_gem_path[1..-1], sub_gem_path)}
    end
    config.webxml["gem"]["path"] = config.gem_path if config.webxml
  end
end