Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

First cut of using bundler and getting everything working with v.latest

  • Loading branch information...
commit 6f473757137225b020726ead9c95d231a4ff6ce6 1 parent 7b280b7
@NZKoz authored
View
4 .gitignore
@@ -1,4 +1,6 @@
pkg
-cassandra_object.gemspec
.yardoc
doc/
+bin/*
+vendor/gems/*
+!vendor/gems/cache/
View
6 Gemfile
@@ -0,0 +1,6 @@
+git "git://github.com/rails/rails.git", :ref=>"abae712213f663b447d49e9b06001cf51e3b5811" do
+ gem "activesupport", "3.0.pre", :path=>"activesupport"
+ gem "activemodel", "3.0.pre", :path=>"activemodel"
+end
+gem "cassandra"
+gem "shoulda"
View
162 cassandra_object.gemspec
@@ -0,0 +1,162 @@
+# Generated by jeweler
+# DO NOT EDIT THIS FILE
+# Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
+# -*- encoding: utf-8 -*-
+
+Gem::Specification.new do |s|
+ s.name = %q{cassandra_object}
+ s.version = "0.4.0"
+
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
+ s.authors = ["Michael Koziarski"]
+ s.date = %q{2009-10-18}
+ s.description = %q{Gives you most of the familiarity of ActiveRecord, but with the scalability of cassandra.}
+ s.email = %q{michael@koziarski.com}
+ s.extra_rdoc_files = [
+ "LICENSE",
+ "README"
+ ]
+ s.files = [
+ "lib/cassandra_object.rb",
+ "lib/cassandra_object/associations.rb",
+ "lib/cassandra_object/associations/one_to_many.rb",
+ "lib/cassandra_object/associations/one_to_one.rb",
+ "lib/cassandra_object/attributes.rb",
+ "lib/cassandra_object/base.rb",
+ "lib/cassandra_object/callbacks.rb",
+ "lib/cassandra_object/collection.rb",
+ "lib/cassandra_object/cursor.rb",
+ "lib/cassandra_object/dirty.rb",
+ "lib/cassandra_object/identity.rb",
+ "lib/cassandra_object/identity/abstract_key_factory.rb",
+ "lib/cassandra_object/identity/key.rb",
+ "lib/cassandra_object/identity/natural_key_factory.rb",
+ "lib/cassandra_object/identity/uuid_key_factory.rb",
+ "lib/cassandra_object/indexes.rb",
+ "lib/cassandra_object/migrations.rb",
+ "lib/cassandra_object/persistence.rb",
+ "lib/cassandra_object/serialization.rb",
+ "lib/cassandra_object/validation.rb",
+ "test/basic_scenarios_test.rb",
+ "test/config/cassandra.in.sh",
+ "test/config/log4j.properties",
+ "test/config/storage-conf.xml",
+ "test/connection.rb",
+ "test/cursor_test.rb",
+ "test/dirty_test.rb",
+ "test/fixture_models.rb",
+ "test/identity/natural_key_factory_test.rb",
+ "test/index_test.rb",
+ "test/migration_test.rb",
+ "test/one_to_many_associations_test.rb",
+ "test/test_helper.rb",
+ "test/validation_test.rb",
+ "vendor/activemodel/CHANGELOG",
+ "vendor/activemodel/CHANGES",
+ "vendor/activemodel/README",
+ "vendor/activemodel/Rakefile",
+ "vendor/activemodel/examples/validations.rb",
+ "vendor/activemodel/lib/active_model.rb",
+ "vendor/activemodel/lib/active_model/attribute_methods.rb",
+ "vendor/activemodel/lib/active_model/conversion.rb",
+ "vendor/activemodel/lib/active_model/deprecated_error_methods.rb",
+ "vendor/activemodel/lib/active_model/dirty.rb",
+ "vendor/activemodel/lib/active_model/errors.rb",
+ "vendor/activemodel/lib/active_model/locale/en.yml",
+ "vendor/activemodel/lib/active_model/naming.rb",
+ "vendor/activemodel/lib/active_model/observing.rb",
+ "vendor/activemodel/lib/active_model/serialization.rb",
+ "vendor/activemodel/lib/active_model/serializers/json.rb",
+ "vendor/activemodel/lib/active_model/serializers/xml.rb",
+ "vendor/activemodel/lib/active_model/state_machine.rb",
+ "vendor/activemodel/lib/active_model/state_machine/event.rb",
+ "vendor/activemodel/lib/active_model/state_machine/machine.rb",
+ "vendor/activemodel/lib/active_model/state_machine/state.rb",
+ "vendor/activemodel/lib/active_model/state_machine/state_transition.rb",
+ "vendor/activemodel/lib/active_model/test_case.rb",
+ "vendor/activemodel/lib/active_model/validations.rb",
+ "vendor/activemodel/lib/active_model/validations/acceptance.rb",
+ "vendor/activemodel/lib/active_model/validations/confirmation.rb",
+ "vendor/activemodel/lib/active_model/validations/exclusion.rb",
+ "vendor/activemodel/lib/active_model/validations/format.rb",
+ "vendor/activemodel/lib/active_model/validations/inclusion.rb",
+ "vendor/activemodel/lib/active_model/validations/length.rb",
+ "vendor/activemodel/lib/active_model/validations/numericality.rb",
+ "vendor/activemodel/lib/active_model/validations/presence.rb",
+ "vendor/activemodel/lib/active_model/validations/with.rb",
+ "vendor/activemodel/lib/active_model/validations_repair_helper.rb",
+ "vendor/activemodel/lib/activemodel.rb",
+ "vendor/activemodel/test/cases/helper.rb",
+ "vendor/activemodel/test/cases/naming_test.rb",
+ "vendor/activemodel/test/cases/observing_test.rb",
+ "vendor/activemodel/test/cases/serializeration/json_serialization_test.rb",
+ "vendor/activemodel/test/cases/serializeration/xml_serialization_test.rb",
+ "vendor/activemodel/test/cases/state_machine/event_test.rb",
+ "vendor/activemodel/test/cases/state_machine/machine_test.rb",
+ "vendor/activemodel/test/cases/state_machine/state_test.rb",
+ "vendor/activemodel/test/cases/state_machine/state_transition_test.rb",
+ "vendor/activemodel/test/cases/state_machine_test.rb",
+ "vendor/activemodel/test/cases/tests_database.rb",
+ "vendor/activemodel/test/cases/validations/acceptance_validation_test.rb",
+ "vendor/activemodel/test/cases/validations/conditional_validation_test.rb",
+ "vendor/activemodel/test/cases/validations/confirmation_validation_test.rb",
+ "vendor/activemodel/test/cases/validations/exclusion_validation_test.rb",
+ "vendor/activemodel/test/cases/validations/format_validation_test.rb",
+ "vendor/activemodel/test/cases/validations/i18n_generate_message_validation_test.rb",
+ "vendor/activemodel/test/cases/validations/i18n_validation_test.rb",
+ "vendor/activemodel/test/cases/validations/inclusion_validation_test.rb",
+ "vendor/activemodel/test/cases/validations/length_validation_test.rb",
+ "vendor/activemodel/test/cases/validations/numericality_validation_test.rb",
+ "vendor/activemodel/test/cases/validations/presence_validation_test.rb",
+ "vendor/activemodel/test/cases/validations/with_validation_test.rb",
+ "vendor/activemodel/test/cases/validations_test.rb",
+ "vendor/activemodel/test/config.rb",
+ "vendor/activemodel/test/fixtures/topics.yml",
+ "vendor/activemodel/test/models/contact.rb",
+ "vendor/activemodel/test/models/custom_reader.rb",
+ "vendor/activemodel/test/models/developer.rb",
+ "vendor/activemodel/test/models/person.rb",
+ "vendor/activemodel/test/models/reply.rb",
+ "vendor/activemodel/test/models/topic.rb",
+ "vendor/activemodel/test/schema.rb",
+ "vendor/activesupport/lib/active_support/concern.rb",
+ "vendor/activesupport/lib/active_support/core_ext/array/wrap.rb",
+ "vendor/activesupport/lib/active_support/core_ext/object/blank.rb",
+ "vendor/activesupport/lib/active_support/core_ext/object/tap.rb",
+ "vendor/activesupport/lib/active_support/dependency_module.rb"
+ ]
+ s.homepage = %q{http://github.com/NZKoz/cassandra_object}
+ s.rdoc_options = ["--charset=UTF-8"]
+ s.require_paths = ["lib"]
+ s.rubygems_version = %q{1.3.5}
+ s.summary = %q{Maps your objects into cassandra.}
+ s.test_files = [
+ "test/basic_scenarios_test.rb",
+ "test/connection.rb",
+ "test/cursor_test.rb",
+ "test/dirty_test.rb",
+ "test/fixture_models.rb",
+ "test/identity/natural_key_factory_test.rb",
+ "test/index_test.rb",
+ "test/migration_test.rb",
+ "test/one_to_many_associations_test.rb",
+ "test/test_helper.rb",
+ "test/validation_test.rb"
+ ]
+
+ if s.respond_to? :specification_version then
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
+ s.specification_version = 3
+
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
+ s.add_runtime_dependency(%q<activesupport>, [">= 3.0.pre"])
+ s.add_runtime_dependency(%q<activemodel>, [">= 3.0.pre"])
+ else
+ s.add_dependency(%q<activesupport>, [">= 3.0.pre"])
+ s.add_dependency(%q<activemodel>, [">= 3.0.pre"])
+ end
+ else
+ s.add_dependency(%q<activesupport>, [">= 3.0.pre"])
+ s.add_dependency(%q<activemodel>, [">= 3.0.pre"])
+ end
+end
View
4 lib/cassandra_object.rb
@@ -6,11 +6,9 @@
require 'i18n'
require 'active_support'
+require 'active_support/all'
require 'active_model'
-require 'active_support/concern'
-require 'active_support/time_with_zone'
require 'cassandra_object/base'
-require 'active_support/core_ext/array/wrap'
module CassandraObject
end
View
5 lib/cassandra_object/callbacks.rb
@@ -2,10 +2,9 @@ module CassandraObject
module Callbacks
extend ActiveSupport::Concern
- depends_on ActiveSupport::Callbacks
-
included do
- define_callbacks :before_save, :after_save, :before_create, :after_create, :before_destroy, :after_destroy
+ extend ActiveModel::Callbacks
+ define_model_callbacks :save, :create, :destroy
end
end
end
View
4 lib/cassandra_object/indexes.rb
@@ -80,10 +80,12 @@ def self.find_by_#{attribute_name}(value)
after_save do |record|
self.indexes[:#{attribute_name}].write(record)
+ true
end
after_destroy do |record|
record.class.indexes[:#{attribute_name}].remove(record)
+ true
end
eom
else
@@ -95,10 +97,12 @@ def self.find_all_by_#{attribute_name}(value, options = {})
after_save do |record|
record.class.indexes[:#{attribute_name}].write(record)
+ true
end
after_destroy do |record|
record.class.indexes[:#{attribute_name}].remove(record)
+ true
end
eom
end
View
30 lib/cassandra_object/persistence.rb
@@ -82,28 +82,34 @@ def decode_columns_hash(attributes)
module InstanceMethods
def save
- if was_new_record = new_record?
- run_callbacks :before_create
+ if new_record?
+ run_callbacks :create do
+ _save
+ end
+ else
+ _save
end
- run_callbacks :before_save
-
- changed_attributes = changed.inject({}) { |h, n| h[n] = read_attribute(n); h }
- @key ||= self.class.next_key(self)
- self.class.write(key, changed_attributes, schema_version)
- run_callbacks :after_save
- run_callbacks :after_create if was_new_record
+
@new_record = false
true
end
+
+ def _save
+ run_callbacks :save do
+ changed_attributes = changed.inject({}) { |h, n| h[n] = read_attribute(n); h }
+ @key ||= self.class.next_key(self)
+ self.class.write(key, changed_attributes, schema_version)
+ end
+ end
def new_record?
@new_record || false
end
def destroy
- run_callbacks :before_destroy
- self.class.remove(key)
- run_callbacks :after_destroy
+ run_callbacks :destroy do
+ self.class.remove(key)
+ end
end
def reload
View
9 lib/cassandra_object/validation.rb
@@ -12,10 +12,10 @@ def self.raise_error(record)
end
end
extend ActiveSupport::Concern
- depends_on ActiveModel::Validations
+ include ActiveModel::Validations
included do
- define_callbacks :before_validation
+ define_callbacks :validation
end
module ClassMethods
@@ -26,8 +26,9 @@ def create!(attributes)
module InstanceMethods
def valid?
- run_callbacks :before_validation
- super
+ run_callbacks :validation do
+ super
+ end
end
def save
View
9 test/test_helper.rb
@@ -1,12 +1,15 @@
-require 'pp'
-require 'rubygems'
+require 'vendor/gems/environment'
+
require 'cassandra_object'
require 'connection'
require 'test/unit'
require 'active_support/test_case'
+require 'shoulda'
+
require 'fixture_models'
-require 'Shoulda'
+require 'pp'
+
class CassandraObjectTestCase < ActiveSupport::TestCase
def teardown
View
BIN  vendor/gems/cache/cassandra-0.6.gem
Binary file not shown
View
BIN  vendor/gems/cache/i18n-0.3.3.gem
Binary file not shown
View
BIN  vendor/gems/cache/rake-0.8.7.gem
Binary file not shown
View
BIN  vendor/gems/cache/shoulda-2.10.2.gem
Binary file not shown
View
BIN  vendor/gems/cache/thrift-0.0.810255.1.gem
Binary file not shown
View
BIN  vendor/gems/cache/thrift_client-0.3.2.gem
Binary file not shown
Please sign in to comment.
Something went wrong with that request. Please try again.