lib/zine/uploader_github.rb in zine-0.5.0 vs lib/zine/uploader_github.rb in zine-0.6.0
- old
+ new
@@ -10,42 +10,48 @@
# access_token: ...
# For instructions on how to create an access token:
# https://help.github.com/articles/creating-an-access-token-for-command-line-use/
def initialize(build_dir, options, credentials, delete_file_array,
upload_file_array)
- return unless options['method'] == 'github'
+ unless options['method'] == 'github'
+ @no_upload = true
+ return
+ end
@build_dir = build_dir
@repo_full_name = options['path_or_repo']
@client = Octokit::Client.new(access_token: credentials['access_token'])
@verbose = options['verbose']
@credentials = credentials
@delete_file_array = delete_file_array
@upload_file_array = upload_file_array
end
# Duplicates within & between the files already removed in Zine::Upload
- # then .each... upload & delete - use build_dor to create relative paths
+ # then .each... upload & delete - uses @build_dir to create relative paths
def upload
+ return if @no_upload
@delete_file_array.each do |file_pathname|
delete_file file_pathname
end
@upload_file_array.each do |file_pathname|
upload_file file_pathname
end
end
+ private
+
# see if file exists, then delete it if it does
# returns commit hash (unused)
def delete_file(rel_path)
- info_hash = info github_path
+ info_hash = info rel_path
@client.delete_contents(@repo_full_name,
rel_path,
'Zine delete', # commit message
info_hash[:sha],
branch: 'gh-pages')
- puts "Deleted #{github_path}" if @verbose
+ puts "Deleted #{rel_path}" if @verbose
rescue Octokit::NotFound
- puts "Tried to delete nonexistent remote file #{github_path}"
+ puts "Tried to delete nonexistent remote file #{rel_path}"
end
# return info on a file if it exsists, otherwise throws Octokit::NotFound
def info(github_path)
Octokit.contents(@repo_full_name,