Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed bug pertaining to Riak API changes. Cleaned up metafiles and bu…

…mped to version 0.0.5.
  • Loading branch information...
commit 1f834ba67d1ee60f56520e0851e2189354fefcfc 1 parent 91836ba
@mikeric authored
View
6 Gemfile
@@ -1,5 +1,5 @@
source :gemcutter
-gem "dm-core", ">= 0.10.2"
-gem "ripple", ">= 0.1.2"
-gem "rspec", "~> 1.3.0"
+gem "dm-core", "~> 1.0.0"
+gem "riak-client", "~> 0.8.0"
+gem "rspec"
View
10 README.md
@@ -14,12 +14,12 @@ Install the **dm-riak-adapter** gem:
## Synopsis
-Require **dm-core** and **dm-riak-adapter**. Tell DataMapper to use the Riak adapter and set a namespace for your app. This namespace will prefix each bucket like `myapp:projects` `myapp:tasks`. Skip setting a namespace and the buckets will have no prefix.
+Require **dm-core** and **dm-riak-adapter**. Tell DataMapper to use the Riak adapter and set a namespace for your app. This namespace will prefix each bucket like `todo:projects` `todo:tasks`. Skip setting a namespace and the buckets will have no prefix.
require 'dm-core'
require 'dm-riak-adapter'
- DataMapper.setup :default, :adapter => 'riak', :namespace => 'myapp'
+ DataMapper.setup :default, :adapter => 'riak', :namespace => 'todo'
Continue defining your models and properties as you normally would. Set a property as type `Key` to use Riak's server-assigned UUIDs.
@@ -43,6 +43,6 @@ Continue defining your models and properties as you normally would. Set a proper
## Resources
-- [Documentation](http://yardoc.org/docs/mikeric-dm-riak-adapter/DataMapper/Adapters/RiakAdapter)
-- [Metrics](http://getcaliper.com/caliper/project?repo=http://rubygems.org/gems/dm-riak-adapter)
-- [Gems](http://rubygems.org/gems/dm-riak-adapter)
+- [GitHub](http://github.com/mikeric/dm-riak-adapter)
+- [RubyDoc](http://rubydoc.info/github/mikeric/dm-riak-adapter/master/frames)
+- [RubyGems](http://rubygems.org/gems/dm-riak-adapter)
View
42 dm-riak-adapter.gemspec
@@ -1,14 +1,17 @@
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
- s.name = %q{dm-riak-adapter}
- s.version = "0.0.4"
+ s.name = "dm-riak-adapter"
+ s.version = "0.0.5"
+ s.authors = ["Mike Richards"]
+ s.date = "2010-11-07"
+ s.description = "DataMapper adapter for Riak"
+ s.summary = "DataMapper adapter for Riak"
+ s.homepage = "http://github.com/mikeric/dm-riak-adapter"
+ s.email = "mike22e@gmail.com"
+
+ s.require_path = "lib"
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
- s.authors = ["Mike Richards"]
- s.date = %q{2010-04-06}
- s.description = %q{DataMapper Adapter for Riak}
- s.email = %q{mike22e@gmail.com}
s.files = [
"README.md",
"lib/dm-riak-adapter.rb",
@@ -17,28 +20,15 @@ Gem::Specification.new do |s|
"spec/dm-riak-adapter_spec.rb",
"spec/spec_helper.rb"
]
- s.homepage = %q{http://github.com/mikeric/dm-riak-adapter}
- s.require_paths = ["lib"]
- s.rubygems_version = %q{1.3.5}
- s.summary = %q{DataMapper Adapter for Riak}
+
s.test_files = [
"spec/dm-riak-adapter_spec.rb",
"spec/spec_helper.rb"
]
- if s.respond_to? :specification_version then
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
- s.specification_version = 2
-
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
- s.add_runtime_dependency(%q<dm-core>, [">= 0.10.2"])
- s.add_runtime_dependency(%q<ripple>, [">= 0"])
- else
- s.add_dependency(%q<dm-core>, [">= 0.10.2"])
- s.add_dependency(%q<ripple>, [">= 0"])
- end
- else
- s.add_dependency(%q<dm-core>, [">= 0.10.2"])
- s.add_dependency(%q<ripple>, [">= 0"])
- end
+ s.required_rubygems_version = ">= 1.3.6"
+
+ s.add_dependency "dm-core", ["~> 1.0.0"]
+ s.add_dependency "riak-client", ["~> 0.8.0"]
+ s.add_development_dependency "rspec"
end
View
17 lib/dm-riak-adapter/adapter.rb
@@ -34,7 +34,7 @@ def initialize(name, options)
# @return [Integer]
# Number of objects created
def create(resources)
- create_objects(resources)
+ create_objects resources
end
# Reads one or many resources from a datastore
@@ -70,9 +70,9 @@ def read(query)
# Number of records updated
def update(attributes, collection)
attributes = attributes_as_fields(attributes)
-
objects_for(collection.query.model).each {|r| r.update(attributes)}
- update_objects(collection)
+
+ update_objects collection
end
# Deletes one or many existing resources
@@ -86,7 +86,7 @@ def update(attributes, collection)
# @return [Integer]
# Number of records deleted
def delete(collection)
- delete_objects(collection)
+ delete_objects collection
end
# Flushes the bucket for the specified model
@@ -106,7 +106,7 @@ def flush(model)
private
def bucket(model)
- @riak.bucket(@namespace + model.storage_name)
+ @riak.bucket @namespace + model.storage_name
end
def objects_for(model)
@@ -115,8 +115,9 @@ def objects_for(model)
def create_objects(resources)
resources.each do |resource|
- object = bucket(resource.model).new.store
- initialize_serial(resource, object.key)
+ object = bucket(resource.model).new
+ object.data = {}
+ initialize_serial resource, object.store.key
object.data = resource.attributes(:field)
object.store
end
@@ -137,5 +138,5 @@ def delete_objects(resources)
end
end
- const_added(:RiakAdapter)
+ const_added :RiakAdapter
end
Please sign in to comment.
Something went wrong with that request. Please try again.