vedeu 0.6.61 → 0.6.62
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/benchmarks/array_vs_range.rb +1 -1
- data/docs/events/drb.md +2 -2
- data/docs/events/visibility.md +1 -1
- data/lib/vedeu/buffers/all.rb +1 -0
- data/lib/vedeu/buffers/empty.rb +2 -2
- data/lib/vedeu/{terminal/buffer.rb → buffers/terminal.rb} +12 -16
- data/lib/vedeu/cursors/cursor.rb +4 -8
- data/lib/vedeu/cursors/refresh.rb +5 -0
- data/lib/vedeu/editor/all.rb +1 -0
- data/lib/vedeu/editor/collection.rb +26 -0
- data/lib/vedeu/editor/document.rb +0 -8
- data/lib/vedeu/editor/line.rb +17 -47
- data/lib/vedeu/editor/lines.rb +22 -51
- data/lib/vedeu/geometries/geometry.rb +0 -6
- data/lib/vedeu/groups/group.rb +0 -6
- data/lib/vedeu/input/capture.rb +1 -1
- data/lib/vedeu/interfaces/clear.rb +1 -1
- data/lib/vedeu/logging/log.rb +5 -2
- data/lib/vedeu/models/focus.rb +4 -13
- data/lib/vedeu/output/compressor.rb +8 -4
- data/lib/vedeu/output/output.rb +3 -3
- data/lib/vedeu/output/renderers/all.rb +2 -2
- data/lib/vedeu/output/renderers/html.rb +1 -1
- data/lib/vedeu/output/renderers/json.rb +1 -1
- data/lib/vedeu/repositories/all.rb +1 -0
- data/lib/vedeu/repositories/assemblage.rb +57 -0
- data/lib/vedeu/repositories/collection.rb +1 -40
- data/lib/vedeu/repositories/model.rb +17 -0
- data/lib/vedeu/runtime/launcher.rb +5 -8
- data/lib/vedeu/terminal/all.rb +0 -1
- data/lib/vedeu/version.rb +1 -1
- data/test/lib/vedeu/{terminal/buffer_test.rb → buffers/terminal_test.rb} +24 -50
- data/test/lib/vedeu/cursors/cursor_test.rb +0 -6
- data/test/lib/vedeu/editor/collection_test.rb +38 -0
- data/test/lib/vedeu/editor/document_test.rb +0 -16
- data/test/lib/vedeu/editor/line_test.rb +17 -75
- data/test/lib/vedeu/editor/lines_test.rb +21 -88
- data/test/lib/vedeu/geometries/geometry_test.rb +0 -6
- data/test/lib/vedeu/groups/group_test.rb +0 -6
- data/test/lib/vedeu/input/mouse_test.rb +1 -1
- data/test/lib/vedeu/logging/log_test.rb +3 -3
- data/test/lib/vedeu/models/focus_test.rb +62 -56
- data/test/lib/vedeu/output/output_test.rb +2 -2
- data/test/lib/vedeu/output/renderers/html_test.rb +2 -2
- data/test/lib/vedeu/output/renderers/json_test.rb +1 -1
- data/test/lib/vedeu/repositories/assemblage_test.rb +96 -0
- data/test/lib/vedeu/repositories/collection_test.rb +0 -54
- data/test/lib/vedeu/repositories/model_test.rb +15 -0
- data/vedeu.gemspec +1 -1
- metadata +13 -7
| @@ -6,9 +6,9 @@ module Vedeu | |
| 6 6 |  | 
| 7 7 | 
             
                describe Lines do
         | 
| 8 8 |  | 
| 9 | 
            -
                  let(:described) | 
| 10 | 
            -
                  let(:instance) | 
