pandocomatic 0.2.7.7 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/lib/pandocomatic/cli.rb +81 -64
  3. data/lib/pandocomatic/command/command.rb +37 -35
  4. data/lib/pandocomatic/command/convert_dir_command.rb +44 -46
  5. data/lib/pandocomatic/command/convert_file_command.rb +314 -286
  6. data/lib/pandocomatic/command/convert_file_multiple_command.rb +56 -53
  7. data/lib/pandocomatic/command/convert_list_command.rb +31 -34
  8. data/lib/pandocomatic/command/copy_file_command.rb +14 -15
  9. data/lib/pandocomatic/command/create_link_command.rb +24 -27
  10. data/lib/pandocomatic/command/skip_command.rb +12 -15
  11. data/lib/pandocomatic/configuration.rb +682 -867
  12. data/lib/pandocomatic/default_configuration.yaml +4 -0
  13. data/lib/pandocomatic/error/cli_error.rb +30 -26
  14. data/lib/pandocomatic/error/configuration_error.rb +10 -9
  15. data/lib/pandocomatic/error/io_error.rb +13 -13
  16. data/lib/pandocomatic/error/pandoc_error.rb +10 -9
  17. data/lib/pandocomatic/error/pandocomatic_error.rb +15 -14
  18. data/lib/pandocomatic/error/processor_error.rb +9 -9
  19. data/lib/pandocomatic/error/template_error.rb +50 -0
  20. data/lib/pandocomatic/input.rb +53 -54
  21. data/lib/pandocomatic/multiple_files_input.rb +79 -72
  22. data/lib/pandocomatic/output.rb +29 -0
  23. data/lib/pandocomatic/pandoc_metadata.rb +193 -181
  24. data/lib/pandocomatic/pandocomatic.rb +101 -97
  25. data/lib/pandocomatic/pandocomatic_yaml.rb +69 -0
  26. data/lib/pandocomatic/path.rb +171 -0
  27. data/lib/pandocomatic/printer/command_printer.rb +7 -5
  28. data/lib/pandocomatic/printer/configuration_errors_printer.rb +7 -6
  29. data/lib/pandocomatic/printer/error_printer.rb +12 -7
  30. data/lib/pandocomatic/printer/finish_printer.rb +11 -10
  31. data/lib/pandocomatic/printer/help_printer.rb +8 -6
  32. data/lib/pandocomatic/printer/printer.rb +34 -34
  33. data/lib/pandocomatic/printer/summary_printer.rb +39 -33
  34. data/lib/pandocomatic/printer/version_printer.rb +8 -8
  35. data/lib/pandocomatic/printer/views/cli_error.txt +5 -0
  36. data/lib/pandocomatic/printer/views/configuration_error.txt +2 -1
  37. data/lib/pandocomatic/printer/views/error.txt +1 -1
  38. data/lib/pandocomatic/printer/views/finish.txt +1 -1
  39. data/lib/pandocomatic/printer/views/help.txt +27 -15
  40. data/lib/pandocomatic/printer/views/summary.txt +7 -1
  41. data/lib/pandocomatic/printer/views/template_error.txt +1 -0
  42. data/lib/pandocomatic/printer/views/version.txt +3 -3
  43. data/lib/pandocomatic/printer/views/warning.txt +1 -1
  44. data/lib/pandocomatic/printer/warning_printer.rb +21 -19
  45. data/lib/pandocomatic/processor.rb +28 -28
  46. data/lib/pandocomatic/processors/fileinfo_preprocessor.rb +35 -30
  47. data/lib/pandocomatic/processors/metadata_preprocessor.rb +23 -22
  48. data/lib/pandocomatic/template.rb +244 -0
  49. data/lib/pandocomatic/warning.rb +24 -25
  50. metadata +32 -12
@@ -3,3 +3,7 @@ settings:
3
3
  follow-symlinks: false
4
4
  skip: ['.*', 'pandocomatic.yaml']
5
5
  match-files: 'first'
6
+ templates:
7
+ empty:
8
+ metadata:
9
+ empty: true
@@ -1,52 +1,56 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #--
2
4
  # Copyright 2017, Huub de Beer <Huub@heerdebeer.org>
3
- #
5
+ #
4
6
  # This file is part of pandocomatic.
