Skip to content

Commit

Permalink
Add wordwrap option to Interfaces::Interface, also;
Browse files Browse the repository at this point in the history
Default wordwrap to true.

Work relating to #341.
  • Loading branch information
gavinlaking committed Jan 31, 2016
1 parent 8ee4a9c commit e0b1c34
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 21 deletions.
2 changes: 1 addition & 1 deletion lib/vedeu/dsl/helpers/attributes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def defaults
style: nil,
truncate: false,
width: nil,
wordwrap: false,
wordwrap: true,
}
end

Expand Down
13 changes: 3 additions & 10 deletions lib/vedeu/dsl/presentation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,23 +129,16 @@ def style(value)
alias styles style
alias styles= style

# Specify whether the view should use wordwrapping, or not
# (default).
# Specify whether the view should use wordwrapping (default).
#
# @param value [Boolean]
# @return [Boolean]
def wordwrap(value = false)
def wordwrap(value = true)
boolean = value ? true : false

model.wordwrap = boolean
end

# Instruct the view to use wordwrapping.
#
# @return [Boolean]
def wordwrap!
wordwrap(true)
end
alias wordwrap! wordwrap

private

Expand Down
7 changes: 7 additions & 0 deletions lib/vedeu/interfaces/interface.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ class Interface
# @return [Vedeu::Views::Composition]
attr_accessor :parent

# @!attribute [rw] wordwrap
# @return [Boolean]
attr_accessor :wordwrap

# @!attribute [rw] zindex
# @return [Fixnum]
attr_accessor :zindex
Expand All @@ -60,6 +64,7 @@ class Interface
# @option attributes repository [Vedeu::Interfaces::Repository]
# @option attributes style [Vedeu::Presentation::Style]
# @option attributes visible [Boolean]
# @option attributes wordwrap [Boolean]
# @option attributes zindex [Fixnum]
# @return [Vedeu::Interfaces::Interface]
def initialize(attributes = {})
Expand All @@ -82,6 +87,7 @@ def attributes
repository: repository,
style: style,
visible: visible,
wordwrap: wordwrap,
zindex: zindex,
}
end
Expand Down Expand Up @@ -156,6 +162,7 @@ def defaults
repository: Vedeu.interfaces,
style: :normal,
visible: true,
wordwrap: true,
zindex: 0,
}
end
Expand Down
2 changes: 1 addition & 1 deletion lib/vedeu/views/default_attributes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def defaults
truncate: false,
value: '',
width: nil,
wordwrap: false,
wordwrap: true,
}
end

Expand Down
14 changes: 6 additions & 8 deletions test/lib/vedeu/dsl/presentation_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,28 +148,28 @@ module DSL
context 'when the value is not given' do
subject { instance.wordwrap }

it { subject.must_equal() }
it { subject.must_equal(true) }
end

context 'when the value is given' do
let(:_value) { false }

subject { instance.wordwrap(_value) }

context 'when the value is nil' do
let(:_value) { nil }

it { subject.must_equal() }
it { subject.must_equal(false) }
end

context 'when the value is false' do
it { subject.must_equal() }
let(:_value) { false }

it { subject.must_equal(false) }
end

context 'when the value evaluates as true' do
let(:_value) { :a_true_value }

it { subject.must_equal() }
it { subject.must_equal(true) }
end
end

Expand All @@ -178,8 +178,6 @@ module DSL

describe '#wordwrap!' do
it { instance.must_respond_to(:wordwrap!) }

# @todo Add more tests.
end

end # Presentation
Expand Down
2 changes: 1 addition & 1 deletion test/lib/vedeu/views/default_attributes_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def nil_for_testing_purposes
style: nil,
truncate: false,
width: nil,
wordwrap: false,
wordwrap: true,
}
}

Expand Down

0 comments on commit e0b1c34

Please sign in to comment.