Skip to content

Commit

Permalink
Add name wherever a Vedeu::Views::Char is being initialized.
Browse files Browse the repository at this point in the history
Work relating to #302.
  • Loading branch information
gavinlaking committed Nov 12, 2015
1 parent c6ecacc commit 9795ead
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 15 deletions.
1 change: 1 addition & 0 deletions lib/vedeu/borders/refresh.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ def build(value, type = :border, iy = 0, ix = 0)
Vedeu::Views::Char.new(value: value,
parent: interface,
colour: colour,
name: name,
style: style,
position: [iy, ix],
border: type)
Expand Down
3 changes: 2 additions & 1 deletion lib/vedeu/editor/cropper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ def viewport

visible.each_with_index do |line, iy|
line.chars.each_with_index do |char, ix|
out << Vedeu::Views::Char.new(parent: interface,
out << Vedeu::Views::Char.new(name: name,
parent: interface,
position: [(by + iy), (bx + ix)],
value: char.freeze)
end
Expand Down
1 change: 1 addition & 0 deletions lib/vedeu/interfaces/clear.rb
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ def output
Array.new(width) do |ix|
Vedeu::Views::Char.new(value: ' '.freeze,
colour: colour,
name: name,
position: [y + iy, x + ix])
end
end
Expand Down
10 changes: 4 additions & 6 deletions test/lib/vedeu/interfaces/clear_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,11 @@ module Interfaces
let(:output) {
[
[
Vedeu::Views::Char.new(value: ' ', position: [1, 1]),
Vedeu::Views::Char.new(value: ' ', position: [1, 2]),

Vedeu::Views::Char.new(name: _name, value: ' ', position: [1, 1]),
Vedeu::Views::Char.new(name: _name, value: ' ', position: [1, 2]),
], [
Vedeu::Views::Char.new(value: ' ', position: [2, 1]),
Vedeu::Views::Char.new(value: ' ', position: [2, 2]),

Vedeu::Views::Char.new(name: _name, value: ' ', position: [2, 1]),
Vedeu::Views::Char.new(name: _name, value: ' ', position: [2, 2]),
]
]
}
Expand Down
2 changes: 2 additions & 0 deletions test/lib/vedeu/models/views/html_char_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ module Views
{
border: border,
colour: colour,
name: _name,
parent: parent,
value: _value
}
}
let(:border) {}
let(:colour) {}
let(:_name) {}
let(:parent) { Vedeu::Views::Line.new(colour: parent_colour) }
let(:parent_colour) {}
let(:_value) {}
Expand Down
23 changes: 19 additions & 4 deletions test/lib/vedeu/output/compressor_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module Output
let(:described) { Vedeu::Output::Compressor }
let(:instance) { described.new(output) }
let(:output) {}
let(:_name) {}

