Class: Lolcommits::Uploader

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/lolcommits-uploader/version.rb,
lib/lolcommits-uploader/uploader.rb

Constant Summary collapse

VERSION =
"0.0.2"

Instance Method Summary collapse

Instance Method Details

#disableObject



29
30
31
# File 'lib/lolcommits-uploader/uploader.rb', line 29

def disable
  gsub_file "#{repo.dir.to_s}/.git/hooks/post-commit", "lolcommits-uploader upload &> /dev/null &", ""
end

#enableObject



24
25
26
# File 'lib/lolcommits-uploader/uploader.rb', line 24

def enable
  append_file "#{repo.dir.to_s}/.git/hooks/post-commit", "lolcommits-uploader upload &> /dev/null &"
end

#uploadObject



6
7
8
# File 'lib/lolcommits-uploader/uploader.rb', line 6

def upload
  upload_file repo.log.first.sha[0..10]
end

#upload_allObject



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/lolcommits-uploader/uploader.rb', line 11

def upload_all
  files = Dir[File.expand_path("~/.lolcommits/#{repo_name}/*.jpg")]
  bar = ProgressBar.new('Uploading', files.size)
  files.each do |filename|
    match = filename.match(/\/([0-9a-f]+)\.jpg$/)
    next unless match && !uploaded?(match[1])
    upload_file match[1]
    bar.inc
  end
  bar.finish
end