Class: LearnCreate

Inherits:
LearnBase show all
Defined in:
lib/learn-tool/learn-create.rb

Constant Summary

Constants inherited from LearnBase

LearnBase::GITHUB_ORG, LearnBase::JAVASCRIPT_LAB_TEMPLATE, LearnBase::REACT_LAB_TEMPLATE, LearnBase::README_TEMPLATE, LearnBase::RUBY_LAB_TEMPLATE

Instance Method Summary collapse

Methods inherited from LearnBase

#cd_into_and, #create_new_repo, #end_message, #get_new_name, #name_new_repo, #repo_is_available

Constructor Details

#initialize(filepath) ⇒ LearnCreate

Returns a new instance of LearnCreate.



3
4
5
6
7
8
9
# File 'lib/learn-tool/learn-create.rb', line 3

def initialize(filepath)
  super(filepath)
  get_new_name
  choose_repo_template
  create_new_repo
  end_message
end

Instance Method Details

#choose_languageObject



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/learn-tool/learn-create.rb', line 32

def choose_language
  language = ''
  loop do
    puts 'What lab template would you like to use? (Ruby/JavaScript/React)'
    language = gets.chomp.downcase
    break if language =~ /^(ru|j|re)/
    puts 'Please enter Ruby, JavaScript or React, or at minimum, the first two letters:'
    puts ''
  end
  language
end

#choose_repo_templateObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/learn-tool/learn-create.rb', line 11

def choose_repo_template
  puts 'Is the lesson you are creating a Readme? (Y/n)'
  readme_input = gets.chomp.downcase
  if readme_input == "n" || readme_input == "no" || readme_input == "N" || readme_input == "No"
    language = choose_language
    case language
    when /^ru/
      @old_repo_name = RUBY_LAB_TEMPLATE
    when /^j/
      @old_repo_name = JAVASCRIPT_LAB_TEMPLATE
    when /^re/
      @old_repo_name = REACT_LAB_TEMPLATE
    else
      @old_repo_name = README_TEMPLATE
    end
  else
    @old_repo_name = README_TEMPLATE
  end
  @old_repo_name
end