Class: ThorEnhance::Autogenerate::Configuration
- Inherits:
-
Object
- Object
- ThorEnhance::Autogenerate::Configuration
- Defined in:
- lib/thor_enhance/autogenerate/configuration.rb
Constant Summary collapse
- DEFAULT_SKIP_KEY =
:skip
Instance Attribute Summary collapse
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
-
#custom_headers ⇒ Object
readonly
Returns the value of attribute custom_headers.
-
#question_headers ⇒ Object
readonly
Returns the value of attribute question_headers.
-
#readme_empty_group ⇒ Object
readonly
Returns the value of attribute readme_empty_group.
-
#readme_enums ⇒ Object
readonly
Returns the value of attribute readme_enums.
-
#readme_skip_key ⇒ Object
readonly
Returns the value of attribute readme_skip_key.
Instance Method Summary collapse
- #custom_header(name, question: false, repeatable: false, required: false) ⇒ Object
- #default ⇒ Object
- #example(required: nil, repeatable: true) ⇒ Object
- #header ⇒ Object
-
#initialize(required: false) ⇒ Configuration
constructor
A new instance of Configuration.
- #readme(required: nil, empty_group: :unassigned, skip_key: DEFAULT_SKIP_KEY, enums: [:important, :advanced, skip_key.to_sym].compact) ⇒ Object
- #set_default_required(value) ⇒ Object
- #title(required: false) ⇒ Object
Constructor Details
#initialize(required: false) ⇒ Configuration
Returns a new instance of Configuration.
10 11 12 13 14 15 16 |
# File 'lib/thor_enhance/autogenerate/configuration.rb', line 10 def initialize(required: false) @required = required @configuration = { add_option_enhance: {}, add_command_method_enhance: {} } @readme_enums = [] @custom_headers = [] @question_headers = [] end |
Instance Attribute Details
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
6 7 8 |
# File 'lib/thor_enhance/autogenerate/configuration.rb', line 6 def configuration @configuration end |
#custom_headers ⇒ Object (readonly)
Returns the value of attribute custom_headers.
6 7 8 |
# File 'lib/thor_enhance/autogenerate/configuration.rb', line 6 def custom_headers @custom_headers end |
#question_headers ⇒ Object (readonly)
Returns the value of attribute question_headers.
6 7 8 |
# File 'lib/thor_enhance/autogenerate/configuration.rb', line 6 def question_headers @question_headers end |
#readme_empty_group ⇒ Object (readonly)
Returns the value of attribute readme_empty_group.
6 7 8 |
# File 'lib/thor_enhance/autogenerate/configuration.rb', line 6 def readme_empty_group @readme_empty_group end |
#readme_enums ⇒ Object (readonly)
Returns the value of attribute readme_enums.
6 7 8 |
# File 'lib/thor_enhance/autogenerate/configuration.rb', line 6 def readme_enums @readme_enums end |
#readme_skip_key ⇒ Object (readonly)
Returns the value of attribute readme_skip_key.
6 7 8 |
# File 'lib/thor_enhance/autogenerate/configuration.rb', line 6 def readme_skip_key @readme_skip_key end |
Instance Method Details
#custom_header(name, question: false, repeatable: false, required: false) ⇒ Object
51 52 53 54 55 56 57 58 59 |
# File 'lib/thor_enhance/autogenerate/configuration.rb', line 51 def custom_header(name, question: false, repeatable: false, required: false) ThorEnhance::Configuration.allow_changes? raise ArgumentError, "Custom Header name must be unique. #{name} is already defined as a custom header. " if custom_headers.include?(name.to_sym) custom_headers << name.to_sym question_headers << name.to_sym if question configuration[:add_command_method_enhance][name.to_sym] = { repeatable: repeatable, required: required, optional_kwargs: [:tag] } end |
#default ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/thor_enhance/autogenerate/configuration.rb', line 22 def default ThorEnhance::Configuration.allow_changes? example header title readme end |
#example(required: nil, repeatable: true) ⇒ Object
38 39 40 41 42 43 |
# File 'lib/thor_enhance/autogenerate/configuration.rb', line 38 def example(required: nil, repeatable: true) ThorEnhance::Configuration.allow_changes? required = required.nil? ? @required : required configuration[:add_command_method_enhance][:example] = { repeatable: repeatable, required: required, required_kwargs: [:desc] } end |
#header ⇒ Object
45 46 47 48 49 |
# File 'lib/thor_enhance/autogenerate/configuration.rb', line 45 def header ThorEnhance::Configuration.allow_changes? configuration[:add_command_method_enhance][:header] = { repeatable: true, required: false, required_kwargs: [:name, :desc], optional_kwargs: [:tag] } end |
#readme(required: nil, empty_group: :unassigned, skip_key: DEFAULT_SKIP_KEY, enums: [:important, :advanced, skip_key.to_sym].compact) ⇒ Object
61 62 63 64 65 66 67 68 69 |
# File 'lib/thor_enhance/autogenerate/configuration.rb', line 61 def readme(required: nil, empty_group: :unassigned, skip_key: DEFAULT_SKIP_KEY, enums: [:important, :advanced, skip_key.to_sym].compact) ThorEnhance::Configuration.allow_changes? @readme_empty_group = empty_group.to_sym @readme_skip_key = skip_key @readme_enums = enums.map(&:to_sym) << empty_group.to_sym required = required.nil? ? @required : required configuration[:add_option_enhance][:readme] = { enums: enums, required: required } end |
#set_default_required(value) ⇒ Object
18 19 20 |
# File 'lib/thor_enhance/autogenerate/configuration.rb', line 18 def set_default_required(value) @required = value end |
#title(required: false) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/thor_enhance/autogenerate/configuration.rb', line 31 def title(required: false) ThorEnhance::Configuration.allow_changes? required = required.nil? ? @required : required configuration[:add_command_method_enhance][:title] = { repeatable: false, required: required } end |