fusuma 2.0.0.pre → 2.0.0.pre2

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 (47) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +8 -5
  3. data/.rubocop_todo.yml +34 -19
  4. data/.solargraph.yml +16 -0
  5. data/.travis.yml +1 -3
  6. data/CHANGELOG.md +1 -1
  7. data/Gemfile +6 -1
  8. data/README.md +43 -5
  9. data/fusuma.gemspec +3 -2
  10. data/lib/fusuma.rb +87 -33
  11. data/lib/fusuma/config.rb +33 -40
  12. data/lib/fusuma/config/index.rb +34 -8
  13. data/lib/fusuma/config/searcher.rb +78 -4
  14. data/lib/fusuma/custom_process.rb +13 -0
  15. data/lib/fusuma/device.rb +19 -6
  16. data/lib/fusuma/environment.rb +3 -3
  17. data/lib/fusuma/hash_support.rb +40 -0
  18. data/lib/fusuma/libinput_command.rb +8 -8
  19. data/lib/fusuma/multi_logger.rb +2 -6
  20. data/lib/fusuma/plugin/base.rb +18 -15
  21. data/lib/fusuma/plugin/buffers/buffer.rb +3 -2
  22. data/lib/fusuma/plugin/buffers/gesture_buffer.rb +34 -25
  23. data/lib/fusuma/plugin/buffers/timer_buffer.rb +3 -3
  24. data/lib/fusuma/plugin/detectors/detector.rb +26 -5
  25. data/lib/fusuma/plugin/detectors/pinch_detector.rb +109 -58
  26. data/lib/fusuma/plugin/detectors/rotate_detector.rb +91 -50
  27. data/lib/fusuma/plugin/detectors/swipe_detector.rb +93 -56
  28. data/lib/fusuma/plugin/events/event.rb +5 -4
  29. data/lib/fusuma/plugin/events/records/context_record.rb +27 -0
  30. data/lib/fusuma/plugin/events/records/gesture_record.rb +9 -6
  31. data/lib/fusuma/plugin/events/records/index_record.rb +46 -14
  32. data/lib/fusuma/plugin/events/records/record.rb +1 -1
  33. data/lib/fusuma/plugin/events/records/text_record.rb +2 -1
  34. data/lib/fusuma/plugin/executors/command_executor.rb +20 -3
  35. data/lib/fusuma/plugin/executors/executor.rb +45 -3
  36. data/lib/fusuma/plugin/filters/filter.rb +1 -1
  37. data/lib/fusuma/plugin/filters/libinput_device_filter.rb +6 -7
  38. data/lib/fusuma/plugin/filters/libinput_timeout_filter.rb +2 -2
  39. data/lib/fusuma/plugin/inputs/input.rb +19 -7
  40. data/lib/fusuma/plugin/inputs/libinput_command_input.rb +10 -5
  41. data/lib/fusuma/plugin/inputs/timer_input.rb +7 -7
  42. data/lib/fusuma/plugin/manager.rb +10 -28
  43. data/lib/fusuma/plugin/parsers/libinput_gesture_parser.rb +10 -8
  44. data/lib/fusuma/plugin/parsers/parser.rb +8 -9
  45. data/lib/fusuma/string_support.rb +16 -0
  46. data/lib/fusuma/version.rb +1 -1
  47. metadata +13 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bd6d9f73a5476aed954644b4d5f7caa9627779139bc84e301fa2ae67fbb1d71f
4
- data.tar.gz: e893683da4aa5f235481ec32bf45a6a2386bc6b64989f36617b6806c538602b3
3
+ metadata.gz: 6f7ab066b275d3d5bdf59d18a948d297d0e164f71d0611e6f999c71d962a8f6d
4
+ data.tar.gz: f92ff70084e6b98482236b67b2f2c68d7424f7cb8ff1e9ad6b61f4a7d4bea244
5
5
  SHA512:
