vedeu 0.5.6 → 0.5.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/lib/vedeu/application/controller.rb +2 -2
  3. data/lib/vedeu/cursor/refresh_cursor.rb +1 -1
  4. data/lib/vedeu/dsl/presentation.rb +3 -3
  5. data/lib/vedeu/dsl/use.rb +0 -34
  6. data/lib/vedeu/events/event.rb +2 -2
  7. data/lib/vedeu/events/trigger.rb +1 -1
  8. data/lib/vedeu/geometry/area.rb +1 -1
  9. data/lib/vedeu/geometry/dimension.rb +2 -2
  10. data/lib/vedeu/input/input.rb +1 -1
  11. data/lib/vedeu/log/log.rb +5 -3
  12. data/lib/vedeu/models/focus.rb +1 -1
  13. data/lib/vedeu/models/interfaces.rb +1 -1
  14. data/lib/vedeu/models/toggleable.rb +5 -5
  15. data/lib/vedeu/null/interface.rb +1 -8
  16. data/lib/vedeu/null/view.rb +1 -8
  17. data/lib/vedeu/output/refresh_group.rb +1 -1
  18. data/lib/vedeu/output/renderers/json.rb +1 -1
  19. data/lib/vedeu/repositories/model.rb +1 -1
  20. data/lib/vedeu/repositories/registerable.rb +1 -1
  21. data/lib/vedeu/templating/view_template.rb +3 -3
  22. data/lib/vedeu/terminal.rb +3 -3
  23. data/lib/vedeu/version.rb +1 -1
  24. data/test/lib/vedeu/bindings_test.rb +2 -2
  25. data/test/lib/vedeu/borders/border_test.rb +2 -6
  26. data/test/lib/vedeu/borders/render_border_test.rb +2 -2
  27. data/test/lib/vedeu/cli/generator/application_test.rb +2 -2
  28. data/test/lib/vedeu/cli/generator/view_test.rb +2 -2
  29. data/test/lib/vedeu/cli/main_test.rb +4 -4
  30. data/test/lib/vedeu/configuration/configuration_test.rb +6 -6
  31. data/test/lib/vedeu/cursor/cursor_test.rb +6 -6
  32. data/test/lib/vedeu/cursor/cursors_test.rb +4 -4
  33. data/test/lib/vedeu/cursor/move_test.rb +2 -2
  34. data/test/lib/vedeu/cursor/refresh_cursor_test.rb +2 -2
  35. data/test/lib/vedeu/cursor/reposition_test.rb +2 -2
  36. data/test/lib/vedeu/distributed/client_test.rb +2 -2
  37. data/test/lib/vedeu/distributed/server_test.rb +3 -5
  38. data/test/lib/vedeu/dsl/border_test.rb +2 -2
  39. data/test/lib/vedeu/dsl/composition_test.rb +3 -3
  40. data/test/lib/vedeu/dsl/interface_test.rb +8 -8
  41. data/test/lib/vedeu/dsl/line_test.rb +2 -2
  42. data/test/lib/vedeu/dsl/use_test.rb +0 -24
  43. data/test/lib/vedeu/events/event_aliases_test.rb +9 -0
  44. data/test/lib/vedeu/events/event_test.rb +5 -5
  45. data/test/lib/vedeu/geometry/coordinate_test.rb +2 -2
  46. data/test/lib/vedeu/input/input_test.rb +2 -2
  47. data/test/lib/vedeu/input/keymap_test.rb +2 -2
  48. data/test/lib/vedeu/log/timer_test.rb +2 -2
  49. data/test/lib/vedeu/models/focus_test.rb +16 -24
  50. data/test/lib/vedeu/models/interfaces_test.rb +2 -2
  51. data/test/lib/vedeu/null/view_test.rb +44 -0
  52. data/test/lib/vedeu/output/clear/named_interface_test.rb +2 -2
  53. data/test/lib/vedeu/output/output_test.rb +2 -2
  54. data/test/lib/vedeu/output/renderers_test.rb +2 -2
  55. data/test/lib/vedeu/output/viewport_test.rb +2 -2
  56. data/test/lib/vedeu/plugins/plugin_test.rb +9 -0
  57. data/test/lib/vedeu/runtime/application_test.rb +2 -2
  58. data/test/lib/vedeu/runtime/launcher_test.rb +2 -2
  59. data/test/lib/vedeu/runtime/router_test.rb +8 -8
  60. data/test/lib/vedeu/templating/template_test.rb +2 -2
  61. data/test/lib/vedeu/templating/view_template_test.rb +4 -3
  62. data/test/lib/vedeu/terminal_mode_test.rb +2 -2
  63. data/test/lib/vedeu/terminal_test.rb +6 -10
  64. data/vedeu.gemspec +1 -1
  65. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 09870ba45d07181770a6a5ce2cb4d76791e4407c
