fusuma 2.4.1 → 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 +32 -0
  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 -29
  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 -23
@@ -1,70 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- require './lib/fusuma/plugin/inputs/input'
5
-
6
- module Fusuma
7
- module Plugin
8
- module Inputs
9
- RSpec.describe Input do
10
- let(:input) { described_class.new }
11
-
12
- describe '#io' do
13
- subject { input.io { 'dummy' } }
14
- it { expect { subject }.to raise_error(NotImplementedError) }
15
- end
16
-
17
- describe '#create_event' do
18
- subject { input.create_event }
19
- it { is_expected.to be_a Events::Event }
20
-
21
- it { expect(input.tag).to eq 'input' }
22
- end
23
-
24
- describe '.select' do
25
- subject { Input.select([DummyInput.new]) }
26
-
27
- it { is_expected.to be_a Events::Event }
28
- end
29
- end
30
-
31
- class DummyInput < Input
32
- def io
33
- @io ||= begin
34
- r, w = IO.pipe
35
- w.puts 'hoge'
36
- w.close
37
- r
38
- end
39
- end
40
- end
41
-
42
- RSpec.describe DummyInput do
43
- let(:dummy_input) { described_class.new }
44
-
45
- around do |example|
46
- ConfigHelper.load_config_yml = <<~CONFIG
47
- plugin:
48
- inputs:
49
- dummy_input:
50
- dummy: dummy
51
- CONFIG
52
-
53
- example.run
54
-
55
- Config.custom_path = nil
56
- end
57
-
58
- describe '#io' do
59
- subject { dummy_input.io }
60
- it { is_expected.to be_a IO }
61
- end
62
-
63
- describe '#config_params' do
64
- subject { dummy_input.config_params }
65
- it { is_expected.to eq(dummy: 'dummy') }
66
- end
67
- end
68
- end
69
- end
70
- end
@@ -1,121 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- require './lib/fusuma/plugin/inputs/libinput_command_input'
5
-
6
- module Fusuma
7
- module Plugin
8
- module Inputs
9
- RSpec.describe LibinputCommandInput do
10
- let(:input) { described_class.new }
11
-
12
- describe '#io' do
13
- before do
14
- @dummy_io = StringIO.new('dummy')
15
- dummy_pid = 999_999_999
16
- libinput_command = instance_double(LibinputCommand)
17
- allow(LibinputCommand).to receive(:new).and_return(libinput_command)
18
- allow(libinput_command).to receive(:debug_events).with(@dummy_io).and_return(dummy_pid)
19
- allow(input).to receive(:create_io).and_return [@dummy_io, @dummy_io]
20
- end
21
-
22
- it { expect(input.io).to eq @dummy_io }
23
- end
24
-
25
- describe '#libinput_options' do
26
- it { expect(input.libinput_options).to be_a Array }
27
-
28
- context 'when device: awesome_device is given as config_params' do
29
- around do |example|
30
- ConfigHelper.load_config_yml = <<~CONFIG
31
- plugin:
32
- inputs:
33
- libinput_command_input:
34
- device: awesome device
35
- CONFIG
36
-
37
- example.run
38
-
39
- Config.custom_path = nil
40
- end
41
- it "contains --device='awesome device'" do
42
- expect(input.libinput_options).to be_include "--device='awesome device'"
43
- end
44
- end
45
-
46
- context 'when enable-tap: true is given as config_params' do
47
- around do |example|
48
- ConfigHelper.load_config_yml = <<~CONFIG
49
- plugin:
50
- inputs:
51
- libinput_command_input:
52
- enable-tap: true
53
- CONFIG
54
-
55
- example.run
56
-
57
- Config.custom_path = nil
58
- end
59
- it 'contains --enable-tap' do
60
- expect(input.libinput_options).to be_include '--enable-tap'
61
- end
62
- end
63
-
64
- context 'when enable-dwt: true is given as config_params' do
65
- around do |example|
66
- ConfigHelper.load_config_yml = <<~CONFIG
67
- plugin:
68
- inputs:
69
- libinput_command_input:
70
- enable-dwt: true
71
- CONFIG
72
-
73
- example.run
74
-
75
- Config.custom_path = nil
76
- end
77
- it 'contains --enable-dwt' do
78
- expect(input.libinput_options).to be_include '--enable-dwt'
79
- end
80
- end
81
-
82
- context 'when show-keycodes: true is given as config_params' do
83
- around do |example|
84
- ConfigHelper.load_config_yml = <<~CONFIG
85
- plugin:
86
- inputs:
87
- libinput_command_input:
88
- show-keycodes: true
89
- CONFIG
90
-
91
- example.run
92
-
93
- Config.custom_path = nil
94
- end
95
- it 'contains --show-keycodes' do
96
- expect(input.libinput_options).to be_include '--show-keycodes'
97
- end
98
- end
99
-
100
- context 'when verbose: true is given as config_params' do
101
- around do |example|
102
- ConfigHelper.load_config_yml = <<~CONFIG
103
- plugin:
104
- inputs:
105
- libinput_command_input:
106
- verbose: true
107
- CONFIG
108
-
109
- example.run
110
-
111
- Config.custom_path = nil
112
- end
113
- it 'contains --verbose' do
114
- expect(input.libinput_options).to be_include '--verbose'
115
- end
116
- end
117
- end
118
- end
119
- end
120
- end
121
- end
@@ -1,40 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- require './lib/fusuma/plugin/inputs/timer_input'
5
-
6
- module Fusuma
7
- module Plugin
8
- module Inputs
9
- RSpec.describe TimerInput do
10
- before do
11
- @dummy_read = StringIO.new('dummy_read')
12
- @dummy_write = StringIO.new('dummy_write')
13
- @input = TimerInput.new
14
- allow(@input).to receive(:create_io).and_return [@dummy_read, @dummy_write]
15
- allow(@input).to receive(:fork)
16
- allow(Process).to receive(:detach).with(anything)
17
- end
18
-
19
- describe '#io' do
20
- it { expect(@input.io).to eq @dummy_read }
21
-
22
- it 'should call #create_io' do
23
- expect(@input).to receive(:create_io)
24
- expect(@input).to receive(:start)
25
- @input.io
26
- end
27
- end
28
-
29
- describe '#start' do
30
- it {
31
- expect(@input).to receive(:fork).and_yield do |block_context|
32
- expect(block_context).to receive(:timer_loop).with(@dummy_read, @dummy_write)
33
- end
34
- @input.start(@dummy_read, @dummy_write)
35
- }
36
- end
37
- end
38
- end
39
- end
40
- end
@@ -1,27 +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
- RSpec.describe Manager do
10
- describe '#require_siblings_from_plugin_dir' do
11
- Manager.new(Base).require_siblings_from_plugin_dir
12
- subject { Manager.new(Base).require_siblings_from_plugin_dir }
13
- it { expect { subject }.not_to raise_error(LoadError) }
14
- end
15
-
16
- describe '#require_siblings_from_gem' do
17
- subject { Manager.new(Inputs::Input).require_siblings_from_gem }
18
- it { expect { subject }.not_to raise_error(LoadError) }
19
- end
20
-
21
- describe '.plugins' do
22
- subject { Manger.plugins }
23
- pending
24
- end
25
- end
26
- end
27
- end
@@ -1,76 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- require './lib/fusuma/plugin/parsers/parser'
5
- require './lib/fusuma/plugin/events/event'
6
-
7
- module Fusuma
8
- module Plugin
9
- module Parsers
10
- RSpec.describe LibinputGestureParser do
11
- let(:parser) { LibinputGestureParser.new }
12
-
13
- around do |example|
14
- ConfigHelper.load_config_yml = <<~CONFIG
15
- plugin:
16
- parsers:
17
- libinput_gesture_parser:
18
- dummy: dummy
19
- CONFIG
20
-
21
- example.run
22
-
23
- Config.custom_path = nil
24
- end
25
-
26
- describe '#source' do
27
- subject { parser.source }
28
-
29
- it { is_expected.to be LibinputGestureParser::DEFAULT_SOURCE }
30
- end
31
-
32
- describe '#parse' do
33
- context 'with different tag(dummy) event' do
34
- let(:event) { Events::Event.new(tag: 'dummy_input', record: 'dummy') }
35
- it { expect(parser.parse(event).record).not_to be_a Events::Records::GestureRecord }
36
- it { expect(parser.parse(event)).to eq event }
37
- end
38
-
39
- context 'with libinput_command_input event' do
40
- let(:event) { Events::Event.new(tag: 'libinput_command_input', record: record) }
41
- context 'with swipe gestures' do
42
- # event10 GESTURE_SWIPE_BEGIN +0.728s 3
43
- # event10 GESTURE_SWIPE_UPDATE +0.948s 3 0.23/ 0.00 ( 0.29/ 0.00 unaccelerated)
44
- # event10 GESTURE_SWIPE_END +0.989s 3
45
- let(:record) { 'event10 GESTURE_SWIPE_BEGIN +0.728s 3' }
46
- it { expect(parser.parse(event).record).to be_a Events::Records::GestureRecord }
47
- it { expect(parser.parse(event).record.status).to eq 'begin' }
48
- end
49
-
50
- context 'with hold gestures' do
51
- # -event10 GESTURE_HOLD_BEGIN +2.125s 3
52
- # event10 GESTURE_HOLD_END +3.274s 3
53
- # event10 GESTURE_HOLD_BEGIN +5.573s 4
54
- # event10 GESTURE_HOLD_END +6.462s 4 cancelled
55
- context 'with begin' do
56
- let(:record) { '-event10 GESTURE_HOLD_BEGIN +2.125s 3' }
57
- it { expect(parser.parse(event).record).to be_a Events::Records::GestureRecord }
58
- it { expect(parser.parse(event).record.status).to eq 'begin' }
59
- end
60
- context 'with end' do
61
- let(:record) { ' event10 GESTURE_HOLD_END +3.274s 3' }
62
- it { expect(parser.parse(event).record).to be_a Events::Records::GestureRecord }
63
- it { expect(parser.parse(event).record.status).to eq 'end' }
64
- end
65
- context 'with end(cancelled)' do
66
- let(:record) { ' event10 GESTURE_HOLD_END +6.462s 4 cancelled' }
67
- it { expect(parser.parse(event).record).to be_a Events::Records::GestureRecord }
68
- it { expect(parser.parse(event).record.status).to eq 'cancelled' }
69
- end
70
- end
71
- end
72
- end
73
- end
74
- end
75
- end
76
- end
@@ -1,45 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- require './lib/fusuma/plugin/parsers/parser'
5
- require './lib/fusuma/plugin/events/event'
6
-
7
- module Fusuma
8
- module Plugin
9
- module Parsers
10
- class DummyParser < Parser
11
- DEFAULT_SOURCE = 'dummy_input'
12
- end
13
-
14
- RSpec.describe Parser do
15
- let(:parser) { DummyParser.new }
16
-
17
- around do |example|
18
- ConfigHelper.load_config_yml = <<~CONFIG
19
- plugin:
20
- parsers:
21
- dummy_parser:
22
- dummy: dummy
23
- CONFIG
24
-
25
- example.run
26
-
27
- Config.custom_path = nil
28
- end
29
-
30
- describe '#source' do
31
- subject { parser.source }
32
-
33
- it { is_expected.to be DummyParser::DEFAULT_SOURCE }
34
- end
35
-
36
- describe '#parse' do
37
- subject { parser.parse(event) }
38
- let(:event) { Events::Event.new(tag: 'dummy_input', record: 'dummy') }
39
-
40
- it { is_expected.to be event }
41
- end
42
- end
43
- end
44
- end
45
- end
data/spec/spec_helper.rb DELETED
@@ -1,23 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'bundler/setup'
4
- require 'helpers/config_helper'
5
-
6
- require 'simplecov'
7
-
8
- RSpec.configure do |config|
9
- # Enable flags like --only-failures and --next-failure
10
- config.example_status_persistence_file_path = '.rspec_status'
11
-
12
- # Disable RSpec exposing methods globally on `Module` and `main`
13
- config.disable_monkey_patching!
14
-
15
- config.expect_with :rspec do |c|
16
- c.syntax = :expect
17
- end
18
-
19
- config.include(Fusuma::ConfigHelper)
20
- end
21
-
22
- SimpleCov.formatter = SimpleCov::Formatter::HTMLFormatter
23
- SimpleCov.start