vedeu 0.0.37 → 0.0.38

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: 30086255eba975054c131f5aa42aeff7e4ab4d4c
4
- data.tar.gz: 338f9940b945d89ee8bc4e21cb068d8e5eccc3b6
3
+ metadata.gz: 661482d026960734c10b12e030206f9570fe369a
4
+ data.tar.gz: 021507e23ec529f132e3da33e03ab7e537fa9e76
5
5
  SHA512:
6
- metadata.gz: df5e8b21200f6197027e7a8430729fea7e1dcf5cfdc757119aedbff3a6179b6a6754fdd4088063980f6881dd650bbd30eeb42f0a732c27e2602fc65725b37f9e
7
- data.tar.gz: 0bd5207420d3d37e1383d44a8fd88e5dc97bb1f07450f162eee30e0bb0cabd98ece969c59536651ed29f624ab412aa1490faed55399063d920a12997715b2417
6
+ metadata.gz: fe71eb666f8f5a6353e6b76b945498c6407c8d83a797e5bbcaf2ceb4b7e9f698e85db442afdfde87c04b151af13b187fd3f8ec4e3aa7adb9daa9b60a202bc1bf
7
+ data.tar.gz: c14259a37b32d99a84dda5d989cff126b3e9365f1dfd3d1e30abb725d9b1c58f7b07232243b811600ccdfadf810d6e3cef032c6b93132e478cd6dc22b771c4af
data/README.md CHANGED
@@ -27,11 +27,15 @@ Expect proper documentation soon!
27
27
  class MyApp
28
28
  include Vedeu
29
29
 
30
- interface :main, { }
30
+ interface 'main' do
31
+ ...
32
+ end
31
33
 
32
- command :thing, { entity: SomeClass,
33
- keypress: 't',
34
- keyword: 'thing' }
34
+ command 'thing' do
35
+ entity SomeClass
36
+ keypress 't'
37
+ keyword 'thing'
38
+ end
35
39
 
36
40
  event :some_event do
37
41
  # ...
@@ -69,43 +73,41 @@ To understand how Vedeu works, you need to familiarise yourself with some terms.
69
73
 
70
74
  ### On Defining Interfaces
71
75
 
72
- interface :main, {
73
- y: 1,
74
- x: 1,
75
- z: 1,
76
- width: 10, # see notes below
77
- height: 10,
78
- colour: {
79
- foreground: '#ffffff',
80
- background: '#000000'
81
- },
82
- cursor: false,
83
- }
76
+ interface 'main' do
77
+ y 1
78
+ x 1
79
+ z 1
80
+ width 10 # see notes below
81
+ height 10
82
+ colour foreground: '#ffffff', background: '#000000'
83
+ cursor false
84
+ end
84
85
 
85
86
  Referring to the above example, interfaces have a name, and various default attributes.
86
87
 
87
- `:y` sets the starting row point. (See Geometry)
88
- `:x` sets the starting column point.
89
- `:z` an integer specifying the z-index of the interface.
88
+ `y` sets the starting row point. (See Geometry)
89
+ `x` sets the starting column point.
90
+ `z` an integer specifying the z-index of the interface.
90
91
  (See Layers)
91
92
 
92
- `:width` sets character width of the interface
93
- `:height` sets character height of the interface
93
+ `width` sets character width of the interface
94
+ `height` sets character height of the interface
94
95
  Note: not setting a width or height will set the values to the terminal's reported width and height.
95
96
 
96
- `:foreground` sets the default foreground colour. (See Colours)
97
- `:background` sets the default background colour.
97
+ `foreground` sets the default foreground colour. (See Colours)
98
+ `background` sets the default background colour.
98
99
 
99
- `:cursor` a boolean specifying whether the cursor should show.
100
+ `cursor` a boolean specifying whether the cursor should show.
100
101
 
101
102
 
102
103
  ### On Defining Commands
103
104
 
104
- command :do_something, {
105
- entity: SomeClass,
106
- keypress: 's',
107
- keyword: 'start',
108
- arguments: [:some, { :values => :here }, "etc"] }
105
+ command 'do_something' do
106
+ entity SomeClass
107
+ keypress 's'
108
+ keyword 'start'
109
+ arguments [:some, { :values => :here }, "etc"]
110
+ end
109
111
 
110
112
  As above, commands have a name, a class which performs the action
