Module: Gemsmith::CLIOptions
- Included in:
- CLI
- Defined in:
- lib/gemsmith/cli_options.rb
Overview
Provides Command Line Interface (CLI) settings initialization with safe defaults.
Class Method Summary collapse
- .author_email ⇒ Object
- .author_name ⇒ Object
- .author_url ⇒ Object
- .company_name ⇒ Object
- .company_url ⇒ Object
- .default_boolean(key, value = false) ⇒ Object
- .gem_platform ⇒ Object
- .gem_private_key ⇒ Object
- .gem_public_key ⇒ Object
- .gem_url ⇒ Object
- .github_user ⇒ Object
-
.initialize_template_options(name, options = {}) ⇒ Object
Initializes template options with default and/or command line overrides.
- .rails_version ⇒ Object
- .ruby_version ⇒ Object
- .year ⇒ Object
Class Method Details
.author_email ⇒ Object
67 68 69 |
# File 'lib/gemsmith/cli_options.rb', line 67 def @settings[:author_email] || Gemsmith::Kit.git_config_value("user.email") || "TODO: Add email address." end |
.author_name ⇒ Object
63 64 65 |
# File 'lib/gemsmith/cli_options.rb', line 63 def @settings[:author_name] || Gemsmith::Kit.git_config_value("user.name") || "TODO: Add full name." end |
.author_url ⇒ Object
71 72 73 |
# File 'lib/gemsmith/cli_options.rb', line 71 def @settings[:author_url] || "https://www.unknown.com" end |
.company_name ⇒ Object
75 76 77 |
# File 'lib/gemsmith/cli_options.rb', line 75 def company_name @settings[:company_name] || end |
.company_url ⇒ Object
79 80 81 |
# File 'lib/gemsmith/cli_options.rb', line 79 def company_url @settings[:company_url] || end |
.default_boolean(key, value = false) ⇒ Object
99 100 101 |
# File 'lib/gemsmith/cli_options.rb', line 99 def default_boolean key, value = false @settings.key?(key) ? @settings[key] : value end |
.gem_platform ⇒ Object
47 48 49 |
# File 'lib/gemsmith/cli_options.rb', line 47 def gem_platform @settings[:gem_platform] || "Gem::Platform::RUBY" end |
.gem_private_key ⇒ Object
55 56 57 |
# File 'lib/gemsmith/cli_options.rb', line 55 def gem_private_key @settings.fetch :gem_private_key, "~/.ssh/gem-private.pem" end |
.gem_public_key ⇒ Object
59 60 61 |
# File 'lib/gemsmith/cli_options.rb', line 59 def gem_public_key @settings.fetch :gem_public_key, "~/.ssh/gem-public.pem" end |
.gem_url ⇒ Object
51 52 53 |
# File 'lib/gemsmith/cli_options.rb', line 51 def gem_url @settings[:gem_url] || end |
.github_user ⇒ Object
83 84 85 |
# File 'lib/gemsmith/cli_options.rb', line 83 def github_user @settings[:github_user] || Gemsmith::Kit.git_config_value("github.user") || "unknown" end |
.initialize_template_options(name, options = {}) ⇒ Object
Initializes template options with default and/or command line overrides.
Parameters
-
name
- Required. The gem name. -
options
- Optional. Additional command line options. Default: {}.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/gemsmith/cli_options.rb', line 10 def name, = {} @settings.merge! @settings = enforce_symbol_keys @settings gem_name name gem_class name @template_options = { gem_name: gem_name, gem_class: gem_class, gem_platform: gem_platform, gem_url: gem_url, gem_private_key: gem_private_key, gem_public_key: gem_public_key, author_name: , author_email: , author_url: , company_name: company_name, company_url: company_url, github_user: github_user, year: year, ruby_version: ruby_version, rails_version: rails_version, post_install_message: @settings[:post_install_message], bin: default_boolean(:bin), rails: default_boolean(:rails), security: default_boolean(:security, true), pry: default_boolean(:pry, true), guard: default_boolean(:guard, true), rspec: default_boolean(:rspec, true), rubocop: default_boolean(:rubocop, true), code_climate: default_boolean(:code_climate, true), gemnasium: default_boolean(:gemnasium, true), travis: default_boolean(:travis, true) } end |
.rails_version ⇒ Object
95 96 97 |
# File 'lib/gemsmith/cli_options.rb', line 95 def rails_version @settings[:rails_version] || "4.2" end |
.ruby_version ⇒ Object
91 92 93 |
# File 'lib/gemsmith/cli_options.rb', line 91 def ruby_version @settings[:ruby_version] || "2.2.3" end |
.year ⇒ Object
87 88 89 |
# File 'lib/gemsmith/cli_options.rb', line 87 def year @settings[:year] || Time.now.year end |