vedeu 0.5.8 → 0.5.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -39,7 +39,7 @@ module Vedeu
39
39
  end
40
40
 
41
41
  describe '#eql?' do
42
- let(:other) { described.new(colour: Colour.new(background: '#000000')) }
42
+ let(:other) { described.new(value: nil) }
43
43
 
44
44
  subject { instance.eql?(other) }
45
45
 
@@ -48,7 +48,7 @@ module Vedeu
48
48
  it { subject.must_equal(true) }
49
49
 
50
50
  context 'when different to other' do
51
- let(:other) { described.new(colour: Colour.new(background: '#ff0000')) }
51
+ let(:other) { described.new(value: 'b') }
52
52
 
53
53
  it { subject.must_equal(false) }
54
54
  end
@@ -26,6 +26,7 @@ unless ENV['NO_SIMPLECOV']
26
26
  add_group 'cursor', 'vedeu/cursor'
27
27
  add_group 'distributed', 'vedeu/distributed'
28
28
  add_group 'dsl', 'vedeu/dsl'
29
+ add_group 'esc', 'vedeu/esc'
29
30
  add_group 'events', 'vedeu/events'
30
31
  add_group 'geometry', 'vedeu/geometry'
31
32
  add_group 'input', 'vedeu/input'
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
22
22
 
23
23
  spec.add_development_dependency 'guard', '2.13.0'
24
24
  spec.add_development_dependency 'guard-minitest', '2.4.4'
25
- spec.add_development_dependency 'minitest', '5.7.0'
25
+ spec.add_development_dependency 'minitest', '5.8.0'
26
26
  spec.add_development_dependency 'minitest-reporters', '1.0.19'
27
27
  spec.add_development_dependency 'mocha', '1.1.0'
28
28
  spec.add_development_dependency 'pry', '0.10.1'
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
32
32
  spec.add_development_dependency 'simplecov-console', '0.2.0'
33
33
  spec.add_development_dependency 'yard', '0.8.7.6'
34
34
 
35
- spec.add_dependency 'bundler', '~> 1.8'
35
+ spec.add_dependency 'bundler', '~> 1.10'
36
36
  spec.add_dependency 'rake', '~> 10.4'
37
37
  spec.add_dependency 'thor', '0.19.1'
38
38
  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.5.8
4
+ version: 0.5.9
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-08-08 00:00:00.000000000 Z
11
+ date: 2015-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: guard
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - '='
46
46
  - !ruby/object:Gem::Version
47
- version: 5.7.0
47
+ version: 5.8.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: 5.7.0
54
+ version: 5.8.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: minitest-reporters
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -170,14 +170,14 @@ dependencies:
170
170
  requirements:
171
171
  - - "~>"
172
172
  - !ruby/object:Gem::Version
173
- version: '1.8'
173
+ version: '1.10'
174
174
  type: :runtime
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
178
  - - "~>"
179
179
  - !ruby/object:Gem::Version
180
- version: '1.8'
180
+ version: '1.10'
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: rake
183
183
  requirement: !ruby/object:Gem::Requirement
@@ -307,7 +307,6 @@ files:
307
307
  - lib/vedeu/colours/colour.rb
308
308
  - lib/vedeu/colours/colour_translator.rb
309
309
  - lib/vedeu/colours/colours.rb
310
- - lib/vedeu/colours/escape_sequences.rb
311
310
  - lib/vedeu/colours/foreground.rb
312
311
  - lib/vedeu/colours/foregrounds.rb
313
312
  - lib/vedeu/common.rb
@@ -348,6 +347,10 @@ files:
348
347
  - lib/vedeu/dsl/text.rb
349
348
  - lib/vedeu/dsl/use.rb
350
349
  - lib/vedeu/dsl/view.rb
350
+ - lib/vedeu/esc/actions.rb
351
+ - lib/vedeu/esc/borders.rb
352
+ - lib/vedeu/esc/colours.rb
353
+ - lib/vedeu/esc/esc.rb
351
354
  - lib/vedeu/events/event.rb
352
355
  - lib/vedeu/events/event_aliases.rb
