vedeu 0.4.11 → 0.4.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +736 -0
  3. data/Rakefile +7 -0
  4. data/bin/vedeu_drb_server +1 -1
  5. data/config/rubocop_disabled.yml +50 -0
  6. data/config/rubocop_enabled.yml +1044 -0
  7. data/examples/borders_app.rb +3 -1
  8. data/examples/colours_app.rb +3 -1
  9. data/examples/configuration_app.rb +1 -1
  10. data/examples/cursor_app.rb +4 -1
  11. data/examples/drb_app.rb +3 -1
  12. data/examples/focus_app.rb +1 -1
  13. data/examples/geometry_app.rb +3 -1
  14. data/examples/hello_world.rb +3 -1
  15. data/examples/lines_app.rb +3 -1
  16. data/examples/typed_commands/typed_commands_app.rb +1 -1
  17. data/examples/view_templates_app/view_templates_app.rb +3 -1
  18. data/lib/vedeu/api.rb +4 -3
  19. data/lib/vedeu/bindings.rb +1 -1
  20. data/lib/vedeu/configuration/api.rb +1 -1
  21. data/lib/vedeu/configuration/cli.rb +3 -2
  22. data/lib/vedeu/configuration/configuration.rb +1 -1
  23. data/lib/vedeu/cursor/cursor.rb +2 -2
  24. data/lib/vedeu/cursor/refresh_cursor.rb +3 -1
  25. data/lib/vedeu/distributed/templates/default_configuration.vedeu +1 -1
  26. data/lib/vedeu/events/event.rb +3 -5
  27. data/lib/vedeu/geometry/position.rb +1 -1
  28. data/lib/vedeu/input/all.rb +1 -1
  29. data/lib/vedeu/input/key.rb +5 -8
  30. data/lib/vedeu/models/all.rb +9 -12
  31. data/lib/vedeu/models/interface.rb +1 -1
  32. data/lib/vedeu/models/menu.rb +1 -1
  33. data/lib/vedeu/output/border.rb +18 -14
  34. data/lib/vedeu/output/clear.rb +10 -3
  35. data/lib/vedeu/output/esc.rb +4 -14
  36. data/lib/vedeu/output/html_char.rb +11 -7
  37. data/lib/vedeu/output/null_border.rb +10 -0
  38. data/lib/vedeu/output/presentation.rb +6 -22
  39. data/lib/vedeu/output/refresh.rb +0 -11
  40. data/lib/vedeu/output/renderers/terminal_renderer.rb +1 -1
  41. data/lib/vedeu/output/translator.rb +5 -5
  42. data/lib/vedeu/output/viewport.rb +12 -9
  43. data/lib/vedeu/repositories/collections.rb +6 -0
  44. data/lib/vedeu/support/visible.rb +17 -12
  45. data/lib/vedeu/traps.rb +3 -3
  46. data/test/lib/vedeu/configuration/cli_test.rb +1 -1
  47. data/test/lib/vedeu/output/null_border_test.rb +14 -0
  48. data/test/lib/vedeu/output/refresh_test.rb +0 -21
  49. data/test/lib/vedeu/support/coercions_test.rb +5 -5
  50. data/test/lib/vedeu/support/common_test.rb +1 -1
  51. data/test/lib/vedeu/support/visible_test.rb +10 -5
  52. data/test/test_helper.rb +2 -2
  53. data/vedeu.gemspec +3 -2
  54. metadata +22 -5
@@ -42,17 +42,6 @@ module Vedeu
42
42
  Vedeu::Compositor.compose(name)
43
43
  end
44
44
 
45
- # Refresh a cursor by name.
46
- #
47
- # @param name [String]
48
- # @return [Array]
49
- def cursor(name = Vedeu.focus)
50
- if name
51
- Vedeu.log(type: :info, message: "Refreshing cursor: '#{name}'")
52
- Vedeu::RefreshCursor.render(name)
53
- end
54
- end
55
-
56
45
  end # Refresh
