pandocomatic 0.0.5 → 0.0.6
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 +4 -4
- data/lib/pandocomatic/configuration.rb +18 -2
- data/lib/pandocomatic/dir_converter.rb +21 -14
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f309756a052d15289809ed50817aab915542e43
|
4
|
+
data.tar.gz: ccdebf26491d9731513ff08523bd96884745c1a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 960aeb18970b6f4b0bd1aae7507a2dbe0ce4a3edb93332b8f194654ddf781ffe2dd21d3f6323e83dd88feb4c601094bd246326418133b25085a52f27f785de91
|
7
|
+
data.tar.gz: 1c0e60f1571f89322890fc6aef04105f9f8760b019d0e352868b55c51035fc93c910829ede0a18919c16acce1f8862ee5ccc3dbbe6c83c3f220d835f68457d3c
|
@@ -57,7 +57,14 @@ module Pandocomatic
|
|
57
57
|
reset_settings settings['settings'] if settings.has_key? 'settings'
|
58
58
|
if settings.has_key? 'templates' then
|
59
59
|
settings['templates'].each do |name, template|
|
60
|
-
|
60
|
+
full_template = {
|
61
|
+
'glob' => [],
|
62
|
+
'preprocessors' => [],
|
63
|
+
'pandoc' => {},
|
64
|
+
'postprocessors' => []
|
65
|
+
}
|
66
|
+
|
67
|
+
reset_template name, full_template.merge(template)
|
61
68
|
end
|
62
69
|
end
|
63
70
|
end
|
@@ -146,7 +153,16 @@ module Pandocomatic
|
|
146
153
|
|
147
154
|
def reset_template name, template
|
148
155
|
if @templates.has_key? name then
|
149
|
-
@templates[name].merge!
|
156
|
+
@templates[name].merge!(template) do |setting, oldval, newval|
|
157
|
+
case setting
|
158
|
+
when 'preprocessors', 'postprocessors', 'glob'
|
159
|
+
oldval.concat(newval).uniq
|
160
|
+
when 'pandoc'
|
161
|
+
oldval.merge newval
|
162
|
+
else
|
163
|
+
newval
|
164
|
+
end
|
165
|
+
end
|
150
166
|
else
|
151
167
|
@templates[name] = template
|
152
168
|
end
|
@@ -8,8 +8,8 @@ module Pandocomatic
|
|
8
8
|
class DirConverter
|
9
9
|
|
10
10
|
def initialize src, dst, config
|
11
|
-
@src_root = src
|
12
|
-
@dst_root = dst
|
11
|
+
@src_root = File.absolute_path src
|
12
|
+
@dst_root = File.absolute_path dst
|
13
13
|
@config = config
|
14
14
|
end
|
15
15
|
|
@@ -26,7 +26,15 @@ module Pandocomatic
|
|
26
26
|
|
27
27
|
dst = File.join dst_dir, filename
|
28
28
|
|
29
|
-
if File.
|
29
|
+
if File.symlink? src and not config.follow_links?
|
30
|
+
# Symlinks are also recognized as files and directories, so first
|
31
|
+
# check if they should be followed (and treated as files and
|
32
|
+
# directories), or if they should be recreated (if follow-links
|
33
|
+
# setting is false
|
34
|
+
recreate_link src, dst
|
35
|
+
|
36
|
+
elsif File.directory? src then
|
37
|
+
|
30
38
|
if config.recursive? then
|
31
39
|
|
32
40
|
# Convert subdirectories only when the recursivity is set in the
|
@@ -35,9 +43,6 @@ module Pandocomatic
|
|
35
43
|
else
|
36
44
|
next # skip directories when not recursive
|
37
45
|
end
|
38
|
-
elsif File.symlink? src and not config.follow_links
|
39
|
-
|
40
|
-
recreate_link src, dst
|
41
46
|
|
42
47
|
elsif File.file? src
|
43
48
|
|
@@ -90,15 +95,17 @@ module Pandocomatic
|
|
90
95
|
end
|
91
96
|
|
92
97
|
# Recreate source link in destination tree if it points to somewhere inside
|
93
|
-
# the source tree
|
98
|
+
# the source tree using relative paths
|
94
99
|
def recreate_link src, dst
|
95
|
-
src_target = File.readlink
|
96
|
-
|
97
|
-
|
98
|
-
dst_target =
|
99
|
-
|
100
|
-
|
101
|
-
|
100
|
+
src_target = File.readlink src
|
101
|
+
if src_target.start_with? '.' then
|
102
|
+
full_src_target = File.expand_path src_target, File.dirname(src)
|
103
|
+
dst_target = src_target
|
104
|
+
if full_src_target.start_with? @src_root
|
105
|
+
File.symlink dst_target, dst unless File.exist? dst
|
106
|
+
else
|
107
|
+
warn "Skipping link #{src} because it points to outside the source tree"
|
108
|
+
end
|
102
109
|
end
|
103
110
|
end
|
104
111
|
|