Sha256: f45bd50787d35cd6b4bd79b63d7fa5f0225dca918479ec78b521ed003cd6a697
Contents?: true
Size: 1.56 KB
Versions: 2
Compression:
Stored size: 1.56 KB
Contents
module Rbcli @data = { scriptname: nil, version: nil, description: nil, config_userfile: 'config.yml', allow_json: false, options: {}, default_action: nil, pre_hook: nil, post_hook: nil } def self.configurate &block @self_before_instance_eval = eval "self", block.binding instance_eval &block end # def self.method_missing(method, *args, &block) # @self_before_instance_eval.send method, *args, &block # end ## # DSL Functions ## def self.scriptname name @data[:scriptname] = name end def self.version vsn @data[:version] = vsn end def self.description desc @data[:description] = desc end def self.log_level level Rbcli::Logger::save_defaults level: level end def self.log_target target Rbcli::Logger::save_defaults target: target end def self.config_userfile *params Rbcli::Config::set_userfile *params @data[:config_userfile] = params[0] end def self.config_defaults filename Rbcli::Config::add_defaults filename end def self.config_default *params Rbcli::Config::add_default *params end def self.allow_json_output allow_json @data[:allow_json] = allow_json end def self.option name, description, type: :boolean, default: false @data[:options][name.to_sym] = { description: description, type: type, default: default } end def self.default_action &block @data[:default_action] = block end def self.pre_hook &block @data[:pre_hook] = block end def self.post_hook &block @data[:post_hook] = block end ## # Data Retrieval ## def self.configuration @data end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rbcli-0.1.1 | lib/rbcli/configurate.rb |
rbcli-0.1.0 | lib/rbcli/configurate.rb |