edrive 1.0.4 → 1.0.5

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
  SHA256:
3
- metadata.gz: 7d15d921aedb78d60f0761a60b775f6c4b46d250501c198d17693fe83ddad71a
4
- data.tar.gz: 8dd7c8c5b6ad755f598c624ca033e05d322648c837ab1334a20e714a874f28c1
3
+ metadata.gz: e47a7b77728080f4f992e78d32b84fdb2f60af0e994c1fe0439abb04649e5d7e
4
+ data.tar.gz: 9e8d01b77f338210e9ecbda9b7b17938016dd1af1da0470a69d82b253193a2f6
5
5
  SHA512:
6
- metadata.gz: 32304c9cf830abd4053f576fe3e2dea981512790f65fc028f4c3ef7cf6371136299122147c7f2c55b1ce2b61b6c48dc5b4bd7e8304c2e1e4c8711323903f2b44
7
- data.tar.gz: e1443d02b252514f2957c6ece035ff0f4a2fb93f88fe1716ec136a8b20d1bb444bfd733757a5af9b6dc5de0003da342cdae5f8555944cc87306ef9b0a638032d
6
+ metadata.gz: aece7fc70c84065b5ac8d59da7b5f3e488d8ed5d2a4cd8ae98ff81db17c7c4cda27deac99607c96d49296b91186bcbc91c0656902f43823fed6dddddb39e0ceb
7
+ data.tar.gz: 2b1a6657d6ed38a580a27e19ea0e0f1c11a58746da9f154ef734d2bd0b051d8682a1d1b842cec9bb7bc8835c4aaf75d9cee5b00bac9e3af41c7b246290269067
data/.gitignore CHANGED
@@ -1,3 +1,3 @@
1
1
  pkg
2
2
  coverage
