uh-layout 0.1.3 → 0.1.4
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/lib/uh/layout/history.rb +25 -0
- data/lib/uh/layout/version.rb +1 -1
- data/lib/uh/layout.rb +9 -1
- data/spec/uh/layout/history_spec.rb +32 -0
- data/spec/uh/layout_spec.rb +20 -0
- data/uh-layout.gemspec +1 -1
- metadata +9 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8356446f440275b330daab65258ae6401736b0e0
|
4
|
+
data.tar.gz: 4d677edea7b0df77f165c172ed6b920d7ad5083d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7916c175a188b94e57bf96b530ab7ed9172ffb9b5c38d2f637dbf1d0457579fb3a7572ba16ba447d7c614041b2f63dcb2da69089d602a5dd367391bffaff96c1
|
7
|
+
data.tar.gz: 4d15bed975b4d4433d381fdceef276cd6afad3aaf54358871bfa4a2ce397dbc1decab23079458ba34957d49e5ac0bfaf926cd561796cc7e84128a37ee3fe35f4
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Uh
|
2
|
+
class Layout
|
3
|
+
class History
|
4
|
+
TAGS_SIZE_MAX = 8
|
5
|
+
|
6
|
+
attr_reader :tags, :tags_size_max
|
7
|
+
|
8
|
+
def initialize(tags = [], tags_size_max: TAGS_SIZE_MAX)
|
9
|
+
@tags = tags
|
10
|
+
@tags_size_max = tags_size_max
|
11
|
+
end
|
12
|
+
|
13
|
+
def record_tag(tag)
|
14
|
+
@tags << tag
|
15
|
+
if @tags.size > @tags_size_max
|
16
|
+
@tags = @tags.drop @tags.size - @tags_size_max
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def last_tag
|
21
|
+
@tags.last
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/uh/layout/version.rb
CHANGED
data/lib/uh/layout.rb
CHANGED
@@ -8,6 +8,7 @@ require 'uh/layout/client_column_mover'
|
|
8
8
|
require 'uh/layout/container'
|
9
9
|
require 'uh/layout/column'
|
10
10
|
require 'uh/layout/dumper'
|
11
|
+
require 'uh/layout/history'
|
11
12
|
require 'uh/layout/screen'
|
12
13
|
require 'uh/layout/tag'
|
13
14
|
|
@@ -22,11 +23,12 @@ module Uh
|
|
22
23
|
def_delegator :current_screen, :current_tag
|
23
24
|
def_delegator :current_tag, :current_column
|
24
25
|
|
25
|
-
attr_reader :screens, :widgets
|
26
|
+
attr_reader :screens, :widgets, :history
|
26
27
|
|
27
28
|
def initialize
|
28
29
|
@screens = Container.new
|
29
30
|
@widgets = []
|
31
|
+
@history = History.new
|
30
32
|
end
|
31
33
|
|
32
34
|
def to_s
|
@@ -84,7 +86,9 @@ module Uh
|
|
84
86
|
end
|
85
87
|
|
86
88
|
def handle_tag_sel(tag_id)
|
89
|
+
tag_id = tag_id.to_s
|
87
90
|
return unless current_tag.id != tag_id
|
91
|
+
@history.record_tag current_tag
|
88
92
|
current_tag.hide
|
89
93
|
current_screen.tags.current = find_tag_or_create tag_id
|
90
94
|
current_tag.each_column &:show_hide_clients
|
@@ -137,6 +141,10 @@ module Uh
|
|
137
141
|
update_widgets
|
138
142
|
end
|
139
143
|
|
144
|
+
def handle_history_tag_pred
|
145
|
+
handle_tag_sel @history.last_tag.id
|
146
|
+
end
|
147
|
+
|
140
148
|
def handle_kill_current
|
141
149
|
current_client and current_client.kill
|
142
150
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Uh
|
2
|
+
class Layout
|
3
|
+
describe History do
|
4
|
+
subject(:history) { described_class.new }
|
5
|
+
|
6
|
+
it 'has an empty tag history' do
|
7
|
+
expect(history.tags).to be_empty
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '#record_tag' do
|
11
|
+
it 'adds current tag' do
|
12
|
+
history.record_tag :some_tag
|
13
|
+
expect(history.tags).to include :some_tag
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'limits stored tags count to configured tags size' do
|
17
|
+
history.tags_size_max.times { |n| history.record_tag "tag_#{n}" }
|
18
|
+
expect { history.record_tag :one_more }
|
19
|
+
.not_to change { history.tags.size }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#last_tag' do
|
24
|
+
it 'returns last recorded tag' do
|
25
|
+
history.record_tag :tag_1
|
26
|
+
history.record_tag :tag_2
|
27
|
+
expect(history.last_tag).to be :tag_2
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/spec/uh/layout_spec.rb
CHANGED
@@ -195,6 +195,17 @@ module Uh
|
|
195
195
|
expect(widget).to receive :update
|
196
196
|
layout.handle_tag_sel '2'
|
197
197
|
end
|
198
|
+
|
199
|
+
it 'accepts non-string arguments' do
|
200
|
+
layout.handle_tag_sel 2
|
201
|
+
expect(layout.current_tag.id).to eq '2'
|
202
|
+
end
|
203
|
+
|
204
|
+
it 'records previous tag in history' do
|
205
|
+
previous_tag = layout.current_tag
|
206
|
+
layout.handle_tag_sel 2
|
207
|
+
expect(layout.history.tags).to include previous_tag
|
208
|
+
end
|
198
209
|
end
|
199
210
|
|
200
211
|
describe 'handle_tag_set' do
|
@@ -399,6 +410,15 @@ module Uh
|
|
399
410
|
end
|
400
411
|
end
|
401
412
|
|
413
|
+
describe '#handle_history_tag_pred' do
|
414
|
+
it 'selects last tag recorded in history' do
|
415
|
+
layout.handle_tag_sel 2
|
416
|
+
expect { layout.handle_history_tag_pred }
|
417
|
+
.to change { layout.current_tag.id }
|
418
|
+
.from(?2).to ?1
|
419
|
+
end
|
420
|
+
end
|
421
|
+
|
402
422
|
describe '#handle_kill_current' do
|
403
423
|
context 'without client' do
|
404
424
|
it 'does not raise any error' do
|
data/uh-layout.gemspec
CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.executables = s.files.grep(/\Abin\//) { |f| File.basename(f) }
|
16
16
|
|
17
17
|
|
18
|
-
s.add_development_dependency 'uh'
|
18
|
+
s.add_development_dependency 'uh', '~> 1.0'
|
19
19
|
s.add_development_dependency 'rake', '~> 10.4'
|
20
20
|
s.add_development_dependency 'rspec', '~> 3.2'
|
21
21
|
end
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uh-layout
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thibault Jouan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: uh
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
19
|
+
version: '1.0'
|
20
20
|
type: :development
|
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: '0'
|
26
|
+
version: '1.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -73,6 +73,7 @@ files:
|
|
73
73
|
- lib/uh/layout/column.rb
|
74
74
|
- lib/uh/layout/container.rb
|
75
75
|
- lib/uh/layout/dumper.rb
|
76
|
+
- lib/uh/layout/history.rb
|
76
77
|
- lib/uh/layout/screen.rb
|
77
78
|
- lib/uh/layout/tag.rb
|
78
79
|
- lib/uh/layout/version.rb
|
@@ -84,6 +85,7 @@ files:
|
|
84
85
|
- spec/uh/layout/client_column_mover_spec.rb
|
85
86
|
- spec/uh/layout/column_spec.rb
|
86
87
|
- spec/uh/layout/container_spec.rb
|
88
|
+
- spec/uh/layout/history_spec.rb
|
87
89
|
- spec/uh/layout/screen_spec.rb
|
88
90
|
- spec/uh/layout/tag_spec.rb
|
89
91
|
- spec/uh/layout_spec.rb
|
@@ -120,6 +122,7 @@ test_files:
|
|
120
122
|
- spec/uh/layout/client_column_mover_spec.rb
|
121
123
|
- spec/uh/layout/column_spec.rb
|
122
124
|
- spec/uh/layout/container_spec.rb
|
125
|
+
- spec/uh/layout/history_spec.rb
|
123
126
|
- spec/uh/layout/screen_spec.rb
|
124
127
|
- spec/uh/layout/tag_spec.rb
|
125
128
|
- spec/uh/layout_spec.rb
|