4
- data.tar.gz: a8fc2634c87ee748a2ef2088f9ec1e0ffa9bf4a8
3
+ metadata.gz: adbde558d3cfb0668d3d05c5e21effc821b92ab4
4
+ data.tar.gz: 1bef10fb655bcbc83cee7796ba12269a114321f9
5
5
  SHA512:
6
- metadata.gz: f1fa1db173f45c407e2430aa91b34a2ba4e01e7153add82561928c7369fbd16b11ac23f8f21264407f7ea1fd2ff89986a11a1174911e9e85950440286549d93f
7
- data.tar.gz: d6520ef6b775f1d5413271fba57b2c28394428fc41af772742c1b92aad2beed4b4c8c72dd939687a3b845465ddb3353e20910fe6cdb22a995ea110f45a7bbefa
6
+ metadata.gz: 24481b866de7f7aa5042a7575aa0e67bf99dd7230bb1085c22c2334a796309bd5a94095539e54b26d7e1c8bcb9450891d015b4eac65597b630038e619dad54a0
7
+ data.tar.gz: a8423cfe4e0c26e88e5a3ef60d0ed4f8b5dde4725b4a89492285dad0b1c3dfe0096d9f1a736f9ac7f81491b01d1f7b734cad345a747154e5017a9be4ca8ee56e
@@ -29,7 +29,7 @@ module Vedeu
29
29
  def controller(controller_name = nil)
30
30
  @controller_name = controller_name
31
31
 
32
- Vedeu::Router.add_controller(controller_name, ancestors.first.to_s)
32
+ Vedeu::Router.add_controller(controller_name, ancestors[0].to_s)
33
33
  end
34
34
  alias_method :controller_name, :controller
35
35
 
@@ -72,7 +72,7 @@ module Vedeu
72
72
  # @param klass [Class]
73
73
  # @return [void]
74
74
  def self.included(klass)
75
- klass.send :extend, ClassMethods
75
+ klass.send(:extend, ClassMethods)
76
76
  end
77
77
 
78
78
  end # Controller
@@ -56,7 +56,7 @@ module Vedeu
56
56
 
57
57
  # @return [Vedeu::Cursor]
58
58
  def new_cursor
59
- @new_cursor ||= Vedeu::Cursor.new(cursor.attributes.merge(position))
59
+ @new_cursor ||= Vedeu::Cursor.new(cursor.attributes.merge!(position))
60
60
  end
61
61
 
62
62
  # @return [Hash<Symbol => Fixnum>]
@@ -56,7 +56,7 @@ module Vedeu
56
56
  # defined colour for a particular interface, line or stream overrides
57
57
  # previously defined entries in the same block.
58
58
  #
59
- # @param attributes [Hash] See {Vedeu::Colour}
59
+ # @param attrs [Hash] See {Vedeu::Colour}
60
60
  #
61
61
  # @example
62
62
  # interface 'my_interface' do
@@ -75,8 +75,8 @@ module Vedeu
75
75
  # end
76
76
  #
77
77
  # @return [Vedeu::Colour]
78
- def colour(attributes = {})
79
- model.colour = Vedeu::Colour.coerce(colour_attributes.merge(attributes))
78
+ def colour(attrs = {})
79
+ model.colour = Vedeu::Colour.coerce(colour_attributes.merge!(attrs))
80
80
  end
81
81
 
82
82
  # Define a style or styles for an interface, line or a stream.
@@ -6,40 +6,6 @@ module Vedeu
6
6
  #
7
7
  module Use
8
8
 
