vedeu 0.0.16 → 0.0.17

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a2f4d3d8682b701ed87f0984fefae3f3a4e62e7a
4
- data.tar.gz: d1dbc4ba626a7f719ba6789905f51688fbdb1ba5
3
+ metadata.gz: 466d28a16f573a911f2e5c83cfd109dcb261399e
4
+ data.tar.gz: 701bcb2687c4b2d80562c8be9e44e3c3e1c16088
5
5
  SHA512:
6
- metadata.gz: 8ec2bfeee749b873c1a768cabe45574aa98378a67402959dd0189aa0b181cebae81d8dadeb32a0f40d32a7c736880565c553b6ed78b9fd8d751d0ccd776ef927
7
- data.tar.gz: 13fc99fc61a854fd5923034e663868da7070ffa54c3b6eabb784c42daba9eecf306a6c39a11c7f8662134d2bd5e62d9a22026eaf99fe9961366ee4925d46544c
6
+ metadata.gz: a38d99aa14a7b147c493571f01b0c699f122d50cc94b2e1cacb365a0159109f4688ca2b200ed349d89b74edac751e043b7e5a3b195cbd0961fd457c0ba541acc
7
+ data.tar.gz: 6592f6616ddaa92c8e004bfab81a77e673838a69e1614244f868d93c26e890685adf265c27cf7b5e2f4d14fb1cc512b697181a10d45977d513363fb5627871d0
data/README.md CHANGED
@@ -33,56 +33,60 @@ TODO: Write detailed documentation
33
33
  | |
34
34
  | |-- Output
35
35
  | |-- Compositor
36
- | |-- Queue
36
+ | |
37
+ | |-- Directive
38
+ | | |-- Colour
39
+ | | | |-- Background < Base
40
+ | | | |-- Foreground < Base
41
+ | | |
42
+ | | |-- Position
43
+ | | | |-- Esc
44
+ | | |
45
+ | | |-- Style
46
+ | | | |-- Cursor
47
+ | | | |-- Esc
48
+ | | |
49
+ | | |-- Wordwrap
50
+ | |
51
+ | |-- InterfaceRepository
52
+ | |-- Position
53
+ | | |-- Esc
54
+ | |
55
+ | |-- Renderer
56
+ | |-- Terminal
57
+ | |-- Queue
37
58
  |
38
59
  |-- InterfaceRepository
39
60
  |-- Terminal
40
61
 
41
62
  Base
42
- |-- Translator
43
63
  |-- Esc
64
+ |-- Translator
65
+
66
+ Command
67
+ |-- CommandRepository
68
+
69
+ Exit
44
70
 
45
71
  Interface
46
- |-- Commands
47
- | |-- Command
48
- | | |-- CommandRepository
49
- | |
50
- | |-- Exit
51
- |
52
- |-- Compositor
53
- | |-- Directive
54
- | | |-- Colour
55
- | | | |-- Foreground < Base
56
- | | | |-- Background < Base
57
- | | |
58
- | | |-- Position
59
- | | | |-- Esc
60
- | | |
61
- | | |-- Style
62
- | | |-- Esc
63
- | |
64
- | |-- InterfaceRepository
65
- | |-- Position
66
- | | |-- Esc
67
- | |
68
- | |-- Renderer
69
- | |-- Terminal
72
+ |-- Colour
73
+ | |-- Background < Base
74
+ | |-- Foreground < Base
70
75
  |
71
76
  |-- Geometry
72
77
  | |-- Terminal
73
78
  |
74
- |-- Input
75
79
  |-- InterfaceRepository
76
- |-- Position
77
- |-- Terminal
80
+
81
+ Repository
82
+ |-- Storage
78
83
 
79
84
  Terminal
85
+ |-- Cursor
80
86
  |-- Esc
81
87
  |-- Position
82
88
  |-- Esc
83
89
 
84
- Wordwrap
85
-
86
90
  ### On Interfaces
87
91
 
88
92
  When we create the interface we define it's width, height, and origin (y, x).
@@ -108,7 +112,7 @@ Diagrams were produced using the Railroad Diagram Generator at `http://bottlecap
108
112
  include Vedeu
109
113
 
110
114
  interface 'status', { y: 1, x: 1, width: :auto, height: 1 }
111
- interface 'main', { y: 2, x: 1, width: :auto, height: :auto }
115
+ interface 'main', { y: 2, x: 1, width: :auto, height: :auto, fg: :red, bg: :black }
112
116
 
113
117
  command 'exit', Vedeu::Exit.dispatch, { keyword: "exit", keypress: "q" }
114
118
  command 'help', MyApp.help, { keyword: "help", keypress: "h" }
@@ -117,7 +121,11 @@ Diagrams were produced using the Railroad Diagram Generator at `http://bottlecap
117
121
  ## Contributing
118
122
 
