Module: Gemsmith::CLIOptions

Included in:
CLI
Defined in:
lib/gemsmith/cli_options.rb

Class Method Summary collapse

Class Method Details

.author_emailObject



54
55
56
# File 'lib/gemsmith/cli_options.rb', line 54

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

.author_nameObject



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

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

.author_urlObject



58
59
60
# File 'lib/gemsmith/cli_options.rb', line 58

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

.company_nameObject



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

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

.company_urlObject



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

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

.default_boolean(key, value = false) ⇒ Object



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

def default_boolean key, value = false
  @settings.has_key?(key) ? @settings[key] : value
end

.gem_platformObject



42
43
44
# File 'lib/gemsmith/cli_options.rb', line 42

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

.gem_urlObject



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

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

.github_userObject



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

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: {}.



9
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
# File 'lib/gemsmith/cli_options.rb', line 9

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,
    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,
    ruby_patch: ruby_patch,
    rails_version: rails_version,
    post_install_message: @settings[:post_install_message],
    bin: default_boolean(:bin),
    rails: default_boolean(:rails),
    pry: default_boolean(:pry, true),
    guard: default_boolean(:guard, true),
    rspec: default_boolean(:rspec, true),
    travis: default_boolean(:travis, true),
    code_climate: default_boolean(:code_climate, true)
  }
end

.rails_versionObject



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

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

.ruby_patchObject



82
83
84
# File 'lib/gemsmith/cli_options.rb', line 82

def ruby_patch
  @settings[:ruby_patch] || "p0"
end

.ruby_versionObject



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

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

.yearObject



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

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