57
46
 
58
47
  end # Vedeu
@@ -37,7 +37,7 @@ module Vedeu
37
37
 
38
38
  # @return [String]
39
39
  def parsed
40
- Array(output).flatten.map(&:to_s).join
40
+ output.flatten.map(&:to_s).join
41
41
  end
42
42
 
43
43
  # @return [String]
@@ -154,7 +154,7 @@ module Vedeu
154
154
  #
155
155
  # @return [String]
156
156
  def rgb
157
- if Vedeu::Configuration.colour_mode == 16777216
157
+ if Vedeu::Configuration.colour_mode == 16_777_216
158
158
  register(colour, sprintf(rgb_prefix, *css_to_rgb))
159
159
 
160
160
  else
@@ -206,16 +206,16 @@ module Vedeu
206
206
  (css_to_rgb[0] / 51) * 36
207
207
  end
208
208
 
209
- # Takes the green component of {#css_to_rgb} and converts to the correct value
210
- # for setting the terminal green value.
209
+ # Takes the green component of {#css_to_rgb} and converts to the correct
210
+ # value for setting the terminal green value.
211
211
  #
212
212
  # @return [Fixnum]
213
213
  def green
214
214
  (css_to_rgb[1] / 51) * 6
215
215
  end
216
216
 
217
- # Takes the blue component of {#css_to_rgb} and converts to the correct value
218
- # for setting the terminal blue value.
217
+ # Takes the blue component of {#css_to_rgb} and converts to the correct
218
+ # value for setting the terminal blue value.
219
219
  #
220
220
  # @return [Fixnum]
221
221
  def blue
@@ -11,18 +11,18 @@ module Vedeu
11
11
  extend Forwardable
12
12
 
13
13
  def_delegators :interface,
14
- :geometry,
15
- :lines,
16
- :lines?,
17
- :cursor
14
+ :geometry,
15
+ :lines,
16
+ :lines?,
17
+ :cursor
18
18
 
19
19
  def_delegators :cursor,
20
- :ox,
21
- :oy
20
+ :ox,
21
+ :oy
22
22
 
23
23
  def_delegators :geometry,
24
- :height,
25
- :width
24
+ :height,
25
+ :width
26
26
 
27
27
  # @param interface [Vedeu::Interface]
28
28
  # @return [Array<Array<Vedeu::Char>>]
@@ -49,7 +49,10 @@ module Vedeu
49
49
 
50
50
  show[0...bordered_height].each_with_index do |line, iy|
51
51
  line[0...bordered_width].each_with_index do |column, ix|
52
- column.position = IndexPosition[iy, ix, interface.border.by, interface.border.bx]
52
+ column.position = IndexPosition[iy,
53
+ ix,
54
+ interface.border.by,
55
+ interface.border.bx]
53
56
  out << column
54
57
  end
55
58
  end
@@ -5,31 +5,37 @@ module Vedeu
5
5
  # A collection of {Vedeu::Char} instances.
6
6
  #
7
7
  class Chars < Vedeu::Collection
8
+
8
9
  end # Chars
9
10
 
10
11
  # A collection of {Vedeu::Event} instances.
11
12
  #
12
13
  class Events < Vedeu::Collection
14
+
13
15
  end # Events
14
16
 
15
17
  # A collection of {Vedeu::Interface} instances.
16
18
  #
17
19
  class Interfaces < Vedeu::Collection
20
+
18
21
  end # Interfaces
19
22
 
20
23
  # A collection of {Vedeu::Key} instances.
21
24
  #
22
25
  class Keys < Vedeu::Collection
26
+
23
27
  end # Keys
24
28
 
25
29
  # A collection of {Vedeu::Line} instances.
26
30
  #
27
31
  class Lines < Vedeu::Collection
32
+
28
33
  end # Lines
29
34
 
30
35
  # A collection of {Vedeu::Stream} instances.
31
36
  #
32
37
  class Streams < Vedeu::Collection
