class Xanthus::GitHub

Attributes

folder[RW]
repo[RW]
token[RW]

Public Class Methods

new() click to toggle source
Calls superclass method
# File lib/xanthus/github.rb, line 9
def initialize
  super
  @repo = ''
  @token = ''
  @folder = Time.now.strftime("%Y-%m-%d_%H-%M")
end

Public Instance Methods

add(content) click to toggle source
# File lib/xanthus/github.rb, line 63
def add content
  Dir.chdir 'repo' do
    FileUtils.mkdir_p @folder
    system('mv', "../#{content}", "#{@folder}/#{content}")
    system('git', 'add', "#{@folder}/#{content}")
    system('git', 'commit', '-m', "[Xanthus] :horse: pushed #{@folder}/#{content} :horse:")
  end
end
clean() click to toggle source
# File lib/xanthus/github.rb, line 86
def clean
  system('rm', '-rf', 'repo')
end
init(config) click to toggle source
# File lib/xanthus/github.rb, line 50
def init config
  system('git', 'clone', "https://#{@token}@github.com/#{@repo}", 'repo')
  Dir.chdir 'repo' do
    self.lfs
    FileUtils.mkdir_p @folder
    Dir.chdir @folder do
      self.xanthus_file
      self.readme_file config
      self.inputs_file config
    end
  end
end
inputs_file(config) click to toggle source
# File lib/xanthus/github.rb, line 37
def inputs_file config
  config.jobs.each do |name,job|
    job.inputs.each do |k, files|
      files.each do |file|
        system('cp', '-f', "../../#{file}", "#{file}")
        system('git', 'add', "#{file}")
        system('git', 'commit', '-m', "[Xanthus] :horse: pushed #{@folder}/#{file} :horse:")
        system('git', 'push', "https://#{@token}@github.com/#{@repo}", 'master')
      end
    end
  end
end
lfs() click to toggle source
# File lib/xanthus/github.rb, line 16
def lfs
  system('git', 'lfs', 'install')
  system('git', 'lfs', 'track', '*.tar.gz')
  system('git', 'add', '.gitattributes')
  system('git', 'push', "https://#{@token}@github.com/#{@repo}", 'master')
end
push() click to toggle source
# File lib/xanthus/github.rb, line 72
def push
  Dir.chdir 'repo' do
    system('git', 'push', "https://#{@token}@github.com/#{@repo}", 'master')
    system('rm', '-rf', @folder)
  end
end
readme_file(config) click to toggle source
# File lib/xanthus/github.rb, line 30
def readme_file config
  self.prepare_readme_file config
  system('git', 'add', 'README.md')
  system('git', 'commit', '-m', "[Xanthus] :horse: pushed #{@folder}/README.md :horse:")
  system('git', 'push', "https://#{@token}@github.com/#{@repo}", 'master')
end
tag() click to toggle source
# File lib/xanthus/github.rb, line 79
def tag
  Dir.chdir 'repo' do
    system('git', 'tag', '-a', "xanthus-#{@folder}", '-m', '"Xanthus automated dataset generation."')
    system('git', 'push', '--tags', "https://#{@token}@github.com/#{@repo}")
  end
end
xanthus_file() click to toggle source
# File lib/xanthus/github.rb, line 23
def xanthus_file
  self.prepare_xanthus_file
  system('git', 'add', '.xanthus')
  system('git', 'commit', '-m', "[Xanthus] :horse: pushed #{@folder}/.xanthus :horse:")
  system('git', 'push', "https://#{@token}@github.com/#{@repo}", 'master')
end