5
- #
7
+ #
6
8
  # Pandocomatic is free software: you can redistribute it and/or modify
7
9
  # it under the terms of the GNU General Public License as published by the
8
10
  # Free Software Foundation, either version 3 of the License, or (at your
9
11
  # option) any later version.
10
- #
12
+ #
11
13
  # Pandocomatic is distributed in the hope that it will be useful, but
12
14
  # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13
15
  # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
16
  # for more details.
15
- #
17
+ #
16
18
  # You should have received a copy of the GNU General Public License along
17
19
  # with pandocomatic. If not, see <http://www.gnu.org/licenses/>.
18
20
  #++
19
21
  module Pandocomatic
20
- require_relative './pandocomatic_error.rb'
22
+ require_relative './pandocomatic_error'
21
23
 
22
- # A command line error.
24
+ # A command-line error.
23
25
  class CLIError < PandocomaticError
24
-
25
26
  # Get the template used to print this CLIError
26
- def template()
27
+ def template
27
28
  'cli_error.txt'
28
29
  end
29
30
 
30
- # :no_input_given,
31
- # :input_does_not_exist,
32
- # :input_is_not_readable,
33
- # :multiple_input_files_only,
34
- # :no_mixed_inputs
31
+ # :no_input_given,
32
+ # :input_does_not_exist,
33
+ # :input_is_not_readable,
34
+ # :multiple_input_files_only,
35
+ # :no_mixed_inputs
36
+
37
+ # :no_output_given,
38
+ # :output_is_not_a_directory,
39
+ # :output_is_not_a_file,
40
+ # :output_it_not_writable,
35
41
 
36
- # :no_output_given,
37
- # :output_is_not_a_directory,
38
- # :output_is_not_a_file,
39
- # :output_it_not_writable,
42
+ # :cannot_use_stdout_with_directory
43
+ # :cannot_use_both_output_and_stdout
40
44
 
41
- # :unknown_option,
42
- # :problematic_invocation,
45
+ # :unknown_option,
46
+ # :problematic_invocation,
43
47
 
44
- # :data_dir_does_not_exist,
45
- # :data_dir_is_not_a_directory,
46
- # :data_dir_is_not_readable,
48
+ # :data_dir_does_not_exist,
49
+ # :data_dir_is_not_a_directory,
50
+ # :data_dir_is_not_readable,
47
51
 
48
- # :config_file_does_not_exist,
49
- # :config_file_is_not_a_file,
50
- # :config_file_is_not_readable
52
+ # :config_file_does_not_exist,
53
+ # :config_file_is_not_a_file,
54
+ # :config_file_is_not_readable
51
55
  end
52
- end
56
+ end
@@ -1,29 +1,30 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #--
2
4
  # Copyright 2017, Huub de Beer <Huub@heerdebeer.org>
3
- #
5
+ #
4
6
  # This file is part of pandocomatic.
5
- #
7
+ #
6
8
  # Pandocomatic is free software: you can redistribute it and/or modify
7
9
  # it under the terms of the GNU General Public License as published by the
8
10
  # Free Software Foundation, either version 3 of the License, or (at your
9
11
  # option) any later version.
10
- #
12
+ #
11
13
  # Pandocomatic is distributed in the hope that it will be useful, but
12
14
  # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13
15
  # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
16
  # for more details.
15
- #
17
+ #
16
18
  # You should have received a copy of the GNU General Public License along
17
19
  # with pandocomatic. If not, see <http://www.gnu.org/licenses/>.
18
20
  #++
19
21
  module Pandocomatic
20
- require_relative './pandocomatic_error.rb'
22
+ require_relative './pandocomatic_error'
21
23
 
22
24
  # A ConfigurationError
23
25
  class ConfigurationError < PandocomaticError
24
-
25
26
  # The template to print this ConfigurationError
26
- def template()
27
+ def template
27
28
  'configuration_error.txt'
28
29
  end
29
30
 
@@ -35,7 +36,7 @@ module Pandocomatic
35
36
  # :config_file_is_not_a_file,
36
37
  # :config_file_is_not_readable,
37
38
  # :unable_to_load_config_file
38
-
39
+
39
40
  # :no_such_template
40
41
  end