6
- metadata.gz: 55b7d3393e283bc459b865d293839d6aa2286db4ece74b14d9b50c05726f4d5bfb32609b79541ad816b0ebdebb687b948f03f53fdd1e4d070bf470af56360c84
7
- data.tar.gz: f9d5b36287ccd132687497f8f527fc1ef90b0dc818feccf2f9cc6db0b76371a30832467df2d8aa0fca8ee3c5804551da8470b34784c185da73dc08ae507034de
6
+ metadata.gz: 885b781c3ec389cc6e37a68eb0799044e8792587145875d7c3facb59dc3a003cd53c4beb9d2a539f534f4947b2a5cf4d43442a9d3a0dba929744881feac7607c
7
+ data.tar.gz: a79c1f4390694af343cb98901f30916c32642ff5318181a8191c855997eff64aea3dc4a88f02b51a7bfb2565ac7037965bb2816b24141eab6bcd6a23f9ce04dc
data/.rubocop.yml CHANGED
@@ -1,7 +1,8 @@
1
1
  inherit_from: .rubocop_todo.yml
2
2
 
3
3
  AllCops:
4
- TargetRubyVersion: '2.3'
4
+ TargetRubyVersion: '2.5'
5
+ NewCops: enable
5
6
 
6
7
  Metrics/ModuleLength:
7
8
  Exclude:
@@ -30,11 +31,13 @@ Style/HashTransformKeys:
30
31
  Style/HashTransformValues:
31
32
  Enabled: true
32
33
 
33
- # For compatible ruby 2.3
34
- Style/RedundantBegin:
35
- Enabled: false
36
-
37
34
  Lint/RaiseException:
38
35
  Enabled: true
39
36
  Lint/StructNewOverride:
40
37
  Enabled: true
38
+
39
+ # for declaring dummy classes in ./spec
40
+ Lint/ConstantDefinitionInBlock:
41
+ Exclude:
42
+ - "**/*_spec.rb"
43
+
data/.rubocop_todo.yml CHANGED
@@ -1,24 +1,49 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2020-01-07 13:21:56 +0900 using RuboCop version 0.78.0.
3
+ # on 2021-03-28 13:34:27 UTC using RuboCop version 1.10.0.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
- # Offense count: 5
9
+ # Offense count: 1
10
+ # Cop supports --auto-correct.
11
+ # Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
12
+ # URISchemes: http, https
13
+ Layout/LineLength:
14
+ Max: 104
15
+
16
+ # Offense count: 9
17
+ # Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
10
18
  Metrics/AbcSize:
11
- Max: 25
19
+ Max: 67
12
20
 
13
- # Offense count: 1
14
- # Configuration parameters: CountComments.
21
+ # Offense count: 2
22
+ # Configuration parameters: CountComments, CountAsOne.
15
23
  Metrics/ClassLength:
16
- Max: 101
24
+ Max: 121
17
25
 
18
- # Offense count: 8
19
- # Configuration parameters: CountComments, ExcludedMethods.
26
+ # Offense count: 7
27
+ # Configuration parameters: IgnoredMethods.
28
+ Metrics/CyclomaticComplexity:
29
+ Max: 12
30
+
31
+ # Offense count: 24
32
+ # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
20
33
  Metrics/MethodLength:
21
- Max: 15
34
+ Max: 57
35
+
36
+ # Offense count: 5
37
+ # Configuration parameters: IgnoredMethods.
38
+ Metrics/PerceivedComplexity:
39
+ Max: 13
40
+
41
+ # Offense count: 1
42
+ # Configuration parameters: EnforcedStyleForLeadingUnderscores.
43
+ # SupportedStylesForLeadingUnderscores: disallowed, required, optional
44
+ Naming/MemoizedInstanceVariableName:
45
+ Exclude:
46
+ - 'lib/fusuma/plugin/detectors/detector.rb'
22
47
 
23
48
  # Offense count: 3
24
49
  Style/Documentation:
@@ -28,13 +53,3 @@ Style/Documentation:
28
53
  - 'lib/fusuma/plugin/detectors/pinch_detector.rb'
29
54
  - 'lib/fusuma/plugin/detectors/rotate_detector.rb'
30
55
  - 'lib/fusuma/plugin/detectors/swipe_detector.rb'