3
-
3
+ Gemfile.lock
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # edrive
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/edrive.svg)](https://badge.fury.io/rb/edrive)
4
- [![CircleCI](https://circleci.com/gh/MichinaoShimizu/edrive.svg?style=svg)](https://circleci.com/gh/MichinaoShimizu/edrive)
5
- [![Maintainability](https://api.codeclimate.com/v1/badges/5ad04170d3d57b928dc6/maintainability)](https://codeclimate.com/github/MichinaoShimizu/edrive/maintainability)
6
4
 
7
5
  Provide simple event dispatcher mechanism for all of ruby products.
8
6
 
@@ -26,6 +24,8 @@ Or install it yourself as:
26
24
 
27
25
  ### Edrive::Dispatcher
28
26
 
27
+ main class
28
+
29
29
  #### lambda & dispatch
30
30
 
31
31
  ```ruby
@@ -79,9 +79,21 @@ dispatcher.dispatch_with_data(:event, 100)
79
79
  106
80
80
  ```
81
81
 
82
+ ### clear target event
83
+
84
+ ```ruby
85
+ dispatcher.clear!(:event)
86
+ ```
87
+
88
+ ### clear all event
89
+
90
+ ```ruby
91
+ dispatcher.clear_all!
92
+ ```
93
+
82
94
  ### Edrive::ProcessorDispatcher
83
95
 
84
- Event dispatcher for processor class inherited `Edrive::Dispatcher` class.
96
+ Event dispatcher for processor class inherited `Edrive::Dispatcher`.
85
97
 
86
98
  Use `:before_process`, `:after_process` events only in this class.
87
99
 
@@ -101,7 +113,7 @@ This class has `dispatch_all` method.
101
113
 
102
114
  ### Edrive::Handler
103
115
 
104
- sample event handlers.
116
+ sample event handlers class.
105
117
 
106
118
  ```ruuby
107
119
  require 'edrive'
@@ -112,27 +124,9 @@ dispatcher.subscribe(:before, Edrive::Handler.json2hash)
112
124
  puts dispatcher.dispatch_with_data(:before, hoge: 2, fuga: 3)
113
125
  ```
114
126
 
115
- ### clear target event
116
-
117
- ```ruby
118
- dispatcher.clear!(:event)
119
- ```
120
-
121
- ### clear all event
122
-
123
- ```ruby
124
- dispatcher.clear_all!
125
- ```
126
-
127
- ## Development
128
-
129
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
130
-
131
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
132
-
133
127
  ## Contributing
134
128
 
135
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/edrive. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
129
+ Bug reports and pull requests are welcome on GitHub at https://github.com/MichinaoShimizu/edrive. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
136
130
 
137
131
  ## License
138
132
 
@@ -140,4 +134,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
140
134
 
141
135
  ## Code of Conduct
142
136
 
143
- Everyone interacting in the Edrive project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/edrive/blob/master/CODE_OF_CONDUCT.md).
137
+ Everyone interacting in the Edrive project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/MichinaoShimizu/edrive/blob/master/CODE_OF_CONDUCT.md).
@@ -6,61 +6,63 @@ require 'edrive/dispatcher'
6
6
  # @attr [Processor] processor processor object
7
7
  # @attr [Symbol] processor_process processor main method symbol
8
8
  # @author shimimi
9
- class ProcessorDispatcher < Edrive::Dispatcher
10
- attr_accessor :processor, :processor_process
9
+ module Edrive
10
+ class ProcessorDispatcher < Edrive::Dispatcher
11
+ attr_accessor :processor, :processor_process
11
12
 
12
- # @return [Array] defined event symbols
13
- DEFINED_EVENT = %i[before after].freeze
13
+ # @return [Array] defined event symbols
14
+ DEFINED_EVENT = %i[before_process after_process].freeze
14
15
 
15
- # @return [Symbol] default processor process symbol
16
- DEFAULT_PROCESSOR_PROCESS = :process
16
+ # @return [Symbol] default processor process symbol
17
+ DEFAULT_PROCESSOR_PROCESS = :process
17
18
 
18
- # Initialize
19
- # @param [Processor] processor processor object
20
- # @param [Symbol] processor_process processor main method
21
- def initialize(processor, processor_process = DEFAULT_PROCESSOR_PROCESS)
22
- super()
23
- @processor = processor
24
- @processor_process = processor_process
25
- end
19
+ # Initialize
20
+ # @param [Processor] processor processor object
21
+ # @param [Symbol] processor_process processor main method
22
+ def initialize(processor, processor_process = DEFAULT_PROCESSOR_PROCESS)
23
+ super()
24
+ @processor = processor
25
+ @processor_process = processor_process
26
+ end
26
27
 
27
- # subscribe handler (proc, lambda, block)
28
- # @param [Symbol] event event name symbol
29
- # @param [Proc] handler handler (lambda, proc)
30
- # @param [Block] block handler (block)
31
- # @raise ArgumentError
32
- # @return [Array] registered handler list
33
- def subscribe(event, handler = nil, &block)
34
- undefined_event_protect(event)
35
- super
36
- end
28
+ # subscribe handler (proc, lambda, block)
29
+ # @param [Symbol] event event name symbol
30
+ # @param [Proc] handler handler (lambda, proc)
31
+ # @param [Block] block handler (block)
32
+ # @raise ArgumentError
33
+ # @return [Array] registered handler list
34
+ def subscribe(event, handler = nil, &block)
35
+ undefined_event_protect(event)
36
+ super
37
+ end
37
38
 
38
- # Dispatch all events
39
- # @param [Boolean] use_result use processor process result in after_process event
40
- # @return [Mixed] last subscriber return value
41
- def dispatch_all(use_result = true)
42
- dispatch(DEFINED_EVENT[0])
43
- if use_result
44
- result = dispatch_processor_process
45
- return dispatch_with_data(DEFINED_EVENT[1], result)
39
+ # Dispatch all events
40
+ # @param [Boolean] use_result use processor process result in after_process event
41
+ # @return [Mixed] last subscriber return value
42
+ def dispatch_all(use_result = true)
43
+ dispatch(DEFINED_EVENT[0])
44
+ if use_result
45
+ result = dispatch_processor_process
46
+ return dispatch_with_data(DEFINED_EVENT[1], result)
47
+ end
48
+ dispatch_processor_process
49
+ dispatch(DEFINED_EVENT[1])
46
50
  end
47
- dispatch_processor_process
48
- dispatch(DEFINED_EVENT[1])
49
- end
50
51
 
51
- # Dispach processor process
52
- # @param [Mixed] args
53
- # @return [Mixed] processor process return value
54
- def dispatch_processor_process(*args)
55
- processor.send(processor_process, *args)
56
- end
52
+ # Dispach processor process
53
+ # @param [Mixed] args
54
+ # @return [Mixed] processor process return value
55
+ def dispatch_processor_process(*args)
56
+ processor.send(processor_process, *args)
57
+ end
57
58
 
58
- private
59
+ private
59
60
 
60
- # Check event is defined or not
61
- # @param [Symbol] event event name symbol
62
- # @raise ArgumentError
63
- def undefined_event_protect(event)
64
- raise ArgumentError, "event #{event} is not defined." unless DEFINED_EVENT.include?(event)
61
+ # Check event is defined or not
62
+ # @param [Symbol] event event name symbol
63
+ # @raise ArgumentError
64
+ def undefined_event_protect(event)
65
+ raise ArgumentError, "event #{event} is not defined." unless DEFINED_EVENT.include?(event)
66
+ end
65
67
  end
66
68
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Edrive
4
- VERSION = '1.0.4'.freeze
4
+ VERSION = '1.0.5'.freeze
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: edrive
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - MichinaoShimizu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-01 00:00:00.000000000 Z
11
+ date: 2018-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oj
@@ -92,7 +92,6 @@ files:
92
92
  - ".gitignore"
93
93
  - CODE_OF_CONDUCT.md
94
94
  - Gemfile
95
- - Gemfile.lock
96
95
  - LICENSE.txt
97
96
  - README.md
98
97
  - Rakefile
@@ -1,40 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- edrive (1.0.4)
5
- oj (~> 3.6)
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- diff-lcs (1.3)
11
- oj (3.6.2)
12
- rake (10.5.0)
13
- rspec (3.7.0)
14
- rspec-core (~> 3.7.0)
15
- rspec-expectations (~> 3.7.0)
16
- rspec-mocks (~> 3.7.0)
17
- rspec-core (3.7.1)
18
- rspec-support (~> 3.7.0)
19
- rspec-expectations (3.7.0)
20
- diff-lcs (>= 1.2.0, < 2.0)
21
- rspec-support (~> 3.7.0)
22
- rspec-mocks (3.7.0)
23
- diff-lcs (>= 1.2.0, < 2.0)
24
- rspec-support (~> 3.7.0)
25
- rspec-support (3.7.1)
26
- rspec_junit_formatter (0.4.1)
27
- rspec-core (>= 2, < 4, != 2.12.0)
28
-
29
- PLATFORMS
30
- ruby
31
-
32
- DEPENDENCIES
33
- bundler (~> 1.16)
34
- edrive!
35
- rake (~> 10.0)
36
- rspec (~> 3.0)
37
- rspec_junit_formatter (~> 0.4)
38
-
39
- BUNDLED WITH
40
- 1.16.2