gyazo 0.3.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of gyazo might be problematic. Click here for more details.

Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/bin/gyazo +11 -3
  3. data/lib/gyazo.rb +18 -9
  4. metadata +13 -41
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA512:
3
+ metadata.gz: f99b4949768b5ba9f29cf39b5860190f97cbd47f383e5bba46005ee1c44a0682b2ed3d4464171127b1561264029aeb7d40b90021eaf54a449239f4c9031a6d9b
4
+ data.tar.gz: dfa38df9ab4c430e5b43801aeea9cc955d623bfa7e96563814bf6378266922cf7376bc0d531190c377bd16b0b2eeb772cff6484958ddfdbe9f6fa941860de8c3
5
+ SHA1:
6
+ metadata.gz: cf46c92ca6507f5474fb7ee25a0df20047638df5
7
+ data.tar.gz: 3bc1210341afed02596e5d2ced915296124cecd5
data/bin/gyazo CHANGED
@@ -1,16 +1,24 @@
1
1
  #!/usr/bin/env ruby
2
+ $:.unshift File.expand_path '../lib', File.dirname(__FILE__)
3
+
2
4
  require 'rubygems'
3
5
  require 'gyazo'
4
6
 
5
- if ARGV.empty?
7
+ raw = ARGV.include? "-raw"
8
+ upload_files = ARGV.reject{|arg| arg =~ /^\-+raw$/ }
9
+
10
+ if upload_files.empty?
6
11
  STDERR.puts "gyazo [file1, file2 ...]"
12
+ STDERR.puts "gyazo -raw [file1, file2 ...] # raw upload"
7
13
  exit 1
8
14
  end
9
15
 
10
16
  g = Gyazo.new
11
- ARGV.each do |file|
17
+
18
+
19
+ upload_files.each do |file|
12
20
  next unless File.exists? file
13
- url = g.upload file
21
+ url = g.upload file, :raw => raw
14
22
  puts url
15
23
  system "open #{url}"
16
24
  sleep 1
@@ -6,7 +6,7 @@ require 'net/http'
6
6
  require 'json'
7
7
 
8
8
  class Gyazo
9
- VERSION = '0.3.1'
9
+ VERSION = '0.4.2'
10
10
 
11
11
  def initialize(app = '/Applications/Gyazo.app',userid=nil)
12
12
  @user = IO.popen("whoami", "r+").gets.chomp
@@ -51,13 +51,22 @@ class Gyazo
51
51
  JSON.parse(res.read_body)['images']
52
52
  end
53
53
 
54
- def upload(imagefile,time=nil)
55
- tmpfile = "/tmp/image_upload#{$$}.png"
56
- if imagefile && File.exist?(imagefile) then
57
- system "sips -s format png \"#{imagefile}\" --out \"#{tmpfile}\" > /dev/null"
54
+ DEFAULT_UPLOAD_OPTS = {:time => nil, :raw => false}
55
+ def upload(imagefile, opts)
56
+ DEFAULT_UPLOAD_OPTS.each do |k,v|
57
+ opts[k] = v unless opts.include? k
58
+ end
59
+
60
+ if opts[:raw] then
61
+ imagedata = File.read(imagefile)
62
+ else
63
+ tmpfile = "/tmp/image_upload#{$$}.png"
64
+ if imagefile && File.exist?(imagefile) then
65
+ system "sips -s format png \"#{imagefile}\" --out \"#{tmpfile}\" > /dev/null"
66
+ end
67
+ imagedata = File.read(tmpfile)
68
+ File.delete(tmpfile)
58
69
  end
59
- imagedata = File.read(tmpfile)
60
- File.delete(tmpfile)
61
70
 
62
71
  boundary = '----BOUNDARYBOUNDARY----'
63
72
  @cgi = '/upload.cgi'
@@ -74,8 +83,8 @@ content-disposition: form-data; name="imagedata"; filename="gyazo.com"\r
74
83
  --#{boundary}--\r
75
84
  EOF
76
85
 
77
- if time && time.class == Time then
78
- @timestr = time.gmtime.strftime("%Y-%m-%d %H:%M:%S")
86
+ if opts[:time].kind_of? Time then
87
+ @timestr = opts[:time].gmtime.strftime("%Y-%m-%d %H:%M:%S")
79
88
  s = <<EOF