31
-
32
- # Offense count: 3
33
- # Cop supports --auto-correct.
34
- # Configuration parameters: AutoCorrect, EnforcedStyle, IgnoredMethods.
35
- # SupportedStyles: predicate, comparison
36
- Style/NumericPredicate:
37
- Exclude:
38
- - 'spec/**/*'
39
- - 'lib/fusuma/plugin/detectors/rotate_detector.rb'
40
- - 'lib/fusuma/plugin/detectors/swipe_detector.rb'
data/.solargraph.yml ADDED
@@ -0,0 +1,16 @@
1
+ ---
2
+ include:
3
+ - "**/*.rb"
4
+ exclude:
5
+ - spec/**/*
6
+ - test/**/*
7
+ - vendor/**/*
8
+ - ".bundle/**/*"
9
+ require: []
10
+ domains: []
11
+ reporters:
12
+ - rubocop
13
+ # - require_not_found
14
+ require_paths: []
15
+ plugins: []
16
+ max_files: 5000
data/.travis.yml CHANGED
@@ -3,9 +3,7 @@ sudo: false
3
3
  language: ruby
4
4
  cache: bundler
5
5
  rvm:
6
- - 2.3.1
7
- - 2.4
8
- - 2.5
6
+ - 2.5.1
9
7
  - 2.6
10
8
  - 2.7
11
9
  before_install: gem install bundler --no-document -v 2.0.1
data/CHANGELOG.md CHANGED
@@ -247,7 +247,7 @@
247
247
 
248
248
  **Closed issues:**
249
249
 
