Skip to content

Commit

Permalink
fixed so that the examples in the documentation works
Browse files Browse the repository at this point in the history
  • Loading branch information
bjornblomqvist committed Oct 7, 2011
1 parent 0390da6 commit ea977e8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
15 changes: 8 additions & 7 deletions lib/clouddns/domain.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,13 @@ def find_records(type)
# Shorthands to add new specific records
#

def a (name, options={}) ; add_record(options.merge(:name => name, :type => 'A')) ; end
def aaaa (name, options={}) ; add_record(options.merge(:name => name, :type => 'AAAA')) ; end
def cname(name, options={}) ; add_record(options.merge(:name => name, :type => 'CNAME')) ; end
def ns (name, options={}) ; add_record(options.merge(:name => name, :type => 'NS')) ; end
def mx (name, options={}) ; add_record(options.merge(:name => name, :type => 'MX')) ; end
def txt (name, options={}) ; add_record(options.merge(:name => name, :type => 'TXT')) ; end
def srv (name, options={}) ; add_record(options.merge(:name => name, :type => 'SRV')) ; end
def a (name, options={}) ; add_record(options.merge(name.is_a?(String) ? {:name => name} : name).merge(:type => 'A')) ; end
def aaaa (name, options={}) ; add_record(options.merge(name.is_a?(String) ? {:name => name} : name).merge(:type => 'AAAA')) ; end
def cname(name, options={}) ; add_record(options.merge(name.is_a?(String) ? {:name => name} : name).merge(:type => 'CNAME')) ; end
def ns (name, options={}) ; add_record(options.merge(name.is_a?(String) ? {:name => name} : name).merge(:type => 'NS')) ; end
def mx (name, options={}) ; add_record(options.merge(name.is_a?(String) ? {:name => name} : name).merge(:type => 'MX')) ; end
def txt (name, options={}) ; add_record(options.merge(name.is_a?(String) ? {:name => name} : name).merge(:type => 'TXT')) ; end
def srv (name, options={}) ; add_record(options.merge(name.is_a?(String) ? {:name => name} : name).merge(:type => 'SRV')) ; end

#
# Shorthands to get records by type
Expand All @@ -152,5 +152,6 @@ def srv_records ; find_records('SRC') ; end
def checksum
Digest::SHA1.hexdigest([@name, @email, @ttl].join)
end

end
end
6 changes: 6 additions & 0 deletions spec/domain_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,11 @@
domain.cname('dev.foobar.com', :data => 'www.foobar.com').cname?.should be_true
domain.mx('foobar.com', :priority => 10, :data => '127.0.0.1').mx?.should be_true
domain.ns('foobar.com', :data => 'ns.rackspace.com').ns?.should be_true

domain.a(:name => 'foo.com', :data => '127.0.0.1').a?.should be_true
domain.cname(:name => 'www.foo.com', :data => 'foo.com').cname?.should be_true
domain.ns(:name => 'ns.rackspace.com', :data => 'ns.rackspace.com').ns?.should be_true
domain.mx(:name => 'mail.foo.com', :data => 'mail.google.com', :priority => 10).mx?.should be_true

end
end

0 comments on commit ea977e8

Please sign in to comment.