cobracommander 0.0.5 → 0.0.6.pre.pre
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/cobracommander/command.rb +6 -14
- data/lib/cobracommander/command_bus.rb +11 -1
- data/lib/cobracommander/command_handler.rb +13 -1
- data/lib/cobracommander/composite_command.rb +10 -14
- data/lib/cobracommander/version.rb +1 -1
- metadata +28 -28
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1c1998ed1111082c636147dd139e35bc950adb55
|
|
4
|
+
data.tar.gz: 99e413d66c93c083bd94b9f80c6a360f2d0cb77c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9d0ca6f867ef35e90d8a756642279247ead8433f9cd2d55baf350c84f416605764a635dfed176c446013d2da2cb6f69e54ab102c79ccc49ee4d6fbf35a717f99
|
|
7
|
+
data.tar.gz: 247c646013ba4625d56b22a76773ffcfba8d6de9eed8bf22ce0248c2142836ab2dae584b65bc8191ef4736b67c5060351fbf85725f4d0a63fe47e159a50f09af
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
module CobraCommander
|
|
2
2
|
# Abstract
|
|
3
3
|
class Command
|
|
4
|
-
attr_reader :reversible
|
|
5
|
-
|
|
6
4
|
# @param nil
|
|
7
5
|
# @return Array
|
|
8
6
|
def expose
|
|
@@ -10,22 +8,16 @@ module CobraCommander
|
|
|
10
8
|
end
|
|
11
9
|
|
|
12
10
|
# NOTE: Meat of action should go here; assume Handler manages validation and just execute
|
|
11
|
+
# @param nil
|
|
12
|
+
# @return Error
|
|
13
13
|
def execute
|
|
14
14
|
raise NotImplementedError
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
-
def unexecute
|
|
18
|
-
raise NotImplementedError if reversible?
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def toggle_reversible
|
|
22
|
-
@reversible = !@reversible
|
|
23
|
-
end
|
|
24
|
-
|
|
25
17
|
# @param nil
|
|
26
|
-
# @return
|
|
27
|
-
def
|
|
28
|
-
|
|
29
|
-
end #
|
|
18
|
+
# @return Error
|
|
19
|
+
def unexecute
|
|
20
|
+
raise NotImplementedError
|
|
21
|
+
end # unexecute()
|
|
30
22
|
end # ::Command
|
|
31
23
|
end
|
|
@@ -7,8 +7,18 @@ module CobraCommander
|
|
|
7
7
|
command.expose.each do |cmd|
|
|
8
8
|
handler = CobraCommander::CommandTranslator.map_to_handler(cmd)
|
|
9
9
|
@handler = handler.new
|
|
10
|
-
@handler.handle(cmd)
|
|
10
|
+
return @handler.handle(cmd)
|
|
11
11
|
end
|
|
12
12
|
end # execute()
|
|
13
|
+
|
|
14
|
+
# @param Command
|
|
15
|
+
# @return mixed
|
|
16
|
+
def unexecute(command)
|
|
17
|
+
command.expose.each do |cmd|
|
|
18
|
+
handler = CobraCommander::CommandTranslator.map_to_handler(cmd)
|
|
19
|
+
@handler = handler.new
|
|
20
|
+
return @handler.unhandle(cmd)
|
|
21
|
+
end
|
|
22
|
+
end # unexecute()
|
|
13
23
|
end # ::CommandBus
|
|
14
24
|
end
|
|
@@ -7,6 +7,18 @@ module CobraCommander
|
|
|
7
7
|
# @return mixed
|
|
8
8
|
def handle(command)
|
|
9
9
|
command.execute
|
|
10
|
-
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# @param Command
|
|
13
|
+
# @return mixed
|
|
14
|
+
def unhandle(command)
|
|
15
|
+
command.unexecute
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# NOTE: Leaving this in until I can figure out a more sensible way to validate arguments
|
|
19
|
+
# If this stays, I plan to call validate(command).execute() within the handle() method in order to provide validation without having to overwrite handle()
|
|
20
|
+
def validate(*args)
|
|
21
|
+
|
|
22
|
+
end # validate()
|
|
11
23
|
end # ::CommandHandler
|
|
12
24
|
end
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
module CobraCommander
|
|
2
2
|
# Abstract
|
|
3
3
|
class CompositeCommand
|
|
4
|
-
attr_reader :
|
|
4
|
+
attr_reader :cmds
|
|
5
5
|
|
|
6
|
+
# @param Array
|
|
7
|
+
# @return void
|
|
6
8
|
def initialize(*commands)
|
|
7
9
|
@cmds = commands
|
|
8
10
|
end
|
|
@@ -31,22 +33,16 @@ module CobraCommander
|
|
|
31
33
|
end
|
|
32
34
|
end
|
|
33
35
|
|
|
36
|
+
# @param nil
|
|
37
|
+
# @return Error
|
|
34
38
|
def execute
|
|
35
39
|
raise NotImplementedError
|
|
36
40
|
end
|
|
37
41
|
|
|
38
|
-
def unexecute
|
|
39
|
-
raise NotImplementedError if reversible?
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def toggle_reversible
|
|
43
|
-
@reversible = !@reversible
|
|
44
|
-
end
|
|
45
|
-
|
|
46
42
|
# @param nil
|
|
47
|
-
# @return
|
|
48
|
-
def
|
|
49
|
-
|
|
50
|
-
end
|
|
51
|
-
end
|
|
43
|
+
# @return Error
|
|
44
|
+
def unexecute
|
|
45
|
+
raise NotImplementedError
|
|
46
|
+
end # unexecute()
|
|
47
|
+
end # ::CompositeCommand
|
|
52
48
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cobracommander
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.6.pre.pre
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- DouglasDDo
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2016-
|
|
11
|
+
date: 2016-08-05 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: A Ruby gem for implementing the Command Pattern.
|
|
14
14
|
email:
|
|
@@ -77,9 +77,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
77
77
|
version: '0'
|
|
78
78
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
79
79
|
requirements:
|
|
80
|
-
- - "
|
|
80
|
+
- - ">"
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
|
-
version:
|
|
82
|
+
version: 1.3.1
|
|
83
83
|
requirements: []
|
|
84
84
|
rubyforge_project:
|
|
85
85
|
rubygems_version: 2.2.2
|
|
@@ -87,39 +87,39 @@ signing_key:
|
|
|
87
87
|
specification_version: 4
|
|
88
88
|
summary: A Ruby gem for implementing the Command Pattern.
|
|
89
89
|
test_files:
|
|
90
|
-
- test/
|
|
91
|
-
- test/dummy/
|
|
92
|
-
- test/dummy/
|
|
93
|
-
- test/dummy/
|
|
94
|
-
- test/dummy/
|
|
95
|
-
- test/dummy/config/environment.rb
|
|
96
|
-
- test/dummy/config/application.rb
|
|
90
|
+
- test/test_helper.rb
|
|
91
|
+
- test/dummy/bin/setup
|
|
92
|
+
- test/dummy/bin/bundle
|
|
93
|
+
- test/dummy/bin/rails
|
|
94
|
+
- test/dummy/bin/rake
|
|
97
95
|
- test/dummy/config/database.yml
|
|
98
|
-
- test/dummy/config/initializers/mime_types.rb
|
|
99
96
|
- test/dummy/config/initializers/backtrace_silencers.rb
|
|
100
|
-
- test/dummy/config/initializers/
|
|
101
|
-
- test/dummy/config/initializers/filter_parameter_logging.rb
|
|
102
|
-
- test/dummy/config/initializers/cookies_serializer.rb
|
|
103
|
-
- test/dummy/config/initializers/assets.rb
|
|
97
|
+
- test/dummy/config/initializers/mime_types.rb
|
|
104
98
|
- test/dummy/config/initializers/inflections.rb
|
|
99
|
+
- test/dummy/config/initializers/wrap_parameters.rb
|
|
105
100
|
- test/dummy/config/initializers/session_store.rb
|
|
106
|
-
- test/dummy/config/
|
|
107
|
-
- test/dummy/config/
|
|
101
|
+
- test/dummy/config/initializers/assets.rb
|
|
102
|
+
- test/dummy/config/initializers/cookies_serializer.rb
|
|
103
|
+
- test/dummy/config/initializers/filter_parameter_logging.rb
|
|
104
|
+
- test/dummy/config/application.rb
|
|
105
|
+
- test/dummy/config/routes.rb
|
|
108
106
|
- test/dummy/config/environments/production.rb
|
|
109
107
|
- test/dummy/config/environments/test.rb
|
|
110
|
-
- test/dummy/config/
|
|
111
|
-
- test/dummy/config/routes.rb
|
|
108
|
+
- test/dummy/config/environments/development.rb
|
|
112
109
|
- test/dummy/config/secrets.yml
|
|
113
|
-
- test/dummy/
|
|
114
|
-
- test/dummy/config.
|
|
115
|
-
- test/dummy/
|
|
110
|
+
- test/dummy/config/environment.rb
|
|
111
|
+
- test/dummy/config/locales/en.yml
|
|
112
|
+
- test/dummy/config/boot.rb
|
|
116
113
|
- test/dummy/app/helpers/application_helper.rb
|
|
117
114
|
- test/dummy/app/views/layouts/application.html.erb
|
|
115
|
+
- test/dummy/app/controllers/application_controller.rb
|
|
118
116
|
- test/dummy/app/assets/javascripts/application.js
|
|
119
117
|
- test/dummy/app/assets/stylesheets/application.css
|
|
120
|
-
- test/dummy/
|
|
121
|
-
- test/dummy/
|
|
122
|
-
- test/dummy/
|
|
123
|
-
- test/dummy/
|
|
118
|
+
- test/dummy/README.rdoc
|
|
119
|
+
- test/dummy/config.ru
|
|
120
|
+
- test/dummy/Rakefile
|
|
121
|
+
- test/dummy/public/422.html
|
|
122
|
+
- test/dummy/public/favicon.ico
|
|
123
|
+
- test/dummy/public/404.html
|
|
124
|
+
- test/dummy/public/500.html
|
|
124
125
|
- test/cobracommander_test.rb
|
|
125
|
-
- test/test_helper.rb
|