Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Don't use Factory in the name. It's tacky.

  • Loading branch information...
commit 233fcb90b78a1c2151ff5e58e209d5d7ba6310f6 1 parent 8338024
@jyurek jyurek authored
View
6 lib/paperclip/geometry.rb
@@ -2,7 +2,7 @@ module Paperclip
# Defines the geometry of an image.
class Geometry
- attr_accessor :height, :width, :modifier, :orientation
+ attr_accessor :height, :width, :modifier
EXIF_ROTATED_ORIENTATION_VALUES = [5, 6, 7, 8]
@@ -23,14 +23,14 @@ def initialize(width = nil, height = nil, modifier = nil)
# Extracts the Geometry from a file (or path to a file)
def self.from_file(file)
- GeometryDetectorFactory.new(file).make
+ GeometryDetector.new(file).make
end
# Extracts the Geometry from a "WxH,O" string
# Where W is the width, H is the height,
# and O is the EXIF orientation
def self.parse(string)
- GeometryParserFactory.new(string).make
+ GeometryParser.new(string).make
end
# Swaps the height and width if necessary
View
4 lib/paperclip/geometry_detector_factory.rb
@@ -1,12 +1,12 @@
module Paperclip
- class GeometryDetectorFactory
+ class GeometryDetector
def initialize(file)
@file = file
raise_if_blank_file
end
def make
- GeometryParserFactory.new(geometry_string.strip).make ||
+ GeometryParser.new(geometry_string.strip).make ||
raise(Errors::NotIdentifiedByImageMagickError.new)
end
View
2  lib/paperclip/geometry_parser_factory.rb
@@ -1,5 +1,5 @@
module Paperclip
- class GeometryParserFactory
+ class GeometryParser
FORMAT = /\b(\d*)x?(\d*)\b(?:,(\d?))?([\>\<\#\@\%^!])?/i
def initialize(string)
@string = string
View
10 test/geometry_detector_factory_test.rb
@@ -1,10 +1,10 @@
require './test/helper'
-class GeometryDetectorFactoryTest < Test::Unit::TestCase
+class GeometryDetectorTest < Test::Unit::TestCase
should 'identify an image and extract its dimensions' do
- Paperclip::GeometryParserFactory.stubs(:new).with("434x66,").returns(stub(:make => :correct))
+ Paperclip::GeometryParser.stubs(:new).with("434x66,").returns(stub(:make => :correct))
file = fixture_file("5k.png")
- factory = Paperclip::GeometryDetectorFactory.new(file)
+ factory = Paperclip::GeometryDetector.new(file)
output = factory.make
@@ -12,9 +12,9 @@ class GeometryDetectorFactoryTest < Test::Unit::TestCase
end
should 'identify an image and extract its dimensions and orientation' do
- Paperclip::GeometryParserFactory.stubs(:new).with("300x200,6").returns(stub(:make => :correct))
+ Paperclip::GeometryParser.stubs(:new).with("300x200,6").returns(stub(:make => :correct))
file = fixture_file("rotated.jpg")
- factory = Paperclip::GeometryDetectorFactory.new(file)
+ factory = Paperclip::GeometryDetector.new(file)
output = factory.make
View
12 test/geometry_parser_factory_test.rb
@@ -1,6 +1,6 @@
require './test/helper'
-class GeometryParserFactoryTest < Test::Unit::TestCase
+class GeometryParserTest < Test::Unit::TestCase
should 'identify an image and extract its dimensions with no orientation' do
Paperclip::Geometry.stubs(:new).with(
:height => '73',
@@ -8,7 +8,7 @@ class GeometryParserFactoryTest < Test::Unit::TestCase
:modifier => nil,
:orientation => nil
).returns(:correct)
- factory = Paperclip::GeometryParserFactory.new("434x73")
+ factory = Paperclip::GeometryParser.new("434x73")
output = factory.make
@@ -22,7 +22,7 @@ class GeometryParserFactoryTest < Test::Unit::TestCase
:modifier => nil,
:orientation => ''
).returns(:correct)
- factory = Paperclip::GeometryParserFactory.new("434x73,")
+ factory = Paperclip::GeometryParser.new("434x73,")
output = factory.make
@@ -36,7 +36,7 @@ class GeometryParserFactoryTest < Test::Unit::TestCase
:modifier => nil,
:orientation => '6'
).returns(:correct)
- factory = Paperclip::GeometryParserFactory.new("300x200,6")
+ factory = Paperclip::GeometryParser.new("300x200,6")
output = factory.make
@@ -50,7 +50,7 @@ class GeometryParserFactoryTest < Test::Unit::TestCase
:modifier => '#',
:orientation => nil
).returns(:correct)
- factory = Paperclip::GeometryParserFactory.new("64x64#")
+ factory = Paperclip::GeometryParser.new("64x64#")
output = factory.make
@@ -64,7 +64,7 @@ class GeometryParserFactoryTest < Test::Unit::TestCase
:modifier => '>',
:orientation => '7'
).returns(:correct)
- factory = Paperclip::GeometryParserFactory.new("100x50,7>")
+ factory = Paperclip::GeometryParser.new("100x50,7>")
output = factory.make
Please sign in to comment.
Something went wrong with that request. Please try again.