119
123
  1. Fork it ( http://github.com/<my-github-username>/vedeu/fork )
120
- 2. Create your feature branch (`git checkout -b my-new-feature`)
121
- 3. Commit your changes (`git commit -am 'Add some feature'`)
122
- 4. Push to the branch (`git push origin my-new-feature`)
123
- 5. Create new Pull Request
124
+ 2. Clone it
125
+ 3. `bundle`
126
+ 4. `rake` or `bundle exec guard`
127
+ 5. Create your feature branch (`git checkout -b my-new-feature`)
128
+ 6. Write some tests, write some code, have some fun
129
+ 7. Commit your changes (`git commit -am 'Add some feature'`)
130
+ 8. Push to the branch (`git push origin my-new-feature`)
131
+ 9. Create new Pull Request
data/lib/vedeu.rb CHANGED
@@ -6,7 +6,9 @@ require_relative 'vedeu/support/terminal'
6
6
 
7
7
  require_relative 'vedeu/output/base'
8
8
  require_relative 'vedeu/output/background'
9
+ require_relative 'vedeu/output/buffer'
9
10
  require_relative 'vedeu/output/compositor'
11
+ require_relative 'vedeu/output/cursor'
10
12
  require_relative 'vedeu/output/directive'
11
13
  require_relative 'vedeu/output/foreground'
12
14
  require_relative 'vedeu/output/geometry'
@@ -3,7 +3,7 @@ module Vedeu
3
3
  private
4
4
 
5
5
  def prefix
6
- '48;5;'
6
+ named? ? '48;2;' : '48;5;'
7
7
  end
8
8
 
9
9
  def codes
@@ -0,0 +1,96 @@
1
+ module Vedeu
2
+ class OutOfRangeError < StandardError; end
3
+
4
+ class Buffer
5
+ include Enumerable
6
+
7
+ attr_accessor :buffer
8
+
9
+ def initialize(options = {})
10
+ @options = options
11
+ @buffer = Array.new(height) { Array.new(width) { :cell } }
12
+ end
13
+
14
+ def to_s
15
+ each { |row| puts row.inspect }
16
+ nil
17
+ end
18
+
19
+ def each(&block)
20
+ buffer.each(&block)
21
+ end
22
+
23
+ def cell(y, x)
24
+ raise OutOfRangeError if invalid_reference?(y, x)
25
+ buffer[y][x]
26
+ end
27
+
28
+ def set_cell(y, x, v = '')
29
+ raise OutOfRangeError if invalid_reference?(y, x)
30
+ buffer[y][x] = v
31
+ end
32
+
33
+ def set_row(y = 0, v = '')
34
+ if v.is_a?(String)
35
+ v.chars.each_with_index { |c, i| set_cell(y, i, c) }
36
+ else
37
+ v.each_with_index { |el, i| set_cell(y, i, el) }
38
+ end
39
+ row(y)
40
+ end
41
+
42
+ def row(y = 0)
43
+ buffer[y]
44
+ end
45
+ alias_method :y, :row
46
+
47
+ def set_column(x = 0, v = '')
48
+ if v.is_a?(String)
49
+ v.chars.each_with_index { |c, i| set_cell(i, x, c) }
50
+ else
51
+ v.each_with_index { |el, i| set_cell(i, x, el) }
52
+ end
53
+ column(x)
54
+ end
55
+
56
+ def column(x = 0)
57
+ buffer.inject([]) { |a, e| a << e[x] }
58
+ end
59
+ alias_method :x, :column
60
+
61
+ private
62
+
63
+ def invalid_reference?(y, x)
64
+ invalid_line?(y) || invalid_column?(x)
65
+ end
66
+
67
+ def invalid_line?(y)
68
+ y < 0 || y > (height - 1)
69
+ end
70
+
71
+ def invalid_column?(x)
72
+ x < 0 || x > (width - 1)
73
+ end
74
+
75
+ def width
76
+ options.fetch(:width)
77
+ end
78
+ alias_method :columns, :width
79
+
80
+ def height
81
+ options.fetch(:height)
82
+ end
83
+ alias_method :lines, :height
84
+
85
+ def options
86
+ defaults.merge!(@options)
87
+ end
88
+
89
+ def defaults
90
+ {
91
+ width: Terminal.width,
92
+ height: Terminal.height
93
+ }
94
+ end
95
+ end
96
+ end
@@ -47,6 +47,7 @@ module Vedeu
47
47
  end
48
48
 
49
49
  container << colour.reset
50
+ container << cursor
50
51
 
51
52
  container
52
53
  end
@@ -75,6 +76,10 @@ module Vedeu
75
76
  interface.colour
76
77
  end
77
78
 
79
+ def cursor
80
+ interface.cursor
81
+ end
82
+
78
83
  def output
79
84
  return @output.split if @output.is_a?(String)
80
85
  @output
@@ -0,0 +1,57 @@
1
+ module Vedeu
2
+ class Cursor
3
+ class << self
4
+ def show
5
+ [esc, '?25h'].join
6
+ end
7
+
8
+ def hide
9
+ [esc, '?25l'].join
10
+ end
11
+
12
+ def home
13
+ [esc, 'H'].join
14
+ end
15
+
16
+ def up(count = 1)
17
+ [esc, "#{count || 1}", 'A'].join
18
+ end
19
+
20
+ def down(count = 1)
21
+ [esc, "#{count || 1}", 'B'].join
22
+ end
23
+
24
+ def right(count = 1)
25
+ [esc, "#{count || 1}", 'C'].join
26
+ end
27
+ alias_method :forward, :right
28
+
29
+ def left(count = 1)
30
+ [esc, "#{count || 1}", 'D'].join
31
+ end
32
+ alias_method :backward, :left
33
+
34
+ def save
35
+ [esc, 's'].join
36
+ end
37
+
38
+ def unsave
39
+ [esc, 'u'].join
40
+ end
41
+ alias_method :restore, :unsave
42
+
43
+ def save_all
44
+ [esc, '7'].join
45
+ end
46
+
47
+ def unsave_all
48
+ [esc, '8'].join
49
+ end
50
+ alias_method :restore_all, :unsave_all
51
+
52
+ def esc
53
+ [27.chr, '['].join
54
+ end
55
+ end
56
+ end
57
+ end
@@ -1,32 +1,39 @@
1
1
  module Vedeu
2
2
  class Esc
3
3
  class << self
4
+ def blink
5
+ [esc, '5m'].join
6
+ end
7
+
4
8
  def bold
5
9
  [esc, '1m'].join
6
10
  end
11
+ alias_method :bright, :bold
7
12
 
8
13
  def clear
9
14
  [esc, '2J'].join
10
15
  end
11
16
 
12
- def esc
13
- [27.chr, '['].join
17
+ def clear_line
18
+ [esc, '2K'].join
14
19
  end
15
20
 
16
- def hide_cursor
17
- [esc, '?25l'].join
21
+ def esc
22
+ [27.chr, '['].join
18
23
  end
19
24
 
20
25
  def inverse
21
26
  [esc, '7m'].join
22
27
  end
28
+ alias_method :reverse, :inverse
23
29
 
24
- def reset
25
- [esc, '0m'].join
30
+ def normal
31
+ [esc, '2m'].join
26
32
  end
33
+ alias_method :dim, :normal
27
34
 
28
- def show_cursor
29
- [esc, '?25h'].join
35
+ def reset
36
+ [esc, '0m'].join
30
37
  end
31
38
 
32
39
  def underline
@@ -3,7 +3,7 @@ module Vedeu
3
3
  private
4
4
 
5
5
  def prefix
6
- '38;5;'
6
+ named? ? '38;2;' : '38;5;'
7
7
  end
8
8
 
9
9
  def codes
@@ -14,11 +14,11 @@ module Vedeu
14
14
  case style
15
15
  when :bold then Esc.bold
16
16
  when :clear then Esc.clear
17
- when :hide_cursor then Esc.hide_cursor
17
+ when :hide_cursor then Cursor.hide
18
18
  when :inverse then Esc.inverse
19
19
  when :reset then Esc.reset
20
20
  when :normal then Esc.reset
21
- when :show_cursor then Esc.show_cursor
21
+ when :show_cursor then Cursor.show
22
22
  when :underline then Esc.underline
23
23
  else
24
24
  ''
@@ -13,6 +13,7 @@ module Vedeu
13
13
 
14
14
  @active = false
15
15
  @name = attributes[:name]
16
+ @cursor = attributes.fetch(:cursor, true)
16
17
  end
17
18
 
18
19
  def create
@@ -27,6 +28,9 @@ module Vedeu
27
28
  Compositor.arrange([Array.new(geometry.height) { '' }], name)
28
29
  end
29
30
 
31
+ def update
32
+ end
33
+
30
34
  def geometry
31
35
  @geometry ||= Geometry.new(attributes)
32
36
  end
@@ -35,6 +39,10 @@ module Vedeu
35
39
  @colour ||= Colour.new([foreground, background])
36
40
  end
37
41
 
42
+ def cursor
43
+ @cursor ? Cursor.show : Cursor.hide
44
+ end
45
+
38
46
  private
39
47
 
40
48
  def foreground
@@ -31,6 +31,10 @@ module Vedeu
31
31
  all.map { |interface| interface.initial_state }
32
32
  end
33
33
 
34
+ def update
35
+ all.map { |interface| interface.update }
36
+ end
37
+
34
38
  def klass
35
39
  Interface
36
40
  end
@@ -65,11 +65,11 @@ module Vedeu
65
65
  end
66
66
 
67
67
  def show_cursor
68
- output(Esc.show_cursor)
68
+ output(Cursor.show)
69
69
  end
70
70
 
71
71
  def hide_cursor
72
- output(Esc.hide_cursor)
72
+ output(Cursor.hide)
73
73
  end
74
74
 
75
75
  def reset_colours
data/lib/vedeu/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Vedeu
2
- VERSION = "0.0.16"
2
+ VERSION = "0.0.17"
3
3
  end
@@ -35,7 +35,7 @@ module Vedeu
35
35
  end
36
36
 
37
37
  it 'returns an escape sequence' do
38
- subject.must_equal("\e[48;5;41m")
38
+ subject.must_equal("\e[48;2;41m")
39
39
  end
40
40
  end
41
41
 
@@ -59,7 +59,7 @@ module Vedeu
59
59
  end
60
60
 
61
61
  it 'returns an escape sequence' do
62
- subject.must_equal("\e[48;5;49m")
62
+ subject.must_equal("\e[48;2;49m")
63
63
  end
64
64
  end
65
65
  end
@@ -0,0 +1,167 @@
1
+ require_relative '../../../test_helper'
2
+
3
+ module Vedeu
4
+ describe Buffer do
5
+ let(:described_class) { Buffer }
6
+ let(:described_instance) { described_class.new(options) }
7
+ let(:options) { { width: 4, height: 3 } }
8
+ let(:subject) { described_instance }
9
+
10
+ it 'returns a Buffer instance' do
11
+ subject.must_be_instance_of(Buffer)
12
+ end
13
+
14
+ it 'sets an instance variable' do
15
+ subject.instance_variable_get("@options").must_equal(options)
16
+ end
17
+
18
+ describe '#to_s' do
19
+ let(:subject) { capture_io { described_instance.to_s }.join }
20
+
21
+ # real method should return NilClass; want to capture io rather
22
+ # than have it spew into minitest output in terminal; see test
23
+ # below.
24
+ # it { subject.must_be_instance_of(NilClass) }
25
+
26
+ it "outputs the content of the buffer" do
27
+ subject.must_equal("[:cell, :cell, :cell, :cell]\n" \
28
+ "[:cell, :cell, :cell, :cell]\n" \
29
+ "[:cell, :cell, :cell, :cell]\n")
30
+ end
31
+ end
32
+
33
+ describe '#each' do
34
+ let(:subject) { described_instance.each }
35
+
36
+ it 'returns an Enumerator' do
37
+ subject.must_be_instance_of(Enumerator)
38
+ end
39
+ end
40
+
41
+ describe '#cell' do
42
+ let(:subject) { described_instance.cell(y, x) }
43
+ let(:y) { 1 }
44
+ let(:x) { 2 }
45
+
46
+ it 'returns a Symbol' do
47
+ subject.must_be_instance_of(Symbol)
48
+ end
49
+
50
+ context 'when the reference is in range' do
51
+ it 'returns the value at that location' do
52
+ subject.must_equal(:cell)
53
+ end
54
+ end
55
+
56
+ context 'when the reference is out of range' do
57
+ let(:y) { 4 }
58
+
59
+ it 'raises an exception' do
60
+ proc { subject }.must_raise(OutOfRangeError)
61
+ end
62
+ end
63
+ end
64
+
65
+ describe '#set_cell' do
66
+ let(:subject) { described_instance.set_cell(y, x, v) }
67
+ let(:y) { 1 }
68
+ let(:x) { 2 }
69
+ let(:v) { '*' }
70
+
71
+ it 'returns a String' do
72
+ subject.must_be_instance_of(String)
73
+ end
74
+
75
+ context 'when the reference is in range' do
76
+ it 'returns the value at that location' do
77
+ subject.must_equal('*')
78
+ end
79
+ end
80
+
81
+ context 'when the reference is out of range' do
82
+ let(:y) { 3 }
83
+ let(:x) { 4 }
84
+
85
+ it 'raises an exception' do
86
+ proc { subject }.must_raise(OutOfRangeError)
87
+ end
88
+ end
89
+ end
90
+
91
+ describe '#set_row' do
92
+ let(:subject) { described_instance.set_row(y, v) }
93
+ let(:y) { 1 }
94
+ let(:v) { '****' }
95
+
96
+ it 'returns an Array' do
97
+ subject.must_be_instance_of(Array)
98
+ end
99
+
100
+ context 'when the value is a String' do
101
+ let(:v) { '****' }
102
+
103
+ it 'sets the row' do
104
+ subject.must_equal(['*', '*', '*', '*'])
105
+ end
106
+ end
107
+
108
+ context 'when the value is an Array' do
109
+ let(:v) { ['*','*','*','*'] }
110
+
111
+ it 'sets the row' do
112
+ subject.must_equal(['*', '*', '*', '*'])
113
+ end
114
+ end
115
+ end
116
+
117
+ describe '#row' do
118
+ let(:subject) { described_instance.row }
119
+
120
+ it 'returns an Array' do
121
+ subject.must_be_instance_of(Array)
122
+ end
123
+
124
+ it 'returns the content of the row at position y' do
125
+ subject.must_equal([:cell, :cell, :cell, :cell])
126
+ end
127
+ end
128
+
129
+ describe '#set_column' do
130
+ let(:subject) { described_instance.set_column(x, v) }
131
+ let(:x) { 2 }
132
+ let(:v) { '***' }
133
+
134
+ it 'returns an Array' do
135
+ subject.must_be_instance_of(Array)
136
+ end
137
+
138
+ context 'when the value is a String' do
139
+ let(:v) { '***' }
140
+
141
+ it 'sets the row' do
142
+ subject.must_equal(['*', '*', '*'])
143
+ end
144
+ end
145
+
146
+ context 'when the value is an Array' do
147
+ let(:v) { ['*', '*', '*'] }
148
+
149
+ it 'sets the row' do
150
+ subject.must_equal(['*', '*', '*'])
151
+ end
152
+ end
153
+ end
154
+
155
+ describe '#column' do
156
+ let(:subject) { described_instance.column }
157
+
158
+ it 'returns an Array' do
159
+ subject.must_be_instance_of(Array)
160
+ end
161
+
162
+ it 'returns the content of the column at position x' do
163
+ subject.must_equal([:cell, :cell, :cell])
164
+ end
165
+ end
166
+ end
167
+ end
@@ -27,7 +27,7 @@ module Vedeu
27
27
  let(:pair) { [:red, :yellow] }
28
28
 
29
29
  it 'returns the code for red on yellow' do
30
- subject.must_equal("\e[38;5;31m\e[48;5;43m")
30
+ subject.must_equal("\e[38;2;31m\e[48;2;43m")
31
31
  end
32
32
  end
33
33
 
@@ -35,7 +35,7 @@ module Vedeu
35
35
  let(:pair) { [:blue] }
36
36
 
37
37
  it 'returns the code for blue on default' do
38
- subject.must_equal("\e[38;5;34m\e[48;5;49m")
38
+ subject.must_equal("\e[38;2;34m\e[48;5;49m")
39
39
  end
40
40
  end
41
41
 
@@ -43,7 +43,7 @@ module Vedeu
43
43
  let(:pair) { [nil, :cyan] }
44
44
 
45
45
  it 'returns the code for default with cyan background' do
46
- subject.must_equal("\e[38;5;39m\e[48;5;46m")
46
+ subject.must_equal("\e[38;5;39m\e[48;2;46m")
47
47
  end
48
48
  end
49
49
 
@@ -51,7 +51,7 @@ module Vedeu
51
51
  let(:pair) { [:melon, :raspberry] }
52
52
 
53
53
  it 'returns the default code' do
54
- subject.must_equal("\e[38;5;39m\e[48;5;49m")
54
+ subject.must_equal("\e[38;2;39m\e[48;2;49m")
55
55
  end
56
56
  end
57
57
 
@@ -81,7 +81,7 @@ module Vedeu
81
81
  end
82
82
 
83
83
  it 'returns an escape sequence' do
84
- subject.must_equal("\e[38;5;39m\e[48;5;49m")
84
+ subject.must_equal("\e[38;2;39m\e[48;2;49m")
85
85
  end
86
86
  end
87
87
 
@@ -0,0 +1,187 @@
1
+ require_relative '../../../test_helper'
2
+
3
+ module Vedeu
4
+ describe Cursor do
5
+ let(:described_class) { Cursor }
6
+
7
+ describe '.hide' do
8
+ let(:subject) { described_class.hide }
9
+
10
+ it 'returns a String' do
11
+ subject.must_be_instance_of(String)
12
+ end
13
+
14
+ it 'returns an escape sequence' do
15
+ subject.must_equal("\e[?25l")
16
+ end
17
+ end
18
+
19
+ describe '.show' do
20
+ let(:subject) { described_class.show }
21
+
22
+ it 'returns a String' do
23
+ subject.must_be_instance_of(String)
24
+ end
25
+
26
+ it 'returns an escape sequence' do
27
+ subject.must_equal("\e[?25h")
28
+ end
29
+ end
30
+
31
+ describe '.home' do
32
+ let(:subject) { described_class.home }
33
+
34
+ it 'returns a String' do
35
+ subject.must_be_instance_of(String)
36
+ end
37
+
38
+ it 'returns an escape sequence' do
39
+ subject.must_equal("\e[H")
40
+ end
41
+ end
42
+
43
+ describe '.up' do
44
+ let(:subject) { described_class.up(count) }
45
+ let(:count) {}
46
+
47
+ it 'returns a String' do
48
+ subject.must_be_instance_of(String)
49
+ end
50
+
51
+ it 'returns an escape sequence' do
52
+ subject.must_equal("\e[1A")
53
+ end
54
+
55
+ context 'with a count' do
56
+ let(:count) { 3 }
57
+
58
+ it 'returns an escape sequence' do
59
+ subject.must_equal("\e[3A")
60
+ end
61
+ end
62
+ end
63
+
64
+ describe '.down' do
65
+ let(:subject) { described_class.down(count) }
66
+ let(:count) {}
67
+
68
+ it 'returns a String' do
69
+ subject.must_be_instance_of(String)
70
+ end
71
+
72
+ it 'returns an escape sequence' do
73
+ subject.must_equal("\e[1B")
74
+ end
75
+
76
+ context 'with a count' do
77
+ let(:count) { 3 }
78
+
79
+ it 'returns an escape sequence' do
80
+ subject.must_equal("\e[3B")
81
+ end
82
+ end
83
+ end
84
+
85
+ describe '.right' do
86
+ let(:subject) { described_class.right(count) }
87
+ let(:count) {}
88
+
89
+ it 'returns a String' do
90
+ subject.must_be_instance_of(String)
91
+ end
92
+
93
+ it 'returns an escape sequence' do
94
+ subject.must_equal("\e[1C")
95
+ end
96
+
97
+ context 'with a count' do
98
+ let(:count) { 3 }
99
+
100
+ it 'returns an escape sequence' do
101
+ subject.must_equal("\e[3C")
102
+ end
103
+ end
104
+ end
105
+
106
+ describe '.left' do
107
+ let(:subject) { described_class.left(count) }
108
+ let(:count) {}
109
+
110
+ it 'returns a String' do
111
+ subject.must_be_instance_of(String)
112
+ end
113
+
114
+ it 'returns an escape sequence' do
115
+ subject.must_equal("\e[1D")
116
+ end
117
+
118
+ context 'with a count' do
119
+ let(:count) { 3 }
120
+
121
+ it 'returns an escape sequence' do
122
+ subject.must_equal("\e[3D")
123
+ end
124
+ end
125
+ end
126
+
127
+ describe '.save' do
128
+ let(:subject) { described_class.save }
129
+
130
+ it 'returns a String' do
131
+ subject.must_be_instance_of(String)
132
+ end
133
+
134
+ it 'returns an escape sequence' do
135
+ subject.must_equal("\e[s")
136
+ end
137
+ end
138
+
139
+ describe '.unsave' do
140
+ let(:subject) { described_class.unsave }
141
+
142
+ it 'returns a String' do
143
+ subject.must_be_instance_of(String)
144
+ end
145
+
146
+ it 'returns an escape sequence' do
147
+ subject.must_equal("\e[u")
148
+ end
149
+ end
150
+
151
+ describe '.save_all' do
152
+ let(:subject) { described_class.save_all }
153
+
154
+ it 'returns a String' do
155
+ subject.must_be_instance_of(String)
156
+ end
157
+
158
+ it 'returns an escape sequence' do
159
+ subject.must_equal("\e[7")
160
+ end
161
+ end
162
+
163
+ describe '.unsave_all' do
164
+ let(:subject) { described_class.unsave_all }
165
+
166
+ it 'returns a String' do
167
+ subject.must_be_instance_of(String)
168
+ end
169
+
170
+ it 'returns an escape sequence' do
171
+ subject.must_equal("\e[8")
172
+ end
173
+ end
174
+
175
+ describe '.esc' do
176
+ let(:subject) { described_class.esc }
177
+
178
+ it 'returns a String' do
179
+ subject.must_be_instance_of(String)
180
+ end
181
+
182
+ it 'returns an escape sequence' do
183
+ subject.must_equal("\e[")
184
+ end
185
+ end
186
+ end
187
+ end
@@ -60,7 +60,7 @@ module Vedeu
60
60
  let(:colour) { [:red, :black] }
61
61
 
62
62
  it 'returns an escape sequence' do
63
- subject.must_equal("\e[38;5;31m\e[48;5;40m")
63
+ subject.must_equal("\e[38;2;31m\e[48;2;40m")
64
64
  end
65
65
  end
66
66
 
@@ -4,6 +4,18 @@ module Vedeu
4
4
  describe Esc do
5
5
  let(:described_class) { Esc }
6
6
 
7
+ describe '.blink' do
8
+ let(:subject) { described_class.blink }
9
+
10
+ it 'returns a String' do
11
+ subject.must_be_instance_of(String)
12
+ end
13
+
14
+ it 'returns an escape sequence' do
15
+ subject.must_equal("\e[5m")
16
+ end
17
+ end
18
+
7
19
  describe '.bold' do
8
20
  let(:subject) { described_class.bold }
9
21
 
@@ -28,27 +40,27 @@ module Vedeu
28
40
  end
29
41
  end
30
42
 
31
- describe '.esc' do
32
- let(:subject) { described_class.esc }
43
+ describe '.clear_line' do
44
+ let(:subject) { described_class.clear_line }
33
45
 
34
46
  it 'returns a String' do
35
47
  subject.must_be_instance_of(String)
36
48
  end
37
49
 
38
50
  it 'returns an escape sequence' do
39
- subject.must_equal("\e[")
51
+ subject.must_equal("\e[2K")
40
52
  end
41
53
  end
42
54
 
43
- describe '.hide_cursor' do
44
- let(:subject) { described_class.hide_cursor }
55
+ describe '.esc' do
56
+ let(:subject) { described_class.esc }
45
57
 
46
58
  it 'returns a String' do
47
59
  subject.must_be_instance_of(String)
48
60
  end
49
61
 
50
62
  it 'returns an escape sequence' do
51
- subject.must_equal("\e[?25l")
63
+ subject.must_equal("\e[")
52
64
  end
53
65
  end
54
66
 
@@ -64,27 +76,27 @@ module Vedeu
64
76
  end
65
77
  end
66
78
 
67
- describe '.reset' do
68
- let(:subject) { described_class.reset }
79
+ describe '.normal' do
80
+ let(:subject) { described_class.normal }
69
81
 
70
82
  it 'returns a String' do
71
83
  subject.must_be_instance_of(String)
72
84
  end
73
85
 
74
86
  it 'returns an escape sequence' do
75
- subject.must_equal("\e[0m")
87
+ subject.must_equal("\e[2m")
76
88
  end
77
89
  end
78
90
 
79
- describe '.show_cursor' do
80
- let(:subject) { described_class.show_cursor }
91
+ describe '.reset' do
92
+ let(:subject) { described_class.reset }
81
93
 
82
94
  it 'returns a String' do
83
95
  subject.must_be_instance_of(String)
84
96
  end
85
97
 
86
98
  it 'returns an escape sequence' do
87
- subject.must_equal("\e[?25h")
99
+ subject.must_equal("\e[0m")
88
100
  end
89
101
  end
90
102
 
@@ -35,7 +35,7 @@ module Vedeu
35
35
  end
36
36
 
37
37
  it 'returns an escape sequence' do
38
- subject.must_equal("\e[38;5;31m")
38
+ subject.must_equal("\e[38;2;31m")
39
39
  end
40
40
  end
41
41
 
@@ -59,7 +59,7 @@ module Vedeu
59
59
  end
60
60
 
61
61
  it 'returns an escape sequence' do
62
- subject.must_equal("\e[38;5;39m")
62
+ subject.must_equal("\e[38;2;39m")
63
63
  end
64
64
  end
65
65
  end
@@ -50,6 +50,14 @@ module Vedeu
50
50
  end
51
51
  end
52
52
 
53
+ describe '.update' do
54
+ let(:subject) { described_class.update }
55
+
56
+ it 'returns an Array' do
57
+ subject.must_be_instance_of(Array)
58
+ end
59
+ end
60
+
53
61
  describe '.klass' do
54
62
  let(:subject) { described_class.klass }
55
63
 
@@ -13,7 +13,8 @@ module Vedeu
13
13
  x: 1,
14
14
  y: 1,
15
15
  fg: :red,
16
- bg: :blue
16
+ bg: :blue,
17
+ cursor: true,
17
18
  }