353
356
  - lib/vedeu/events/event_collection.rb
@@ -391,18 +394,17 @@ files:
391
394
  - lib/vedeu/models/views/line.rb
392
395
  - lib/vedeu/models/views/stream.rb
393
396
  - lib/vedeu/models/views/view.rb
394
- - lib/vedeu/null.rb
395
397
  - lib/vedeu/null/border.rb
396
398
  - lib/vedeu/null/buffer.rb
397
399
  - lib/vedeu/null/generic.rb
398
400
  - lib/vedeu/null/geometry.rb
399
401
  - lib/vedeu/null/interface.rb
400
402
  - lib/vedeu/null/menu.rb
403
+ - lib/vedeu/null/null.rb
401
404
  - lib/vedeu/null/view.rb
402
405
  - lib/vedeu/output/clear/named_group.rb
403
406
  - lib/vedeu/output/clear/named_interface.rb
404
407
  - lib/vedeu/output/compressor.rb
405
- - lib/vedeu/output/esc.rb
406
408
  - lib/vedeu/output/html_char.rb
407
409
  - lib/vedeu/output/output.rb
408
410
  - lib/vedeu/output/presentation.rb
@@ -478,7 +480,6 @@ files:
478
480
  - test/lib/vedeu/colours/colour_test.rb
479
481
  - test/lib/vedeu/colours/colour_translator_test.rb
480
482
  - test/lib/vedeu/colours/colours_test.rb
481
- - test/lib/vedeu/colours/escape_sequences_test.rb
482
483
  - test/lib/vedeu/colours/foreground_test.rb
483
484
  - test/lib/vedeu/colours/foregrounds_test.rb
484
485
  - test/lib/vedeu/common_test.rb
@@ -508,6 +509,9 @@ files:
508
509
  - test/lib/vedeu/dsl/text_test.rb
509
510
  - test/lib/vedeu/dsl/use_test.rb
510
511
  - test/lib/vedeu/dsl/view_test.rb
512
+ - test/lib/vedeu/esc/actions_test.rb
513
+ - test/lib/vedeu/esc/borders_test.rb
514
+ - test/lib/vedeu/esc/colours_test.rb
511
515
  - test/lib/vedeu/events/event_aliases_test.rb
512
516
  - test/lib/vedeu/events/event_collection_test.rb
513
517
  - test/lib/vedeu/events/event_test.rb
@@ -665,7 +669,6 @@ test_files:
665
669
  - test/lib/vedeu/colours/colour_test.rb
666
670
  - test/lib/vedeu/colours/colour_translator_test.rb
667
671
  - test/lib/vedeu/colours/colours_test.rb
668
- - test/lib/vedeu/colours/escape_sequences_test.rb
669
672
  - test/lib/vedeu/colours/foreground_test.rb
670
673
  - test/lib/vedeu/colours/foregrounds_test.rb
671
674
  - test/lib/vedeu/common_test.rb
@@ -695,6 +698,9 @@ test_files:
695
698
  - test/lib/vedeu/dsl/text_test.rb
696
699
  - test/lib/vedeu/dsl/use_test.rb
697
700
  - test/lib/vedeu/dsl/view_test.rb
701
+ - test/lib/vedeu/esc/actions_test.rb
702
+ - test/lib/vedeu/esc/borders_test.rb
703
+ - test/lib/vedeu/esc/colours_test.rb
698
704
  - test/lib/vedeu/events/event_aliases_test.rb
699
705
  - test/lib/vedeu/events/event_collection_test.rb
700
706
  - test/lib/vedeu/events/event_test.rb