38
+
33
39
  end # Streams
34
40
 
35
41
  end # Vedeu
@@ -23,16 +23,7 @@ module Vedeu
23
23
  # @param visible [Boolean|Symbol]
24
24
  # @return [Visible]
25
25
  def initialize(visible = nil)
26
- @visible = if visible == :hide || visible == false
27
- false
28
-
29
- elsif visible == :show || visible == true
30
- true
31
-
32
- else
33
- !!visible
34
-
35
- end
26
+ @visible = visible
36
27
  end
37
28
 
38
29
  # @return [String]
@@ -55,14 +46,14 @@ module Vedeu
55
46
  #
56
47
  # @return [Boolean]
57
48
  def visible?
58
- @visible
49
+ visible
59
50
  end
60
51
 
61
52
  # Returns a boolean indicating whether the instance is invisible.
62
53
  #
63
54
  # @return [Boolean]
64
55
  def invisible?
65
- !@visible
56
+ !visible
66
57
  end
67
58
 
68
59
  # @return [Visible]
@@ -80,6 +71,20 @@ module Vedeu
80
71
  visible? ? hide : show
81
72
  end
82
73
 
74
+ # @return [Boolean]
75
+ def visible
76
+ if @visible == :hide || @visible == false
77
+ false
78
+
79
+ elsif @visible == :show || @visible == true
80
+ true
81
+
82
+ else
83
+ !!@visible
84
+
85
+ end
86
+ end
87
+
83
88
  end # Visible
84
89
 
85
90
  end # Vedeu
data/lib/vedeu/traps.rb CHANGED
@@ -8,9 +8,9 @@ module Vedeu
8
8
 
9
9
  Signal.trap('TERM') { exit! }
10
10
 
11
- #TTIN
12
- #USR1
13
- #USR2
11
+ Signal.trap('TTIN') {}
12
+ Signal.trap('USR1') {}
13
+ Signal.trap('USR2') {}
14
14
 
15
15
  Signal.trap('SIGWINCH') { Vedeu.trigger(:_resize_) }
16
16
 
@@ -21,7 +21,7 @@ module Vedeu
21
21
  describe '#colour_mode' do
22
22
  it '--colour-mode' do
23
23
  Configuration.configure(['--colour-mode', '16777216']) {}
24
- Configuration.colour_mode.must_equal(16777216)
24
+ Configuration.colour_mode.must_equal(16_777_216)
25
25
  end
26
26
 
27
27
  it '--colour-mode' do
@@ -41,6 +41,13 @@ module Vedeu
41
41
  it { subject.must_equal(12) }
42
42
  end
43
43
 
44
+ describe '#height' do
45
+ subject { instance.height }
46
+
47
+ it { subject.must_be_instance_of(Fixnum) }
48
+ it { subject.must_equal(7) }
49
+ end
50
+
44
51
  describe '#render' do
45
52
  subject { instance.render }
46
53
 
@@ -48,6 +55,13 @@ module Vedeu
48
55
  it { subject.must_equal([]) }
49
56
  end
50
57
 
58
+ describe '#width' do
59
+ subject { instance.width }
60
+
61
+ it { subject.must_be_instance_of(Fixnum) }
62
+ it { subject.must_equal(7) }
63
+ end
64
+
51
65
  end # NullBorder
52
66
 
53
67
  end # Vedeu
@@ -57,27 +57,6 @@ module Vedeu
57
57
  end
58
58
  end
59
59
 
60
- describe '.cursor' do
61
- let(:_name) {}
62
-
63
- subject { described.cursor(_name) }
64
-
65
- before { Vedeu::RefreshCursor.stubs(:render) }
66
-
67
- context 'when there is a name' do
68
- let(:_name) { 'refresh_cursor' }
69
-
70
- it {
71
- Vedeu::RefreshCursor.expects(:render).with(_name)
72
- subject
73
- }
74
- end
75
-
76
- context 'when there is no name' do
77
- it { subject.must_equal(nil) }
78
- end
79
- end
80
-
81
60
  end # Refresh
