public 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8a382ce8e0b3b53e121f5a0dbade5349e37855eb
4
+ data.tar.gz: 315d92c0d4d95a13b01327d213132008ff934027
5
+ SHA512:
6
+ metadata.gz: 2472cbe3f756ed800a57424cc4634bfb4f351f3188063346e63e7d3504af76e405659ff0b5cee981e401a0d085d4750442963be681fa2c11702b5991b947f2ef
7
+ data.tar.gz: 2ab29f30bad923207d1dbf186aa8805dd6f2a6ee47a6139e977d9bca33a6446fd7b56f1c09a1ba5fbf5771454a706954752d4c8288d5e6ad3bb9f9b6c10996bf
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .DS_Store
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in public.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Kristian Freeman
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,53 @@
1
+ # Public
2
+
3
+ Public is a Ruby command-line tool for quickly copying files to your public
4
+ [Dropbox](https://dropbox.com) folder.
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ gem 'public'
11
+
12
+ And then execute:
13
+
14
+ $ bundle
15
+
16
+ Or install it yourself as:
17
+
18
+ $ gem install public
19
+
20
+ ## Usage
21
+
22
+ Run the command by itself to generate a configuration file:
23
+
24
+ ```
25
+ > public
26
+ ```
27
+
28
+ This will create `~/.public_gem`, where you can set your Dropbox ID:
29
+
30
+ ```
31
+ dropbox_user_id: CHANGE_ME
32
+ ```
33
+
34
+ Your Dropbox ID can be found in a URL from your public folder:
35
+
36
+ ```
37
+ https://dl.dropboxusercontent.com/u/YOUR_ID/foobar
38
+ ```
39
+
40
+ Once you change this, you can then run `public` with a file (or files) as the
41
+ argument to copy them to your Public folder **and** your clipboard.
42
+
43
+ ```
44
+ > public foobar.txt
45
+ ```
46
+
47
+ ## Contributing
48
+
49
+ 1. Fork it
50
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
51
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
52
+ 4. Push to the branch (`git push origin my-new-feature`)
53
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/public ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'public'
4
+
5
+ if ARGV.empty?
6
+ Public.config
7
+ else
8
+ ARGV.each.with_index do |arg|
9
+ Public.process(arg)
10
+ end
11
+ end
12
+
data/lib/.public_gem ADDED
@@ -0,0 +1 @@
1
+ dropbox_user_id: CHANGE_ME
data/lib/public.rb ADDED
@@ -0,0 +1,77 @@
1
+ require "public/version"
2
+ require "fileutils"
3
+ require "clipboard"
4
+
5
+ GEM_DIRECTORY = File.dirname(__FILE__)
6
+ CONFIG = "#{ Dir.home }/.public_gem"
7
+
8
+ class Public
9
+ def self.config
10
+ file = setup
11
+ get_id(file)
12
+ end
13
+
14
+ def self.setup
15
+ if File.file?(CONFIG)
16
+ file = File.read(CONFIG)
17
+ get_id(file)
18
+ if @user_id == "CHANGE_ME"
19
+ change_me
20
+ else
21
+ puts "Already configured with a Dropbox ID of #{ @user_id }"
22
+ puts "Try copying a file with 'public <FILE>'"
23
+ end
24
+ else
25
+ not_configured
26
+ end
27
+ file
28
+ end
29
+
30
+ def self.not_configured
31
+ FileUtils.cp "#{ GEM_DIRECTORY }/.public_gem", CONFIG
32
+ file = File.read(CONFIG)
33
+ change_me
34
+ file
35
+ end
36
+
37
+ def self.get_id(file)
38
+ @user_id = file.split(": ").last.chomp unless file.nil?
39
+ end
40
+
41
+ def self.process(file)
42
+ unless File.file?(CONFIG)
43
+ not_configured
44
+ else
45
+ if File.file?(file)
46
+ move_file(file)
47
+ else
48
+ puts "That file doesn't exist!"
49
+ end
50
+ end
51
+ end
52
+
53
+ def self.move_file(file)
54
+ dropbox_location = "#{ Dir.home }/Dropbox/Public/"
55
+ FileUtils.cp file, dropbox_location
56
+ copy_link(file)
57
+ end
58
+
59
+ def self.copy_link(file)
60
+ get_id(File.read(CONFIG))
61
+ if @user_id == "CHANGE_ME"
62
+ change_me
63
+ else
64
+ dropbox_url = "https://dl.dropboxusercontent.com/u/#{ @user_id }/#{ file }"
65
+ Clipboard.copy(dropbox_url)
66
+ puts dropbox_url
67
+ puts "Copied to clipboard."
68
+ end
69
+ end
70
+
71
+ def self.change_me
72
+ puts "Your config file is located at '~/.public_gem'"
73
+ puts "Please replace the default value with your Dropbox ID."
74
+ puts "(You can find this in a Dropbox public URL: "
75
+ puts "dl.dropboxusercontent.com/u/YOUR_ID/foobar.zip)"
76
+ end
77
+ end
@@ -0,0 +1,3 @@
1
+ class Public
2
+ VERSION = "0.0.4"
3
+ end
data/public.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'public/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "public"
8
+ spec.version = Public::VERSION
9
+ spec.authors = ["Kristian Freeman"]
10
+ spec.email = ["kristian@kristianfreeman.com"]
11
+ spec.description = %q{Dropbox public files made easy}
12
+ spec.summary = %q{Command-line tool for copying a file to your public Dropbox folder and then adding it to your clipboard}
13
+ spec.homepage = "https://github.com/imkmf/public"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables << 'public'
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+
24
+ spec.add_dependency "clipboard"
25
+ end
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: public
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.4
5
+ platform: ruby
6
+ authors:
7
+ - Kristian Freeman
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-07-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: clipboard
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Dropbox public files made easy
56
+ email:
57
+ - kristian@kristianfreeman.com
58
+ executables:
59
+ - public
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - .gitignore
64
+ - Gemfile
65
+ - LICENSE.txt
66
+ - README.md
67
+ - Rakefile
68
+ - bin/public
69
+ - lib/.public_gem
70
+ - lib/public.rb
71
+ - lib/public/version.rb
72
+ - public.gemspec
73
+ homepage: https://github.com/imkmf/public
74
+ licenses:
75
+ - MIT
76
+ metadata: {}
77
+ post_install_message:
78
+ rdoc_options: []
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ requirements: []
92
+ rubyforge_project:
93
+ rubygems_version: 2.0.3
94
+ signing_key:
95
+ specification_version: 4
96
+ summary: Command-line tool for copying a file to your public Dropbox folder and then
97
+ adding it to your clipboard
98
+ test_files: []