250
- - Print system information for debuging [\#70](https://github.com/iberianpig/fusuma/issues/70)
250
+ - Print system information for debugging [\#70](https://github.com/iberianpig/fusuma/issues/70)
251
251
  - rescue from SIGINT Interruption with Ctrl-C [\#64](https://github.com/iberianpig/fusuma/issues/64)
252
252
 
253
253
  ## [v0.7.1](https://github.com/iberianpig/fusuma/tree/v0.7.1) (2018-06-01)
data/Gemfile CHANGED
@@ -12,7 +12,12 @@ gem 'pry-byebug', '~> 3.4'
12
12
  gem 'pry-doc'
13
13
  gem 'pry-inline'
14
14
  gem 'rake', '~> 13.0'
15
+ gem 'rblineprof'
16
+ gem 'rblineprof-report'
15
17
  gem 'reek'
16
18
  gem 'rspec', '~> 3.0'
17
- gem 'rubocop', '0.81'
19
+ gem 'rubocop'
20
+ gem 'rubocop-rake'
21
+ gem 'rubocop-rspec'
22
+ gem 'solargraph'
18
23
  gem 'yard'
data/README.md CHANGED
@@ -17,7 +17,7 @@ This gem makes your linux able to recognize swipes or pinchs and assign commands
17
17
 
18
18
  ## Installation
19
19
 
20
- ### 1. Grant permission to read the touchpad device
20
+ ### Grant permission to read the touchpad device
21
21
 
22
22
  **IMPORTANT**: You **MUST** be a member of the **INPUT** group to read touchpad by Fusuma.
23
23
 
@@ -31,7 +31,9 @@ Then, You apply the change with no logout or reboot.
31
31
  $ newgrp input
32
32
  ```
33
33
 
34
- ### 2. Install libinput-tools
34
+ ### For Debian Based Distros (Ubuntu, Debian, Mint, Pop!OS)
35
+
36
+ #### 1. Install libinput-tools
35
37
 
36
38
  You need `libinput` release 1.0 or later.
37
39
 
@@ -39,7 +41,7 @@ You need `libinput` release 1.0 or later.
39
41
  $ sudo apt-get install libinput-tools
40
42
  ```
41
43
 
42
- ### 3. Install Ruby
44
+ #### 2. Install Ruby
43
45
 
44
46
  Fusuma runs in Ruby, so you must install it first.
45
47
 
@@ -47,13 +49,13 @@ Fusuma runs in Ruby, so you must install it first.
47
49
  $ sudo apt-get install ruby
48
50
  ```
49
51
 
50
- ### 4. Install Fusuma
52
+ #### 3. Install Fusuma
51
53
 
52
54
  ```bash
53
55
  $ sudo gem install fusuma
54
56
  ```
55
57
 
56
- ### 5. Install xdotool (optional)
58
+ #### 4. Install xdotool (optional)
57
59
 
58
60
  For sending shortcuts:
59
61
 
@@ -61,6 +63,42 @@ For sending shortcuts:
61
63
  $ sudo apt-get install xdotool
62
64
  ```
63
65
 
66
+ ### For Arch Based Distros (Manjaro, Arch)
67
+
68
+ #### 1. Install libinput.
69
+
70
+ You need `libinput` release 1.0 or later. This is most probably installed by default on Manjaro
71
+
72
+ ```z-h
73
+ $ sudo pacman -S libinput
74
+ ```
75
+
76
+ #### 2. Install Ruby
77
+
78
+ Fusuma runs in Ruby, so you must install it first.
79
+
80
+ ```zsh
81
+ $ sudo pacman -S ruby
82
+ ```
83
+
84
+ #### 3. Install Fusuma
85
+
86
+ **Note:** 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)
87
+
88
+ 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)
89
+
90
+ ```zsh
91
+ $ sudo gem install fusuma
92
+ ```
93
+
94
+ #### 4. Install xdotool (optional)
95
+
96
+ For sending shortcuts:
97
+
98
+ ```zsh
99
+ $ sudo pacman -S xdotool
100
+ ```
101
+
64
102
  ### Touchpad not working in GNOME
65
103
 
66
104
  Ensure the touchpad events are being sent to the GNOME desktop by running the following command:
data/fusuma.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.authors = ['iberianpig']
11
11
  spec.email = ['yhkyky@gmail.com']
12
12
 
13
- spec.summary = 'Multitouch gestures with libinput dirver on X11, Linux'
13
+ spec.summary = 'Multitouch gestures with libinput driver on X11, Linux'
14
14
  spec.description = 'Fusuma is multitouch gesture recognizer. This gem makes your touchpad on Linux able to recognize swipes or pinchs and assign command to them. Read installation on Github(https://github.com/iberianpig/fusuma#installation).'
15
15
  spec.homepage = 'https://github.com/iberianpig/fusuma'
16
16
  spec.license = 'MIT'
@@ -23,6 +23,7 @@ Gem::Specification.new do |spec|
23
23
  spec.require_paths = ['lib']
24
24
  spec.metadata['yard.run'] = 'yri' # use "yard" to build full HTML docs.
25
25
 
26
- spec.required_ruby_version = '>= 2.3' # https://packages.ubuntu.com/search?keywords=ruby&searchon=names&exact=1&suite=all&section=main
26
+ spec.required_ruby_version = '>= 2.5.1' # https://packages.ubuntu.com/search?keywords=ruby&searchon=names&exact=1&suite=all&section=main
27
+ # support bionic (18.04LTS) 2.5.1
27
28
  spec.add_dependency 'posix-spawn'
28
29
  end
data/lib/fusuma.rb CHANGED
@@ -2,10 +2,10 @@
2
2
 
3
3
  require_relative './fusuma/version'
4
4
  require_relative './fusuma/multi_logger'
5
- require_relative './fusuma/config.rb'
6
- require_relative './fusuma/environment.rb'
7
- require_relative './fusuma/device.rb'
8
- require_relative './fusuma/plugin/manager.rb'
5
+ require_relative './fusuma/config'
6
+ require_relative './fusuma/environment'
7
+ require_relative './fusuma/device'
8
+ require_relative './fusuma/plugin/manager'
9
9
 
10
10
  # this is top level module
11
11
  module Fusuma
@@ -16,6 +16,8 @@ module Fusuma
16
16
  set_trap
17
17
  read_options(option)
18
18
  instance = new
19
+ ## NOTE: Uncomment following line to measure performance
20
+ # instance.run_with_lineprof
19
21
  instance.run
20
22
  end
21
23
 
@@ -62,68 +64,120 @@ module Fusuma
62
64
  end
63
65
 
64
66
  def run
65
- loop do
66
- event = input
67
- event || next
68
- clear_expired_events
69
- filtered = filter(event) || next
70
- parsed = parse(filtered) || next
71
- buffered = buffer(parsed) || next
72
- detected = detect(buffered) || next
73
- merged = merge(detected) || next
74
- execute(merged)
67
+ loop { pipeline }
68
+ end
69
+
70
+ def pipeline
71
+ event = input || return
72
+ clear_expired_events
73
+ filtered = filter(event) || return
74
+ parsed = parse(filtered) || return
75
+ buffered = buffer(parsed) || return
76
+ detected = detect(buffered) || return
77
+ condition, context, event = merge(detected) || return
78
+ execute(condition, context, event)
79
+ end
80
+
81
+ # For performance monitoring
82
+ def run_with_lineprof(count: 1000)
83
+ require 'rblineprof'
84
+ require 'rblineprof-report'
85
+
86
+ profile = lineprof(%r{#{Pathname.new(__FILE__).parent}/.}) do
87
+ count.times { pipeline }
75
88
  end
89
+ LineProf.report(profile)
90
+ exit 0
76
91
  end
77
92
 
93
+ # @return [Plugin::Events::Event]
78
94
  def input
79
95
  Plugin::Inputs::Input.select(@inputs)
80
96
  end
81
97
 
98
+ # @param [Plugin::Events::Event]
99
+ # @return [Plugin::Events::Event]
82
100
  def filter(event)
83
101
  event if @filters.any? { |f| f.filter(event) }
84
102
  end
85
103
 
104
+ # @param [Plugin::Events::Event]
105
+ # @return [Plugin::Events::Event]
86
106
  def parse(event)
87
107
  @parsers.reduce(event) { |e, p| p.parse(e) if e }
88
108
  end
89
109
 
110
+ # @param [Plugin::Events::Event]
111
+ # @return [Array<Plugin::Buffers::Buffer>]
112
+ # @return [NilClass]
90
113
  def buffer(event)
91
- @buffers.any? { |b| b.buffer(event) } && @buffers
114
+ @buffers.select { |b| b.buffer(event) }
92
115
  end
93
116
 
94
117
  # @param buffers [Array<Buffer>]
95
118
  # @return [Array<Event>]
96
119
  def detect(buffers)
97
- @detectors.each_with_object([]) do |detector, detected|
98
- if (event = detector.detect(buffers))
99
- detected << event
100
- end
120
+ matched_detectors = @detectors.select do |detector|
121
+ detector.watch? ||
122
+ buffers.any? { |b| detector.sources.include?(b.type) }
123
+ end
124
+
125
+ events = matched_detectors.each_with_object([]) do |detector, detected|
126
+ Array(detector.detect(@buffers)).each { |e| detected << e }
101
127
  end
128
+
129
+ return if events.empty?
130
+
131
+ events
102
132
  end
103
133
 
104
- # @param events [Array<Event>]
105
- # @return [Event] a Event merged all records from arguments
134
+ # @param events [Array<Plugin::Events::Event>]
135
+ # @return [Plugin::Events::Event] Event merged all records from arguments
106
136
  # @return [NilClass] when event is NOT given
107
137
  def merge(events)
108
- main_events, modifiers = events.partition { |event| event.record.mergable? }
109
- return nil unless (main_event = main_events.first)
138
+ index_events, context_events = events.partition { |event| event.record.type == :index }
139
+ main_events, modifiers = index_events.partition { |event| event.record.mergable? }
140
+ request_context = context_events.each_with_object({}) do |e, results|
141
+ results[e.record.name] = e.record.value
142
+ end
143
+ main_events.sort_by! { |e| e.record.trigger_priority }
144
+
145
+ condition = nil
146
+ matched_context = nil
147
+ event = main_events.find do |main_event|
148
+ matched_context = Config::Searcher.find_context(request_context) do
149
+ condition, index_record = Config::Searcher.find_condition do
150
+ main_event.record.merge(records: modifiers.map(&:record))
151
+ end
152
+ main_event if index_record
153
+ end
154
+ end
155
+ return if event.nil?
110
156
 
111
- main_event.record.merge(records: modifiers.map(&:record))
112
- main_event
157
+ [condition, matched_context, event]
113
158
  end
114
159
 
115
- def execute(event)
160
+ # @param event [Plugin::Events::Event]
161
+ def execute(condition, context, event)
116
162
  return unless event
117
163
 
118
- l = lambda do
119
- executor = @executors.find { |e| e.executable?(event) }
120
- executor&.execute(event)
164
+ # Find executable condition and executor
165
+ executor = Config::Searcher.with_context(context) do
166
+ Config::Searcher.with_condition(condition) do
167
+ @executors.find { |e| e.executable?(event) }
168
+ end
121
169
  end
122
170
 
123
- l.call ||
124
- Config::Searcher.skip { l.call } ||
125
- Config::Searcher.fallback { l.call } ||
126
- Config::Searcher.skip { Config::Searcher.fallback { l.call } }
171
+ return if executor.nil?
172
+
173
+ # Check interval and execute
174
+ Config::Searcher.with_context(context) do
175
+ Config::Searcher.with_condition(condition) do
176
+ executor.enough_interval?(event) &&
177
+ executor.update_interval(event) &&
178
+ executor.execute(event)
179
+ end
180
+ end
127
181
  end
128
182
 
129
183
  def clear_expired_events
data/lib/fusuma/config.rb CHANGED
@@ -1,9 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative './multi_logger.rb'
4
- require_relative './config/index.rb'
5
- require_relative './config/searcher.rb'
6
- require_relative './config/yaml_duplication_checker.rb'
3
+ require_relative './multi_logger'
4
+ require_relative './config/index'
5
+ require_relative './config/searcher'
6
+ require_relative './config/yaml_duplication_checker'
7
+ require_relative './hash_support'
7
8
  require 'singleton'
8
9
  require 'yaml'
9
10
 
@@ -12,13 +13,18 @@ module Fusuma
12
13
  # read keymap from yaml file
13
14
  class Config
14
15
  class NotFoundError < StandardError; end
16
+
15
17
  class InvalidFileError < StandardError; end
16
18
 
17
19
  include Singleton
18
20
 
19
21
  class << self
20
- def search(keys)
21
- instance.search(keys)
22
+ def search(index)
23
+ instance.search(index)
24
+ end
25
+
26
+ def find_execute_key(index)
27
+ instance.find_execute_key(index)
22
28
  end
23
29
 
24
30
  def custom_path=(new_path)
@@ -26,9 +32,7 @@ module Fusuma
26
32
  end
27
33
  end
28
34
 
29
- attr_reader :keymap
30
- attr_reader :custom_path
31
- attr_reader :searcher
35
+ attr_reader :keymap, :custom_path, :searcher
32
36
 
33
37
  def initialize
34
38
  @searcher = Searcher.new
@@ -49,8 +53,8 @@ module Fusuma
49
53
  self
50
54
  end
51
55
 
52
- # @return [Hash]
53
- # @raise [InvalidError]
56
+ # @return [Hash] If check passes
57
+ # @raise [InvalidFileError] If check does not pass
54
58
  def validate(path)
55
59
  duplicates = []
56
60
  YAMLDuplicationChecker.check(File.read(path), path) do |ignored, duplicate|
@@ -59,20 +63,30 @@ module Fusuma
59
63
  end
60
64
  raise InvalidFileError, "Detect duplicate keys #{duplicates}" unless duplicates.empty?
61
65
 
62
- yaml = YAML.load_file(path)
63
-
64
- raise InvalidFileError, 'Invaid YAML file' unless yaml.is_a? Hash
65
-
66
- yaml.deep_symbolize_keys
66
+ yamls = YAML.load_stream(File.read(path)).compact
67
+ yamls.map(&:deep_symbolize_keys)
67
68
  rescue StandardError => e
68
69
  MultiLogger.error e.message
69
70
  raise InvalidFileError, e.message
70
71
  end
71
72
 
72
73
  # @param index [Index]
73
- # @param location [Hash]
74
- def search(index, location: keymap)
75
- @searcher.search_with_cache(index, location: location)
74
+ # @param context [Hash]
75
+ def search(index)
76
+ @searcher.search_with_cache(index, location: keymap)
77
+ end
78
+
79
+ # @param index [Config::Index]
80
+ # @return Symbol
81
+ def find_execute_key(index)
82
+ @execute_keys ||= Plugin::Executors::Executor.plugins.map do |executor|
83
+ executor.new.execute_keys
84
+ end.flatten
85
+
86
+ execute_params = search(index)
87
+ return if execute_params.nil?
88
+
89
+ @execute_keys.find { |k| execute_params.keys.include?(k) }
76
90
  end
77
91
 
78
92
  private
@@ -104,24 +118,3 @@ module Fusuma
104
118
  end
105
119
  end
106
120
  end
107
-
108
- # activesupport-4.1.1/lib/active_support/core_ext/hash/keys.rb
109
- class Hash
110
- def deep_symbolize_keys
111
- deep_transform_keys do |key|
112
- begin
113
- key.to_sym
114
- rescue StandardError
115
- key
116
- end
117
- end
118
- end
119
-
120
- def deep_transform_keys(&block)
121
- result = {}
122
- each do |key, value|
123
- result[yield(key)] = value.is_a?(Hash) ? value.deep_transform_keys(&block) : value
124
- end
125
- result
126
- end
127
- end