photo-cook 1.2.1 → 1.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 54e3edc9dd1cca1b0bb175a4d1015b220f01d12e
4
- data.tar.gz: 83bd26d3887b920c1a289d92cc4a274bada08c8b
3
+ metadata.gz: 654d5fd2b8fe7bd8b296817062dc007a661aca94
4
+ data.tar.gz: 4522e68c06b3955db4b81e08beed6bdfb3131e7b
5
5
  SHA512:
6
- metadata.gz: fc6465991aac047ceb19817f305ade9d39949e6aa737b7fa82419b6bed5a3c5203907c29516a852472247155371112eefd823082a9d701315bf72158edd54059
7
- data.tar.gz: a58e5f69881238958e46fd6b8379cbc49de2d67c94b417b3bccb45464558693660941d452ea2023515734acd373b5dd1146745d0f52d634685229dd9061b20e4
6
+ metadata.gz: aa5c419b8b1c9dec864a590deaf2d494c0cabc508241d9a740d8261d57a2538fa86e5628301c032a928bd1f58ed4900cc959e8c10db6f2dcba739c07ce245503
7
+ data.tar.gz: 84912264a46fb54cadcedfd6dc8c66979cc67021dbc7c9e1684f74ea8a5cf7f2061ac9231c8891492d6e042770065e5f64f2315566c1825ec966d21ac0bbbca6
@@ -13,10 +13,10 @@ module PhotoCook
13
13
  x
14
14
  end
15
15
 
16
- def check!(x)
16
+ def check!(x, ensure_in_bounds = true)
17
17
  x = typecast(x)
18
18
  raise Invalid, x if !x.kind_of?(Integer) && (x.nan? || x.infinite?)
19
- raise OutOfBounds, x unless in_bounds?(x)
19
+ raise OutOfBounds, x if ensure_in_bounds && !in_bounds?(x)
20
20
  true
21
21
  end
22
22
 
@@ -54,3 +54,15 @@ module PhotoCook
54
54
  end
55
55
  end
56
56
  end
57
+
58
+ class Float
59
+ def round_pixels
60
+ PhotoCook::Pixels.round(self)
61
+ end
62
+ end
63
+
64
+ class Fixnum
65
+ def round_pixels
66
+ self
67
+ end
68
+ end
@@ -32,7 +32,7 @@ module PhotoCook
32
32
  #
33
33
  # NOTE: This method will perform validation
34
34
  def uri(uri, width, height, mode, options = {})
35
- Assemble.assemble_resize_uri(uri, *parse_options(width, height, mode, options))
35
+ Assemble.assemble_resize_uri(uri, *parse_options(width, height, mode, options, false))
36
36
  end
37
37
 
38
38
  # Inverse of PhotoCook#resize (see ^):
@@ -79,13 +79,13 @@ module PhotoCook
79
79
  end
80
80
  end
81
81
 
82
- def parse_options(width, height, mode, options)
82
+ def parse_options(width, height, mode, options, check_pixels_in_bounds = true)
83
83
  multiplier = options.fetch(:multiplier, self.multiplier).to_f
84
84
  mode = Mode.parse!(mode)
85
85
  width = Pixels.round(Pixels.parse(width) * multiplier)
86
86
  height = Pixels.round(Pixels.parse(height) * multiplier)
87
- Pixels.check!(width)
88
- Pixels.check!(height)
87
+ Pixels.check!(width, check_pixels_in_bounds)
88
+ Pixels.check!(height, check_pixels_in_bounds)
89
89
  [width, height, mode]
90
90
  end
91
91
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module PhotoCook
3
- VERSION = '1.2.1'
3
+ VERSION = '1.2.3'
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: photo-cook
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yaroslav Konoplov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-19 00:00:00.000000000 Z
11
+ date: 2016-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack