pandocomatic 0.0.5 → 0.0.6

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: 6dd24956dd80cddb7d00b97c85b67f273aaac352
4
- data.tar.gz: a7e58aca8742f9dd3257f7402bf7b91f641b240f
3
+ metadata.gz: 8f309756a052d15289809ed50817aab915542e43
4
+ data.tar.gz: ccdebf26491d9731513ff08523bd96884745c1a3
5
5
  SHA512:
6
- metadata.gz: 8a9a03171aba28b925e30434ead0a1aae0664a1d78bf322e6e828cc7434c4597947703a04894ce242781fcb5ac9195c252e529eb6fcd4221ab610a6f4464f88b
7
- data.tar.gz: 31f06d733453f38c5d02da008fb1da0a632f4b8255f586c9dca839601dbaa3c8770a92f98a1471a8350ca5f9c0bdd6d5ae438bbbcc5060d61de6bcf32c566a3a
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
- reset_template name, template
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! template
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.directory? src then
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(src)
96
- full_src_target = File.realpath src_target
97
- if full_src_target.start_with? @src_root
98
- dst_target = File.join @dst_root, src_target
99
- File.symlink dst_target, dst
100
- else
101
- warn "Skipping link #{src} because it points to outside the source tree"
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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pandocomatic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Huub de Beer