Permalink
Browse files

Merge branch 'master' of git://github.com/sam/dm-more

  • Loading branch information...
Wesley Beary
Wesley Beary committed Jul 21, 2008
2 parents b429af7 + 0489eaa commit 7d5899260faa4aeba3b8623cec5dd219815ff7e8
Showing with 352 additions and 99 deletions.
  1. +1 −1 adapters/dm-couchdb-adapter/Rakefile
  2. +4 −3 adapters/dm-couchdb-adapter/lib/couchdb_adapter.rb
  3. +1 −1 adapters/dm-couchdb-adapter/lib/couchdb_adapter/version.rb
  4. +1 −1 adapters/dm-rest-adapter/Rakefile
  5. +3 −2 adapters/dm-rest-adapter/lib/rest_adapter.rb
  6. +1 −1 adapters/dm-rest-adapter/lib/rest_adapter/version.rb
  7. +1 −1 dm-adjust/Rakefile
  8. +4 −1 dm-adjust/lib/dm-adjust.rb
  9. +4 −2 dm-adjust/lib/dm-adjust/version.rb
  10. +1 −1 dm-aggregates/Rakefile
  11. +10 −8 dm-aggregates/lib/dm-aggregates.rb
  12. +4 −2 dm-aggregates/lib/dm-aggregates/version.rb
  13. +1 −1 dm-is-state_machine/TODO
  14. +4 −5 dm-is-state_machine/lib/dm-is-state_machine/is/data/event.rb
  15. +7 −7 dm-is-state_machine/lib/dm-is-state_machine/is/data/machine.rb
  16. +3 −3 dm-is-state_machine/lib/dm-is-state_machine/is/data/state.rb
  17. +1 −1 dm-is-state_machine/lib/dm-is-state_machine/is/dsl/event_dsl.rb
  18. +3 −3 dm-is-state_machine/lib/dm-is-state_machine/is/dsl/state_dsl.rb
  19. +6 −6 dm-is-state_machine/lib/dm-is-state_machine/is/state_machine.rb
  20. +1 −1 dm-is-state_machine/lib/dm-is-state_machine/is/version.rb
  21. +2 −2 dm-is-state_machine/spec/examples/invalid_events.rb
  22. +1 −1 dm-is-state_machine/spec/examples/invalid_states.rb
  23. +3 −3 dm-is-state_machine/spec/examples/invalid_transitions_1.rb
  24. +3 −3 dm-is-state_machine/spec/examples/invalid_transitions_2.rb
  25. +2 −2 dm-is-state_machine/spec/examples/traffic_light.rb
  26. +11 −11 dm-is-state_machine/spec/integration/traffic_light_spec.rb
  27. +3 −3 dm-is-state_machine/spec/unit/data/event_spec.rb
  28. +5 −5 dm-is-state_machine/spec/unit/data/machine_spec.rb
  29. +2 −2 dm-is-state_machine/spec/unit/data/state_spec.rb
  30. +3 −3 dm-is-state_machine/spec/unit/dsl/event_dsl_spec.rb
  31. +1 −1 dm-is-state_machine/spec/unit/dsl/state_dsl_spec.rb
  32. +3 −3 dm-is-state_machine/spec/unit/state_machine_spec.rb
  33. +3 −0 dm-types/Manifest.txt
  34. +7 −0 dm-types/lib/dm-types.rb
  35. +31 −0 dm-types/lib/dm-types/bcrypt_hash.rb
  36. +50 −0 dm-types/spec/integration/bcrypt_hash_spec.rb
  37. +50 −0 dm-types/spec/unit/bcrypt_hash_spec.rb
  38. +54 −8 dm-validations/lib/dm-validations/auto_validate.rb
  39. +49 −0 dm-validations/spec/integration/auto_validate_spec.rb
  40. +2 −1 merb_datamapper/lib/merb_datamapper.rb
  41. +6 −0 merb_datamapper/lib/merb_datamapper/merbtasks.rb
@@ -9,7 +9,7 @@ require ROOT + 'lib/couchdb_adapter/version'
AUTHOR = "Bernerd Schaefer"
EMAIL = "bj.schaefer@gmail.com"
GEM_NAME = "dm-couchdb-adapter"
-GEM_VERSION = DataMapper::Adapters::CouchDBAdapter::VERSION
+GEM_VERSION = DataMapper::More::CouchDBAdapter::VERSION
GEM_DEPENDENCIES = [["dm-core", GEM_VERSION]]
GEM_CLEAN = ["log", "pkg"]
GEM_EXTRAS = { :has_rdoc => true, :extra_rdoc_files => %w[ README.txt LICENSE TODO ] }
@@ -1,10 +1,11 @@
require 'rubygems'
-gem 'dm-core', '=0.9.3'
-require 'base64'
+require 'pathname'
+require Pathname(__FILE__).dirname + 'couchdb_adapter/version'
+gem 'dm-core', DataMapper::More::CouchDBAdapter::VERSION
require 'dm-core'
+require 'base64'
require 'json'
require 'net/http'
-require 'pathname'
require 'uri'
require Pathname(__FILE__).dirname + 'couchdb_adapter/json_object'
require Pathname(__FILE__).dirname + 'couchdb_adapter/view'
@@ -1,5 +1,5 @@
module DataMapper
- module Adapters
+ module More
class CouchDBAdapter
VERSION = "0.9.3"
end
@@ -9,7 +9,7 @@ require ROOT + 'lib/rest_adapter/version'
AUTHOR = "Potomac Ruby Hackers"
EMAIL = "potomac-ruby-hackers@googlegroups.com"
GEM_NAME = "dm-rest-adapter"
-GEM_VERSION = DataMapper::Adapters::RestAdapter::VERSION
+GEM_VERSION = DataMapper::More::RestAdapter::VERSION
GEM_DEPENDENCIES = [["dm-core", GEM_VERSION]]
GEM_CLEAN = ["log", "pkg"]
GEM_EXTRAS = { :has_rdoc => true, :extra_rdoc_files => %w[ README.txt LICENSE TODO ] }
@@ -1,9 +1,10 @@
require 'rubygems'
-gem 'dm-core', '=0.9.3'
+require 'pathname'
+require Pathname(__FILE__).dirname + 'rest_adapter/version'
+gem 'dm-core', DataMapper::More::RestAdapter::VERSION
require 'dm-core'
require 'extlib'
require 'dm-serializer'
-require 'pathname'
require 'net/http'
require 'rexml/document'
@@ -1,5 +1,5 @@
module DataMapper
- module Adapters
+ module More
class RestAdapter
VERSION = "0.9.3"
end
View
@@ -9,7 +9,7 @@ require ROOT + 'lib/dm-adjust/version'
AUTHOR = "Sindre Aarsaether"
EMAIL = "sindre [a] identu [d] no"
GEM_NAME = "dm-adjust"
-GEM_VERSION = DataMapper::Adjust::VERSION
+GEM_VERSION = DataMapper::More::Adjust::VERSION
GEM_DEPENDENCIES = [["dm-core", GEM_VERSION]]
GEM_CLEAN = ["log", "pkg"]
GEM_EXTRAS = { :has_rdoc => true, :extra_rdoc_files => %w[ README.txt LICENSE TODO ] }
@@ -1,6 +1,9 @@
require 'rubygems'
+require 'pathname'
-gem 'dm-core', '=0.9.3'
+require Pathname(__FILE__).dirname + 'dm-adjust/version'
+
+gem 'dm-core', DataMapper::More::Adjust::VERSION
require 'dm-core'
dir = Pathname(__FILE__).dirname.expand_path / 'dm-adjust'
@@ -1,5 +1,7 @@
module DataMapper
- module Adjust
- VERSION = "0.9.3"
+ module More
+ module Adjust
+ VERSION = "0.9.3"
+ end
end
end
View
@@ -9,7 +9,7 @@ require ROOT + 'lib/dm-aggregates/version'
AUTHOR = "Foy Savas"
EMAIL = "foysavas@gmail.com"
GEM_NAME = "dm-aggregates"
-GEM_VERSION = DataMapper::Aggregates::VERSION
+GEM_VERSION = DataMapper::More::Aggregates::VERSION
GEM_DEPENDENCIES = [["dm-core", GEM_VERSION]]
GEM_CLEAN = ["log", "pkg"]
GEM_EXTRAS = { :has_rdoc => true, :extra_rdoc_files => %w[ README.txt LICENSE TODO ] }
@@ -1,13 +1,15 @@
require 'rubygems'
-gem 'dm-core', '=0.9.3'
+dir = Pathname(__FILE__).dirname.expand_path + 'dm-aggregates'
+
+require dir + 'version'
+gem 'dm-core', DataMapper::More::Aggregates::VERSION
require 'dm-core'
-dir = Pathname(__FILE__).dirname.expand_path / 'dm-aggregates'
-require dir / 'aggregate_functions'
-require dir / 'model'
-require dir / 'repository'
-require dir / 'collection'
-require dir / 'adapters' / 'data_objects_adapter'
-require dir / 'support' / 'symbol'
+require dir + 'aggregate_functions'
+require dir + 'model'
+require dir + 'repository'
+require dir + 'collection'
+require dir + 'adapters' + 'data_objects_adapter'
+require dir + 'support' + 'symbol'
@@ -1,5 +1,7 @@
module DataMapper
- module Aggregates
- VERSION = "0.9.3"
+ module More
+ module Aggregates
+ VERSION = "0.9.3"
+ end
end
end
View
@@ -8,4 +8,4 @@ TODO
* Consider trying out a nested state machine.
* Not real happy with spec/unit/dsl:
- specs are brittle
- - specs don't actually test much
+ - specs don't actually test much
@@ -2,7 +2,7 @@ module DataMapper
module Is
module StateMachine
module Data
-
+
class Event
attr_reader :name, :machine, :transitions
@@ -12,15 +12,14 @@ def initialize(name, machine)
@machine = machine
@transitions = []
end
-
+
def add_transition(from, to)
@transitions << { :from => from, :to => to }
end
-
+
end
-
+
end # Data
end # StateMachine
end # Is
end # DataMapper
-
@@ -2,20 +2,20 @@ module DataMapper
module Is
module StateMachine
module Data
-
+
# Represents one state machine
class Machine
attr_reader :column, :initial
attr_accessor :current_state_name
attr_accessor :events, :states
-
+
def initialize(column, initial)
@column, @initial = column, initial
@events, @states = [], []
@current_state_name = initial
end
-
+
# Fire (activate) the event with name +event_name+
#
# @api public
@@ -44,25 +44,25 @@ def current_state
find_state(@current_state_name)
# TODO: add caching, i.e. with `@current_state ||= ...`
end
-
+
# Find event whose name is +event_name+
#
# @api semipublic
def find_event(event_name)
@events.find { |event| event.name.to_s == event_name.to_s }
# TODO: use a data structure that prevents duplicates
end
-
+
# Find state whose name is +event_name+
#
# @api semipublic
def find_state(state_name)
@states.find { |state| state.name.to_s == state_name.to_s }
# TODO: use a data structure that prevents duplicates
end
-
+
end
-
+
end # Data
end # StateMachine
end # Is
@@ -6,15 +6,15 @@ module Data
class State
attr_reader :name, :machine, :options
-
+
def initialize(name, machine, options = {})
@name = name
@options = options
@machine = machine
end
-
+
end
-
+
end # Data
end # StateMachine
end # Is
@@ -61,7 +61,7 @@ def transitions(options)
end
event_name = @is_state_machine[:event][:name]
event_object = @is_state_machine[:event][:object]
-
+
from = options[:from]
to = options[:to]
event_object.add_transition(from, to)
@@ -15,10 +15,10 @@ module StateDsl
# state :green, :enter => Proc.new { |o| o.log("G") }
# state :yellow, :enter => Proc.new { |o| o.log("Y") }
# state :red, :enter => Proc.new { |o| o.log("R") }
- #
+ #
# # event definitions go here...
# end
- #
+ #
# def log(string)
# Merb::Logger.info(string)
# end
@@ -33,7 +33,7 @@ def state(name, options = {})
state = Data::State.new(name, machine, options)
machine.states << state
end
-
+
end # StateDsl
end # StateMachine
end # Is
@@ -27,7 +27,7 @@ def is_state_machine(options = {}, &block)
extend DataMapper::Is::StateMachine::EventDsl
extend DataMapper::Is::StateMachine::StateDsl
include DataMapper::Is::StateMachine::InstanceMethods
-
+
# ===== Setup context =====
options = { :column => :state, :initial => nil }.merge(options)
column = options[:column]
@@ -59,9 +59,9 @@ def is_state_machine(options = {}, &block)
# ===== Teardown context =====
pop_state_machine_context
end
-
+
protected
-
+
def push_state_machine_context(label)
((@is_state_machine ||= {})[:context] ||= []) << label
@@ -70,18 +70,18 @@ def push_state_machine_context(label)
# @is_state_machine[:context] ||= []
# @is_state_machine[:context] << label
end
-
+
def pop_state_machine_context
@is_state_machine[:context].pop
end
-
+
def state_machine_context?(label)
(i = @is_state_machine) && (c = i[:context]) &&
c.respond_to?(:include?) && c.include?(label)
end
module InstanceMethods
-
+
def initialize(*args)
super
# ===== Call :enter Proc if present =====
@@ -4,4 +4,4 @@ module StateMachine
VERSION = "0.9.3"
end
end
-end
+end
@@ -1,14 +1,14 @@
# An invalid example.
class InvalidEvents
include DataMapper::Resource
-
+
property :id, Serial
is :state_machine do
state :day
state :night
end
-
+
# The next lines are intentionally incorrect.
#
# 'event' only makes sense in a block under 'is :state_machine'
@@ -1,7 +1,7 @@
# An invalid example.
class InvalidStates
include DataMapper::Resource
-
+
property :id, Serial
is :state_machine do
@@ -1,15 +1,15 @@
# An invalid example.
class InvalidTransitions1
include DataMapper::Resource
-
+
property :id, Serial
is :state_machine do
state :happy
state :sad
-
+
event :toggle
-
+
# The next lines are intentionally incorrect.
#
# 'transitions' is only valid when nested beneath 'event'
@@ -1,16 +1,16 @@
# An invalid example.
class InvalidTransitions2
include DataMapper::Resource
-
+
property :id, Serial
is :state_machine do
state :happy
state :sad
-
+
event :toggle
end
-
+
# The next lines are intentionally incorrect.
#
# 'transitions' is only valid when nested beneath 'event'
Oops, something went wrong.

0 comments on commit 7d58992

Please sign in to comment.