80
89
  --#{boundary}\r
81
90
  content-disposition: form-data; name="date"\r
metadata CHANGED
@@ -1,13 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gyazo
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
5
- prerelease:
6
- segments:
7
- - 0
8
- - 3
9
- - 1
10
- version: 0.3.1
4
+ version: 0.4.2
11
5
  platform: ruby
12
6
  authors:
13
7
  - Toshiyuki Masui
@@ -15,36 +9,25 @@ autorequire:
15
9
  bindir: bin
16
10
  cert_chain: []
17
11
 
18
- date: 2013-02-28 00:00:00 Z
12
+ date: 2013-12-18 00:00:00 Z
19
13
  dependencies:
20
14
  - !ruby/object:Gem::Dependency
21
15
  name: rdoc
22
16
  prerelease: false
23
17
  requirement: &id001 !ruby/object:Gem::Requirement
24
- none: false
25
18
  requirements:
26
19
  - - ~>
27
20
  - !ruby/object:Gem::Version
28
- hash: 19
29
- segments:
30
- - 3
31
- - 10
32
- version: "3.10"
21
+ version: "4.0"
33
22
  type: :development
34
23
  version_requirements: *id001
35
24
  - !ruby/object:Gem::Dependency
36
25
  name: newgem
37
26
  prerelease: false
38
27
  requirement: &id002 !ruby/object:Gem::Requirement
39
- none: false
40
28
  requirements:
41
29
  - - ">="
42
30
  - !ruby/object:Gem::Version
43
- hash: 5
44
- segments:
45
- - 1
46
- - 5
47
- - 3
48
31
  version: 1.5.3
49
32
  type: :development
50
33
  version_requirements: *id002
@@ -52,15 +35,10 @@ dependencies:
52
35
  name: hoe
53
36
  prerelease: false
54
37
  requirement: &id003 !ruby/object:Gem::Requirement
55
- none: false
56
38
  requirements:
57
39
  - - ~>
58
40
  - !ruby/object:Gem::Version
59
- hash: 27
60
- segments:
61
- - 2
62
- - 12
63
- version: "2.12"
41
+ version: "3.7"
64
42
  type: :development
65
43
  version_requirements: *id003
66
44
  description: "* Upload an image to Gyazo.com"
@@ -74,6 +52,7 @@ extra_rdoc_files:
74
52
  - History.txt
75
53
  - Manifest.txt
76
54
  - PostInstall.txt
55
+ - README.rdoc
77
56
  files:
78
57
  - History.txt
79
58
  - Manifest.txt
@@ -89,7 +68,9 @@ files:
89
68
  - bin/gyazo
90
69
  - .gemtest
91
70
  homepage: http://github.com/masui/gyazo-ruby
92
- licenses: []
71
+ licenses:
72
+ - MIT
73
+ metadata: {}
93
74
 
94
75
  post_install_message: PostInstall.txt
95
76
  rdoc_options:
@@ -98,29 +79,20 @@ rdoc_options:
98
79
  require_paths:
99
80
  - lib
100
81
  required_ruby_version: !ruby/object:Gem::Requirement
101
- none: false
102
82
  requirements:
103
- - - ">="
83
+ - &id004
84
+ - ">="
104
85
  - !ruby/object:Gem::Version
105
- hash: 3
106
- segments:
107
- - 0
108
86
  version: "0"
109
87
  required_rubygems_version: !ruby/object:Gem::Requirement
110
- none: false
111
88
  requirements:
112
- - - ">="
113
- - !ruby/object:Gem::Version
114
- hash: 3
115
- segments:
116
- - 0
117
- version: "0"
89
+ - *id004
118
90
  requirements: []
119
91
 
120
92
  rubyforge_project: gyazo
121
- rubygems_version: 1.8.23
93
+ rubygems_version: 2.1.11
122
94
  signing_key:
123
- specification_version: 3
95
+ specification_version: 4
124
96
  summary: "* Upload an image to Gyazo.com"
125
97
  test_files:
126
98
  - test/test_gyazo.rb