Sha256: 76dc3bf06bd634177b195f78ab6558da92b3527ef4c0084e4ac695c3e53a846c

Contents?: true

Size: 1.1 KB

Versions: 35

Compression:

Stored size: 1.1 KB

Contents

require 'polyglot'
require 'treetop'

require 'fig/grammar'
require 'fig/logging'
require 'fig/packageerror'
require 'fig/repository'
require 'fig/urlaccesserror'

module Fig
  class Parser
    def initialize(application_config)
      @parser = FigParser.new
      @application_config = application_config
    end

    def parse_package(package_name, version_name, directory, input)
      input = input.gsub(/#.*$/, '')
      result = @parser.parse(" #{input} ")
      if result.nil?
        Logging.fatal "#{directory}: #{@parser.failure_reason}"
        raise PackageError.new("#{directory}: #{@parser.failure_reason}")
      end
      package = result.to_package(package_name, version_name, directory)
      bad_urls = []
      package.walk_statements do |statement|
        statement.urls.each do |url|
          # collect all bad urls in bad_urls
          next if not Repository.is_url?(url)
          bad_urls << url if not @application_config.url_access_allowed?(url)
        end
      end
      raise URLAccessError.new(bad_urls, package_name, version_name) if not bad_urls.empty?
      return package
    end
  end
end

Version data entries

35 entries across 35 versions & 2 rubygems

Version Path
fig18-0.1.50-i386-mswin32 lib/fig/parser.rb
fig18-0.1.50 lib/fig/parser.rb
fig-0.1.50-java lib/fig/parser.rb
fig-0.1.50 lib/fig/parser.rb
fig18-0.1.50-i386-mingw32 lib/fig/parser.rb
fig-0.1.49-java lib/fig/parser.rb
fig-0.1.49 lib/fig/parser.rb
fig18-0.1.49 lib/fig/parser.rb
fig18-0.1.49-i386-mswin32 lib/fig/parser.rb
fig18-0.1.49-i386-mingw32 lib/fig/parser.rb
fig18-0.1.48 lib/fig/parser.rb
fig18-0.1.48-i386-mswin32 lib/fig/parser.rb
fig18-0.1.48-i386-mingw32 lib/fig/parser.rb
fig-0.1.48 lib/fig/parser.rb
fig-0.1.48-java lib/fig/parser.rb
fig18-0.1.47 lib/fig/parser.rb
fig18-0.1.47-i386-mswin32 lib/fig/parser.rb
fig18-0.1.47-i386-mingw32 lib/fig/parser.rb
fig-0.1.47 lib/fig/parser.rb
fig-0.1.47-java lib/fig/parser.rb