utopia-gallery 2.0.2 → 2.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5be9fa59f72e89a487b5f833b02ff4e9358ebd93
4
- data.tar.gz: 38dcd9b0c8b778f03cc2ca1fc4dd86e0c738b6ad
3
+ metadata.gz: 03fb77bfb663311263c588d8b8f8fe3aaaab4aa0
4
+ data.tar.gz: 502e44584091b100cd4dcda5b11f49001da757b5
5
5
  SHA512:
6
- metadata.gz: 4f58a9a8deeb5bcc0c7083d9e8451ec27601c67654d112122959fa826c8117ff1c876af74eee587cd366139f05af15773d9162b9cba9a32d59edcec215adc842
7
- data.tar.gz: 195cd55dd865423a767673784768271a19941a5884aaff4d376b0dc033eda0c5eaa92285f1d0c8d490caf28cb42c09f0228a8e7a83e432c97c3dbb9ad1317695
6
+ metadata.gz: c991284fd407efa94e5f9013446e6a557837c0612e47656a8647ae39e57e47d42bdf993cd2679f5c7a8e39f399fcae9c0c010df6d440cd4ac2773e195ef00443
7
+ data.tar.gz: 4f33aa3535e26ad29a208154095766354b36c307927cc86537b4d3eb1b25c20a1776c6c36c0f4079b7566f7a2cf3fc7b351302b1bd131832c670907fdfa86a6b
data/.travis.yml CHANGED
@@ -31,7 +31,10 @@ cache:
31
31
  - $HOME/vips
32
32
 
33
33
  before_install:
34
- - source install-vips.sh
34
+ - source install-vips.sh
35
+
36
+ script:
37
+ - bundle exec rake
35
38
 
36
39
  rvm:
37
40
  - 2.2.4
data/README.md CHANGED
@@ -57,6 +57,22 @@ Add `_photo.xnode` such as:
57
57
  </figure>
58
58
  ```
59
59
 
60
+ Or, if you prefer the `<picture>` element:
61
+
62
+ ```html
63
+ <figure class="photo">
64
+ <a href="#{attributes[:src].large}" title="#{attributes[:alt]}">
65
+ <picture>
66
+ <source srcset="#{attributes[:src].small}, #{attributes[:src].medium} 2x"/>
67
+ <img src="#{attributes[:src].small}" alt="#{attributes[:alt]}"/>
68
+ </picture>
69
+ </a>
70
+ <?r if caption = attributes[:alt].caption ?>
71
+ <figcaption>#{caption}</figcaption>
72
+ <?r end ?>
73
+ </figure>
74
+ ```
75
+
60
76
  ### Adding Captions
61
77
 
62
78
  You can add captions and other metadata by adding a `gallery.yaml` file:
@@ -49,6 +49,14 @@ module Utopia
49
49
  @processes.values.collect{|process| output_path_for(process)}
50
50
  end
51
51
 
52
+ def outputs
53
+ return to_enum(:outputs) unless block_given?
54
+
55
+ @processes.values do |process|
56
+ yield process, output_path_for(process)
57
+ end
58
+ end
59
+
52
60
  def output_path_for(process)
53
61
  File.join(@cache_root, process.relative_path(@media))
54
62
  end
@@ -69,6 +69,10 @@ module Utopia
69
69
  @options = options
70
70
  end
71
71
 
72
+ attr :size
73
+ attr :method
74
+ attr :options
75
+
72
76
  def call(cache, locals)
73
77
  output_path = cache.output_path_for(self)
74
78
  media = cache.media
@@ -1,5 +1,5 @@
1
1
  module Utopia
2
2
  module Gallery
3
- VERSION = "2.0.2"
3
+ VERSION = "2.0.3"
4
4
  end
5
5
  end
@@ -3,7 +3,7 @@ RSpec.describe Utopia::Gallery::Cache do
3
3
  let(:pages_root) {File.join(__dir__, 'site/pages')}
4
4
  let(:cache_root) {File.join(__dir__, 'site/public/_gallery')}
5
5
 
6
- before(:each) do
6
+ before(:each) do
7
7
  FileUtils.rm_rf cache_root
8
8
  end
9
9
 
@@ -31,6 +31,25 @@ RSpec.describe Utopia::Gallery::Cache do
31
31
  end
32
32
  end
33
33
 
34
+ it "should preserve aspect ratio" do
35
+ subject.each do |cache|
36
+ cache.update
37
+
38
+ input_image = Vips::Image.new_from_file(cache.input_path)
39
+ input_image.autorot
40
+ input_aspect_ratio = Rational(input_image.width, input_image.height)
41
+
42
+ cache.outputs do |process, output_path|
43
+ next unless process.method == :resize_to_fit
44
+
45
+ output_image = Vips::Image.new_from_file(output_path)
46
+ output_aspect_ratio = Rational(output_image.width, output_image.height)
47
+
48
+ expect(output_aspect_ratio).to be_within(0.01).of(input_aspect_ratio)
49
+ end
50
+ end
51
+ end
52
+
34
53
  it "it should be reentrant" do
35
54
  subject.each(&:update)
36
55
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: utopia-gallery
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-25 00:00:00.000000000 Z
11
+ date: 2017-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: utopia