Module: Kernel

Defined in:
lib/bones.rb

Instance Method Summary collapse

Instance Method Details

#Bones(filename = nil, &block) ⇒ Object

call-seq:

Bones { block }

Configure Mr Bones using the given block of code. If a block is not given, the Bones module is returned.



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/bones.rb', line 105

def Bones( filename = nil, &block )

  # we absolutely have to have the bones plugin
  plugin_names = ::Bones.plugin_names
  ::Bones.plugin :bones_plugin unless plugin_names.empty? or plugin_names.include? :bones_plugin

  plugins = ::Bones.initialize_plugins.values
  ::Bones::Plugins::Gem.import_gemspec(filename) if filename
  return ::Bones unless block

  extend_method = Object.instance_method(:extend).bind(::Bones.config)
  plugins.each { |plugin|
    ps = plugin.const_get :Syntax rescue next
    extend_method.call ps
  }

  instance_eval_method = Object.instance_method(:instance_eval).bind(::Bones.config)
  instance_eval_method.call(&block)

  plugins.each { |plugin| plugin.post_load if plugin.respond_to? :post_load }
  plugins.each { |plugin| plugin.define_tasks if plugin.respond_to? :define_tasks }

  rakefiles = Dir.glob(File.join(Dir.pwd, %w[tasks *.rake])).sort
  rakefiles.each {|fn| Rake.application.add_import(fn)}
end