gyazo 0.1.0 → 0.2.0

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.
Files changed (3) hide show
  1. data/lib/gyazo.rb +23 -2
  2. data/test/test_gyazo.rb +15 -14
  3. metadata +4 -4
@@ -3,9 +3,10 @@ $:.unshift(File.dirname(__FILE__)) unless
3
3
  $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
4
4
 
5
5
  require 'net/http'
6
+ require 'json'
6
7
 
7
8
  class Gyazo
8
- VERSION = '0.1.0'
9
+ VERSION = '0.2.0'
9
10
 
10
11
  def initialize(app = '/Applications/Gyazo.app')
11
12
  @user = IO.popen("whoami", "r+").gets.chomp
@@ -18,6 +19,27 @@ class Gyazo
18
19
  elsif File.exist?(@old_idfile) then
19
20
  @id = File.read(@old_idfile).chomp
20
21
  end
22
+ @host = 'gyazo.com'
23
+ end
24
+
25
+ def info(gyazoid)
26
+ gyazoid =~ /[0-9a-f]{32}/
27
+ gyazoid = $&
28
+ cgi = "/api/image/get?image_id=#{gyazoid}"
29
+ header = {}
30
+ res = Net::HTTP.start(@host,80){|http|
31
+ http.get(cgi,header)
32
+ }
33
+ JSON.parse(res.read_body)
34
+ end
35
+
36
+ def list(page,count)
37
+ cgi = "/api/image/list?userkey=#{@id}&page=#{page}&count=#{count}"
38
+ header = {}
39
+ res = Net::HTTP.start(@host,80){|http|
40
+ http.get(cgi,header)
41
+ }
42
+ JSON.parse(res.read_body)['images']
21
43
  end
22
44
 
23
45
  def upload(imagefile,time=nil)
@@ -29,7 +51,6 @@ class Gyazo
29
51
  File.delete(tmpfile)
30
52
 
31
53
  boundary = '----BOUNDARYBOUNDARY----'
32
- @host = 'gyazo.com'
33
54
  @cgi = '/upload.cgi'
34
55
  @ua = 'Gyazo/1.0'
35
56
  data = <<EOF
@@ -1,14 +1,15 @@
1
- require File.dirname(__FILE__) + '/test_helper.rb'
2
-
3
- class TestGyazo < Test::Unit::TestCase
4
-
5
- def setup
6
- end
7
-
8
- def test_upload
9
- imagefile = File.dirname(__FILE__) + '/test.png'
10
- g = Gyazo.new
11
- url = g.upload(imagefile)
12
- assert_equal(url,'http://gyazo.com/a2a2a8154340bd33e9cd5eeea1efd832.png')
13
- end
14
- end
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ class TestGyazo < Test::Unit::TestCase
4
+
5
+ def setup
6
+ end
7
+
8
+ def test_upload
9
+ imagefile = File.dirname(__FILE__) + '/test.png'
10
+ g = Gyazo.new
11
+ url = g.upload(imagefile)
12
+ assert_equal(url,'http://gyazo.com/6bdded98323cba83530daae7fa7881f9')
13
+ # assert_equal(url,'http://gyazo.com/a2a2a8154340bd33e9cd5eeea1efd832')
14
+ end
15
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gyazo
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 1
8
+ - 2
9
9
  - 0
10
- version: 0.1.0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Toshiyuki Masui
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2013-02-01 00:00:00 Z
18
+ date: 2013-02-10 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: rdoc