thumb_fu 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG ADDED
@@ -0,0 +1,2 @@
1
+ v0.1.1. fix thumb
2
+ v0.1.0. first release
data/LICENSE ADDED
File without changes
data/Manifest ADDED
@@ -0,0 +1,7 @@
1
+ CHANGELOG
2
+ LICENSE
3
+ Manifest
4
+ README
5
+ Rakefile
6
+ images/not_ready.jpg
7
+ lib/thumb_fu.rb
data/README ADDED
File without changes
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'echoe'
4
+ Echoe.new('thumb_fu', '0.1.1') do |p|
5
+ p.description = "Generate a page thumbnail using www.bitpixels.com"
6
+ p.url = "http://github.com/23ninja/thumb_fu"
7
+ p.author = "Iskander HAziev"
8
+ p.email = "gvalmon@gmail.com"
9
+ p.ignore_pattern = ["tmp/*", "script/*"]
10
+ p.development_dependencies = []
11
+ end
Binary file
data/lib/thumb_fu.rb ADDED
@@ -0,0 +1,54 @@
1
+ require 'open-uri'
2
+ require 'digest/md5'
3
+ module ThumbFu
4
+ class Thumb
5
+ attr_accessor :url, :api_key, :width
6
+
7
+ def initialize(api_key, url, options = {})
8
+ @api_key = api_key
9
+ @url = url
10
+ @width = options[:width] || 200
11
+ @image = nil
12
+ end
13
+
14
+ def url
15
+ "http://www.bitpixels.com/getthumbnail?code=#{@api_key}8&url=#{@url}&size=#{@width}"
16
+ end
17
+
18
+ def image
19
+ generate unless generated?
20
+ @image
21
+ end
22
+
23
+ def save(path)
24
+ return false unless ready?
25
+ open(path, 'wb') do |file|
26
+ file << image
27
+ end
28
+ end
29
+
30
+ def ready?
31
+ image_hashsum != not_ready_hashsum
32
+ end
33
+
34
+ protected
35
+ def generate
36
+ @image = open(url).read
37
+ rescue
38
+ false
39
+ end
40
+
41
+ def generated?
42
+ !@image.nil?
43
+ end
44
+
45
+ def image_hashsum
46
+ Digest::MD5.hexdigest(image)
47
+ end
48
+
49
+ def not_ready_hashsum
50
+ image_path = File.join(File.dirname(__FILE__), '..', 'images', 'not_ready.jpg')
51
+ Digest::MD5.hexdigest(open(image_path).read)
52
+ end
53
+ end
54
+ end
data/thumb_fu.gemspec ADDED
@@ -0,0 +1,29 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{thumb_fu}
5
+ s.version = "0.1.1"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
+ s.authors = [%q{Iskander HAziev}]
9
+ s.date = %q{2011-06-23}
10
+ s.description = %q{Generate a page thumbnail using www.bitpixels.com}
11
+ s.email = %q{gvalmon@gmail.com}
12
+ s.extra_rdoc_files = [%q{CHANGELOG}, %q{LICENSE}, %q{README}, %q{lib/thumb_fu.rb}]
13
+ s.files = [%q{CHANGELOG}, %q{LICENSE}, %q{Manifest}, %q{README}, %q{Rakefile}, %q{images/not_ready.jpg}, %q{lib/thumb_fu.rb}, %q{thumb_fu.gemspec}]
14
+ s.homepage = %q{http://github.com/23ninja/thumb_fu}
15
+ s.rdoc_options = [%q{--line-numbers}, %q{--inline-source}, %q{--title}, %q{Thumb_fu}, %q{--main}, %q{README}]
16
+ s.require_paths = [%q{lib}]
17
+ s.rubyforge_project = %q{thumb_fu}
18
+ s.rubygems_version = %q{1.8.5}
19
+ s.summary = %q{Generate a page thumbnail using www.bitpixels.com}
20
+
21
+ if s.respond_to? :specification_version then
22
+ s.specification_version = 3
23
+
24
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
25
+ else
26
+ end
27
+ else
28
+ end
29
+ end
metadata ADDED
@@ -0,0 +1,69 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: thumb_fu
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.1.1
6
+ platform: ruby
7
+ authors:
8
+ - Iskander HAziev
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-06-23 00:00:00 Z
14
+ dependencies: []
15
+
16
+ description: Generate a page thumbnail using www.bitpixels.com
17
+ email: gvalmon@gmail.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - CHANGELOG
24
+ - LICENSE
25
+ - README
26
+ - lib/thumb_fu.rb
27
+ files:
28
+ - CHANGELOG
29
+ - LICENSE
30
+ - Manifest
31
+ - README
32
+ - Rakefile
33
+ - images/not_ready.jpg
34
+ - lib/thumb_fu.rb
35
+ - thumb_fu.gemspec
36
+ homepage: http://github.com/23ninja/thumb_fu
37
+ licenses: []
38
+
39
+ post_install_message:
40
+ rdoc_options:
41
+ - --line-numbers
42
+ - --inline-source
43
+ - --title
44
+ - Thumb_fu
45
+ - --main
46
+ - README
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: "0"
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: "1.2"
61
+ requirements: []
62
+
63
+ rubyforge_project: thumb_fu
64
+ rubygems_version: 1.8.5
65
+ signing_key:
66
+ specification_version: 3
67
+ summary: Generate a page thumbnail using www.bitpixels.com
68
+ test_files: []
69
+