pickhost-cli 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt ADDED
@@ -0,0 +1,28 @@
1
+ === 0.3.0 / 2009-10-04
2
+
3
+ * try to notify user via kdialog
4
+
5
+ === 0.2.0 / 2009-09-06
6
+
7
+ * include client_key in POST
8
+
9
+ === 0.1.3 / 2009-08-20
10
+
11
+ * moved to jeweler
12
+
13
+ === 0.1.2 / 2009-08-10
14
+
15
+ * return errors
16
+
17
+ === 0.1.1 / 2009-07-25
18
+
19
+ * fixed a bug with absolute paths
20
+
21
+ === 0.1.0 / 2009-07-24
22
+
23
+ * support authentication
24
+
25
+ === 0.0.1 / 2009-07-24
26
+
27
+ * initial release
28
+
data/LICENCE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Ole Riesenberg
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.textile ADDED
@@ -0,0 +1,58 @@
1
+ h1. pickhost_cli
2
+
3
+ * "http://github.com/Hoodow/pickhost-cli":http://github.com/Hoodow/pickhost-cli
4
+
5
+ h2. DESCRIPTION:
6
+
7
+ Command line uploader for "http://pickhost.eu":pickhost.eu
8
+
9
+ h2. SYNOPSIS:
10
+
11
+ <pre><code>
12
+ pickhost filename
13
+ </code></pre>
14
+
15
+ for authentication create a *~/pickhost-cli.yml*:
16
+
17
+ <pre><code>
18
+ user: your pickhost login
19
+ token: your api token
20
+ </code></pre>
21
+
22
+ your API token be found in your account settings.
23
+
24
+ h2. INSTALL:
25
+
26
+ <pre><code>
27
+ gem sources -a http://gems.github.com (you only have to do this once)
28
+ gem install Hoodow-pickhost-cli
29
+ </code></pre>
30
+
31
+ h2. CONTRIBUTORS
32
+
33
+ * Klaus Breyer
34
+
35
+ h2. LICENSE:
36
+
37
+ (The MIT License)
38
+
39
+ Copyright (c) 2009 Ole Riesenberg
40
+
41
+ Permission is hereby granted, free of charge, to any person obtaining
42
+ a copy of this software and associated documentation files (the
43
+ 'Software'), to deal in the Software without restriction, including
44
+ without limitation the rights to use, copy, modify, merge, publish,
45
+ distribute, sublicense, and/or sell copies of the Software, and to
46
+ permit persons to whom the Software is furnished to do so, subject to
47
+ the following conditions:
48
+
49
+ The above copyright notice and this permission notice shall be
50
+ included in all copies or substantial portions of the Software.
51
+
52
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
53
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
54
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
55
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
56
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
57
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
58
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.3.0
data/bin/pickhost ADDED
@@ -0,0 +1,69 @@
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 'pathname'
14
+ require 'yaml'
15
+ require 'json'
16
+ require 'httpclient'
17
+
18
+ module Pickhost
19
+ extend self
20
+
21
+ def parse(input)
22
+ return help if input == '-h' || input.nil? || input[/help/]
23
+ upload(Pathname(input).realpath)
24
+ end
25
+
26
+ def upload(file)
27
+ url = URI.parse('http://pickhost.eu/api/upload')
28
+ response = JSON.parse(
29
+ HTTPClient.post(url, { :client_key => "54c56f1de2678ac4d32aa19fb66fe06c",
30
+ :file => File.new(file) }.merge(auth)).body.content )
31
+ return response["errors"] if response["errors"]
32
+ copy response["image"]["public_view_url"]
33
+ end
34
+
35
+ def help
36
+ "USE:\n " + File.read(__FILE__).match(/USE:(.+?)=end/m)[1].strip
37
+ end
38
+
39
+ private
40
+ # stolen from defunkt's gist ( http://github.com/defunkt/gist )
41
+ def copy(content)
42
+ case RUBY_PLATFORM
43
+ when /darwin/
44
+ return content if `which pbcopy`.strip == ''
45
+ IO.popen('pbcopy', 'r+') { |clip| clip.puts content }
46
+ when /linux/
47
+ notify(content)
48
+ return content if `which xclip 2> /dev/null`.strip == ''
49
+ IO.popen('xclip', 'r+') { |clip| clip.puts content }
50
+ end
51
+
52
+ content
53
+ end
54
+
55
+ def notify(content)
56
+ unless `which kdialog 2> /dev/null`.strip == ''
57
+ `kdialog --passivepopup "Image uploaded to Pic(k)host:\n\n#{content}" 5`
58
+ end
59
+ end
60
+
61
+ def auth
62
+ path = File.expand_path("~#{ENV['USER']}/.pickhost-cli.yml")
63
+ hsh = File.exist?(path) ? YAML.load_file(path) : {}
64
+
65
+ hsh
66
+ end
67
+ end
68
+
69
+ puts Pickhost.parse(ARGV.first)
@@ -0,0 +1,3 @@
1
+ class PickhostCli
2
+ VERSION = '0.1.1'
3
+ end
@@ -0,0 +1,8 @@
1
+ require "test/unit"
2
+ require "pickhost_cli"
3
+
4
+ class TestPickhostCli < Test::Unit::TestCase
5
+ def test_sanity
6
+ flunk "write tests or I will kneecap you"
7
+ end
8
+ end
metadata ADDED
@@ -0,0 +1,69 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pickhost-cli
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.0
5
+ platform: ruby
6
+ authors:
7
+ - Ole Riesenberg
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-10-04 00:00:00 +02: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
+ description:
26
+ email: or@oleriesenberg.com
27
+ executables:
28
+ - pickhost
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - README.textile
33
+ files:
34
+ - History.txt
35
+ - LICENCE
36
+ - VERSION
37
+ - bin/pickhost
38
+ - lib/pickhost_cli.rb
39
+ - README.textile
40
+ has_rdoc: true
41
+ homepage: http://pickhost.eu
42
+ licenses: []
43
+
44
+ post_install_message:
45
+ rdoc_options:
46
+ - --charset=UTF-8
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: "0"
54
+ version:
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: "0"
60
+ version:
61
+ requirements: []
62
+
63
+ rubyforge_project:
64
+ rubygems_version: 1.3.5
65
+ signing_key:
66
+ specification_version: 3
67
+ summary: Command line uploader for pickhost.eu
68
+ test_files:
69
+ - test/test_pickhost_cli.rb