Module: Warbler::Traits

Included in:
Config
Defined in:
lib/warbler/traits.rb,
lib/warbler/traits/jar.rb,
lib/warbler/traits/war.rb,
lib/warbler/traits/rack.rb,
lib/warbler/traits/rails.rb,
lib/warbler/traits/bundler.rb,
lib/warbler/traits/gemspec.rb,
lib/warbler/traits/jbundler.rb,
lib/warbler/traits/nogemspec.rb

Overview

Traits are project configuration characteristics that correspond to the framework or project layout. Each trait corresponds to a class in Warbler::Traits that contains baked-in knowledge about the kind of project and how it should be packed into the jar or war file.

Defined Under Namespace

Classes: Bundler, Gemspec, JBundler, Jar, NoGemspec, Rack, Rails, War

Instance Method Summary collapse

Instance Method Details

#after_configureObject



36
37
38
# File 'lib/warbler/traits.rb', line 36

def after_configure
  trait_objects.each {|t| t.after_configure }
end

#auto_detect_traitsObject



28
29
30
# File 'lib/warbler/traits.rb', line 28

def auto_detect_traits
  TraitsDependencyArray.new(Traits.constants.map {|t| Traits.const_get(t)}).tsort.select {|tc| tc.detect? }
end

#before_configureObject



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

def before_configure
  trait_objects.each {|t| t.before_configure }
end

#dump_traitsObject



48
49
50
51
# File 'lib/warbler/traits.rb', line 48

def dump_traits
  @trait_objects = nil
  @traits.collect! {|t| t.name }
end

#initialize(forced_traits) ⇒ Object

Parameters:

  • forced_traits (Array<Class>, nil)

    array of Warbler::Trait types to force rather than auto-detecting them



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

def initialize(forced_traits)
  @traits = if forced_traits.nil? || forced_traits.empty?
              auto_detect_traits
            else
              validate_traits(forced_traits)
            end
end

#trait_objectsObject



40
41
42
# File 'lib/warbler/traits.rb', line 40

def trait_objects
  @trait_objects ||= @traits.map {|klass| klass.new(self) }
end

#update_archive(jar) ⇒ Object



44
45
46
# File 'lib/warbler/traits.rb', line 44

def update_archive(jar)
  trait_objects.each {|t| t.update_archive(jar) }
end