18
19
  }
19
20
  let(:result) {}
@@ -67,5 +68,23 @@ module Vedeu
67
68
  subject.must_be_instance_of(Colour)
68
69
  end
69
70
  end
71
+
72
+ describe '#cursor' do
73
+ let(:subject) { described_instance.cursor }
74
+
75
+ context 'when the cursor is on' do
76
+ it 'returns an escape sequence' do
77
+ subject.must_be_instance_of(String)
78
+ end
79
+ end
80
+
81
+ context 'when the cursor is off' do
82
+ let(:attributes) { { cursor: false } }
83
+
84
+ it 'returns an escape sequence' do
85
+ subject.must_be_instance_of(String)
86
+ end
87
+ end
88
+ end
70
89
  end
71
90
  end
@@ -77,22 +77,44 @@ module Vedeu
77
77
 
78
78
  describe '.open' do
79
79
  let(:subject) { described_class.open }
80
+
81
+ it 'returns a NilClass' do
82
+ subject.must_be_instance_of(NilClass)
83
+ end
80
84
  end
81
85
 
82
86
  describe '.close' do
83
87
  let(:subject) { described_class.close }
88
+
89
+ it 'returns a NilClass' do
90
+ subject.must_be_instance_of(NilClass)
91
+ end
84
92
  end
