fusuma-plugin-keypress 0.4.0.pre → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bf01d5bb0635029913f1c7fa172d65f6bd7ebaa184bf2c7bf7a374e6c58edec6
4
- data.tar.gz: 6aa537cc3c9717d1ad0f913ada4487f20d44915892b1517c5f1c9aeb61571867
3
+ metadata.gz: 958f90d65b6a5bfe120a5462bbfc1d21e01dbdf95d97f279e824a6ad6aafa5a3
4
+ data.tar.gz: 6d8c96cb5be6b003f00c0d20bc6bf68af693857e82d9ceb87837a1b752678e0f
5
5
  SHA512:
6
- metadata.gz: 1a2fc9a98ae8f36c88a46dd35caa917a37b6bf059faf9dae7911813dfe837ee55f9e07ffbb5b7ebb2bb656c7c16a1ff3b3cd2743a391d0385c486039508237d5
7
- data.tar.gz: 3e52a0c29351c21422e499a3803b32f20416888be23811a606f115cd21e6286e5eb2f7c19bded0fae339d7335e90d72479476495888677430e211485c60ee465
6
+ metadata.gz: 7be790c59d66696f078c89121f32f9dd61630a0debfe3584899cac8b0ed73d335b2858aca88e7d84b511dcb1cbaf9a0e36ac487300c519f2c5480ac7f16a4040
7
+ data.tar.gz: 858e05f1aca03e80be587ed315e79717a5c6815336c5b1ef8e1c112603df698be6d3b720853c18f2b200137b8c9eb866907e325032c8727ee6d1ffba368bc07e
data/README.md CHANGED
@@ -45,6 +45,7 @@ Keys following are available for `keypress`.
45
45
  * `RIGHTALT`
46
46
  * `RIGHTCTRL`
47
47
  * `RIGHTSHIFT`
48
+ * `RIGHTMETA`
48
49
 
49
50
  ## Example
50
51
 
@@ -16,14 +16,13 @@ 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
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
20
- spec.files = Dir.chdir(File.expand_path(__dir__)) do
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']
26
24
 
27
- spec.required_ruby_version = '>= 2.4' # https://packages.ubuntu.com/search?keywords=ruby&searchon=names&exact=1&suite=all&section=main
28
- spec.add_dependency 'fusuma', '~> 2.0.0.pre'
25
+ spec.required_ruby_version = '>= 2.5.1' # https://packages.ubuntu.com/search?keywords=ruby&searchon=names&exact=1&suite=all&section=main
26
+ # support bionic (18.04LTS) 2.5.1
27
+ spec.add_dependency 'fusuma', '~> 2.0'
29
28
  end
@@ -5,8 +5,14 @@ module Fusuma
5
5
  module Detectors
6
6
  # Detect KeypressEvent from KeypressBuffer
7
7
  class KeypressDetector < Detector
8
+ SOURCES = ['keypress'].freeze
8
9
  BUFFER_TYPE = 'keypress'
9
10
 
11
+ # Always watch buffers and detect them.
12
+ def watch?
13
+ true
14
+ end
15
+
10
16
  # @param buffers [Array<Event>]
11
17
  # @return [Event] if event is detected
12
18
  # @return [NilClass] if event is NOT detected
@@ -15,9 +21,7 @@ module Fusuma
15
21
 
16
22
  return if buffer.empty?
17
23
 
18
- records = buffer.events.select do |e|
19
- e.record.status == 'pressed'
20
- end.map(&:record)
24
+ records = buffer.events.select { |e| e.record.status == 'pressed' }.map(&:record)
21
25
 
