pandocomatic 0.1.4.15 → 0.1.4.16
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 +96 -35
 - data/lib/pandocomatic/pandocomatic.rb +10 -4
 - metadata +8 -7
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 5c02545012823b03faea6b75bd1eefe4f0321f87
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: e20c1f0fb820d2372a549bdeae47b8ef97207e9c
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: dffc42a133303448e4e0fb8c2921231b5c59de5b50b2506e1babdc8b4499f11d724e48615f60cd0449206e26bf6dbc69d97933bea6efd195a1c8b16445dc9598
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: c7f3608f963daa702eeec4f3203bf8eba373f31aae316fafe9bdee1d3bd4cbccbff00137c6cb2758e24ddfd82512e0feca30143b766dc1bc3ff286dd3cbb9794
         
     | 
| 
         @@ -311,8 +311,11 @@ module Pandocomatic 
     | 
|
| 
       311 
311 
     | 
    
         
             
                    # @param mixin_template [Hash] the template to mixin into the base template
         
     | 
| 
       312 
312 
     | 
    
         
             
                    # @return [Hash] the merged templates
         
     | 
| 
       313 
313 
     | 
    
         
             
                    def merge(base_template, mixin_template)
         
     | 
| 
      
 314 
     | 
    
         
            +
                        if mixin_template['extends'] and mixin_template['extends'].is_a? String
         
     | 
| 
      
 315 
     | 
    
         
            +
                            mixin_template['extends'] = [mixin_template['extends']]
         
     | 
| 
      
 316 
     | 
    
         
            +
                        end
         
     | 
| 
      
 317 
     | 
    
         
            +
             
     | 
| 
       314 
318 
     | 
    
         
             
                        fields = [
         
     | 
| 
       315 
     | 
    
         
            -
                            'extends', 
         
     | 
| 
       316 
319 
     | 
    
         
             
                            'glob', 
         
     | 
| 
       317 
320 
     | 
    
         
             
                            'metadata',
         
     | 
| 
       318 
321 
     | 
    
         
             
                            'setup', 
         
     | 
| 
         @@ -323,46 +326,104 @@ module Pandocomatic 
     | 
|
| 
       323 
326 
     | 
    
         
             
                        ]
         
     | 
| 
       324 
327 
     | 
    
         | 
| 
       325 
328 
     | 
    
         
             
                        fields.each do |field|
         
     | 
| 
       326 
     | 
    
         
            -
                             
     | 
| 
       327 
     | 
    
         
            -
                             
     | 
| 
       328 
     | 
    
         
            -
             
     | 
| 
       329 
     | 
    
         
            -
             
     | 
| 
       330 
     | 
    
         
            -
             
     | 
| 
       331 
     | 
    
         
            -
             
     | 
| 
       332 
     | 
    
         
            -
             
     | 
| 
       333 
     | 
    
         
            -
             
     | 
| 
       334 
     | 
    
         
            -
             
     | 
| 
       335 
     | 
    
         
            -
             
     | 
| 
       336 
     | 
    
         
            -
             
     | 
| 
       337 
     | 
    
         
            -
             
     | 
| 
       338 
     | 
    
         
            -
             
     | 
| 
       339 
     | 
    
         
            -
             
     | 
| 
       340 
     | 
    
         
            -
             
     | 
| 
       341 
     | 
    
         
            -
             
     | 
| 
       342 
     | 
    
         
            -
             
     | 
| 
       343 
     | 
    
         
            -
             
     | 
| 
       344 
     | 
    
         
            -
             
     | 
| 
       345 
     | 
    
         
            -
             
     | 
| 
       346 
     | 
    
         
            -
             
     | 
| 
       347 
     | 
    
         
            -
             
     | 
| 
       348 
     | 
    
         
            -
             
     | 
| 
      
 329 
     | 
    
         
            +
                            parent = base_template[field]
         
     | 
| 
      
 330 
     | 
    
         
            +
                            current = mixin_template[field]
         
     | 
| 
      
 331 
     | 
    
         
            +
                            extended_value = extend_value current, parent
         
     | 
| 
      
 332 
     | 
    
         
            +
             
     | 
