vedeu 0.6.67 → 0.6.68
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/docs/api.md +4 -0
- data/examples/dsl_editor.rb +1 -1
- data/lib/vedeu/editor/editor.rb +4 -2
- data/lib/vedeu/events/aliases.rb +3 -1
- data/lib/vedeu/input/mapper.rb +9 -5
- data/lib/vedeu/logging/log.rb +2 -0
- data/lib/vedeu/models/row.rb +1 -1
- data/lib/vedeu/models/views/char.rb +1 -1
- data/lib/vedeu/output/all.rb +1 -0
- data/lib/vedeu/output/compressor.rb +23 -5
- data/lib/vedeu/output/compressor_cache.rb +61 -0
- data/lib/vedeu/version.rb +1 -1
- data/test/lib/vedeu/models/row_test.rb +23 -7
- data/test/lib/vedeu/output/compressor_cache_test.rb +148 -0
- data/vedeu.gemspec +1 -1
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 850ce1133d6018ed381e4ddbb4ee9bdff12e4bbb
|
4
|
+
data.tar.gz: bb06f89c8568103c095e448fab6a2fc3eef3dfb8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2cdb5a8f19a21d62dd57faead71646070464ac3072e3945d08b534a642be3ad52004e53bf8af4614c870cf18f332888595805e280f6863b8a18c36d8f07bc347
|
7
|
+
data.tar.gz: e045c49ba37aaf20676442a648f8e5c84bc99181835c3fd09f00b349aa21dd15926a5a76216cf6618bdf1af4e51dc60ffc3c422ab32cc869cec4281986a30e59
|
data/docs/api.md
CHANGED
data/examples/dsl_editor.rb
CHANGED
data/lib/vedeu/editor/editor.rb
CHANGED
@@ -91,9 +91,11 @@ module Vedeu
|
|
91
91
|
|
92
92
|
# See {file:docs/events/system.md#\_editor_}
|
93
93
|
Vedeu.bind(:_editor_) do |key|
|
94
|
-
Vedeu.
|
94
|
+
Vedeu.timer('Executing editor keypress') do
|
95
|
+
Vedeu.trigger(:key, key)
|
95
96
|
|
96
|
-
|
97
|
+
Vedeu::Editor::Editor.keypress(name: Vedeu.focus, input: key)
|
98
|
+
end
|
97
99
|
end
|
98
100
|
|
99
101
|
# :nocov:
|
data/lib/vedeu/events/aliases.rb
CHANGED
@@ -88,7 +88,9 @@ module Vedeu
|
|
88
88
|
return [] unless registered?(alias_name)
|
89
89
|
|
90
90
|
find(alias_name).map do |event_name|
|
91
|
-
Vedeu.log(type:
|
91
|
+
Vedeu.log(type: :event,
|
92
|
+
message: "Triggering: '#{event_name}' from alias " \
|
93
|
+
"'#{alias_name}'".freeze)
|
92
94
|
Vedeu::Events::Trigger.trigger(event_name, *args)
|
93
95
|
end
|
94
96
|
end
|
data/lib/vedeu/input/mapper.rb
CHANGED
@@ -157,11 +157,13 @@ module Vedeu
|
|
157
157
|
|
158
158
|
# See {file:docs/events/system.md#\_keypress_}
|
159
159
|
Vedeu.bind(:_keypress_) do |key, name|
|
160
|
-
Vedeu.
|
160
|
+
Vedeu.timer('Executing keypress') do
|
161
|
+
Vedeu.trigger(:key, key)
|
161
162
|
|
162
|
-
|
163
|
+
Vedeu.add_keypress(key)
|
163
164
|
|
164
|
-
|
165
|
+
Vedeu.keypress(key, name)
|
166
|
+
end
|
165
167
|
end
|
166
168
|
|
167
169
|
# See {file:docs/events/drb.md#\_drb_input_}
|
@@ -177,9 +179,11 @@ module Vedeu
|
|
177
179
|
|
178
180
|
# See {file:docs/events/system.md#\_command_}
|
179
181
|
Vedeu.bind(:_command_) do |command|
|
180
|
-
Vedeu.
|
182
|
+
Vedeu.timer('Executing command') do
|
183
|
+
Vedeu.add_command(command)
|
181
184
|
|
182
|
-
|
185
|
+
Vedeu.trigger(:command, command)
|
186
|
+
end
|
183
187
|
end
|
184
188
|
|
185
189
|
# :nocov:
|
data/lib/vedeu/logging/log.rb
CHANGED
@@ -196,6 +196,8 @@ module Vedeu
|
|
196
196
|
# @see Vedeu::Logging::Log.log_stdout
|
197
197
|
# @!method log_stderr
|
198
198
|
# @see Vedeu::Logging::Log.log_stderr
|
199
|
+
# @!method log_timestamp
|
200
|
+
# @see Vedeu::Logging::Log.log_timestamp
|
199
201
|
def_delegators Vedeu::Logging::Log,
|
200
202
|
:log,
|
201
203
|
:log_stdout,
|
data/lib/vedeu/models/row.rb
CHANGED
@@ -96,7 +96,7 @@ module Vedeu
|
|
96
96
|
|
97
97
|
# @return [Vedeu::Geometries::Position]
|
98
98
|
def position
|
99
|
-
@position
|
99
|
+
@position ||= Vedeu::Geometries::Position.coerce(@attributes[:position])
|
100
100
|
end
|
101
101
|
|
102
102
|
# Sets the position of the Vedeu::Views::Char.
|
data/lib/vedeu/output/all.rb
CHANGED
@@ -33,10 +33,11 @@ module Vedeu
|
|
33
33
|
end
|
34
34
|
|
35
35
|
# @note
|
36
|
-
# Takes approximately ~
|
36
|
+
# - Takes approximately ~6ms for 2100 chars. (2015-11-25)
|
37
|
+
# - Takes approximately ~25ms for 2100 chars. (2015-07-25)
|
37
38
|
# @return [String]
|
38
39
|
def render
|
39
|
-
return
|
40
|
+
return cached if Vedeu::Configuration.compression?
|
40
41
|
|
41
42
|
uncompress
|
42
43
|
end
|
@@ -60,9 +61,26 @@ module Vedeu
|
|
60
61
|
end
|
61
62
|
end
|
62
63
|
|
64
|
+
def cached
|
65
|
+
cached_original = Vedeu::Output::CompressorCache.read(:original)
|
66
|
+
cached_compressed = Vedeu::Output::CompressorCache.read(:compressed)
|
67
|
+
|
68
|
+
if content.size == cached_original.size && content == cached_original
|
69
|
+
cached_compressed
|
70
|
+
|
71
|
+
else
|
72
|
+
Vedeu::Output::CompressorCache.write(:original, content)
|
73
|
+
Vedeu::Output::CompressorCache.write(:compressed, compress)
|
74
|
+
compress
|
75
|
+
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
63
79
|
# @return [String]
|
64
80
|
def compress
|
65
|
-
|
81
|
+
message = "Compression for #{content.size} objects".freeze
|
82
|
+
|
83
|
+
@compress ||= Vedeu.timer(message) do
|
66
84
|
out = content.map do |cell|
|
67
85
|
[
|
68
86
|
# position_for(cell),
|
@@ -73,9 +91,9 @@ module Vedeu
|
|
73
91
|
].join
|
74
92
|
end.join
|
75
93
|
|
94
|
+
|
76
95
|
Vedeu.log(type: :compress,
|
77
|
-
message: "
|
78
|
-
"#{out.size} characters".freeze)
|
96
|
+
message: "#{message} -> #{out.size} characters".freeze)
|
79
97
|
|
80
98
|
out
|
81
99
|
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module Vedeu
|
2
|
+
|
3
|
+
module Output
|
4
|
+
|
5
|
+
module CompressorCache
|
6
|
+
|
7
|
+
extend self
|
8
|
+
|
9
|
+
# @param key [NilClass|Symbol]
|
10
|
+
# @return [Array<void>]
|
11
|
+
def read(key)
|
12
|
+
storage.fetch(key, [])
|
13
|
+
end
|
14
|
+
|
15
|
+
# @return [Hash<Symbol => Array<void>>]
|
16
|
+
def reset!
|
17
|
+
@storage = in_memory
|
18
|
+
end
|
19
|
+
alias_method :reset, :reset!
|
20
|
+
|
21
|
+
# @return [Hash<Symbol => Array<void>>]
|
22
|
+
def storage
|
23
|
+
@storage ||= in_memory
|
24
|
+
end
|
25
|
+
|
26
|
+
# @param key [NilClass|Symbol]
|
27
|
+
# @param value [Array|NilClass]
|
28
|
+
# @return [Hash<Symbol => Array<void>>]
|
29
|
+
def write(key, value)
|
30
|
+
return storage if invalid_key?(key) || invalid_value?(value)
|
31
|
+
|
32
|
+
storage.merge!(key => value)
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
# @return [Hash<Symbol => Array<void>>]
|
38
|
+
def in_memory
|
39
|
+
{
|
40
|
+
compressed: '',
|
41
|
+
original: [],
|
42
|
+
}
|
43
|
+
end
|
44
|
+
|
45
|
+
# @param key [NilClass|Symbol]
|
46
|
+
# @return [Boolean]
|
47
|
+
def invalid_key?(key)
|
48
|
+
key.nil? || !in_memory.keys.include?(key)
|
49
|
+
end
|
50
|
+
|
51
|
+
# @param value [Array|NilClass]
|
52
|
+
# @return [Boolean]
|
53
|
+
def invalid_value?(value)
|
54
|
+
value.nil? || value.empty?
|
55
|
+
end
|
56
|
+
|
57
|
+
end # CompressorCache
|
58
|
+
|
59
|
+
end # Output
|
60
|
+
|
61
|
+
end # Vedeu
|
data/lib/vedeu/version.rb
CHANGED
@@ -8,7 +8,13 @@ module Vedeu
|
|
8
8
|
|
9
9
|
let(:described) { Vedeu::Models::Row }
|
10
10
|
let(:instance) { described.new(cells) }
|
11
|
-
let(:cells) {
|
11
|
+
let(:cells) {
|
12
|
+
[
|
13
|
+
Vedeu::Views::Char.new(value: 'A'),
|
14
|
+
Vedeu::Models::Cell.new(value: 'B'),
|
15
|
+
Vedeu::Views::Char.new(value: 'C'),
|
16
|
+
]
|
17
|
+
}
|
12
18
|
|
13
19
|
describe '#initialize' do
|
14
20
|
it { instance.must_be_instance_of(described) }
|
@@ -69,9 +75,11 @@ module Vedeu
|
|
69
75
|
|
70
76
|
context 'when the index is not nil' do
|
71
77
|
context 'and the index is in range' do
|
72
|
-
let(:
|
78
|
+
let(:expected) { Vedeu::Views::Char.new(value: 'C') }
|
73
79
|
|
74
|
-
|
80
|
+
let(:index) { 2 }
|
81
|
+
|
82
|
+
it { subject.must_equal(expected) }
|
75
83
|
end
|
76
84
|
|
77
85
|
context 'and the index is out of range' do
|
@@ -88,11 +96,19 @@ module Vedeu
|
|
88
96
|
end
|
89
97
|
end
|
90
98
|
|
91
|
-
|
92
|
-
|
99
|
+
describe '#content' do
|
100
|
+
let(:expected) {
|
101
|
+
[
|
102
|
+
Vedeu::Views::Char.new(value: 'A'),
|
103
|
+
Vedeu::Views::Char.new(value: 'C'),
|
104
|
+
Vedeu::Views::Char.new(value: "\e[0m"),
|
105
|
+
]
|
106
|
+
}
|
107
|
+
|
108
|
+
subject { instance.content }
|
93
109
|
|
94
|
-
|
95
|
-
|
110
|
+
it { subject.must_equal(expected) }
|
111
|
+
end
|
96
112
|
|
97
113
|
describe '#each' do
|
98
114
|
subject { instance.each }
|
@@ -0,0 +1,148 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
module Output
|
6
|
+
|
7
|
+
# class CompressorCacheTestClass
|
8
|
+
# end
|
9
|
+
|
10
|
+
describe CompressorCache do
|
11
|
+
|
12
|
+
let(:described) { Vedeu::Output::CompressorCache }
|
13
|
+
let(:empty) {
|
14
|
+
{
|
15
|
+
compressed: '',
|
16
|
+
original: [],
|
17
|
+
}
|
18
|
+
}
|
19
|
+
|
20
|
+
before { described.reset! }
|
21
|
+
|
22
|
+
describe '#read' do
|
23
|
+
let(:key) {}
|
24
|
+
|
25
|
+
subject { described.read(key) }
|
26
|
+
|
27
|
+
context 'when the key is nil' do
|
28
|
+
it { subject.must_equal([]) }
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'when the key is not :compressed or :original' do
|
32
|
+
let(:key) { :invalid }
|
33
|
+
|
34
|
+
it { subject.must_equal([]) }
|
35
|
+
end
|
36
|
+
|
37
|
+
context 'when the key is :compressed' do
|
38
|
+
let(:key) { :compressed }
|
39
|
+
|
40
|
+
context 'when there is no compressed data stored' do
|
41
|
+
it { subject.must_equal('') }
|
42
|
+
end
|
43
|
+
|
44
|
+
context 'when there is compressed data stored' do
|
45
|
+
before { described.write(:compressed, 'compressed_data') }
|
46
|
+
|
47
|
+
it { subject.must_equal('compressed_data') }
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
context 'when the key is :original' do
|
52
|
+
let(:key) { :original }
|
53
|
+
|
54
|
+
context 'when there is no original data stored' do
|
55
|
+
it { subject.must_equal([]) }
|
56
|
+
end
|
57
|
+
|
58
|
+
context 'when there is original data stored' do
|
59
|
+
before { described.write(:original, [:original_data]) }
|
60
|
+
|
61
|
+
it { subject.must_equal([:original_data]) }
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe '#reset!' do
|
67
|
+
before { described.write(:original, [:original_data]) }
|
68
|
+
|
69
|
+
subject { described.reset! }
|
70
|
+
|
71
|
+
it { described.must_respond_to(:reset) }
|
72
|
+
it { subject.must_equal(empty) }
|
73
|
+
end
|
74
|
+
|
75
|
+
describe '#storage' do
|
76
|
+
subject { described.storage }
|
77
|
+
|
78
|
+
context 'when the storage is empty' do
|
79
|
+
it { subject.must_equal(empty) }
|
80
|
+
end
|
81
|
+
|
82
|
+
context 'when the storage is not empty' do
|
83
|
+
let(:expected) {
|
84
|
+
{
|
85
|
+
compressed: 'compressed_data',
|
86
|
+
original: [:original_data],
|
87
|
+
}
|
88
|
+
}
|
89
|
+
|
90
|
+
before {
|
91
|
+
described.write(:original, [:original_data])
|
92
|
+
described.write(:compressed, 'compressed_data')
|
93
|
+
}
|
94
|
+
|
95
|
+
it { subject.must_equal(expected) }
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
describe '#write' do
|
100
|
+
let(:key) {}
|
101
|
+
let(:_value) {}
|
102
|
+
|
103
|
+
subject { described.write(key, _value) }
|
104
|
+
|
105
|
+
context 'when the key is invalid' do
|
106
|
+
context 'when the key is nil' do
|
107
|
+
it { subject.must_equal(empty) }
|
108
|
+
end
|
109
|
+
|
110
|
+
context 'when the key is invalid' do
|
111
|
+
let(:key) { :invalid }
|
112
|
+
|
113
|
+
it { subject.must_equal(empty) }
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
context 'when the key is valid' do
|
118
|
+
let(:key) { :compressed }
|
119
|
+
|
120
|
+
context 'when the value is nil' do
|
121
|
+
it { subject.must_equal(empty) }
|
122
|
+
end
|
123
|
+
|
124
|
+
context 'when the value is empty' do
|
125
|
+
let(:_value) { [] }
|
126
|
+
|
127
|
+
it { subject.must_equal(empty) }
|
128
|
+
end
|
129
|
+
|
130
|
+
context 'when the value is not nil or empty' do
|
131
|
+
let(:_value) { 'compressed_data' }
|
132
|
+
let(:expected) {
|
133
|
+
{
|
134
|
+
compressed: 'compressed_data',
|
135
|
+
original: [],
|
136
|
+
}
|
137
|
+
}
|
138
|
+
|
139
|
+
it { subject.must_equal(expected) }
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
end # CompressorCache
|
145
|
+
|
146
|
+
end # Output
|
147
|
+
|
148
|
+
end # Vedeu
|
data/vedeu.gemspec
CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.add_development_dependency 'guard-minitest', '2.4.4'
|
25
25
|
spec.add_development_dependency 'guard-rubocop', '1.2.0'
|
26
26
|
spec.add_development_dependency 'minitest', '5.8.3'
|
27
|
-
spec.add_development_dependency 'minitest-reporters', '1.1.
|
27
|
+
spec.add_development_dependency 'minitest-reporters', '1.1.6'
|
28
28
|
spec.add_development_dependency 'mocha', '1.1.0'
|
29
29
|
spec.add_development_dependency 'pry', '0.10.3'
|
30
30
|
spec.add_development_dependency 'rubocop', '0.35.1'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vedeu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.68
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gavin Laking
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: guard
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - '='
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 1.1.
|
75
|
+
version: 1.1.6
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - '='
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 1.1.
|
82
|
+
version: 1.1.6
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: mocha
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -482,6 +482,7 @@ files:
|
|
482
482
|
- lib/vedeu/null/view.rb
|
483
483
|
- lib/vedeu/output/all.rb
|
484
484
|
- lib/vedeu/output/compressor.rb
|
485
|
+
- lib/vedeu/output/compressor_cache.rb
|
485
486
|
- lib/vedeu/output/output.rb
|
486
487
|
- lib/vedeu/output/presentation/all.rb
|
487
488
|
- lib/vedeu/output/presentation/colour.rb
|
@@ -660,6 +661,7 @@ files:
|
|
660
661
|
- test/lib/vedeu/models/views/view_test.rb
|
661
662
|
- test/lib/vedeu/null/generic_test.rb
|
662
663
|
- test/lib/vedeu/null/view_test.rb
|
664
|
+
- test/lib/vedeu/output/compressor_cache_test.rb
|
663
665
|
- test/lib/vedeu/output/compressor_test.rb
|
664
666
|
- test/lib/vedeu/output/output_test.rb
|
665
667
|
- test/lib/vedeu/output/presentation/colour_test.rb
|
@@ -875,6 +877,7 @@ test_files:
|
|
875
877
|
- test/lib/vedeu/models/views/view_test.rb
|
876
878
|
- test/lib/vedeu/null/generic_test.rb
|
877
879
|
- test/lib/vedeu/null/view_test.rb
|
880
|
+
- test/lib/vedeu/output/compressor_cache_test.rb
|
878
881
|
- test/lib/vedeu/output/compressor_test.rb
|
879
882
|
- test/lib/vedeu/output/output_test.rb
|
880
883
|
- test/lib/vedeu/output/presentation/colour_test.rb
|