22
26
  index_record = Events::Records::IndexRecord.new(
23
27
  index: create_index(records: records),
@@ -3,7 +3,7 @@
3
3
  module Fusuma
4
4
  module Plugin
5
5
  module Keypress
6
- VERSION = '0.4.0.pre'
6
+ VERSION = '0.4.2'
7
7
  end
8
8
  end
9
9
  end
@@ -3,8 +3,8 @@
3
3
  # fusuma will `require fusuma-plugin-xxxx/plugin/xxxx.rb`
4
4
 
5
5
  require_relative './keypress/version'
6
- require_relative './events/records/keypress_record.rb'
7
- require_relative './filters/keypress_filter.rb'
8
- require_relative './parsers/keypress_parser.rb'
9
- require_relative './buffers/keypress_buffer.rb'
10
- require_relative './detectors/keypress_detector.rb'
6
+ require_relative './events/records/keypress_record'
7
+ require_relative './filters/keypress_filter'
8
+ require_relative './parsers/keypress_parser'
9
+ require_relative './buffers/keypress_buffer'
10
+ require_relative './detectors/keypress_detector'
@@ -7,6 +7,18 @@ module Fusuma
7
7
  class KeypressParser < Parser
8
8
  DEFAULT_SOURCE = 'libinput_command_input'
9
9
 
10
+ AVAILABLE_KEYS = %w[
11
+ CAPSLOCK
12
+ LEFTALT
13
+ LEFTCTRL
14
+ LEFTMETA
15
+ LEFTSHIFT
16
+ RIGHTALT
17
+ RIGHTCTRL
18
+ RIGHTSHIFT
19
+ RIGHTMETA
20
+ ].freeze
21
+
10
22
  # @param record [String]
11
23
  # @return [Records::Gesture, nil]
12
24
  def parse_record(record)
@@ -27,6 +39,8 @@ module Fusuma
27
39
  code = matched[2] # LEFTSHIFT
28
40
  status = matched[3] # pressed
29
41
 
42
+ return unless AVAILABLE_KEYS.include?(code)
43
+
30
44
  Events::Records::KeypressRecord.new(status: status, code: code)
31
45
  end
32
46
  end
@@ -0,0 +1,66 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ require 'fusuma/plugin/detectors/detector'
6
+ require 'fusuma/plugin/buffers/buffer'
7
+
8
+ require './lib/fusuma/plugin/buffers/keypress_buffer'
9
+ require './lib/fusuma/plugin/detectors/keypress_detector'
10
+
11
+ module Fusuma
12
+ module Plugin
13
+ module Detectors
14
+ RSpec.describe KeypressDetector do
15
+ before do
16
+ @detector = KeypressDetector.new
17
+ @buffer = Buffers::KeypressBuffer.new
18
+ end
19
+
20
+ describe '#detector' do
21
+ context 'with no keypress event in buffer' do
22
+ before do
23
+ @buffer.clear
24
+ end
25
+
26
+ it { expect(@detector.detect([@buffer])).to eq nil }
27
+ end
28
+ end
29
+
30
+ context 'with keypress events in buffer' do
31
+ before do
32
+ record = Events::Records::KeypressRecord.new(status: 'pressed', code: 'LEFTSHIFT')
33
+ event = Events::Event.new(tag: 'keypress_parser', record: record)
34
+
35
+ @buffer.buffer(event)
36
+ end
37
+ it { expect(@detector.detect([@buffer])).to be_a Events::Event }
38
+ it { expect(@detector.detect([@buffer]).record).to be_a Events::Records::IndexRecord }
39
+ it { expect(@detector.detect([@buffer]).record.index).to be_a Config::Index }
40
+
41
+ it 'should detect LEFTSHIFT' do
42
+ expect(@detector.detect([@buffer]).record.index.keys.map(&:symbol))
43
+ .to eq(%i[keypress LEFTSHIFT])
44
+ end
45
+ end
46
+
47
+ context 'with two different keypress events in buffer' do
48
+ before do
49
+ record1 = Events::Records::KeypressRecord.new(status: 'pressed', code: 'LEFTSHIFT')
50
+ record2 = Events::Records::KeypressRecord.new(status: 'pressed', code: 'LEFTCTRL')
51
+ event1 = Events::Event.new(tag: 'keypress_parser', record: record1)
52
+ event2 = Events::Event.new(tag: 'keypress_parser', record: record2)
53
+
54
+ @buffer.buffer(event1)
55
+ @buffer.buffer(event2)
56
+ end
57
+
58
+ it 'should detect LEFTSHIFT+LEFTCTRL' do
59
+ expect(@detector.detect([@buffer]).record.index.keys.map(&:symbol))
60
+ .to eq(%i[keypress LEFTSHIFT+LEFTCTRL])
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe Fusuma::Plugin::Keypress do
6
+ it 'has a version number' do
7
+ expect(Fusuma::Plugin::Keypress::VERSION).not_to be nil
8
+ end
9
+ 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
@@ -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-keypress
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0.pre
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - iberianpig
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-11-09 00:00:00.000000000 Z
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.0.pre
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.0.pre
26
+ version: '2.0'
27
27
  description: fusuma-plugin-keypress is Fusuma plugin for keypress combination.
28
28
  email:
29
29
  - yhkyky@gmail.com
@@ -31,19 +31,11 @@ executables: []
31
31
  extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
- - ".gitignore"
35
- - ".rubocop.yml"
36
- - ".travis.yml"
37
- - CHANGELOG.md
38
- - CODE_OF_CONDUCT.md
39
- - Gemfile
40
34
  - LICENSE.txt
41
35
  - README.md
42
- - Rakefile
43
36
  - bin/console
44
37
  - bin/setup
45
38
  - fusuma-plugin-keypress.gemspec
46
- - lefthook.yml
47
39
  - lib/fusuma/plugin/buffers/keypress_buffer.rb
48
40
  - lib/fusuma/plugin/detectors/keypress_detector.rb
49
41
  - lib/fusuma/plugin/events/records/keypress_record.rb
@@ -51,11 +43,15 @@ files:
51
43
  - lib/fusuma/plugin/keypress.rb
52
44
  - lib/fusuma/plugin/keypress/version.rb
53
45
  - lib/fusuma/plugin/parsers/keypress_parser.rb
46
+ - spec/fusuma/plugin/detectors/keypress_detector_spec.rb
47
+ - spec/fusuma/plugin/keypress_spec.rb
48
+ - spec/helpers/config_helper.rb
49
+ - spec/spec_helper.rb
54
50
  homepage: https://github.com/iberianpig/fusuma-plugin-keypress
55
51
  licenses:
56
52
  - MIT
57
53
  metadata: {}
58
- post_install_message:
54
+ post_install_message:
59
55
  rdoc_options: []
60
56
  require_paths:
61
57
  - lib
@@ -63,15 +59,19 @@ required_ruby_version: !ruby/object:Gem::Requirement
63
59
  requirements:
64
60
  - - ">="
65
61
  - !ruby/object:Gem::Version
66
- version: '2.4'
62
+ version: 2.5.1
67
63
  required_rubygems_version: !ruby/object:Gem::Requirement
68
64
  requirements:
69
- - - ">"
65
+ - - ">="
70
66
  - !ruby/object:Gem::Version
71
- version: 1.3.1
67
+ version: '0'
72
68
  requirements: []
73
69
  rubygems_version: 3.1.4
74
- signing_key:
70
+ signing_key:
75
71
  specification_version: 4
76
72
  summary: Keypress plugin for Fusuma
77
- test_files: []
73
+ test_files:
74
+ - spec/fusuma/plugin/detectors/keypress_detector_spec.rb
75
+ - spec/fusuma/plugin/keypress_spec.rb
76
+ - spec/helpers/config_helper.rb
77
+ - spec/spec_helper.rb
data/.gitignore DELETED
@@ -1,13 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
10
-
11
- # rspec failure tracking
12
- .rspec_status
13
- .ruby-version
data/.rubocop.yml DELETED
@@ -1,17 +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
- Metrics/LineLength:
15
- Max: 100
16
- Exclude:
17
- - "fusuma-plugin-*.gemspec"
data/.travis.yml DELETED
@@ -1,10 +0,0 @@
1
- ---
2
- sudo: false
3
- language: ruby
4
- cache: bundler
5
- rvm:
6
- - 2.3.1
7
- - 2.4
8
- - 2.5
9
- - 2.6
10
- before_install: gem install bundler --no-document -v 2.0.1
data/CHANGELOG.md DELETED
@@ -1,9 +0,0 @@
1
- # Change Log
2
-
3
- ## [v0.1.1](https://github.com/iberianpig/fusuma-plugin-keypress/tree/v0.1.1) (2020-02-18)
4
- [Full Changelog](https://github.com/iberianpig/fusuma-plugin-keypress/compare/v0.1.0...v0.1.1)
5
-
6
- ## [v0.1.0](https://github.com/iberianpig/fusuma-plugin-keypress/tree/v0.1.0) (2019-11-12)
7
-
8
-
9
- \* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/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,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source 'https://rubygems.org'
4
-
5
- # Specify your gem's dependencies in fusuma-plugin-keypress.gemspec
6
- gemspec
7
-
8
- gem 'bundler'
9
- gem 'github_changelog_generator'
10
- gem 'lefthook'
11
- gem 'pry-byebug', '~> 3.4'
12
- gem 'pry-doc'
13
- gem 'pry-inline'
14
- gem 'rake', '~> 13.0'
15
- gem 'reek'
16
- gem 'rspec', '~> 3.0'
17
- gem 'rubocop'
18
- 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