ruby-imagespec 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/parser/gif.rb +5 -1
- data/lib/parser/jpeg.rb +5 -1
- data/lib/parser/png.rb +5 -1
- data/lib/parser/swf.rb +5 -1
- metadata +44 -62
- data/.gitignore +0 -1
- data/LICENSE +0 -28
- data/Rakefile +0 -41
- data/VERSION +0 -1
- data/ruby-imagespec.gemspec +0 -60
- data/tasks/image_spec_tasks.rake +0 -4
- data/test/fixtures/corrupt.jpg +0 -1
- data/test/fixtures/leaderboard.jpg +0 -0
- data/test/fixtures/leaderboard.swf +0 -0
- data/test/fixtures/skyscraper.gif +0 -0
- data/test/fixtures/skyscraper.png +0 -0
- data/test/image_spec_test.rb +0 -37
data/lib/parser/gif.rb
CHANGED
@@ -7,7 +7,7 @@ class ImageSpec
|
|
7
7
|
|
8
8
|
def self.attributes(stream)
|
9
9
|
width, height = dimensions(stream)
|
10
|
-
{:width => width, :height => height, :content_type => CONTENT_TYPE}
|
10
|
+
{:width => width, :height => height, :content_type => CONTENT_TYPE, :dimensions => [width, height], :file_size => size(stream)}
|
11
11
|
end
|
12
12
|
|
13
13
|
def self.detected?(stream)
|
@@ -20,6 +20,10 @@ class ImageSpec
|
|
20
20
|
stream.read(4).unpack('SS')
|
21
21
|
end
|
22
22
|
|
23
|
+
def self.size(stream)
|
24
|
+
stream.size
|
25
|
+
end
|
26
|
+
|
23
27
|
end
|
24
28
|
end
|
25
29
|
end
|
data/lib/parser/jpeg.rb
CHANGED
@@ -9,7 +9,7 @@ class ImageSpec
|
|
9
9
|
|
10
10
|
def self.attributes(stream)
|
11
11
|
width, height = dimensions(stream)
|
12
|
-
{:width => width, :height => height, :content_type => CONTENT_TYPE}
|
12
|
+
{:width => width, :height => height, :content_type => CONTENT_TYPE, :dimensions => [width, height], :file_size => size(stream)}
|
13
13
|
end
|
14
14
|
|
15
15
|
def self.detected?(stream)
|
@@ -60,6 +60,10 @@ class ImageSpec
|
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
|
+
def self.size(stream)
|
64
|
+
stream.size
|
65
|
+
end
|
66
|
+
|
63
67
|
end
|
64
68
|
end
|
65
69
|
end
|
data/lib/parser/png.rb
CHANGED
@@ -7,7 +7,7 @@ class ImageSpec
|
|
7
7
|
|
8
8
|
def self.attributes(stream)
|
9
9
|
width, height = dimensions(stream)
|
10
|
-
{:width => width, :height => height, :content_type => CONTENT_TYPE}
|
10
|
+
{:width => width, :height => height, :content_type => CONTENT_TYPE, :dimensions => [width, height], :file_size => size(stream)}
|
11
11
|
end
|
12
12
|
|
13
13
|
def self.detected?(stream)
|
@@ -20,6 +20,10 @@ class ImageSpec
|
|
20
20
|
stream.read(8).unpack('NN')
|
21
21
|
end
|
22
22
|
|
23
|
+
def self.size(stream)
|
24
|
+
stream.size
|
25
|
+
end
|
26
|
+
|
23
27
|
end
|
24
28
|
end
|
25
29
|
end
|
data/lib/parser/swf.rb
CHANGED
@@ -9,7 +9,7 @@ class ImageSpec
|
|
9
9
|
|
10
10
|
def self.attributes(stream)
|
11
11
|
width, height = dimensions(stream)
|
12
|
-
{:width => width, :height => height, :content_type => CONTENT_TYPE}
|
12
|
+
{:width => width, :height => height, :content_type => CONTENT_TYPE, :dimensions => [width, height], :file_size => size(stream)}
|
13
13
|
end
|
14
14
|
|
15
15
|
def self.detected?(stream)
|
@@ -69,6 +69,10 @@ class ImageSpec
|
|
69
69
|
return [width, height]
|
70
70
|
end
|
71
71
|
|
72
|
+
def self.size(stream)
|
73
|
+
stream.size
|
74
|
+
end
|
75
|
+
|
72
76
|
end
|
73
77
|
end
|
74
78
|
end
|
metadata
CHANGED
@@ -1,15 +1,10 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-imagespec
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 2
|
9
|
-
- 0
|
10
|
-
version: 0.2.0
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.0
|
5
|
+
prerelease:
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Brandon Anderson
|
14
9
|
- Michael Sheakoski
|
15
10
|
- Mike Boone
|
@@ -17,74 +12,61 @@ authors:
|
|
17
12
|
autorequire:
|
18
13
|
bindir: bin
|
19
14
|
cert_chain: []
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
15
|
+
date: 2012-08-16 00:00:00.000000000 Z
|
16
|
+
dependencies:
|
17
|
+
- !ruby/object:Gem::Dependency
|
18
|
+
name: rake
|
19
|
+
requirement: !ruby/object:Gem::Requirement
|
20
|
+
none: false
|
21
|
+
requirements:
|
22
|
+
- - ! '>='
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: '0'
|
25
|
+
type: :development
|
26
|
+
prerelease: false
|
27
|
+
version_requirements: !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
description:
|
26
34
|
email: dimitrij@blacksquaremedia.com
|
27
35
|
executables: []
|
28
|
-
|
29
36
|
extensions: []
|
30
|
-
|
31
|
-
|
32
|
-
- LICENSE
|
33
|
-
- README
|
34
|
-
files:
|
35
|
-
- .gitignore
|
36
|
-
- LICENSE
|
37
|
+
extra_rdoc_files: []
|
38
|
+
files:
|
37
39
|
- README
|
38
|
-
- Rakefile
|
39
|
-
- VERSION
|
40
40
|
- init.rb
|
41
|
-
- lib/image_spec.rb
|
42
|
-
- lib/parser.rb
|
43
41
|
- lib/parser/gif.rb
|
44
|
-
- lib/parser/jpeg.rb
|
45
42
|
- lib/parser/png.rb
|
46
43
|
- lib/parser/swf.rb
|
47
|
-
-
|
48
|
-
-
|
49
|
-
-
|
50
|
-
- test/fixtures/leaderboard.jpg
|
51
|
-
- test/fixtures/leaderboard.swf
|
52
|
-
- test/fixtures/skyscraper.gif
|
53
|
-
- test/fixtures/skyscraper.png
|
54
|
-
- test/image_spec_test.rb
|
55
|
-
has_rdoc: true
|
44
|
+
- lib/parser/jpeg.rb
|
45
|
+
- lib/image_spec.rb
|
46
|
+
- lib/parser.rb
|
56
47
|
homepage: http://github.com/dim/ruby-imagespec
|
57
48
|
licenses: []
|
58
|
-
|
59
49
|
post_install_message:
|
60
|
-
rdoc_options:
|
61
|
-
|
62
|
-
require_paths:
|
50
|
+
rdoc_options: []
|
51
|
+
require_paths:
|
63
52
|
- lib
|
64
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
53
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
54
|
none: false
|
66
|
-
requirements:
|
67
|
-
- -
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
|
70
|
-
|
71
|
-
- 0
|
72
|
-
version: "0"
|
73
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ! '>='
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: 1.9.1
|
59
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
60
|
none: false
|
75
|
-
requirements:
|
76
|
-
- -
|
77
|
-
- !ruby/object:Gem::Version
|
78
|
-
|
79
|
-
segments:
|
80
|
-
- 0
|
81
|
-
version: "0"
|
61
|
+
requirements:
|
62
|
+
- - ! '>='
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: 1.3.6
|
82
65
|
requirements: []
|
83
|
-
|
84
66
|
rubyforge_project:
|
85
|
-
rubygems_version: 1.
|
67
|
+
rubygems_version: 1.8.24
|
86
68
|
signing_key:
|
87
69
|
specification_version: 3
|
88
70
|
summary: Image/Flash extract width/height dimensions extractor
|
89
|
-
test_files:
|
90
|
-
|
71
|
+
test_files: []
|
72
|
+
has_rdoc:
|
data/.gitignore
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
pkg
|
data/LICENSE
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
# Copyright (c) 2008, Brandon Anderson (anderson.brandon@gmail.com)
|
2
|
-
# All rights reserved.
|
3
|
-
#
|
4
|
-
# Redistribution and use in source and binary forms, with or without modification,
|
5
|
-
# are permitted provided that the following conditions are met:
|
6
|
-
#
|
7
|
-
# Redistributions of source code must retain the above copyright notice,
|
8
|
-
# this list of conditions and the following disclaimer.
|
9
|
-
#
|
10
|
-
# Redistributions in binary form must reproduce the above copyright notice,
|
11
|
-
# this list of conditions and the following disclaimer in the documentation
|
12
|
-
# and/or other materials provided with the distribution.
|
13
|
-
#
|
14
|
-
# Neither the name of the original author nor the names of contributors
|
15
|
-
# may be used to endorse or promote products derived from this software
|
16
|
-
# without specific prior written permission.
|
17
|
-
#
|
18
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
19
|
-
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
20
|
-
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
21
|
-
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
22
|
-
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
23
|
-
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
24
|
-
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
25
|
-
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
26
|
-
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
27
|
-
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
28
|
-
#
|
data/Rakefile
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
require 'rake'
|
2
|
-
require 'rake/testtask'
|
3
|
-
require 'rake/rdoctask'
|
4
|
-
|
5
|
-
desc 'Default: run unit tests.'
|
6
|
-
task :default => :test
|
7
|
-
|
8
|
-
desc 'Test the image_spec plugin.'
|
9
|
-
Rake::TestTask.new(:test) do |t|
|
10
|
-
t.libs << 'lib'
|
11
|
-
t.pattern = 'test/**/*_test.rb'
|
12
|
-
t.verbose = true
|
13
|
-
end
|
14
|
-
|
15
|
-
desc 'Generate documentation for the image_spec plugin.'
|
16
|
-
Rake::RDocTask.new(:rdoc) do |rdoc|
|
17
|
-
rdoc.rdoc_dir = 'rdoc'
|
18
|
-
rdoc.title = 'ImageSpec'
|
19
|
-
rdoc.options << '--line-numbers' << '--inline-source'
|
20
|
-
rdoc.rdoc_files.include('README')
|
21
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
22
|
-
end
|
23
|
-
|
24
|
-
begin
|
25
|
-
require 'jeweler'
|
26
|
-
Jeweler::Tasks.new do |gemspec|
|
27
|
-
gemspec.name = "ruby-imagespec"
|
28
|
-
gemspec.summary = "Image/Flash extract width/height dimensions extractor"
|
29
|
-
gemspec.description = "A lightweight module designed to extract the width/height dimensions of various image types. Also supports SWFs."
|
30
|
-
gemspec.email = "dimitrij@blacksquaremedia.com"
|
31
|
-
gemspec.homepage = "http://github.com/dim/ruby-imagespec"
|
32
|
-
gemspec.authors = [
|
33
|
-
"Brandon Anderson",
|
34
|
-
"Michael Sheakoski",
|
35
|
-
"Mike Boone",
|
36
|
-
"Dimitrij Denissenko"]
|
37
|
-
end
|
38
|
-
Jeweler::GemcutterTasks.new
|
39
|
-
rescue LoadError
|
40
|
-
puts "Jeweler not available. Install it with: gem install jeweler"
|
41
|
-
end
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.2.0
|
data/ruby-imagespec.gemspec
DELETED
@@ -1,60 +0,0 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
-
# -*- encoding: utf-8 -*-
|
5
|
-
|
6
|
-
Gem::Specification.new do |s|
|
7
|
-
s.name = %q{ruby-imagespec}
|
8
|
-
s.version = "0.2.0"
|
9
|
-
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Brandon Anderson", "Michael Sheakoski", "Mike Boone", "Dimitrij Denissenko"]
|
12
|
-
s.date = %q{2010-08-26}
|
13
|
-
s.description = %q{A lightweight module designed to extract the width/height dimensions of various image types. Also supports SWFs.}
|
14
|
-
s.email = %q{dimitrij@blacksquaremedia.com}
|
15
|
-
s.extra_rdoc_files = [
|
16
|
-
"LICENSE",
|
17
|
-
"README"
|
18
|
-
]
|
19
|
-
s.files = [
|
20
|
-
".gitignore",
|
21
|
-
"LICENSE",
|
22
|
-
"README",
|
23
|
-
"Rakefile",
|
24
|
-
"VERSION",
|
25
|
-
"init.rb",
|
26
|
-
"lib/image_spec.rb",
|
27
|
-
"lib/parser.rb",
|
28
|
-
"lib/parser/gif.rb",
|
29
|
-
"lib/parser/jpeg.rb",
|
30
|
-
"lib/parser/png.rb",
|
31
|
-
"lib/parser/swf.rb",
|
32
|
-
"ruby-imagespec.gemspec",
|
33
|
-
"tasks/image_spec_tasks.rake",
|
34
|
-
"test/fixtures/corrupt.jpg",
|
35
|
-
"test/fixtures/leaderboard.jpg",
|
36
|
-
"test/fixtures/leaderboard.swf",
|
37
|
-
"test/fixtures/skyscraper.gif",
|
38
|
-
"test/fixtures/skyscraper.png",
|
39
|
-
"test/image_spec_test.rb"
|
40
|
-
]
|
41
|
-
s.homepage = %q{http://github.com/dim/ruby-imagespec}
|
42
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
43
|
-
s.require_paths = ["lib"]
|
44
|
-
s.rubygems_version = %q{1.3.7}
|
45
|
-
s.summary = %q{Image/Flash extract width/height dimensions extractor}
|
46
|
-
s.test_files = [
|
47
|
-
"test/image_spec_test.rb"
|
48
|
-
]
|
49
|
-
|
50
|
-
if s.respond_to? :specification_version then
|
51
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
52
|
-
s.specification_version = 3
|
53
|
-
|
54
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
55
|
-
else
|
56
|
-
end
|
57
|
-
else
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
data/tasks/image_spec_tasks.rake
DELETED
data/test/fixtures/corrupt.jpg
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
ABCDEFGHIJKLMNOPQRSTUVWXYZ
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/test/image_spec_test.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
$: << File.join(File.dirname(__FILE__),'..', 'lib')
|
2
|
-
|
3
|
-
require 'test/unit'
|
4
|
-
require 'image_spec'
|
5
|
-
|
6
|
-
class ImageSpecTest < Test::Unit::TestCase
|
7
|
-
# Replace this with your real tests.
|
8
|
-
|
9
|
-
def fixture(name)
|
10
|
-
File.open File.expand_path("../fixtures/#{name}", __FILE__), 'rb'
|
11
|
-
end
|
12
|
-
|
13
|
-
def assert_spec(values, spec)
|
14
|
-
assert_equal values, [spec.width, spec.height, spec.content_type]
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_identifying_jpeg
|
18
|
-
assert_spec [728, 90, "image/jpeg"], ImageSpec.new(fixture('leaderboard.jpg'))
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_identifying_gif
|
22
|
-
assert_spec [120, 600, "image/gif"], ImageSpec.new(fixture('skyscraper.gif'))
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_identifying_png
|
26
|
-
assert_spec [120, 600, "image/png"], ImageSpec.new(fixture('skyscraper.png'))
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_identifying_swf
|
30
|
-
assert_spec [728, 90, "application/x-shockwave-flash"], ImageSpec.new(fixture('leaderboard.swf'))
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_corrupted_files
|
34
|
-
assert_raises(ImageSpec::Error) { ImageSpec.new(fixture('corrupt.jpg')) }
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|