85
93
 
86
94
  describe '.cooked' do
87
- let(:subject) { described_class.cooked }
95
+ let(:subject) { described_class.cooked(instance) }
96
+ let(:instance) {}
97
+
98
+ it 'returns a NilClass' do
99
+ subject.must_be_instance_of(NilClass)
100
+ end
88
101
  end
89
102
 
90
103
  describe '.raw' do
91
- let(:subject) { described_class.raw }
104
+ let(:subject) { described_class.raw(instance) }
105
+ let(:instance) {}
106
+
107
+ it 'returns a NilClass' do
108
+ subject.must_be_instance_of(NilClass)
109
+ end
92
110
  end
93
111
 
94
112
  describe '.console' do
95
113
  let(:subject) { described_class.console }
114
+
115
+ it 'returns the console' do
116
+ subject.must_equal(console)
117
+ end
96
118
  end
97
119
 
98
120
  describe '.clear_screen' do
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ 30.upto(38) do |fg|
4
+ 40.upto(48) do |bg|
5
+ print "\e[38;2;#{fg}m\e[48;2;#{bg}mVedeu\e[0m"
6
+ end
7
+ print "\n"
8
+ end
data/test/test_helper.rb CHANGED
@@ -2,7 +2,6 @@ require 'simplecov'
2
2
  require 'minitest/autorun'
