picgarage 0.0.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.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in picgarage.gemspec
4
+ gemspec
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
data/bin/pgupload ADDED
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'picgarage'
4
+
5
+ image = ARGV[0]
6
+
7
+ picgarage = PicGarage::PicGarage.new
8
+
9
+ short_url = picgarage.upload_image(image)
10
+
11
+ if RUBY_PLATFORM.downcase.include?("darwin")
12
+
13
+ IO.popen('pbcopy', 'r+') do |clipboard|
14
+
15
+ clipboard.puts short_url
16
+
17
+ end
18
+
19
+ end
20
+
21
+ puts short_url
@@ -0,0 +1,3 @@
1
+ module PicGarage
2
+ VERSION = "0.0.1"
3
+ end
data/lib/picgarage.rb ADDED
@@ -0,0 +1,51 @@
1
+ require 'rubygems'
2
+ require 'json'
3
+ require 'curb'
4
+
5
+ module PicGarage
6
+
7
+ class PicGarage
8
+
9
+ def upload_image(image)
10
+
11
+ if File.exists?(image)
12
+
13
+ image_types = ["image/png", "image/x-png", "image/jpeg", "image/pjpeg", "image/gif"]
14
+
15
+ file_options = RUBY_PLATFORM.downcase.include?("darwin") ? "-Ib" : "-ib"
16
+ mime_type = `file #{file_options} #{image.gsub(/ /, "\\ ")}`.split(';').first
17
+
18
+ if image_types.include? mime_type
19
+
20
+ post = Curl::Easy.new("http://www.picgarage.net/uploader.json")
21
+ post.multipart_form_post = true
22
+ post.http_post(Curl::PostField.file("image", image))
23
+
24
+ if post.response_code == 201
25
+
26
+ response = JSON.parse(post.body_str)
27
+ response["image"]["large_url"]
28
+
29
+ else
30
+
31
+ "Bad response from server, please try again."
32
+
33
+ end
34
+
35
+ else
36
+
37
+ "Given image type is not accepted."
38
+
39
+ end
40
+
41
+ else
42
+
43
+ "Given image does not exist."
44
+
45
+ end
46
+
47
+ end
48
+
49
+ end
50
+
51
+ end
data/picgarage.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "picgarage/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "picgarage"
7
+ s.version = PicGarage::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Sean Porter"]
10
+ s.email = ["portertech@gmail.com"]
11
+ s.homepage = "https://github.com/portertech/picgarage"
12
+ s.summary = %q{A rubygem for uploading images to PicGarage.net}
13
+ s.description = %q{A rubygem for uploading images to PicGarage.net}
14
+
15
+ s.rubyforge_project = "picgarage"
16
+
17
+ s.add_dependency("json")
18
+ s.add_dependency("curb")
19
+
20
+ s.files = `git ls-files`.split("\n")
21
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
22
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
23
+ s.require_paths = ["lib"]
24
+ end
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: picgarage
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.1
6
+ platform: ruby
7
+ authors:
8
+ - Sean Porter
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-06-09 00:00:00 +09:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: json
18
+ prerelease: false
19
+ requirement: &id001 !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: "0"
25
+ type: :runtime
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: curb
29
+ prerelease: false
30
+ requirement: &id002 !ruby/object:Gem::Requirement
31
+ none: false
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: "0"
36
+ type: :runtime
37
+ version_requirements: *id002
38
+ description: A rubygem for uploading images to PicGarage.net
39
+ email:
40
+ - portertech@gmail.com
41
+ executables:
42
+ - pgupload
43
+ extensions: []
44
+
45
+ extra_rdoc_files: []
46
+
47
+ files:
48
+ - .gitignore
49
+ - Gemfile
50
+ - Rakefile
51
+ - bin/pgupload
52
+ - lib/picgarage.rb
53
+ - lib/picgarage/version.rb
54
+ - picgarage.gemspec
55
+ has_rdoc: true
56
+ homepage: https://github.com/portertech/picgarage
57
+ licenses: []
58
+
59
+ post_install_message:
60
+ rdoc_options: []
61
+
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: "0"
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: "0"
76
+ requirements: []
77
+
78
+ rubyforge_project: picgarage
79
+ rubygems_version: 1.6.2
80
+ signing_key:
81
+ specification_version: 3
82
+ summary: A rubygem for uploading images to PicGarage.net
83
+ test_files: []
84
+