dynamic_registrar 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +7 -0
- data/.rvmrc +2 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +34 -0
- data/LICENSE +21 -0
- data/README.md +44 -0
- data/Rakefile +64 -0
- data/dynamic_registrar.gemspec +26 -0
- data/lib/dynamic_registrar.rb +6 -0
- data/lib/dynamic_registrar/errors/registration_conflict_error.rb +10 -0
- data/lib/dynamic_registrar/registrar.rb +80 -0
- data/lib/dynamic_registrar/version.rb +22 -0
- data/test/abstract_unit.rb +2 -0
- data/test/dynamic_registrar/errors/test_registration_conflict_error.rb +10 -0
- data/test/dynamic_registrar/test_registrar.rb +112 -0
- data/test/dynamic_registrar/test_version.rb +22 -0
- data/test/test_dynamic_registrar.rb +15 -0
- metadata +146 -0
data/.gitignore
ADDED
data/.rvmrc
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
dynamic_registrar (0.0.developer)
|
5
|
+
ZenTest (~> 4.4.2)
|
6
|
+
cover_me (~> 1.0.0.rc4)
|
7
|
+
parallel_tests (~> 0.4.9)
|
8
|
+
yard (~> 0.6.3)
|
9
|
+
|
10
|
+
GEM
|
11
|
+
remote: http://rubygems.org/
|
12
|
+
specs:
|
13
|
+
ZenTest (4.4.2)
|
14
|
+
configatron (2.6.4)
|
15
|
+
yamler (>= 0.1.0)
|
16
|
+
cover_me (1.0.0.rc4)
|
17
|
+
configatron
|
18
|
+
hashie
|
19
|
+
hashie (0.4.0)
|
20
|
+
parallel (0.5.1)
|
21
|
+
parallel_tests (0.4.9)
|
22
|
+
parallel
|
23
|
+
yamler (0.1.0)
|
24
|
+
yard (0.6.4)
|
25
|
+
|
26
|
+
PLATFORMS
|
27
|
+
ruby
|
28
|
+
|
29
|
+
DEPENDENCIES
|
30
|
+
ZenTest (~> 4.4.2)
|
31
|
+
cover_me (~> 1.0.0.rc4)
|
32
|
+
dynamic_registrar!
|
33
|
+
parallel_tests (~> 0.4.9)
|
34
|
+
yard (~> 0.6.3)
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2010 3Crowd Technologies, Inc.
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
The capability registrar allows modules to register versioned callbacks. Callbacks may only be
|
2
|
+
registered once per registration namespace. If multiple callback registration is attempted a
|
3
|
+
RegistrationConflictError will be raised.
|
4
|
+
|
5
|
+
Example
|
6
|
+
=======
|
7
|
+
|
8
|
+
master_registrar = Registrar.new
|
9
|
+
|
10
|
+
master_registrar.default_registration_namespace = :test
|
11
|
+
|
12
|
+
callback procs should avoid side effects
|
13
|
+
The register call will throw an exception if you don't pass in a second argument containing the registration namespace,
|
14
|
+
unless the default_registration_namespace attribute is set
|
15
|
+
|
16
|
+
master_registrar.register :awesome_called do | awesome_data |
|
17
|
+
awesome_data
|
18
|
+
end
|
19
|
+
|
20
|
+
master_registrar.register :awesome_called, :something_else do | awesome_data |
|
21
|
+
"And now for something completely different"
|
22
|
+
end
|
23
|
+
|
24
|
+
dispatches to all registration namespaces in undefined order for all :awesome_called registered callbacks
|
25
|
+
returns a Hash with the registration_namespace of the callback as the key, and the value is the value returned by
|
26
|
+
the callback function.
|
27
|
+
|
28
|
+
calling
|
29
|
+
|
30
|
+
master_registrar.dispatch :awesome_called, :with_data => { :some_lol_data => :wow_cool }
|
31
|
+
|
32
|
+
returns
|
33
|
+
|
34
|
+
{ :test => { :some_lol_data => :wow_cool }, :something_else => "And now for something completely different" }
|
35
|
+
|
36
|
+
|
37
|
+
dispatches to named registration namespaces return a Hash with the registration_namespace as the key, and the value is the
|
38
|
+
value returned by the callback function, or an empty hash if the callback function is not registered
|
39
|
+
|
40
|
+
master_registrar.dispatch :awesome_called, :in_registration_namespace => :test, :with_data => { :some_lol_data => :omg_specific_cool }
|
41
|
+
|
42
|
+
returns
|
43
|
+
|
44
|
+
{ :test => { :some_lol_data => :omg_specific_cool } }
|
data/Rakefile
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'yard'
|
4
|
+
require 'bundler'
|
5
|
+
|
6
|
+
Bundler::GemHelper.install_tasks
|
7
|
+
|
8
|
+
task :default => [ 'build' ]
|
9
|
+
|
10
|
+
namespace :test do
|
11
|
+
desc 'execute tests in parallel in separate Ruby VM instances using parallel_test'
|
12
|
+
task :parallel do
|
13
|
+
test_files = FileList['test/**/test_*.rb'].sort.reverse
|
14
|
+
executable = 'parallel_test'
|
15
|
+
command = "#{executable} --type test -n #{test_files.size} -o '-I\'.:lib:test\'' #{test_files.join(' ')}"
|
16
|
+
abort unless system(command) # allow to chain tasks e.g. rake parallel:spec parallel:features
|
17
|
+
end
|
18
|
+
|
19
|
+
Rake::TestTask.new :serial do |task|
|
20
|
+
task.libs << "test"
|
21
|
+
task.test_files = FileList['test/**/test_*.rb'].sort.reverse
|
22
|
+
task.verbose = true
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
desc 'execute all tests both in serial and in parallel'
|
27
|
+
task :test => [ 'test:parallel', 'test:serial' ]
|
28
|
+
|
29
|
+
YARD::Rake::YardocTask.new(:doc) do |t|
|
30
|
+
t.files = ['lib/**/*.rb']
|
31
|
+
end
|
32
|
+
|
33
|
+
task 'build' => [ 'coverage:clobber', 'test', 'coverage:report', 'doc' ]
|
34
|
+
|
35
|
+
namespace 'coverage' do
|
36
|
+
|
37
|
+
desc 'generate code coverage report from unit tests'
|
38
|
+
task :report => [ 'test:serial' ] do
|
39
|
+
|
40
|
+
puts 'Generating code coverage report...'
|
41
|
+
|
42
|
+
require 'cover_me'
|
43
|
+
|
44
|
+
CoverMe.config do |c|
|
45
|
+
c.project.root = File.expand_path(File.dirname(__FILE__))
|
46
|
+
|
47
|
+
c.file_pattern = /(#{CoverMe.config.project.root}\/app\/.+\.rb|#{CoverMe.config.project.root}\/lib\/.+\.rb)/ix
|
48
|
+
end
|
49
|
+
|
50
|
+
CoverMe.complete!
|
51
|
+
|
52
|
+
puts 'Done generating code coverage report'
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
desc 'remove code coverage report'
|
57
|
+
task :clobber do
|
58
|
+
puts 'Removing coverage report and data...'
|
59
|
+
rm_rf 'coverage'
|
60
|
+
rm_f 'coverage.data'
|
61
|
+
puts 'Done removing coverage report and data'
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "dynamic_registrar/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "dynamic_registrar"
|
7
|
+
s.version = DynamicRegistrar::Version.inspect
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Justin Lynn (justinlynn)","3Crowd Technologies, Inc. (Sponsor)"]
|
10
|
+
s.email = ["ops@3crowd.com"]
|
11
|
+
s.homepage = "https://github.com/3Crowd/dynamic_registrar"
|
12
|
+
s.summary = %q{Registration for dynamic invocation}
|
13
|
+
s.description = %q{Namespaced and versioned registration of callbacks for dynamic invocation by clients}
|
14
|
+
|
15
|
+
s.rubyforge_project = "dynamic_registrar"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
|
22
|
+
s.add_dependency 'yard', '~> 0.6.3'
|
23
|
+
s.add_dependency 'cover_me', '~> 1.0.0.rc4'
|
24
|
+
s.add_dependency 'parallel_tests', '~> 0.4.9'
|
25
|
+
s.add_dependency 'ZenTest', '~> 4.4.2'
|
26
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module DynamicRegistrar
|
2
|
+
# Encapsulates errors thrown by DynamicRegistrar
|
3
|
+
module Errors
|
4
|
+
# Defines a registration conflict error. This typically occurs when an attempt
|
5
|
+
# has been made to register a callback with the name of an existing callback
|
6
|
+
# in the scoped namespace.
|
7
|
+
class RegistrationConflictError < StandardError
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'thread'
|
2
|
+
|
3
|
+
require 'dynamic_registrar/errors/registration_conflict_error'
|
4
|
+
|
5
|
+
module DynamicRegistrar
|
6
|
+
# Controls the registration and dispatching of callbacks
|
7
|
+
class Registrar
|
8
|
+
|
9
|
+
# Mutex to provide for no double or overwritten registration guarantee even in multithreaded environments
|
10
|
+
# @private
|
11
|
+
@@registration_guard = Mutex.new
|
12
|
+
|
13
|
+
# The default namespace used when calling Registrar#register! without specifying a namespace
|
14
|
+
attr_reader :default_registration_namespace
|
15
|
+
|
16
|
+
# The collection of callbacks currently registered within the Registrar
|
17
|
+
def registered_callbacks
|
18
|
+
@@registration_guard.synchronize do
|
19
|
+
@registered_callbacks
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# Create a new DynamicRegistrar::Registrar
|
24
|
+
# @param [ Symbol ] default_registration_namespace The default namespace in which to register callbacks. Should not be set to nil.
|
25
|
+
def initialize default_registration_namespace
|
26
|
+
@default_registration_namespace = default_registration_namespace
|
27
|
+
@registered_callbacks = Hash.new
|
28
|
+
end
|
29
|
+
|
30
|
+
# Register a new callback procedure. This method is thread-safe.
|
31
|
+
# @param [ Symbol ] name The name of the callback to register
|
32
|
+
# @param [ Symbol ] namespace The namespace in which to register the callback
|
33
|
+
def register! name, namespace = @default_registration_namespace, &callback_proc
|
34
|
+
@@registration_guard.synchronize do
|
35
|
+
raise Errors::RegistrationConflictError if registered_in_namespace? name, namespace
|
36
|
+
@registered_callbacks[namespace] ||= Hash.new
|
37
|
+
@registered_callbacks[namespace][name] = callback_proc
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# Dispatch message to given callback. All named callbacks matching the name will
|
42
|
+
# be run in all namespaces in indeterminate order
|
43
|
+
# @param [ Symbol ] name The name of the callback
|
44
|
+
# @param [ Symbol ] namespace The namespace in which the named callback should be found. Optional, if omitted then all matching named callbacks in all namespaces will be executed
|
45
|
+
# @return [ Hash ] A hash whose keys are the namespaces in which callbacks were executed, and whose values are the results of those executions. If empty, then no callbacks were executed.
|
46
|
+
def dispatch name, namespace = nil
|
47
|
+
responses = Hash.new
|
48
|
+
namespaces_to_search = namespace ? [namespace] : namespaces
|
49
|
+
namespaces_to_search.each do |namespace|
|
50
|
+
responses[namespace] ||= Hash.new
|
51
|
+
responses[namespace][name] = @registered_callbacks[namespace][name].call if @registered_callbacks[namespace].has_key?(name)
|
52
|
+
end
|
53
|
+
responses
|
54
|
+
end
|
55
|
+
|
56
|
+
# Query if a callback of given name is registered in any namespace
|
57
|
+
# @param [ Symbol ] name The name of the callback to check
|
58
|
+
def registered? name
|
59
|
+
registration_map = namespaces.map do |namespace|
|
60
|
+
registered_in_namespace? name, namespace
|
61
|
+
end
|
62
|
+
registration_map.any?
|
63
|
+
end
|
64
|
+
|
65
|
+
# Query if a callback of given name is registered in given namespace
|
66
|
+
# @param [ Symbol ] name The name of the callback to check
|
67
|
+
# @param [ Symbol ] namespace The name of the namespace in which to check
|
68
|
+
def registered_in_namespace? name, namespace
|
69
|
+
@registered_callbacks.has_key?(namespace) && @registered_callbacks[namespace].has_key?(name)
|
70
|
+
end
|
71
|
+
|
72
|
+
private
|
73
|
+
|
74
|
+
def namespaces
|
75
|
+
@registered_callbacks.keys
|
76
|
+
end
|
77
|
+
|
78
|
+
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module DynamicRegistrar
|
2
|
+
# Release version, set on revision control release branches as a separate commit
|
3
|
+
# after branching so that trunk patches can be easily backported.
|
4
|
+
#
|
5
|
+
# This is always 0.0.developer on master/mainline, refer to the HEAD commit for
|
6
|
+
# the version number instead.
|
7
|
+
module Version
|
8
|
+
# Incremented on breaking changes (breaks serialized data and/or removes deprecated APIs, for example)
|
9
|
+
MAJOR = "0"
|
10
|
+
# Incremented for major feature releases that do not break backwards compatibility
|
11
|
+
MINOR = "0"
|
12
|
+
# Incremented for minor fixes and updates
|
13
|
+
PATCH = "1"
|
14
|
+
|
15
|
+
# Converts the version number held in this module to a human readable string
|
16
|
+
# @return [ String ] The BinData version release
|
17
|
+
def self.inspect
|
18
|
+
[MAJOR,MINOR,PATCH].join('.')
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'abstract_unit'
|
2
|
+
require 'dynamic_registrar/errors/registration_conflict_error'
|
3
|
+
|
4
|
+
class DynamicRegistrarErrorsRegistrationConflictErrorTest < MiniTest::Unit::TestCase
|
5
|
+
|
6
|
+
def test_ensure_defines_registration_conflict_error_on_inclusion
|
7
|
+
refute DynamicRegistrar::Errors::RegistrationConflictError.nil?, 'Including file did not define RegistrationConflictError'
|
8
|
+
end
|
9
|
+
|
10
|
+
end
|
@@ -0,0 +1,112 @@
|
|
1
|
+
require 'abstract_unit'
|
2
|
+
require 'dynamic_registrar/registrar'
|
3
|
+
|
4
|
+
class DynamicRegistrarRegistrarTest < MiniTest::Unit::TestCase
|
5
|
+
|
6
|
+
def test_ensure_includes_errors
|
7
|
+
refute DynamicRegistrar::Errors::RegistrationConflictError.nil?, 'Including file did not define RegistrationConflictError'
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_has_default_registration_namespace_reader
|
11
|
+
assert_includes DynamicRegistrar::Registrar.instance_methods, :default_registration_namespace
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_has_register_bang_method
|
15
|
+
assert_includes DynamicRegistrar::Registrar.instance_methods, 'register!'.to_sym
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_has_registered_callbacks_reader
|
19
|
+
assert_includes DynamicRegistrar::Registrar.instance_methods, :registered_callbacks
|
20
|
+
refute_includes DynamicRegistrar::Registrar.instance_methods, 'registered_callbacks='.to_sym
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_has_registration_query_method
|
24
|
+
assert_includes DynamicRegistrar::Registrar.instance_methods, 'registered?'.to_sym
|
25
|
+
assert_includes DynamicRegistrar::Registrar.instance_methods, 'registered_in_namespace?'.to_sym
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_has_dispatch_method
|
29
|
+
assert_includes DynamicRegistrar::Registrar.instance_methods, :dispatch
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_register_method_adds_given_parameters_to_registered_callbacks
|
33
|
+
registrar = DynamicRegistrar::Registrar.new :test_namespace
|
34
|
+
assert_empty registrar.registered_callbacks
|
35
|
+
registrar.register! :test_callback do
|
36
|
+
# empty block to match interface
|
37
|
+
end
|
38
|
+
assert registrar.registered?(:test_callback), 'Test callback was not registered in registrar even though we attempted to do so'
|
39
|
+
assert registrar.registered_in_namespace?(:test_callback, :test_namespace), 'Test callback in namespace test_namespace was not registered in the registrar even though we attempted to do so'
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_registered_method_does_not_report_registered_callback_when_no_callback_is_registered
|
43
|
+
registrar = DynamicRegistrar::Registrar.new(:default_namespace)
|
44
|
+
refute registrar.registered?(:nonexistent_callback), 'Registrar#registered? returned true for a non-registered callback in any namespace'
|
45
|
+
refute registrar.registered_in_namespace?(:nonexistent_callback, :nonexistant_namespace), 'Registrar#registered_in_namespace? returned true for non-registered callback in non-existant namespace'
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_attempting_to_double_register_in_same_namespace_results_in_exception
|
49
|
+
registrar = DynamicRegistrar::Registrar.new(:default)
|
50
|
+
registrar.register! :test_callback do # in :default namespace
|
51
|
+
#empty block to match interface
|
52
|
+
end
|
53
|
+
assert_raises DynamicRegistrar::Errors::RegistrationConflictError do
|
54
|
+
registrar.register! :test_callback do # in :default namespace
|
55
|
+
#empty block to match interface
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_dispatching_call_to_one_named_callback_dispatches_to_all_registered_namespaces
|
61
|
+
registrar = DynamicRegistrar::Registrar.new(:default)
|
62
|
+
test_callback_namespace_one_called = false
|
63
|
+
registrar.register! :test_callback, :test_namespace_one do
|
64
|
+
test_callback_namespace_one_called = true
|
65
|
+
end
|
66
|
+
test_callback_namespace_two_called = false
|
67
|
+
registrar.register! :test_callback, :test_namespace_two do
|
68
|
+
test_callback_namespace_two_called = true
|
69
|
+
end
|
70
|
+
registrar.dispatch :test_callback
|
71
|
+
assert test_callback_namespace_one_called, 'Dispatching to test_callback with all namespaces did not run callback for namespace_one'
|
72
|
+
assert test_callback_namespace_two_called, 'Dispatching to test_callback with all namespaces did not run callback for namespace_two'
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_dispatching_call_to_one_named_callback_in_named_namespace_dispatches_to_only_that_callback
|
76
|
+
registrar = DynamicRegistrar::Registrar.new(:default)
|
77
|
+
test_callback_namespace_one_called = false
|
78
|
+
registrar.register! :test_callback, :test_namespace_one do
|
79
|
+
test_callback_namespace_one_called = true
|
80
|
+
end
|
81
|
+
|
82
|
+
test_callback_namespace_two_called = false
|
83
|
+
registrar.register! :test_callback, :test_namespace_two do
|
84
|
+
test_callback_namespace_two_called = true
|
85
|
+
end
|
86
|
+
|
87
|
+
registrar.dispatch :test_callback, :test_namespace_one
|
88
|
+
|
89
|
+
assert test_callback_namespace_one_called, 'Dispatching to test_callback with test_namespace_one namespace did not run callback for namespace_one'
|
90
|
+
refute test_callback_namespace_two_called, 'Dispatching to test_callback with test_namespace_one namespace called callback for namespace_two'
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_callbacks_return_output_in_known_format
|
94
|
+
registrar = DynamicRegistrar::Registrar.new(:default)
|
95
|
+
registrar.register! :test_callback, :test_namespace_one do
|
96
|
+
:aishgaoirhvoi43
|
97
|
+
end
|
98
|
+
registrar.register! :test_callback, :test_namespace_two do
|
99
|
+
:sdo8ivh90r8h034c
|
100
|
+
end
|
101
|
+
|
102
|
+
responses = registrar.dispatch :test_callback
|
103
|
+
|
104
|
+
assert_includes responses.keys, :test_namespace_one
|
105
|
+
assert_includes responses.keys, :test_namespace_two
|
106
|
+
assert_includes responses[:test_namespace_one].keys, :test_callback
|
107
|
+
assert_includes responses[:test_namespace_two].keys, :test_callback
|
108
|
+
assert_equal responses[:test_namespace_one][:test_callback], :aishgaoirhvoi43
|
109
|
+
assert_equal responses[:test_namespace_two][:test_callback], :sdo8ivh90r8h034c
|
110
|
+
end
|
111
|
+
|
112
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'abstract_unit'
|
2
|
+
require 'dynamic_registrar/version'
|
3
|
+
|
4
|
+
class DynamicRegistrarVersionTest < MiniTest::Unit::TestCase
|
5
|
+
|
6
|
+
def test_inspect_is_not_dynamic_registrar_version
|
7
|
+
refute DynamicRegistrar::Version.inspect == 'DynamicRegistrar::Version', 'DynamicRegistrar Version is DynamicRegistrar::Version, inspect is probably not defined properly'
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_inspect_return_value_is_not_same_as_to_s
|
11
|
+
refute DynamicRegistrar::Version.inspect == DynamicRegistrar::Version.to_s, 'DynamicRegistrar Version to_s equaled DynamicRegistrar Version inspect!'
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_to_s_returns_dynamic_registrar_version_module_name
|
15
|
+
assert DynamicRegistrar::Version.to_s == 'DynamicRegistrar::Version', 'DynamicRegistrar::Version.to_s did not return DynamicRegistrar::Version, someone probably adjusted it to display the version string.'
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_inspect_converts_version_properly
|
19
|
+
assert [DynamicRegistrar::Version::MAJOR, DynamicRegistrar::Version::MINOR, DynamicRegistrar::Version::PATCH].join('.') == DynamicRegistrar::Version.inspect, 'DynamicRegistrar::Version does not inspect properly'
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'abstract_unit'
|
2
|
+
require 'dynamic_registrar'
|
3
|
+
|
4
|
+
class DynamicRegistrarTest < MiniTest::Unit::TestCase
|
5
|
+
|
6
|
+
def test_inclusion_of_version
|
7
|
+
refute DynamicRegistrar::Version.nil?, 'DynamicRegistrar does not include version module'
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_inclusion_of_registrar
|
11
|
+
refute DynamicRegistrar::Registrar.nil?, 'DynamicRegistrar does not include registrar module'
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
metadata
ADDED
@@ -0,0 +1,146 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dynamic_registrar
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Justin Lynn (justinlynn)
|
13
|
+
- 3Crowd Technologies, Inc. (Sponsor)
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-12-26 00:00:00 -08:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: yard
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
- 6
|
32
|
+
- 3
|
33
|
+
version: 0.6.3
|
34
|
+
type: :runtime
|
35
|
+
version_requirements: *id001
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: cover_me
|
38
|
+
prerelease: false
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ~>
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
segments:
|
45
|
+
- 1
|
46
|
+
- 0
|
47
|
+
- 0
|
48
|
+
- rc4
|
49
|
+
version: 1.0.0.rc4
|
50
|
+
type: :runtime
|
51
|
+
version_requirements: *id002
|
52
|
+
- !ruby/object:Gem::Dependency
|
53
|
+
name: parallel_tests
|
54
|
+
prerelease: false
|
55
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
57
|
+
requirements:
|
58
|
+
- - ~>
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
segments:
|
61
|
+
- 0
|
62
|
+
- 4
|
63
|
+
- 9
|
64
|
+
version: 0.4.9
|
65
|
+
type: :runtime
|
66
|
+
version_requirements: *id003
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
name: ZenTest
|
69
|
+
prerelease: false
|
70
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
segments:
|
76
|
+
- 4
|
77
|
+
- 4
|
78
|
+
- 2
|
79
|
+
version: 4.4.2
|
80
|
+
type: :runtime
|
81
|
+
version_requirements: *id004
|
82
|
+
description: Namespaced and versioned registration of callbacks for dynamic invocation by clients
|
83
|
+
email:
|
84
|
+
- ops@3crowd.com
|
85
|
+
executables: []
|
86
|
+
|
87
|
+
extensions: []
|
88
|
+
|
89
|
+
extra_rdoc_files: []
|
90
|
+
|
91
|
+
files:
|
92
|
+
- .gitignore
|
93
|
+
- .rvmrc
|
94
|
+
- Gemfile
|
95
|
+
- Gemfile.lock
|
96
|
+
- LICENSE
|
97
|
+
- README.md
|
98
|
+
- Rakefile
|
99
|
+
- dynamic_registrar.gemspec
|
100
|
+
- lib/dynamic_registrar.rb
|
101
|
+
- lib/dynamic_registrar/errors/registration_conflict_error.rb
|
102
|
+
- lib/dynamic_registrar/registrar.rb
|
103
|
+
- lib/dynamic_registrar/version.rb
|
104
|
+
- test/abstract_unit.rb
|
105
|
+
- test/dynamic_registrar/errors/test_registration_conflict_error.rb
|
106
|
+
- test/dynamic_registrar/test_registrar.rb
|
107
|
+
- test/dynamic_registrar/test_version.rb
|
108
|
+
- test/test_dynamic_registrar.rb
|
109
|
+
has_rdoc: true
|
110
|
+
homepage: https://github.com/3Crowd/dynamic_registrar
|
111
|
+
licenses: []
|
112
|
+
|
113
|
+
post_install_message:
|
114
|
+
rdoc_options: []
|
115
|
+
|
116
|
+
require_paths:
|
117
|
+
- lib
|
118
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
119
|
+
none: false
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
segments:
|
124
|
+
- 0
|
125
|
+
version: "0"
|
126
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
127
|
+
none: false
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
segments:
|
132
|
+
- 0
|
133
|
+
version: "0"
|
134
|
+
requirements: []
|
135
|
+
|
136
|
+
rubyforge_project: dynamic_registrar
|
137
|
+
rubygems_version: 1.3.7
|
138
|
+
signing_key:
|
139
|
+
specification_version: 3
|
140
|
+
summary: Registration for dynamic invocation
|
141
|
+
test_files:
|
142
|
+
- test/abstract_unit.rb
|
143
|
+
- test/dynamic_registrar/errors/test_registration_conflict_error.rb
|
144
|
+
- test/dynamic_registrar/test_registrar.rb
|
145
|
+
- test/dynamic_registrar/test_version.rb
|
146
|
+
- test/test_dynamic_registrar.rb
|