Skip to content

Commit

Permalink
Latest preparations before release.
Browse files Browse the repository at this point in the history
  • Loading branch information
isabanin committed Nov 1, 2010
1 parent 0c59908 commit a7816c2
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 12 deletions.
4 changes: 4 additions & 0 deletions CHANGES.rdoc
@@ -1,5 +1,9 @@
= Changelog

== 0.2.0

* Added support for Jobs.

== 0.1.2

* Initial public release.
30 changes: 29 additions & 1 deletion README.rdoc
@@ -1,6 +1,6 @@
= dynectastic

Dynectastic is a nice little wrapper for Dynect's REST API. Use it to manage Zones, Records and Nodes on your Dynect account.
Dynectastic is a nice wrapper for Dynect's REST API. Use it to manage Zones, Records and Nodes on your Dynect account.

== Installation

Expand All @@ -20,6 +20,34 @@ Make sure to create a separate login/password pair for your API client or it wil

Now you can use this "dynect" object to call various API methods.

== Requests

You can always access most recent request of a resource by calling last_request on it:

zone.freeze
zone.last_request # => #<Dynectastic::Request:...>

Every request store it's response:

zone.last_request.response # => #<HTTParty::Response:...>

== Jobs

Every request to Dynect has a special Job assigned to it. You can access it like this:

zone.publish # => true
zone.last_request.job.id # => 343245
zone.last_request.job.complete? # => true

Sometimes a long running job can not be completed in time, so Dynectastic returns false as a result of your request:

zone.publish # => false
zone.last_request.job.id # => 342626
zone.last_request.job.complete? # => false

Since Dynect does not allow you to run several jobs simultaneously, sometimes your requests will return Dynectastic::SessionBusy exception.
Luckily there is a built-in retry cycle for such exceptions: Dynectastic will sleep for a few seconds and retry your request 5 more times.

== Zone examples

With Dynectastic you can find, create, freeze, unfreeze, publish and destroy zones:
Expand Down
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
0.1.2
0.2.0
11 changes: 7 additions & 4 deletions dynectastic.gemspec
Expand Up @@ -5,11 +5,11 @@

Gem::Specification.new do |s|
s.name = %q{dynectastic}
s.version = "0.1.2"
s.version = "0.2.0"

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Ilya Sabanin"]
s.date = %q{2010-10-29}
s.date = %q{2010-11-01}
s.description = %q{More or less complete set of tools for managing your Dynect zones, records and nodes via REST API.}
s.email = %q{ilya.sabanin@gmail.com}
s.extra_rdoc_files = [
Expand All @@ -35,14 +35,16 @@ Gem::Specification.new do |s|
"lib/dynectastic/factories/zone_factory.rb",
"lib/dynectastic/job.rb",
"lib/dynectastic/record.rb",
"lib/dynectastic/request.rb",
"lib/dynectastic/resource.rb",
"lib/dynectastic/session.rb",
"lib/dynectastic/zone.rb",
"test/helper.rb",
"test/test_job.rb",
"test/test_node_factory.rb",
"test/test_record.rb",
"test/test_record_factory.rb",
"test/test_request.rb",
"test/test_resource.rb",
"test/test_session.rb",
"test/test_zone.rb",
"test/test_zone_factory.rb"
Expand All @@ -54,10 +56,11 @@ Gem::Specification.new do |s|
s.summary = %q{Neat wrapper for Dynect REST API.}
s.test_files = [
"test/helper.rb",
"test/test_job.rb",
"test/test_node_factory.rb",
"test/test_record.rb",
"test/test_record_factory.rb",
"test/test_request.rb",
"test/test_resource.rb",
"test/test_session.rb",
"test/test_zone.rb",
"test/test_zone_factory.rb"
Expand Down
2 changes: 1 addition & 1 deletion lib/dynectastic.rb
Expand Up @@ -3,7 +3,7 @@

module Dynectastic

VERSION = '0.1.2'
VERSION = '0.2.0'
API_URL = 'https://api2.dynect.net'
RETRIES = 5

Expand Down
2 changes: 1 addition & 1 deletion lib/dynectastic/request.rb
Expand Up @@ -31,7 +31,7 @@ def perform(*args)
rescue HTTParty::RedirectionTooDeep => e
if e.response.body.include?("/REST/Job")
memorize_response_data(e.response)
job
false
else
raise e
end
Expand Down
6 changes: 6 additions & 0 deletions lib/dynectastic/zone.rb
Expand Up @@ -17,19 +17,25 @@ def save
def publish
if factory.publish(name)
@published = true
else
job
end
end

def freeze
if factory.freeze(name)
@frozen = true
else
job
end
end

def unfreeze
if factory.unfreeze(name)
@frozen = false
true
else
job
end
end

Expand Down
8 changes: 4 additions & 4 deletions test/test_request.rb
Expand Up @@ -35,16 +35,16 @@ class TestRequest < Test::Unit::TestCase
})
end

should "return job" do
assert @request_result.kind_of?(Dynectastic::Job)
should "return false" do
assert_equal false, @request_result
end

should "flag resource with job_incomplete" do
assert @request_result.incomplete?
assert @long_running.last_request.job.incomplete?
end

should "memorize job_id" do
assert @request_result.id.kind_of?(Numeric)
assert @long_running.last_request.job.id.kind_of?(Numeric)
end

should "memorize response" do
Expand Down

0 comments on commit a7816c2

Please sign in to comment.