fusuma 2.0.0 → 2.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +27 -22
  3. data/fusuma.gemspec +2 -4
  4. data/lib/fusuma.rb +11 -4
  5. data/lib/fusuma/config.rb +1 -1
  6. data/lib/fusuma/config/searcher.rb +1 -2
  7. data/lib/fusuma/environment.rb +1 -1
  8. data/lib/fusuma/libinput_command.rb +11 -11
  9. data/lib/fusuma/plugin/buffers/timer_buffer.rb +1 -3
  10. data/lib/fusuma/plugin/executors/command_executor.rb +10 -10
  11. data/lib/fusuma/plugin/executors/executor.rb +1 -1
  12. data/lib/fusuma/plugin/inputs/libinput_command_input.rb +9 -2
  13. data/lib/fusuma/plugin/manager.rb +3 -3
  14. data/lib/fusuma/version.rb +1 -1
  15. data/spec/helpers/config_helper.rb +20 -0
  16. data/spec/lib/config/searcher_spec.rb +179 -0
  17. data/spec/lib/config_spec.rb +104 -0
  18. data/spec/lib/custom_process_spec.rb +28 -0
  19. data/spec/lib/device_spec.rb +96 -0
  20. data/spec/lib/dummy_config.yml +31 -0
  21. data/spec/lib/fusuma_spec.rb +103 -0
  22. data/spec/lib/libinput-list-devices_iberianpig-XPS-9360.txt +181 -0
  23. data/spec/lib/libinput-list-devices_magic_trackpad.txt +51 -0
  24. data/spec/lib/libinput-list-devices_razer_razer_blade.txt +252 -0
  25. data/spec/lib/libinput-list-devices_thejinx0r.txt +361 -0
  26. data/spec/lib/libinput-list-devices_unavailable.txt +36 -0
  27. data/spec/lib/libinput_command_spec.rb +164 -0
  28. data/spec/lib/plugin/base_spec.rb +74 -0
  29. data/spec/lib/plugin/buffers/buffer_spec.rb +80 -0
  30. data/spec/lib/plugin/buffers/dummy_buffer.rb +20 -0
  31. data/spec/lib/plugin/buffers/gesture_buffer_spec.rb +172 -0
  32. data/spec/lib/plugin/detectors/detector_spec.rb +43 -0
  33. data/spec/lib/plugin/detectors/dummy_detector.rb +24 -0
  34. data/spec/lib/plugin/detectors/pinch_detector_spec.rb +119 -0
  35. data/spec/lib/plugin/detectors/rotate_detector_spec.rb +125 -0
  36. data/spec/lib/plugin/detectors/swipe_detector_spec.rb +118 -0
  37. data/spec/lib/plugin/events/event_spec.rb +30 -0
  38. data/spec/lib/plugin/events/records/gesture_record_spec.rb +22 -0
  39. data/spec/lib/plugin/events/records/record_spec.rb +31 -0
  40. data/spec/lib/plugin/events/records/text_record_spec.rb +26 -0
  41. data/spec/lib/plugin/executors/command_executor_spec.rb +57 -0
  42. data/spec/lib/plugin/executors/executor_spec.rb +164 -0
  43. data/spec/lib/plugin/filters/filter_spec.rb +92 -0
  44. data/spec/lib/plugin/filters/libinput_filter_spec.rb +120 -0
  45. data/spec/lib/plugin/inputs/input_spec.rb +70 -0
  46. data/spec/lib/plugin/inputs/libinput_command_input_spec.rb +121 -0
  47. data/spec/lib/plugin/inputs/timer_input_spec.rb +40 -0
  48. data/spec/lib/plugin/manager_spec.rb +27 -0
  49. data/spec/lib/plugin/parsers/parser_spec.rb +45 -0
  50. data/spec/spec_helper.rb +20 -0
  51. metadata +76 -35
  52. data/.github/FUNDING.yml +0 -8
  53. data/.github/ISSUE_TEMPLATE/bug_report.md +0 -32
  54. data/.github/ISSUE_TEMPLATE/feature_request.md +0 -17
  55. data/.github/pull_request_template.md +0 -9
  56. data/.github/stale.yml +0 -18
  57. data/.gitignore +0 -17
  58. data/.reek.yml +0 -96
  59. data/.rspec +0 -2
  60. data/.rubocop.yml +0 -43
  61. data/.rubocop_todo.yml +0 -55
  62. data/.solargraph.yml +0 -16
  63. data/.travis.yml +0 -9
  64. data/CHANGELOG.md +0 -456
  65. data/CODE_OF_CONDUCT.md +0 -74
  66. data/CONTRIBUTING.md +0 -72
  67. data/Gemfile +0 -23
  68. data/Rakefile +0 -15
