Class: Public
- Inherits:
-
Object
- Object
- Public
- Defined in:
- lib/public.rb,
lib/public/version.rb
Constant Summary collapse
- VERSION =
"0.0.5"
Class Method Summary collapse
- .change_me ⇒ Object
- .config ⇒ Object
- .copy_link(file) ⇒ Object
- .get_id(file) ⇒ Object
- .move_file(file) ⇒ Object
- .not_configured ⇒ Object
- .process(file) ⇒ Object
- .setup ⇒ Object
Class Method Details
.change_me ⇒ Object
72 73 74 75 76 77 |
# 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 ⇒ Object
9 10 11 12 |
# File 'lib/public.rb', line 9 def self.config file = setup get_id(file) end |
.copy_link(file) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 |
# 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) ⇒ Object
37 38 39 |
# File 'lib/public.rb', line 37 def self.get_id(file) @user_id = file.split(": ").last.chomp unless file.nil? end |
.move_file(file) ⇒ Object
53 54 55 56 57 58 |
# 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 ⇒ Object
30 31 32 33 34 35 |
# 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) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 |
# 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 ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# 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 |