describe '#initialize' do
it { instance.must_be_instance_of(described) }
Expand All @@ -29,10 +30,13 @@ module Output
let(:output) {
Vedeu::Models::Page.coerce([
Vedeu::Views::Char.new(value: 'Y',
name: _name,
colour: { foreground: '#ff0000' }),
Vedeu::Views::Char.new(value: 'e',
name: _name,
colour: { foreground: '#ff0000' }),
Vedeu::Views::Char.new(value: 's',
name: _name,
colour: { foreground: '#ff0000' }),
])
}
Expand All @@ -46,12 +50,16 @@ module Output
let(:output) {
Vedeu::Models::Page.coerce([
Vedeu::Views::Char.new(value: 'a',
name: _name,
colour: { foreground: '#ff0000' }),
Vedeu::Views::Char.new(value: 'b',
name: _name,
colour: { foreground: '#ff0000' }),
Vedeu::Views::Char.new(value: 'c',
name: _name,
colour: { foreground: '#0000ff' }),
Vedeu::Views::Char.new(value: 'd',
name: _name,
colour: { foreground: '#0000ff' }),
])
}
Expand All @@ -64,9 +72,9 @@ module Output
'elements' do
let(:output) {
Vedeu::Models::Page.coerce([
Vedeu::Views::Char.new(value: 'N'),
Vedeu::Views::Char.new(name: _name, value: 'N'),
Vedeu::Models::Escape.new(value: "\e[?25l"),
Vedeu::Views::Char.new(value: 't'),
Vedeu::Views::Char.new(name: _name, value: 't'),
])
}
it 'converts the non-Vedeu::Views::Char elements into String ' \
Expand All @@ -83,10 +91,13 @@ module Output
let(:output) {
Vedeu::Models::Page.coerce([
Vedeu::Views::Char.new(value: 'Y',
name: _name,
colour: { foreground: '#ff0000' }),
Vedeu::Views::Char.new(value: 'e',
name: _name,
colour: { foreground: '#ff0000' }),
Vedeu::Views::Char.new(value: 's',
name: _name,
colour: { foreground: '#ff0000' }),
])
}
Expand All @@ -102,12 +113,16 @@ module Output
let(:output) {
Vedeu::Models::Page.coerce([
Vedeu::Views::Char.new(value: 'a',
name: _name,
colour: { foreground: '#ff0000' }),
Vedeu::Views::Char.new(value: 'b',
name: _name,
colour: { foreground: '#ff0000' }),
Vedeu::Views::Char.new(value: 'c',
name: _name,
colour: { foreground: '#0000ff' }),
Vedeu::Views::Char.new(value: 'd',
name: _name,
colour: { foreground: '#0000ff' }),
])
}
Expand All @@ -124,9 +139,9 @@ module Output
context 'when the output is not all Vedeu::Views::Char elements' do
let(:output) {
Vedeu::Models::Page.coerce([
Vedeu::Views::Char.new(value: 'N'),
Vedeu::Views::Char.new(name: _name, value: 'N'),
Vedeu::Models::Escape.new(value: "\e[?25l"),
Vedeu::Views::Char.new(value: 't'),
Vedeu::Views::Char.new(name: _name, value: 't'),
])
}
it 'converts the non-Vedeu::Views::Char elements into String ' \
Expand Down
4 changes: 3 additions & 1 deletion test/lib/vedeu/output/renderers/json_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module Renderers
let(:instance) { described.new(options) }
let(:options) { {} }
let(:output) { Vedeu::Models::Page.new }
let(:_name) {}

before do
::File.stubs(:write)
Expand All @@ -33,7 +34,8 @@ module Renderers
describe '#render' do
let(:output) {
Vedeu::Models::Page.coerce([
Vedeu::Views::Char.new(value: 'a',
Vedeu::Views::Char.new(value: 'a',
name: _name,
colour: {
background: '#ff0000',
foreground: '#ffffff' }),
Expand Down
7 changes: 4 additions & 3 deletions test/lib/vedeu/output/renderers/terminal_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,20 @@ module Renderers
let(:described) { Vedeu::Renderers::Terminal }
let(:instance) { described.new(options) }
let(:options) { {} }
let(:_name) {}
let(:output) {
Vedeu::Models::Page.coerce([
[
Vedeu::Models::Cell.new(position: [1, 1]),
Vedeu::Views::Char.new(value: 'a', position: [1, 2]),
Vedeu::Views::Char.new(name: _name, value: 'a', position: [1, 2]),
Vedeu::Models::Cell.new(position: [1, 3]),
], [
Vedeu::Models::Cell.new(position: [2, 1]),
Vedeu::Views::Char.new(value: 'b', position: [2, 2]),
Vedeu::Views::Char.new(name: _name, value: 'b', position: [2, 2]),
Vedeu::Models::Cell.new(position: [2, 3]),
], [
Vedeu::Models::Cell.new(position: [3, 1]),
Vedeu::Views::Char.new(value: 'c', position: [3, 2]),
Vedeu::Views::Char.new(name: _name, value: 'c', position: [3, 2]),
Vedeu::Models::Cell.new(position: [3, 3]),
],
])
Expand Down

0 comments on commit 9795ead

Please sign in to comment.