| 11 | 
            -
                  let(: | 
| 9 | 
            +
                  let(:described)  { Vedeu::Editor::Lines }
         | 
| 10 | 
            +
                  let(:instance)   { described.new(collection) }
         | 
| 11 | 
            +
                  let(:collection) {
         | 
| 12 12 | 
             
                    [
         | 
| 13 13 | 
             
                      Vedeu::Editor::Line.new('Some text...'),
         | 
| 14 14 | 
             
                      Vedeu::Editor::Line.new('More text...'),
         | 
| @@ -18,18 +18,19 @@ module Vedeu | |
| 18 18 |  | 
| 19 19 | 
             
                  describe '#initialize' do
         | 
| 20 20 | 
             
                    it { instance.must_be_instance_of(described) }
         | 
| 21 | 
            -
                    it { instance.instance_variable_get('@ | 
| 21 | 
            +
                    it { instance.instance_variable_get('@collection').must_equal(collection) }
         | 
| 22 22 |  | 
| 23 23 | 
             
                    context 'when lines were not given' do
         | 
| 24 | 
            -
                      let(: | 
| 24 | 
            +
                      let(:collection) {}
         | 
| 25 25 |  | 
| 26 | 
            -
                      it { instance.instance_variable_get('@ | 
| 26 | 
            +
                      it { instance.instance_variable_get('@collection').must_equal([]) }
         | 
| 27 27 | 
             
                    end
         | 
| 28 28 | 
             
                  end
         | 
| 29 29 |  | 
| 30 30 | 
             
                  describe 'accessors' do
         | 
| 31 | 
            +
                    it { instance.must_respond_to(:collection) }
         | 
| 32 | 
            +
                    it { instance.must_respond_to(:collection=) }
         | 
| 31 33 | 
             
                    it { instance.must_respond_to(:lines) }
         | 
| 32 | 
            -
                    it { instance.must_respond_to(:lines=) }
         | 
| 33 34 | 
             
                  end
         | 
| 34 35 |  | 
| 35 36 | 
             
                  describe '.coerce' do
         | 
| @@ -40,16 +41,16 @@ module Vedeu | |
| 40 41 | 
             
                    it { subject.must_be_instance_of(described) }
         | 
| 41 42 |  | 
| 42 43 | 
             
                    context 'when the document is already a Vedeu::Editor::Lines object' do
         | 
| 43 | 
            -
                      let(:document) { Vedeu::Editor::Lines.new( | 
| 44 | 
            +
                      let(:document) { Vedeu::Editor::Lines.new(collection) }
         | 
| 44 45 |  | 
| 45 46 | 
             
                      it { subject.must_equal(document) }
         | 
| 46 | 
            -
                      it { subject. | 
| 47 | 
            +
                      it { subject.collection.must_equal(collection) }
         | 
| 47 48 | 
             
                    end
         | 
| 48 49 |  | 
| 49 50 | 
             
                    context 'when the document is an empty Array' do
         | 
| 50 51 | 
             
                      let(:document) { [] }
         | 
| 51 52 |  | 
| 52 | 
            -
                      it { subject. | 
| 53 | 
            +
                      it { subject.collection.must_equal([]) }
         | 
| 53 54 | 
             
                    end
         | 
| 54 55 |  | 
| 55 56 | 
             
                    context 'when the document is an Array' do
         | 
| @@ -68,7 +69,7 @@ module Vedeu | |
| 68 69 | 
             
                        ]
         | 
| 69 70 | 
             
                      }
         | 
| 70 71 |  | 
| 71 | 
            -
                      it { subject. | 
| 72 | 
            +
                      it { subject.collection.must_equal(expected) }
         | 
| 72 73 | 
             
                    end
         | 
| 73 74 |  | 
| 74 75 | 
             
                    context 'when the document is a String' do
         | 
| @@ -86,31 +87,6 @@ module Vedeu | |
| 86 87 | 
             
                    end
         | 
| 87 88 | 
             
                  end
         | 
| 88 89 |  | 
| 89 | 
            -
                  describe '#[]' do
         | 
| 90 | 
            -
                    subject { instance.[](index) }
         | 
| 91 | 
            -
             | 
| 92 | 
            -
                    context 'when index is a Fixnum' do
         | 
| 93 | 
            -
                      let(:index)    { 2 }
         | 
| 94 | 
            -
                      let(:expected) {
         | 
| 95 | 
            -
                        Vedeu::Editor::Line.new('Other text...')
         | 
| 96 | 
            -
                      }
         | 
| 97 | 
            -
             | 
| 98 | 
            -
                      it { subject.must_equal(expected) }
         | 
| 99 | 
            -
                    end
         | 
| 100 | 
            -
             | 
| 101 | 
            -
                    context 'when index is a Range' do
         | 
| 102 | 
            -
                      let(:index)    { (1..2) }
         | 
| 103 | 
            -
                      let(:expected) {
         | 
| 104 | 
            -
                        [
         | 
| 105 | 
            -
                          Vedeu::Editor::Line.new('More text...'),
         | 
| 106 | 
            -
                          Vedeu::Editor::Line.new('Other text...')
         | 
| 107 | 
            -
                        ]
         | 
| 108 | 
            -
                      }
         | 
| 109 | 
            -
             | 
| 110 | 
            -
                      it { subject.must_equal(expected) }
         | 
| 111 | 
            -
                    end
         | 
| 112 | 
            -
                  end
         | 
| 113 | 
            -
             | 
| 114 90 | 
             
                  describe '#delete_character' do
         | 
| 115 91 | 
             
                    let(:x)         { 0 }
         | 
| 116 92 | 
             
                    let(:y)         { 0 }
         | 
| @@ -118,7 +94,7 @@ module Vedeu | |
| 118 94 | 
             
                    subject { instance.delete_character(y, x) }
         | 
| 119 95 |  | 
| 120 96 | 
             
                    context 'when there are no lines' do
         | 
| 121 | 
            -
                      let(: | 
| 97 | 
            +
                      let(:collection) {
         | 
| 122 98 | 
             
                        [
         | 
| 123 99 | 
             
                          Vedeu::Editor::Line.new('')
         | 
| 124 100 | 
             
                        ]
         | 
| @@ -131,7 +107,7 @@ module Vedeu | |
| 131 107 | 
             
                    end
         | 
| 132 108 |  | 
| 133 109 | 
             
                    context 'when there is one line' do
         | 
| 134 | 
            -
                      let(: | 
| 110 | 
            +
                      let(:collection) {
         | 
| 135 111 | 
             
                        [
         | 
| 136 112 | 
             
                          Vedeu::Editor::Line.new('Hydrogen')
         | 
| 137 113 | 
             
                        ]
         | 
| @@ -167,7 +143,7 @@ module Vedeu | |
| 167 143 |  | 
| 168 144 | 
             
                    context 'when there are multiple lines' do
         | 
| 169 145 | 
             
                      let(:y)     { 1 }
         | 
| 170 | 
            -
                      let(: | 
| 146 | 
            +
                      let(:collection) {
         | 
| 171 147 | 
             
                        [
         | 
| 172 148 | 
             
                          Vedeu::Editor::Line.new('Hydrogen'),
         | 
| 173 149 | 
             
                          Vedeu::Editor::Line.new('Helium'),
         | 
| @@ -224,7 +200,7 @@ module Vedeu | |
| 224 200 | 
             
                    it { subject.must_be_instance_of(described) }
         | 
| 225 201 |  | 
| 226 202 | 
             
                    context 'when the lines are empty' do
         | 
| 227 | 
            -
                      let(: | 
| 203 | 
            +
                      let(:collection) { [] }
         | 
| 228 204 |  | 
| 229 205 | 
             
                      it { subject.must_equal(Vedeu::Editor::Lines.new) }
         | 
| 230 206 | 
             
                    end
         | 
| @@ -276,34 +252,6 @@ module Vedeu | |
| 276 252 | 
             
                    end
         | 
| 277 253 | 
             
                  end
         | 
| 278 254 |  | 
| 279 | 
            -
                  describe '#empty?' do
         | 
| 280 | 
            -
                    subject { instance.empty? }
         | 
| 281 | 
            -
             | 
| 282 | 
            -
                    context 'when the line is empty' do
         | 
| 283 | 
            -
                      let(:lines) {}
         | 
| 284 | 
            -
             | 
| 285 | 
            -
                      it { subject.must_equal(true) }
         | 
| 286 | 
            -
                    end
         | 
| 287 | 
            -
             | 
| 288 | 
            -
                    context 'when the line is not empty' do
         | 
| 289 | 
            -
                      it { subject.must_equal(false) }
         | 
| 290 | 
            -
                    end
         | 
| 291 | 
            -
                  end
         | 
| 292 | 
            -
             | 
| 293 | 
            -
                  describe '#eql?' do
         | 
| 294 | 
            -
                    let(:other) { instance }
         | 
| 295 | 
            -
             | 
| 296 | 
            -
                    subject { instance.eql?(other) }
         | 
| 297 | 
            -
             | 
| 298 | 
            -
                    it { subject.must_equal(true) }
         | 
| 299 | 
            -
             | 
| 300 | 
            -
                    context 'when different to other' do
         | 
| 301 | 
            -
                      let(:other) { described.new('Other text...') }
         | 
| 302 | 
            -
             | 
| 303 | 
            -
                      it { subject.must_equal(false) }
         | 
| 304 | 
            -
                    end
         | 
| 305 | 
            -
                  end
         | 
| 306 | 
            -
             | 
| 307 255 | 
             
                  describe '#insert_character' do
         | 
| 308 256 | 
             
                    let(:x)         { 0 }
         | 
| 309 257 | 
             
                    let(:y)         { 0 }
         | 
| @@ -312,7 +260,7 @@ module Vedeu | |
| 312 260 | 
             
                    subject { instance.insert_character(character, y, x) }
         | 
| 313 261 |  | 
| 314 262 | 
             
                    context 'when there are no lines' do
         | 
| 315 | 
            -
                      let(: | 
| 263 | 
            +
                      let(:collection) {
         | 
| 316 264 | 
             
                        [
         | 
| 317 265 | 
             
                          Vedeu::Editor::Line.new('')
         | 
| 318 266 | 
             
                        ]
         | 
| @@ -325,7 +273,7 @@ module Vedeu | |
| 325 273 | 
             
                    end
         | 
| 326 274 |  | 
| 327 275 | 
             
                    context 'when there is one line' do
         | 
| 328 | 
            -
                      let(: | 
| 276 | 
            +
                      let(:collection) {
         | 
| 329 277 | 
             
                        [
         | 
| 330 278 | 
             
                          Vedeu::Editor::Line.new('Hydrogen')
         | 
| 331 279 | 
             
                        ]
         | 
| @@ -361,7 +309,7 @@ module Vedeu | |
| 361 309 |  | 
| 362 310 | 
             
                    context 'when there are multiple lines' do
         | 
| 363 311 | 
             
                      let(:y)     { 1 }
         | 
| 364 | 
            -
                      let(: | 
| 312 | 
            +
                      let(:collection) {
         | 
| 365 313 | 
             
                        [
         | 
| 366 314 | 
             
                          Vedeu::Editor::Line.new('Hydrogen'),
         | 
| 367 315 | 
             
                          Vedeu::Editor::Line.new('Helium'),
         | 
| @@ -460,7 +408,6 @@ module Vedeu | |
| 460 408 |  | 
| 461 409 | 
             
                      it { subject.must_equal(expected) }
         | 
| 462 410 | 
             
                    end
         | 
| 463 | 
            -
             | 
| 464 411 | 
             
                  end
         | 
| 465 412 |  | 
| 466 413 | 
             
                  describe '#line' do
         | 
| @@ -471,7 +418,7 @@ module Vedeu | |
| 471 418 | 
             
                    it { subject.must_be_instance_of(Vedeu::Editor::Line) }
         | 
| 472 419 |  | 
| 473 420 | 
             
                    context 'when there are no lines' do
         | 
| 474 | 
            -
                      let(: | 
| 421 | 
            +
                      let(:collection) {}
         | 
| 475 422 |  | 
| 476 423 | 
             
                      it { subject.must_equal(Vedeu::Editor::Line.new) }
         | 
| 477 424 | 
             
                    end
         | 
| @@ -513,25 +460,11 @@ module Vedeu | |
| 513 460 | 
             
                    end
         | 
| 514 461 | 
             
                  end
         | 
| 515 462 |  | 
| 516 | 
            -
                  describe '#size' do
         | 
| 517 | 
            -
                    subject { instance.size }
         | 
| 518 | 
            -
             | 
| 519 | 
            -
                    context 'when there are no lines' do
         | 
| 520 | 
            -
                      let(:lines) {}
         | 
| 521 | 
            -
             | 
| 522 | 
            -
                      it { subject.must_equal(0) }
         | 
| 523 | 
            -
                    end
         | 
| 524 | 
            -
             | 
| 525 | 
            -
                    context 'when there are lines' do
         | 
| 526 | 
            -
                      it { subject.must_equal(3) }
         | 
| 527 | 
            -
                    end
         | 
| 528 | 
            -
                  end
         | 
| 529 | 
            -
             | 
| 530 463 | 
             
                  describe '#to_s' do
         | 
| 531 464 | 
             
                    subject { instance.to_s }
         | 
| 532 465 |  | 
| 533 466 | 
             
                    context 'when there are no lines' do
         | 
| 534 | 
            -
                      let(: | 
| 467 | 
            +
                      let(:collection) {}
         | 
| 535 468 |  | 
| 536 469 | 
             
                      it { subject.must_equal("") }
         | 
| 537 470 | 
             
                    end
         | 
| @@ -56,7 +56,7 @@ module Vedeu | |
| 56 56 |  | 
| 57 57 | 
             
                      it {
         | 
| 58 58 | 
             
                        Vedeu.expects(:trigger).with(:_mouse_event_, input)
         | 
| 59 | 
            -
                        subject.must_equal("\e[93m[input] | 
| 59 | 
            +
                        subject.must_equal("\e[93m[input]    \e[39m\e[33mVedeu does not " \
         | 
| 60 60 | 
             
                                           "support mouse button '66' yet.\e[39m")
         | 
| 61 61 | 
             
                      }
         | 
| 62 62 | 
             
                    end
         | 
| @@ -19,7 +19,7 @@ module Vedeu | |
| 19 19 | 
             
                    subject { described.log(message: _message, force: force, type: type) }
         | 
| 20 20 |  | 
| 21 21 | 
             
                    it { subject.must_equal(
         | 
| 22 | 
            -
                      "\e[97m[info] | 
| 22 | 
            +
                      "\e[97m[info]     \e[39m\e[37mSome message...\e[39m"
         | 
| 23 23 | 
             
                    ) }
         | 
| 24 24 | 
             
                  end
         | 
| 25 25 |  | 
| @@ -31,7 +31,7 @@ module Vedeu | |
| 31 31 |  | 
| 32 32 | 
             
                    it {
         | 
| 33 33 | 
             
                      capture_io { subject }.must_equal(
         | 
| 34 | 
            -
                        ["\e[96m[create] | 
| 34 | 
            +
                        ["\e[96m[create]   \e[39m\e[36mLogging to stdout...\e[39m\n", ""]
         | 
| 35 35 | 
             
                      )
         | 
| 36 36 | 
             
                    }
         | 
| 37 37 | 
             
                  end
         | 
| @@ -44,7 +44,7 @@ module Vedeu | |
| 44 44 |  | 
| 45 45 | 
             
                    it {
         | 
| 46 46 | 
             
                      capture_io { subject }.must_equal(
         | 
| 47 | 
            -
                        ["", "\e[97m[debug] | 
| 47 | 
            +
                        ["", "\e[97m[debug]    \e[39m\e[37mLogging to stderr...\e[39m\n"]
         | 
| 48 48 | 
             
                      )
         | 
| 49 49 | 
             
                    }
         | 
| 50 50 | 
             
                  end
         | 
| @@ -17,36 +17,36 @@ module Vedeu | |
| 17 17 | 
             
                  before do
         | 
| 18 18 | 
             
                    Vedeu.stubs(:log)
         | 
| 19 19 |  | 
| 20 | 
            -
                     | 
| 20 | 
            +
                    described.reset
         | 
| 21 21 | 
             
                    Vedeu.interfaces.reset
         | 
| 22 22 |  | 
| 23 23 | 
             
                    Vedeu.stubs(:trigger)
         | 
| 24 24 | 
             
                  end
         | 
| 25 25 | 
             
                  after do
         | 
| 26 | 
            -
                     | 
| 26 | 
            +
                    described.reset
         | 
| 27 27 | 
             
                    Vedeu.interfaces.reset
         | 
| 28 28 | 
             
                  end
         | 
| 29 29 |  | 
| 30 30 | 
             
                  describe '#add' do
         | 
| 31 31 | 
             
                    context 'adds an interface to storage' do
         | 
| 32 | 
            -
                      it {  | 
| 32 | 
            +
                      it { described.add('thallium').must_equal(['thallium']) }
         | 
| 33 33 | 
             
                    end
         | 
| 34 34 |  | 
| 35 35 | 
             
                    context 'does not add it again if already exists' do
         | 
| 36 36 | 
             
                      before { Vedeu.interface('thallium') {} }
         | 
| 37 37 |  | 
| 38 38 | 
             
                      it {
         | 
| 39 | 
            -
                         | 
| 40 | 
            -
                         | 
| 39 | 
            +
                        described.add('thallium')
         | 
| 40 | 
            +
                        described.registered.must_equal(['thallium'])
         | 
| 41 41 | 
             
                      }
         | 
| 42 42 | 
             
                    end
         | 
| 43 43 |  | 
| 44 44 | 
             
                    it 'does not add it again if already exists' do
         | 
| 45 | 
            -
                       | 
| 46 | 
            -
                       | 
| 47 | 
            -
                       | 
| 48 | 
            -
                       | 
| 49 | 
            -
                       | 
| 45 | 
            +
                      described.add('thallium')
         | 
| 46 | 
            +
                      described.add('lead')
         | 
| 47 | 
            +
                      described.add('bismuth')
         | 
| 48 | 
            +
                      described.add('bismuth', true)
         | 
| 49 | 
            +
                      described.registered.must_equal(
         | 
| 50 50 | 
             
                        ['bismuth', 'thallium', 'lead']
         | 
| 51 51 | 
             
                      )
         | 
| 52 52 | 
             
                    end
         | 
| @@ -55,9 +55,9 @@ module Vedeu | |
| 55 55 | 
             
                      before { Vedeu.interface('thallium') {} }
         | 
| 56 56 |  | 
| 57 57 | 
             
                      it {
         | 
| 58 | 
            -
                         | 
| 59 | 
            -
                         | 
| 60 | 
            -
                         | 
| 58 | 
            +
                        described.add('thallium')
         | 
| 59 | 
            +
                        described.add('lead', true)
         | 
| 60 | 
            +
                        described.registered.must_equal(['lead', 'thallium'])
         | 
| 61 61 | 
             
                      }
         | 
| 62 62 | 
             
                    end
         | 
| 63 63 |  | 
| @@ -65,31 +65,31 @@ module Vedeu | |
| 65 65 | 
             
                      before { Vedeu.interface('thallium') {} }
         | 
| 66 66 |  | 
| 67 67 | 
             
                      it {
         | 
| 68 | 
            -
                         | 
| 69 | 
            -
                         | 
| 70 | 
            -
                         | 
| 68 | 
            +
                        described.add('thallium')
         | 
| 69 | 
            +
                        described.add('lead')
         | 
| 70 | 
            +
                        described.registered.must_equal(['thallium', 'lead'])
         | 
| 71 71 | 
             
                      }
         | 
| 72 72 | 
             
                    end
         | 
| 73 73 | 
             
                  end
         | 
| 74 74 |  | 
| 75 75 | 
             
                  describe '#by_name' do
         | 
| 76 76 | 
             
                    it 'the named interface is focussed when the method is called' do
         | 
| 77 | 
            -
                       | 
| 78 | 
            -
                       | 
| 79 | 
            -
                       | 
| 80 | 
            -
                       | 
| 77 | 
            +
                      described.add('thallium')
         | 
| 78 | 
            +
                      described.add('lead')
         | 
| 79 | 
            +
                      described.add('bismuth')
         | 
| 80 | 
            +
                      described.by_name('lead').must_equal('lead')
         | 
| 81 81 | 
             
                    end
         | 
| 82 82 |  | 
| 83 83 | 
             
                    it 'raises an exception if the interface does not exist' do
         | 
| 84 | 
            -
                      proc {  | 
| 84 | 
            +
                      proc { described.by_name('not_found') }.
         | 
| 85 85 | 
             
                        must_raise(Vedeu::Error::ModelNotFound)
         | 
| 86 86 | 
             
                    end
         | 
| 87 87 |  | 
| 88 88 | 
             
                    context 'API methods' do
         | 
| 89 89 | 
             
                      it 'the named interface is focussed when the method is called' do
         | 
| 90 | 
            -
                         | 
| 91 | 
            -
                         | 
| 92 | 
            -
                         | 
| 90 | 
            +
                        described.add('thallium')
         | 
| 91 | 
            +
                        described.add('lead')
         | 
| 92 | 
            +
                        described.add('bismuth')
         | 
| 93 93 | 
             
                        Vedeu.focus_by_name('lead').must_equal('lead')
         | 
| 94 94 | 
             
                      end
         | 
| 95 95 |  | 
| @@ -101,14 +101,14 @@ module Vedeu | |
| 101 101 | 
             
                  end
         | 
| 102 102 |  | 
| 103 103 | 
             
                  describe '#current' do
         | 
| 104 | 
            -
                    before {  | 
| 104 | 
            +
                    before { described.reset }
         | 
| 105 105 |  | 
| 106 106 | 
             
                    subject { described.current }
         | 
| 107 107 |  | 
| 108 108 | 
             
                    it 'returns the name of the interface currently in focus' do
         | 
| 109 | 
            -
                       | 
| 110 | 
            -
                       | 
| 111 | 
            -
                       | 
| 109 | 
            +
                      described.add('thallium')
         | 
| 110 | 
            +
                      described.add('lead')
         | 
| 111 | 
            +
                      described.add('bismuth')
         | 
| 112 112 | 
             
                      subject.must_equal('thallium')
         | 
| 113 113 | 
             
                    end
         | 
| 114 114 |  | 
| @@ -118,23 +118,23 @@ module Vedeu | |
| 118 118 |  | 
| 119 119 | 
             
                    context 'API methods' do
         | 
| 120 120 | 
             
                      it 'returns the name of the interface currently in focus' do
         | 
| 121 | 
            -
                         | 
| 122 | 
            -
                         | 
| 123 | 
            -
                         | 
| 121 | 
            +
                        described.add('thallium')
         | 
| 122 | 
            +
                        described.add('lead')
         | 
| 123 | 
            +
                        described.add('bismuth')
         | 
| 124 124 | 
             
                        Vedeu.focus.must_equal('thallium')
         | 
| 125 125 | 
             
                      end
         | 
| 126 126 | 
             
                    end
         | 
| 127 127 | 
             
                  end
         | 
| 128 128 |  | 
| 129 129 | 
             
                  describe '#current?' do
         | 
| 130 | 
            -
                    before {  | 
| 130 | 
            +
                    before { described.stubs(:current).returns('lead') }
         | 
| 131 131 |  | 
| 132 132 | 
             
                    context 'when the interface is currently in focus' do
         | 
| 133 | 
            -
                      it {  | 
| 133 | 
            +
                      it { described.current?('lead').must_equal(true) }
         | 
| 134 134 | 
             
                    end
         | 
| 135 135 |  | 
| 136 136 | 
             
                    context 'when the interface is not currently in focus' do
         | 
| 137 | 
            -
                      it {  | 
| 137 | 
            +
                      it { described.current?('bismuth').must_equal(false) }
         | 
| 138 138 | 
             
                    end
         | 
| 139 139 |  | 
| 140 140 | 
             
                    context 'API methods' do
         | 
| @@ -150,16 +150,16 @@ module Vedeu | |
| 150 150 |  | 
| 151 151 | 
             
                  describe '#next_item' do
         | 
| 152 152 | 
             
                    it 'the next interface is focussed when the method is called' do
         | 
| 153 | 
            -
                       | 
| 154 | 
            -
                       | 
| 155 | 
            -
                       | 
| 156 | 
            -
                       | 
| 153 | 
            +
                      described.add('thallium')
         | 
| 154 | 
            +
                      described.add('lead')
         | 
| 155 | 
            +
                      described.add('bismuth')
         | 
| 156 | 
            +
                      described.next_item.must_equal('lead')
         | 
| 157 157 | 
             
                    end
         | 
| 158 158 |  | 
| 159 159 | 
             
                    context 'returns false if storage is empty' do
         | 
| 160 | 
            -
                      before {  | 
| 160 | 
            +
                      before { described.reset }
         | 
| 161 161 |  | 
| 162 | 
            -
                      it {  | 
| 162 | 
            +
                      it { described.next_item.must_equal(false) }
         | 
| 163 163 | 
             
                    end
         | 
| 164 164 | 
             
                  end
         | 
| 165 165 |  | 
| @@ -172,7 +172,7 @@ module Vedeu | |
| 172 172 | 
             
                    end
         | 
| 173 173 |  | 
| 174 174 | 
             
                    it 'the next visible interface is focussed when the method is called' do
         | 
| 175 | 
            -
                       | 
| 175 | 
            +
                      described.next_visible_item.must_equal('silver')
         | 
| 176 176 | 
             
                    end
         | 
| 177 177 |  | 
| 178 178 | 
             
                    context 'when there are no visible interfaces' do
         | 
| @@ -183,29 +183,29 @@ module Vedeu | |
| 183 183 | 
             
                      }
         | 
| 184 184 |  | 
| 185 185 | 
             
                      it 'puts the first interface defined in focus' do
         | 
| 186 | 
            -
                         | 
| 186 | 
            +
                        described.next_visible_item.must_equal('gold')
         | 
| 187 187 | 
             
                      end
         | 
| 188 188 | 
             
                    end
         | 
| 189 189 |  | 
| 190 190 | 
             
                    context 'when there are no interfaces' do
         | 
| 191 | 
            -
                      before {  | 
| 191 | 
            +
                      before { described.reset }
         | 
| 192 192 |  | 
| 193 | 
            -
                      it {  | 
| 193 | 
            +
                      it { described.next_visible_item.must_equal(false) }
         | 
| 194 194 | 
             
                    end
         | 
| 195 195 | 
             
                  end
         | 
| 196 196 |  | 
| 197 197 | 
             
                  describe '#prev_item' do
         | 
| 198 198 | 
             
                    it 'the previous interface is focussed when the method is called' do
         | 
| 199 | 
            -
                       | 
| 200 | 
            -
                       | 
| 201 | 
            -
                       | 
| 202 | 
            -
                       | 
| 199 | 
            +
                      described.add('thallium')
         | 
| 200 | 
            +
                      described.add('lead')
         | 
| 201 | 
            +
                      described.add('bismuth')
         | 
| 202 | 
            +
                      described.prev_item.must_equal('bismuth')
         | 
| 203 203 | 
             
                    end
         | 
| 204 204 |  | 
| 205 205 | 
             
                    context 'returns false if storage is empty' do
         | 
| 206 | 
            -
                      before {  | 
| 206 | 
            +
                      before { described.reset }
         | 
| 207 207 |  | 
| 208 | 
            -
                      it {  | 
| 208 | 
            +
                      it { described.prev_item.must_equal(false) }
         | 
| 209 209 | 
             
                    end
         | 
| 210 210 | 
             
                  end
         | 
| 211 211 |  | 
| @@ -219,7 +219,7 @@ module Vedeu | |
| 219 219 |  | 
| 220 220 | 
             
                    it 'the previous visible interface is focussed when the method is ' \
         | 
| 221 221 | 
             
                       'called' do
         | 
| 222 | 
            -
                       | 
| 222 | 
            +
                      described.prev_visible_item.must_equal('silver')
         | 
| 223 223 | 
             
                    end
         | 
| 224 224 |  | 
| 225 225 | 
             
                    context 'when there are no visible interfaces' do
         | 
| @@ -230,25 +230,31 @@ module Vedeu | |
| 230 230 | 
             
                      end
         | 
| 231 231 |  | 
| 232 232 | 
             
                      it 'puts the first interface defined in focus' do
         | 
| 233 | 
            -
                         | 
| 233 | 
            +
                        described.prev_visible_item.must_equal('gold')
         | 
| 234 234 | 
             
                      end
         | 
| 235 235 | 
             
                    end
         | 
| 236 236 |  | 
| 237 237 | 
             
                    context 'when there are no interfaces' do
         | 
| 238 | 
            -
                      before {  | 
| 238 | 
            +
                      before { described.reset }
         | 
| 239 239 |  | 
| 240 | 
            -
                      it {  | 
| 240 | 
            +
                      it { described.prev_visible_item.must_equal(false) }
         | 
| 241 241 | 
             
                    end
         | 
| 242 242 | 
             
                  end
         | 
| 243 243 |  | 
| 244 244 | 
             
                  describe '#refresh' do
         | 
| 245 245 | 
             
                    before do
         | 
| 246 | 
            -
                       | 
| 246 | 
            +
                      described.add('thallium')
         | 
| 247 247 | 
             
                      Vedeu.stubs(:trigger).returns([])
         | 
| 248 248 | 
             
                    end
         | 
| 249 249 |  | 
| 250 250 | 
             
                    it 'triggers the event to refresh the interface current in focus' do
         | 
| 251 | 
            -
                       | 
| 251 | 
            +
                      described.refresh.must_equal([])
         | 
| 252 | 
            +
                    end
         | 
| 253 | 
            +
                  end
         | 
| 254 | 
            +
             | 
| 255 | 
            +
                  describe '#storage' do
         | 
| 256 | 
            +
                    context 'when the storage is empty' do
         | 
| 257 | 
            +
                      it { described.storage.must_equal([]) }
         | 
| 252 258 | 
             
                    end
         | 
| 253 259 | 
             
                  end
         | 
| 254 260 |  | 
| @@ -27,7 +27,7 @@ module Vedeu | |
| 27 27 | 
             
                      let(:output) { Vedeu::Models::Page.new }
         | 
| 28 28 |  | 
| 29 29 | 
             
                      it {
         | 
| 30 | 
            -
                        Vedeu::Terminal | 
| 30 | 
            +
                        Vedeu::Buffers::Terminal.expects(:write).with(output)
         | 
| 31 31 | 
             
                        subject
         | 
| 32 32 | 
             
                      }
         | 
| 33 33 | 
             
                    end
         | 
| @@ -75,7 +75,7 @@ module Vedeu | |
| 75 75 | 
             
                        let(:output) { Vedeu::Models::Page.new }
         | 
| 76 76 |  | 
| 77 77 | 
             
                        it {
         | 
| 78 | 
            -
                          Vedeu::Terminal | 
| 78 | 
            +
                          Vedeu::Buffers::Terminal.expects(:write).with(output)
         | 
| 79 79 | 
             
                          subject
         | 
| 80 80 | 
             
                        }
         | 
| 81 81 | 
             
                      end
         | 
| @@ -32,13 +32,13 @@ module Vedeu | |
| 32 32 | 
             
                  }
         | 
| 33 33 | 
             
                  let(:timestamp)     { false }
         | 
| 34 34 | 
             
                  let(:write_file)    { false }
         | 
| 35 | 
            -
                  let(:buffer)        { Vedeu::Terminal | 
| 35 | 
            +
                  let(:buffer)        { Vedeu::Buffers::Terminal }
         | 
| 36 36 |  | 
| 37 37 | 
             
                  before do
         | 
| 38 38 | 
             
                    ::File.stubs(:write)
         | 
| 39 39 | 
             
                    Vedeu.stubs(:height).returns(2)
         | 
| 40 40 | 
             
                    Vedeu.stubs(:width).returns(4)
         | 
| 41 | 
            -
                    Vedeu::Terminal | 
| 41 | 
            +
                    Vedeu::Buffers::Terminal.reset!
         | 
| 42 42 | 
             
                  end
         | 
| 43 43 |  | 
| 44 44 | 
             
                  describe '#initialize' do
         |