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

Class Method Details

.author_emailObject



67
68
69
# File 'lib/gemsmith/cli_options.rb', line 67

def author_email
  @settings[:author_email] || Gemsmith::Kit.git_config_value("user.email") || "TODO: Add email address."
end

.author_nameObject



63
64
65
# File 'lib/gemsmith/cli_options.rb', line 63

def author_name
  @settings[:author_name] || Gemsmith::Kit.git_config_value("user.name") || "TODO: Add full name."
end

.author_urlObject



71
72
73
# File 'lib/gemsmith/cli_options.rb', line 71

def author_url
  @settings[:author_url] || "https://www.unknown.com"
end

.company_nameObject



75
76
77
# File 'lib/gemsmith/cli_options.rb', line 75

def company_name
  @settings[:company_name] || author_name
end

.company_urlObject



79
80
81
# File 'lib/gemsmith/cli_options.rb', line 79

def company_url
  @settings[:company_url] || author_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_platformObject



47
48
49
# File 'lib/gemsmith/cli_options.rb', line 47

def gem_platform
  @settings[:gem_platform] || "Gem::Platform::RUBY"
end

.gem_private_keyObject



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_keyObject



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_urlObject



51
52
53
# File 'lib/gemsmith/cli_options.rb', line 51

def gem_url
  @settings[:gem_url] || author_url
end

.github_userObject



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 initialize_template_options name, options = {}
  @settings.merge! options
  @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_name,
    author_email: author_email,
    author_url: 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_versionObject



95
96
97
# File 'lib/gemsmith/cli_options.rb', line 95

def rails_version
  @settings[:rails_version] || "4.2"
end

.ruby_versionObject



91
92
93
# File 'lib/gemsmith/cli_options.rb', line 91

def ruby_version
  @settings[:ruby_version] || "2.2.3"
end

.yearObject



87
88
89
# File 'lib/gemsmith/cli_options.rb', line 87

def year
  @settings[:year] || Time.now.year
end