class Public
Constants
- VERSION
Public Class Methods
change_me()
click to toggle source
# File lib/public.rb, line 72 def self.change_me puts "Your config file is located at '~/.public_gem'" puts "Please replace the default value with your Dropbox ID." puts "(You can find this in a Dropbox public URL: " puts "dl.dropboxusercontent.com/u/YOUR_ID/foobar.zip)" end
config()
click to toggle source
# File lib/public.rb, line 9 def self.config file = setup get_id(file) end
copy_link(file)
click to toggle source
# File lib/public.rb, line 60 def self.copy_link(file) get_id(File.read(CONFIG)) if @user_id == "CHANGE_ME" change_me else dropbox_url = "https://dl.dropboxusercontent.com/u/#{ @user_id }/#{ file }" Clipboard.copy(dropbox_url) puts dropbox_url puts "Copied to clipboard." end end
get_id(file)
click to toggle source
# File lib/public.rb, line 37 def self.get_id(file) @user_id = file.split(": ").last.chomp unless file.nil? end
move_file(file)
click to toggle source
# File lib/public.rb, line 53 def self.move_file(file) without_spaces = file.gsub(" ", "_") dropbox_location = Dir.home + "/Dropbox/Public/" + without_spaces FileUtils.cp file, dropbox_location copy_link(without_spaces) end
not_configured()
click to toggle source
# File lib/public.rb, line 30 def self.not_configured FileUtils.cp "#{ GEM_DIRECTORY }/.public_gem", CONFIG file = File.read(CONFIG) change_me file end
process(file)
click to toggle source
# File lib/public.rb, line 41 def self.process(file) unless File.file?(CONFIG) not_configured else if File.file?(file) move_file(file) else puts "That file doesn't exist!" end end end
setup()
click to toggle source
# File lib/public.rb, line 14 def self.setup if File.file?(CONFIG) file = File.read(CONFIG) get_id(file) if @user_id == "CHANGE_ME" change_me else puts "Already configured with a Dropbox ID of #{ @user_id }" puts "Try copying a file with 'public <FILE>'" end else not_configured end file end