Module: Gemsmith::CLIOptions

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

Class Method Summary collapse

Class Method Details

.author_emailObject



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

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

.author_nameObject



60
61
62
# File 'lib/gemsmith/cli_options.rb', line 60

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

.author_urlObject



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

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

.company_nameObject



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

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

.company_urlObject



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

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

.default_boolean(key, value = false) ⇒ Object



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

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

.gem_platformObject



44
45
46
# File 'lib/gemsmith/cli_options.rb', line 44

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

.gem_private_keyObject



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

def gem_private_key
  @settings.fetch :gem_private_key, "~/.ssh/gem-private.pem"
end

.gem_public_keyObject



56
57
58
# File 'lib/gemsmith/cli_options.rb', line 56

def gem_public_key
  @settings.fetch :gem_public_key, "~/.ssh/gem-public.pem"
end

.gem_urlObject



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

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

.github_userObject



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

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
41
42
# 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,
    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),
    pry: default_boolean(:pry, true),
    guard: default_boolean(:guard, true),
    rspec: default_boolean(:rspec, true),
    code_climate: default_boolean(:code_climate, true),
    gemnasium: default_boolean(:gemnasium, true),
    travis: default_boolean(:travis, true)
  }
end

.rails_versionObject



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

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

.ruby_versionObject



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

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

.yearObject



84
85
86
# File 'lib/gemsmith/cli_options.rb', line 84

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