Sha256: 76e66f2eb9d5ae8f0dab66d53289786b7a993ed6bb74f0503ffd1413d9d57ee2

Contents?: true

Size: 1.48 KB

Versions: 16

Compression:

Stored size: 1.48 KB

Contents

module RGeoServer
  # A namespace is a uniquely identifiable grouping of feature types. A namespaces is identified by a prefix and a uri.
  class Namespace < ResourceInfo

    OBJ_ATTRIBUTES = {:enabled => 'enabled', :catalog => 'catalog', :name => 'prefix', :uri => 'uri' }
    OBJ_DEFAULT_ATTRIBUTES = {:enabled => 'true', :catalog => nil, :name => nil }

    define_attribute_methods OBJ_ATTRIBUTES.keys
    update_attribute_accessors OBJ_ATTRIBUTES

    @@route = "namespaces"
    @@resource_name = "namespace"

    def self.resource_name
      @@resource_name
    end

    def self.root_xpath
      "//#{@@route}/#{@@resource_name}"
    end

    def self.member_xpath
      "//#{resource_name}"
    end

    def route
      @@route  
    end

    def message
      builder = Nokogiri::XML::Builder.new do |xml|
        xml.namespace { 
          xml.prefix @name 
          xml.uri @uri
        }
      end
      return builder.doc.to_xml 
    end

    # @param [RGeoServer::Catalog] catalog
    # @param [Hash] options
    def initialize catalog, options
      super(catalog)
      _run_initialize_callbacks do
        @name = options[:name].strip
        @uri = options[:uri] if options[:uri]
      end        
      @route = route
    end

    def profile_xml_to_hash profile_xml
      doc = profile_xml_to_ng profile_xml 
      h = {
        'name' => doc.at_xpath('//namespace/prefix/text()').to_s,
        'uri' => doc.at_xpath('//namespace/uri/text()').to_s
      }.freeze
      h  
    end

  end
end 

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
rgeoserver-0.10.1 lib/rgeoserver/namespace.rb
rgeoserver-0.10.0 lib/rgeoserver/namespace.rb
rgeoserver-0.9.1 lib/rgeoserver/namespace.rb
rgeoserver-0.9.0 lib/rgeoserver/namespace.rb
rgeoserver-0.8.0 lib/rgeoserver/namespace.rb
rgeoserver-0.7.10 lib/rgeoserver/namespace.rb
rgeoserver-0.7.9 lib/rgeoserver/namespace.rb
rgeoserver-0.7.8 lib/rgeoserver/namespace.rb
rgeoserver-0.7.7 lib/rgeoserver/namespace.rb
rgeoserver-0.7.6 lib/rgeoserver/namespace.rb
rgeoserver-0.7.5 lib/rgeoserver/namespace.rb
rgeoserver-0.7.4 lib/rgeoserver/namespace.rb
rgeoserver-0.7.3 lib/rgeoserver/namespace.rb
rgeoserver-0.7.2 lib/rgeoserver/namespace.rb
rgeoserver-0.7.1 lib/rgeoserver/namespace.rb
rgeoserver-0.7 lib/rgeoserver/namespace.rb