111
113
  (you define this), and they can be invoked with a keypress or a keyword. At this time, Vedeu will call the `.dispatch` method on your class, passing any arguments you originally defined in the command. In the future, both the method called and the arguments could be dynamic.
@@ -113,7 +115,6 @@ As above, commands have a name, a class which performs the action
113
115
  ### On Defining Events
114
116
 
115
117
  event :event_name do |arg1, arg2|
116
-
117
118
  end
118
119
 
119
120
  One can define events which perform work or trigger other events. Vedeu has 3 built-in events which are namespaced with underscores as to hopefully not cause a collision with events you wish to create:
data/lib/vedeu.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  require 'date'
2
2
  require 'logger'
3
3
 
4
- require_relative 'vedeu/repository/command_repository'
5
- require_relative 'vedeu/repository/interface_repository'
4
+ require_relative 'vedeu/models/builders/command_builder'
5
+ require_relative 'vedeu/models/builders/interface_builder'
6
6
  require_relative 'vedeu/repository/event_repository'
7
7
  require_relative 'vedeu/support/coordinate'
8
8
  require_relative 'vedeu/support/exit'
@@ -11,14 +11,12 @@ require_relative 'vedeu/launcher'
11
11
  module Vedeu
12
12
  # :nocov:
13
13
  module ClassMethods
14
- def command(name, options = {})
15
- CommandRepository.create({ name: stringify_symbols(name) }
16
- .merge!(options))
14
+ def command(name, &block)
15
+ CommandBuilder.build(name, &block)
17
16
  end
18
17
 
19
- def interface(name, options = {})
20
- InterfaceRepository.create({ name: stringify_symbols(name) }
21
- .merge!(options))
18
+ def interface(name, &block)
19
+ InterfaceBuilder.build(name, &block)
22
20
  end
23
21
 
24
22
  def event(name, &block)
@@ -0,0 +1,31 @@
1
+ require_relative '../../repository/command_repository'
2
+
3
+ module Vedeu
4
+ class CommandBuilder
5
+ def self.build(name, &block)
6
+ new(name).build(&block)
7
+ end
8
+
9
+ def initialize(name)
10
+ @name = name.to_s
11
+ end
12
+
13
+ def build(&block)
14
+ self.instance_eval(&block)
15
+
16
+ CommandRepository.create(attributes)
17
+ end
18
+
19
+ private
20
+
21
+ attr_reader :name
22
+
23
+ def attributes
24
+ @attributes ||= { name: name }
25
+ end
26
+
27
+ def method_missing(method_name, arg, &block)
28
+ attributes[method_name] = arg
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,52 @@
1
+ require_relative '../colour'
2
+ require_relative '../../support/coordinate'
3
+ require_relative '../../repository/interface_repository'
4
+
5
+ module Vedeu
6
+ class InterfaceBuilder
7
+ def self.build(name, &block)
8
+ new(name).build(&block)
9
+ end
10
+
11
+ def initialize(name)
12
+ @name = name.to_s
13
+ end
14
+
15
+ def build(&block)
16
+ self.instance_eval(&block)
17
+
18
+ InterfaceRepository.create(attributes)
19
+ end
20
+
21
+ private
22
+
23
+ attr_reader :name
24
+
25
+ def attributes
26
+ user_attributes.merge!(overrides)
27
+ end
28
+
29
+ def overrides
30
+ @overrides = if user_attributes[:centred] == true
31
+ { x: geometry.left, y: geometry.top }
32
+ else
33
+ {}
34
+ end
35
+ end
36
+
37
+ def geometry
38
+ @_geometry ||= Coordinate.new({
39
+ height: user_attributes[:height],
40
+ width: user_attributes[:width],
41
+ })
42
+ end
43
+
44
+ def user_attributes
45
+ @attributes ||= { name: name, centred: false }
46
+ end
47
+
48
+ def method_missing(method_name, arg, &block)
49
+ user_attributes[method_name] = arg
50
+ end
51
+ end
52
+ end
@@ -18,14 +18,6 @@ module Vedeu
18
18
  @bg ||= Esc.background_colour(css_background)
19
19
  end
20
20
 
21
- def css_foreground
22
- @foreground
23
- end
24
-
25
- def css_background
26
- @background
27
- end
28
-
29
21
  def to_json(*args)
