fusuma 2.0.0.pre2 → 2.0.4

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.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +7 -6
  3. data/fusuma.gemspec +3 -5
  4. data/lib/fusuma/config/searcher.rb +2 -0
  5. data/lib/fusuma/device.rb +3 -3
  6. data/lib/fusuma/environment.rb +1 -0
  7. data/lib/fusuma/libinput_command.rb +12 -12
  8. data/lib/fusuma/plugin/executors/command_executor.rb +10 -10
  9. data/lib/fusuma/plugin/inputs/input.rb +1 -0
  10. data/lib/fusuma/plugin/inputs/libinput_command_input.rb +9 -2
  11. data/lib/fusuma/plugin/manager.rb +12 -1
  12. data/lib/fusuma/version.rb +1 -1
  13. data/spec/helpers/config_helper.rb +20 -0
  14. data/spec/lib/config/searcher_spec.rb +97 -0
  15. data/spec/lib/config_spec.rb +112 -0
  16. data/spec/lib/custom_process_spec.rb +28 -0
  17. data/spec/lib/device_spec.rb +96 -0
  18. data/spec/lib/dummy_config.yml +31 -0
  19. data/spec/lib/fusuma_spec.rb +103 -0
  20. data/spec/lib/libinput-list-devices_iberianpig-XPS-9360.txt +181 -0
  21. data/spec/lib/libinput-list-devices_magic_trackpad.txt +51 -0
  22. data/spec/lib/libinput-list-devices_razer_razer_blade.txt +252 -0
  23. data/spec/lib/libinput-list-devices_thejinx0r.txt +361 -0
  24. data/spec/lib/libinput-list-devices_unavailable.txt +36 -0
  25. data/spec/lib/libinput_command_spec.rb +164 -0
  26. data/spec/lib/plugin/base_spec.rb +74 -0
  27. data/spec/lib/plugin/buffers/buffer_spec.rb +80 -0
  28. data/spec/lib/plugin/buffers/dummy_buffer.rb +20 -0
  29. data/spec/lib/plugin/buffers/gesture_buffer_spec.rb +172 -0
  30. data/spec/lib/plugin/detectors/detector_spec.rb +43 -0
  31. data/spec/lib/plugin/detectors/dummy_detector.rb +24 -0
  32. data/spec/lib/plugin/detectors/pinch_detector_spec.rb +119 -0
  33. data/spec/lib/plugin/detectors/rotate_detector_spec.rb +125 -0
  34. data/spec/lib/plugin/detectors/swipe_detector_spec.rb +118 -0
  35. data/spec/lib/plugin/events/event_spec.rb +30 -0
  36. data/spec/lib/plugin/events/records/gesture_record_spec.rb +22 -0
  37. data/spec/lib/plugin/events/records/record_spec.rb +31 -0
  38. data/spec/lib/plugin/events/records/text_record_spec.rb +26 -0
  39. data/spec/lib/plugin/executors/command_executor_spec.rb +57 -0
  40. data/spec/lib/plugin/executors/executor_spec.rb +160 -0
  41. data/spec/lib/plugin/filters/filter_spec.rb +92 -0
  42. data/spec/lib/plugin/filters/libinput_filter_spec.rb +120 -0
  43. data/spec/lib/plugin/inputs/input_spec.rb +70 -0
  44. data/spec/lib/plugin/inputs/libinput_command_input_spec.rb +121 -0
  45. data/spec/lib/plugin/inputs/timer_input_spec.rb +40 -0
  46. data/spec/lib/plugin/manager_spec.rb +27 -0
  47. data/spec/lib/plugin/parsers/parser_spec.rb +45 -0
  48. data/spec/spec_helper.rb +20 -0
  49. metadata +83 -42
  50. data/.github/FUNDING.yml +0 -8
  51. data/.github/ISSUE_TEMPLATE/bug_report.md +0 -32
  52. data/.github/ISSUE_TEMPLATE/feature_request.md +0 -17
  53. data/.github/pull_request_template.md +0 -9
  54. data/.github/stale.yml +0 -18
  55. data/.gitignore +0 -17
  56. data/.reek.yml +0 -96
  57. data/.rspec +0 -2
  58. data/.rubocop.yml +0 -43
  59. data/.rubocop_todo.yml +0 -55
  60. data/.solargraph.yml +0 -16
  61. data/.travis.yml +0 -9
  62. data/CHANGELOG.md +0 -456
  63. data/CODE_OF_CONDUCT.md +0 -74
  64. data/CONTRIBUTING.md +0 -72
  65. data/Gemfile +0 -23
  66. data/Rakefile +0 -15
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+ require './lib/fusuma/custom_process'
5
+
6
+ module Fusuma
7
+ RSpec.describe CustomProcess do
8
+ class ForkTest
9
+ include CustomProcess
10
+
11
+ def call
12
+ fork { puts 'hoge' }
13
+ end
14
+ end
15
+
16
+ describe '.fork' do
17
+ before do
18
+ allow(Process).to receive(:fork)
19
+ end
20
+ it 'call Process.fork and Process.setproctitle' do
21
+ expect(Process).to receive(:fork).and_yield do
22
+ expect(Process).to receive(:setproctitle)
23
+ end
24
+ ForkTest.new.call
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,96 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+ require './lib/fusuma/device'
5
+ require './lib/fusuma/plugin/inputs/libinput_command_input'
6
+
7
+ module Fusuma
8
+ RSpec.describe Device do
9
+ describe '.all' do
10
+ it 'should fetch all devices'
11
+ end
12
+
13
+ describe '.reset' do
14
+ it 'should clear all cache'
15
+ end
16
+
17
+ describe '.available' do
18
+ let(:libinput_device_command) { 'dummy-libinput-list-devices' }
19
+
20
+ before do
21
+ Device.reset
22
+ allow_any_instance_of(LibinputCommand)
23
+ .to receive(:list_devices_command)
24
+ .and_return(libinput_device_command)
25
+
26
+ @dummy_io = StringIO.new('dummy')
27
+ allow(Open3).to receive(:popen3)
28
+ .with(libinput_device_command)
29
+ .and_return([@dummy_io, list_devices_output, @dummy_io, nil])
30
+ end
31
+
32
+ context 'with XPS-9360 (have a correct device)' do
33
+ let(:list_devices_output) do
34
+ File.open('./spec/lib/libinput-list-devices_iberianpig-XPS-9360.txt')
35
+ end
36
+
37
+ it { expect(Device.available).to be_a Array }
38
+ it { expect(Device.available.map(&:name)).not_to include 'Power Button' }
39
+ it { expect(Device.available.map(&:name)).to include 'DLL075B:01 06CB:76AF Touchpad' }
40
+ end
41
+
42
+ context 'with no tap to click device (like a bluetooth apple trackpad)' do
43
+ let(:list_devices_output) do
44
+ File.open('spec/lib/libinput-list-devices_magic_trackpad.txt')
45
+ end
46
+
47
+ it { expect(Device.available).to be_a Array }
48
+ it { expect(Device.available.map(&:name)).to eq ['Christopher’s Trackpad', 'bcm5974'] }
49
+ end
50
+
51
+ context "context with the device's name not found at first line" do
52
+ let(:list_devices_output) do
53
+ File.open('spec/lib/libinput-list-devices_thejinx0r.txt')
54
+ end
55
+
56
+ it { expect(Device.available).to be_a Array }
57
+ it { expect(Device.available.map(&:name)).to include 'HTX USB HID Device HTX HID Device Touchpad' }
58
+ end
59
+
60
+ context 'when no devices' do
61
+ let(:list_devices_output) do
62
+ File.open('spec/lib/libinput-list-devices_unavailable.txt')
63
+ end
64
+
65
+ it 'should failed with exit' do
66
+ expect { Device.available }.to raise_error(SystemExit)
67
+ end
68
+
69
+ it 'should failed with printing error log' do
70
+ expect(MultiLogger).to receive(:error)
71
+ expect { Device.available }.to raise_error(SystemExit)
72
+ end
73
+ end
74
+
75
+ context 'with some device has same names' do
76
+ let(:list_devices_output) do
77
+ File.open('spec/lib/libinput-list-devices_razer_razer_blade.txt')
78
+ end
79
+
80
+ it { expect(Device.available).to be_a Array }
81
+ it 'should have capabilities' do
82
+ razer_devices = Device.all.group_by(&:name)['Razer Razer Blade']
83
+ expect(razer_devices.size).to eq 3
84
+ end
85
+
86
+ it 'should know capabilities' do
87
+ razer_devices = Device.all.group_by(&:name)['Razer Razer Blade']
88
+ capabilities = razer_devices.map(&:capabilities)
89
+ expect(capabilities).to eq ['keyboard', 'keyboard pointer', 'pointer']
90
+ keyboard_devices = razer_devices.select { |d| d.capabilities == 'keyboard' }
91
+ expect(keyboard_devices.size).to eq 1
92
+ end
93
+ end
94
+ end
95
+ end
96
+ end
@@ -0,0 +1,31 @@
1
+ swipe:
2
+ 3:
3
+ left:
4
+ command: 'echo swipe 3 left'
5
+ right:
6
+ command: 'echo swipe 3 right'
7
+ up:
8
+ command: 'echo swipe 3 up'
9
+ down:
10
+ command: 'echo swipe 3 down'
11
+ 4:
12
+ left:
13
+ command: 'echo swipe 4 left'
14
+ right:
15
+ command: 'echo swipe 4 right'
16
+ up:
17
+ command: 'echo swipe 4 up'
18
+ down:
19
+ command: 'echo swipe 4 down'
20
+
21
+ pinch:
22
+ 2:
23
+ in:
24
+ command: 'echo pinch 2 in'
25
+ out:
26
+ command: 'echo pinch 2 out'
27
+ 4:
28
+ in:
29
+ command: 'echo pinch 4 in'
30
+ out:
31
+ command: 'echo pinch 4 in'
@@ -0,0 +1,103 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+ require './lib/fusuma'
5
+ require './lib/fusuma/plugin/inputs/libinput_command_input'
6
+ require './lib/fusuma/plugin/filters/libinput_device_filter'
7
+
8
+ module Fusuma
9
+ RSpec.describe Runner do
10
+ describe '.run' do
11
+ before do
12
+ Singleton.__init__(MultiLogger)
13
+ Singleton.__init__(Config)
14
+ allow_any_instance_of(Runner).to receive(:run)
15
+ allow_any_instance_of(LibinputCommand).to receive(:version)
16
+ .and_return("1.8\n")
17
+ end
18
+
19
+ context 'when without option' do
20
+ it 'should not enable debug mode' do
21
+ expect(MultiLogger.instance).not_to be_debug_mode
22
+ Runner.run
23
+ end
24
+ end
25
+
26
+ context 'when run with argument "--version"' do
27
+ # NOTE: skip print reload config message
28
+ before { allow(MultiLogger).to receive(:info).with(anything) }
29
+ it 'should print version' do
30
+ expect(MultiLogger).to receive(:info)
31
+ .with("Fusuma: #{Fusuma::VERSION}")
32
+ expect(MultiLogger).to receive(:info)
33
+ .with("libinput: #{LibinputCommand.new.version}")
34
+ expect(MultiLogger).to receive(:info)
35
+ .with("OS: #{`uname -rsv`}".strip)
36
+ expect(MultiLogger).to receive(:info)
37
+ .with("Distribution: #{`cat /etc/issue`}".strip)
38
+ expect(MultiLogger).to receive(:info)
39
+ .with("Desktop session: #{`echo $DESKTOP_SESSION $XDG_SESSION_TYPE`}".strip)
40
+ expect { Runner.run(version: true) }.to raise_error(SystemExit)
41
+ end
42
+ end
43
+
44
+ context 'when run with argument "-l"' do
45
+ it 'should print device list' do
46
+ allow(Device).to receive(:available) {
47
+ [
48
+ Device.new(name: 'test_device1'),
49
+ Device.new(name: 'test_device2')
50
+ ]
51
+ }
52
+
53
+ expected = <<~OUTPUT
54
+ test_device1
55
+ test_device2
56
+ OUTPUT
57
+ expect { Runner.run(list: true) }.to raise_error(SystemExit)
58
+ .and output(/#{expected}/).to_stdout
59
+ end
60
+ end
61
+
62
+ # TODO: remove from_option and command line options
63
+ context 'when run with argument "--device="test_device2"' do
64
+ it 'should set device' do
65
+ allow(Device).to receive(:names) { %w[test_device1 test_device2] }
66
+ expect(Plugin::Filters::LibinputDeviceFilter::KeepDevice)
67
+ .to receive(:from_option=).with('test_device2')
68
+ Runner.run(device: 'test_device2')
69
+ end
70
+ end
71
+
72
+ context 'when run with argument "-v"' do
73
+ it 'should enable debug mode' do
74
+ MultiLogger.send(:new)
75
+ Runner.run(verbose: true)
76
+ expect(MultiLogger.instance).to be_debug_mode
77
+ end
78
+ end
79
+
80
+ context 'when run with argument "-c path/to/config.yml"' do
81
+ before do
82
+ allow_any_instance_of(Runner).to receive(:run)
83
+ @config = Config.instance
84
+
85
+ string = <<~CONFIG
86
+ swipe:
87
+ 3:
88
+ left:
89
+ command: echo 'swipe left'
90
+
91
+ CONFIG
92
+ @file_path = Tempfile.open do |temp_file|
93
+ temp_file.tap { |f| f.write(string) }
94
+ end
95
+ end
96
+ it 'should assign custom_path' do
97
+ expect { Runner.run(config_path: @file_path) }
98
+ .to change { @config.custom_path }.from(nil).to(@file_path)
99
+ end
100
+ end
101
+ end
102
+ end
103
+ end
@@ -0,0 +1,181 @@
1
+ Device: Power Button
2
+ Kernel: /dev/input/event3
3
+ Group: 1
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: Video Bus
20
+ Kernel: /dev/input/event5
21
+ Group: 2
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
+
37
+ Device: Power Button
38
+ Kernel: /dev/input/event1
39
+ Group: 3
40
+ Seat: seat0, default
41
+ Capabilities: keyboard
42
+ Tap-to-click: n/a
43
+ Tap-and-drag: n/a
44
+ Tap drag lock: n/a
45
+ Left-handed: n/a
46
+ Nat.scrolling: n/a
47
+ Middle emulation: n/a
48
+ Calibration: n/a
49
+ Scroll methods: none
50
+ Click methods: none
51
+ Disable-w-typing: n/a
52
+ Accel profiles: n/a
53
+ Rotation: n/a
54
+
55
+ Device: Sleep Button
56
+ Kernel: /dev/input/event2
57
+ Group: 4
58
+ Seat: seat0, default
59
+ Capabilities: keyboard
60
+ Tap-to-click: n/a
61
+ Tap-and-drag: n/a
62
+ Tap drag lock: n/a
63
+ Left-handed: n/a
64
+ Nat.scrolling: n/a
65
+ Middle emulation: n/a
66
+ Calibration: n/a
67
+ Scroll methods: none
68
+ Click methods: none
69
+ Disable-w-typing: n/a
70
+ Accel profiles: n/a
71
+ Rotation: n/a
72
+
73
+ Device: Integrated_Webcam_HD
74
+ Kernel: /dev/input/event15
75
+ Group: 5
76
+ Seat: seat0, default
77
+ Capabilities: keyboard
78
+ Tap-to-click: n/a
79
+ Tap-and-drag: n/a
80
+ Tap drag lock: n/a
81
+ Left-handed: n/a
82
+ Nat.scrolling: n/a
83
+ Middle emulation: n/a
84
+ Calibration: n/a
85
+ Scroll methods: none
86
+ Click methods: none
87
+ Disable-w-typing: n/a
88
+ Accel profiles: n/a
89
+ Rotation: n/a
90
+
91
+ Device: DLL075B:01 06CB:76AF Touchpad
92
+ Kernel: /dev/input/event14
93
+ Group: 6
94
+ Seat: seat0, default
95
+ Size: 101.33x56.67mm
96
+ Capabilities: pointer
97
+ Tap-to-click: disabled
98
+ Tap-and-drag: enabled
99
+ Tap drag lock: disabled
100
+ Left-handed: disabled
101
+ Nat.scrolling: disabled
102
+ Middle emulation: disabled
103
+ Calibration: n/a
104
+ Scroll methods: *two-finger edge
105
+ Click methods: *button-areas clickfinger
106
+ Disable-w-typing: enabled
107
+ Accel profiles: none
108
+ Rotation: n/a
109
+
110
+ Device: Intel Virtual Button driver
111
+ Kernel: /dev/input/event8
112
+ Group: 7
113
+ Seat: seat0, default
114
+ Capabilities: keyboard
115
+ Tap-to-click: n/a
116
+ Tap-and-drag: n/a
117
+ Tap drag lock: n/a
118
+ Left-handed: n/a
119
+ Nat.scrolling: n/a
120
+ Middle emulation: n/a
121
+ Calibration: n/a
122
+ Scroll methods: none
123
+ Click methods: none
124
+ Disable-w-typing: n/a
125
+ Accel profiles: n/a
126
+ Rotation: n/a
127
+
128
+ Device: Intel HID events
129
+ Kernel: /dev/input/event7
130
+ Group: 8
131
+ Seat: seat0, default
132
+ Capabilities: keyboard
133
+ Tap-to-click: n/a
134
+ Tap-and-drag: n/a
135
+ Tap drag lock: n/a
136
+ Left-handed: n/a
137
+ Nat.scrolling: n/a
138
+ Middle emulation: n/a
139
+ Calibration: n/a
140
+ Scroll methods: none
141
+ Click methods: none
142
+ Disable-w-typing: n/a
143
+ Accel profiles: n/a
144
+ Rotation: n/a
145
+
146
+ Device: AT Translated Set 2 keyboard
147
+ Kernel: /dev/input/event4
148
+ Group: 9
149
+ Seat: seat0, default
150
+ Capabilities: keyboard
151
+ Tap-to-click: n/a
152
+ Tap-and-drag: n/a
153
+ Tap drag lock: n/a
154
+ Left-handed: n/a
155
+ Nat.scrolling: n/a
156
+ Middle emulation: n/a
157
+ Calibration: n/a
158
+ Scroll methods: none
159
+ Click methods: none
160
+ Disable-w-typing: n/a
161
+ Accel profiles: n/a
162
+ Rotation: n/a
163
+
164
+ Device: Dell WMI hotkeys
165
+ Kernel: /dev/input/event9
166
+ Group: 10
167
+ Seat: seat0, default
168
+ Capabilities: keyboard
169
+ Tap-to-click: n/a
170
+ Tap-and-drag: n/a
171
+ Tap drag lock: n/a
172
+ Left-handed: n/a
173
+ Nat.scrolling: n/a
174
+ Middle emulation: n/a
175
+ Calibration: n/a
176
+ Scroll methods: none
177
+ Click methods: none
178
+ Disable-w-typing: n/a
179
+ Accel profiles: n/a
180
+ Rotation: n/a
181
+
@@ -0,0 +1,51 @@
1
+ Device: Christopher’s Trackpad
2
+ Kernel: /dev/input/event8
3
+ Group: 7
4
+ Seat: seat0, default
5
+ Capabilities: pointer
6
+ Tap-to-click: n/a
7
+ Tap-and-drag: n/a
8
+ Tap drag lock: n/a
9
+ Left-handed: disabled
10
+ Nat.scrolling: disabled
11
+ Middle emulation: n/a
12
+ Calibration: n/a
13
+ Scroll methods: button
14
+ Click methods: none
15
+ Disable-w-typing: n/a
16
+ Accel profiles: flat*adaptive
17
+
18
+ Device: Apple Inc. Apple Internal Keyboard / Trackpad
19
+ Kernel: /dev/input/event6
20
+ Group: 8
21
+ Seat: seat0, default
22
+ Capabilities: keyboard
23
+ Tap-to-click: n/a
24
+ Tap-and-drag: n/a
25
+ Tap drag lock: n/a
26
+ Left-handed: n/a
27
+ Nat.scrolling: n/a
28
+ Middle emulation: n/a
29
+ Calibration: n/a
30
+ Scroll methods: none
31
+ Click methods: none
32
+ Disable-w-typing: n/a
33
+ Accel profiles: n/a
34
+
35
+ Device: bcm5974
36
+ Kernel: /dev/input/event9
37
+ Group: 9
38
+ Seat: seat0, default
39
+ Size: 69.17x50.22mm
40
+ Capabilities: pointer
41
+ Tap-to-click: disabled
42
+ Tap-and-drag: enabled
43
+ Tap drag lock: disabled
44
+ Left-handed: disabled
45
+ Nat.scrolling: disabled
46
+ Middle emulation: n/a
47
+ Calibration: n/a
48
+ Scroll methods: *two-finger edge
49
+ Click methods: button-areas *clickfinger
50
+ Disable-w-typing: enabled
51
+ Accel profiles: none