Class: Deplate::Command::AUTHOR

Inherits:
Deplate::Command show all
Defined in:
lib/deplate/commands.rb

Class Method Summary collapse

Methods inherited from Deplate::Command

commands, #finish, #format_special, #process, register_as, #setup, #setup_command, update_variables

Methods included from Names

name_match_c, name_match_fs, name_match_sf

Methods inherited from Element

#join_lines, #join_lines_re_zh_cn

Class Method Details

.accumulate(src, array, deplate, text, match, args, cmd) ⇒ Object



430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
# File 'lib/deplate/commands.rb', line 430

def accumulate(src, array, deplate, text, match, args, cmd)
    Deplate::Core.log('%s: %s' % [cmd, text], :debug, src)
    deplate.options.author ||= []
    for this in text.split(/([;\/]|\s+(&|and))\s+/)
        unless this =~ /^\s*([;\/&]|and)\s*$/
            author = Deplate::Names.name_match_sf(this) || 
                Deplate::Names.name_match_fs(this) || {}
            sn = args['surname']
            author[:surname] = sn if sn
            fn = args['firstname']
            author[:firstname] = fn if fn
            if this.empty?
                author[:name] = args['name'] || '%s %s' % [args['firstname'], args['surname']]
            else
                author[:name] = this
            end
            author[:note] = args['note']
            deplate.options.author << author
        end
    end
    sep     = deplate.variables['authorSep'] || '; '
    authors = deplate.options.author.collect {|h| h[:name]}
    authors = authors.join(sep)
    parsed  = deplate.parse_with_source(src, authors, false)
    deplate.set_clip('author', Deplate::Element::Clip.new(parsed, deplate, src))
    deplate.(src, 
                              'type' => 'metadata', 
                              'name' => 'author',
                              'value' => authors
                             )
end