class OpeningAct

Main class for OpeningAct

Constants

VERSION

Attributes

template[R]

Public Class Methods

perform(name, test_name) click to toggle source
# File lib/opening_act.rb, line 14
def self.perform(name, test_name)
  return leave_the_stage if nested_git? && quit_playing?

  setup(name, test_name)
  add_overwrite_rename_or_quit while directory_exists?
  take_the_stage
  create_project_files
  curtain_call
end

Private Class Methods

add_overwrite_rename_or_quit() click to toggle source
# File lib/opening_act.rb, line 26
def self.add_overwrite_rename_or_quit
  directory_exists_commands
  command = command_input
  determine_action(command)
end
correct_test_name?(test_type) click to toggle source
# File lib/opening_act.rb, line 32
def self.correct_test_name?(test_type)
  %w[minitest rspec].include?(test_type[1..-1])
end
create_project_files() click to toggle source
# File lib/opening_act.rb, line 36
def self.create_project_files
  template.create
  template.remove_extra_files
  template.rename_files
  template.initiate_project
end
determine_action(command) click to toggle source
# File lib/opening_act.rb, line 43
def self.determine_action(command)
  case command
  when 'add'              then add_confirmation
  when 'overwrite'        then overwrite_existing_dir
  when 'rename'           then rename_project
  when 'quit' || 'q'      then leave_the_stage
  else 'no command'
  end
end
directory_exists?() click to toggle source
# File lib/opening_act.rb, line 53
def self.directory_exists?
  Dir.exist? name
end
flag?(test_type) click to toggle source
# File lib/opening_act.rb, line 57
def self.flag?(test_type)
  test_type[0] == '-'
end
nested_git?() click to toggle source
# File lib/opening_act.rb, line 61
def self.nested_git?
  File.exist? '.git'
end
overwrite_existing_dir() click to toggle source
# File lib/opening_act.rb, line 65
def self.overwrite_existing_dir
  FileUtils.rm_rf(template.name)

  overwrite_confirmation
end
quit_playing?() click to toggle source
# File lib/opening_act.rb, line 71
def self.quit_playing?
  nested_git_confirmation

  user_input.downcase != 'continue'
end
rename_project() click to toggle source
# File lib/opening_act.rb, line 77
def self.rename_project
  template.name = project_name_input
  rename_confirmation
end
setup(project_name, test_type) click to toggle source
# File lib/opening_act.rb, line 82
def self.setup(project_name, test_type)
  project_name = project_name_input unless valid_name?(project_name)
  test_type = test_type_input unless valid_test?(test_type)

  @template = Template.new(project_name, test_type)
end