Class: LearnDuplicate

Inherits:
LearnBase show all
Defined in:
lib/learn-tool/learn-duplicate.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) ⇒ LearnDuplicate

Returns a new instance of LearnDuplicate.



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

def initialize(filepath)
  super(filepath)
  puts 'Note: You must have write access to the learn-co-curriculum org on GitHub to use this tool'
  get_old_repo
end

Instance Method Details

#get_old_repoObject



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

def get_old_repo  
  loop do
    puts 'What is the name of the repository you would like to copy? Paste exactly as is shown in the URL (i.e. advanced-hashes-hashketball)'
    old_repo_name_input = gets.strip
    if !repo_is_available(old_repo_name_input)
      @old_repo_name = old_repo_name_input
      puts ''
      puts 'Old repository: ' + @old_repo_name
      until name_new_repo do
        puts 'Careful - rate limiting can occur'
      end
      
      
      create_new_repo
      end_message
      break
    else
      puts 'Provided repository name is not a valid learn-co-curriculum repository. Please try again. Careful - rate limiting can be triggered'
    end
  end
end