| 
      
 333 
     | 
    
         
            +
                            if extended_value.nil?
         
     | 
| 
      
 334 
     | 
    
         
            +
                                base_template.delete field
         
     | 
| 
      
 335 
     | 
    
         
            +
                            else
         
     | 
| 
      
 336 
     | 
    
         
            +
                                base_template[field] = extended_value
         
     | 
| 
      
 337 
     | 
    
         
            +
                            end
         
     | 
| 
      
 338 
     | 
    
         
            +
                        end
         
     | 
| 
      
 339 
     | 
    
         
            +
             
     | 
| 
      
 340 
     | 
    
         
            +
                        base_template
         
     | 
| 
      
 341 
     | 
    
         
            +
                    end
         
     | 
| 
      
 342 
     | 
    
         
            +
             
     | 
| 
      
 343 
     | 
    
         
            +
                    # Extend the current value with the parent value. Depending on the
         
     | 
| 
      
 344 
     | 
    
         
            +
                    # value and type of the current and parent values, the extension
         
     | 
| 
      
 345 
     | 
    
         
            +
                    # differs.
         
     | 
| 
      
 346 
     | 
    
         
            +
                    #
         
     | 
| 
      
 347 
     | 
    
         
            +
                    # For simple values, the current value takes precedence over the
         
     | 
| 
      
 348 
     | 
    
         
            +
                    # parent value
         
     | 
| 
      
 349 
     | 
    
         
            +
                    #
         
     | 
| 
      
 350 
     | 
    
         
            +
                    # For Hash values, each parent value's property is extended as well
         
     | 
| 
      
 351 
     | 
    
         
            +
                    #
         
     | 
| 
      
 352 
     | 
    
         
            +
                    # For Arrays, the current overwrites and adds to parent value's items
         
     | 
| 
      
 353 
     | 
    
         
            +
                    # unless the current value is a Hash with a 'remove' and 'add'
         
     | 
| 
      
 354 
     | 
    
         
            +
                    # property. Then the 'add' items are added to the parent value and the
         
     | 
| 
      
 355 
     | 
    
         
            +
                    # 'remove' items are removed from the parent value.
         
     | 
| 
      
 356 
     | 
    
         
            +
                    #
         
     | 
| 
      
 357 
     | 
    
         
            +
                    # @param current [Object] the current value
         
     | 
| 
      
 358 
     | 
    
         
            +
                    # @param parent [Object] the parent value the current might extend
         
     | 
| 
      
 359 
     | 
    
         
            +
                    # @return [Object] the extended value
         
     | 
| 
      
 360 
     | 
    
         
            +
                    def extend_value(current, parent)
         
     | 
| 
      
 361 
     | 
    
         
            +
                        if parent.nil?
         
     | 
| 
      
 362 
     | 
    
         
            +
                            # If no parent value is specified, the current takes
         
     | 
| 
      
 363 
     | 
    
         
            +
                            # precedence
         
     | 
| 
      
 364 
     | 
    
         
            +
                            current
         
     | 
| 
      
 365 
     | 
    
         
            +
                        else
         
     | 
| 
      
 366 
     | 
    
         
            +
                            if current.nil?
         
     | 
| 
      
 367 
     | 
    
         
            +
                                # Current nil removes value of parent; follows YAML spec.
         
     | 
| 
      
 368 
     | 
    
         
            +
                                # Note. take care to actually remove this value from a
         
     | 
| 
      
 369 
     | 
    
         
            +
                                # Hash. (Like it is done in the next case)
         
     | 
| 
      
 370 
     | 
    
         
            +
                                nil
         
     | 
| 
      
 371 
     | 
    
         
            +
                            else
         
     | 
| 
      
 372 
     | 
    
         
            +
                                if parent.is_a? Hash
         
     | 
| 
      
 373 
     | 
    
         
            +
                                    if current.is_a? Hash
         
     | 
| 
      
 374 
     | 
    
         
            +
                                        # Mixin current and parent values
         
     | 
| 
      
 375 
     | 
    
         
            +
                                        parent.each_pair do |property, value|
         
     | 
| 
      
 376 
     | 
    
         
            +
                                            if current.has_key? property
         
     | 