41
- end
42
+ end
@@ -1,40 +1,41 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #--
2
4
  # Copyright 2017, Huub de Beer <Huub@heerdebeer.org>
3
- #
5
+ #
4
6
  # This file is part of pandocomatic.
5
- #
7
+ #
6
8
  # Pandocomatic is free software: you can redistribute it and/or modify
7
9
  # it under the terms of the GNU General Public License as published by the
8
10
  # Free Software Foundation, either version 3 of the License, or (at your
9
11
  # option) any later version.
10
- #
12
+ #
11
13
  # Pandocomatic is distributed in the hope that it will be useful, but
12
14
  # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13
15
  # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
16
  # for more details.
15
- #
17
+ #
16
18
  # You should have received a copy of the GNU General Public License along
17
19
  # with pandocomatic. If not, see <http://www.gnu.org/licenses/>.
18
20
  #++
19
21
  module Pandocomatic
20
- require_relative './pandocomatic_error.rb'
22
+ require_relative './pandocomatic_error'
21
23
 
22
24
  # An IOError
23
25
  class IOError < PandocomaticError
24
-
25
26
  # The template to use when printing this IOError
26
- def template()
27
+ def template
27
28
  'io_error.txt'
28
29
  end
29
-
30
+
30
31
  # :file_does_not_exist file
31
32
  # :file_is_not_a_file file
32
33
  # :file_is_not_readable file
33
34
  # :file_is_not_writable file
34
-
35
+
35
36
  # :error_opening_file file
36
37
  # :error_writing_file file
37
-
38
+
38
39
  # :directory_does_not_exist dir
39
40
  # :directory_is_not_a_directory dir
40
41
  # :directory_is_not_readable dir
@@ -42,11 +43,10 @@ module Pandocomatic
42
43
 
43
44
  # :error_opening_directory dir
44
45
  # :error_creating_directory dir
45
-
46
+
46
47
  # :file_or_directory_does_not_exist src
47
48
  # :unable_to_copy_file [src, dst]
48
49
  # :unable_to_create_symbolic_link [src, dst]
49
50
  # :unable_to_read_symbolic_link [src]
50
51
  end
51
-
52
- end
52
+ end
@@ -1,32 +1,33 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #--
2
4
  # Copyright 2017, Huub de Beer <Huub@heerdebeer.org>
3
- #
5
+ #
4
6
  # This file is part of pandocomatic.
5
- #
7
+ #
6
8
  # Pandocomatic is free software: you can redistribute it and/or modify
7
9
  # it under the terms of the GNU General Public License as published by the
8
10
  # Free Software Foundation, either version 3 of the License, or (at your
9
11
  # option) any later version.
10
- #
12
+ #
11
13
  # Pandocomatic is distributed in the hope that it will be useful, but
12
14
  # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13
15
  # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
16
  # for more details.
15
- #
17
+ #
16
18
  # You should have received a copy of the GNU General Public License along
17
19
  # with pandocomatic. If not, see <http://www.gnu.org/licenses/>.
18
20
  #++
19
21
  module Pandocomatic
20
- require_relative './pandocomatic_error.rb'
22
+ require_relative './pandocomatic_error'
21
23
 
22
- # An error when running pandoc
24
+ # An error when running pandoc
23
25
  class PandocError < PandocomaticError
24
-
25
26
  # The template to use to print this PandocError
26
- def template()
27
+ def template
27
28
  'pandoc_error.txt'
28
29
  end
29
30
 
30
31
  # :error_running_pandoc
31
32
  end
32
- end
33
+ end
@@ -1,23 +1,25 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #--
2
4
  # Copyright 2017, Huub de Beer <Huub@heerdebeer.org>
3
- #
5
+ #
4
6
  # This file is part of pandocomatic.
5
- #
7
+ #
6
8
  # Pandocomatic is free software: you can redistribute it and/or modify
7
9
  # it under the terms of the GNU General Public License as published by the
8
10
  # Free Software Foundation, either version 3 of the License, or (at your
9
11
  # option) any later version.
10
- #
12
+ #
11
13
  # Pandocomatic is distributed in the hope that it will be useful, but
12
14
  # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13
15
  # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
16
  # for more details.