30
22
  as_hash.to_json
31
23
  end
@@ -34,11 +26,21 @@ module Vedeu
34
26
  foreground + background
35
27
  end
36
28
 
29
+ private
30
+
37
31
  def as_hash
38
32
  {
39
33
  foreground: css_foreground,
40
34
  background: css_background,
41
35
  }
42
36
  end
37
+
38
+ def css_foreground
39
+ @foreground
40
+ end
41
+
42
+ def css_background
43
+ @background
44
+ end
43
45
  end
44
46
  end
@@ -32,6 +32,10 @@ module Vedeu
32
32
  super(self.to_s)
33
33
  end
34
34
 
35
+ def geometry
36
+ @_geometry ||= Coordinate.new(attributes)
37
+ end
38
+
35
39
  def origin(index = 0)
36
40
  geometry.origin(index)
37
41
  end
@@ -73,9 +77,5 @@ module Vedeu
73
77
  def no_content?
74
78
  self.current.nil? || self.current.empty?
75
79
  end
76
-
77
- def geometry
78
- @_geometry ||= Coordinate.new(attributes)
79
- end
80
80
  end
81
81
  end
@@ -9,27 +9,15 @@ module Vedeu
9
9
  end
10
10
 
11
11
  def clear
12
- set_colour + clear_lines
12
+ interface.height.times.inject([interface.colour.to_s]) do |line, index|
13
+ line << interface.origin(index)
14
+ line << (' ' * interface.width)
15
+ line << interface.origin(index)
16
+ end.join
13
17
  end
14
18
 
15
19
  private
16
20
 
17
21
  attr_reader :interface
18
-
19
- def set_colour
20
- interface.colour.to_s
21
- end
22
-
23
- def clear_lines
24
- interface.height.times.inject([]) do |line, index|
25
- line << clear_line(index)
26
- end.join
27
- end
28
-
29
- def clear_line(index)
30
- interface.origin(index) +
31
- (' ' * interface.width) +
32
- interface.origin(index)
33
- end
34
22
  end
35
23
  end
@@ -11,8 +11,7 @@ module Vedeu
11
11
  end
12
12
 
13
13
  def render
14
- out = []
15
- out << ClearInterface.call(interface)
14
+ out = [ClearInterface.call(interface)]
16
15
  interface.lines.each_with_index do |line, index|
17
16
  out << interface.origin(index)
18
17
  out << line.to_s
@@ -2,6 +2,40 @@ require_relative 'text_adaptor'
2
2
 
3
3
  module Vedeu
4
4
  class HashParser
5
+ # Convert a hash into a collection of interfaces.
6
+ #
7
+ # @param output [Hash] a collection of interface pairs of the
8
+ # format:
9
+ #
10
+ # {
11
+ # interface_1: "A block of text containing\n" \
12
+ # "new line characters.\n",
13
+ # interface_2: "Some content destined for the " \
14
+ # "other interface.\n"
15
+ # }
16
+ #
17
+ # becomes:
18
+ #
19
+ # {
20
+ # interfaces: [
21
+ # {
22
+ # name: 'interface_1',
23
+ # lines: [{
24
+ # streams: { text: "A block of text containing" }
25
+ # }, {
26
+ # streams: { text: "new line characters." }
27
+ # }]
28
+ # }, {
29
+ # name: 'interface_2',
30
+ # lines: [{
31
+ # streams: { text: "Some content destined for the " \
32
+ # "other interface." }
33
+ # }]
34
+ # }
35
+ # ]
36
+ # }
37
+ #
38
+ # @return [Hash]
5
39
  def self.parse(output = {})
6
40
  new(output).parse
7
41
  end
@@ -1,5 +1,11 @@
1
1
  module Vedeu
2
2
  class TextAdaptor
3
+ # Convert a block of text into a collection of lines.
4
+ #
5
+ # @param text [String] a block of text containing new line (\n)
6
+ # characters.
7
+ #
8
+ # @return [Array]
3
9
  def self.adapt(text)
4
10
  new(text).adapt
5
11
  end
@@ -119,7 +119,9 @@ module Vedeu
119
119
  height: height,
120
120
  width: width,
121
121
  centred: centred,
122
+ top: top,
122
123
  bottom: bottom,
124
+ left: left,
123
125
  right: right,
124
126
  }
125
127
  end
