tiqav 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -26,6 +26,8 @@ Search Images on Tiqav.com
26
26
  puts img.url
27
27
  puts img.thumbnail
28
28
  puts img.glitch
29
+
30
+ puts Tiqav.feeling_lucky 'ちくわ'
29
31
 
30
32
 
31
33
  == REQUIREMENTS:
data/Rakefile CHANGED
@@ -14,7 +14,8 @@ $hoe = Hoe.spec 'tiqav' do
14
14
  self.developer 'Sho Hashimoto', 'hashimoto@shokai.org'
15
15
  # self.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
16
16
  self.rubyforge_name = self.name # TODO this is default value
17
- self.extra_deps = [['json','>= 1.5.4']]
17
+ self.extra_deps = [['json','>= 1.5.4'],
18
+ ['addressable', '>= 2.2.8']]
18
19
 
19
20
  end
20
21
 
@@ -4,11 +4,12 @@ $:.unshift(File.dirname(__FILE__)) unless
4
4
  require 'net/http'
5
5
  require 'uri'
6
6
  require 'json'
7
+ require 'addressable/uri'
7
8
  require 'tiqav/error'
8
9
  require 'tiqav/image'
9
10
  require 'tiqav/search'
10
11
  require 'tiqav/alpha_num'
11
12
 
12
13
  module Tiqav
13
- VERSION = '0.0.3'
14
+ VERSION = '0.0.4'
14
15
  end
@@ -8,10 +8,10 @@ module Tiqav
8
8
  @id = id
9
9
  @ext = ext
10
10
  @filename = "#{@id}.#{@ext}"
11
- @url = URI.parse "http://img.tiqav.com/#{@filename}"
12
- @permalink = URI.parse "http://tiqav.com/#{@id}"
13
- @thumbnail = URI.parse "http://img.tiqav.com/#{@id}.th.#{ext}"
14
- @glitch = URI.parse "http://img.tiqav.com/#{@id}.glitch"
11
+ @url = Addressable::URI.parse "http://img.tiqav.com/#{@filename}"
12
+ @permalink = Addressable::URI.parse "http://tiqav.com/#{@id}"
13
+ @thumbnail = Addressable::URI.parse "http://img.tiqav.com/#{@id}.th.#{ext}"
14
+ @glitch = Addressable::URI.parse "http://img.tiqav.com/#{@id}.glitch"
15
15
  end
16
16
 
17
17
  def save(fname)
@@ -1,7 +1,7 @@
1
1
 
2
2
  module Tiqav
3
3
  def self.search(word)
4
- uri = URI.parse "http://api.tiqav.com/search.json?q=#{URI.encode word}"
4
+ uri = Addressable::URI.parse "http://api.tiqav.com/search.json?q=#{Addressable::URI.encode word}"
5
5
  res = Net::HTTP.start(uri.host, uri.port).request(Net::HTTP::Get.new uri.request_uri)
6
6
  raise Error, "HTTP Status #{res.code} at #{uri}" unless res.code.to_i == 200
7
7
  JSON.parse(res.body).map{|img|
@@ -17,4 +17,8 @@ module Tiqav
17
17
  end
18
18
  end
19
19
 
20
+ def self.feeling_lucky(word)
21
+ Addressable::URI.parse "http://#{word}.tiqav.com/"
22
+ end
23
+
20
24
  end
@@ -16,3 +16,7 @@ puts img.thumbnail
16
16
  puts img.glitch
17
17
  img.save img.filename
18
18
  puts "saved!! => #{img.filename}"
19
+
20
+ puts Tiqav.feeling_lucky 'ちくわ'
21
+
22
+
@@ -17,22 +17,22 @@ class TestTiqavImage < Test::Unit::TestCase
17
17
  end
18
18
 
19
19
  def test_image_url
20
- assert @img.url.kind_of? URI::HTTP
20
+ assert @img.url.kind_of? Addressable::URI
21
21
  end
22
22
 
23
23
  def test_image_permalink
24
- assert @img.permalink.kind_of? URI::HTTP
24
+ assert @img.permalink.kind_of? Addressable::URI
25
25
  end
26
26
 
27
27
  def test_image_thumbnail
28
- assert @img.thumbnail.kind_of? URI::HTTP
28
+ assert @img.thumbnail.kind_of? Addressable::URI
29
29
  res = Net::HTTP.start(@img.thumbnail.host, @img.thumbnail.port).
30
30
  request(Net::HTTP::Head.new @img.thumbnail.path)
31
31
  assert res.code.to_i == 200
32
32
  end
33
33
 
34
34
  def test_image_glitch
35
- assert @img.glitch.kind_of? URI::HTTP
35
+ assert @img.glitch.kind_of? Addressable::URI
36
36
  res = Net::HTTP.start(@img.glitch.host, @img.glitch.port).
37
37
  request(Net::HTTP::Head.new @img.glitch.path)
38
38
  assert res.code.to_i == 200
@@ -15,7 +15,7 @@ class TestTiqavSearch < Test::Unit::TestCase
15
15
  end
16
16
 
17
17
  def test_feelinkg_lucky
18
- assert Tiqav.feeling_lucky('ちくわ').kind_of? URI::HTTP
18
+ assert Tiqav.feeling_lucky('ちくわ').kind_of? Addressable::URI
19
19
  end
20
20
 
21
21
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tiqav
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 3
10
- version: 0.0.3
9
+ - 4
10
+ version: 0.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Sho Hashimoto
@@ -34,9 +34,25 @@ dependencies:
34
34
  type: :runtime
35
35
  version_requirements: *id001
36
36
  - !ruby/object:Gem::Dependency
37
- name: rdoc
37
+ name: addressable
38
38
  prerelease: false
39
39
  requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ hash: 23
45
+ segments:
46
+ - 2
47
+ - 2
48
+ - 8
49
+ version: 2.2.8
50
+ type: :runtime
51
+ version_requirements: *id002
52
+ - !ruby/object:Gem::Dependency
53
+ name: rdoc
54
+ prerelease: false
55
+ requirement: &id003 !ruby/object:Gem::Requirement
40
56
  none: false
41
57
  requirements:
42
58
  - - ~>
@@ -47,11 +63,11 @@ dependencies:
47
63
  - 10
48
64
  version: "3.10"
49
65
  type: :development
50
- version_requirements: *id002
66
+ version_requirements: *id003
51
67
  - !ruby/object:Gem::Dependency
52
68
  name: newgem
53
69
  prerelease: false
54
- requirement: &id003 !ruby/object:Gem::Requirement
70
+ requirement: &id004 !ruby/object:Gem::Requirement
55
71
  none: false
56
72
  requirements:
57
73
  - - ">="
@@ -63,11 +79,11 @@ dependencies:
63
79
  - 3
64
80
  version: 1.5.3
65
81
  type: :development
66
- version_requirements: *id003
82
+ version_requirements: *id004
67
83
  - !ruby/object:Gem::Dependency
68
84
  name: hoe
69
85
  prerelease: false
70
- requirement: &id004 !ruby/object:Gem::Requirement
86
+ requirement: &id005 !ruby/object:Gem::Requirement
71
87
  none: false
72
88
  requirements:
73
89
  - - ~>
@@ -78,7 +94,7 @@ dependencies:
78
94
  - 15
79
95
  version: "2.15"
80
96
  type: :development
81
- version_requirements: *id004
97
+ version_requirements: *id005
82
98
  description: Search Images on Tiqav.com
83
99
  email:
84
100
  - hashimoto@shokai.org