15
- #
17
+ #
16
18
  # You should have received a copy of the GNU General Public License along
17
19
  # with pandocomatic. If not, see <http://www.gnu.org/licenses/>.
18
20
  #++
19
21
  module Pandocomatic
20
- require_relative '../printer/error_printer.rb'
22
+ require_relative '../printer/error_printer'
21
23
 
22
24
  # General pandocomatic error
23
25
  #
@@ -39,7 +41,7 @@ module Pandocomatic
39
41
  # @param data [Object = nil] extra information attached to this
40
42
  # PandocomaticError, if any; optional
41
43
  def initialize(type = :unknown, error = nil, data = nil)
42
- super type.to_s.gsub("_", " ").capitalize
44
+ super type.to_s.gsub('_', ' ').capitalize
43
45
  @type = type
44
46
  @error = error
45
47
  @data = data
@@ -48,28 +50,27 @@ module Pandocomatic
48
50
  # Has this PandocomaticError an underlying error?
49
51
  #
50
52
  # @return [Boolean]
51
- def has_error?()
52
- not @error.nil?
53
+ def error?
54
+ !@error.nil?
53
55
  end
54
56
 
55
57
  # Has this PandocomaticError extra information associated to it?
56
58
  #
57
59
  # @return [Boolean]
58
- def has_data?()
59
- not @data.nil?
60
+ def data?
61
+ !@data.nil?
60
62
  end
61
63
 
62
64
  # Print this error.
63
- def print()
65
+ def print
64
66
  ErrorPrinter.new(self).print
65
67
  end
66
68
 
67
69
  # Show this error
68
70
  #
69
71
  # @return [String] a string representation of this PandocomaticError
70
- def show()
72
+ def show
71
73
  ErrorPrinter.new(self).to_s
72
74
  end
73
-
74
75
  end
75
- end
76
+ end
@@ -1,29 +1,30 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #--
2
4
  # Copyright 2017, Huub de Beer <Huub@heerdebeer.org>
3
- #
5
+ #
4
6
  # This file is part of pandocomatic.
5
- #
7
+ #
6
8
  # Pandocomatic is free software: you can redistribute it and/or modify
7
9
  # it under the terms of the GNU General Public License as published by the
8
10
  # Free Software Foundation, either version 3 of the License, or (at your
9
11
  # option) any later version.
10
- #
12
+ #
11
13
  # Pandocomatic is distributed in the hope that it will be useful, but
12
14
  # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13
15
  # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
16
  # for more details.
15
- #
17
+ #
16
18
  # You should have received a copy of the GNU General Public License along
17
19
  # with pandocomatic. If not, see <http://www.gnu.org/licenses/>.
18
20
  #++
19
21
  module Pandocomatic
20
- require_relative './pandocomatic_error.rb'
22
+ require_relative './pandocomatic_error'
21
23
 
22
24
  # An error while running a processor
23
25
  class ProcessorError < PandocomaticError
24
-
25
26
  # The template to use when printing this ProcessorError
26
- def template()
27
+ def template
27
28
  'processor_error.txt'
28
29
  end
29
30
 
@@ -31,5 +32,4 @@ module Pandocomatic
31
32
  # :script_is_not_executable script
32
33
  # :error_processing_script [script, src]
33
34
  end
34
-
35
- end
35
+ end
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ #--
4
+ # Copyright 2022, Huub de Beer <Huub@heerdebeer.org>
5
+ #
6
+ # This file is part of pandocomatic.
7
+ #
8
+ # Pandocomatic is free software: you can redistribute it and/or modify
9
+ # it under the terms of the GNU General Public License as published by the
10
+ # Free Software Foundation, either version 3 of the License, or (at your
11
+ # option) any later version.
12
+ #
13
+ # Pandocomatic is distributed in the hope that it will be useful, but
14
+ # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15
+ # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16
+ # for more details.
17
+ #
18
+ # You should have received a copy of the GNU General Public License along
19
+ # with pandocomatic. If not, see <http://www.gnu.org/licenses/>.
20
+ #++
21
+ module Pandocomatic
22
+ require_relative './pandocomatic_error'
23
+
24
+ # A TemplateError
25
+ class TemplateError < PandocomaticError
26
+ # Create a new PandocomaticError
27
+ #
28
+ # @param type [Symbol = :unknown] the type of error, defaults to :unknown
29
+ # @param data [Object = nil] extra information attached to this
30
+ # TemplateError, if any; optional
31
+ def initialize(type = :unknown, data = nil)
32
+ super(type, nil, data)
33
+ end
34
+
35
+ # Represent this template error as a string.
36
+ # @return [String]
37
+ def to_s
38
+ "Environment variable '#{@data[:key]}'"\
39
+ "#{" in '#{@data[:path]}'" unless @data[:path].nil?}"\
40
+ ' does not exist: No substitution possible.'
41
+ end
42
+
43
+ # The template to print this TemplateError
44
+ def template
45
+ 'template_error.txt'
46
+ end
47
+
48
+ # :environment_variable_does_not_exist
49
+ end
50
+ end
@@ -1,79 +1,78 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #--
2
4
  # Copyright 2019 Huub de Beer <Huub@heerdebeer.org>
