ochibako_share 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 00d3f20de71b93a2711b59a7b52fce557fe7e847
4
+ data.tar.gz: f6a34a9aebf4b099f7aa8cbd5fc439df7a5fa602
5
+ SHA512:
6
+ metadata.gz: 8b40c0ae3afde38ee3135dad24a0380258c815c5d52da24e224145eb465c4eba42e24e16be654ea115e5f606a04cac6002a0ddd6151f63c6b9013a77781d905c
7
+ data.tar.gz: e88e1128883d0f7f88aca389a9eb2f94bc25d23fa82a5b7fb9b19db3109aa99266d8a384c9076979fc6cfae712ae7ca6f3024b668e292987c0095348f31324f5
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/ruby
2
+ # usage: ochibako-share <files-to-upload>
3
+ # This will upload your file into the App folder
4
+ require 'dropbox_sdk'
5
+ require 'net/http'
6
+ require 'uri'
7
+
8
+ def follow_url(url, limit = 8)
9
+ raise RuntimeError, "Too many HTTP redirects" if limit == 0
10
+
11
+ res = Net::HTTP.get_response(URI.parse(url))
12
+ if Net::HTTPRedirection === res
13
+ return follow_url(res['location'], limit - 1)
14
+ else
15
+ return url
16
+ end
17
+ end
18
+
19
+ def db_download_url(url)
20
+ url.sub(/\?dl=0\z/, '?dl=1')
21
+ end
22
+
23
+ access_token_file = File.expand_path('~/.ochibako-share-auth')
24
+ load access_token_file
25
+
26
+ client = DropboxClient.new(ACCESS_TOKEN)
27
+
28
+ $stderr.puts "Uploading files to DropBox as #{client.account_info['email']}"
29
+
30
+ ARGV.each do |src|
31
+ $stderr.print "#{src} -> "
32
+ dst = File.basename(src)
33
+ result = client.put_file(dst, File.read(src))
34
+ shares = client.shares(dst)
35
+ $stderr.puts "\n" + db_download_url(follow_url(shares['url']))
36
+ end
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/ruby
2
+ # Run this file to authenticate this application on your Dropbox account
3
+ # https://www.dropbox.com/developers/core/start/ruby
4
+ require 'dropbox_sdk'
5
+
6
+ app_key_file = File.expand_path('~/.ochibako-share-app')
7
+ access_token_file = File.expand_path('~/.ochibako-share-auth')
8
+
9
+ begin
10
+ load app_key_file
11
+ rescue LoadError => err
12
+ $stderr.puts "Create #{app_key_file} following README.md:\n#{err.message}"
13
+ exit 1
14
+ end
15
+
16
+ flow = DropboxOAuth2FlowNoRedirect.new(APP_KEY, APP_SECRET)
17
+ authorize_url = flow.start()
18
+ $stderr.puts 'Go to the following URL, Click "Allow", and Copy the authorization code.'
19
+ $stderr.puts authorize_url
20
+ $stderr.print 'Authorization code: '
21
+ code = gets.strip
22
+
23
+ begin
24
+ access_token, user_id = flow.finish(code)
25
+ rescue DropboxError => err
26
+ $stderr.puts "Invalid authorization code: #{code.inspect}"
27
+ exit 1
28
+ end
29
+
30
+ File.open(File.expand_path(access_token_file), "w", 0600) do |f|
31
+ f.puts "#user_id: #{user_id}"
32
+ f.puts "ACCESS_TOKEN = #{access_token.dump}"
33
+ end
34
+
35
+ $stderr.puts "Access token is stored in: #{access_token_file}"
metadata ADDED
@@ -0,0 +1,62 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ochibako_share
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - zunda
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-03-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: dropbox-sdk
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: A Ruby CLI client to upload files to your Dropbox and obtain URL to share
28
+ them.
29
+ email: zundan@gmail.com
30
+ executables:
31
+ - ochibako-share
32
+ - ochibako-share-auth
33
+ extensions: []
34
+ extra_rdoc_files: []
35
+ files:
36
+ - bin/ochibako-share
37
+ - bin/ochibako-share-auth
38
+ homepage: https://github.com/zunda/ochibako-share#readme
39
+ licenses:
40
+ - MIT
41
+ metadata: {}
42
+ post_install_message:
43
+ rdoc_options: []
44
+ require_paths:
45
+ - lib
46
+ required_ruby_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - '>='
49
+ - !ruby/object:Gem::Version
50
+ version: '0'
51
+ required_rubygems_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ requirements: []
57
+ rubyforge_project:
58
+ rubygems_version: 2.0.14
59
+ signing_key:
60
+ specification_version: 4
61
+ summary: A CLI client for uploading and sharing files
62
+ test_files: []