Class: NominetEPP::RequestExtension
- Inherits:
-
Object
- Object
- NominetEPP::RequestExtension
show all
- Defined in:
- lib/nominet-epp/request.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Instance Attribute Details
#namespaces ⇒ Object
Returns the value of attribute namespaces.
35
36
37
|
# File 'lib/nominet-epp/request.rb', line 35
def namespaces
@namespaces
end
|
Instance Method Details
#namespace_name ⇒ Object
44
45
46
47
48
49
50
51
|
# File 'lib/nominet-epp/request.rb', line 44
def namespace_name
case namespace_uri
when /\Aurn\:/
namespace_uri.split(':').last.split('-',2).first.to_sym
else
namespace_uri.split('/').last.split('-')[0...-1].join('-').to_sym
end
end
|
#namespace_uri ⇒ Object
41
42
43
|
# File 'lib/nominet-epp/request.rb', line 41
def namespace_uri
raise NotImplementedError
end
|
#schema_name(urn) ⇒ String
Returns the name of the given schema
97
98
99
100
101
102
103
104
|
# File 'lib/nominet-epp/request.rb', line 97
def schema_name(urn)
case urn
when /\Aurn\:/
urn.split(':').last
else
urn.split('/').last
end
end
|
#schemaLocation ⇒ Object
53
54
55
|
# File 'lib/nominet-epp/request.rb', line 53
def schemaLocation
"#{namespace_uri} #{schema_name(namespace_uri)}.xsd"
end
|
#set_namespaces(namespaces) ⇒ Object
37
38
39
|
# File 'lib/nominet-epp/request.rb', line 37
def set_namespaces(namespaces)
@namespaces = namespaces
end
|
#x_namespace(node, name = namespace_name, ns = namespace_uri) ⇒ Object
83
84
85
86
|
# File 'lib/nominet-epp/request.rb', line 83
def x_namespace(node, name = namespace_name, ns = namespace_uri)
return @namespaces[name] if @namespaces.has_key?(name)
@namespaces[name] = xml_namespace(node, name, ns)
end
|
#x_node(name, value = nil) ⇒ Object
77
78
79
80
81
|
# File 'lib/nominet-epp/request.rb', line 77
def x_node(name, value = nil)
node = xml_node(name, value)
node.namespaces.namespace = x_namespace(node)
node
end
|
#x_schemaLocation(node, sL = schemaLocation) ⇒ Object
88
89
90
91
|
# File 'lib/nominet-epp/request.rb', line 88
def x_schemaLocation(node, sL = schemaLocation)
xattr = XML::Attr.new(node, "schemaLocation", sL)
xattr.namespaces.namespace = x_namespace(node, 'xsi', 'http://www.w3.org/2001/XMLSchema-instance')
end
|
#xml_namespace(node, name, uri, namespaces = {}) ⇒ XML::Namespace
Creates and returns a new XML namespace
73
74
75
|
# File 'lib/nominet-epp/request.rb', line 73
def xml_namespace(node, name, uri, namespaces = {})
XML::Namespace.new(node, name, uri)
end
|
#xml_node(name, value = nil) ⇒ XML::Node
Creates and returns a new XML node
63
64
65
|
# File 'lib/nominet-epp/request.rb', line 63
def xml_node(name, value = nil)
XML::Node.new(name, value)
end
|