fusuma 1.3.3 → 1.4.0

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: 1b012552c1ff9c6bedfd50b1e7bb69c86c5c7707c7fb33a18c01680d20ebd727
4
- data.tar.gz: 9e67721caad84d06736b68e7c1eedf43dc71d1ad72be48675b6508effc5b0e40
3
+ metadata.gz: f16929054076669742906dca54ea4cc907c5b4adb12d6454261dce202baa5280
4
+ data.tar.gz: '08cbb875607091af2b3ae0a27f96bb735532527f4e64df534f19dda6c0ea74af'
5
5
  SHA512:
6
- metadata.gz: 2adcbd119334a2050cfd01e9b75ee74e7ba5061f8ca5bb96c9c3472096c43d431a151851129db0099ac24b39bb8c04db8811ccc740034d409fb9d814fa218c06
7
- data.tar.gz: 691e7617d19b4670a8e4e3b1c3ed01fd4a01745632d9be6b6a6e33a45834ba046baa6ae5f19bac0d7c1721e7dc981bbeeb9c2b189499e17bd26240f368df9619
6
+ metadata.gz: '08fa7c0802ba80260e7c3c7a06e3509d363d314cb49618c8af728f1eb5ee33bc44f9c71f4197d010485583d6c251eb8796c2e62fa30aa81a6bb6124ec0d73caf'
7
+ data.tar.gz: a01441b1995ec469729deb899c68ff54955a0b4083d943ee137f293d7b0b0202f186263d47dd3f96d1a3f1257686a5394677a8da667311b05870606bfc9ba9f3
data/.gitignore CHANGED
@@ -11,5 +11,7 @@
11
11
  # rspec failure tracking
12
12
  .rspec_status
13
13
 
14
+ .ruby-version
15
+
14
16
  # todo
