fusuma-plugin-sendkey 0.6.0.pre2 → 0.6.3
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/README.md +1 -1
- data/fusuma-plugin-sendkey.gemspec +5 -5
- data/lib/fusuma/plugin/executors/sendkey_executor.rb +1 -13
- data/lib/fusuma/plugin/sendkey/keyboard.rb +24 -16
- data/lib/fusuma/plugin/sendkey/version.rb +1 -1
- data/spec/fusuma/plugin/executors/sendkey_executor_spec.rb +138 -0
- data/spec/fusuma/plugin/sendkey/keyboard_spec.rb +199 -0
- data/spec/fusuma/plugin/sendkey_spec.rb +7 -0
- data/spec/helpers/config_helper.rb +16 -0
- data/spec/spec_helper.rb +18 -0
- metadata +19 -18
- data/.gitignore +0 -13
- data/.rspec +0 -3
- data/.rubocop.yml +0 -25
- data/.travis.yml +0 -9
- data/CHANGELOG.md +0 -29
- data/CODE_OF_CONDUCT.md +0 -74
- data/Gemfile +0 -16
- data/Rakefile +0 -15
- data/lefthook.yml +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 24fac291a7e0bf5b13f8fbcf7ed445f12578789bee9f2dbfc1ebaaac0d6bc402
|
4
|
+
data.tar.gz: 505bc012318b5091804c85581dad55f8a9506e405919bbf1efc33886d485dddc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5938a1dabc01213cf6ec68fe37c23613374fc3412ae1831a41ce115fae56f82939d3b029c747de3a9d6569245a638c7178291a09bebbc752fbb0f9cb8b92611
|
7
|
+
data.tar.gz: 7d6db30818a00e6d6814083c7d265679116f1b314f6872e26005e57b2ad6e5851b5aabf290bbab0a342c593a6025fe4a44f088cfccf3f9d770689265c9ee6098
|
data/README.md
CHANGED
@@ -27,7 +27,7 @@ $ sudo pacman -S libevdev base-devel
|
|
27
27
|
### 2. Install fusuma-plugin-sendkey
|
28
28
|
|
29
29
|
|
30
|
-
**Note For Arch Based Distros:** By default in Arch Linux, when running
|
30
|
+
**Note For Arch Based Distros:** By default in Arch Linux, when running `gem`, gems are installed per-user (into `~/.gem/ruby/`), instead of system-wide (into `/usr/lib/ruby/gems/`). This is considered the best way to manage gems on Arch, because otherwise they might interfere with gems installed by Pacman. (From Arch Wiki)
|
31
31
|
|
32
32
|
To install gems system-wide, see any of the methods listed on [Arch Wiki](https://wiki.archlinux.org/index.php/ruby#Installing_gems_system-wide)
|
33
33
|
|
@@ -16,14 +16,14 @@ Gem::Specification.new do |spec|
|
|
16
16
|
spec.license = 'MIT'
|
17
17
|
|
18
18
|
# Specify which files should be added to the gem when it is released.
|
19
|
-
|
20
|
-
spec.
|
21
|
-
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
22
|
-
end
|
19
|
+
spec.files = Dir['{bin,lib,exe}/**/*', 'LICENSE*', 'README*', '*.gemspec']
|
20
|
+
spec.test_files = Dir['{test,spec,features}/**/*']
|
23
21
|
spec.bindir = 'exe'
|
24
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
25
23
|
spec.require_paths = ['lib']
|
24
|
+
spec.required_ruby_version = '>= 2.5.1' # https://packages.ubuntu.com/search?keywords=ruby&searchon=names&exact=1&suite=all§ion=main
|
25
|
+
# support bionic (18.04LTS) 2.5.1
|
26
26
|
|
27
|
-
spec.add_dependency 'fusuma', '~> 2.0
|
27
|
+
spec.add_dependency 'fusuma', '~> 2.0'
|
28
28
|
spec.add_dependency 'revdev'
|
29
29
|
end
|
@@ -34,10 +34,7 @@ module Fusuma
|
|
34
34
|
# @param event [Event]
|
35
35
|
# @return [nil]
|
36
36
|
def _execute(event)
|
37
|
-
keyboard.type(
|
38
|
-
param: search_param(event),
|
39
|
-
keep: search_keypress(event)
|
40
|
-
)
|
37
|
+
keyboard.type(param: search_param(event))
|
41
38
|
end
|
42
39
|
|
43
40
|
# check executable
|
@@ -62,15 +59,6 @@ module Fusuma
|
|
62
59
|
index = Config::Index.new([*event.record.index.keys, :sendkey])
|
63
60
|
Config.search(index)
|
64
61
|
end
|
65
|
-
|
66
|
-
# @param event [Event]
|
67
|
-
# @return [String]
|
68
|
-
def search_keypress(event)
|
69
|
-
keys = event.record.index.keys
|
70
|
-
keypress_index = keys.find_index { |k| k.symbol == :keypress }
|
71
|
-
code = keypress_index && keys[keypress_index + 1].symbol
|
72
|
-
code.to_s
|
73
|
-
end
|
74
62
|
end
|
75
63
|
end
|
76
64
|
end
|
@@ -10,9 +10,25 @@ module Fusuma
|
|
10
10
|
module Sendkey
|
11
11
|
# Emulate Keyboard
|
12
12
|
class Keyboard
|
13
|
+
MODIFIER_KEY_CODES = %w[
|
14
|
+
KEY_CAPSLOCK
|
15
|
+
KEY_LEFTALT
|
16
|
+
KEY_LEFTCTRL
|
17
|
+
KEY_LEFTMETA
|
18
|
+
KEY_LEFTSHIFT
|
19
|
+
KEY_RIGHTALT
|
20
|
+
KEY_RIGHTCTRL
|
21
|
+
KEY_RIGHTSHIFT
|
22
|
+
KEY_RIGHTMETA
|
23
|
+
].freeze
|
24
|
+
|
25
|
+
def self.find_device(name_pattern:)
|
26
|
+
Fusuma::Device.all.find { |d| d.name.match(/#{name_pattern}/) }
|
27
|
+
end
|
28
|
+
|
13
29
|
def initialize(name_pattern: nil)
|
14
30
|
name_pattern ||= 'keyboard|Keyboard|KEYBOARD'
|
15
|
-
device = find_device(name_pattern: name_pattern)
|
31
|
+
device = Keyboard.find_device(name_pattern: name_pattern)
|
16
32
|
|
17
33
|
if device.nil?
|
18
34
|
warn "sendkey: Keyboard: /#{name_pattern}/ is not found"
|
@@ -26,16 +42,14 @@ module Fusuma
|
|
26
42
|
|
27
43
|
# @param param [String]
|
28
44
|
# @param keep [String]
|
29
|
-
def type(param
|
45
|
+
def type(param:)
|
30
46
|
return unless param.is_a?(String)
|
31
47
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
clear_modifiers(keep_keycodes)
|
36
|
-
keycodes.each { |keycode| key_event(keycode: keycode, press: true) }
|
48
|
+
param_keycodes = split_param(param)
|
49
|
+
clear_modifiers(MODIFIER_KEY_CODES - param_keycodes)
|
50
|
+
param_keycodes.each { |keycode| key_event(keycode: keycode, press: true) }
|
37
51
|
key_sync(press: true)
|
38
|
-
|
52
|
+
param_keycodes.reverse.each { |keycode| key_event(keycode: keycode, press: false) }
|
39
53
|
key_sync(press: false)
|
40
54
|
end
|
41
55
|
|
@@ -101,19 +115,13 @@ module Fusuma
|
|
101
115
|
Object.const_get "LinuxInput::#{keycode}"
|
102
116
|
end
|
103
117
|
|
118
|
+
# @param [Array<String>] keycodes to be released
|
104
119
|
def clear_modifiers(keycodes)
|
105
|
-
|
106
|
-
LEFTSHIFT RIGHTALT RIGHTCTRL RIGHTSHIFT ]
|
107
|
-
.map { |code| key_prefix(code) }
|
108
|
-
(modifiers - keycodes).each { |code| key_event(keycode: code, press: false) }
|
120
|
+
keycodes.each { |code| key_event(keycode: code, press: false) }
|
109
121
|
end
|
110
122
|
|
111
123
|
private
|
112
124
|
|
113
|
-
def find_device(name_pattern:)
|
114
|
-
Fusuma::Device.all.find { |d| d.name.match(/#{name_pattern}/) }
|
115
|
-
end
|
116
|
-
|
117
125
|
def split_param(param)
|
118
126
|
param.split('+').map { |code| key_prefix(code) }
|
119
127
|
end
|
@@ -0,0 +1,138 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
require 'fusuma/plugin/executors/executor'
|
6
|
+
require 'fusuma/plugin/events/event'
|
7
|
+
require 'fusuma/plugin/events/records/index_record'
|
8
|
+
|
9
|
+
require './lib/fusuma/plugin/executors/sendkey_executor'
|
10
|
+
|
11
|
+
module Fusuma
|
12
|
+
module Plugin
|
13
|
+
module Executors
|
14
|
+
RSpec.describe SendkeyExecutor do
|
15
|
+
around do |example|
|
16
|
+
ConfigHelper.load_config_yml = <<~CONFIG
|
17
|
+
dummy:
|
18
|
+
1:
|
19
|
+
direction:
|
20
|
+
sendkey: KEY_CODE
|
21
|
+
|
22
|
+
plugin:
|
23
|
+
executors:
|
24
|
+
sendkey_executor:
|
25
|
+
device_name: dummy
|
26
|
+
CONFIG
|
27
|
+
|
28
|
+
example.run
|
29
|
+
|
30
|
+
Config.custom_path = nil
|
31
|
+
end
|
32
|
+
|
33
|
+
before do
|
34
|
+
index = Config::Index.new([:dummy, 1, :direction])
|
35
|
+
record = Events::Records::IndexRecord.new(index: index)
|
36
|
+
@event = Events::Event.new(tag: 'dummy_detector', record: record)
|
37
|
+
@executor = described_class.new
|
38
|
+
|
39
|
+
@keyboard = instance_double(Sendkey::Keyboard)
|
40
|
+
|
41
|
+
allow(@executor).to receive(:keyboard).and_return @keyboard
|
42
|
+
end
|
43
|
+
|
44
|
+
describe '#execute' do
|
45
|
+
before do
|
46
|
+
allow(Process).to receive(:daemon).with(true)
|
47
|
+
allow(Process).to receive(:detach).with(anything)
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'fork' do
|
51
|
+
expect(@executor).to receive(:fork).and_yield do |block_context|
|
52
|
+
expect(block_context).to receive(:_execute).with(@event)
|
53
|
+
end
|
54
|
+
|
55
|
+
@executor.execute(@event)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe '#_execute' do
|
60
|
+
it 'send KEY_CODE message to keybard' do
|
61
|
+
allow(@executor).to receive(:search_param).with(@event).and_return('KEY_CODE')
|
62
|
+
expect(@keyboard).to receive(:type).with(param: 'KEY_CODE')
|
63
|
+
@executor._execute(@event)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe '#executable?' do
|
68
|
+
before do
|
69
|
+
allow(@keyboard).to receive(:valid?).with(param: 'MODIFIER_CODE+KEY_CODE')
|
70
|
+
.and_return true
|
71
|
+
allow(@keyboard).to receive(:valid?).with(param: 'KEY_CODE')
|
72
|
+
.and_return true
|
73
|
+
allow(@keyboard).to receive(:valid?).with(param: 'INVALID_CODE')
|
74
|
+
.and_return false
|
75
|
+
end
|
76
|
+
|
77
|
+
context 'when given valid event tagged as xxxx_detector' do
|
78
|
+
it { expect(@executor).to be_executable(@event) }
|
79
|
+
end
|
80
|
+
|
81
|
+
context 'when given INVALID event tagged as invalid_tag' do
|
82
|
+
before do
|
83
|
+
@event.tag = 'invalid_tag'
|
84
|
+
end
|
85
|
+
|
86
|
+
it { expect(@executor).not_to be_executable(@event) }
|
87
|
+
end
|
88
|
+
|
89
|
+
context "when sendkey: 'MODIFIER_CODE+KEY_CODE'" do
|
90
|
+
around do |example|
|
91
|
+
ConfigHelper.load_config_yml = <<~CONFIG
|
92
|
+
dummy:
|
93
|
+
1:
|
94
|
+
direction:
|
95
|
+
sendkey: 'MODIFIER_CODE+KEY_CODE'
|
96
|
+
plugin:
|
97
|
+
executors:
|
98
|
+
sendkey_executor:
|
99
|
+
device_name: dummy
|
100
|
+
CONFIG
|
101
|
+
|
102
|
+
example.run
|
103
|
+
|
104
|
+
Config.custom_path = nil
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'returns true' do
|
108
|
+
expect(@executor).to be_executable(@event)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
context "when sendkey: 'INVALID_CODE'" do
|
113
|
+
around do |example|
|
114
|
+
ConfigHelper.load_config_yml = <<~CONFIG
|
115
|
+
dummy:
|
116
|
+
1:
|
117
|
+
direction:
|
118
|
+
sendkey: 'INVALID_CODE'
|
119
|
+
plugin:
|
120
|
+
executors:
|
121
|
+
sendkey_executor:
|
122
|
+
device_name: dummy
|
123
|
+
CONFIG
|
124
|
+
|
125
|
+
example.run
|
126
|
+
|
127
|
+
Config.custom_path = nil
|
128
|
+
end
|
129
|
+
|
130
|
+
it 'returns true' do
|
131
|
+
expect(@executor).not_to be_executable(@event)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
@@ -0,0 +1,199 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
require './lib/fusuma/plugin/sendkey/keyboard'
|
6
|
+
|
7
|
+
module Fusuma
|
8
|
+
module Plugin
|
9
|
+
module Sendkey
|
10
|
+
RSpec.describe Keyboard do
|
11
|
+
describe '#new' do
|
12
|
+
context 'when keyboard is found' do
|
13
|
+
before do
|
14
|
+
dummy_keyboard = Fusuma::Device.new(name: 'dummy keyboard')
|
15
|
+
allow(described_class)
|
16
|
+
.to receive(:find_device)
|
17
|
+
.and_return(dummy_keyboard)
|
18
|
+
allow(Sendkey::Device).to receive(:new).and_return('dummy')
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'does not raise error' do
|
22
|
+
expect { described_class.new }.not_to raise_error
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'when keyboard is not found' do
|
27
|
+
before do
|
28
|
+
allow(described_class)
|
29
|
+
.to receive(:find_device)
|
30
|
+
.and_return(nil)
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'does not raise error' do
|
34
|
+
expect { described_class.new }.to raise_error SystemExit
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context 'when detected device name is Keyboard (Capitarized)' do
|
39
|
+
before do
|
40
|
+
other_device = Fusuma::Device.new(name: 'Keyboard', id: 'dummy')
|
41
|
+
|
42
|
+
allow(described_class)
|
43
|
+
.to receive(:find_device)
|
44
|
+
.and_return(other_device)
|
45
|
+
allow(Sendkey::Device).to receive(:new).and_return('dummy')
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'does not raise error' do
|
49
|
+
expect { described_class.new }.not_to raise_error
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context 'when detected device name is KEYBOARD (Upper case)' do
|
54
|
+
before do
|
55
|
+
other_device = Fusuma::Device.new(name: 'KEYBOARD', id: 'dummy')
|
56
|
+
allow(described_class)
|
57
|
+
.to receive(:find_device)
|
58
|
+
.and_return(other_device)
|
59
|
+
allow(Sendkey::Device).to receive(:new).and_return('dummy')
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'does not raise error' do
|
63
|
+
expect { described_class.new }.not_to raise_error
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
context 'with given name pattern' do
|
68
|
+
before do
|
69
|
+
specified_device = Fusuma::Device.new(
|
70
|
+
name: 'Awesome KEY/BOARD input device',
|
71
|
+
id: 'dummy'
|
72
|
+
)
|
73
|
+
allow(Fusuma::Device).to receive(:all).and_return([specified_device])
|
74
|
+
allow(Sendkey::Device).to receive(:new).and_return('dummy')
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'does not raise error' do
|
78
|
+
expect { described_class.new(name_pattern: 'Awesome KEY/BOARD') }.not_to raise_error
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
context 'when name pattern (use default) is not given' do
|
83
|
+
subject { -> { described_class.new(name_pattern: nil) } }
|
84
|
+
|
85
|
+
before do
|
86
|
+
allow(Sendkey::Device).to receive(:new).and_return('dummy')
|
87
|
+
end
|
88
|
+
|
89
|
+
context 'when exist device named keyboard(lower-case)' do
|
90
|
+
before do
|
91
|
+
specified_device = Fusuma::Device.new(
|
92
|
+
name: 'keyboard',
|
93
|
+
id: 'dummy'
|
94
|
+
)
|
95
|
+
allow(Fusuma::Device).to receive(:all).and_return([specified_device])
|
96
|
+
end
|
97
|
+
|
98
|
+
it { is_expected.not_to raise_error }
|
99
|
+
end
|
100
|
+
|
101
|
+
context 'when exist device named Keyboard(Capital-case)' do
|
102
|
+
before do
|
103
|
+
specified_device = Fusuma::Device.new(
|
104
|
+
name: 'Keyboard',
|
105
|
+
id: 'dummy'
|
106
|
+
)
|
107
|
+
allow(Fusuma::Device).to receive(:all).and_return([specified_device])
|
108
|
+
end
|
109
|
+
|
110
|
+
it { is_expected.not_to raise_error }
|
111
|
+
end
|
112
|
+
|
113
|
+
context 'when exist device named KEYBOARD(UPPER case)' do
|
114
|
+
before do
|
115
|
+
specified_device = Fusuma::Device.new(
|
116
|
+
name: 'KEYBOARD',
|
117
|
+
id: 'dummy'
|
118
|
+
)
|
119
|
+
allow(Fusuma::Device).to receive(:all).and_return([specified_device])
|
120
|
+
end
|
121
|
+
|
122
|
+
it { is_expected.not_to raise_error }
|
123
|
+
end
|
124
|
+
|
125
|
+
context 'when exist no device named keyboard|Keyboard|KEYBOARD' do
|
126
|
+
before do
|
127
|
+
specified_device = Fusuma::Device.new(
|
128
|
+
name: 'KEY-BOARD',
|
129
|
+
id: 'dummy'
|
130
|
+
)
|
131
|
+
allow(Fusuma::Device).to receive(:all).and_return([specified_device])
|
132
|
+
end
|
133
|
+
|
134
|
+
it { is_expected.to raise_error(SystemExit) }
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
describe '#type' do
|
140
|
+
before do
|
141
|
+
allow(described_class)
|
142
|
+
.to receive(:find_device)
|
143
|
+
.and_return(Fusuma::Device.new(name: 'dummy keyboard'))
|
144
|
+
|
145
|
+
@device = instance_double(Sendkey::Device)
|
146
|
+
allow(@device).to receive(:write_event).with(anything)
|
147
|
+
# allow(@device).to receive(:valid?).with(param: 'KEY_A')
|
148
|
+
|
149
|
+
allow(Sendkey::Device).to receive(:new).and_return(@device)
|
150
|
+
|
151
|
+
@keyboard = described_class.new
|
152
|
+
end
|
153
|
+
|
154
|
+
it 'presses key KEY_A and release KEY_A' do
|
155
|
+
expect(@keyboard).to receive(:clear_modifiers).ordered
|
156
|
+
expect(@keyboard).to receive(:key_event).with(keycode: 'KEY_A', press: true).ordered
|
157
|
+
expect(@keyboard).to receive(:key_event).with(keycode: 'KEY_A', press: false).ordered
|
158
|
+
@keyboard.type(param: 'A')
|
159
|
+
end
|
160
|
+
|
161
|
+
context 'with modifier keys' do
|
162
|
+
before do
|
163
|
+
@keys = 'LEFTSHIFT+A'
|
164
|
+
end
|
165
|
+
|
166
|
+
it 'clear all modifier keys except parameter of sendkey' do
|
167
|
+
expect(@keyboard).to receive(:clear_modifiers).with(Keyboard::MODIFIER_KEY_CODES - ['KEY_LEFTSHIFT']).ordered
|
168
|
+
@keyboard.type(param: @keys)
|
169
|
+
end
|
170
|
+
|
171
|
+
it 'types (Shift)A' do
|
172
|
+
expect(@keyboard).to receive(:clear_modifiers).ordered
|
173
|
+
expect(@keyboard).to receive(:key_event).with(keycode: 'KEY_LEFTSHIFT', press: true).ordered
|
174
|
+
expect(@keyboard).to receive(:key_event).with(keycode: 'KEY_A', press: true).ordered
|
175
|
+
expect(@keyboard).to receive(:key_event).with(keycode: 'KEY_A', press: false).ordered
|
176
|
+
expect(@keyboard).to receive(:key_event).with(keycode: 'KEY_LEFTSHIFT', press: false).ordered
|
177
|
+
@keyboard.type(param: @keys)
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
context 'with multiple keys' do
|
182
|
+
before do
|
183
|
+
@keys = 'A+B'
|
184
|
+
end
|
185
|
+
|
186
|
+
it 'types AB' do
|
187
|
+
expect(@keyboard).to receive(:clear_modifiers).ordered
|
188
|
+
expect(@keyboard).to receive(:key_event).with(keycode: 'KEY_A', press: true).ordered
|
189
|
+
expect(@keyboard).to receive(:key_event).with(keycode: 'KEY_B', press: true).ordered
|
190
|
+
expect(@keyboard).to receive(:key_event).with(keycode: 'KEY_B', press: false).ordered
|
191
|
+
expect(@keyboard).to receive(:key_event).with(keycode: 'KEY_A', press: false).ordered
|
192
|
+
@keyboard.type(param: @keys)
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'tempfile'
|
4
|
+
require 'fusuma/config'
|
5
|
+
|
6
|
+
module Fusuma
|
7
|
+
module ConfigHelper
|
8
|
+
module_function
|
9
|
+
|
10
|
+
def load_config_yml=(string)
|
11
|
+
Config.custom_path = Tempfile.open do |temp_file|
|
12
|
+
temp_file.tap { |f| f.write(string) }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'helpers/config_helper'
|
5
|
+
|
6
|
+
RSpec.configure do |config|
|
7
|
+
# Enable flags like --only-failures and --next-failure
|
8
|
+
config.example_status_persistence_file_path = '.rspec_status'
|
9
|
+
|
10
|
+
# Disable RSpec exposing methods globally on `Module` and `main`
|
11
|
+
config.disable_monkey_patching!
|
12
|
+
|
13
|
+
config.expect_with :rspec do |c|
|
14
|
+
c.syntax = :expect
|
15
|
+
end
|
16
|
+
|
17
|
+
config.include(Fusuma::ConfigHelper)
|
18
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fusuma-plugin-sendkey
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- iberianpig
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-03
|
11
|
+
date: 2021-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fusuma
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.0
|
19
|
+
version: '2.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.0
|
26
|
+
version: '2.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: revdev
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -46,26 +46,22 @@ executables:
|
|
46
46
|
extensions: []
|
47
47
|
extra_rdoc_files: []
|
48
48
|
files:
|
49
|
-
- ".gitignore"
|
50
|
-
- ".rspec"
|
51
|
-
- ".rubocop.yml"
|
52
|
-
- ".travis.yml"
|
53
|
-
- CHANGELOG.md
|
54
|
-
- CODE_OF_CONDUCT.md
|
55
|
-
- Gemfile
|
56
49
|
- LICENSE.txt
|
57
50
|
- README.md
|
58
|
-
- Rakefile
|
59
51
|
- bin/console
|
60
52
|
- bin/setup
|
61
53
|
- exe/fusuma-sendkey
|
62
54
|
- fusuma-plugin-sendkey.gemspec
|
63
|
-
- lefthook.yml
|
64
55
|
- lib/fusuma/plugin/executors/sendkey_executor.rb
|
65
56
|
- lib/fusuma/plugin/sendkey.rb
|
66
57
|
- lib/fusuma/plugin/sendkey/device.rb
|
67
58
|
- lib/fusuma/plugin/sendkey/keyboard.rb
|
68
59
|
- lib/fusuma/plugin/sendkey/version.rb
|
60
|
+
- spec/fusuma/plugin/executors/sendkey_executor_spec.rb
|
61
|
+
- spec/fusuma/plugin/sendkey/keyboard_spec.rb
|
62
|
+
- spec/fusuma/plugin/sendkey_spec.rb
|
63
|
+
- spec/helpers/config_helper.rb
|
64
|
+
- spec/spec_helper.rb
|
69
65
|
homepage: https://github.com/iberianpig/fusuma-plugin-sendkey
|
70
66
|
licenses:
|
71
67
|
- MIT
|
@@ -78,15 +74,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
78
74
|
requirements:
|
79
75
|
- - ">="
|
80
76
|
- !ruby/object:Gem::Version
|
81
|
-
version:
|
77
|
+
version: 2.5.1
|
82
78
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
79
|
requirements:
|
84
|
-
- - "
|
80
|
+
- - ">="
|
85
81
|
- !ruby/object:Gem::Version
|
86
|
-
version:
|
82
|
+
version: '0'
|
87
83
|
requirements: []
|
88
|
-
rubygems_version: 3.
|
84
|
+
rubygems_version: 3.1.4
|
89
85
|
signing_key:
|
90
86
|
specification_version: 4
|
91
87
|
summary: Fusuma plugin to send keyboard events
|
92
|
-
test_files:
|
88
|
+
test_files:
|
89
|
+
- spec/fusuma/plugin/sendkey_spec.rb
|
90
|
+
- spec/fusuma/plugin/sendkey/keyboard_spec.rb
|
91
|
+
- spec/fusuma/plugin/executors/sendkey_executor_spec.rb
|
92
|
+
- spec/helpers/config_helper.rb
|
93
|
+
- spec/spec_helper.rb
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/.rubocop.yml
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
AllCops:
|
2
|
-
TargetRubyVersion: 2.4
|
3
|
-
NewCops: enable
|
4
|
-
|
5
|
-
Metrics/ModuleLength:
|
6
|
-
Exclude:
|
7
|
-
- "**/*_spec.rb"
|
8
|
-
|
9
|
-
Metrics/BlockLength:
|
10
|
-
Exclude:
|
11
|
-
- "**/*_spec.rb"
|
12
|
-
- "fusuma-plugin-*.gemspec"
|
13
|
-
|
14
|
-
Layout/LineLength:
|
15
|
-
Max: 100
|
16
|
-
Exclude:
|
17
|
-
- "**/*_spec.rb"
|
18
|
-
- "fusuma-plugin-*.gemspec"
|
19
|
-
|
20
|
-
Style/HashEachMethods:
|
21
|
-
Enabled: true
|
22
|
-
Style/HashTransformKeys:
|
23
|
-
Enabled: true
|
24
|
-
Style/HashTransformValues:
|
25
|
-
Enabled: true
|
data/.travis.yml
DELETED
data/CHANGELOG.md
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
# Changelog
|
2
|
-
|
3
|
-
## [v0.2.1](https://github.com/iberianpig/fusuma-plugin-keypress/tree/v0.2.1) (2020-04-15)
|
4
|
-
|
5
|
-
[Full Changelog](https://github.com/iberianpig/fusuma-plugin-keypress/compare/v0.2.0...v0.2.1)
|
6
|
-
|
7
|
-
**Closed issues:**
|
8
|
-
|
9
|
-
- Only 'LEFTMETA' keycode works on KDE Plasma [\#2](https://github.com/iberianpig/fusuma-plugin-keypress/issues/2)
|
10
|
-
|
11
|
-
## [v0.2.0](https://github.com/iberianpig/fusuma-plugin-keypress/tree/v0.2.0) (2020-03-18)
|
12
|
-
|
13
|
-
[Full Changelog](https://github.com/iberianpig/fusuma-plugin-keypress/compare/v0.1.1...v0.2.0)
|
14
|
-
|
15
|
-
**Closed issues:**
|
16
|
-
|
17
|
-
- Trigger a command multiple times while keeping the key pressed [\#1](https://github.com/iberianpig/fusuma-plugin-keypress/issues/1)
|
18
|
-
|
19
|
-
## [v0.1.1](https://github.com/iberianpig/fusuma-plugin-keypress/tree/v0.1.1) (2020-02-18)
|
20
|
-
|
21
|
-
[Full Changelog](https://github.com/iberianpig/fusuma-plugin-keypress/compare/v0.1.0...v0.1.1)
|
22
|
-
|
23
|
-
## [v0.1.0](https://github.com/iberianpig/fusuma-plugin-keypress/tree/v0.1.0) (2019-11-12)
|
24
|
-
|
25
|
-
[Full Changelog](https://github.com/iberianpig/fusuma-plugin-keypress/compare/fb8d8ccfc3828e487607706335f670ae5392f08d...v0.1.0)
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
|
data/CODE_OF_CONDUCT.md
DELETED
@@ -1,74 +0,0 @@
|
|
1
|
-
# Contributor Covenant Code of Conduct
|
2
|
-
|
3
|
-
## Our Pledge
|
4
|
-
|
5
|
-
In the interest of fostering an open and welcoming environment, we as
|
6
|
-
contributors and maintainers pledge to making participation in our project and
|
7
|
-
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
-
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
-
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
-
orientation.
|
11
|
-
|
12
|
-
## Our Standards
|
13
|
-
|
14
|
-
Examples of behavior that contributes to creating a positive environment
|
15
|
-
include:
|
16
|
-
|
17
|
-
* Using welcoming and inclusive language
|
18
|
-
* Being respectful of differing viewpoints and experiences
|
19
|
-
* Gracefully accepting constructive criticism
|
20
|
-
* Focusing on what is best for the community
|
21
|
-
* Showing empathy towards other community members
|
22
|
-
|
23
|
-
Examples of unacceptable behavior by participants include:
|
24
|
-
|
25
|
-
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
-
advances
|
27
|
-
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
-
* Public or private harassment
|
29
|
-
* Publishing others' private information, such as a physical or electronic
|
30
|
-
address, without explicit permission
|
31
|
-
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
-
professional setting
|
33
|
-
|
34
|
-
## Our Responsibilities
|
35
|
-
|
36
|
-
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
-
behavior and are expected to take appropriate and fair corrective action in
|
38
|
-
response to any instances of unacceptable behavior.
|
39
|
-
|
40
|
-
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
-
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
-
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
-
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
-
threatening, offensive, or harmful.
|
45
|
-
|
46
|
-
## Scope
|
47
|
-
|
48
|
-
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
-
when an individual is representing the project or its community. Examples of
|
50
|
-
representing a project or community include using an official project e-mail
|
51
|
-
address, posting via an official social media account, or acting as an appointed
|
52
|
-
representative at an online or offline event. Representation of a project may be
|
53
|
-
further defined and clarified by project maintainers.
|
54
|
-
|
55
|
-
## Enforcement
|
56
|
-
|
57
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
-
reported by contacting the project team at yhkyky@gmail.com. All
|
59
|
-
complaints will be reviewed and investigated and will result in a response that
|
60
|
-
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
-
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
-
Further details of specific enforcement policies may be posted separately.
|
63
|
-
|
64
|
-
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
-
faith may face temporary or permanent repercussions as determined by other
|
66
|
-
members of the project's leadership.
|
67
|
-
|
68
|
-
## Attribution
|
69
|
-
|
70
|
-
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
-
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
-
|
73
|
-
[homepage]: http://contributor-covenant.org
|
74
|
-
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
source "https://rubygems.org"
|
2
|
-
|
3
|
-
# Specify your gem's dependencies in fusuma-plugin-sendkey.gemspec
|
4
|
-
gemspec
|
5
|
-
|
6
|
-
gem 'bundler'
|
7
|
-
gem 'github_changelog_generator', '~> 1.14'
|
8
|
-
gem 'lefthook'
|
9
|
-
gem 'pry-byebug', '~> 3.4'
|
10
|
-
gem 'pry-doc'
|
11
|
-
gem 'pry-inline'
|
12
|
-
gem 'rake', '~> 13.0'
|
13
|
-
gem 'reek'
|
14
|
-
gem 'rspec', '~> 3.0'
|
15
|
-
gem 'rubocop'
|
16
|
-
gem 'yard'
|
data/Rakefile
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'bundler/gem_tasks'
|
4
|
-
require 'rspec/core/rake_task'
|
5
|
-
|
6
|
-
RSpec::Core::RakeTask.new(:spec)
|
7
|
-
|
8
|
-
task default: :spec
|
9
|
-
|
10
|
-
require 'github_changelog_generator/task'
|
11
|
-
|
12
|
-
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
|
13
|
-
config.user = 'iberianpig'
|
14
|
-
config.project = 'fusuma-plugin-keypress'
|
15
|
-
end
|
data/lefthook.yml
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
# EXAMPLE USAGE
|
2
|
-
# Refer for explanation to following link:
|
3
|
-
# https://github.com/Arkweid/lefthook/blob/master/docs/full_guide.md
|
4
|
-
|
5
|
-
# pre-push:
|
6
|
-
# commands:
|
7
|
-
# packages-audit:
|
8
|
-
# tags: frontend security
|
9
|
-
# run: yarn audit
|
10
|
-
# gems-audit:
|
11
|
-
# tags: backend security
|
12
|
-
# run: bundle audit
|
13
|
-
|
14
|
-
pre-commit:
|
15
|
-
parallel: true
|
16
|
-
commands:
|
17
|
-
# eslint:
|
18
|
-
# glob: "*.{js,ts}"
|
19
|
-
# run: yarn eslint {staged_files}
|
20
|
-
rubocop:
|
21
|
-
tags: backend style
|
22
|
-
glob: "*.rb"
|
23
|
-
# exclude: "application.rb|routes.rb"
|
24
|
-
run: bundle exec rubocop --force-exclusion {staged_files}
|
25
|
-
# scripts:
|
26
|
-
# "hello.js":
|
27
|
-
# runner: node
|
28
|
-
# "any.go":
|
29
|
-
# runner: go run
|