cobracommander 0.0.1.pre.beta → 0.0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 49ace5cf729ae02baf05a83b57b1aa1f4385a5f2
4
- data.tar.gz: 1ba2904478371ee75ae7dd13c49b015f51ad0916
3
+ metadata.gz: 409545a98433d23e825ebb7c6f2c1eb64c3c758e
4
+ data.tar.gz: 19eb4adb85cf7ca2a0ca27b07009fb910d799f14
5
5
  SHA512:
6
- metadata.gz: 2ddc01acc4ca338d0738beae15eab82b943bbf2923e6a09a51871a8057bee24ed034917621cea4743de295d60827c5b3c8668edc529d3394167fff9689633e6c
7
- data.tar.gz: 5376311901fcb5730b96342783a836f217363121a97ab59e82c92b88153785fd134a49c6991c314cc6b85b717e117d1a55284d13ce6af230fa45e1719a34f045
6
+ metadata.gz: f95ac0de36a0f636eeab0005ce28570b3f9638df1ea7c4b395fd0b805971df1eb0766657037d97e25b53b2ae371e815b17260825ec7dab74ac64ce44eba49e98
7
+ data.tar.gz: 76c4a63a16b8f805b1bf1f5ab1bf1053eee42bc532a46c9f5eb85194cef56c869c9e6176e407f95d1387000627c314b3c5192c4349492505ce35285784bebdbc
@@ -3,8 +3,6 @@ module CobraCommander
3
3
  class Command
4
4
  attr_reader :reversible
5
5
 
6
- # Liskov Substitution Principle
7
- # avoids having to change CommandBus by keeping interface consistent
8
6
  # @param nil
9
7
  # @return Array
10
8
  def expose
@@ -17,7 +15,7 @@ module CobraCommander
17
15
  end
18
16
 
19
17
  def unexecute
20
- raise NotImplementedError if @reversible
18
+ raise NotImplementedError if reversible?
21
19
  end
22
20
 
23
21
  def toggle_reversible
@@ -26,7 +24,7 @@ module CobraCommander
26
24
 
27
25
  # @param nil
28
26
  # @return Boolean
29
- def is_reversible?
27
+ def reversible?
30
28
  @reversible
31
29
  end # is_reversible?()
32
30
  end # ::Command
@@ -1,21 +1,12 @@
1
1
  module CobraCommander
2
2
  module CommandBus
3
- # NOTE: include in class, not extend
4
3
 
5
4
  # @param Command
6
5
  # @return mixed
7
6
  def execute(command)
8
- # use CommandTranslator
9
- ##-> take in command
10
- ##-> return matched handler
11
- ##-> assign handler to var
12
-
13
7
  command.expose.each do |cmd|
14
8
  handler = CobraCommander::CommandTranslator.map_to_handler(cmd)
15
- # instantiate handler
16
9
  @handler = handler.new
17
- # assign handler instance
18
- ##-> invoke handle() method and pass in command
19
10
  @handler.handle(cmd)
20
11
  end
21
12
  end # execute()
@@ -2,10 +2,10 @@ module CobraCommander
2
2
  # Abstract
3
3
  class CommandHandler
4
4
 
5
+ # NOTE: If you need validation, implement it in this method in the Child CommandHandler
5
6
  # @param Command
6
7
  # @return mixed
7
8
  def handle(command)
8
- # NOTE: Validation should go here.
9
9
  command.execute
10
10
  end # handle()
11
11
  end # ::CommandHandler
@@ -1,17 +1,13 @@
1
1
  module CobraCommander
2
- # NOTE: May change this to module. Include in CommandBus. Reduce instantiation?
3
2
  class CommandTranslator
4
3
 
5
4
  # @param Command
6
5
  # @return CommandHandler
7
6
  def self.map_to_handler(command)
8
- # takes in command
9
- # turns command to String
10
- # append 'Handler' to String
11
7
  @handler = command.class.to_s + 'Handler'
12
- # return CommandHandler or raise error if no matching CommandHandler exists
8
+
13
9
  if Object.const_get(@handler).is_a?(Class)
14
- return @handler.constantize
10
+ return Object.const_get(@handler)
15
11
  else
16
12
  raise "There is no CommandHandler by that name"
17
13
  end
@@ -36,7 +36,7 @@ module CobraCommander
36
36
  end
37
37
 
38
38
  def unexecute
39
- raise NotImplementedError if @reversible
39
+ raise NotImplementedError if reversible?
40
40
  end
41
41
 
42
42
  def toggle_reversible
@@ -45,7 +45,7 @@ module CobraCommander
45
45
 
46
46
  # @param nil
47
47
  # @return Boolean
48
- def is_reversible?
48
+ def reversible?
49
49
  @reversible
50
50
  end
51
51
  end
@@ -1,3 +1,3 @@
1
1
  module CobraCommander
2
- VERSION = "0.0.1-beta"
2
+ VERSION = "0.0.2.pre"
3
3
  end
@@ -1,8 +1,4 @@
1
- # require 'cobracommander/command_bus'
2
- # require 'cobracommander/command_handler'
3
- # require 'cobracommander/command_translator'
4
- # require 'cobracommander/command'
5
- # require 'cobracommander/composite_command'
1
+ require 'active_support/dependencies/autoload'
6
2
  require 'cobracommander/version'
7
3
 
8
4
  module CobraCommander
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.1.pre.beta
4
+ version: 0.0.2.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-07-22 00:00:00.000000000 Z
11
+ date: 2016-07-25 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A Ruby gem for implementing the Command Pattern.
14
14
  email:
@@ -26,7 +26,6 @@ files:
26
26
  - lib/cobracommander/command_translator.rb
27
27
  - lib/cobracommander/composite_command.rb
28
28
  - lib/cobracommander/version.rb
29
- - lib/tasks/cobracommander_tasks.rake
30
29
  - test/cobracommander_test.rb
31
30
  - test/dummy/README.rdoc
32
31
  - test/dummy/Rakefile
@@ -1,4 +0,0 @@
1
- # desc "Explaining what the task does"
2
- # task :cobracommander do
3
- # # Task goes here
4
- # end