lib/aipp/parser.rb in aipp-0.2.2 vs lib/aipp/parser.rb in aipp-0.2.3

- old
+ new

@@ -10,20 +10,24 @@ attr_reader :config # @return [AIXM::Document] target document attr_reader :aixm + # @return [Hash] map from border names to border objects + attr_reader :borders + # @return [OpenStruct] object cache attr_reader :cache def initialize(options:) @options = options @options[:storage] = options[:storage].join(options[:region]) @options[:storage].mkpath unless @options[:storage].exist? @config = {} @aixm = AIXM.document(region: @options[:region], effective_at: @options[:airac].date) @dependencies = THash.new + @borders = {} @cache = OpenStruct.new end # Read the configuration from config.yml. def read_config @@ -36,12 +40,19 @@ # Read the region directory and build the dependency list. def read_region info("Reading region #{options[:region]}") dir = Pathname(__FILE__).dirname.join('regions', options[:region]) fail("unknown region `#{options[:region]}'") unless dir.exist? + # Borders + dir.glob('borders/*.geojson').each do |file| + border = AIPP::Border.new(file) + @borders[border.name] = border + end + # Helpers dir.glob('helpers/*.rb').each { |f| require f } + # Parsers dir.glob('*.rb').each do |file| - debug("Requiring #{file.basename}") + verbose_info "Requiring #{file.basename}" require file aip = file.basename('.*').to_s @dependencies[aip] = ("AIPP::%s::%s::DEPENDS" % [options[:region], aip.remove(/\W/).classify]).constantize end end