@@ -30,48 +30,39 @@ module Example
30
30
  class App
31
31
  include Vedeu
32
32
 
33
- def self.example_position
34
- @_position = Vedeu::Coordinate.new({
35
- width: 40,
36
- height: 2,
37
- centered: true
38
- }).position
33
+ # assign the interface to a variable so that you can use it as a
34
+ # reference in another interface.
35
+ example = interface 'example' do
36
+ colour foreground: '#ff0000', background: '#000000'
37
+ cursor false
38
+ width 40
39
+ height 3
40
+ centred true
39
41
  end
40
42
 
41
- def self.command_position
42
- {
43
- y: example_position[:bottom],
44
- x: example_position[:x],
45
- height: 1,
46
- width: 40,
47
- centered: true
48
- }
43
+ # y and x come from the interface above, ensuring that 'command'
44
+ # is positioned under 'example' (see 'y')
45
+ interface 'command' do
46
+ colour foreground: '#aadd00', background: '#4040cc'
47
+ cursor true
48
+ width 40
49
+ height 1
50
+ y example.geometry.bottom
51
+ x example.geometry.left
52
+ centred false
49
53
  end
50
54
 
51
- interface 'example', {
52
- colour: {
53
- background: '#ff0000',
54
- foreground: '#000000'
55
- },
56
- cursor: false
57
- }.merge(example_position)
58
- interface 'command', {
59
- colour: {
60
- background: '#4040cc',
61
- foreground: '#aadd00'
62
- },
63
- cursor: true
64
- }.merge(command_position)
65
- command 'time', {
66
- entity: ExampleCommand,
67
- keyword: 'time',
68
- keypress: 't'
69
- }
70
- command 'exit', {
71
- entity: Vedeu::Exit,
72
- keyword: 'exit',
73
- keypress: 'q'
74
- }
55
+ command 'time' do
56
+ entity ExampleCommand
57
+ keyword 'time'
58
+ keypress 't'
59
+ end
60
+
61
+ command 'exit' do
62
+ entity Vedeu::Exit
63
+ keyword 'exit'
64
+ keypress 'q'
65
+ end
75
66
 
76
67
  event :key do |key|
77
68
  case key
@@ -0,0 +1,16 @@
1
+ require_relative '../../../../test_helper'
2
+ require_relative '../../../../../lib/vedeu/models/builders/command_builder'
3
+ require_relative '../../../../support/dummy_command'
4
+
5
+ module Vedeu
6
+ describe CommandBuilder do
7
+ it 'creates and stores a new command' do
8
+ command = CommandBuilder.build('dummy') do
9
+ entity DummyCommand
10
+ keyword 'dummy'
11
+ keypress 'd'
12
+ end
13
+ command.must_be_instance_of(Command)
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,73 @@
1
+ require_relative '../../../../test_helper'
2
+ require_relative '../../../../../lib/vedeu/models/builders/interface_builder'
3
+
4
+ module Vedeu
5
+ describe InterfaceBuilder do
6
+ it 'creates and stores a new interface' do
7
+ interface = InterfaceBuilder.build('widget') do
8
+ colour foreground: '#ff0000', background: '#5f0000'
9
+ cursor false
10
+ width 10
11
+ height 2
12
+ centred true
13
+ end
14
+ interface.must_be_instance_of(Interface)
15
+ end
16
+
17
+ it 'overrides x and y when centred is true' do
18
+ IO.console.stub :winsize, [10, 40] do
19
+ interface = InterfaceBuilder.build('widget') do
20
+ colour foreground: '#ff0000', background: '#5f0000'
21
+ cursor false
22
+ centred true
23
+ width 10
24
+ height 2
25
+ x 5
26
+ y 5
27
+ end
28
+ interface.x.must_equal(15)
29
+ interface.y.must_equal(4)
30
+ end
31
+ end
32
+
33
+ it 'uses x and y when centred is false' do
34
+ interface = InterfaceBuilder.build('widget') do
35
+ colour foreground: '#ff0000', background: '#5f0000'
36
+ cursor false
37
+ centred false
38
+ width 10
39
+ height 2
40
+ x 5
41
+ y 5
42
+ end
43
+ interface.x.must_equal(5)
44
+ interface.y.must_equal(5)
45
+ end
46
+
47
+ it 'allows interfaces to share behaviour' do
48
+ IO.console.stub :winsize, [10, 40] do
49
+ main = InterfaceBuilder.build('main') do
50
+ colour foreground: '#ff0000', background: '#000000'
51
+ cursor false
52
+ centred true
53
+ width 10
54
+ height 2
55
+ end
56
+ status = InterfaceBuilder.build('status') do
57
+ colour foreground: 'aadd00', background: '#4040cc'
58
+ cursor true
59
+ centred true
60
+ width 10
61
+ height 1
62
+ y main.geometry.bottom
63
+ x main.geometry.left
64
+ end
65
+
66
+ main.x.must_equal(15)
67
+ main.y.must_equal(4)
68
+ status.x.must_equal(15)
69
+ status.y.must_equal(5)
70
+ end
71
+ end
72
+ end
73
+ end
@@ -27,37 +27,35 @@ module Vedeu
27
27
  end
28
28
  end
29
29
 
30
- describe '#css_background' do
31
- it 'returns an escape sequence' do
30
+ describe '#to_json' do
31
+ it 'returns the model as JSON' do
32
32
  Colour.new({
33
+ foreground: '#ff0000',
33
34
  background: '#000000'
34
- }).css_background.must_equal('#000000')
35
- end
36
-
37
- it 'returns an empty string if the value is nil' do
38
- Colour.new.css_background.must_equal('')
35
+ }).to_json.must_equal(
36
+ "{\"foreground\":\"#ff0000\",\"background\":\"#000000\"}"
37
+ )
39
38
  end
40
- end
41
39
 
42
- describe '#css_foreground' do
43
- it 'returns an escape sequence' do
40
+ it 'returns an escape sequence when the foreground is missing' do
44
41
  Colour.new({
45
- foreground: '#ff0000'
46
- }).css_foreground.must_equal('#ff0000')
47
- end
48
-
49
- it 'returns an empty string if the value is nil' do
50
- Colour.new.css_foreground.must_equal('')
42
+ background: '#000000'
43
+ }).to_json.must_equal(
44
+ "{\"foreground\":\"\",\"background\":\"#000000\"}"
45
+ )
51
46
  end
52
- end
53
47
 
54
- describe '#to_json' do
55
- it 'returns the model as JSON' do
48
+ it 'returns an escape sequence when the background is missing' do
56
49
  Colour.new({
57
50
  foreground: '#ff0000',
58
- background: '#000000'
59
51
  }).to_json.must_equal(
60
- "{\"foreground\":\"#ff0000\",\"background\":\"#000000\"}"
52
+ "{\"foreground\":\"#ff0000\",\"background\":\"\"}"
53
+ )
54
+ end
55
+
56
+ it 'returns an empty string when both are missing' do
57
+ Colour.new.to_json.must_equal(
58
+ "{\"foreground\":\"\",\"background\":\"\"}"
61
59
  )
62
60
  end
63
61
  end
@@ -86,17 +84,5 @@ module Vedeu
86
84
  Colour.new.to_s.must_equal('')
87
85
  end
88
86
  end
89
-
90
- describe '#as_hash' do
91
- it 'returns the model as a Hash' do
92
- Colour.new({
93
- foreground: '#ff0000',
94
- background: '#000000'
95
- }).as_hash.must_equal({
96
- foreground: '#ff0000',
97
- background: '#000000'
98
- })
99
- end
100
- end
101
87
  end
102
88
  end
@@ -75,6 +75,17 @@ module Vedeu
75
75
  end
76
76
  end
77
77
 
78
+ describe '#geometry' do
79
+ it 'delegates to the Coordinate class' do
80
+ interface = Interface.new({
81
+ name: '#geometry',
82
+ width: 5,
83
+ height: 5
84
+ })
85
+ interface.geometry.must_be_instance_of(Coordinate)
86
+ end
87
+ end
88
+
78
89
  describe '#origin' do
79
90
  it 'delegates to the Coordinate class to get the origin' do
80
91
  interface = Interface.new({
@@ -12,14 +12,19 @@ module Vedeu
12
12
  it 'returns the content for the interface' do
13
13
  interface = Interface.new({
14
14
  name: '.call',
15
- width: 5,
15
+ width: 32,
16
16
  height: 2,
17
- lines: 'RenderInterface.call'
17
+ lines: 'RenderInterface.call',
18
+ lines: [
19
+ { streams: { text: '1d194f184a0b937c71bfcbdf13511992' } },
20
+ { streams: { text: '8787092f681b149d645df64e73d3cb37' } }
21
+ ]
18
22
  })
19
23
  RenderInterface.call(interface).must_equal(
20
- "\e[1;1H \e[1;1H" \
21
- "\e[2;1H \e[2;1H" \
22
- "\e[1;1HRenderInterface.call"
24
+ "\e[1;1H \e[1;1H" \
25
+ "\e[2;1H \e[2;1H" \
26
+ "\e[1;1H1d194f184a0b937c71bfcbdf13511992" \
27
+ "\e[2;1H8787092f681b149d645df64e73d3cb37"
23
28
  )
24
29
  end
25
30
  end
@@ -10,10 +10,21 @@ module Vedeu
10
10
  dummy: 'More content...'
11
11
  }).must_equal({
12
12
  interfaces: [
13
- { name: 'test', lines: [
14
- { streams: { text: 'Some content...' } }] },
15
- { name: 'dummy', lines: [
16
- { streams: { text: 'More content...' } }] }
13
+ {
14
+ name: 'test',
15
+ lines: [
16
+ {
17
+ streams: { text: 'Some content...' }
18
+ }
19
+ ]
20
+ }, {
21
+ name: 'dummy',
22
+ lines: [
23
+ {
24
+ streams: { text: 'More content...' }
25
+ }
26
+ ]
27
+ }
17
28
  ]
18
29
  })
19
30
  end
@@ -23,11 +34,21 @@ module Vedeu
23
34
  dummy: 'Some content...'
24
35
  }).must_equal({
25
36
  interfaces: [
26
- { name: 'dummy', lines: [
27
- { streams: { text: 'Some content...' } }] }
37
+ {
38
+ name: 'dummy',
39
+ lines: [
40
+ {
41
+ streams: { text: 'Some content...' }
42
+ }
43
+ ]
44
+ }
28
45
  ]
29
46
  })
30
47
  end
48
+
49
+ it 'returns a Hash when the output is empty' do
50
+ HashParser.parse({}).must_equal({ interfaces: [] })
51
+ end
31
52
  end
32
53
  end
33
54
  end
@@ -6,17 +6,43 @@ module Vedeu
6
6
  describe '.adapt' do
7
7
  it 'returns an empty collection for an empty string' do
8
8
  TextAdaptor.adapt('').must_be_empty
9
+
10
+ TextAdaptor.adapt('').must_equal([])
9
11
  end
10
12
 
11
13
  it 'returns a single line' do
12
14
  text = "This is a single line of text.\n"
13
15
  TextAdaptor.adapt(text).size.must_equal(1)
16
+
17
+ TextAdaptor.adapt(text).must_equal(
18
+ [
19
+ {
20
+ streams: { text: 'This is a single line of text.' }
21
+ }
22
+ ]
23
+ )
14
24
  end
15
25
 
16
26
  it 'returns multiple lines' do
17
27
  text = "Lorem ipm olor sit aet,\nConsctetur adipiscing.\n" \
18
28
  "Curitur aiquet, trpis id dui.\n\nCondum elemum.\n"
19
29
  TextAdaptor.adapt(text).size.must_equal(5)
30
+
31
+ TextAdaptor.adapt(text).must_equal(
32
+ [
33
+ {
34
+ streams: { text: 'Lorem ipm olor sit aet,' }
35
+ }, {
36
+ streams: { text: 'Consctetur adipiscing.' }
37
+ }, {
38
+ streams: { text: 'Curitur aiquet, trpis id dui.' }
39
+ }, {
40
+ streams: { text: '' }
41
+ }, {
42
+ streams: { text: 'Condum elemum.' }
43
+ }
44
+ ]
45
+ )
20
46
  end
21
47
  end
22
48
  end
@@ -351,7 +351,9 @@ module Vedeu
351
351
  height: 6,
352
352
  width: 18,
353
353
  centred: true,
354
+ top: 9,
354
355
  bottom: 15,
356
+ left: 31,
355
357
  right: 49,
356
358
  })
357
359
  end
@@ -365,7 +367,9 @@ module Vedeu
365
367
  height: 6,
366
368
  width: 18,
367
369
  centred: false,
370
+ top: 1,
368
371
  bottom: 7,
372
+ left: 7,
369
373
  right: 25,
370
374
  })
371
375
  end
@@ -378,7 +382,9 @@ module Vedeu
378
382
  height: 6,
379
383
  width: 18,
380
384
  centred: false,
385
+ top: 5,
381
386
  bottom: 11,
387
+ left: 1,
382
388
  right: 19,
383
389
  })
384
390
  end
@@ -391,7 +397,9 @@ module Vedeu
391
397
  height: 6,
392
398
  width: 18,
393
399
  centred: false,
400
+ top: 1,
394
401
  bottom: 7,
402
+ left: 1,
395
403
  right: 19,
396
404
  })
397
405
  end
@@ -1,8 +1,39 @@
1
1
  #!/usr/bin/env ruby
2
+ require_relative '../../lib/vedeu/support/translator'
2
3
 
4
+ values = ["00", "5f", "87", "af", "d7", "ff"]
5
+ codes = {}
6
+
7
+ values.each do |r|
8
+ values.each do |g|
9
+ values.each do |b|
10
+ value = ["#", r, g, b].join
11
+ trans = Vedeu::Translator.translate(value)
12
+ codes[trans] = value
13
+ end
14
+ end
15
+ end
16
+
17
+ # basic
3
18
  30.upto(38) do |fg|
4
19
  40.upto(48) do |bg|
5
20
  print "\e[38;2;#{fg}m\e[48;2;#{bg}mVedeu\e[0m"
6
21
  end
7
22
  print "\n"
8
23
  end
24
+
25
+ # foreground
26
+ codes.each_slice(6) do |c|
27
+ c.each do |k, v|
28
+ printf "\e[48;2;49m \e[38;5;%s30m%s %3s ", k, v, k
29
+ end
30
+ print "\e[48;2;49m\e[38;2;39m\n"
31
+ end
32
+
33
+ # background
34
+ codes.each_slice(6) do |c|
35
+ c.each do |k, v|
36
+ printf "\e[48;5;%sm \e[38;2;30m%s %3s ", k, v, k
37
+ end
38
+ print "\e[48;2;49m\e[38;2;39m\n"
39
+ end
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.0.37'
7
+ spec.version = '0.0.38'
8
8
  spec.authors = ['Gavin Laking']
9
9
  spec.email = ['gavinlaking@gmail.com']
10
10
  spec.summary = %q{A terminal case of wonderland.}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vedeu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.37
4
+ version: 0.0.38
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gavin Laking
@@ -177,6 +177,8 @@ files:
177
177
  - lib/vedeu/models/attributes/interface_collection.rb
178
178
  - lib/vedeu/models/attributes/line_collection.rb
179
179
  - lib/vedeu/models/attributes/stream_collection.rb
180
+ - lib/vedeu/models/builders/command_builder.rb
181
+ - lib/vedeu/models/builders/interface_builder.rb
180
182
  - lib/vedeu/models/colour.rb
181
183
  - lib/vedeu/models/command.rb
182
184
  - lib/vedeu/models/composition.rb
@@ -219,6 +221,8 @@ files:
219
221
  - test/lib/vedeu/models/attributes/interface_collection_test.rb
220
222
  - test/lib/vedeu/models/attributes/line_collection_test.rb
221
223
  - test/lib/vedeu/models/attributes/stream_collection_test.rb
224
+ - test/lib/vedeu/models/builders/command_builder_test.rb
225
+ - test/lib/vedeu/models/builders/interface_builder_test.rb
222
226
  - test/lib/vedeu/models/colour_test.rb
223
227
  - test/lib/vedeu/models/command_test.rb
224
228
  - test/lib/vedeu/models/composition_test.rb
@@ -303,6 +307,8 @@ test_files:
303
307
  - test/lib/vedeu/models/attributes/interface_collection_test.rb
304
308
  - test/lib/vedeu/models/attributes/line_collection_test.rb
305
309
  - test/lib/vedeu/models/attributes/stream_collection_test.rb
310
+ - test/lib/vedeu/models/builders/command_builder_test.rb
311
+ - test/lib/vedeu/models/builders/interface_builder_test.rb
306
312
  - test/lib/vedeu/models/colour_test.rb
307
313
  - test/lib/vedeu/models/command_test.rb
308
314
  - test/lib/vedeu/models/composition_test.rb