jekyll-retinamagick 0.0.2 → 0.0.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: 1f059a36c0d5a85e6ea78310cc4d7981cf2a3013
4
- data.tar.gz: 301979a3cf3257a1cc1132a31a234ff1e4b449da
3
+ metadata.gz: 33a537388d726e82dde5fa52b96cc09f8c0589c9
4
+ data.tar.gz: 7aaa267ca13188232d14db7cb3d25eaca81c899d
5
5
  SHA512:
6
- metadata.gz: 15be8a6357ddd63372e12d83599caa02896321b12db0a7a2ecb443a983b009fa1f30dff284851d2103e441fa56aa43c8aa21737bba7918c0d1cd28e8e614c809
7
- data.tar.gz: 8d164bede5fc3a86400ca20c05f821b8460d83aaaf9d6c1ce4a19d3ea265dea341666e942654384f7f0b8f7ad27049cc2310b3164296dfbf3afffc42b420aa24
6
+ metadata.gz: 680185aed2affdef8bb349d24ee1ec1b099b33cfb53b9b269f592d0ebc7181eeb23c7fcb142fb9f9de8b413bd54f9eb4e8adbfa5b9a7cee7cc38e7988f30fbfe
7
+ data.tar.gz: 3f423ddcc8e36cffa5357d5dc68cf06899eda92b2ad73374f2d28e16bc4bbcfc501c9401ad957adcce8b0fe65339ce85074320114464acd3ea866578e3e491f2
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module Retinamagick
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
@@ -18,9 +18,17 @@ module Jekyll
18
18
  @dir = dir
19
19
  @name = name
20
20
  @dst_dir = preset.delete('destination')
21
- @src_dir = preset.delete('source')
21
+ @src = File.join(@base, preset.delete('source'), name)
22
22
  @commands = preset
23
- @retina = retina
23
+ if retina
24
+ filepath, extension = name.match(/(.+)(\.[a-zA-Z]{3,4})/i).captures
25
+ @name = "#{filepath}@2x#{extension}"
26
+ if @commands.has_key?("resize")
27
+ size = @commands["resize"]
28
+ width, height = size.match(/([0-9]+)x([0-9]+)/i).captures
29
+ @commands[:resize] = "#{Integer(width) * 2}x#{Integer(height) * 2}"
30
+ end
31
+ end
24
32
  end
25
33
 
26
34
  # Obtains source file path by substituting the preset's source directory
@@ -28,7 +36,7 @@ module Jekyll
28
36
  #
29
37
  # Returns source file path.
30
38
  def path
31
- File.join(@base, @dir.sub(@dst_dir, @src_dir), @name)
39
+ @src
32
40
  end
33
41
 
34
42
  # Use MiniMagick to create a derivative image at the destination
@@ -38,23 +46,15 @@ module Jekyll
38
46
  # Returns false if the file was not modified since last time (no-op).
39
47
  def write(dest)
40
48
  dest_path = destination(dest)
41
- if @retina
42
- filepath, extension = dest_path.match(/(.+)(\.[a-zA-Z]{3,4})/i).captures
43
- dest_path = "#{filepath}@2x#{extension}"
44
- end
45
49
 
46
- return false if File.exist? dest_path and !modified?
50
+ return false if File.exist? dest_path
47
51
 
48
52
  @@mtimes[path] = mtime
49
53
 
50
54
  FileUtils.mkdir_p(File.dirname(dest_path))
51
55
  image = ::MiniMagick::Image.open(path)
52
56
  @commands.each_pair do |command, arg|
53
- if @retina
54
- width, height = arg.match(/([0-9]+)x([0-9]+)/i).captures
55
- arg = "#{Integer(width) * 2}x#{Integer(height) * 2}"
56
- end
57
- image.resize arg
57
+ image.send command, arg
58
58
  end
59
59
  image.write dest_path
60
60
 
@@ -75,7 +75,9 @@ module Jekyll
75
75
  site.config['retinamagick'].each_pair do |name, preset|
76
76
  Dir.glob(File.join(site.source, preset['source'], "*.{png,jpg,jpeg,gif}")) do |source|
77
77
  site.static_files << GeneratedImageFile.new(site, site.source, preset['destination'], File.basename(source), preset.clone, false)
78
- site.static_files << GeneratedImageFile.new(site, site.source, preset['destination'], File.basename(source), preset.clone, true)
78
+ if preset.has_key?("resize")
79
+ site.static_files << GeneratedImageFile.new(site, site.source, preset['destination'], File.basename(source), preset.clone, true)
80
+ end
79
81
  end
80
82
  end
81
83
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-retinamagick
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brendan Tobolaski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-03 00:00:00.000000000 Z
11
+ date: 2013-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll