Class Index [+]

Quicksearch

DataMapper::Spec

Public Class Methods

cleanup_models() click to toggle source

global model cleanup

    # File lib/dm-core/spec/lib/spec_helper.rb, line 15
15:     def self.cleanup_models
16:       descendants = DataMapper::Model.descendants.to_a
17: 
18:       while model = descendants.shift
19:         model_name = model.name.to_s.strip
20: 
21:         unless model_name.empty? || model_name[0] == ##
22:           parts         = model_name.split('::')
23:           constant_name = parts.pop.to_sym
24:           base          = parts.empty? ? Object : DataMapper::Ext::Object.full_const_get(parts.join('::'))
25: 
26:           base.class_eval { remove_const(constant_name) if const_defined?(constant_name) }
27:         end
28: 
29:         remove_ivars(model)
30:         model.instance_methods(false).each { |method| model.send(:undef_method, method) }
31: 
32:       end
33: 
34:       DataMapper::Model.descendants.clear
35:     end
configure() click to toggle source
    # File lib/dm-core/spec/setup.rb, line 24
24:       def configure
25:         @configured = begin
26:           setup_logger
27:           require_plugins
28:           require_spec_adapter
29:           true
30:         end
31:       end
configured?() click to toggle source
    # File lib/dm-core/spec/setup.rb, line 33
33:       def configured?
34:         @configured
35:       end
remove_ivars(object, instance_variables = object.instance_variables) click to toggle source
    # File lib/dm-core/spec/lib/spec_helper.rb, line 37
37:     def self.remove_ivars(object, instance_variables = object.instance_variables)
38:       seen  = {}
39:       stack = instance_variables.map { |var| [ object, var ] }
40: 
41:       while node = stack.pop
42:         object, ivar = node
43: 
44:         # skip "global" and non-DM objects
45:         next if object.kind_of?(DataMapper::Logger)                    ||
46:                 object.kind_of?(DataMapper::DescendantSet)             ||
47:                 object.kind_of?(DataMapper::Adapters::AbstractAdapter) ||
48:                 object.class.name[0, 13] == 'DataObjects::'
49: 
50:         # skip classes and modules in the DataMapper namespace
51:         next if object.kind_of?(Module) &&
52:                 !object.name.nil?       &&
53:                 object.name[0, 12] == 'DataMapper::'
54: 
55:         # skip when the ivar is no longer defined in the object
56:         next unless object.instance_variable_defined?(ivar)
57: 
58:         value = object.instance_variable_get(ivar)
59: 
60:         # skip descendant sets
61:         next if value.kind_of?(DataMapper::DescendantSet)
62: 
63:         object.__send__(:remove_instance_variable, ivar) unless object.frozen?
64: 
65:         # skip when the value was seen
66:         next if seen.key?(value.object_id)
67:         seen[value.object_id] = true
68: 
69:         stack.concat value.instance_variables.map { |ivar| [ value, ivar ] }
70:       end
71:     end
require_plugins() click to toggle source
    # File lib/dm-core/spec/setup.rb, line 54
54:       def require_plugins
55:         plugins = ENV['PLUGINS'] || ENV['PLUGIN']
56:         plugins = plugins.to_s.split(/[,\s]+/)
57:         unless ENV['ADAPTER'] == 'in_memory'
58:           plugins.push('dm-migrations')
59:         end
60:         plugins.uniq.each { |plugin| require plugin }
61:       end
require_spec_adapter() click to toggle source
    # File lib/dm-core/spec/setup.rb, line 44
44:       def require_spec_adapter
45:         desired_adapter = ENV['ADAPTER']
46:         if desired_adapter.nil? || desired_adapter == 'in_memory'
47:           ENV['ADAPTER_SUPPORTS'] = 'all'
48:           Adapters.use(Adapters::InMemoryAdapter)
49:         else
50:           require "dm-#{desired_adapter}-adapter/spec/setup"
51:         end
52:       end
root() click to toggle source
    # File lib/dm-core/spec/setup.rb, line 8
 8:       def root
 9:         @root ||= default_root
10:       end
root=(path) click to toggle source
    # File lib/dm-core/spec/setup.rb, line 12
12:       def root=(path)
13:         @root = Pathname(path)
14:       end
setup_logger() click to toggle source
    # File lib/dm-core/spec/setup.rb, line 37
37:       def setup_logger
38:         if log = ENV['LOG']
39:           logger = DataMapper::Logger.new(log_stream(log), :debug)
40:           logger.auto_flush = true
41:         end
42:       end
spec_adapters() click to toggle source
    # File lib/dm-core/spec/setup.rb, line 63
63:       def spec_adapters
64:         @spec_adapters ||= {}
65:       end

Private Class Methods

default_root() click to toggle source
    # File lib/dm-core/spec/setup.rb, line 74
74:       def default_root
75:         Pathname(Dir.pwd).join('spec')
76:       end
log_stream(log) click to toggle source
    # File lib/dm-core/spec/setup.rb, line 78
78:       def log_stream(log)
79:         log == 'file' ? root.join('log/dm.log') : $stdout
80:       end
perform_action(kind, action) click to toggle source
    # File lib/dm-core/spec/setup.rb, line 69
69:       def perform_action(kind, action)
70:         configure unless configured?
71:         spec_adapters[kind].send(action)
72:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.