Sha256: b6b2b94a9dd8fd7cf98d6d26045b224dd198379d6c4c0b310cc7a6ecaee85227

Contents?: true

Size: 766 Bytes

Versions: 3

Compression:

Stored size: 766 Bytes

Contents

require 'timezone/parser/rule'
require 'timezone/parser/data'
require 'timezone/parser/zone'
require 'timezone/parser/zone/data_generator'

module Timezone
  module Parser
    COMMENT_REGEXP = /^\s*#/
    RULE_REGEXP    = /^Rule/
    LINK_REGEXP    = /^Link/
    ZONE_REGEXP    = /^Zone/

    def self.parse(file)
      IO.readlines(file).map(&:strip).each do |line|
        if line =~ COMMENT_REGEXP
          next
        elsif line =~ RULE_REGEXP
          rule(line)
        elsif line =~ LINK_REGEXP
          # TODO [panthomakos] Need to add linking.
        elsif line =~ ZONE_REGEXP || (line != '' && !line.nil?)
          zone(line)
        else
          Timezone::Parser::Zone.generate(Timezone::Parser::Zone.last)
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
timezone-0.3.2 lib/timezone/parser.rb
timezone-0.3.1 lib/timezone/parser.rb
timezone-0.3.0 lib/timezone/parser.rb