fusuma 2.4.0 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +34 -2
  3. data/fusuma.gemspec +17 -18
  4. data/lib/fusuma/config/index.rb +17 -17
  5. data/lib/fusuma/config/searcher.rb +1 -1
  6. data/lib/fusuma/config/yaml_duplication_checker.rb +7 -7
  7. data/lib/fusuma/config.rb +17 -13
  8. data/lib/fusuma/device.rb +12 -12
  9. data/lib/fusuma/environment.rb +10 -10
  10. data/lib/fusuma/hash_support.rb +1 -1
  11. data/lib/fusuma/libinput_command.rb +18 -19
  12. data/lib/fusuma/multi_logger.rb +4 -4
  13. data/lib/fusuma/plugin/base.rb +6 -6
  14. data/lib/fusuma/plugin/buffers/buffer.rb +5 -4
  15. data/lib/fusuma/plugin/buffers/gesture_buffer.rb +6 -6
  16. data/lib/fusuma/plugin/buffers/timer_buffer.rb +2 -2
  17. data/lib/fusuma/plugin/detectors/detector.rb +5 -5
  18. data/lib/fusuma/plugin/detectors/hold_detector.rb +29 -29
  19. data/lib/fusuma/plugin/detectors/pinch_detector.rb +47 -47
  20. data/lib/fusuma/plugin/detectors/rotate_detector.rb +40 -40
  21. data/lib/fusuma/plugin/detectors/swipe_detector.rb +43 -43
  22. data/lib/fusuma/plugin/events/event.rb +11 -11
  23. data/lib/fusuma/plugin/events/records/gesture_record.rb +5 -5
  24. data/lib/fusuma/plugin/events/records/index_record.rb +5 -5
  25. data/lib/fusuma/plugin/events/records/record.rb +2 -2
  26. data/lib/fusuma/plugin/events/records/text_record.rb +1 -1
  27. data/lib/fusuma/plugin/executors/command_executor.rb +4 -4
  28. data/lib/fusuma/plugin/executors/executor.rb +3 -3
  29. data/lib/fusuma/plugin/filters/filter.rb +3 -3
  30. data/lib/fusuma/plugin/filters/libinput_device_filter.rb +12 -12
  31. data/lib/fusuma/plugin/inputs/input.rb +8 -8
  32. data/lib/fusuma/plugin/inputs/libinput_command_input.rb +13 -13
  33. data/lib/fusuma/plugin/inputs/timer_input.rb +3 -3
  34. data/lib/fusuma/plugin/manager.rb +27 -21
  35. data/lib/fusuma/plugin/parsers/libinput_gesture_parser.rb +10 -10
  36. data/lib/fusuma/plugin/parsers/parser.rb +3 -3
  37. data/lib/fusuma/string_support.rb +3 -3
  38. data/lib/fusuma/version.rb +1 -1
  39. data/lib/fusuma.rb +10 -10
  40. metadata +3 -79
  41. data/spec/helpers/config_helper.rb +0 -20
  42. data/spec/lib/config/searcher_spec.rb +0 -179
  43. data/spec/lib/config_spec.rb +0 -104
  44. data/spec/lib/custom_process_spec.rb +0 -28
  45. data/spec/lib/device_spec.rb +0 -96
  46. data/spec/lib/dummy_config.yml +0 -31
  47. data/spec/lib/fusuma_spec.rb +0 -103
  48. data/spec/lib/libinput-list-devices_iberianpig-XPS-9360.txt +0 -181
  49. data/spec/lib/libinput-list-devices_magic_trackpad.txt +0 -51
  50. data/spec/lib/libinput-list-devices_razer_razer_blade.txt +0 -252
  51. data/spec/lib/libinput-list-devices_thejinx0r.txt +0 -361
  52. data/spec/lib/libinput-list-devices_unavailable.txt +0 -36
  53. data/spec/lib/libinput_command_spec.rb +0 -164
  54. data/spec/lib/plugin/base_spec.rb +0 -74
  55. data/spec/lib/plugin/buffers/buffer_spec.rb +0 -80
  56. data/spec/lib/plugin/buffers/dummy_buffer.rb +0 -20
  57. data/spec/lib/plugin/buffers/gesture_buffer_spec.rb +0 -192
  58. data/spec/lib/plugin/detectors/detector_spec.rb +0 -43
  59. data/spec/lib/plugin/detectors/dummy_detector.rb +0 -24
  60. data/spec/lib/plugin/detectors/hold_detector_spec.rb +0 -145
  61. data/spec/lib/plugin/detectors/pinch_detector_spec.rb +0 -119
  62. data/spec/lib/plugin/detectors/rotate_detector_spec.rb +0 -125
  63. data/spec/lib/plugin/detectors/swipe_detector_spec.rb +0 -118
  64. data/spec/lib/plugin/events/event_spec.rb +0 -30
  65. data/spec/lib/plugin/events/records/gesture_record_spec.rb +0 -22
  66. data/spec/lib/plugin/events/records/record_spec.rb +0 -31
  67. data/spec/lib/plugin/events/records/text_record_spec.rb +0 -26
  68. data/spec/lib/plugin/executors/command_executor_spec.rb +0 -57
  69. data/spec/lib/plugin/executors/executor_spec.rb +0 -164
  70. data/spec/lib/plugin/filters/filter_spec.rb +0 -92
  71. data/spec/lib/plugin/filters/libinput_filter_spec.rb +0 -120
  72. data/spec/lib/plugin/inputs/input_spec.rb +0 -70
  73. data/spec/lib/plugin/inputs/libinput_command_input_spec.rb +0 -121
  74. data/spec/lib/plugin/inputs/timer_input_spec.rb +0 -40
  75. data/spec/lib/plugin/manager_spec.rb +0 -27
  76. data/spec/lib/plugin/parsers/libinput_gesture_parser_spec.rb +0 -76
  77. data/spec/lib/plugin/parsers/parser_spec.rb +0 -45
  78. data/spec/spec_helper.rb +0 -20
