Module: RubyLeiningen::Commands
- Defined in:
- lib/ruby_leiningen/commands.rb,
lib/ruby_leiningen/commands/run.rb,
lib/ruby_leiningen/commands/base.rb,
lib/ruby_leiningen/commands/deps.rb,
lib/ruby_leiningen/commands/check.rb,
lib/ruby_leiningen/commands/clean.rb,
lib/ruby_leiningen/commands/helpers.rb,
lib/ruby_leiningen/commands/release.rb,
lib/ruby_leiningen/commands/uberjar.rb,
lib/ruby_leiningen/commands/version.rb,
lib/ruby_leiningen/commands/mixins/profile.rb,
lib/ruby_leiningen/commands/plugins/bikeshed.rb,
lib/ruby_leiningen/commands/mixins/environment.rb
Defined Under Namespace
Modules: Helpers, Mixins Classes: Base, Check, Clean, Config, Deps, Release, Run, Uberjar, Version
Class Method Summary collapse
-
.define_command_class(name, options, &config_block) ⇒ Object
rubocop:disable Metrics/MethodLength.
- .define_custom_command(name, options = {}) ⇒ Object
Class Method Details
.define_command_class(name, options, &config_block) ⇒ Object
rubocop:disable Metrics/MethodLength
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/ruby_leiningen/commands.rb', line 31 def define_command_class(name, , &config_block) Class.new(Base) do unless [:include_profile_support] == false include Mixins::Profile end unless [:include_environment_support] == false include Mixins::Environment end define_method 'configure_command' do |builder, opts| config = (config_block || ->(conf, _) { conf }) .call(Config.new, opts) builder = super(builder, opts) builder = builder.with_subcommand(name) do |sub| config.subcommand_block.call(sub) end config.command_block.call(builder) end end end |
.define_custom_command(name, options = {}) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/ruby_leiningen/commands.rb', line 18 def define_custom_command(name, = {}, &) klass_name = name.classify klass = define_command_class(name, , &) const_set(klass_name, klass) return if [:skip_singleton_method] RubyLeiningen.define_singleton_method name do |opts = {}| klass.new.execute(opts) end end |