uh-layout 0.1.5 → 0.1.6

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
  SHA1:
3
- metadata.gz: edf8a87089f0c32d03e6e00cbc1bc40a93c84011
4
- data.tar.gz: a1d22d1bdb126e9a699e0ca2fe8c343e569ccc32
3
+ metadata.gz: d5eb173000501f534469ab6801bd388d44d309f3
4
+ data.tar.gz: 014263683a19cedca1cb588cbc65d5cfaafb0254
5
5
  SHA512:
6
- metadata.gz: b0cd253e73d437556eea6d053607a4f10d04b7f82d2c9cf13a6d985f44b2f346464de146bdc8f261d26196367ff5411abd725761eca691444bee1482e6c18180
7
- data.tar.gz: f39cab274b9a47ac3a26a71dd736432bab091b3f425b9781f5aaaeceacbb08b490b49ea99c049bc4c3e234a2094ea8ef9d0b98c0a6ebc68220d7159c18537aee
6
+ metadata.gz: 7a188d97b67af33cacf8466fb7216364ec782b74dc1688d1e27a0a08df31989c656e647a395dc03839b012d6412de4208a37f84a8f1095f20567d82e38a7a646
7
+ data.tar.gz: 8003a17f7f10d7a35df2510a9913b104f1ef4295873689d36cc8874926087d5590266588d01fde91fd38d28d5f16418e19f7ad9667192dfc1c9e159336e0a2ca
@@ -16,10 +16,10 @@ module Uh
16
16
 
17
17
  attr_reader :geo, :clients, :mode
18
18
 
19
- def initialize(geo)
19
+ def initialize(geo, mode: :stack)
20
20
  @geo = geo.dup
21
21
  @clients = Container.new
22
- @mode = :stack
22
+ @mode = mode
23
23
  end
24
24
 
25
25
  def to_s
@@ -44,6 +44,14 @@ module Uh
44
44
  MODES[@mode].new @clients, @geo
45
45
  end
46
46
 
47
+ def client_swap(direction)
48
+ @clients.set direction
49
+ if @mode == :tile
50
+ arrange_clients
51
+ show_hide_clients
52
+ end
53
+ end
54
+
47
55
  def arrange_clients
48
56
  arranger.arrange
49
57
  clients.each &:moveresize
@@ -53,6 +53,7 @@ module Uh
53
53
  end
54
54
 
55
55
  def set(direction)
56
+ raise RuntimeError unless @entries.size >= 2
56
57
  new_index = @current_index.send direction
57
58
  if new_index.between? 0, @entries.size - 1
58
59
  swap @current_index, new_index
@@ -1,5 +1,5 @@
1
1
  module Uh
2
2
  class Layout
3
- VERSION = '0.1.5'
3
+ VERSION = '0.1.6'
4
4
  end
5
5
  end
data/lib/uh/layout.rb CHANGED
@@ -130,7 +130,7 @@ module Uh
130
130
 
131
131
  def handle_client_swap(direction)
132
132
  return unless current_client
133
- current_column.clients.set direction
133
+ current_column.client_swap direction
134
134
  update_widgets
135
135
  end
136
136
 
@@ -3,9 +3,10 @@ module Uh
3
3
  describe Column do
4
4
  let(:geo) { build_geo }
5
5
  let(:other_geo) { build_geo 640, 0, 320, 240 }
6
+ let(:mode) { :stack }
6
7
  let(:client) { build_client }
7
8
  let(:other_client) { build_client }
8
- subject(:column) { described_class.new geo }
9
+ subject(:column) { described_class.new geo, mode: mode }
9
10
 
10
11
  it 'has a copy to given geo' do
11
12
  expect(column.geo).to eq(geo).and not_be geo
@@ -71,6 +72,29 @@ module Uh
71
72
  end
72
73
  end
73
74
 
75
+ describe '#client_swap' do
76
+ before { column << client << other_client }
77
+
78
+ it 'sends #set message to clients with given direction' do
79
+ expect(column.clients).to receive(:set).with :pred
80
+ column.client_swap :pred
81
+ end
82
+
83
+ context 'when column mode is tile' do
84
+ let(:mode) { :tile }
85
+
86
+ it 'arranges current column clients' do
87
+ expect(column).to receive :arrange_clients
88
+ column.client_swap :pred
89
+ end
90
+
91
+ it 'shows and hides clients in current column' do
92
+ expect(column).to receive :show_hide_clients
93
+ column.client_swap :pred
94
+ end
95
+ end
96
+ end
97
+
74
98
  describe '#arrange_clients' do
75
99
  before { column << client << other_client }
76
100
 
@@ -173,6 +173,14 @@ module Uh
173
173
  expect { container.set :pred }.not_to change { container.current }
174
174
  end
175
175
  end
176
+
177
+ context 'when entries count is less than 2' do
178
+ let(:entries) { %i[foo] }
179
+
180
+ it 'raises a RuntimeError' do
181
+ expect { container.set :pred }.to raise_error Layout::RuntimeError
182
+ end
183
+ end
176
184
  end
177
185
 
178
186
  describe '#swap' do
@@ -353,15 +353,9 @@ module Uh
353
353
  context 'with one column and two clients' do
354
354
  before { layout << other_client << client }
355
355
 
356
- it 'swaps current client with the other client' do
356
+ it 'sends #client_swap to current column with given direction' do
357
+ expect(layout.current_column).to receive(:client_swap).with :pred
357
358
  layout.handle_client_swap :pred
358
- expect(layout.current_column.clients.to_a)
359
- .to eq [client, other_client]
360
- end
361
-
362
- it 'does not change current client' do
363
- expect { layout.handle_client_swap :pred }
364
- .not_to change { layout.current_client }
365
359
  end
366
360
 
367
361
  it 'updates widgets' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uh-layout
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thibault Jouan