Class: RepositoryInterface

Inherits:
Object
  • Object
show all
Defined in:
lib/github-to-canvas/repository_interface.rb

Class Method Summary collapse

Class Method Details

.get_name(filepath, html) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/github-to-canvas/repository_interface.rb', line 13

def self.get_name(filepath, html)
  repo_info = RepositoryConverter.get_repo_info(filepath)
  name = html[/<h1>.*<\/h1>/]
  if name
    name = name.sub('<h1>','').sub('</h1>','') 
  else
    name = repo_info[:repo_name].split(/[- _]/).map(&:capitalize).join(' ')
  end
  name
end

.local_repo_post_submission(options, response) ⇒ Object



3
4
5
6
7
8
9
10
11
# File 'lib/github-to-canvas/repository_interface.rb', line 3

def self.local_repo_post_submission(options, response)
  # Updates or creates a local .canvas file
  CanvasDotfile.update_or_create(options, response) 

  # If --save option is used, the .canvas file gets committed and pushed to the remote repo
  if options[:save_to_github]
    self.save_to_github(options[:filepath], options[:branch])
  end
end

.read_local_file(filepath, file_to_convert) ⇒ Object



24
25
26
27
28
29
30
31
32
# File 'lib/github-to-canvas/repository_interface.rb', line 24

def self.read_local_file(filepath, file_to_convert)
  begin
    markdown = File.read("#{filepath}/#{file_to_convert}")
  rescue
    puts "#{file_to_convert} not found in current directory. Exiting..."
    abort
  end
  markdown
end