uh-layout 0.2.0.pre → 0.2.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
  SHA1:
3
- metadata.gz: fc164691d2b3d8dc056de7e226bbd5b5bc3ace1d
4
- data.tar.gz: 7165a0026736e62d2dbe3eff8685104db77f7949
3
+ metadata.gz: 3c533d7d89d0e414fbb0e0d38aab099bf212fb12
4
+ data.tar.gz: 8f2519ea364df77eb5dbc4a3fc72fc3d9b3a38a4
5
5
  SHA512:
6
- metadata.gz: 162c88a8afceaa50dc189b20e4c711cd10754d10ede67d5877b7c57e31dd854a3dd28757ed2fa97bacbe04214590742799589603dc36fb0d87c398950bfa4fdc
7
- data.tar.gz: 6b8426fb7d7c09244555b582f1ceed8edeeba0f503a07e8987788d0a2a65a9f4fcf46ad749ae58285b0cbe06d9fc1512e66dff34385cb5fe7f2f3dc5ea92e153
6
+ metadata.gz: f8b643fa3d028bcfdf30d8c9d9bca5093e9851c1755c35a33d79bb4892a1c251b628d16a6263559f0a7adc0c3ecb6eef2a5083dfdf0a6693f0ffde4cb2743e64
7
+ data.tar.gz: 1440d45b69db7599aff55259a0ebe146519a890311df09f97af4d74eae6c8e928f5bb3fe76b788bdfea41152cf4b50f22884835b8794b7e953334963fd1ca1b2
data/lib/uh/layout/bar.rb CHANGED
@@ -10,6 +10,7 @@ module Uh
10
10
 
11
11
  include GeoAccessors
12
12
 
13
+ attr_reader :screen
13
14
  attr_writer :active, :status
14
15
 
15
16
  def initialize(display, screen, colors)
@@ -0,0 +1,19 @@
1
+ module Uh
2
+ class Layout
3
+ module Registrant
4
+ class << self
5
+ def register(layout, display)
6
+ display.screens.each do |screen|
7
+ layout.screens << scr = Screen.new(screen.id, screen.geo)
8
+ layout.widgets << bar = Bar.new(display, scr, layout.colors).show.focus
9
+ bar.on_update do
10
+ bar.active = layout.current_screen? scr
11
+ end
12
+ scr.height = scr.height - bar.height
13
+ end
14
+ layout.update_widgets
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -1,5 +1,5 @@
1
1
  module Uh
2
2
  class Layout
3
- VERSION = '0.2.0.pre'
3
+ VERSION = '0.2.0'
4
4
  end
5
5
  end
data/lib/uh/layout.rb CHANGED
@@ -9,6 +9,7 @@ require 'uh/layout/container'
9
9
  require 'uh/layout/column'
10
10
  require 'uh/layout/dumper'
11
11
  require 'uh/layout/history'
12
+ require 'uh/layout/registrant'
12
13
  require 'uh/layout/screen'
13
14
  require 'uh/layout/tag'
14
15
 
@@ -31,7 +32,7 @@ module Uh
31
32
  def_delegator :current_screen, :current_tag
32
33
  def_delegator :current_tag, :current_column
33
34
 
34
- attr_reader :screens, :widgets, :history
35
+ attr_reader :screens, :widgets, :colors, :history
35
36
 
36
37
  def initialize
37
38
  @screens = Container.new
@@ -41,15 +42,7 @@ module Uh
41
42
  end
42
43
 
43
44
  def register(display)
44
- display.screens.each do |screen|
45
- @screens << scr = Screen.new(screen.id, screen.geo)
46
- @widgets << bar = Bar.new(display, scr, @colors).show.focus
47
- bar.on_update do
48
- bar.active = current_screen? scr
49
- end
50
- scr.height = scr.height - bar.height
51
- end
52
- update_widgets
45
+ Registrant.register self, display
53
46
  end
54
47
 
55
48
  def to_s
