Sha256: 97c982af4f15fe949fcdd9dcaa7c005427c446d55061b9094f720066511412cb

Contents?: true

Size: 970 Bytes

Versions: 24

Compression:

Stored size: 970 Bytes

Contents

#!/usr/bin/env ruby

$-w = true
$:.unshift File.dirname($0) + '/../lib'

require 'vpim/vcard'

ARGV.each do |file|

  File.open(file).each do |line|

    if line =~ /\s*alias\s+(\w+)\s+(.*)/
      nick = $1
      rhs  = $2
      email = nil
      name = nil

      case rhs
        when /(.*)<(.*)>/
          email = $2
          name = $1
        else
          email = rhs
          name = nick
          nick = nil
      end

      card = Vpim::Vcard::Maker.make2 do |maker|
        # don't have the broken-down name, we'll have to leave it blank
        maker.name { |n| n.fullname = name }

        # Set preferred, its the only one...
        maker.add_email( email ) { |e| e.preferred = true }

        maker.nickname = nick if nick
       
        # mark as auto-generated, it makes it easier to see them
        maker.add_field( Vpim::DirectoryInfo::Field.create('note', "auto-generated-from-mutt-aliases") )
      end

      puts card.to_s
    end
  end
end

Version data entries

24 entries across 24 versions & 11 rubygems

Version Path
vpim-24.2.20 samples/mutt-aliases-to-vcf.rb
fraser-vpim-0.658 samples/mutt-aliases-to-vcf.rb
fraser-vpim-0.659 samples/mutt-aliases-to-vcf.rb
fraser-vpim-rails-0.658 samples/mutt-aliases-to-vcf.rb
fraser-vpim-rails-0.659 samples/mutt-aliases-to-vcf.rb
xing-vpim-0.658.1 samples/mutt-aliases-to-vcf.rb
vpim-13.11.11 samples/mutt-aliases-to-vcf.rb
vpim2-0.0.1 samples/mutt-aliases-to-vcf.rb
vpim-rails-reinteractive-0.7 samples/mutt-aliases-to-vcf.rb
vpim-rails-0.665 samples/mutt-aliases-to-vcf.rb
thoughtafter-vpim-0.7.0.1 samples/mutt-aliases-to-vcf.rb
vpim-rails-0.664 samples/mutt-aliases-to-vcf.rb
vpim-rails-0.663 samples/mutt-aliases-to-vcf.rb
vpim-rails-0.662 samples/mutt-aliases-to-vcf.rb
scashin133-vpim-9.4.0 samples/mutt-aliases-to-vcf.rb
vpim-rails-0.661 samples/mutt-aliases-to-vcf.rb
mumboe-vpim-0.7 samples/mutt-aliases-to-vcf.rb
mumboe-vpim-0.695 samples/mutt-aliases-to-vcf.rb
fairtilizer-vpim-0.695 samples/mutt-aliases-to-vcf.rb
vpim-0.619 samples/mutt-aliases-to-vcf.rb