3
- #
5
+ #
4
6
  # This file is part of pandocomatic.
5
- #
7
+ #
6
8
  # Pandocomatic is free software: you can redistribute it and/or modify
7
9
  # it under the terms of the GNU General Public License as published by the
8
10
  # Free Software Foundation, either version 3 of the License, or (at your
9
11
  # option) any later version.
10
- #
12
+ #
11
13
  # Pandocomatic is distributed in the hope that it will be useful, but
12
14
  # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13
15
  # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
16
  # for more details.
15
- #
17
+ #
16
18
  # You should have received a copy of the GNU General Public License along
17
19
  # with pandocomatic. If not, see <http://www.gnu.org/licenses/>.
18
20
  #++
19
21
  module Pandocomatic
22
+ require_relative './configuration'
20
23
 
21
- require_relative './configuration.rb'
22
-
23
- # Generic class to handle input files and directories in a general manner.
24
- class Input
25
-
26
- attr_reader :errors
24
+ # Generic class to handle input files and directories in a general manner.
25
+ class Input
26
+ attr_reader :errors
27
27
 
28
- # Create a new Input
29
- #
30
- # @param input [String[]] a list of input files
31
- def initialize(input)
32
- @input_files = input
33
- @errors = []
34
- end
28
+ # Create a new Input
29
+ #
30
+ # @param input [String[]] a list of input files
31
+ def initialize(input)
32
+ @input_files = input
33
+ @errors = []
34
+ end
35
35
 
36
- # The absolute path to this Input
37
- #
38
- # @return String
39
- def absolute_path()
40
- File.absolute_path @input_files.first
41
- end
36
+ # The absolute path to this Input
37
+ #
38
+ # @return String
39
+ def absolute_path
40
+ File.absolute_path @input_files.first
41
+ end
42
42
 
43
- # The base name of this Input
44
- #
45
- # @return String
46
- def base()
47
- File.basename @input_files.first
48
- end
43
+ # The base name of this Input
44
+ #
45
+ # @return String
46
+ def base
47
+ File.basename @input_files.first
48
+ end
49
49
 
50
- # The name of this input
51
- #
52
- # @return String
53
- def name()
54
- @input_files.first
55
- end
50
+ # The name of this input
51
+ #
52
+ # @return String
53
+ def name
54
+ @input_files.first
55
+ end
56
56
 
57
- # Is this input a directory?
58
- #
59
- # @return Boolean
60
- def directory?()
61
- File.directory? @input_files.first
62
- end
63
-
64
- # Does this input have encountered any errors?
65
- #
66
- # @return Boolean
67
- def has_errors?()
68
- not @errors.empty?
69
- end
57
+ # Is this input a directory?
58
+ #
59
+ # @return Boolean
60
+ def directory?
61
+ File.directory? @input_files.first
62
+ end
70
63
 
71
- # A string representation of this Input
72
- #
73
- # @return String
74
- def to_s()
75
- self.name
76
- end
64
+ # Does this input have encountered any errors?
65
+ #
66
+ # @return Boolean
67
+ def errors?
68
+ !@errors.empty?
69
+ end
77
70
 
71
+ # A string representation of this Input
72
+ #
73
+ # @return String
74
+ def to_s
75
+ name
78
76
  end
77
+ end
79
78
  end