@@ -1,125 +0,0 @@
1
- module Vedeu
2
-
3
- # Provides escape sequence strings for terminal colours and some actions.
4
- #
5
- module EscapeSequences
6
-
7
- extend self
8
-
9
- # @return [Hash<Symbol => String>]
10
- def actions
11
- {
12
- hide_cursor: "\e[?25l",
13
- show_cursor: "\e[?25h",
14
- cursor_position: "\e[6n",
15
- bg_reset: "\e[49m",
16
- blink: "\e[5m",
17
- blink_off: "\e[25m",
18
- bold: "\e[1m",
19
- bold_off: "\e[22m",
20
- border_on: "\e(0",
21
- border_off: "\e(B",
22
- dim: "\e[2m",
23
- fg_reset: "\e[39m",
24
- negative: "\e[7m",
25
- positive: "\e[27m",
26
- reset: "\e[0m",
27
- underline: "\e[4m",
28
- underline_off: "\e[24m",
29
- }
30
- end
31
-
32
- # Produces the background named colour escape sequence hash from the
33
- # foreground escape sequence hash.
34
- #
35
- # @return [Hash<Symbol => Fixnum>]
36
- def background_codes
37
- hash = {}
38
- Vedeu::EscapeSequences.foreground_codes.inject(hash) do |h, (k, v)|
39
- h.merge!(k => v + 10)
40
- end
41
- end
42
-
43
- # Produces the foreground named colour escape sequence hash. The background
44
- # escape sequences are also generated from this by adding 10 to the values.
45
- # This hash gives rise to methods you can call directly on `Esc` to produce
46
- # the desired colours:
47
- #
48
- # @example
49
- # Esc.red # => "\e[31m"
50
- #
51
- # Esc.red { 'some text' } # => "\e[31msome text\e[39m"
52
- #
53
- # Esc.on_blue # => "\e[44m"
54
- #
55
- # Esc.on_blue { 'some text' } # => "\e[44msome text\e[49m"
56
- #
57
- # # Valid names:
58
- # :black, :red, :green, :yellow, :blue, :magenta, :cyan, :light_grey,
59
- # :default, :dark_grey, :light_red, :light_green, :light_yellow,
60
- # :light_blue, :light_magenta, :light_cyan, :white
61
- #
62
- # @return [Hash<Symbol => Fixnum>]
63
- def foreground_codes
64
- {
65
- black: 30,
66
- red: 31,
67
- green: 32,
68
- yellow: 33,
69
- blue: 34,
70
- magenta: 35,
71
- cyan: 36,
72
- light_grey: 37,
73
- default: 39,
74
- dark_grey: 90,
75
- light_red: 91,
76
- light_green: 92,
77
- light_yellow: 93,
78
- light_blue: 94,
79
- light_magenta: 95,
80
- light_cyan: 96,
81
- white: 97,
82
- }
83
- end
84
- alias_method :codes, :foreground_codes
85
-
86
- # @return [void]
87
- def setup!
88
- define_actions!
89
- define_backgrounds!
90
- define_foregrounds!
91
- end
92
-
93
- private
94
-
95
- # @return [void]
96
- def define_actions!
97
- actions.each { |key, code| define_method(key) { code } }
98
- end
99
-
100
- # @return [void]
101
- def define_backgrounds!
102
- background_codes.each do |key, code|
103
- define_method('on_' + key.to_s) do |&blk|
104
- "\e[#{code}m" + (blk ? blk.call + "\e[49m" : '')
105
- end
106
- end
107
- end
108
-
109
- # Dynamically creates methods for each terminal named colour. When a block
110
- # is given, then the colour is reset to 'default' once the block is called.
111
- #
112
- # @return [void]
113
- def define_foregrounds!
114
- foreground_codes.each do |key, code|
115
- define_method(key) do |&blk|
116
- "\e[#{code}m" + (blk ? blk.call + "\e[39m" : '')
117
- end
118
- end
119
- end
120
-
121
- end # EscapeSequences
122
-
123
- end # Vedeu
124
-
125
- Vedeu::EscapeSequences.setup!
@@ -1,100 +0,0 @@
1
- require 'test_helper'
2
-
3
- module Vedeu
4
-
5
- describe EscapeSequences do
6
-
7
- let(:described) { Vedeu::EscapeSequences }
8
-
9
- before { Vedeu::Terminal.stubs(:size).returns([80, 25]) }
10
-
11
- describe 'foreground colour methods' do
12
- it { described.black.must_equal("\e[30m") }
13
- it { described.red.must_equal("\e[31m") }
14
- it { described.green.must_equal("\e[32m") }
15
- it { described.yellow.must_equal("\e[33m") }
16
- it { described.blue.must_equal("\e[34m") }
17
- it { described.magenta.must_equal("\e[35m") }
18
- it { described.cyan.must_equal("\e[36m") }
19
- it { described.light_grey.must_equal("\e[37m") }
20
- it { described.default.must_equal("\e[39m") }
21
- it { described.dark_grey.must_equal("\e[90m") }
22
- it { described.light_red.must_equal("\e[91m") }
23
- it { described.light_green.must_equal("\e[92m") }
24
- it { described.light_yellow.must_equal("\e[93m") }
25
- it { described.light_blue.must_equal("\e[94m") }
26
- it { described.light_magenta.must_equal("\e[95m") }
27
- it { described.light_cyan.must_equal("\e[96m") }
28
- it { described.white.must_equal("\e[97m") }
29
-
30
- it 'returns an escape sequence for the foreground colour and resets ' \
31
- 'after calling the block' do
32
- described.cyan do
33
- 'ununpentium'
34
- end.must_equal("\e[36mununpentium\e[39m")
35
- end
36
- end
37
-
38
- describe '.codes' do
39
- it { described.codes.must_be_instance_of(Hash) }
40
- it { described.must_respond_to(:foreground_codes) }
41
- end
42
-
43
- describe '.background_codes' do
44
- it { described.background_codes.must_be_instance_of(Hash) }
45
- end
46
-
47
- describe 'background colour methods' do
48
- it { described.on_black.must_equal("\e[40m") }
49
- it { described.on_red.must_equal("\e[41m") }
50
- it { described.on_green.must_equal("\e[42m") }
51
- it { described.on_yellow.must_equal("\e[43m") }
52
- it { described.on_blue.must_equal("\e[44m") }
53
- it { described.on_magenta.must_equal("\e[45m") }
54
- it { described.on_cyan.must_equal("\e[46m") }
55
- it { described.on_light_grey.must_equal("\e[47m") }
56
- it { described.on_default.must_equal("\e[49m") }
57
- it { described.on_dark_grey.must_equal("\e[100m") }
58
- it { described.on_light_red.must_equal("\e[101m") }
59
- it { described.on_light_green.must_equal("\e[102m") }
60
- it { described.on_light_yellow.must_equal("\e[103m") }
61
- it { described.on_light_blue.must_equal("\e[104m") }
62
- it { described.on_light_magenta.must_equal("\e[105m") }
63
- it { described.on_light_cyan.must_equal("\e[106m") }
64
- it { described.on_white.must_equal("\e[107m") }
65
-
66
- it 'returns an escape sequence for the background colour and resets ' \
67
- 'after calling the block' do
68
- described.on_red do
69
- 'livermorium'
70
- end.must_equal("\e[41mlivermorium\e[49m")
71
- end
72
- end
73
-
74
- describe 'action methods' do
75
- it { described.hide_cursor.must_equal("\e[?25l") }
76
- it { described.show_cursor.must_equal("\e[?25h") }
77
- it { described.cursor_position.must_equal("\e[6n") }
78
- it { described.bg_reset.must_equal("\e[49m") }
79
- it { described.blink.must_equal("\e[5m") }
80
- it { described.blink_off.must_equal("\e[25m") }
81
- it { described.bold.must_equal("\e[1m") }
82
- it { described.bold_off.must_equal("\e[22m") }
83
- it { described.border_on.must_equal("\e(0") }
84
- it { described.border_off.must_equal("\e(B") }
85
- it { described.dim.must_equal("\e[2m") }
86
- it { described.fg_reset.must_equal("\e[39m") }
87
- it { described.negative.must_equal("\e[7m") }
88
- it { described.positive.must_equal("\e[27m") }
89
- it { described.reset.must_equal("\e[0m") }
90
- it { described.underline.must_equal("\e[4m") }
91
- it { described.underline_off.must_equal("\e[24m") }
92
- end
93
-
94
- describe '.actions' do
95
- it { described.actions.must_be_instance_of(Hash) }
96
- end
97
-
98
- end # EscapeSequences
99
-
100
- end # Vedeu