quilt 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,4 +1,12 @@
1
- == 0.0.1 / 2008-04-12
1
+ 2008-06-08 swdyh <youhei at gmail.com>
2
+
3
+ * 0.0.2 release:
4
+ * added size option
5
+ * added quilt.gemspec
6
+
7
+
8
+ 2008-04-19 swdyh <youhei at gmail.com>
9
+
10
+ * 0.0.1 release:
2
11
 
3
- * initial release
4
12
 
File without changes
data/Rakefile CHANGED
@@ -8,6 +8,7 @@ require 'rake/rdoctask'
8
8
  require 'rake/contrib/rubyforgepublisher'
9
9
  require 'rake/contrib/sshpublisher'
10
10
  require 'fileutils'
11
+ require 'date'
11
12
  include FileUtils
12
13
 
13
14
  NAME = "quilt"
@@ -17,7 +18,7 @@ DESCRIPTION = "a library for generating identicon."
17
18
  RUBYFORGE_PROJECT = "quilt"
18
19
  HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
19
20
  BIN_FILES = %w( )
20
- VERS = "0.0.1"
21
+ VERS = "0.0.2"
21
22
 
22
23
  REV = File.read(".svn/entries")[/committed-rev="(d+)"/, 1] rescue nil
23
24
  CLEAN.include ['**/.*.sw?', '*.gem', '.config']
@@ -26,7 +27,7 @@ RDOC_OPTS = [
26
27
  "--charset", "utf-8",
27
28
  "--opname", "index.html",
28
29
  "--line-numbers",
29
- "--main", "README",
30
+ "--main", "README.rdoc",
30
31
  "--inline-source",
31
32
  ]
32
33
 
@@ -44,7 +45,7 @@ spec = Gem::Specification.new do |s|
44
45
  s.version = VERS
45
46
  s.platform = Gem::Platform::RUBY
46
47
  s.has_rdoc = true
47
- s.extra_rdoc_files = ["README", "ChangeLog", "MIT-LICENSE"]
48
+ s.extra_rdoc_files = ["README.rdoc", "ChangeLog", "MIT-LICENSE"]
48
49
  s.rdoc_options += RDOC_OPTS + ['--exclude', '^(examples|extras)/']
49
50
  s.summary = DESCRIPTION
50
51
  s.description = DESCRIPTION
@@ -61,7 +62,7 @@ spec = Gem::Specification.new do |s|
61
62
  #s.add_dependency('activesupport', '>=1.3.1')
62
63
  #s.required_ruby_version = '>= 1.8.2'
63
64
 
64
- s.files = %w(README ChangeLog Rakefile) +
65
+ s.files = %w(README.rdoc ChangeLog Rakefile) +
65
66
  Dir.glob("{bin,doc,test,lib,templates,generator,extras,website,script}/**/*") +
66
67
  Dir.glob("ext/**/*.{h,c,rb}") +
67
68
  Dir.glob("examples/**/*.rb") +
@@ -94,7 +95,7 @@ Rake::RDocTask.new do |rdoc|
94
95
  if ENV['DOC_FILES']
95
96
  rdoc.rdoc_files.include(ENV['DOC_FILES'].split(/,\s*/))
96
97
  else
97
- rdoc.rdoc_files.include('README', 'ChangeLog')
98
+ rdoc.rdoc_files.include('README.rdoc', 'ChangeLog')
98
99
  rdoc.rdoc_files.include('lib/**/*.rb')
99
100
  rdoc.rdoc_files.include('ext/**/*.c')
100
101
  end
@@ -129,3 +130,9 @@ task :release => [:clean, :package] do |t|
129
130
  puts "Releasing #{NAME} v. #{VERS}"
130
131
  rf.add_release RUBYFORGE_PROJECT, NAME, VERS, *files
131
132
  end
133
+
134
+ desc 'Show information about the gem.'
135
+ task :debug_gem do
136
+ puts spec.to_ruby
137
+ end
138
+
@@ -1,3 +1,4 @@
1
+ # -*- coding: utf-8 -*-
1
2
  require 'rubygems'
2
3
  require 'digest/sha1'
3
4
 