9
- # Duplicate a stored model.
10
- #
11
- # This DSL method copies the attributes of a stored model, changes the
12
- # name to that of the current model, and stores the duplicate as a new
13
- # model in model's repository.
14
- #
15
- # @example
16
- # # Here the attributes of 'my_geometry' are used to create the
17
- # # new model 'my_other_geometry'.
18
- # Vedeu.geometry 'my_other_geometry' do
19
- # duplicate('my_geometry')
20
- # end
21
- #
22
- # @note
23
- # - Only models of the same repository can be used in this way.
24
- # - If the stored model cannot be found, the duplicate may not have
25
- # the values you required.
26
- # - Values defined before will be overwritten by the new values from
27
- # the stored model.
28
- # - Values defined after will overwrite the values of the new
29
- # duplicate model.
30
- #
31
- # @param name [String] The name of the model to duplicate.
32
- # @return [void] The new model based on the original.
33
- def duplicate(name)
34
- original = use(name)
35
-
36
- unless original.respond_to?(:null?)
37
- duplicated = original.dup
38
- duplicated.name = model.name
39
- duplicated.store
40
- end
41
- end
42
-
43
9
  # Use the attribute of stored model.
44
10
  #
45
11
  # This DSL method provides access to a stored model by name. You can
@@ -80,7 +80,7 @@ module Vedeu
80
80
  def bind(name, options = {}, &block)
81
81
  Vedeu.log(type: :event, message: "Binding: '#{name.inspect}'")
82
82
 
83
- new(name, options, block).bind
83
+ new(name, block, options).bind
84
84
  end
85
85
  alias_method :event, :bind
86
86
  alias_method :register, :bind
@@ -125,7 +125,7 @@ module Vedeu
125
125
  #
126
126
  # @param (see Vedeu::Event.bind)
127
127
  # @return [Vedeu::Event]
128
- def initialize(name, options = {}, closure)
128
+ def initialize(name, closure, options = {})
129
129
  @name = name
130
130
  @options = options
131
131
  @closure = closure
@@ -33,7 +33,7 @@ module Vedeu
33
33
  # @return [Array]
34
34
  def trigger
35
35
  if results.one?
36
- results.first
36
+ results[0]
37
37
 
38
38
  else
39
39
  results
@@ -49,7 +49,7 @@ module Vedeu
49
49
  maximised: attributes[:maximised],
50
50
  centred: attributes[:centred])
51
51
 
52
- new(y: y_yn.first, yn: y_yn.last, x: x_xn.first, xn: x_xn.last)
52
+ new(y: y_yn[0], yn: y_yn[-1], x: x_xn[0], xn: x_xn[-1])
53
53
  end
54
54
 
55
55
  # Returns a new instance of Vedeu::Area.
@@ -29,14 +29,14 @@ module Vedeu
29
29
  #
30
30
  # @return [Fixnum]
31
31
  def d1
32
- dimension.first < 1 ? 1 : dimension.first
32
+ dimension[0] < 1 ? 1 : dimension[0]
33
33
  end
34
34
 
35
35
  # Fetch the ending coordinate.
36
36
  #
37
37
  # @return [Fixnum]
38
38
  def d2
39
- dimension.last
39
+ dimension[-1]
40
40
  end
41
41
 
42
42
  # Fetch the coordinates.
@@ -113,7 +113,7 @@ module Vedeu
113
113
  "\u0024" => :ctrl_x,
114
114
  "\u0025" => :ctrl_y,
115
115
  "\u0026" => :ctrl_z,
116
- }.merge(f_keys)
116
+ }.merge!(f_keys)
117
117
  end
118
118
 
119
119
  # @return [Hash<String => Symbol]
@@ -52,7 +52,9 @@ module Vedeu
52
52
 
53
53
  # @return [void]
54
54
  def close
55
- @dev.close rescue nil
55
+ @dev.close
56
+ rescue
57
+ nil
56
58
  end
57
59
 
58
60
  private
@@ -168,7 +170,7 @@ module Vedeu
168
170
  # @param body [String] The log message itself.
169
171
  # @return [String]
170
172
  def message_body(type, body)
171
- Vedeu::Esc.send(message_types.fetch(type, :default).last) do
173
+ Vedeu::Esc.send(message_types.fetch(type, :default)[-1]) do
172
174
  body
173
175
  end
174
176
  end
@@ -179,7 +181,7 @@ module Vedeu
179
181
  # @param type [Symbol] The type of log message.
180
182
  # @return [String]
181
183
  def message_type(type)
182
- Vedeu::Esc.send(message_types.fetch(type, :default).first) do
184
+ Vedeu::Esc.send(message_types.fetch(type, :default)[0]) do
183
185
  "[#{type}]".ljust(9)
184
186
  end
185
187
  end
