fusuma 0.11.1 → 1.0
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/.github/FUNDING.yml +8 -0
- data/.gitignore +6 -0
- data/.reek.yml +93 -45
- data/.rubocop.yml +2 -0
- data/.rubocop_todo.yml +16 -75
- data/Gemfile +2 -0
- data/README.md +12 -5
- data/Rakefile +2 -1
- data/bin/console +1 -1
- data/exe/fusuma +1 -0
- data/fusuma.gemspec +9 -2
- data/lib/fusuma.rb +88 -31
- data/lib/fusuma/config.rb +65 -66
- data/lib/fusuma/config/index.rb +49 -0
- data/lib/fusuma/device.rb +58 -37
- data/lib/fusuma/multi_logger.rb +3 -0
- data/lib/fusuma/plugin/base.rb +56 -0
- data/lib/fusuma/plugin/buffers/buffer.rb +41 -0
- data/lib/fusuma/plugin/buffers/gesture_buffer.rb +70 -0
- data/lib/fusuma/plugin/detectors/detector.rb +41 -0
- data/lib/fusuma/plugin/detectors/pinch_detector.rb +141 -0
- data/lib/fusuma/plugin/detectors/rotate_detector.rb +135 -0
- data/lib/fusuma/plugin/detectors/swipe_detector.rb +145 -0
- data/lib/fusuma/plugin/events/event.rb +38 -0
- data/lib/fusuma/plugin/events/records/gesture_record.rb +31 -0
- data/lib/fusuma/plugin/events/records/index_record.rb +53 -0
- data/lib/fusuma/plugin/events/records/record.rb +20 -0
- data/lib/fusuma/plugin/events/records/text_record.rb +28 -0
- data/lib/fusuma/plugin/executors/command_executor.rb +39 -0
- data/lib/fusuma/plugin/executors/executor.rb +27 -0
- data/lib/fusuma/plugin/filters/filter.rb +40 -0
- data/lib/fusuma/plugin/filters/libinput_device_filter.rb +42 -0
- data/lib/fusuma/plugin/inputs/input.rb +28 -0
- data/lib/fusuma/plugin/inputs/libinput_command_input.rb +133 -0
- data/lib/fusuma/plugin/manager.rb +118 -0
- data/lib/fusuma/plugin/parsers/libinput_gesture_parser.rb +54 -0
- data/lib/fusuma/plugin/parsers/parser.rb +46 -0
- data/lib/fusuma/version.rb +3 -1
- metadata +74 -14
- data/lib/fusuma/command_executor.rb +0 -43
- data/lib/fusuma/event_stack.rb +0 -87
- data/lib/fusuma/gesture_event.rb +0 -50
- data/lib/fusuma/libinput_commands.rb +0 -98
- data/lib/fusuma/pinch.rb +0 -58
- data/lib/fusuma/swipe.rb +0 -59
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 80d93508637448b749150766ad39d75fffa6b993600ff40d3c95129fee193ba0
|
4
|
+
data.tar.gz: 408a2ab6bbe496f5a7d989400e3598fc9aa9371e9c13e6a9fc4e5b915033efbb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8bbc0dbaee8c103c2d2c8d506975d85d531ba14ca204c886f2d95a6b7812f133e97e45e418086290b07e4f0aad653bf15296a1b4f7e74b63f25d02d9f4a89553
|
7
|
+
data.tar.gz: 71746fc05185021c81e54ff4956895b7e8e1644638a1b0e5917b86864175cd544085e90bf9422fb3910ecc33b8d199295ade1198eb5122b61856e5dcb58b9358
|
data/.github/FUNDING.yml
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
# These are supported funding model platforms
|
2
|
+
|
3
|
+
github: # [iberianpig] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
4
|
+
patreon: iberianpig # Replace with a single Patreon username
|
5
|
+
open_collective: # Replace with a single Open Collective username
|
6
|
+
ko_fi: # Replace with a single Ko-fi username
|
7
|
+
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
8
|
+
custom: # Replace with a single custom sponsorship URL
|
data/.gitignore
CHANGED
data/.reek.yml
CHANGED
@@ -1,48 +1,96 @@
|
|
1
|
-
---
|
2
|
-
|
3
|
-
### Generic smell configuration
|
4
1
|
|
2
|
+
---
|
3
|
+
### enabled rules
|
5
4
|
detectors:
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
5
|
+
TooManyInstanceVariables:
|
6
|
+
enabled: true
|
7
|
+
exclude: []
|
8
|
+
max_instance_variables: 50
|
9
|
+
TooManyMethods:
|
10
|
+
enabled: true
|
11
|
+
exclude: []
|
12
|
+
max_methods: 30
|
13
|
+
TooManyStatements:
|
14
|
+
enabled: true
|
15
|
+
exclude: []
|
16
|
+
max_statements: 80
|
17
|
+
TooManyConstants:
|
18
|
+
enabled: true
|
19
|
+
exclude: []
|
20
|
+
max_constants: 50
|
21
|
+
LongParameterList:
|
22
|
+
enabled: true
|
23
|
+
exclude: []
|
24
|
+
max_params: 8
|
25
|
+
LongYieldList:
|
26
|
+
enabled: true
|
27
|
+
exclude: []
|
28
|
+
max_params: 8
|
29
|
+
NestedIterators:
|
30
|
+
enabled: true
|
31
|
+
exclude: []
|
32
|
+
max_allowed_nesting: 5
|
33
|
+
ignore_iterators:
|
34
|
+
- tap
|
35
|
+
ModuleInitialize:
|
36
|
+
enabled: true
|
37
|
+
exclude: []
|
38
|
+
SubclassedFromCoreClass:
|
39
|
+
enabled: true
|
40
|
+
exclude: []
|
11
41
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
42
|
+
### unanabled rules
|
43
|
+
Attribute:
|
44
|
+
enabled: false
|
45
|
+
exclude: []
|
46
|
+
BooleanParameter:
|
47
|
+
enabled: false
|
48
|
+
exclude: []
|
49
|
+
ClassVariable:
|
50
|
+
enabled: false
|
51
|
+
exclude: []
|
52
|
+
ControlParameter:
|
53
|
+
enabled: false
|
54
|
+
exclude: []
|
55
|
+
DataClump:
|
56
|
+
enabled: false
|
57
|
+
exclude: []
|
58
|
+
DuplicateMethodCall:
|
59
|
+
enabled: false
|
60
|
+
exclude: []
|
61
|
+
FeatureEnvy:
|
62
|
+
enabled: false
|
63
|
+
exclude: []
|
64
|
+
InstanceVariableAssumption:
|
65
|
+
enabled: false
|
66
|
+
exclude: []
|
67
|
+
IrresponsibleModule:
|
68
|
+
enabled: false
|
69
|
+
exclude: []
|
70
|
+
ManualDispatch:
|
71
|
+
enabled: false
|
72
|
+
exclude: []
|
73
|
+
NilCheck:
|
74
|
+
enabled: false
|
75
|
+
exclude: []
|
76
|
+
RepeatedConditional:
|
77
|
+
enabled: false
|
78
|
+
exclude: []
|
79
|
+
UncommunicativeMethodName:
|
80
|
+
enabled: false
|
81
|
+
exclude: []
|
82
|
+
UncommunicativeModuleName:
|
83
|
+
enabled: false
|
84
|
+
exclude: []
|
85
|
+
UncommunicativeParameterName:
|
86
|
+
enabled: false
|
87
|
+
exclude: []
|
88
|
+
UncommunicativeVariableName:
|
89
|
+
enabled: false
|
90
|
+
exclude: []
|
91
|
+
UnusedParameters:
|
92
|
+
enabled: false
|
93
|
+
exclude: []
|
94
|
+
UtilityFunction:
|
95
|
+
enabled: false
|
96
|
+
exclude: []
|
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
CHANGED
@@ -1,60 +1,28 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on 2019-
|
3
|
+
# on 2019-08-12 15:52:49 +0900 using RuboCop version 0.74.0.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
8
8
|
|
9
9
|
# Offense count: 3
|
10
|
-
|
11
|
-
|
12
|
-
# SupportedHashRocketStyles: key, separator, table
|
13
|
-
# SupportedColonStyles: key, separator, table
|
14
|
-
# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
|
15
|
-
Layout/AlignHash:
|
16
|
-
Exclude:
|
17
|
-
- 'spec/lib/config_spec.rb'
|
18
|
-
|
19
|
-
# Offense count: 20
|
20
|
-
# Cop supports --auto-correct.
|
21
|
-
Layout/EmptyLineAfterGuardClause:
|
22
|
-
Exclude:
|
23
|
-
- 'lib/fusuma.rb'
|
24
|
-
- 'lib/fusuma/command_executor.rb'
|
25
|
-
- 'lib/fusuma/config.rb'
|
26
|
-
- 'lib/fusuma/device.rb'
|
27
|
-
- 'lib/fusuma/event_stack.rb'
|
28
|
-
- 'lib/fusuma/gesture_event.rb'
|
29
|
-
- 'lib/fusuma/libinput_commands.rb'
|
30
|
-
- 'lib/fusuma/multi_logger.rb'
|
31
|
-
- 'lib/fusuma/pinch.rb'
|
32
|
-
- 'lib/fusuma/swipe.rb'
|
10
|
+
Metrics/AbcSize:
|
11
|
+
Max: 25
|
33
12
|
|
34
|
-
# Offense count:
|
35
|
-
#
|
36
|
-
|
37
|
-
|
38
|
-
Exclude:
|
39
|
-
- 'lib/fusuma/device.rb'
|
13
|
+
# Offense count: 6
|
14
|
+
# Configuration parameters: CountComments, ExcludedMethods.
|
15
|
+
Metrics/MethodLength:
|
16
|
+
Max: 15
|
40
17
|
|
41
|
-
# Offense count:
|
42
|
-
|
43
|
-
# Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, IgnoredMethods, AllowBracesOnProceduralOneLiners.
|
44
|
-
# SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces
|
45
|
-
# ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object
|
46
|
-
# FunctionalMethods: let, let!, subject, watch
|
47
|
-
# IgnoredMethods: lambda, proc, it
|
48
|
-
Style/BlockDelimiters:
|
18
|
+
# Offense count: 3
|
19
|
+
Style/Documentation:
|
49
20
|
Exclude:
|
50
|
-
- '
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
# SupportedStyles: always, never
|
56
|
-
Style/FrozenStringLiteralComment:
|
57
|
-
Enabled: false
|
21
|
+
- 'spec/**/*'
|
22
|
+
- 'test/**/*'
|
23
|
+
- 'lib/fusuma/plugin/detectors/pinch_detector.rb'
|
24
|
+
- 'lib/fusuma/plugin/detectors/rotate_detector.rb'
|
25
|
+
- 'lib/fusuma/plugin/detectors/swipe_detector.rb'
|
58
26
|
|
59
27
|
# Offense count: 3
|
60
28
|
# Cop supports --auto-correct.
|
@@ -63,32 +31,5 @@ Style/FrozenStringLiteralComment:
|
|
63
31
|
Style/NumericPredicate:
|
64
32
|
Exclude:
|
65
33
|
- 'spec/**/*'
|
66
|
-
- 'lib/fusuma/
|
67
|
-
- 'lib/fusuma/
|
68
|
-
|
69
|
-
# Offense count: 1
|
70
|
-
# Cop supports --auto-correct.
|
71
|
-
# Configuration parameters: ConvertCodeThatCanStartToReturnNil, Whitelist.
|
72
|
-
# Whitelist: present?, blank?, presence, try, try!
|
73
|
-
Style/SafeNavigation:
|
74
|
-
Exclude:
|
75
|
-
- 'lib/fusuma.rb'
|
76
|
-
|
77
|
-
# Offense count: 1
|
78
|
-
# Cop supports --auto-correct.
|
79
|
-
Style/UnneededInterpolation:
|
80
|
-
Exclude:
|
81
|
-
- 'lib/fusuma/command_executor.rb'
|
82
|
-
|
83
|
-
# Offense count: 1
|
84
|
-
# Cop supports --auto-correct.
|
85
|
-
Style/UnneededPercentQ:
|
86
|
-
Exclude:
|
87
|
-
- 'spec/lib/command_executor_spec.rb'
|
88
|
-
|
89
|
-
# Offense count: 3
|
90
|
-
# Cop supports --auto-correct.
|
91
|
-
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
92
|
-
# URISchemes: http, https
|
93
|
-
Metrics/LineLength:
|
94
|
-
Max: 87
|
34
|
+
- 'lib/fusuma/plugin/detectors/rotate_detector.rb'
|
35
|
+
- 'lib/fusuma/plugin/detectors/swipe_detector.rb'
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Fusuma [](https://badge.fury.io/rb/fusuma) [](https://travis-ci.org/iberianpig/fusuma)
|
2
2
|
|
3
3
|
Fusuma is multitouch gesture recognizer.
|
4
|
-
This gem makes your linux
|
4
|
+
This gem makes your linux able to recognize swipes or pinchs and assign commands to them.
|
5
5
|
|
6
6
|

|
7
7
|
|
@@ -16,7 +16,7 @@ This gem makes your linux PC able to recognize swipes or pinchs and assign comma
|
|
16
16
|
$ sudo gpasswd -a $USER input
|
17
17
|
```
|
18
18
|
|
19
|
-
Then, You **MUST** **
|
19
|
+
Then, You **MUST** **REBOOT** to assign this group.
|
20
20
|
|
21
21
|
### 2. Install libinput-tools
|
22
22
|
You need `libinput` release 1.0 or later.
|
@@ -25,13 +25,20 @@ You need `libinput` release 1.0 or later.
|
|
25
25
|
$ sudo apt-get install libinput-tools
|
26
26
|
```
|
27
27
|
|
28
|
-
### 3. Install
|
28
|
+
### 3. Install Ruby
|
29
|
+
Fusuma runs in Ruby, so you must install it first.
|
30
|
+
|
31
|
+
```bash
|
32
|
+
$ sudo apt-get install ruby
|
33
|
+
```
|
34
|
+
|
35
|
+
### 4. Install Fusuma
|
29
36
|
|
30
37
|
```bash
|
31
38
|
$ sudo gem install fusuma
|
32
39
|
```
|
33
40
|
|
34
|
-
###
|
41
|
+
### 5. Install xdotool (optional)
|
35
42
|
|
36
43
|
For sending shortcuts:
|
37
44
|
```bash
|
@@ -126,7 +133,7 @@ swipe:
|
|
126
133
|
command: 'xdotool key super'
|
127
134
|
4:
|
128
135
|
up:
|
129
|
-
command: '
|
136
|
+
command: 'xdotool key super+m'
|
130
137
|
down:
|
131
138
|
command: 'xdotool key super+m'
|
132
139
|
pinch:
|
data/Rakefile
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'bundler/gem_tasks'
|
2
4
|
require 'rspec/core/rake_task'
|
3
5
|
|
@@ -5,7 +7,6 @@ RSpec::Core::RakeTask.new(:spec)
|
|
5
7
|
|
6
8
|
task default: :spec
|
7
9
|
|
8
|
-
|
9
10
|
require 'github_changelog_generator/task'
|
10
11
|
|
11
12
|
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
|
data/bin/console
CHANGED
data/exe/fusuma
CHANGED
data/fusuma.gemspec
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
lib = File.expand_path('lib', __dir__)
|
2
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
5
|
require 'fusuma/version'
|
@@ -9,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
9
11
|
spec.email = ['yhkyky@gmail.com']
|
10
12
|
|
11
13
|
spec.summary = 'Multitouch gestures with libinput dirver on X11, Linux'
|
12
|
-
spec.description = 'Fusuma is multitouch gesture recognizer. This gem makes your
|
14
|
+
spec.description = 'Fusuma is multitouch gesture recognizer. This gem makes your touchpad on Linux able to recognize swipes or pinchs and assign command to them. Read installation on Github(https://github.com/iberianpig/fusuma#installation).'
|
13
15
|
spec.homepage = 'https://github.com/iberianpig/fusuma'
|
14
16
|
spec.license = 'MIT'
|
15
17
|
|
@@ -19,12 +21,17 @@ Gem::Specification.new do |spec|
|
|
19
21
|
spec.bindir = 'exe'
|
20
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
23
|
spec.require_paths = ['lib']
|
24
|
+
spec.metadata['yard.run'] = 'yri' # use "yard" to build full HTML docs.
|
22
25
|
|
26
|
+
spec.required_ruby_version = '>= 2.3' # https://packages.ubuntu.com/search?keywords=ruby&searchon=names&exact=1&suite=all§ion=main
|
23
27
|
spec.add_development_dependency 'bundler'
|
24
28
|
spec.add_development_dependency 'github_changelog_generator', '~> 1.14'
|
25
29
|
spec.add_development_dependency 'pry-byebug', '~> 3.4'
|
26
|
-
spec.add_development_dependency '
|
30
|
+
spec.add_development_dependency 'pry-doc'
|
31
|
+
spec.add_development_dependency 'pry-inline'
|
32
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
27
33
|
spec.add_development_dependency 'reek'
|
28
34
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
29
35
|
spec.add_development_dependency 'rubocop'
|
36
|
+
spec.add_development_dependency 'yard'
|
30
37
|
end
|
data/lib/fusuma.rb
CHANGED
@@ -1,16 +1,10 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require_relative 'fusuma/
|
4
|
-
require_relative 'fusuma/
|
5
|
-
require_relative 'fusuma/
|
6
|
-
require_relative 'fusuma/
|
7
|
-
require_relative 'fusuma/
|
8
|
-
require_relative 'fusuma/config.rb'
|
9
|
-
require_relative 'fusuma/device.rb'
|
10
|
-
require_relative 'fusuma/libinput_commands.rb'
|
11
|
-
require 'logger'
|
12
|
-
require 'open3'
|
13
|
-
require 'yaml'
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative './fusuma/version'
|
4
|
+
require_relative './fusuma/multi_logger'
|
5
|
+
require_relative './fusuma/config.rb'
|
6
|
+
require_relative './fusuma/device.rb'
|
7
|
+
require_relative './fusuma/plugin/manager.rb'
|
14
8
|
|
15
9
|
# this is top level module
|
16
10
|
module Fusuma
|
@@ -32,53 +26,116 @@ module Fusuma
|
|
32
26
|
end
|
33
27
|
|
34
28
|
def read_options(option)
|
35
|
-
|
29
|
+
MultiLogger.instance.debug_mode = option[:verbose]
|
30
|
+
|
31
|
+
load_custom_config(option[:config_path])
|
32
|
+
|
33
|
+
Plugin::Manager.require_plugins_from_relative
|
34
|
+
Plugin::Manager.require_plugins_from_config
|
35
|
+
|
36
|
+
print_version(then_exit: option[:version])
|
37
|
+
print_enabled_plugins
|
38
|
+
|
36
39
|
print_device_list if option[:list]
|
37
|
-
|
38
|
-
debug_mode if option[:verbose]
|
39
|
-
Device.given_device = option[:device]
|
40
|
+
Device.given_devices = option[:device]
|
40
41
|
Process.daemon if option[:daemon]
|
41
42
|
end
|
42
43
|
|
43
|
-
|
44
|
+
# TODO: print after reading plugins
|
45
|
+
def print_version(then_exit: false)
|
44
46
|
MultiLogger.info '---------------------------------------------'
|
45
47
|
MultiLogger.info "Fusuma: #{Fusuma::VERSION}"
|
46
|
-
MultiLogger.info "libinput: #{
|
48
|
+
MultiLogger.info "libinput: #{Plugin::Inputs::LibinputCommandInput.new.version}"
|
47
49
|
MultiLogger.info "OS: #{`uname -rsv`}".strip
|
48
50
|
MultiLogger.info "Distribution: #{`cat /etc/issue`}".strip
|
49
51
|
MultiLogger.info "Desktop session: #{`echo $DESKTOP_SESSION`}".strip
|
50
52
|
MultiLogger.info '---------------------------------------------'
|
53
|
+
Kernel.exit(0) if then_exit
|
54
|
+
end
|
55
|
+
|
56
|
+
def print_enabled_plugins
|
57
|
+
MultiLogger.debug '---------------------------------------------'
|
58
|
+
MultiLogger.debug 'Enabled Plugins: '
|
59
|
+
Plugin::Manager.plugins
|
60
|
+
.reject { |k, _v| k.to_s =~ /Base/ }
|
61
|
+
.map { |_base, plugins| plugins.map { |plugin| " #{plugin}" } }
|
62
|
+
.flatten.sort.each { |name| MultiLogger.debug name }
|
63
|
+
MultiLogger.debug '---------------------------------------------'
|
51
64
|
end
|
52
65
|
|
53
66
|
def print_device_list
|
54
|
-
puts Device.
|
67
|
+
puts Device.available.map(&:name)
|
55
68
|
exit(0)
|
56
69
|
end
|
57
70
|
|
58
|
-
def
|
71
|
+
def load_custom_config(config_path = nil)
|
59
72
|
return unless config_path
|
60
|
-
|
61
|
-
Config.
|
62
|
-
Config.reload
|
73
|
+
|
74
|
+
Config.custom_path = config_path
|
63
75
|
end
|
64
76
|
|
65
77
|
def debug_mode
|
66
|
-
print_version
|
67
78
|
MultiLogger.instance.debug_mode = true
|
79
|
+
print_version
|
68
80
|
end
|
69
81
|
end
|
70
82
|
|
71
83
|
def initialize
|
72
|
-
@
|
84
|
+
@inputs = Plugin::Inputs::Input.plugins.map(&:new)
|
85
|
+
@filters = Plugin::Filters::Filter.plugins.map(&:new)
|
86
|
+
@parsers = Plugin::Parsers::Parser.plugins.map(&:new)
|
87
|
+
@buffers = Plugin::Buffers::Buffer.plugins.map(&:new)
|
88
|
+
@detectors = Plugin::Detectors::Detector.plugins.map(&:new)
|
89
|
+
@executors = Plugin::Executors::Executor.plugins.map(&:new)
|
73
90
|
end
|
74
91
|
|
75
92
|
def run
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
93
|
+
# TODO: run with multi thread
|
94
|
+
@inputs.first.run do |event|
|
95
|
+
filtered = filter(event)
|
96
|
+
parsed = parse(filtered)
|
97
|
+
buffered = buffer(parsed)
|
98
|
+
detected = detect(buffered)
|
99
|
+
execute(detected)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def filter(event)
|
104
|
+
@filters.reduce(event) { |e, f| f.filter(e) if e }
|
105
|
+
end
|
106
|
+
|
107
|
+
def parse(event)
|
108
|
+
@parsers.reduce(event) { |e, p| p.parse(e) if e }
|
109
|
+
end
|
110
|
+
|
111
|
+
def buffer(event)
|
112
|
+
@buffers.each { |b| b.buffer(event) }
|
113
|
+
end
|
114
|
+
|
115
|
+
# @param buffers [Array<Buffer>]
|
116
|
+
# @return [Event] if event is detected
|
117
|
+
# @return [NilClass] if event is NOT detected
|
118
|
+
def detect(buffers)
|
119
|
+
@detectors.each_with_object([]) do |detector, index_records|
|
120
|
+
event = detector.detect(buffers) # event
|
121
|
+
|
122
|
+
if event&.record&.mergable?
|
123
|
+
event.record.merge(records: index_records)
|
124
|
+
buffers.each(&:clear) # clear buffer
|
125
|
+
break(event)
|
126
|
+
end
|
127
|
+
|
128
|
+
break nil if @detectors.last == detector
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
def execute(event)
|
133
|
+
return unless event
|
134
|
+
|
135
|
+
executor = @executors.find do |e|
|
136
|
+
e.executable?(event)
|
81
137
|
end
|
138
|
+
executor&.execute(event)
|
82
139
|
end
|
83
140
|
end
|
84
141
|
end
|