@@ -0,0 +1,70 @@
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
@@ -0,0 +1,121 @@
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
@@ -0,0 +1,40 @@
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
@@ -0,0 +1,27 @@
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
@@ -0,0 +1,45 @@
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
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/setup'
4
+ require 'helpers/config_helper'
5
+ require 'coveralls'
6
+ Coveralls.wear!
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
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fusuma
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - iberianpig
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-04-12 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: posix-spawn
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
11
+ date: 2021-05-21 00:00:00.000000000 Z
12
+ dependencies: []
27
13
  description: Fusuma is multitouch gesture recognizer. This gem makes your touchpad
28
14
  on Linux able to recognize swipes or pinchs and assign command to them. Read installation
29
15
  on Github(https://github.com/iberianpig/fusuma#installation).
@@ -34,25 +20,8 @@ executables:
34
20
  extensions: []
35
21
  extra_rdoc_files: []
36
22
  files:
37
- - ".github/FUNDING.yml"
38
- - ".github/ISSUE_TEMPLATE/bug_report.md"
39
- - ".github/ISSUE_TEMPLATE/feature_request.md"
40
- - ".github/pull_request_template.md"
41
- - ".github/stale.yml"
42
- - ".gitignore"
43
- - ".reek.yml"
44
- - ".rspec"
45
- - ".rubocop.yml"
46
- - ".rubocop_todo.yml"
47
- - ".solargraph.yml"
48
- - ".travis.yml"
49
- - CHANGELOG.md
50
- - CODE_OF_CONDUCT.md
51
- - CONTRIBUTING.md
52
- - Gemfile
53
23
  - LICENSE
54
24
  - README.md
55
- - Rakefile
56
25
  - bin/console
57
26
  - bin/setup
58
27
  - exe/fusuma
@@ -96,6 +65,42 @@ files:
96
65
  - lib/fusuma/plugin/parsers/parser.rb
97
66
  - lib/fusuma/string_support.rb
98
67
  - lib/fusuma/version.rb
68
+ - spec/helpers/config_helper.rb
69
+ - spec/lib/config/searcher_spec.rb
70
+ - spec/lib/config_spec.rb
71
+ - spec/lib/custom_process_spec.rb
72
+ - spec/lib/device_spec.rb
73
+ - spec/lib/dummy_config.yml
74
+ - spec/lib/fusuma_spec.rb
75
+ - spec/lib/libinput-list-devices_iberianpig-XPS-9360.txt
76
+ - spec/lib/libinput-list-devices_magic_trackpad.txt
77
+ - spec/lib/libinput-list-devices_razer_razer_blade.txt
78
+ - spec/lib/libinput-list-devices_thejinx0r.txt
79
+ - spec/lib/libinput-list-devices_unavailable.txt
80
+ - spec/lib/libinput_command_spec.rb
81
+ - spec/lib/plugin/base_spec.rb
82
+ - spec/lib/plugin/buffers/buffer_spec.rb
83
+ - spec/lib/plugin/buffers/dummy_buffer.rb
84
+ - spec/lib/plugin/buffers/gesture_buffer_spec.rb
85
+ - spec/lib/plugin/detectors/detector_spec.rb
86
+ - spec/lib/plugin/detectors/dummy_detector.rb
87
+ - spec/lib/plugin/detectors/pinch_detector_spec.rb
88
+ - spec/lib/plugin/detectors/rotate_detector_spec.rb
89
+ - spec/lib/plugin/detectors/swipe_detector_spec.rb
90
+ - spec/lib/plugin/events/event_spec.rb
91
+ - spec/lib/plugin/events/records/gesture_record_spec.rb
92
+ - spec/lib/plugin/events/records/record_spec.rb
93
+ - spec/lib/plugin/events/records/text_record_spec.rb
94
+ - spec/lib/plugin/executors/command_executor_spec.rb
95
+ - spec/lib/plugin/executors/executor_spec.rb
96
+ - spec/lib/plugin/filters/filter_spec.rb
97
+ - spec/lib/plugin/filters/libinput_filter_spec.rb
98
+ - spec/lib/plugin/inputs/input_spec.rb
99
+ - spec/lib/plugin/inputs/libinput_command_input_spec.rb
100
+ - spec/lib/plugin/inputs/timer_input_spec.rb
101
+ - spec/lib/plugin/manager_spec.rb
102
+ - spec/lib/plugin/parsers/parser_spec.rb
103
+ - spec/spec_helper.rb
99
104
  homepage: https://github.com/iberianpig/fusuma
100
105
  licenses:
101
106
  - MIT
@@ -120,4 +125,40 @@ rubygems_version: 3.1.4
120
125
  signing_key:
121
126
  specification_version: 4
122
127
  summary: Multitouch gestures with libinput driver, Linux
123
- test_files: []
128
+ test_files:
129
+ - spec/lib/device_spec.rb
130
+ - spec/lib/config/searcher_spec.rb
131
+ - spec/lib/libinput-list-devices_iberianpig-XPS-9360.txt
132
+ - spec/lib/dummy_config.yml
133
+ - spec/lib/libinput-list-devices_magic_trackpad.txt
134
+ - spec/lib/custom_process_spec.rb
135
+ - spec/lib/plugin/base_spec.rb
136
+ - spec/lib/plugin/inputs/libinput_command_input_spec.rb
137
+ - spec/lib/plugin/inputs/input_spec.rb
138
+ - spec/lib/plugin/inputs/timer_input_spec.rb
139
+ - spec/lib/plugin/events/records/record_spec.rb
140
+ - spec/lib/plugin/events/records/gesture_record_spec.rb
141
+ - spec/lib/plugin/events/records/text_record_spec.rb
142
+ - spec/lib/plugin/events/event_spec.rb
143
+ - spec/lib/plugin/filters/libinput_filter_spec.rb
144
+ - spec/lib/plugin/filters/filter_spec.rb
145
+ - spec/lib/plugin/detectors/detector_spec.rb
146
+ - spec/lib/plugin/detectors/swipe_detector_spec.rb
147
+ - spec/lib/plugin/detectors/rotate_detector_spec.rb
148
+ - spec/lib/plugin/detectors/pinch_detector_spec.rb
149
+ - spec/lib/plugin/detectors/dummy_detector.rb
150
+ - spec/lib/plugin/manager_spec.rb
151
+ - spec/lib/plugin/buffers/dummy_buffer.rb
152
+ - spec/lib/plugin/buffers/buffer_spec.rb
153
+ - spec/lib/plugin/buffers/gesture_buffer_spec.rb
154
+ - spec/lib/plugin/parsers/parser_spec.rb
155
+ - spec/lib/plugin/executors/executor_spec.rb
156
+ - spec/lib/plugin/executors/command_executor_spec.rb
157
+ - spec/lib/libinput-list-devices_unavailable.txt
158
+ - spec/lib/libinput_command_spec.rb
159
+ - spec/lib/fusuma_spec.rb
160
+ - spec/lib/libinput-list-devices_razer_razer_blade.txt
161
+ - spec/lib/libinput-list-devices_thejinx0r.txt
162
+ - spec/lib/config_spec.rb
163
+ - spec/helpers/config_helper.rb
164
+ - spec/spec_helper.rb