Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

rip out a bunch of node stuff not compatible with the Record resource…

…_path, to be revisited
  • Loading branch information...
commit e03deee1a2e5d37cc622af3fbd51243e8bf00525 1 parent 2587177
@fujin fujin authored
View
8 lib/dynect_rest.rb
@@ -130,13 +130,7 @@ def self.underscore(string)
##
%w{AAAA A CNAME DNSKEY DS KEY LOC MX NS PTR RP SOA SRV TXT}.each do |record_type|
define_method underscore(record_type) do
- DynectRest::Resource.new(self,"#{record_type}Record" , @zone)
- end
- end
-
- %w{Node NodeList}.each do |type|
- define_method underscore(type) do
- DynectRest::Resource.new(self,"#{type}" , @zone)
+ DynectRest::Resource.new(self,"#{record_type}" , @zone)
end
end
View
29 lib/dynect_rest/resource.rb
@@ -6,9 +6,9 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
-#
+#
# http://www.apache.org/licenses/LICENSE-2.0
-#
+#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -25,13 +25,13 @@ def initialize(dynect, record_type, zone, fqdn=nil, record_id=nil, ttl=nil, rdat
@dynect = dynect
@record_type = record_type
@fqdn = fqdn
- @record_id = record_id
- @ttl = ttl
+ @record_id = record_id
+ @ttl = ttl
@zone = zone
- @rdata = rdata
+ @rdata = rdata
end
- def [](rdata_key)
+ def [](rdata_key)
@rdata[rdata_key]
end
@@ -42,7 +42,7 @@ def []=(rdata_key, rdata_value)
def fqdn(value=nil)
value ? (@fqdn = value; self) : @fqdn
end
-
+
def record_id(value=nil)
value ? (@record_id = value; self) : @record_id
end
@@ -53,7 +53,7 @@ def ttl(value=nil)
def resource_path(full=false)
@record_type << "Record" unless @record_type[-6,6] == "Record"
- if (full == true || full == :full)
+ if (full == true || full == :full)
"/REST/#{@record_type}/#{@zone}"
else
"#{@record_type}/#{@zone}"
@@ -64,7 +64,7 @@ def get(fqdn = nil, record_id=nil)
if record_id && fqdn
raw_rr = @dynect.get("#{resource_path}/#{fqdn}/#{record_id}")
DynectRest::Resource.new(dynect,
- raw_rr["record_type"] + 'Record',
+ raw_rr["record_type"],
raw_rr["zone"],
raw_rr["fqdn"],
raw_rr["record_id"],
@@ -80,10 +80,10 @@ def get(fqdn = nil, record_id=nil)
end
end
case raw_rr_list.length
- when 0
- raise DynectRest::Exceptions::RequestFailed, "Cannot find #{record_type} record for #{fqdn}"
- when 1
- raw_rr_list[0]
+ when 0
+ raise DynectRest::Exceptions::RequestFailed, "Cannot find #{record_type} record for #{fqdn}"
+ when 1
+ raw_rr_list[0]
else
raw_rr_list
end
@@ -108,7 +108,7 @@ def save(replace=false)
else
if replace == true || replace == :replace
@dynect.put("#{resource_path}/#{@fqdn}", self)
- else
+ else
@dynect.post("#{resource_path}/#{@fqdn}", self)
end
end
@@ -146,4 +146,3 @@ def method_missing(method_symbol, *args, &block)
end
end
-
View
10 spec/dynect_rest_spec.rb
@@ -74,14 +74,4 @@
subject { d.txt }
its(:resource_path) { should == 'TXTRecord/zone' }
end
-
- describe "node_list" do
- subject { d.node_list }
- its(:resource_path) { should == 'NodeList/zone' }
- end
-
- describe "node" do
- subject { d.node }
- its(:resource_path) { should == 'Node/zone' }
- end
end
Please sign in to comment.
Something went wrong with that request. Please try again.