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 +4 -4
- data/lib/jekyll-retinamagick/version.rb +1 -1
- data/lib/jekyll-retinamagick.rb +16 -14
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33a537388d726e82dde5fa52b96cc09f8c0589c9
|
4
|
+
data.tar.gz: 7aaa267ca13188232d14db7cb3d25eaca81c899d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 680185aed2affdef8bb349d24ee1ec1b099b33cfb53b9b269f592d0ebc7181eeb23c7fcb142fb9f9de8b413bd54f9eb4e8adbfa5b9a7cee7cc38e7988f30fbfe
|
7
|
+
data.tar.gz: 3f423ddcc8e36cffa5357d5dc68cf06899eda92b2ad73374f2d28e16bc4bbcfc501c9401ad957adcce8b0fe65339ce85074320114464acd3ea866578e3e491f2
|
data/lib/jekyll-retinamagick.rb
CHANGED
@@ -18,9 +18,17 @@ module Jekyll
|
|
18
18
|
@dir = dir
|
19
19
|
@name = name
|
20
20
|
@dst_dir = preset.delete('destination')
|
21
|
-
@
|
21
|
+
@src = File.join(@base, preset.delete('source'), name)
|
22
22
|
@commands = preset
|
23
|
-
|
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
|
-
|
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
|
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
|
-
|
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
|
-
|
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.
|
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-
|
11
|
+
date: 2013-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|