82
61
 
83
62
  end # Vedeu
@@ -57,23 +57,23 @@ module Vedeu
57
57
  end
58
58
 
59
59
  it 'returns a collection of models when a single hash' do
60
- coerced = CoercionsTestClass.coercer({ :name => 'test1' })
60
+ coerced = CoercionsTestClass.coercer({ name: 'test1' })
61
61
  coerced.must_be_instance_of(Array)
62
- coerced.first.attributes.must_equal({ name: "test1" })
62
+ coerced.first.attributes.must_equal({ name: 'test1' })
63
63
  end
64
64
 
65
65
  it 'returns a collection of models when multiple hashes' do
66
66
  coerced = CoercionsTestClass.coercer([
67
- { :name => 'test1' }, { :name => 'test2' }
67
+ { name: 'test1' }, { name: 'test2' }
68
68
  ])
69
69
  coerced.size.must_equal(2)
70
70
  coerced.map(&:attributes).must_equal(
71
- [{ name: "test1" }, { name: "test2" }]
71
+ [{ name: 'test1' }, { name: 'test2' }]
72
72
  )
73
73
  end
74
74
 
75
75
  it 'returns a collection of models when a single array' do
76
- coerced = CoercionsTestClass.coercer([{ :name => 'test3' }])
76
+ coerced = CoercionsTestClass.coercer([{ name: 'test3' }])
77
77
  coerced.size.must_equal(1)
78
78
  coerced.first.attributes.must_equal({ name: "test3" })
79
79
  end
@@ -46,7 +46,7 @@ module Vedeu
46
46
  end
47
47
 
48
48
  describe '#to_sentence' do
49
- let(:array) { %w{ hydrogen helium lithium } }
49
+ let(:array) { ['hydrogen', 'helium', 'lithium'] }
50
50
 
51
51
  subject { described.to_sentence(array) }
52
52
 
@@ -12,35 +12,40 @@ module Vedeu
12
12
 
13
13
  describe '#initialize' do
14
14
  it { instance.must_be_instance_of(Visible) }
15
+ it { instance.instance_variable_get('@visible').must_equal(visible) }
16
+ end
17
+
18
+ describe '#visible' do
19
+ subject { instance.visible }
15
20
 
16
21
  context 'when visible is :hide' do
17
22
  let(:visible) { :hide }
18
23
 
19
- it { instance.instance_variable_get('@visible').must_equal(false) }
24
+ it { subject.must_equal(false) }
20
25
  end
21
26
 
22
27
  context 'when visible is :show' do
23
28
  let(:visible) { :show }
24
29
 
25
- it { instance.instance_variable_get('@visible').must_equal(true) }
30
+ it { subject.must_equal(true) }
26
31
  end
27
32
 
28
33
  context 'when visible is nil' do
29
34
  let(:visible) { nil }
30
35
 
31
- it { instance.instance_variable_get('@visible').must_equal(false) }
36
+ it { subject.must_equal(false) }
32
37
  end
33
38
 
34
39
  context 'when visible is false' do
35
40
  let(:visible) { false }
36
41
 
37
- it { instance.instance_variable_get('@visible').must_equal(false) }
42
+ it { subject.must_equal(false) }
38
43
  end
39
44
 
40
45
  context 'when visible is anything else that evaluates to true' do
41
46
  let(:visible) { 'yeah show it!' }
42
47
 
43
- it { instance.instance_variable_get('@visible').must_equal(true) }
48
+ it { subject.must_equal(true) }
44
49
  end
45
50
  end
46
51
 
data/test/test_helper.rb CHANGED
@@ -41,14 +41,14 @@ def test_configuration
41
41
  Vedeu::Configuration.reset!
42
42
 
43
43
  Vedeu.configure do
44
- colour_mode 16777216
44
+ colour_mode 16_777_216
45
45
  # adds ~40ms to test run speed
