Skip to content
Browse files

Add Gemfile.

Add an example.rb and pointer to it from the readme.
  • Loading branch information...
1 parent 7c9d619 commit 075713517292b182458c0f97d3062e354676ec1d @fairchild fairchild committed Jun 5, 2011
Showing with 72 additions and 1 deletion.
  1. +14 −0 Gemfile
  2. +30 −0 Gemfile.lock
  3. +1 −1 README.rdoc
  4. +27 −0 example.rb
View
14 Gemfile
@@ -0,0 +1,14 @@
+source 'http://rubygems.org'
+
+gem 'rest-client', :require=>"rest_client"
+gem 'json'
+
+
+group :development do
+ gem 'rake'
+ gem "rspec", "~> 2.0.0"
+ gem "yard"
+end
+
+
+
View
30 Gemfile.lock
@@ -0,0 +1,30 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ diff-lcs (1.1.2)
+ json (1.5.1)
+ mime-types (1.16)
+ rake (0.9.1)
+ rest-client (1.6.3)
+ mime-types (>= 1.16)
+ rspec (2.0.1)
+ rspec-core (~> 2.0.1)
+ rspec-expectations (~> 2.0.1)
+ rspec-mocks (~> 2.0.1)
+ rspec-core (2.0.1)
+ rspec-expectations (2.0.1)
+ diff-lcs (>= 1.1.2)
+ rspec-mocks (2.0.1)
+ rspec-core (~> 2.0.1)
+ rspec-expectations (~> 2.0.1)
+ yard (0.7.1)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ json
+ rake
+ rest-client
+ rspec (~> 2.0.0)
+ yard
View
2 README.rdoc
@@ -12,7 +12,7 @@ Since this is 90% of what you'll be doing, we make it easy.
dyn.cname.fqdn("something.example.com").cname("ec2-10-10-10-10.amazonaws.com").save
dyn.publish
-Will add an A record and a CNAME. You can use the chained method syntax for every resource record - we map unknown methods to the resource data you make in the call.
+Will add an A record and a CNAME. You can use the chained method syntax for every resource record - we map unknown methods to the resource data you make in the call. See [example.rb] for an executable example using environment variables.
== Everything else
View
27 example.rb
@@ -0,0 +1,27 @@
+require 'dynect_rest'
+
+DYNECT_CUST = ENV['DYNECT_CUST'] || 'customer'
+DYNECT_USER = ENV['DYNECT_USER'] || 'user'
+DYNECT_PASS = ENV['DYNECT_PASS'] || 'secretword'
+DYNECT_ZONE = ENV['DYNECT_ZONE'] || 'example.com'
+
+@dyn = DynectRest.new(DYNECT_CUST, DYNECT_USER, DYNECT_PASS, DYNECT_ZONE, true)
+
+# Create or Update an A Record for the given host
+host = "example.#{DYNECT_ZONE}"
+@record = @dyn.a.fqdn(host)
+if @record.get(host)
+ @dyn.a.fqdn(host).ttl(300).address("10.4.5.254").save(true)
+ # the true flag will use a put instead of a post. This is required if you want to be able to update, as welll as create
+else
+ @dyn.a.fqdn(host).ttl(300).address("10.4.5.254").save(false)
+end
+
+# Create a new cname record
+@dyn.cname.fqdn("example-cname.#{DYNECT_ZONE}").cname("ec2-10-10-10-10.amazonaws.com").save
+
+@dyn.publish
+@dyn.logout
+
+
+

0 comments on commit 0757135

Please sign in to comment.
Something went wrong with that request. Please try again.