BigW Consortium Gitlab

dependency_manager.rb 687 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
module BlobViewer
  class DependencyManager < Base
    include Auxiliary

    self.partial_name = 'dependency_manager'
    self.binary = false

    def manager_name
      raise NotImplementedError
    end

    def manager_url
      raise NotImplementedError
    end

    def package_type
      'package'
    end

    def package_name
      nil
    end

    def package_url
      nil
    end

    private

    def package_name_from_json(key)
      prepare!

      JSON.parse(blob.data)[key] rescue nil
    end

    def package_name_from_method_call(name)
      prepare!

      match = blob.data.match(/#{name}\s*=\s*["'](?<name>[^"']+)["']/)
      match[:name] if match
    end
  end
end