Hoodow-pickhost-cli 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +8 -0
- data/Manifest.txt +8 -0
- data/README.txt +47 -0
- data/Rakefile +15 -0
- data/bin/pickhost +58 -0
- data/lib/pickhost_cli.rb +3 -0
- data/test/test_pickhost_cli.rb +8 -0
- metadata +82 -0
data/History.txt
ADDED
data/Manifest.txt
ADDED
data/README.txt
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
= pickhost_cli
|
2
|
+
|
3
|
+
* http://github.com/Hoodow/pickhost-cli
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
Command line uploader for pickhost.eu
|
8
|
+
|
9
|
+
== SYNOPSIS:
|
10
|
+
|
11
|
+
pickhost filename
|
12
|
+
|
13
|
+
for authentication create a ~/pickhost-cli.yml:
|
14
|
+
|
15
|
+
user: your pickhost login
|
16
|
+
token: your api token
|
17
|
+
|
18
|
+
your API token be found in your account settings.
|
19
|
+
|
20
|
+
== INSTALL:
|
21
|
+
|
22
|
+
* gem install Hoodow-pickhost-cli
|
23
|
+
|
24
|
+
== LICENSE:
|
25
|
+
|
26
|
+
(The MIT License)
|
27
|
+
|
28
|
+
Copyright (c) 2009 Ole Riesenberg
|
29
|
+
|
30
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
31
|
+
a copy of this software and associated documentation files (the
|
32
|
+
'Software'), to deal in the Software without restriction, including
|
33
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
34
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
35
|
+
permit persons to whom the Software is furnished to do so, subject to
|
36
|
+
the following conditions:
|
37
|
+
|
38
|
+
The above copyright notice and this permission notice shall be
|
39
|
+
included in all copies or substantial portions of the Software.
|
40
|
+
|
41
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
42
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
43
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
44
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
45
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
46
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
47
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'hoe'
|
5
|
+
|
6
|
+
Hoe.spec 'pickhost-cli' do
|
7
|
+
self.developer('Ole Riesenberg', 'or@oleriesenberg.com')
|
8
|
+
self.url = "http://github.com/Hoodow/pickhost-cli"
|
9
|
+
self.description = "Command line uploader for pickhost.eu"
|
10
|
+
self.extra_deps = [
|
11
|
+
['httpclient','>= 2.1.5.2']
|
12
|
+
]
|
13
|
+
end
|
14
|
+
|
15
|
+
# vim: syntax=ruby
|
data/bin/pickhost
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
=begin
|
4
|
+
|
5
|
+
inspired by defunkt's gist ( http://github.com/defunkt/gist )
|
6
|
+
|
7
|
+
USE:
|
8
|
+
|
9
|
+
pickhost <filename>
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'yaml'
|
14
|
+
require 'json'
|
15
|
+
require 'httpclient'
|
16
|
+
|
17
|
+
module Pickhost
|
18
|
+
extend self
|
19
|
+
|
20
|
+
def parse(input)
|
21
|
+
return help if input == '-h' || input.nil? || input[/help/]
|
22
|
+
upload([Dir.pwd, input].join('/'))
|
23
|
+
end
|
24
|
+
|
25
|
+
def upload(file)
|
26
|
+
url = URI.parse('http://pickhost.eu/api/upload')
|
27
|
+
response = JSON.parse( HTTPClient.post(url, { :file => File.new(file) }.merge(auth)).body.content )
|
28
|
+
copy response["image"]["public_view_url"]
|
29
|
+
end
|
30
|
+
|
31
|
+
def help
|
32
|
+
"USE:\n " + File.read(__FILE__).match(/USE:(.+?)=end/m)[1].strip
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
# stolen from defunkt's gist ( http://github.com/defunkt/gist )
|
37
|
+
def copy(content)
|
38
|
+
case RUBY_PLATFORM
|
39
|
+
when /darwin/
|
40
|
+
return content if `which pbcopy`.strip == ''
|
41
|
+
IO.popen('pbcopy', 'r+') { |clip| clip.puts content }
|
42
|
+
when /linux/
|
43
|
+
return content if `which xclip 2> /dev/null`.strip == ''
|
44
|
+
IO.popen('xclip', 'r+') { |clip| clip.puts content }
|
45
|
+
end
|
46
|
+
|
47
|
+
content
|
48
|
+
end
|
49
|
+
|
50
|
+
def auth
|
51
|
+
path = File.expand_path("~#{ENV['USER']}/.pickhost-cli.yml")
|
52
|
+
hsh = File.exist?(path) ? YAML.load_file(path) : {}
|
53
|
+
|
54
|
+
hsh
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
puts Pickhost.parse(ARGV.first)
|
data/lib/pickhost_cli.rb
ADDED
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: Hoodow-pickhost-cli
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ole Riesenberg
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-07-24 00:00:00 -07:00
|
13
|
+
default_executable: pickhost
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: httpclient
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 2.1.5.2
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: hoe
|
27
|
+
type: :development
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.3.2
|
34
|
+
version:
|
35
|
+
description: Command line uploader for pickhost.eu
|
36
|
+
email:
|
37
|
+
- or@oleriesenberg.com
|
38
|
+
executables:
|
39
|
+
- pickhost
|
40
|
+
extensions: []
|
41
|
+
|
42
|
+
extra_rdoc_files:
|
43
|
+
- History.txt
|
44
|
+
- Manifest.txt
|
45
|
+
- README.txt
|
46
|
+
files:
|
47
|
+
- History.txt
|
48
|
+
- Manifest.txt
|
49
|
+
- README.txt
|
50
|
+
- Rakefile
|
51
|
+
- bin/pickhost
|
52
|
+
- lib/pickhost_cli.rb
|
53
|
+
- test/test_pickhost_cli.rb
|
54
|
+
has_rdoc: true
|
55
|
+
homepage: http://github.com/Hoodow/pickhost-cli
|
56
|
+
post_install_message:
|
57
|
+
rdoc_options:
|
58
|
+
- --main
|
59
|
+
- README.txt
|
60
|
+
require_paths:
|
61
|
+
- lib
|
62
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: "0"
|
67
|
+
version:
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: "0"
|
73
|
+
version:
|
74
|
+
requirements: []
|
75
|
+
|
76
|
+
rubyforge_project: pickhost-cli
|
77
|
+
rubygems_version: 1.2.0
|
78
|
+
signing_key:
|
79
|
+
specification_version: 2
|
80
|
+
summary: Command line uploader for pickhost.eu
|
81
|
+
test_files:
|
82
|
+
- test/test_pickhost_cli.rb
|