@@ -34,13 +35,16 @@ module Quilt
34
35
  end
35
36
 
36
37
  def write path
37
- # @image.write path
38
38
  open(path, 'w') {|f| f.puts @image.to_blob }
39
39
  end
40
40
 
41
41
  def to_blob
42
42
  @image.to_blob
43
43
  end
44
+
45
+ def resize size
46
+ @image.resize! size, size
47
+ end
44
48
  end
45
49
 
46
50
  class ImageGD
@@ -78,6 +82,13 @@ module Quilt
78
82
  def to_blob
79
83
  @image.pngStr
80
84
  end
85
+
86
+ def resize size
87
+ _image = GD::Image.new size, size
88
+ # FIXME bug
89
+ @image.copyResized _image, 0, 0, 0, 0, size, size, @image.width, @image.height
90
+ @image = _image
91
+ end
81
92
  end
82
93
 
83
94
  class Identicon
@@ -115,13 +126,24 @@ module Quilt
115
126
  @code = Identicon.calc_code str.to_s
116
127
  end
117
128
  @decode = decode @code
118
- @scale = opt[:scale] || 1
129
+
130
+ if opt[:size]
131
+ @scale = (((opt[:size] / 3) - 1) / (PATCH_SIZE - 1)) + 1
132
+ @resize_to = opt[:size]
133
+ else
134
+ @scale = opt[:scale] || 1
135
+ end
136
+
119
137
  @patch_width = (PATCH_SIZE - 1) * @scale + 1
120
138
  @image = @@image_lib.new @patch_width * 3, @patch_width * 3
121
139
  @back_color = @image.color 255, 255, 255
122
140
  @fore_color = @image.color @decode[:red], @decode[:green], @decode[:blue]
123
141
  @image.transparent @back_color
124
142
  render
143
+
144
+ if @resize_to
145
+ @image.resize @resize_to
146
+ end
125
147
  end
126
148
 
127
149
  def decode code
@@ -70,4 +70,19 @@ class QultTest < Test::Unit::TestCase
70
70
  assert_equal salt, Quilt::Identicon.salt
71
71
  end
72
72
  end
73
+
74
+ def test_size_opt_im
75
+ size = 100
76
+ Quilt::Identicon.image_lib = Quilt::ImageRmagick
77
+ identicon = Quilt::Identicon.new 'foo', :size => size
78
+ assert_equal size, identicon.instance_variable_get(:@image).instance_variable_get(:@image).rows
79
+ assert_equal size, identicon.instance_variable_get(:@image).instance_variable_get(:@image).columns
80
+ end
81
+
82
+ def test_size_opt_gd
83
+ Quilt::Identicon.image_lib = Quilt::ImageGD
84
+ identicon = Quilt::Identicon.new 'foo', :size => size
85
+ assert_equal size, identicon.instance_variable_get(:@image).instance_variable_get(:@image).width
86
+ assert_equal size, identicon.instance_variable_get(:@image).instance_variable_get(:@image).height
87
+ end
73
88
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quilt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - swdyh
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-04-13 00:00:00 +09:00
12
+ date: 2008-06-19 00:00:00 +09:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -20,11 +20,11 @@ executables: []
20
20
  extensions: []
21
21
 
22
22
  extra_rdoc_files:
23
- - README
23
+ - README.rdoc
24
24
  - ChangeLog
25
25
  - MIT-LICENSE
26
26
  files:
27
- - README
27
+ - README.rdoc
28
28
  - ChangeLog
29
29
  - Rakefile
30
30
  - test/quilt_test.rb
@@ -43,7 +43,7 @@ rdoc_options:
43
43
  - index.html
44
44
  - --line-numbers
45
45
  - --main
46
- - README
46
+ - README.rdoc
47
47
  - --inline-source
48
48
  - --exclude
49
49
  - ^(examples|extras)/
@@ -64,7 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
64
64
  requirements: []
65
65
 
66
66
  rubyforge_project: quilt
67
- rubygems_version: 1.0.1
67
+ rubygems_version: 1.1.1
68
68
  signing_key:
69
69
  specification_version: 2
70
70
  summary: a library for generating identicon.