Browse files

Fix typos

 * Rename instances of 'aquire' to 'acquire'.
  • Loading branch information...
1 parent 39d2542 commit 0dbbaf9eaf6269b3f85a640828328ba7e0eaf4c6 @myabc myabc committed Aug 26, 2008
View
34 data_objects/lib/data_objects/support/pooling.rb
@@ -9,7 +9,7 @@ class Object
# because instances are keeped in memory reused.
#
# Classes that include Pooling module have re-defined new
- # method that returns instances aquired from pool.
+ # method that returns instances acquired from pool.
#
# Term resource is used for any type of poolable objects
# and should NOT be thought as DataMapper Resource or
@@ -43,18 +43,18 @@ def initialize_pool(size_limit, options = {})
end
# ==== Notes
- # Instances of poolable resource are aquired from
+ # Instances of poolable resource are acquired from
# pool. This quires a new instance from pool and
# returns it.
#
# ==== Returns
- # Resource instance aquired from the pool.
+ # Resource instance acquired from the pool.
#
# ==== Raises
# ArgumentError:: when pool is exhausted and no instance
- # can be aquired.
+ # can be acquired.
def new
- pool.aquire
+ pool.acquire
end
# ==== Notes
@@ -118,20 +118,20 @@ def size
end
# ==== Notes
- # Indicates if pool has resources to aquire.
+ # Indicates if pool has resources to acquire.
#
# ==== Returns
- # <Boolean>:: true if pool has resources can be aquired,
+ # <Boolean>:: true if pool has resources can be acquired,
# false otherwise.
def available?
@reserved.size < size_limit
end
# ==== Notes
- # Aquires last used available resource and returns it.
+ # Acquires last used available resource and returns it.
# If no resources available, current implementation
# throws an exception.
- def aquire
+ def acquire
@lock.synchronize do
if available?
instance = prepair_available_resource
@@ -145,10 +145,10 @@ def aquire
end
# ==== Notes
- # Releases previously aquired instance.
+ # Releases previously acquired instance.
#
# ==== Parameters
- # instance <Anything>:: previosly aquired instance.
+ # instance <Anything>:: previosly acquired instance.
#
# ==== Raises
# RuntimeError:: when given not pooled instance.
@@ -178,12 +178,12 @@ def flush!
end
# ==== Notes
- # Check if instance has been aquired from the pool.
+ # Check if instance has been acquired from the pool.
#
# ==== Returns
- # <Boolean>:: true if given resource instance has been aquired from pool,
+ # <Boolean>:: true if given resource instance has been acquired from pool,
# false otherwise.
- def aquired?(instance)
+ def acquired?(instance)
@reserved.include?(instance)
end
@@ -208,7 +208,7 @@ def release_outdated
# ==== Returns
# <Boolean>:: true if instance should be released, false otherwise.
def time_to_release?(instance)
- (Time.now - instance.instance_variable_get("@__pool_aquire_timestamp")) > @expiration_period
+ (Time.now - instance.instance_variable_get("@__pool_acquire_timestamp")) > @expiration_period
end
protected
@@ -220,13 +220,13 @@ def time_to_release?(instance)
def prepair_available_resource
if @available.size > 0
res = @available.pop
- res.instance_variable_set("@__pool_aquire_timestamp", Time.now)
+ res.instance_variable_set("@__pool_acquire_timestamp", Time.now)
res
else
res = @class_of_resources.allocate
res.send(:initialize, *@initialization_args)
- res.instance_variable_set("@__pool_aquire_timestamp", Time.now)
+ res.instance_variable_set("@__pool_acquire_timestamp", Time.now)
res
end
View
8 data_objects/spec/connection_spec.rb
@@ -49,7 +49,7 @@ class MyConnection < DataObjects::Connection; end
uri.path.should == '/database'
end
- it "should accept a conneciton uri as a Addressable::URI" do
+ it "should accept a connection uri as a Addressable::URI" do
c = DataObjects::Connection.new(Addressable::URI::parse('mock://localhost/database'))
# relying on the fact that mock connection sets @uri
uri = c.instance_variable_get("@uri")
@@ -58,17 +58,17 @@ class MyConnection < DataObjects::Connection; end
uri.to_s.should == 'mock://localhost/database'
end
- it "should determine which DataObject adapter from the uri scheme" do
+ it "should determine which DataObject adapter to use from the uri scheme" do
DataObjects::Mock::Connection.should_receive(:__new)
DataObjects::Connection.new('mock://localhost/database')
end
- it "should determine which DataObject adapter from a JDBC URL scheme" do
+ it "should determine which DataObject adapter to use from a JDBC URL scheme" do
DataObjects::Mock::Connection.should_receive(:__new)
DataObjects::Connection.new('jdbc:mock://localhost/database')
end
- it "should aquire a connection" do
+ it "should acquire a connection" do
uri = Addressable::URI.parse('mock://localhost/database')
DataObjects::Mock::Connection.should_receive(:__new).with(uri)
View
64 data_objects/spec/support/pooling_spec.rb
@@ -33,8 +33,8 @@ class UndisposableResource
@pool.should respond_to(:flush!)
end
- it "responds to aquire" do
- @pool.should respond_to(:aquire)
+ it "responds to acquire" do
+ @pool.should respond_to(:acquire)
end
it "responds to release" do
@@ -100,7 +100,7 @@ class UndisposableResource
-describe "Aquire from contant size pool" do
+describe "Acquire from constant size pool" do
before :each do
DisposableResource.initialize_pool(2)
end
@@ -110,53 +110,53 @@ class UndisposableResource
end
it "increased size of the pool" do
- @time = DisposableResource.pool.aquire
+ @time = DisposableResource.pool.acquire
DisposableResource.pool.size.should == 1
end
it "places initialized instance in the reserved set" do
- @time = DisposableResource.pool.aquire
+ @time = DisposableResource.pool.acquire
DisposableResource.pool.instance_variable_get("@reserved").size.should == 1
end
it "raises an exception when pool size limit is hit" do
- @t1 = DisposableResource.pool.aquire
- @t2 = DisposableResource.pool.aquire
+ @t1 = DisposableResource.pool.acquire
+ @t2 = DisposableResource.pool.acquire
- lambda { DisposableResource.pool.aquire }.should raise_error(RuntimeError)
+ lambda { DisposableResource.pool.acquire }.should raise_error(RuntimeError)
end
it "returns last released resource" do
- @t1 = DisposableResource.pool.aquire
- @t2 = DisposableResource.pool.aquire
+ @t1 = DisposableResource.pool.acquire
+ @t2 = DisposableResource.pool.acquire
DisposableResource.pool.release(@t1)
- DisposableResource.pool.aquire.should == @t1
+ DisposableResource.pool.acquire.should == @t1
end
it "really truly returns last released resource" do
- @t1 = DisposableResource.pool.aquire
+ @t1 = DisposableResource.pool.acquire
DisposableResource.pool.release(@t1)
- @t2 = DisposableResource.pool.aquire
+ @t2 = DisposableResource.pool.acquire
DisposableResource.pool.release(@t2)
- @t3 = DisposableResource.pool.aquire
+ @t3 = DisposableResource.pool.acquire
DisposableResource.pool.release(@t3)
- DisposableResource.pool.aquire.should == @t1
+ DisposableResource.pool.acquire.should == @t1
@t1.should == @t3
end
it "sets allocation timestamp on resource instance" do
@t1 = DisposableResource.new
- @t1.instance_variable_get("@__pool_aquire_timestamp").should be_close(Time.now, 2)
+ @t1.instance_variable_get("@__pool_acquire_timestamp").should be_close(Time.now, 2)
end
end
-describe "Releasing from contant size pool" do
+describe "Releasing from constant size pool" do
before :each do
DisposableResource.initialize_pool(2)
end
@@ -166,8 +166,8 @@ class UndisposableResource
end
it "decreases size of the pool" do
- @t1 = DisposableResource.pool.aquire
- @t2 = DisposableResource.pool.aquire
+ @t1 = DisposableResource.pool.acquire
+ @t2 = DisposableResource.pool.acquire
DisposableResource.pool.release(@t1)
DisposableResource.pool.size.should == 1
@@ -182,42 +182,42 @@ class UndisposableResource
end
it "disposes released object" do
- @t1 = DisposableResource.pool.aquire
+ @t1 = DisposableResource.pool.acquire
@t1.should_receive(:dispose)
DisposableResource.pool.release(@t1)
end
it "removes released object from reserved set" do
- @t1 = DisposableResource.pool.aquire
+ @t1 = DisposableResource.pool.acquire
lambda {
DisposableResource.pool.release(@t1)
}.should change(DisposableResource.pool.instance_variable_get("@reserved"), :size).by(-1)
end
it "returns released object back to available set" do
- @t1 = DisposableResource.pool.aquire
+ @t1 = DisposableResource.pool.acquire
lambda {
DisposableResource.pool.release(@t1)
}.should change(DisposableResource.pool.instance_variable_get("@available"), :size).by(1)
end
- it "updates aquire timestamp on already allocated resource instance" do
- # aquire it once
+ it "updates acquire timestamp on already allocated resource instance" do
+ # acquire it once
@t1 = DisposableResource.new
# wait a bit
sleep 3
# check old timestamp
- @t1.instance_variable_get("@__pool_aquire_timestamp").should be_close(Time.now, 4)
+ @t1.instance_variable_get("@__pool_acquire_timestamp").should be_close(Time.now, 4)
- # re-aquire
+ # re-acquire
DisposableResource.pool.release(@t1)
@t1 = DisposableResource.new
# see timestamp is updated
- @t1.instance_variable_get("@__pool_aquire_timestamp").should be_close(Time.now, 2)
+ @t1.instance_variable_get("@__pool_acquire_timestamp").should be_close(Time.now, 2)
end
end
@@ -238,15 +238,15 @@ class UndisposableResource
end
it "returns false when pool is exhausted" do
- # aquires the last available resource
+ # acquires the last available resource
DisposableResource.new
DisposableResource.pool.should_not be_available
end
end
-describe "Flushing of contant size pool" do
+describe "Flushing of constant size pool" do
before :each do
DisposableResource.initialize_pool(2)
@@ -291,10 +291,10 @@ class UndisposableResource
DisposableResource.instance_variable_set("@__pool", nil)
end
- it "aquires new instances from pool" do
+ it "acquires new instances from pool" do
@instance_one = DisposableResource.new
- DisposableResource.pool.aquired?(@instance_one).should be(true)
+ DisposableResource.pool.acquired?(@instance_one).should be(true)
end
it "flushed existing pool on re-initialization" do
@@ -344,7 +344,7 @@ class UndisposableResource
DisposableResource.instance_variable_set("@__pool", nil)
end
- it "returns true when object's last aquisition time is greater than limit" do
+ it "returns true when object's last acquisition time is greater than limit" do
@t1 = DisposableResource.new
DisposableResource.pool.time_to_release?(@t1).should be(false)

0 comments on commit 0dbbaf9

Please sign in to comment.