| 
      
 377 
     | 
    
         
            +
                                                extended_value = extend_value(current[property], value)
         
     | 
| 
      
 378 
     | 
    
         
            +
                                                if extended_value.nil?
         
     | 
| 
      
 379 
     | 
    
         
            +
                                                    current.delete property
         
     | 
| 
      
 380 
     | 
    
         
            +
                                                else
         
     | 
| 
      
 381 
     | 
    
         
            +
                                                    current[property] = extended_value
         
     | 
| 
      
 382 
     | 
    
         
            +
                                                end
         
     | 
| 
      
 383 
     | 
    
         
            +
                                            else
         
     | 
| 
      
 384 
     | 
    
         
            +
                                                current[property] = value
         
     | 
| 
      
 385 
     | 
    
         
            +
                                            end
         
     | 
| 
      
 386 
     | 
    
         
            +
                                        end
         
     | 
| 
       349 
387 
     | 
    
         
             
                                    end
         
     | 
| 
       350 
     | 
    
         
            -
             
     | 
| 
       351 
     | 
    
         
            -
             
     | 
| 
       352 
     | 
    
         
            -
             
     | 
| 
       353 
     | 
    
         
            -
             
     | 
| 
       354 
     | 
    
         
            -
             
     | 
| 
       355 
     | 
    
         
            -
             
     | 
| 
      
 388 
     | 
    
         
            +
                                    current
         
     | 
| 
      
 389 
     | 
    
         
            +
                                elsif parent.is_a? Array
         
     | 
| 
      
 390 
     | 
    
         
            +
                                    if current.is_a? Hash
         
     | 
| 
      
 391 
     | 
    
         
            +
                                        if current.has_key? 'remove'
         
     | 
| 
      
 392 
     | 
    
         
            +
                                            to_remove = current['remove']
         
     | 
| 
      
 393 
     | 
    
         
            +
             
     | 
| 
      
 394 
     | 
    
         
            +
                                            if to_remove.is_a? Array
         
     | 
| 
      
 395 
     | 
    
         
            +
                                                parent = parent.delete_if {|v| current['remove'].include? v}
         
     | 
| 
      
 396 
     | 
    
         
            +
                                            else
         
     | 
| 
      
 397 
     | 
    
         
            +
                                                parent = parent.delete to_remove
         
     | 
| 
      
 398 
     | 
    
         
            +
                                            end
         
     | 
| 
      
 399 
     | 
    
         
            +
                                        end
         
     | 
| 
      
 400 
     | 
    
         
            +
             
     | 
| 
      
 401 
     | 
    
         
            +
                                        if current.has_key? 'add'
         
     | 
| 
      
 402 
     | 
    
         
            +
                                            to_add = current['add']
         
     | 
| 
      
 403 
     | 
    
         
            +
                                            
         
     | 
| 
      
 404 
     | 
    
         
            +
                                            if to_add.is_a? Array
         
     | 
| 
      
 405 
     | 
    
         
            +
                                                parent = current['add'].concat(parent).uniq
         
     | 
| 
      
 406 
     | 
    
         
            +
                                            else
         
     | 
| 
      
 407 
     | 
    
         
            +
                                                parent.push(to_add).uniq
         
     | 
| 
      
 408 
     | 
    
         
            +
                                            end
         
     | 
| 
      
 409 
     | 
    
         
            +
                                        end
         
     | 
| 
      
 410 
     | 
    
         
            +
             
     | 
| 
      
 411 
     | 
    
         
            +
                                        parent
         
     | 
| 
      
 412 
     | 
    
         
            +
                                    elsif current.is_a? Array
         
     | 
| 
      
 413 
     | 
    
         
            +
                                        # Just combine parent and current arrays, current
         
     | 
| 
      
 414 
     | 
    
         
            +
                                        # values take precedence
         
     | 
| 
      
 415 
     | 
    
         
            +
                                        current.concat(parent).uniq
         
     | 
| 
      
 416 
     | 
    
         
            +
                                    else
         
     | 
| 
      
 417 
     | 
    
         
            +
                                        # Unknown what to do, assuming current should take
         
     | 
| 
      
 418 
     | 
    
         
            +
                                        # precedence
         
     | 