@@ -1,361 +0,0 @@
1
- event7 - HTX USB HID Device HTX HID Device Touchpad: kernel bug: clickpad advertising right button
2
- Device: Power Button
3
- Kernel: /dev/input/event1
4
- Group: 1
5
- Seat: seat0, default
6
- Capabilities: keyboard
7
- Tap-to-click: n/a
8
- Tap-and-drag: n/a
9
- Tap drag lock: n/a
10
- Left-handed: n/a
11
- Nat.scrolling: n/a
12
- Middle emulation: n/a
13
- Calibration: n/a
14
- Scroll methods: none
15
- Click methods: none
16
- Disable-w-typing: n/a
17
- Accel profiles: n/a
18
- Rotation: n/a
19
-
20
- Device: HTX USB HID Device HTX HID Device Keyboard
21
- Kernel: /dev/input/event4
22
- Group: 2
23
- Seat: seat0, default
24
- Capabilities: keyboard
25
- Tap-to-click: n/a
26
- Tap-and-drag: n/a
27
- Tap drag lock: n/a
28
- Left-handed: n/a
29
- Nat.scrolling: n/a
30
- Middle emulation: n/a
31
- Calibration: n/a
32
- Scroll methods: none
33
- Click methods: none
34
- Disable-w-typing: n/a
35
- Accel profiles: n/a
36
- Rotation: n/a
37
-
38
- Device: HTX USB HID Device HTX HID Device Consumer Control
39
- Kernel: /dev/input/event5
40
- Group: 2
41
- Seat: seat0, default
42
- Capabilities: keyboard pointer
43
- Tap-to-click: n/a
44
- Tap-and-drag: n/a
45
- Tap drag lock: n/a
46
- Left-handed: n/a
47
- Nat.scrolling: disabled
48
- Middle emulation: n/a
49
- Calibration: n/a
50
- Scroll methods: none
51
- Click methods: none
52
- Disable-w-typing: n/a
53
- Accel profiles: n/a
54
- Rotation: n/a
55
-
56
- Device: HTX USB HID Device HTX HID Device Touchpad
57
- Kernel: /dev/input/event7
58
- Group: 2
59
- Seat: seat0, default
60
- Size: 114x86mm
61
- Capabilities: pointer gesture
62
- Tap-to-click: disabled
63
- Tap-and-drag: enabled
64
- Tap drag lock: disabled
65
- Left-handed: disabled
66
- Nat.scrolling: disabled
67
- Middle emulation: disabled
68
- Calibration: n/a
69
- Scroll methods: *two-finger edge
70
- Click methods: *button-areas clickfinger
71
- Disable-w-typing: enabled
72
- Accel profiles: none
73
- Rotation: n/a
74
-
75
- Device: SINO WEALTH Gaming KB
76
- Kernel: /dev/input/event9
77
- Group: 3
78
- Seat: seat0, default
79
- Capabilities: keyboard
80
- Tap-to-click: n/a
81
- Tap-and-drag: n/a
82
- Tap drag lock: n/a
83
- Left-handed: n/a
84
- Nat.scrolling: n/a
85
- Middle emulation: n/a
86
- Calibration: n/a
87
- Scroll methods: none
88
- Click methods: none
89
- Disable-w-typing: n/a
90
- Accel profiles: n/a
91
- Rotation: n/a
92
-
93
- Device: SINO WEALTH Gaming KB System Control
94
- Kernel: /dev/input/event10
95
- Group: 3
96
- Seat: seat0, default
97
- Capabilities: keyboard
98
- Tap-to-click: n/a
99
- Tap-and-drag: n/a
100
- Tap drag lock: n/a
101
- Left-handed: n/a
102
- Nat.scrolling: n/a
103
- Middle emulation: n/a
104
- Calibration: n/a
105
- Scroll methods: none
106
- Click methods: none
107
- Disable-w-typing: n/a
108
- Accel profiles: n/a
109
- Rotation: n/a
110
-
111
- Device: SINO WEALTH Gaming KB Consumer Control
112
- Kernel: /dev/input/event11
113
- Group: 3
114
- Seat: seat0, default
115
- Capabilities: keyboard pointer
116
- Tap-to-click: n/a
117
- Tap-and-drag: n/a
118
- Tap drag lock: n/a
119
- Left-handed: n/a
120
- Nat.scrolling: disabled
121
- Middle emulation: n/a
122
- Calibration: n/a
123
- Scroll methods: none
124
- Click methods: none
125
- Disable-w-typing: n/a
126
- Accel profiles: n/a
127
- Rotation: n/a
128
-
129
- Device: SINO WEALTH Gaming KB Keyboard
130
- Kernel: /dev/input/event12
131
- Group: 3
132
- Seat: seat0, default
133
- Capabilities: keyboard
134
- Tap-to-click: n/a
135
- Tap-and-drag: n/a
136
- Tap drag lock: n/a
137
- Left-handed: n/a
138
- Nat.scrolling: n/a
139
- Middle emulation: n/a
140
- Calibration: n/a
141
- Scroll methods: none
142
- Click methods: none
143
- Disable-w-typing: n/a
144
- Accel profiles: n/a
145
- Rotation: n/a
146
-
147
- Device: Yubico YubiKey OTP+FIDO+CCID
148
- Kernel: /dev/input/event6
149
- Group: 4
150
- Seat: seat0, default
151
- Capabilities: keyboard
152
- Tap-to-click: n/a
153
- Tap-and-drag: n/a
154
- Tap drag lock: n/a
155
- Left-handed: n/a
156
- Nat.scrolling: n/a
157
- Middle emulation: n/a
158
- Calibration: n/a
159
- Scroll methods: none
160
- Click methods: none
161
- Disable-w-typing: n/a
162
- Accel profiles: n/a
163
- Rotation: n/a
164
-
165
- Device: HDA NVidia HDMI/DP,pcm=3
166
- Kernel: /dev/input/event13
167
- Group: 5
168
- Seat: seat0, default
169
- Capabilities:
170
- Tap-to-click: n/a
171
- Tap-and-drag: n/a
172
- Tap drag lock: n/a
173
- Left-handed: n/a
174
- Nat.scrolling: n/a
175
- Middle emulation: n/a
176
- Calibration: n/a
177
- Scroll methods: none
178
- Click methods: none
179
- Disable-w-typing: n/a
180
- Accel profiles: n/a
181
- Rotation: n/a
182
-
183
- Device: HDA NVidia HDMI/DP,pcm=7
184
- Kernel: /dev/input/event14
185
- Group: 5
186
- Seat: seat0, default
187
- Capabilities:
188
- Tap-to-click: n/a
189
- Tap-and-drag: n/a
190
- Tap drag lock: n/a
191
- Left-handed: n/a
192
- Nat.scrolling: n/a
193
- Middle emulation: n/a
194
- Calibration: n/a
195
- Scroll methods: none
196
- Click methods: none
197
- Disable-w-typing: n/a
198
- Accel profiles: n/a
199
- Rotation: n/a
200
-
201
- Device: HDA NVidia HDMI/DP,pcm=8
202
- Kernel: /dev/input/event15
203
- Group: 5
204
- Seat: seat0, default
205
- Capabilities:
206
- Tap-to-click: n/a
207
- Tap-and-drag: n/a
208
- Tap drag lock: n/a
209
- Left-handed: n/a
210
- Nat.scrolling: n/a
211
- Middle emulation: n/a
212
- Calibration: n/a
213
- Scroll methods: none
214
- Click methods: none
215
- Disable-w-typing: n/a
216
- Accel profiles: n/a
217
- Rotation: n/a
218
-
219
- Device: HDA NVidia HDMI/DP,pcm=9
220
- Kernel: /dev/input/event16
221
- Group: 5
222
- Seat: seat0, default
223
- Capabilities:
224
- Tap-to-click: n/a
225
- Tap-and-drag: n/a
226
- Tap drag lock: n/a
227
- Left-handed: n/a
228
- Nat.scrolling: n/a
229
- Middle emulation: n/a
230
- Calibration: n/a
231
- Scroll methods: none
232
- Click methods: none
233
- Disable-w-typing: n/a
234
- Accel profiles: n/a
235
- Rotation: n/a
236
-
237
- Device: HDA NVidia HDMI/DP,pcm=3
238
- Kernel: /dev/input/event17
239
- Group: 5
240
- Seat: seat0, default
241
- Capabilities:
242
- Tap-to-click: n/a
243
- Tap-and-drag: n/a
244
- Tap drag lock: n/a
245
- Left-handed: n/a
246
- Nat.scrolling: n/a
247
- Middle emulation: n/a
248
- Calibration: n/a
249
- Scroll methods: none
250
- Click methods: none
251
- Disable-w-typing: n/a
252
- Accel profiles: n/a
253
- Rotation: n/a
254
-
255
- Device: HDA NVidia HDMI/DP,pcm=7
256
- Kernel: /dev/input/event18
257
- Group: 5
258
- Seat: seat0, default
259
- Capabilities:
260
- Tap-to-click: n/a
261
- Tap-and-drag: n/a
262
- Tap drag lock: n/a
263
- Left-handed: n/a
264
- Nat.scrolling: n/a
265
- Middle emulation: n/a
266
- Calibration: n/a
267
- Scroll methods: none
268
- Click methods: none
269
- Disable-w-typing: n/a
270
- Accel profiles: n/a
271
- Rotation: n/a
272
-
273
- Device: HDA NVidia HDMI/DP,pcm=8
274
- Kernel: /dev/input/event19
275
- Group: 5
276
- Seat: seat0, default
277
- Capabilities:
278
- Tap-to-click: n/a
279
- Tap-and-drag: n/a
280
- Tap drag lock: n/a
281
- Left-handed: n/a
282
- Nat.scrolling: n/a
283
- Middle emulation: n/a
284
- Calibration: n/a
285
- Scroll methods: none
286
- Click methods: none
287
- Disable-w-typing: n/a
288
- Accel profiles: n/a
289
- Rotation: n/a
290
-
291
- Device: HDA NVidia HDMI/DP,pcm=9
292
- Kernel: /dev/input/event20
293
- Group: 5
294
- Seat: seat0, default
295
- Capabilities:
296
- Tap-to-click: n/a
297
- Tap-and-drag: n/a
298
- Tap drag lock: n/a
299
- Left-handed: n/a
300
- Nat.scrolling: n/a
301
- Middle emulation: n/a
302
- Calibration: n/a
303
- Scroll methods: none
304
- Click methods: none
305
- Disable-w-typing: n/a
306
- Accel profiles: n/a
307
- Rotation: n/a
308
-
309
- Device: QEMU QEMU USB Tablet
310
- Kernel: /dev/input/event2
311
- Group: 6
312
- Seat: seat0, default
313
- Capabilities: pointer
314
- Tap-to-click: n/a
315
- Tap-and-drag: n/a
316
- Tap drag lock: n/a
317
- Left-handed: disabled
318
- Nat.scrolling: disabled
319
- Middle emulation: disabled
320
- Calibration: identity matrix
321
- Scroll methods: none
322
- Click methods: none
323
- Disable-w-typing: n/a
324
- Accel profiles: n/a
325
- Rotation: n/a
326
-
327
- Device: AT Translated Set 2 keyboard
328
- Kernel: /dev/input/event0
329
- Group: 7
330
- Seat: seat0, default
331
- Capabilities: keyboard
332
- Tap-to-click: n/a
333
- Tap-and-drag: n/a
334
- Tap drag lock: n/a
335
- Left-handed: n/a
336
- Nat.scrolling: n/a
337
- Middle emulation: n/a
338
- Calibration: n/a
339
- Scroll methods: none
340
- Click methods: none
341
- Disable-w-typing: n/a
342
- Accel profiles: n/a
343
- Rotation: n/a
344
-
345
- Device: ImExPS/2 Generic Explorer Mouse
346
- Kernel: /dev/input/event3
347
- Group: 8
348
- Seat: seat0, default
349
- Capabilities: pointer
350
- Tap-to-click: n/a
351
- Tap-and-drag: n/a
352
- Tap drag lock: n/a
353
- Left-handed: disabled
354
- Nat.scrolling: disabled
355
- Middle emulation: disabled
356
- Calibration: n/a
357
- Scroll methods: button
358
- Click methods: none
359
- Disable-w-typing: n/a
360
- Accel profiles: flat *adaptive
361
- Rotation: n/a
@@ -1,36 +0,0 @@
1
- Device: AT Translated Set 2 keyboard
2
- Kernel: /dev/input/event4
3
- Group: 9
4
- Seat: seat0, default
5
- Capabilities: keyboard
6
- Tap-to-click: n/a
7
- Tap-and-drag: n/a
8
- Tap drag lock: n/a
9
- Left-handed: n/a
10
- Nat.scrolling: n/a
11
- Middle emulation: n/a
12
- Calibration: n/a
13
- Scroll methods: none
14
- Click methods: none
15
- Disable-w-typing: n/a
16
- Accel profiles: n/a
17
- Rotation: n/a
18
-
19
- Device: Dell WMI hotkeys
20
- Kernel: /dev/input/event9
21
- Group: 10
22
- Seat: seat0, default
23
- Capabilities: keyboard
24
- Tap-to-click: n/a
25
- Tap-and-drag: n/a
26
- Tap drag lock: n/a
27
- Left-handed: n/a
28
- Nat.scrolling: n/a
29
- Middle emulation: n/a
30
- Calibration: n/a
31
- Scroll methods: none
32
- Click methods: none
33
- Disable-w-typing: n/a
34
- Accel profiles: n/a
35
- Rotation: n/a
36
-
@@ -1,164 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- require './lib/fusuma/libinput_command'
5
-
6
- module Fusuma
7
- RSpec.describe LibinputCommand do
8
- let(:libinput_command) do
9
- described_class.new(libinput_options: libinput_options, commands: commands)
10
- end
11
- let(:libinput_options) { [] }
12
- let(:commands) { {} }
13
- describe '#version' do
14
- subject { libinput_command.version }
15
-
16
- context 'when libinput-list-device is available' do
17
- before do
18
- allow(libinput_command).to receive('which')
19
- .with('libinput') { false }
20
- allow(libinput_command).to receive('which')
21
- .with('libinput-list-devices') { true }
22
- allow_any_instance_of(Kernel).to receive(:`)
23
- .with('libinput-list-devices --version') { "1.6.3\n" }
24
- end
25
-
26
- it { is_expected.to eq '1.6.3' }
27
- it { expect(libinput_command.new_cli_option_available?).to be false }
28
- end
29
-
30
- context 'when libinput is available' do
31
- before do
32
- allow(libinput_command).to receive('which')
33
- .with('libinput') { true }
34
- allow(libinput_command).to receive('which')
35
- .with('libinput-list-devices') { false }
36
- allow_any_instance_of(Kernel).to receive(:`)
37
- .with('libinput --version') { "1.8\n" }
38
- end
39
-
40
- it { is_expected.to eq '1.8' }
41
- it { expect(libinput_command.new_cli_option_available?).to be true }
42
- end
43
-
44
- context 'when libinput command is not found' do
45
- before do
46
- allow(libinput_command).to receive('which')
47
- .with('libinput') { false }
48
- allow(libinput_command).to receive('which')
49
- .with('libinput-list-devices') { false }
50
- end
51
-
52
- it 'shold print error and exit 1' do
53
- expect(MultiLogger).to receive(:error)
54
- expect { subject }.to raise_error(SystemExit)
55
- end
56
- end
57
- end
58
-
59
- describe '#new_cli_option_available?' do
60
- subject { libinput_command.new_cli_option_available? }
61
- context 'with NEW_CLI_OPTION_VERSION' do
62
- before do
63
- allow(libinput_command).to receive(:version)
64
- .and_return(LibinputCommand::NEW_CLI_OPTION_VERSION)
65
- end
66
- it { is_expected.to eq true }
67
- end
68
- context 'without NEW_CLI_OPTION_VERSION' do
69
- before do
70
- allow(libinput_command).to receive(:version)
71
- .and_return('1.7')
72
- end
73
- it { is_expected.to eq false }
74
- end
75
- end
76
-
77
- describe 'list_devices' do
78
- subject { libinput_command.list_devices }
79
- after { subject }
80
-
81
- before do
82
- dummy_io = StringIO.new('dummy')
83
- io = StringIO.new('dummy output')
84
- allow(Open3).to receive(:popen3).with(anything).and_return([dummy_io, io, dummy_io,
85
- dummy_io, nil])
86
- end
87
-
88
- context 'with the alternative command' do
89
- let(:commands) { { list_devices_command: 'dummy_list_devices' } }
90
-
91
- it 'should call dummy events' do
92
- expect(Open3).to receive(:popen3).with(/dummy_list_devices/)
93
- end
94
- end
95
-
96
- context 'with new cli version' do
97
- before do
98
- allow(libinput_command).to receive(:new_cli_option_available?)
99
- .and_return(true)
100
- end
101
-
102
- it 'call `libinput list-devices`' do
103
- command = 'libinput list-devices'
104
- expect(Open3).to receive(:popen3)
105
- .with(command)
106
- end
107
- end
108
- context 'with old cli version' do
109
- before do
110
- allow(libinput_command).to receive(:new_cli_option_available?)
111
- .and_return(false)
112
- end
113
-
114
- it 'call `libinput-list-devices`' do
115
- command = 'libinput-list-devices'
116
- expect(Open3).to receive(:popen3)
117
- .with(command)
118
- end
119
- end
120
- end
121
-
122
- describe 'debug_events' do
123
- before do
124
- @dummy_io = StringIO.new('dummy')
125
- allow(Process).to receive(:detach).with(anything).and_return(nil)
126
- end
127
- subject { libinput_command.debug_events(@dummy_io) }
128
-
129
- context 'with the alternative command' do
130
- before do
131
- allow(libinput_command).to receive(:debug_events_with_options).and_return 'dummy_debug_events'
132
- end
133
-
134
- it 'should call dummy events' do
135
- expect(Process).to receive(:spawn).with('dummy_debug_events',
136
- { out: @dummy_io, in: '/dev/null' }).once
137
- subject
138
- end
139
- end
140
- end
141
-
142
- describe '#debug_events_with_options' do
143
- subject { libinput_command.debug_events_with_options }
144
-
145
- context 'with new cli version' do
146
- before do
147
- allow(libinput_command)
148
- .to receive(:new_cli_option_available?)
149
- .and_return(true)
150
- end
151
- it { is_expected.to eq 'stdbuf -oL -- libinput debug-events' }
152
- end
153
-
154
- context 'with old cli version' do
155
- before do
156
- allow(libinput_command)
157
- .to receive(:new_cli_option_available?)
158
- .and_return(false)
159
- end
160
- it { is_expected.to eq 'stdbuf -oL -- libinput-debug-events' }
161
- end
162
- end
163
- end
164
- end
@@ -1,74 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- require './lib/fusuma/plugin/base'
5
- require './lib/fusuma/plugin/manager'
6
-
7
- module Fusuma
8
- module Plugin
9
- class DummyPlugin < Base
10
- def config_param_types
11
- {
12
- dummy_string: String,
13
- dummy_list: Array,
14
- dummy_bool: [TrueClass, FalseClass]
15
- }
16
- end
17
- end
18
-
19
- class DummyChildPlugin < DummyPlugin
20
- end
21
-
22
- RSpec.describe DummyPlugin do
23
- before do
24
- @dummy_plugin = DummyPlugin.new
25
- @dummy_child_plugin = DummyChildPlugin.new
26
-
27
- ConfigHelper.load_config_yml = <<-CONFIG
28
- plugin:
29
- dummy_plugin:
30
- dummy_string: dummy
31
- dummy_list:
32
- - 1
33
- - 2
34
- - 3
35
- dummy_bool: true
36
- CONFIG
37
- end
38
-
39
- after do
40
- Config.custom_path = nil
41
- end
42
- describe '.inherited' do
43
- it 'should add required class to subclass on Manager' do
44
- expect(Manager.plugins[Base.name]).to include(DummyPlugin)
45
- end
46
- end
47
-
48
- describe '.plugins' do
49
- it 'should list plugins' do
50
- expect(DummyPlugin.plugins).to eq([DummyChildPlugin])
51
- end
52
- end
53
-
54
- describe '#config_param_types' do
55
- it 'should define class for config params' do
56
- expect(@dummy_plugin.config_param_types).to be_a Hash
57
- end
58
- end
59
-
60
- describe '#config_params' do
61
- it 'should fetch options from config' do
62
- expect(@dummy_plugin.config_params).to be_a Hash
63
- expect(@dummy_plugin.config_params(:dummy_string)).to be_a String
64
- end
65
- end
66
-
67
- describe '#config_index' do
68
- it 'should return index' do
69
- expect(@dummy_plugin.config_index).to be_a Config::Index
70
- end
71
- end
72
- end
73
- end
74
- end
@@ -1,80 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- require './lib/fusuma/plugin/events/event'
6
- require_relative './dummy_buffer'
7
-
8
- module Fusuma
9
- module Plugin
10
- module Buffers
11
- RSpec.describe DummyBuffer do
12
- before do
13
- @buffer = DummyBuffer.new
14
- end
15
-
16
- describe '#type' do
17
- subject { @buffer.type }
18
- it { is_expected.to eq 'dummy' }
19
- end
20
-
21
- describe '#buffer' do
22
- it 'should buffer event' do
23
- event = Events::Event.new(tag: 'dummy', record: 'dummy record')
24
- expect(@buffer.buffer(event)).to eq [event]
25
- expect(@buffer.events).to eq [event]
26
- end
27
-
28
- it 'should NOT buffer event' do
29
- event = Events::Event.new(tag: 'SHOULD NOT BUFFER', record: 'dummy record')
30
- @buffer.buffer(event)
31
- expect(@buffer.events).to eq []
32
- end
33
- end
34
-
35
- describe '#source' do
36
- subject { @buffer.source }
37
-
38
- it { is_expected.to eq DummyBuffer::DEFAULT_SOURCE }
39
-
40
- context 'with config' do
41
- around do |example|
42
- @source = 'custom_event'
43
-
44
- ConfigHelper.load_config_yml = <<~CONFIG
45
- plugin:
46
- buffers:
47
- dummy_buffer:
48
- source: #{@source}
49
- CONFIG
50
-
51
- example.run
52
-
53
- Config.custom_path = nil
54
- end
55
-
56
- it { is_expected.to eq @source }
57
- end
58
- end
59
-
60
- describe '#config_params' do
61
- around do |example|
62
- ConfigHelper.load_config_yml = <<~CONFIG
63
- plugin:
64
- buffers:
65
- dummy_buffer:
66
- dummy: dummy
67
- CONFIG
68
-
69
- example.run
70
-
71
- Config.custom_path = nil
72
- end
73
-
74
- subject { @buffer.config_params }
75
- it { is_expected.to eq(dummy: 'dummy') }
76
- end
77
- end
78
- end
79
- end
80
- end