3
3
  require 'minitest/pride'
4
4
  require 'pry'
5
- require 'pry-nav'
6
5
 
7
6
  SimpleCov.start do
8
7
  command_name 'MiniTest::Spec'
data/vedeu.gemspec CHANGED
@@ -26,8 +26,7 @@ Gem::Specification.new do |spec|
26
26
  spec.add_development_dependency "minitest", "5.3.4"
27
27
  spec.add_development_dependency "minitest-reporters", "1.0.4"
28
28
  spec.add_development_dependency "mocha", "1.1.0"
29
- spec.add_development_dependency "pry", "0.9.12.6"
30
- spec.add_development_dependency "pry-nav", "0.2.3"
29
+ spec.add_development_dependency "pry", "0.10.0"
31
30
  spec.add_development_dependency "rake", "10.3.2"
32
31
  spec.add_development_dependency "simplecov", "0.8.2"
33
32
  end
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.0.16
4
+ version: 0.0.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gavin Laking
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-15 00:00:00.000000000 Z
11
+ date: 2014-06-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aruba
@@ -142,28 +142,14 @@ dependencies:
142
142
  requirements:
143
143
  - - '='
144
144
  - !ruby/object:Gem::Version
145
- version: 0.9.12.6
145
+ version: 0.10.0
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - '='
151
151
  - !ruby/object:Gem::Version