@@ -0,0 +1,46 @@
1
+ module Uh
2
+ class Layout
3
+ describe Registrant do
4
+ let(:layout) { Layout.new }
5
+ let(:geo) { build_geo }
6
+ let(:screen) { double 'screen', id: 0, geo: geo, height: geo.height }
7
+ let(:display) { double 'display', screens: [screen] }
8
+ let(:bar) { instance_spy Bar, height: 16 }
9
+
10
+ before do
11
+ allow(Bar).to receive(:new) { bar }
12
+ end
13
+
14
+ describe '#register' do
15
+ it 'registers display screens as layout screens' do
16
+ described_class.register layout, display
17
+ expect(layout.screens[0])
18
+ .to be_a(Screen)
19
+ .and have_attributes(id: 0)
20
+ end
21
+
22
+ it 'builds a new bar widget' do
23
+ expect(Bar)
24
+ .to receive(:new)
25
+ .with display, an_instance_of(Screen), layout.colors
26
+ described_class.register layout, display
27
+ end
28
+
29
+ it 'registers the bar widget' do
30
+ described_class.register layout, display
31
+ expect(layout.widgets[0]).to be bar
32
+ end
33
+
34
+ it 'decreases the layout screens height with the bar height' do
35
+ described_class.register layout, display
36
+ expect(layout.screens[0].height).to eq screen.height - bar.height
37
+ end
38
+
39
+ it 'updates layout widgets' do
40
+ expect(layout).to receive :update_widgets
41
+ described_class.register layout, display
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -12,6 +12,14 @@ module Uh
12
12
  layout.widgets << widget
13
13
  end
14
14
 
15
+ describe '#register' do
16
+ it 'uses a registrant to register the layout with given display' do
17
+ display = double 'display'
18
+ expect(Layout::Registrant).to receive(:register).with layout, display
19
+ layout.register display
20
+ end
21
+ end
22
+
15
23
  describe '#include?' do
16
24
  it 'returns false when layout does not include given client' do
17
25
  expect(layout.include? client).to be false
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uh-layout
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0.pre
4
+ version: 0.2.0
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-04-12 00:00:00.000000000 Z
11
+ date: 2015-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: uh
@@ -75,6 +75,7 @@ files:
75
75
  - lib/uh/layout/container.rb
76
76
  - lib/uh/layout/dumper.rb
77
77
  - lib/uh/layout/history.rb
78
+ - lib/uh/layout/registrant.rb
78
79
  - lib/uh/layout/screen.rb
79
80
  - lib/uh/layout/tag.rb
80
81
  - lib/uh/layout/version.rb
@@ -87,6 +88,7 @@ files:
87
88
  - spec/uh/layout/column_spec.rb
88
89
  - spec/uh/layout/container_spec.rb
89
90
  - spec/uh/layout/history_spec.rb
91
+ - spec/uh/layout/registrant_spec.rb
90
92
  - spec/uh/layout/screen_spec.rb
91
93
  - spec/uh/layout/tag_spec.rb
92
94
  - spec/uh/layout_spec.rb
@@ -105,9 +107,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
105
107
  version: '0'
106
108
  required_rubygems_version: !ruby/object:Gem::Requirement
107
109
  requirements:
108
- - - ">"
110
+ - - ">="
109
111
  - !ruby/object:Gem::Version
110
- version: 1.3.1
112
+ version: '0'
111
113
  requirements: []
112
114
  rubyforge_project:
113
115
  rubygems_version: 2.4.5
@@ -124,6 +126,7 @@ test_files:
124
126
  - spec/uh/layout/column_spec.rb
125
127
  - spec/uh/layout/container_spec.rb
126
128
  - spec/uh/layout/history_spec.rb
129
+ - spec/uh/layout/registrant_spec.rb
127
130
  - spec/uh/layout/screen_spec.rb
128
131
  - spec/uh/layout/tag_spec.rb
129
132
  - spec/uh/layout_spec.rb