vedeu 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2990a71171d7d18e057affb7e509d13267efbcfb
4
- data.tar.gz: 65566020c8f8fa0a069bcf3d8ebff832e5ac378d
3
+ metadata.gz: 54bb0cd0826751a7fb718c0bd4a68aed54a12d1e
4
+ data.tar.gz: 06d71adf59c0300bd27812b07593bcfdfb71114a
5
5
  SHA512:
6
- metadata.gz: c2a5b89fc277c8200f574717dd643c2c9b1b689f15f9a913a13ad67ac6f275fa4c7755493eb7452022a53e0941bb97574bdf2e692a1bbdabb93001a2d9a5e674
7
- data.tar.gz: a1259cc57c8a5425171af9f16707ea73daa66e709e71dc5ea78ce3d9af756976d55aa8cb3b659cab92469edd1896174ce948984b1e4cda4fc529221d34a24f61
6
+ metadata.gz: 072569691f768aee22091160266ea4cb944865ecb186eb62eec47617f39a28d30d5629ff72b2c69919f82dbc3c41bb562dbef2afa00daaf91d466db358465a4b
7
+ data.tar.gz: 42074a95c54fedb6143ad082188185ca2e5bd6d60d0f092cb9e2d16bf9bfba2b49b40c0e1a7a23b0e218473415128cfe5d2d17bb7923fa3be8e9d5449542be2f
data/Guardfile CHANGED
@@ -18,8 +18,3 @@ guard :bundler do
18
18
  watch('Gemfile')
19
19
  watch(/^.+\.gemspec/)
20
20
  end
21
-
22
- guard 'yard' do
23
- watch(%r{docs/.+\.md})
24
- watch(%r{lib/.+\.rb})
25
- end
@@ -17,8 +17,11 @@ module Vedeu
17
17
 
18
18
  # Define a keymap called '_global_' which will respond no matter which
19
19
  # interface is in focus.
20
+ #
21
+ # @note
22
+ # Initially, no keys are registered with the global keymap.
20
23
  Vedeu::DSL::Keymap.keymap('_global_') do
21
-
24
+ # ...
22
25
  end
23
26
 
24
27
  end # Vedeu
@@ -4,6 +4,7 @@ require 'vedeu/dsl/components/keymap'
4
4
 
5
5
  module Vedeu
6
6
 
7
+ # A container class for keys associated with a particular interface.
7
8
  class Keymap
8
9
 
9
10
  include Vedeu::Model
@@ -79,6 +80,9 @@ module Vedeu
79
80
  keys.any? { |key| key.input == input }
80
81
  end
81
82
 
83
+ # Triggers the action associated with the key, if it is registered with this
84
+ # keymap.
85
+ #
82
86
  # @param input [String|Symbol]
83
87
  # @return [Array|FalseClass]
84
88
  def use(input)
@@ -93,6 +97,8 @@ module Vedeu
93
97
 
94
98
  private
95
99
 
100
+ # Checks that the provided key is not already registered with this keymap.
101
+ #
96
102
  # @param key [Vedeu::Key]
97
103
  # @return [Boolean]
98
104
  def valid?(key)
@@ -1,7 +1,12 @@
1
1
  module Vedeu
2
2
 
3
+ # Maps keys to keymaps.
3
4
  class Mapper
4
5
 
6
+ # Takes a key as a keypress and sends it to registered keymaps. If found,
7
+ # the associated action is fired, if not, we move to the next keymap or
8
+ # return false.
9
+ #
5
10
  # @param key [NilClass|String|Symbol]
6
11
  # @param name [NilClass|String]
7
12
  # @return [Boolean]
@@ -11,6 +16,9 @@ module Vedeu
11
16
  new(key, name).keypress
12
17
  end
13
18
 
19
+ # Checks a key is valid; i.e. not already registered to a keymap. If the
20
+ # key is registered, then the key is invalid and cannot be used again.
21
+ #
14
22
  # @param key [NilClass|String|Symbol]
15
23
  # @param name [NilClass|String]
16
24
  # @return [Boolean]
@@ -93,11 +101,15 @@ module Vedeu
93
101
  end
94
102
  alias_method :interface, :name
95
103
 
104
+ # Return the name of the global keymap.
105
+ #
96
106
  # @return [String]
97
107
  def global
98
108
  '_global_'
99
109
  end
100
110
 
111
+ # Return the name of the system keymap.
112
+ #
101
113
  # @return [String]
102
114
  def system
103
115
  '_system_'
@@ -66,7 +66,7 @@ module Vedeu
66
66
 
67
67
  # @return []
68
68
  def configuration
69
- Configuration.configure(argv)
69
+ Vedeu::Configuration.configure(argv)
70
70
  end
71
71
 
72
72
  end # Launcher
@@ -34,34 +34,6 @@ module Vedeu
34
34
  attr_reader :attributes
35
35
  attr_writer :x, :y
36
36
 
37
- class << self
38
-
39
- # Build models using a simple DSL when a block is given, otherwise returns
40
- # a new instance of the class including this module.
41
- #
42
- # @see Vedeu::Geometry#initialize
43
- def build(attributes = {}, &block)
44
- attributes = defaults.merge(attributes)
45
-
46
- model = new(attributes)
47
- model.deputy(attributes[:client]).instance_eval(&block) if block_given?
48
- model
49
- end
50
-
51
- private
52
-
53
- # The default values for a new instance of this class.
54
- #
55
- # @return [Hash]
56
- def defaults
57
- {
58
- client: nil,
59
- name: '',
60
- }
61
- end
62
-
63
- end
64
-
65
37
  # Returns a new instance of Geometry.