15
17
  todo.md
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## [Unreleased](https://github.com/iberianpig/fusuma/tree/HEAD)
4
+
5
+ [Full Changelog](https://github.com/iberianpig/fusuma/compare/v1.3.3...HEAD)
6
+
7
+ **Closed issues:**
8
+
9
+ - Can not use fusuma with a error: NoMethodError [\#149](https://github.com/iberianpig/fusuma/issues/149)
10
+
11
+ ## [v1.3.3](https://github.com/iberianpig/fusuma/tree/v1.3.3) (2020-02-10)
12
+
13
+ [Full Changelog](https://github.com/iberianpig/fusuma/compare/v1.3.2...v1.3.3)
14
+
3
15
  ## [v1.3.2](https://github.com/iberianpig/fusuma/tree/v1.3.2) (2020-01-07)
4
16
 
5
17
  [Full Changelog](https://github.com/iberianpig/fusuma/compare/v1.3.1...v1.3.2)
@@ -107,7 +119,6 @@
107
119
 
108
120
  - Interval and threshold specific for a trigger [\#92](https://github.com/iberianpig/fusuma/pull/92) ([irq](https://github.com/irq))
109
121
  - Fix spelling: Elementary to elementary [\#90](https://github.com/iberianpig/fusuma/pull/90) ([ryonakano](https://github.com/ryonakano))
110
- - Update rake requirement to ~\> 12.3 [\#72](https://github.com/iberianpig/fusuma/pull/72) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
111
122
 
112
123
  ## [v0.9.2](https://github.com/iberianpig/fusuma/tree/v0.9.2) (2018-07-19)
113
124
 
@@ -197,6 +208,7 @@
197
208
  **Merged pull requests:**
198
209
 
199
210
  - Assigning commands [\#73](https://github.com/iberianpig/fusuma/pull/73) ([iberianpig](https://github.com/iberianpig))
211
+ - Update rake requirement to ~\> 12.3 [\#72](https://github.com/iberianpig/fusuma/pull/72) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
200
212
 
201
213
  ## [v0.3.5](https://github.com/iberianpig/fusuma/tree/v0.3.5) (2018-01-01)
202
214
 
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Fusuma [![Gem Version](https://badge.fury.io/rb/fusuma.svg)](https://badge.fury.io/rb/fusuma) [![Build Status](https://travis-ci.org/iberianpig/fusuma.svg?branch=master)](https://travis-ci.org/iberianpig/fusuma)
1
+ # Fusuma [![Gem Version](https://badge.fury.io/rb/fusuma.svg)](https://badge.fury.io/rb/fusuma) [![Build Status](https://travis-ci.com/iberianpig/fusuma.svg?branch=master)](https://travis-ci.com/iberianpig/fusuma)
2
2
 
3
3
  Fusuma is multitouch gesture recognizer.
4
4
  This gem makes your linux able to recognize swipes or pinchs and assign commands to them.
@@ -127,9 +127,6 @@ module Fusuma
127
127
  main_events, modifiers = events.partition { |event| event.record.mergable? }
128
128
  return nil unless (main_event = main_events.first)
129
129
 
130
- # NOTE: clear buffers after detected main_event
131
- @buffers.each(&:clear)
132
-
133
130
  main_event.record.merge(records: modifiers.map(&:record))
134
131
  main_event
135
132
  end
@@ -61,71 +61,71 @@ module Fusuma
61
61
  end
62
62
  line_parser.generate_devices
63
63
  end
64
+ end
64
65
 
65
- # parse line and generate devices
66
- class LineParser
67
- attr_reader :lines
68
-
69
- def initialize
70
- @lines = []
71
- end
66
+ # parse line and generate devices
67
+ class LineParser
68
+ attr_reader :lines
72
69
 
73
- # @param line [String]
74
- def push(line)
75
- lines.push(line)
76
- end
70
+ def initialize
71
+ @lines = []
72
+ end
77
73
 
78
- # @return [Array]
79
- def generate_devices
80
- lines.each_with_object([]) do |line, devices|
81
- attributes = extract_attribute(line: line)
74
+ # @param line [String]
75
+ def push(line)
76
+ lines.push(line)
77
+ end
82
78
 
83
- next if attributes == {}
79
+ # @return [Array]
80
+ def generate_devices
81
+ lines.each_with_object([]) do |line, devices|
82
+ attributes = extract_attribute(line: line)
84
83
 
85
- if attributes[:name]
86
- # when detected new line including device name
87
- devices << Device.new # next device
88
- end
84
+ next if attributes == {}
89
85
 
90
- devices.last.assign_attributes(attributes) unless devices.empty?
86
+ if attributes[:name]
87
+ # when detected new line including device name
88
+ devices << Device.new # next device
91
89
  end
90
+
91
+ devices.last.assign_attributes(attributes) unless devices.empty?
92
92
  end
93
+ end
93
94
 
94
- # @param line [String]
95
- # @return [Hash]
96
- def extract_attribute(line:)
97
- if (id = id_from(line))
98
- { id: id }
99
- elsif (name = name_from(line))
100
- { name: name }
101
- elsif (available = available_from(line))
102
- { available: available }
103
- else
104
- {}
105
- end
95
+ # @param line [String]
96
+ # @return [Hash]
97
+ def extract_attribute(line:)
98
+ if (id = id_from(line))
99
+ { id: id }
100
+ elsif (name = name_from(line))
101
+ { name: name }
102
+ elsif (available = available_from(line))
103
+ { available: available }
104
+ else
105
+ {}
106
106
  end
107
+ end
107
108
 
108
- def id_from(line)
109
- line.match('^Kernel:[[:space:]]*') do |m|
110
- m.post_match.match(/event[0-9]+/).to_s
111
- end
109
+ def id_from(line)
110
+ line.match('^Kernel:[[:space:]]*') do |m|
111
+ m.post_match.match(/event[0-9]+/).to_s
112
112
  end
113
+ end
113
114
 
114
- def name_from(line)
115
- line.match('^Device:[[:space:]]*') do |m|
116
- m.post_match.strip
117
- end
115
+ def name_from(line)
116
+ line.match('^Device:[[:space:]]*') do |m|
117
+ m.post_match.strip
118
118
  end
119
+ end
119
120
 
120
- def available_from(line)
121
- # NOTE: is natural scroll available?
122
- if line =~ /^Nat.scrolling: /
123
- return false if line =~ %r{n/a}
121
+ def available_from(line)
122
+ # NOTE: is natural scroll available?
123
+ if line =~ /^Nat.scrolling: /
124
+ return false if line =~ %r{n/a}
124
125
 
125
- return true # disabled / enabled
126
- end
127
- nil
126
+ return true # disabled / enabled
128
127
  end
128
+ nil
129
129
  end
130
130
  end
131
131
  end
@@ -8,6 +8,14 @@ module Fusuma
8
8
  # manage events and generate command
9
9
  class GestureBuffer < Buffer
10
10
  DEFAULT_SOURCE = 'libinput_gesture_parser'
11
+ DEFAULT_SECONDS_TO_KEEP = 0.1
12
+
13
+ def config_param_types
14
+ {
15
+ 'source': [String],
16
+ 'seconds_to_keep': [Float, Integer]
17
+ }
18
+ end
11
19
 
12
20
  # @param event [Event]
13
21
  def buffer(event)
@@ -17,6 +25,8 @@ module Fusuma
17
25
  # - other event buffer
18
26
  return if event&.tag != source
19
27
 
28
+ delete_old_events
29
+
20
30
  @events.push(event)
21
31
  clear unless updating?
22
32
  end
@@ -60,6 +70,16 @@ module Fusuma
60
70
 
61
71
  private
62
72
 
73
+ # Delete old events pushed before 0.1sec
74
+ def delete_old_events
75
+ @seconds_to_keep ||= (config_params(:seconds_to_keep) || DEFAULT_SECONDS_TO_KEEP)
76
+ @events.each do |e|
77
+ break if Time.now - e.time < @seconds_to_keep
78
+
79
+ @events.delete(e)
80
+ end
81
+ end
82
+
63
83
  def updating?
64
84
  return true unless @events.last.record.status =~ /begin|end/
65
85
  end
@@ -38,7 +38,7 @@ module Fusuma
38
38
  @version ||= `#{version_command}`.strip
39
39
  end
40
40
 
41
- # @yield [line] gives a line in libinput list-devices output to the block
41
+ # @yieldparam [String] gives a line in libinput list-devices output to the block
42
42
  def list_devices
43
43
  cmd = list_devices_command
44
44
  MultiLogger.debug(list_devices: cmd)
@@ -47,7 +47,7 @@ module Fusuma
47
47
  end
48
48
  end
49
49
 
50
- # @yield [line] gives a line in libinput debug-events output to the block
50
+ # @yieldparam [String] gives a line in libinput debug-events output to the block
51
51
  def debug_events
52
52
  prefix = 'stdbuf -oL --'
53
53
  options = [*libinput_options]
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Fusuma
4
- VERSION = '1.3.3'
4
+ VERSION = '1.4.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fusuma
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.3
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - iberianpig
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-02-10 00:00:00.000000000 Z
11
+ date: 2020-02-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler