Class: Gemfather::Cli::SettingsBuilder
- Inherits:
-
Object
- Object
- Gemfather::Cli::SettingsBuilder
- Defined in:
- lib/gemfather/cli/settings_builder.rb
Constant Summary collapse
- DEFAULT_GEM_NAME =
"awesome-new-gem"- DEFAULT_USER_EMAIL =
"[email protected]"- DEFAULT_USERNAME =
`whoami`.chomp
Instance Attribute Summary collapse
-
#settings ⇒ Object
Returns the value of attribute settings.
Instance Method Summary collapse
- #call ⇒ Object
- #get_binding ⇒ Object
-
#initialize ⇒ SettingsBuilder
constructor
A new instance of SettingsBuilder.
Constructor Details
#initialize ⇒ SettingsBuilder
Returns a new instance of SettingsBuilder.
12 13 14 |
# File 'lib/gemfather/cli/settings_builder.rb', line 12 def initialize @settings = {} end |
Instance Attribute Details
#settings ⇒ Object
Returns the value of attribute settings.
10 11 12 |
# File 'lib/gemfather/cli/settings_builder.rb', line 10 def settings @settings end |
Instance Method Details
#call ⇒ Object
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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/gemfather/cli/settings_builder.rb', line 16 def call prompt = TTY::Prompt.new(interrupt: :exit) user_email = `git config user.email`.chomp settings[:email] = user_email.empty? ? DEFAULT_USER_EMAIL : user_email username = `git config user.name`.chomp settings[:username] = username.empty? ? DEFAULT_USERNAME : username settings[:name] = prompt.ask("Gem name:", default: DEFAULT_GEM_NAME) settings[:summary] = prompt.ask("Summary", default: DEFAULT_GEM_NAME) settings[:description] = prompt.ask("Description", default: DEFAULT_GEM_NAME) settings[:homepage] = prompt.ask("Home page(URL)", default: DEFAULT_GEM_NAME, value: "https://github.com/") settings[:licence] = prompt.select("Select Licence") do || .choice "MIT", "mit" .choice "N/A", "n/a" end settings[:linter] = prompt.select("Select linter") do || .choice "Standard", "standard" .choice "Rubocop", "rubocop" .choice "N/A", "n/a" end settings[:test] = prompt.select("Select test tool") do || .choice "RSpec", "rspec" .choice "Minitest", "minitest" .choice "N/A", "n/a" end settings[:ci] = prompt.select("Select CI") do || .choice "GitHub", "github" .choice "Gitlab", "gitlab" end settings[:use_release_please] = prompt.yes?("Do you want to use release-please for releases?") settings[:makefile?] = prompt.yes?("Do you need Makefile?") settings[:coc?] = prompt.yes?("Do you need Code Of Conduct?") settings[:changelog?] = prompt.yes?("Do you need CHANGELOG file?") settings[:debugger] = prompt.select("Select debugger tool:") do || .choice "IRB", "irb" .choice "Pry", "pry" end settings end |
#get_binding ⇒ Object
66 67 68 |
# File 'lib/gemfather/cli/settings_builder.rb', line 66 def get_binding binding end |