46
46
  # debug!
47
47
 
48
48
  # if debug! above is commented out, then only
49
49
  # `Vedeu.log(type: <any type>, message: '...', force: true)`
50
50
  # will be logged, otherwise every `Vedeu.log` will be logged.
51
- log '/tmp/vedeu_test_helper.log'
51
+ log '/tmp/vedeu_test_helper.log'
52
52
  end
53
53
  end
54
54
 
data/vedeu.gemspec CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = 'vedeu'
7
- spec.version = '0.4.11'
7
+ spec.version = '0.4.12'
8
8
  spec.authors = ['Gavin Laking']
9
9
  spec.email = ['gavinlaking@gmail.com']
10
10
  spec.summary = %q{A terminal case of wonderland.}
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
 
20
20
  spec.add_development_dependency 'aruba', '0.6.2'
21
21
  spec.add_development_dependency 'bundler', '~> 1.7'
22
- spec.add_development_dependency 'cucumber', '1.3.19'
22
+ spec.add_development_dependency 'cucumber', '2.0.0'
23
23
  spec.add_development_dependency 'guard', '2.12.5'
24
24
  spec.add_development_dependency 'guard-bundler', '2.1.0'
25
25
  spec.add_development_dependency 'guard-cucumber', '1.5.4'
@@ -31,6 +31,7 @@ Gem::Specification.new do |spec|
31
31
  spec.add_development_dependency 'pry', '0.10.1'
32
32
  spec.add_development_dependency 'pry-byebug', '3.1.0'
33
33
  spec.add_development_dependency 'rake', '10.4.2'
34
+ spec.add_development_dependency 'rubocop'
34
35
  spec.add_development_dependency 'ruby-prof', '0.15.6'
35
36
  spec.add_development_dependency 'simplecov', '0.9.2'
36
37
  spec.add_development_dependency 'yard', '0.8.7.6'
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.4.11
4
+ version: 0.4.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gavin Laking
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-24 00:00:00.000000000 Z
11
+ date: 2015-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aruba
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - '='
46
46
  - !ruby/object:Gem::Version
47
- version: 1.3.19
47
+ version: 2.0.0
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - '='
53
53
  - !ruby/object:Gem::Version
54
- version: 1.3.19
54
+ version: 2.0.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: guard
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -206,6 +206,20 @@ dependencies:
206
206
  - - '='
207
207
  - !ruby/object:Gem::Version
208
208
  version: 10.4.2
209
+ - !ruby/object:Gem::Dependency
210
+ name: rubocop
211
+ requirement: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - ">="
214
+ - !ruby/object:Gem::Version
215
+ version: '0'
216
+ type: :development
217
+ prerelease: false
218
+ version_requirements: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - ">="
221
+ - !ruby/object:Gem::Version
222
+ version: '0'
209
223
  - !ruby/object:Gem::Dependency
210
224
  name: ruby-prof
211
225
  requirement: !ruby/object:Gem::Requirement
@@ -260,6 +274,7 @@ extensions: []
260
274
  extra_rdoc_files: []
261
275
  files:
262
276
  - ".gitignore"
277
+ - ".rubocop.yml"
263
278
  - ".ruby-version"
264
279
  - ".travis.yml"
265
280
  - ".yardopts"
@@ -274,6 +289,8 @@ files:
274
289
  - bin/vedeu_drb_server
275
290
  - bin/vedeu_test
276
291
  - config/cucumber.yml
292
+ - config/rubocop_disabled.yml
293
+ - config/rubocop_enabled.yml
277
294
  - docs/api.md
278
295
  - docs/getting_started.md
279
296
  - docs/object_graph.md
@@ -551,7 +568,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
551
568
  version: '0'
552
569
  requirements: []
553
570
  rubyforge_project:
554
- rubygems_version: 2.4.3
571
+ rubygems_version: 2.4.6
555
572
  signing_key:
556
573
  specification_version: 4
557
574
  summary: A terminal case of wonderland.