| 
      
 419 
     | 
    
         
            +
                                        current
         
     | 
| 
       356 
420 
     | 
    
         
             
                                    end
         
     | 
| 
       357 
421 
     | 
    
         
             
                                else
         
     | 
| 
       358 
     | 
    
         
            -
                                     
     | 
| 
       359 
     | 
    
         
            -
             
     | 
| 
       360 
     | 
    
         
            -
                                    end
         
     | 
| 
      
 422 
     | 
    
         
            +
                                    # Simple values: current replaces parent
         
     | 
| 
      
 423 
     | 
    
         
            +
                                    current
         
     | 
| 
       361 
424 
     | 
    
         
             
                                end
         
     | 
| 
       362 
425 
     | 
    
         
             
                            end
         
     | 
| 
       363 
426 
     | 
    
         
             
                        end
         
     | 
| 
       364 
     | 
    
         
            -
             
     | 
| 
       365 
     | 
    
         
            -
                        base_template
         
     | 
| 
       366 
427 
     | 
    
         
             
                    end
         
     | 
| 
       367 
428 
     | 
    
         | 
| 
       368 
429 
     | 
    
         
             
                    # Resolve the templates the templates extends and mixes them in, in
         
     | 
| 
         @@ -45,9 +45,12 @@ module Pandocomatic 
     | 
|
| 
       45 
45 
     | 
    
         | 
| 
       46 
46 
     | 
    
         
             
                # The Pandocomatic class controlls the pandocomatic conversion process
         
     | 
| 
       47 
47 
     | 
    
         
             
                class Pandocomatic
         
     | 
| 
      
 48 
     | 
    
         
            +
                    
         
     | 
| 
      
 49 
     | 
    
         
            +
                    # Pandocomatic error status codes start from ERROR_STATUS
         
     | 
| 
      
 50 
     | 
    
         
            +
                    ERROR_STATUS = 1266 # This is the sum of the ascii values of the characters in 'pandocomatic'
         
     | 
| 
       48 
51 
     | 
    
         | 
| 
       49 
52 
     | 
    
         
             
                    # Pandocomatic's current version
         
     | 