152
- version: 0.9.12.6
153
- - !ruby/object:Gem::Dependency
154
- name: pry-nav
155
- requirement: !ruby/object:Gem::Requirement
156
- requirements:
157
- - - '='
158
- - !ruby/object:Gem::Version
159
- version: 0.2.3
160
- type: :development
161
- prerelease: false
162
- version_requirements: !ruby/object:Gem::Requirement
163
- requirements:
164
- - - '='
165
- - !ruby/object:Gem::Version
166
- version: 0.2.3
152
+ version: 0.10.0
167
153
  - !ruby/object:Gem::Dependency
168
154
  name: rake
169
155
  requirement: !ruby/object:Gem::Requirement
@@ -227,8 +213,10 @@ files:
227
213
  - lib/vedeu/launcher.rb
228
214
  - lib/vedeu/output/background.rb
229
215
  - lib/vedeu/output/base.rb
216
+ - lib/vedeu/output/buffer.rb
230
217
  - lib/vedeu/output/colour.rb
231
218
  - lib/vedeu/output/compositor.rb
219
+ - lib/vedeu/output/cursor.rb
232
220
  - lib/vedeu/output/directive.rb
233
221
  - lib/vedeu/output/esc.rb
234
222
  - lib/vedeu/output/foreground.rb
@@ -258,8 +246,10 @@ files:
258
246
  - test/lib/vedeu/launcher_test.rb