66
38
  #
67
39
  # @param attributes [Hash]
@@ -344,6 +316,7 @@ module Vedeu
344
316
  def defaults
345
317
  {
346
318
  centred: false,
319
+ client: nil,
347
320
  height: Terminal.height,
348
321
  name: '',
349
322
  width: Terminal.width,
@@ -26,22 +26,6 @@ module Vedeu
26
26
 
27
27
  class << self
28
28
 
29
- # @option attributes collection []
30
- # @option attributes client []
31
- # @option attributes name []
32
- # @option attributes current []
33
- # @option attributes selected []
34
- def build(attributes = {}, &block)
35
- attributes = defaults.merge(attributes)
36
-
37
- model = new(attributes[:collection],
38
- attributes[:name],
39
- attributes[:current],
40
- attributes[:selected])
41
- model.deputy(attributes[:client]).instance_eval(&block) if block_given?
42
- model
43
- end
44
-
45
29
  # Register a menu by name which will display a collection of items for
46
30
  # your users to select; and provide interactivity within your application.
47
31
  #
@@ -68,36 +52,23 @@ module Vedeu
68
52
  build({ name: name }, &block).store
69
53
  end
70
54
 
71
- private
72
-
73
- # The default values for a new instance of this class.
74
- #
75
- # @return [Hash]
76
- def defaults
77
- {
78
- client: nil,
79
- collection: [],
80
- current: 0,
81
- name: '',
82
- selected: nil,
83
- }
84
- end
85
-
86
55
  end
87
56
 
88
57
  # Returns a new instance of Menu.
89
58
  #
90
- # @param collection [Array]
91
- # @param name [String]
92
- # @param current [Fixnum]
93
- # @param selected [Fixnum|NilClass]
59
+ # @param attributes [Hash]
60
+ # @option attributes collection [Array]
61
+ # @option attributes name [String]
62
+ # @option attributes current [Fixnum]
63
+ # @option attributes selected [Fixnum|NilClass]
94
64
  # @return [Menu]
95
- def initialize(collection = [], name = '', current = 0, selected = nil)
96
- @collection = collection
97
- @name = name
98
- @current = current
99
- @selected = selected
65
+ def initialize(attributes = {})
66
+ @attributes = defaults.merge(attributes)
67
+ @collection = @attributes[:collection]
68
+ @current = @attributes[:current]
69
+ @name = @attributes[:name]
100
70
  @repository = Vedeu.menus
71
+ @selected = @attributes[:selected]
101
72
  end
102
73
 
103
74
  # Returns the item from the collection which shares the same index as the
@@ -227,6 +198,19 @@ module Vedeu
227
198
 
228
199
  private
229
200
 
201
+ # The default values for a new instance of this class.
202
+ #
203
+ # @return [Hash]
204
+ def defaults
205
+ {
206
+ client: nil,
207
+ collection: [],
208
+ current: 0,
209
+ name: '',
210
+ selected: nil,
211
+ }
212
+ end
213
+
230
214
  end # Menu
231
215
 
232
216
  end # Vedeu
@@ -10,6 +10,21 @@ module Vedeu
10
10
 
11
11
  module ClassMethods
12
12
 
13
+ # Build models using a simple DSL when a block is given, otherwise returns
14
+ # a new instance of the class including this module.
15
+ #
16
+ # @param attributes [Hash] A collection of attributes specific to the
17
+ # model.
18
+ # @param block [Proc] The block passed to the build method.
19
+ # @return [Object] An instance of the model.
20
+ def build(attributes = {}, &block)
21
+ attributes = defaults.merge(attributes)
22
+
23
+ model = new(attributes)
24
+ model.deputy(attributes[:client]).instance_eval(&block) if block_given?
25
+ model
26
+ end
27
+
13
28
  # Provide a convenient way to define the child or children of a model.
14
29
  #
15
30
  # @param klass [Class] The member (singular) or collection (multiple)
@@ -21,6 +36,18 @@ module Vedeu
21
36
  alias_method :member, :child
22
37
  alias_method :collection, :child
23
38
 
39
+ private
40
+
41
+ # The default values for a new instance of this class.
42
+ #
43
+ # @return [Hash]
44
+ def defaults
45
+ {
46
+ client: nil,
47
+ name: '',
48
+ }
49
+ end
50
+
24
51
  end # ClassMethods
25
52
 
26
53
  # When this module is included in a class, provide ClassMethods as class
@@ -22,50 +22,21 @@ module Vedeu
22
22
  attr_reader :interfaces
23
23
  alias_method :value, :interfaces
24
24
 
25
- class << self
26
-
27
- # @param attributes [Hash]
28
- # @option attributes client []
29
- # @option attributes colour []
30
- # @option attributes interfaces []
31
- # @option attributes style []
32
- # @param block [Proc]
33
- # @return [Class]
34
- def build(attributes = {}, &block)
35
- attrs = defaults.merge(attributes)
36
-
37
- model = new(attrs[:interfaces], attrs[:colour], attrs[:style])
38
- model.deputy(attributes[:client]).instance_eval(&block) if block_given?
39
- model
40
- end
41
-
42
- private
43
-
44
- # The default values for a new instance of this class.
45
- #
46
- # @return [Hash]
47
- def defaults
48
- {
49
- client: nil,
50
- colour: nil,
51
- interfaces: [],
52
- style: nil,
53
- }
54
- end
55
-
56
- end
57
-
58
25
  # Returns a new instance of Composition.
59
26
  #
60
- # @param interfaces [Interfaces]
27
+ # @param attributes [Hash]
28
+ # @option attributes colour []
29
+ # @option attributes interfaces []
30
+ # @option attributes style []
61
31
  # @return [Composition]
62
- def initialize(interfaces = [], colour = nil, style = nil)
63
- @interfaces = interfaces
64
- @colour = colour
65
- @style = style
32
+ def initialize(attributes = {})
33
+ @attributes = defaults.merge(attributes)
34
+ @interfaces = @attributes[:interfaces]
35
+ @colour = Colour.coerce(@attributes[:colour])
36
+ @style = Style.coerce(@attributes[:style])
66
37
  end
67
38
 
68
- # @param child []
39
+ # @param child [Vedeu::Interface]
69
40
  # @return []
70
41
  def add(child)
71
42
  @interfaces = interfaces.add(child)
@@ -83,6 +54,20 @@ module Vedeu
83
54
  collection.coerce(@interfaces, self)
84
55
  end
85
56
 
57
+ private
58
+
59
+ # The default values for a new instance of this class.
60
+ #
61
+ # @return [Hash]
62
+ def defaults
63
+ {
64
+ client: nil,
65
+ colour: nil,
66
+ interfaces: [],
67
+ style: nil,
68
+ }
69
+ end
70
+
86
71
  end # Composition
87
72
 
88
73
  end # Vedeu
@@ -47,69 +47,28 @@ module Vedeu
47
47
  :height,
48
48
  :origin
49
49
 
50
- class << self
51
-
52
- # Build interfaces using a simple DSL.
53
- # If a name is provided as part of the attributes, we check the repository
54
- # for an interface of the same name and update it from the new attributes
55
- # provided, or if a block is given, new parameters set via the DSL.
56
- #
57
- # @param attributes [Hash]
58
- # @option attributes client []
59
- # @option attributes colour []
60
- # @option attributes lines []
61
- # @option attributes name []
62
- # @option attributes parent []
63
- # @option attributes style []
64
- # @param block [Proc]
65
- # @return [Class]
66
- def build(attributes = {}, &block)
67
- attributes = defaults.merge(attributes)
68
- model = new(attributes[:name],
69
- attributes[:lines],
70
- attributes[:parent],
71
- attributes[:colour],
72
- attributes[:style])
73
- model.deputy(attributes[:client]).instance_eval(&block) if block_given?
74
- model
75
- end
76
-
77
- private
78
-
79
- # The default values for a new instance of this class.
80
- #
81
- # @return [Hash]
82
- def defaults
83
- {
84
- client: nil,
85
- colour: nil,
86
- lines: [],
87
- name: '',
88
- parent: nil,
89
- style: nil,
90
- }
91
- end
92
- end
93
-
94
50
  # Return a new instance of Interface.
95
51
  #
96
- # @param name [String]
97
- # @param lines [Vedeu::Lines]
98
- # @param parent [Vedeu::Composition]
99
- # @param colour [Vedeu::Colour]
100
- # @param style [Vedeu::Style]
101
- # @return [Interface]
102
- def initialize(name = '', lines = [], parent = nil, colour = nil, style = nil)
103
- @name = name
104
- @lines = lines
105
- @parent = parent
106
- @colour = colour
107
- @style = style
108
-
109
- @delay = 0.0
110
- @group = ''
111
-
52
+ # @param attributes [Hash]
53
+ # @option attributes colour [Vedeu::Colour]
54
+ # @option attributes delay [Float]
55
+ # @option attributes group [String]
56
+ # @option attributes lines [Vedeu::Lines]
57
+ # @option attributes name [String]
58
+ # @option attributes parent [Vedeu::Composition]
59
+ # @option attributes style [Vedeu::Style]
60
+ # @return [Vedeu::Interface]
61
+ def initialize(attributes = {})
62
+ @attributes = defaults.merge(attributes)
63
+
64
+ @colour = Colour.coerce(@attributes[:colour])
65
+ @delay = @attributes[:delay]
66
+ @group = @attributes[:group]
67
+ @lines = @attributes[:lines]
68
+ @name = @attributes[:name]
69
+ @parent = @attributes[:parent]
112
70
  @repository = Vedeu.interfaces
71
+ @style = Style.coerce(@attributes[:style])
113
72
  end
114
73
 
115
74
  # @param child []
@@ -188,6 +147,24 @@ module Vedeu
188
147
  store_group
189
148
  end
190
149
 
150
+ private
151
+
152
+ # The default values for a new instance of this class.
153
+ #
154
+ # @return [Hash]
155
+ def defaults
156
+ {
157
+ client: nil,
158
+ colour: nil,
159
+ delay: 0.0,
160
+ group: '',
161
+ lines: [],
162
+ name: '',
163
+ parent: nil,
164
+ style: nil,
165
+ }
166
+ end
167
+
191
168
  end # Interface
192
169
 
193
170
  end # Vedeu
@@ -23,48 +23,19 @@ module Vedeu
23
23
 
24
24
  alias_method :value, :streams
25
25
 
26
- class << self
27
-
28
- # @option attributes streams []
29
- # @option attributes parent []
30
- # @option attributes colour []
31
- # @option attributes style []
32
- # @option attributes client []
33
- def build(attributes = {}, &block)
34
- attributes = defaults.merge(attributes)
35
-
36
- model = new(attributes[:streams],
37
- attributes[:parent],
38
- attributes[:colour],
39
- attributes[:style])
40
- model.deputy(attributes[:client]).instance_eval(&block) if block_given?
41
- model
42
- end
43
-
44
- private
45
-
46
- # The default values for a new instance of this class.
47
- #
48
- # @return [Hash]
49
- def defaults
50
- {
51
- client: nil,
52
- colour: nil,
53
- parent: nil,
54
- streams: [],
55
- style: nil,
56
- }
57
- end
58
- end
59
-
60
26
  # Returns a new instance of Line.
61
27
  #
28
+ # @option attributes streams [Vedeu::Streams]
29
+ # @option attributes parent [Vedeu::Interface]
30
+ # @option attributes colour [Vedeu::Colour]
31
+ # @option attributes style [Vedeu::Style]
62
32
  # @return [Line]
63
- def initialize(streams = [], parent = nil, colour = nil, style = nil)
64
- @colour = colour
65
- @parent = parent
66
- @streams = streams
67
- @style = style
33
+ def initialize(attributes = {})
34
+ @attributes = defaults.merge(attributes)
35
+ @colour = Colour.coerce(@attributes[:colour])
36
+ @parent = @attributes[:parent]
37
+ @streams = @attributes[:streams]
38
+ @style = Style.coerce(@attributes[:style])
68
39
  end
69
40
 
70
41
  # @param child []
@@ -116,6 +87,21 @@ module Vedeu
116
87
  parent.width if parent
117
88
  end
118
89
 
90
+ private
91
+
92
+ # The default values for a new instance of this class.
93
+ #
94
+ # @return [Hash]
95
+ def defaults
96
+ {
97
+ client: nil,
98
+ colour: nil,
99
+ parent: nil,
100
+ streams: [],
101
+ style: nil,
102
+ }
103
+ end
104
+
119
105
  end # Line
120
106
 
121
107
  end # Vedeu
@@ -23,53 +23,21 @@ module Vedeu
23
23
  alias_method :data, :value
24
24
  alias_method :text, :value
25
25
 
26
- class << self
27
-
28
- # @option attributes value []
29
- # @option attributes parent []
30
- # @option attributes colour []
31
- # @option attributes style []
32
- # @option attributes client []
33
- def build(attributes = {}, &block)
34
- attributes = defaults.merge(attributes)
35
-
36
- model = new(attributes[:value],
37
- attributes[:parent],
38
- attributes[:colour],
39
- attributes[:style])
40
- model.deputy(attributes[:client]).instance_eval(&block) if block_given?
41
- model
42
- end
43
-
44
- private
45
-
46
- # The default values for a new instance of this class.
47
- #
48
- # @return [Hash]
49
- def defaults
50
- {
51
- client: nil,
52
- colour: nil,
53
- parent: nil,
54
- style: nil,
55
- value: '',
56
- }
57
- end
58
-
59
- end
60
-
61
26
  # Returns a new instance of Stream.
62
27
  #
63
- # @param value [String]
64
- # @param parent [Vedeu::Line]
65
- # @param colour [Vedeu::Colour]
66
- # @param style [Vedeu::Style]
28
+ # @param attributes [Hash]
29
+ # @option attributes value [String]
30
+ # @option attributes parent [Vedeu::Line]
31
+ # @option attributes colour [Vedeu::Colour]
32
+ # @option attributes style [Vedeu::Style]
33
+ # @option attributes client [Object]
67
34
  # @return [Vedeu::Stream]
68
- def initialize(value = '', parent = nil, colour = nil, style = nil)
69
- @value = value
70
- @parent = parent
71
- @colour = colour
72
- @style = style
35
+ def initialize(attributes = {})
36
+ @attributes = defaults.merge(attributes)
37
+ @colour = Colour.coerce(@attributes[:colour])
38
+ @parent = @attributes[:parent]
39
+ @style = Style.coerce(@attributes[:style])
40
+ @value = @attributes[:value]
73
41
  end
74
42
 
75
43
  # @param child [Vedeu::Stream]
@@ -126,6 +94,21 @@ module Vedeu
126
94
  parent.width if parent
127
95
  end
128
96
 
97
+ private
98
+
99
+ # The default values for a new instance of this class.
100
+ #
101
+ # @return [Hash]
102
+ def defaults
103
+ {
104
+ client: nil,
105
+ colour: nil,
106
+ parent: nil,
107
+ style: nil,
108
+ value: '',
109
+ }
110
+ end
111
+
129
112
  end # Stream
130
113
 
131
114
  end # Vedeu
@@ -17,31 +17,6 @@ module Vedeu
17
17
  attr_accessor :attributes
18
18
  attr_reader :name
19
19
 
20
- class << self
21
-
22
- # @see Vedeu::Border#initialize
23
- def build(attributes = {}, &block)
24
- attributes = defaults.merge(attributes)
25
-
26
- model = new(attributes)
27
- model.deputy(attributes[:client]).instance_eval(&block) if block_given?
28
- model
29
- end
30
-
31
- private
32
-
33
- # The default values for a new instance of this class.
34
- #
35
- # @return [Hash]
36
- def defaults
37
- {
38
- client: nil,
39
- name: '',
40
- }
41
- end
42
-
43
- end
44
-
45
20
  # Returns a new instance of Border.
46
21
  #
47
22
  # @param attributes [Hash]
@@ -375,6 +350,7 @@ module Vedeu
375
350
  {
376
351
  bottom_left: "\x6D", # └
377
352
  bottom_right: "\x6A", # ┘
353
+ client: nil,
378
354
  colour: {},
379
355
  enabled: false,
380
356
  horizontal: "\x71", # ─
@@ -85,7 +85,7 @@ module Vedeu
85
85
  # @return [Vedeu::Lines]
86
86
  def to_line_objects(text_as_lines)
87
87
  line_objects = Array(text_as_lines).map do |text_line|
88
- stream = Vedeu::Stream.new(text_line)
88
+ stream = Vedeu::Stream.new({ value: text_line })
89
89
  line = Vedeu::Line.new
90
90
  stream.parent = line
91
91
  line.add(stream)
@@ -8,7 +8,13 @@ module Vedeu
8
8
 
9
9
  let(:described) { Vedeu::DSL::Menu }
10
10
  let(:instance) { described.new(model) }
11
- let(:model) { Vedeu::Menu.new(collection, menu_name) }
11
+ let(:model) { Vedeu::Menu.new(attributes) }
12
+ let(:attributes) {
13
+ {
14
+ collection: collection,
15
+ name: menu_name,
16
+ }
17
+ }
12
18
  let(:collection) { [:sodium, :magnesium, :aluminium, :silicon] }
13
19
  let(:menu_name) { 'elements' }
14
20
 
@@ -8,7 +8,15 @@ module Vedeu
8
8
 
9
9
  let(:described) { Vedeu::DSL::Line }
10
10
  let(:instance) { described.new(model) }
11
- let(:model) { Vedeu::Line.new(streams, parent, colour, style) }
11
+ let(:model) { Vedeu::Line.new(attributes) }
12
+ let(:attributes){
13
+ {
14
+ streams: streams,
15
+ parent: parent,
16
+ colour: colour,
17
+ style: style,
18
+ }
19
+ }
12
20
  let(:client) {}
13
21
  let(:streams) { [] }
14
22
  let(:parent) { Vedeu::Interface.new }
@@ -18,7 +26,7 @@ module Vedeu
18
26
  describe '#initialize' do
19
27
  subject { instance }
20
28
 
21
- it { subject.must_be_instance_of(Vedeu::DSL::Line) }
29
+ it { subject.must_be_instance_of(described) }
22
30
  it { subject.instance_variable_get('@model').must_equal(model) }
23
31
  it { subject.instance_variable_get('@client').must_equal(client) }
24
32
  end
@@ -4,28 +4,33 @@ module Vedeu
4
4
 
5
5
  describe Launcher do
6
6
 
7
- let(:described) { Launcher.new }
7
+ let(:described) { Vedeu::Launcher }
8
+ let(:instance) { described.new }
8
9
 
9
10
  before do
10
- Configuration.stubs(:configure)
11
+ Configuration.stubs(:configure)#.returns(test_configuration)
11
12
  Application.stubs(:start)
12
13
  Kernel.stubs(:exit)
13
14
  Kernel.stubs(:puts)
14
15
  end
15
16
 
16
17
  describe '#initialize' do
17
- it { described.must_be_instance_of(Launcher) }
18
- it { described.instance_variable_get('@argv').must_equal([]) }
19
- it { described.instance_variable_get('@stdin').must_equal(STDIN) }
20
- it { described.instance_variable_get('@stdout').must_equal(STDOUT) }
21
- it { described.instance_variable_get('@stderr').must_equal(STDERR) }
22
- it { described.instance_variable_get('@kernel').must_equal(Kernel) }
23
- it { described.instance_variable_get('@exit_code').must_equal(1) }
18
+ subject { instance }
19
+
20
+ it { subject.must_be_instance_of(described) }
21
+ it { subject.instance_variable_get('@argv').must_equal([]) }
22
+ it { subject.instance_variable_get('@stdin').must_equal(STDIN) }
23
+ it { subject.instance_variable_get('@stdout').must_equal(STDOUT) }
24
+ it { subject.instance_variable_get('@stderr').must_equal(STDERR) }
25
+ it { subject.instance_variable_get('@kernel').must_equal(Kernel) }
26
+ it { subject.instance_variable_get('@exit_code').must_equal(1) }
24
27
  end
25
28
 
26
29
  describe '#execute!' do
30
+ subject { instance.execute! }
31
+
27
32
  it 'returns 0 for successful execution' do
28
- Launcher.new.execute!.must_equal(0)
33
+ subject.must_equal(0)
29
34
  end
30
35
 
31
36
  # context 'when an exception is raised' do
@@ -20,6 +20,7 @@ module Vedeu
20
20
  context 'with default attributes' do
21
21
  it { subject.instance_variable_get('@attributes').must_equal({
22
22
  centred: false,
23
+ client: nil,
23
24
  height: 25,
24
25
  name: '',
25
26
  width: 80,
@@ -5,7 +5,15 @@ module Vedeu
5
5
  describe Menu do
6
6
 
7
7
  let(:described) { Vedeu::Menu }
8
- let(:instance) { described.new(collection, menu_name, current, selected) }
8
+ let(:instance) { described.new(attributes) }
9
+ let(:attributes) {
10
+ {
11
+ collection: collection,
12
+ name: menu_name,
13
+ current: current,
14
+ selected: selected,
15
+ }
16
+ }
9
17
  let(:collection) { ['hydrogen', 'carbon', 'nitrogen', 'oxygen'] }
10
18
  let(:menu_name) { 'elements' }
11
19
  let(:current) { 0 }
@@ -13,12 +21,6 @@ module Vedeu
13
21
 
14
22
  before { Vedeu.menus.reset }
15
23
 
16
- describe '.build' do
17
- subject { described.build }
18
-
19
- it { subject.must_be_instance_of(described) }
20
- end
21
-
22
24
  describe '.menu' do
23
25
  subject {
24
26
  described.menu('elements') do
@@ -7,7 +7,15 @@ module Vedeu
7
7
  let(:described) { Vedeu::Char }
8
8
  let(:instance) { described.new(value, parent, colour, style, position) }
9
9
  let(:value) { 'a' }
10
- let(:parent) { Line.new([], nil, parent_colour, parent_style) }
10
+ let(:parent) { Line.new(parent_attributes) }
11
+ let(:parent_attributes) {
12
+ {
13
+ streams: [],
14
+ parent: nil,
15
+ colour: parent_colour,
16
+ style: parent_style,
17
+ }
18
+ }
11
19
  let(:colour) { nil }
12
20
  let(:style) { nil }
13
21
  let(:position) { nil }
@@ -4,9 +4,15 @@ module Vedeu
4
4
 
5
5
  describe Composition do
6
6
 
7
- let(:described) { Vedeu::Composition }
8
- let(:instance) { described.new(interfaces) }
9
-
7
+ let(:described) { Vedeu::Composition }
8
+ let(:instance) { described.new(attributes) }
9
+ let(:attributes) {
10
+ {
11
+ interfaces: interfaces,
12
+ colour: colour,
13
+ style: style,
14
+ }
15
+ }
10
16
  let(:interfaces) { [] }
11
17
  let(:colour) {}
12
18
  let(:style) {}
@@ -18,7 +24,7 @@ module Vedeu
18
24
  end
19
25
  }
20
26
 
21
- it { subject.must_be_instance_of(Composition) }
27
+ it { subject.must_be_instance_of(described) }
22
28
  end
23
29
 
24
30
  describe '#initialize' do
@@ -26,8 +32,8 @@ module Vedeu
26
32
 
27
33
  it { subject.must_be_instance_of(described) }
28
34
  it { subject.instance_variable_get('@interfaces').must_equal(interfaces) }
29
- it { subject.instance_variable_get('@colour').must_equal(colour) }
30
- it { subject.instance_variable_get('@style').must_equal(style) }
35
+ it { subject.instance_variable_get('@colour').must_be_instance_of(Vedeu::Colour) }
36
+ it { subject.instance_variable_get('@style').must_be_instance_of(Vedeu::Style) }
31
37
  end
32
38
 
33
39
  describe '#inspect' do
@@ -4,13 +4,22 @@ module Vedeu
4
4
 
5
5
  describe Interface do
6
6
 
7
- let(:described) { Vedeu::Interface }
8
- let(:instance) { described.new(_name, lines, parent, colour, style) }
9
- let(:_name) { 'hydrogen' }
10
- let(:lines) { [] }
11
- let(:parent) {}
12
- let(:colour) {}
13
- let(:style) {}
7
+ let(:described) { Vedeu::Interface }
8
+ let(:instance) { described.new(attributes) }
9
+ let(:attributes) {
10
+ {
11
+ name: _name,
12
+ lines: lines,
13
+ parent: parent,
14
+ colour: colour,
15
+ style: style,
16
+ }
17
+ }
18
+ let(:_name) { 'hydrogen' }
19
+ let(:lines) { [] }
20
+ let(:parent) {}
21
+ let(:colour) {}
22
+ let(:style) {}
14
23
 
15
24
  describe '#initialize' do
16
25
  subject { instance }
@@ -18,8 +27,8 @@ module Vedeu
18
27
  it { subject.instance_variable_get('@name').must_equal(_name) }
19
28
  it { subject.instance_variable_get('@lines').must_equal(lines) }
20
29
  it { subject.instance_variable_get('@parent').must_equal(parent) }
21
- it { subject.instance_variable_get('@colour').must_equal(colour) }
22
- it { subject.instance_variable_get('@style').must_equal(style) }
30
+ it { subject.instance_variable_get('@colour').must_be_instance_of(Vedeu::Colour) }
31
+ it { subject.instance_variable_get('@style').must_be_instance_of(Vedeu::Style) }
23
32
  it { subject.instance_variable_get('@border').must_equal(nil) }
24
33
  it { subject.instance_variable_get('@delay').must_equal(0.0) }
25
34
  it { subject.instance_variable_get('@geometry').must_equal(nil) }
@@ -4,26 +4,34 @@ module Vedeu
4
4
 
5
5
  describe Line do
6
6
 
7
- let(:described) { Vedeu::Line }
8
- let(:instance) { described.new(streams, parent, colour, style) }
7
+ let(:described) { Vedeu::Line }
8
+ let(:instance) { described.new(attributes) }
9
+ let(:attributes) {
10
+ {
11
+ streams: streams,
12
+ parent: parent,
13
+ colour: colour,
14
+ style: style,
15
+ }
16
+ }
9
17
  let(:streams) {
10
18
  [
11
- Stream.new('Something interesting ',
12
- streams_parent,
13
- Colour.new({ foreground: '#ffff00' }),
14
- Style.new('normal')),
15
- Stream.new('on this line ',
16
- streams_parent,
17
- Colour.new({ foreground: '#00ff00' }),
18
- Style.new('normal')),
19
- Stream.new('would be cool, eh?',
20
- streams_parent,
21
- Colour.new({ foreground: '#0000ff' }),
22
- Style.new('normal'))
19
+ Stream.new({ value: 'Something interesting ',
20
+ parent: streams_parent,
21
+ colour: Colour.new({ foreground: '#ffff00' }),
22
+ style: Style.new('normal') }),
23
+ Stream.new({ value: 'on this line ',
24
+ parent: streams_parent,
25
+ colour: Colour.new({ foreground: '#00ff00' }),
26
+ style: Style.new('normal') }),
27
+ Stream.new({ value: 'would be cool, eh?',
28
+ parent: streams_parent,
29
+ colour: Colour.new({ foreground: '#0000ff' }),
30
+ style: Style.new('normal') })
23
31
  ]
24
32
  }
25
33
 
26
- let(:streams_parent) { Line.new(nil, parent, colour, style) }
34
+ let(:streams_parent) { Line.new({ streams: nil, parent: parent, colour: colour, style: style }) }
27
35
 
28
36
  let(:parent) { mock('Interface') }
29
37
  let(:colour) { Colour.new({ foreground: '#ff0000', background: '#000000' }) }
@@ -37,7 +45,7 @@ module Vedeu
37
45
  describe '#initialize' do
38
46
  subject { instance }
39
47
 
40
- it { subject.must_be_instance_of(Line) }
48
+ it { subject.must_be_instance_of(described) }
41
49
  it { subject.instance_variable_get('@streams').must_equal(streams) }
42
50
  it { subject.instance_variable_get('@parent').must_equal(parent) }
43
51
  it { subject.instance_variable_get('@colour').must_equal(colour) }
@@ -4,16 +4,24 @@ module Vedeu
4
4
 
5
5
  describe Stream do
6
6
 
7
- let(:described) { Vedeu::Stream }
8
- let(:instance) { described.new(value, parent, colour, style) }
9
- let(:value) { 'Some text' }
10
- let(:parent) {
11
- Line.new(
12
- [],
13
- line_parent,
14
- Colour.new({ background: '#0000ff', foreground: '#ffff00' }),
15
- Style.new('normal')
16
- )
7
+ let(:described) { Vedeu::Stream }
8
+ let(:instance) { described.new(attributes) }
9
+ let(:attributes) {
10
+ {
11
+ value: value,
12
+ parent: parent,
13
+ colour: colour,
14
+ style: style
15
+ }
16
+ }
17
+ let(:value) { 'Some text' }
18
+ let(:parent) {
19
+ Line.new({
20
+ streams: [],
21
+ parent: line_parent,
22
+ colour: Colour.new({ background: '#0000ff', foreground: '#ffff00' }),
23
+ style: Style.new('normal')
24
+ })
17
25
  }
18
26
  let(:colour) { Colour.new({ background: '#ff0000', foreground: '#000000' }) }
19
27
  let(:style) { Style.new('normal') }
@@ -22,7 +30,8 @@ module Vedeu
22
30
  describe '#initialize' do
23
31
  subject { instance }
24
32
 
25
- it { subject.must_be_instance_of(Stream) }
33
+ it { subject.must_be_instance_of(described) }
34
+ # it { subject.instance_variable_get('@attributes').must_equal(attributes) }
26
35
  it { subject.instance_variable_get('@value').must_equal(value) }
27
36
  it { subject.instance_variable_get('@parent').must_equal(parent) }
28
37
  it { subject.instance_variable_get('@colour').must_equal(colour) }
@@ -48,6 +48,7 @@ module Vedeu
48
48
  {
49
49
  bottom_left: 'm',
50
50
  bottom_right: 'j',
51
+ client: nil,
51
52
  colour: {},
52
53
  enabled: false,
53
54
  horizontal: 'q',
@@ -15,10 +15,10 @@ module Vedeu
15
15
  }
16
16
  let(:lines) {
17
17
  [
18
- Line.new([Stream.new('this is the first')]),
19
- Line.new([Stream.new('this is the second and it is long')]),
20
- Line.new([Stream.new('this is the third, it is even longer and still truncated')]),
21
- Line.new([Stream.new('this should not render')]),
18
+ Line.new({ streams: [Stream.new({ value: 'this is the first' })] }),
19
+ Line.new({ streams: [Stream.new({ value: 'this is the second and it is long' })] }),
20
+ Line.new({ streams: [Stream.new({ value: 'this is the third, it is even longer and still truncated' })] }),
21
+ Line.new({ streams: [Stream.new({ value: 'this should not render' })] }),
22
22
  ]
23
23
  }
24
24
 
@@ -37,10 +37,10 @@ module Vedeu
37
37
  }
38
38
  let(:text_line_objects) {
39
39
  [
40
- Vedeu::Line.new("Krypton is a colorless, odorless, tasteless noble gas."),
41
- Vedeu::Line.new("It occurs in trace amounts in the atmosphere."),
42
- Vedeu::Line.new("It is isolated by fractionally distilling liquefied air."),
43
- Vedeu::Line.new("Krypton is often used with other rare gases in fluorescent lamps.")
40
+ Vedeu::Line.new({ streams: [Vedeu::Stream.new({ value: "Krypton is a colorless, odorless, tasteless noble gas." })] }),
41
+ Vedeu::Line.new({ streams: [Vedeu::Stream.new({ value: "It occurs in trace amounts in the atmosphere." })] }),
42
+ Vedeu::Line.new({ streams: [Vedeu::Stream.new({ value: "It is isolated by fractionally distilling liquefied air." })] }),
43
+ Vedeu::Line.new({ streams: [Vedeu::Stream.new({ value: "Krypton is often used with other rare gases in fluorescent lamps." })] })
44
44
  ]
45
45
  }
46
46
 
@@ -23,14 +23,15 @@ module Vedeu
23
23
  end
24
24
 
25
25
  describe '#to_s' do
26
- let(:line) { Line.new(
27
- [],
28
- mock('Interface'),
29
- Colour.new({ foreground: '#00ff00', background: '#000000' }),
30
- Style.new('normal')
31
- )
26
+ let(:line) {
27
+ Vedeu::Line.new({
28
+ streams: [],
29
+ parent: mock('Interface'),
30
+ colour: Colour.new({ foreground: '#00ff00', background: '#000000' }),
31
+ style: Style.new('normal')
32
+ })
32
33
  }
33
- let(:stream) { Stream.new(stream_value, line, stream_colour, stream_style) }
34
+ let(:stream) { Stream.new({ value: stream_value, parent: line, colour: stream_colour, style: stream_style }) }
34
35
  let(:stream_value) { 'Some text' }
35
36
  let(:stream_colour) { Colour.new({ foreground: '#ff0000', background: '#000000' }) }
36
37
  let(:stream_style) { Style.new(:underline) }
@@ -4,17 +4,19 @@ module Vedeu
4
4
 
5
5
  describe Style do
6
6
 
7
- let(:described) { Style }
7
+ let(:described) { Vedeu::Style }
8
+ let(:instance) { described.new(value) }
9
+ let(:value) { 'bold' }
8
10
 
9
11
  describe '#initialize' do
10
- subject { described.new('bold') }
12
+ subject { instance }
11
13
 
12
14
  it { subject.must_be_instance_of(described) }
13
15
  it { subject.instance_variable_get('@value').must_equal('bold') }
14
16
  end
15
17
 
16
18
  describe '#attributes' do
17
- subject { described.new('bold').attributes }
19
+ subject { instance.attributes }
18
20
 
19
21
  it { subject.must_be_instance_of(Hash) }
20
22
 
@@ -26,7 +28,7 @@ module Vedeu
26
28
  describe '#to_s' do
27
29
  let(:value) {}
28
30
 
29
- subject { described.new(value).to_s }
31
+ subject { instance.to_s }
30
32
 
31
33
  it { subject.must_be_instance_of(String) }
32
34
  it { subject.must_equal('') }
@@ -5,15 +5,16 @@ module Vedeu
5
5
  describe Position do
6
6
 
7
7
  let(:described) { Vedeu::Position }
8
- let(:instance) { described.new(12, 19) }
9
-
8
+ let(:instance) { described.new(y, x) }
9
+ let(:y) { 12 }
10
+ let(:x) { 19 }
10
11
 
11
12
  describe '#initialize' do
12
13
  subject { instance }
13
14
 
14
- it { subject.must_be_instance_of(Position) }
15
- it { subject.instance_variable_get('@y').must_equal(12) }
16
- it { subject.instance_variable_get('@x').must_equal(19) }
15
+ it { subject.must_be_instance_of(described) }
16
+ it { subject.instance_variable_get('@y').must_equal(y) }
17
+ it { subject.instance_variable_get('@x').must_equal(x) }
17
18
  end
18
19
 
19
20
  describe '#to_s' do
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.3.2'
7
+ spec.version = '0.3.3'
8
8
  spec.authors = ['Gavin Laking']
9
9
  spec.email = ['gavinlaking@gmail.com']
10
10
  spec.summary = %q{A terminal case of wonderland.}
@@ -24,7 +24,6 @@ Gem::Specification.new do |spec|
24
24
  spec.add_development_dependency 'guard-bundler', '2.1.0'
25
25
  spec.add_development_dependency 'guard-cucumber', '1.5.3'
26
26
  spec.add_development_dependency 'guard-minitest', '2.4.3'
27
- spec.add_development_dependency 'guard-yard', '2.1.4'
28
27
  spec.add_development_dependency 'minitest', '5.5.1'
29
28
  spec.add_development_dependency 'minitest-reporters', '1.0.10'
30
29
  spec.add_development_dependency 'mocha', '1.1.0'
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.3.2
4
+ version: 0.3.3
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-02-16 00:00:00.000000000 Z
11
+ date: 2015-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aruba
@@ -108,20 +108,6 @@ dependencies:
108
108
  - - '='
109
109
  - !ruby/object:Gem::Version
110
110
  version: 2.4.3
111
- - !ruby/object:Gem::Dependency
112
- name: guard-yard
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - '='
116
- - !ruby/object:Gem::Version
117
- version: 2.1.4
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - '='
123
- - !ruby/object:Gem::Version
124
- version: 2.1.4
125
111
  - !ruby/object:Gem::Dependency
126
112
  name: minitest
127
113
  requirement: !ruby/object:Gem::Requirement