| 
       50 
     | 
    
         
            -
                    VERSION = [0, 1, 4,  
     | 
| 
      
 53 
     | 
    
         
            +
                    VERSION = [0, 1, 4, 16]
         
     | 
| 
       51 
54 
     | 
    
         | 
| 
       52 
55 
     | 
    
         
             
                    # Pandocomatic's default configuration file
         
     | 
| 
       53 
56 
     | 
    
         
             
                    CONFIG_FILE = 'pandocomatic.yaml'
         
     | 
| 
         @@ -103,11 +106,12 @@ module Pandocomatic 
     | 
|
| 
       103 
106 
     | 
    
         
             
                                # conversion.
         
     | 
| 
       104 
107 
     | 
    
         
             
                                if command.all_errors.size > 0
         
     | 
| 
       105 
108 
     | 
    
         
             
                                    ConfigurationErrorsPrinter.new(command.all_errors).print
         
     | 
| 
       106 
     | 
    
         
            -
                                    exit
         
     | 
| 
      
 109 
     | 
    
         
            +
                                    exit ERROR_STATUS
         
     | 
| 
       107 
110 
     | 
    
         
             
                                end
         
     | 
| 
       108 
111 
     | 
    
         | 
| 
       109 
112 
     | 
    
         
             
                                # Pandocomatic is successfully configured: running the
         
     | 
| 
       110 
     | 
    
         
            -
                                # actual conversion now.
         
     | 
| 
      
 113 
     | 
    
         
            +
                                # actual conversion now. But first a short summary of the
         
     | 
| 
      
 114 
     | 
    
         
            +
                                # process to execute is printed.
         
     | 
| 
       111 
115 
     | 
    
         
             
                                SummaryPrinter.new(command, input, output).print unless quiet or not command.directory?
         
     | 
| 
       112 
116 
     | 
    
         | 
| 
       113 
117 
     | 
    
         
             
                                # Depending on the options dry-run and quiet, the command.execute
         
     | 
| 
         @@ -120,9 +124,11 @@ module Pandocomatic 
     | 
|
| 
       120 
124 
     | 
    
         
             
                        rescue PandocomaticError => e
         
     | 
| 
       121 
125 
     | 
    
         
             
                            # Report the error and break off the conversion process.
         
     | 
| 
       122 
126 
     | 
    
         
             
                            ErrorPrinter.new(e).print
         
     | 
| 
      
 127 
     | 
    
         
            +
                            exit ERROR_STATUS + 1
         
     | 
| 
       123 
128 
     | 
    
         
             
                        rescue StandardError => e
         
     | 
| 
       124 
129 
     | 
    
         
             
                            # An unexpected error has occurred; break off the program drastically
         
     | 
| 
       125 
     | 
    
         
            -
                            # for now
         
     | 
| 
      
 130 
     | 
    
         
            +
                            # for now. This is likely a bug: ask the user to report it.
         
     | 
| 
      
 131 
     | 
    
         
            +
                            warn "An unexpected error has occurred. You can report this bug via https://github.com/htdebeer/pandocomatic/issues/new."
         
     | 
| 
       126 
132 
     | 
    
         
             
                            raise e
         
     | 
| 
       127 
133 
     | 
    
         
             
                        end
         
     | 
| 
       128 
134 
     | 
    
         
             
                    end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: pandocomatic
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.1.4. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.1.4.16
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Huub de Beer
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2017-09- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2017-09-13 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: paru
         
     | 
| 
         @@ -19,7 +19,7 @@ dependencies: 
     | 
|
| 
       19 
19 
     | 
    
         
             
                    version: 0.2.5
         
     | 
| 
       20 
20 
     | 
    
         
             
                - - ">="
         
     | 
| 
       21 
21 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       22 
     | 
    
         
            -
                    version: 0.2.5. 
     | 
| 
      
 22 
     | 
    
         
            +
                    version: 0.2.5.7
         
     | 
| 
       23 
23 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       24 
24 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       25 
25 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
         @@ -29,7 +29,7 @@ dependencies: 
     | 
|
| 
       29 
29 
     | 
    
         
             
                    version: 0.2.5
         
     | 
| 
       30 
30 
     | 
    
         
             
                - - ">="
         
     | 
| 
       31 
31 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       32 
     | 
    
         
            -
                    version: 0.2.5. 
     | 
| 
      
 32 
     | 
    
         
            +
                    version: 0.2.5.7
         
     | 
| 
       33 
33 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       34 
34 
     | 
    
         
             
              name: trollop
         
     | 
| 
       35 
35 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
         @@ -78,8 +78,9 @@ dependencies: 
     | 
|
| 
       78 
78 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       79 
79 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       80 
80 
     | 
    
         
             
                    version: 0.9.8
         
     | 
| 
       81 
     | 
    
         
            -
            description:  
     | 
| 
       82 
     | 
    
         
            -
               
     | 
| 
      
 81 
     | 
    
         
            +
            description: Pandocomatic is a tool to automate using pandoc (<http://pandoc.org>).
         
     | 
| 
      
 82 
     | 
    
         
            +
              With pandocomatic you can express common patterns of using pandoc for generating
         
     | 
| 
      
 83 
     | 
    
         
            +
              your documents. Applied to a directory, pandocomatic can act as a static site generator.
         
     | 
| 
       83 
84 
     | 
    
         
             
            email: Huub@heerdebeer.org
         
     | 
| 
       84 
85 
     | 
    
         
             
            executables:
         
     | 
| 
       85 
86 
     | 
    
         
             
            - pandocomatic
         
     | 
| 
         @@ -153,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       153 
154 
     | 
    
         
             
            requirements:
         
     | 
| 
       154 
155 
     | 
    
         
             
            - pandoc, a universal document converer <http://pandoc.org>
         
     | 
| 
       155 
156 
     | 
    
         
             
            rubyforge_project: 
         
     | 
| 
       156 
     | 
    
         
            -
            rubygems_version: 2. 
     | 
| 
      
 157 
     | 
    
         
            +
            rubygems_version: 2.5.2
         
     | 
| 
       157 
158 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       158 
159 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       159 
160 
     | 
    
         
             
            summary: Automating the use of pandoc
         
     |