@@ -70,7 +70,7 @@ module Vedeu
70
70
  #
71
71
  # @return [String]
72
72
  def current
73
- storage.first
73
+ storage[0]
74
74
  end
75
75
  alias_method :focus, :current
76
76
 
@@ -21,7 +21,7 @@ module Vedeu
21
21
  # @return [Array<Vedeu::Interface>]
22
22
  # @see Vedeu::DSL::Interface#zindex
23
23
  def zindexed
24
- all.sort { |a, b| a.zindex <=> b.zindex }
24
+ all.sort_by(&:zindex)
25
25
  end
26
26
 
27
27
  end # Interfaces
@@ -53,7 +53,7 @@ module Vedeu
53
53
  # @param name [String]
54
54
  # @return [void]
55
55
  def hide(name = nil)
56
- model_by_name(name, repository).hide
56
+ model_by_name(repository, name).hide
57
57
  end
58
58
  alias_method :hide_cursor, :hide
59
59
  alias_method :hide_group, :hide
@@ -64,7 +64,7 @@ module Vedeu
64
64
  # @param name [String]
65
65
  # @return [void]
66
66
  def show(name = nil)
67
- model_by_name(name, repository).show
67
+ model_by_name(repository, name).show
68
68
  end
69
69
  alias_method :show_cursor, :show
70
70
  alias_method :show_group, :show
@@ -75,7 +75,7 @@ module Vedeu
75
75
  # @param name [String]
76
76
  # @return [void]
77
77
  def toggle(name = nil)
78
- model_by_name(name, repository).toggle
78
+ model_by_name(repository, name).toggle
79
79
  end
80
80
  alias_method :toggle_cursor, :toggle
81
81
  alias_method :toggle_group, :toggle
@@ -88,7 +88,7 @@ module Vedeu
88
88
  # @param name [String]
89
89
  # @param klass [void] The repository of the model.
90
90
  # @return [void]
91
- def model_by_name(name = nil, klass)
91
+ def model_by_name(klass, name = nil)
92
92
  klass.by_name(name || Vedeu.focus)
93
93
  end
94
94
 
@@ -100,7 +100,7 @@ module Vedeu
100
100
  # @param klass [Class]
101
101
  # @return [void]
102
102
  def self.included(klass)
103
- klass.send :extend, ClassMethods
103
+ klass.send(:extend, ClassMethods)
104
104
  end
105
105
 
106
106
  end # Toggleable
@@ -31,7 +31,7 @@ module Vedeu
31
31
  def initialize(attributes = {})
32
32
  @attributes = attributes
33
33
  @name = @attributes[:name]
34
- @visible = @attributes[:visible]
34
+ @visible = false
35
35
  end
36
36
 
37
37
  # @return [NilClass]
@@ -56,13 +56,6 @@ module Vedeu
56
56
  self
57
57
  end
58
58
 
59
- # The null interface should not be visible.
60
- #
61
- # @return [FalseClass]
62
- def visible?
63
- false
64
- end
65
-
66
59
  end # Interface
67
60
 
68
61
  end # Null
@@ -31,7 +31,7 @@ module Vedeu
31
31
  def initialize(attributes = {})
32
32
  @attributes = attributes
33
33
  @name = @attributes[:name]
34
- @visible = @attributes[:visible]
34
+ @visible = false
35
35
  end
36
36
 
37
37
  # @return [NilClass]
@@ -53,13 +53,6 @@ module Vedeu
53
53
  self
54
54
  end
55
55
 
56
- # The null interface should not be visible.
57
- #
58
- # @return [FalseClass]
59
- def visible?
60
- false
61
- end
62
-
63
56
  end # View
64
57
 
65
58
  end # Null
@@ -33,7 +33,7 @@ module Vedeu
33
33
 
34
34
  # @return [Array<String>]
35
35
  def zindexed
36
- interfaces.sort { |a, b| a.zindex <=> b.zindex }.map(&:name)
36
+ interfaces.sort_by(&:zindex).map(&:name)
37
37
  end
38
38
 
39
39
  # @return [Array<Vedeu::Interface>]
@@ -39,7 +39,7 @@ module Vedeu
39
39
  # @param output [Array<Array<Vedeu::Views::Char>>]
40
40
  # @return [Array]
41
41
  def sorted(output)
42
- Array(output).flatten.sort { |a, b| a.position <=> b.position }
42
+ Array(output).flatten.sort_by(&:position)
43
43
  end
44
44
 
45
45
  end # JSON
@@ -82,7 +82,7 @@ module Vedeu
82
82
  # @param klass [Class]
83
83
  # @return [void]
84
84
  def self.included(klass)
85
- klass.send :extend, ClassMethods
85
+ klass.send(:extend, ClassMethods)
86
86
  end
87
87
 
88
88
  # Returns a DSL instance responsible for defining the DSL methods of this
@@ -63,7 +63,7 @@ module Vedeu
63
63
  # @param klass [Class]
64
64
  # @return [void]
65
65
  def self.included(klass)
66
- klass.send :extend, ClassMethods
66
+ klass.send(:extend, ClassMethods)
67
67
  end
68
68
 
69
69
  end # Registerable
@@ -50,7 +50,7 @@ module Vedeu
50
50
 
51
51
  # @return [Vedeu::Colour|Hash<Symbol => Symbol>]
52
52
  def default_colour
53
- if interface?
53
+ if options[:name]
54
54
  interface.colour
55
55
 
56
56
  else
@@ -64,7 +64,7 @@ module Vedeu
64
64
 
65
65
  # @return [Symbol]
66
66
  def default_style
67
- if interface?
67
+ if options[:name]
68
68
  interface.style
69
69
 
70
70
  else
@@ -75,7 +75,7 @@ module Vedeu
75
75
 
76
76
  # @return [Vedeu::Interface]
77
77
  def interface
78
- Vedeu.interfaces.by_name(options[:name]) if options[:name]
78
+ Vedeu.interfaces.by_name(options[:name])
79
79
  end
80
80
  alias_method :interface?, :interface
81
81
 
@@ -135,7 +135,7 @@ module Vedeu
135
135
  #
136
136
  # @return [Fixnum]
137
137
  def centre_y
138
- centre.first
138
+ centre[0]
139
139
  end
140
140
 
141
141
  # Returns the `x` (column/character) component of the coodinate tuple
@@ -143,7 +143,7 @@ module Vedeu
143
143
  #
144
144
  # @return [Fixnum]
145
145
  def centre_x
146
- centre.last
146
+ centre[-1]
147
147
  end
148
148
 
149
149
  # Returns 1. This 1 is either the top-most or left-most coordinate of the
@@ -168,7 +168,7 @@ module Vedeu
168
168
  def width
169
169
  return Vedeu::Configuration.drb_width if Vedeu::Configuration.drb?
170
170
 
171
- size.last
171
+ size[-1]
172
172
  end
173
173
  alias_method :xn, :width
174
174
  alias_method :txn, :width
@@ -1,6 +1,6 @@
1
1
  module Vedeu
2
2
 
3
3
  # The current version of Vedeu.
4
- VERSION = '0.5.6'
4
+ VERSION = '0.5.7'
5
5
 
6
6
  end
@@ -7,14 +7,14 @@ module Vedeu
7
7
  let(:described) { Vedeu::Bindings }
8
8
 
9
9
  describe '.setup!' do
10
- before {
10
+ before do
11
11
  Vedeu::Bindings::Application.stubs(:setup!)
12
12
  Vedeu::Bindings::Visibility.stubs(:setup!)
13
13
  Vedeu::Bindings::Movement.stubs(:setup!)
14
14
  Vedeu::Bindings::Menus.stubs(:setup!)
15
15
  Vedeu::Bindings::DRB.stubs(:setup!)
16
16
  Vedeu::Bindings::System.stubs(:setup!)
17
- }
17
+ end
18
18
 
19
19
  subject { described.setup! }
20
20
 
@@ -29,9 +29,7 @@ module Vedeu
29
29
  }
30
30
  let(:geometry) {}
31
31
 
32
- before {
33
- Vedeu.geometries.stubs(:by_name).returns(geometry)
34
- }
32
+ before { Vedeu.geometries.stubs(:by_name).returns(geometry) }
35
33
 
36
34
  describe '.build' do
37
35
  subject {
@@ -422,9 +420,7 @@ module Vedeu
422
420
  }
423
421
  let(:interface) { Vedeu::Interface.new(visible: visibility) }
424
422
 
425
- before {
426
- Vedeu.interfaces.stubs(:by_name).returns(interface)
427
- }
423
+ before { Vedeu.interfaces.stubs(:by_name).returns(interface) }
428
424
 
429
425
  subject { instance.render }
430
426