259
247
  - test/lib/vedeu/output/background_test.rb
260
248
  - test/lib/vedeu/output/base_test.rb
249
+ - test/lib/vedeu/output/buffer_test.rb
261
250
  - test/lib/vedeu/output/colour_test.rb
262
251
  - test/lib/vedeu/output/compositor_test.rb
252
+ - test/lib/vedeu/output/cursor_test.rb
263
253
  - test/lib/vedeu/output/directive_test.rb
264
254
  - test/lib/vedeu/output/esc_test.rb
265
255
  - test/lib/vedeu/output/foreground_test.rb
@@ -286,6 +276,7 @@ files:
286
276
  - test/lib/vedeu/support/terminal_test.rb
287
277
  - test/lib/vedeu/version_test.rb
288
278
  - test/lib/vedeu_test.rb
279
+ - test/support/colours.rb
289
280
  - test/test_helper.rb
290
281
  - vedeu.gemspec
291
282
  homepage: http://www.gavinlaking.name/
@@ -320,8 +311,10 @@ test_files:
320
311
  - test/lib/vedeu/launcher_test.rb
321
312
  - test/lib/vedeu/output/background_test.rb
322
313
  - test/lib/vedeu/output/base_test.rb
314
+ - test/lib/vedeu/output/buffer_test.rb
323
315
  - test/lib/vedeu/output/colour_test.rb
324
316
  - test/lib/vedeu/output/compositor_test.rb
317
+ - test/lib/vedeu/output/cursor_test.rb
325
318
  - test/lib/vedeu/output/directive_test.rb
326
319
  - test/lib/vedeu/output/esc_test.rb
327
320
  - test/lib/vedeu/output/foreground_test.rb
@@ -348,5 +341,6 @@ test_files:
348
341
  - test/lib/vedeu/support/terminal_test.rb
349
342
  - test/lib/vedeu/version_test.rb
350
343
  - test/lib/vedeu_test.rb
344
+ - test/support/colours.rb
351
345
  - test/test_helper.rb
352
346
  has_rdoc: