lib/ryonan/interactive.rb in ryonan-0.0.2 vs lib/ryonan/interactive.rb in ryonan-0.0.3

- old
+ new

@@ -1,7 +1,6 @@ require 'readline' -require 'active_support/core_ext/string/strip' module Ryonan module Interactive class << self def print_template_list(filer) @@ -21,16 +20,16 @@ exit 1 end end def read_template_name - name = Readline.readline(<<-'EOS'.strip_heredoc.chomp + ' ') + name = Readline.readline(<<~'EOS'.chomp + ' ') Input the destination directory name ( Deprecated: If the input is blank, to expand the template directory on one level up ) -> EOS - + if name == Config.template_dir_name puts "#{Config.template_dir_name} will overlap with the template directory name" exit 1 else name @@ -40,19 +39,19 @@ def read_configs(template_root) puts 'Set the value to the variable in the template' variables = File.open(config_file_path(template_root)).readlines.map(&:chomp) variables.map { |line| read_config(line) }.to_h end - - private - + + private + def config_file_path(template_root) "#{template_root}/#{Config.template_dir_name}/#{Config.config_file_name}" end - + def read_config(line) - if line.match(/.+=/) + if line =~ /.+=/ (variable_name, default) = line.split('=') input = Readline.readline(" #{variable_name} (Default: #{default}) -> ") variable_value = input.empty? ? default : input else variable_name = line @@ -60,6 +59,6 @@ end [variable_name, variable_value] end end end -end \ No newline at end of file +end