Skip to content

Commit

Permalink
Renamed #uri to #normilize_uri on AbstractAdapter. Exposed @uri read …
Browse files Browse the repository at this point in the history
…only as uri
  • Loading branch information
Guy van den Berg committed Apr 13, 2008
1 parent 5d74448 commit a535182
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
9 changes: 5 additions & 4 deletions lib/data_mapper/adapters/abstract_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module DataMapper
module Adapters
class AbstractAdapter
attr_reader :name
attr_reader :name, :uri
attr_accessor :resource_naming_convention, :field_naming_convention

# Methods dealing with a single resource object
Expand Down Expand Up @@ -49,8 +49,9 @@ def delete_set(repository, query)
# raise NotImplementedError
# raise ArgumentError unless block_given?
# end

def uri(uri_or_options)


def normilize_uri(uri_or_options)
uri_or_options
end

Expand All @@ -67,7 +68,7 @@ def initialize(name, uri_or_options)
raise ArgumentError, "+uri_or_options+ should be a Hash, a URI or a String but was #{uri_or_options.class}", caller unless [ Hash, URI, String ].any? { |k| k === uri_or_options }

@name = name
@uri = uri(uri_or_options)
@uri = normilize_uri(uri_or_options)

@resource_naming_convention = NamingConventions::UnderscoredAndPluralized
@field_naming_convention = NamingConventions::Underscored
Expand Down
2 changes: 1 addition & 1 deletion lib/data_mapper/adapters/data_objects_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ def property_to_column_name(model_name, property, qualify)

include SQL

def uri(uri_or_options)
def normilize_uri(uri_or_options)
uri_or_options = URI.parse(uri_or_options) if String === uri_or_options
return uri_or_options if URI === uri_or_options

Expand Down
8 changes: 4 additions & 4 deletions lib/data_mapper/adapters/sqlite3_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ def create_connection
return connnection
end

def uri(uri_or_options)
uri = super(uri_or_options)
uri.path = File.join(Dir.pwd, File.dirname(uri.path), File.basename(uri.path)) unless File.exists?(uri.path)
uri
def normilize_uri(uri_or_options)
uri = super(uri_or_options)
uri.path = File.join(Dir.pwd, File.dirname(uri.path), File.basename(uri.path)) unless File.exists?(uri.path)
uri
end
end # class Sqlite3Adapter

Expand Down
6 changes: 3 additions & 3 deletions spec/unit/adapters/data_objects_adapter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ class LittleBox
}

adapter = DataMapper::Adapters::DataObjectsAdapter.allocate
adapter.uri(options).should ==
adapter.normilize_uri(options).should ==
URI.parse("mysql://me:mypass@davidleal.com:5000/you_can_call_me_al?socket=nosock")
end

Expand All @@ -284,11 +284,11 @@ class LittleBox
}

adapter = DataMapper::Adapters::DataObjectsAdapter.allocate
adapter.uri(options).should == URI.parse("mysql:///you_can_call_me_al")
adapter.normilize_uri(options).should == URI.parse("mysql:///you_can_call_me_al")
end

it 'should accept the uri when no overrides exist' do
uri = URI.parse("protocol:///")
DataMapper::Adapters::DataObjectsAdapter.allocate.uri(uri).should == uri
DataMapper::Adapters::DataObjectsAdapter.allocate.normilize_uri(uri).should == uri
end
end

0 comments on commit a535182

Please sign in to comment.