Class: Dopstick::Generator::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/dopstick/generator/options.rb

Direct Known Subclasses

Gem::Options, NPM::Options

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Options

Returns a new instance of Options.



8
9
10
# File 'lib/dopstick/generator/options.rb', line 8

def initialize(options)
  @options = options
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



24
25
26
# File 'lib/dopstick/generator/options.rb', line 24

def method_missing(name, *args)
  @options.key?(name) ? @options[name] : super
end

Instance Method Details

#[](key) ⇒ Object



12
13
14
# File 'lib/dopstick/generator/options.rb', line 12

def [](key)
  @options[key]
end

#bin?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/dopstick/generator/options.rb', line 32

def bin?
  !@options[:bin].empty?
end

#github_urlObject



60
61
62
# File 'lib/dopstick/generator/options.rb', line 60

def github_url
  "https://github.com/#{github_user}/#{package_name}"
end

#github_userObject



48
49
50
51
52
# File 'lib/dopstick/generator/options.rb', line 48

def github_user
  @github_user ||= @options[:author_github].presence ||
                   `git config user.github`.chomp.presence ||
                   "[USER]"
end

#merge(other) ⇒ Object



16
17
18
# File 'lib/dopstick/generator/options.rb', line 16

def merge(other)
  @options.merge(other)
end

#paypal_userObject



54
55
56
57
58
# File 'lib/dopstick/generator/options.rb', line 54

def paypal_user
  @paypal_user ||= @options[:author_paypal].presence ||
                   `git config user.paypal`.chomp.presence ||
                   "[USER]"
end

#respond_to_missing?(name, _include_all) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/dopstick/generator/options.rb', line 20

def respond_to_missing?(name, _include_all)
  options.key?(name) || super
end

#skip_install?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/dopstick/generator/options.rb', line 28

def skip_install?
  @options[:skip_install]
end

#user_emailObject



42
43
44
45
46
# File 'lib/dopstick/generator/options.rb', line 42

def user_email
  @user_email ||= @options[:author_email].presence ||
                  `git config user.email`.chomp.presence ||
                  "your@email.com"
end

#user_nameObject



36
37
38
39
40
# File 'lib/dopstick/generator/options.rb', line 36

def user_name
  @user_name ||= @options[:author_name].presence ||
                 `git config user.name`.chomp.presence ||
                 "Your Name"
end