vedeu 0.4.63 → 0.4.64

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: b5a611c12fd166638545458a66d83fefcceb4201
4
- data.tar.gz: 4d7c37c1ac9281c6cae6a65dc83827e78b2ec578
3
+ metadata.gz: a32a9c9990ac18d631952547ac6fb6270fce65d3
4
+ data.tar.gz: c246ba1065c2cc51e843d8bac331fff26752ac0e
5
5
  SHA512:
6
- metadata.gz: 134e9ebd933984c61d89832cef7da1583aa36ea046e440ccdf2afa1f1bc6858820a6f7d270b39dfda7fa5204da4925808164998d4210f24ff016798cbeda2bff
7
- data.tar.gz: 19f6de39f023fe2bb7d9d0aab6014ce112227df1e8a2f8b8d511d6aea01c4e4015587077967a5b7f1b8da8633ab3bc724c4c34669f74220bc2f961e61b3d8d57
6
+ metadata.gz: f122e786688becea11c0709cbbb31f246d4beb9a9b37a0238d48e43fafa94e1282ee333942457ecff92096b2341684df300ef1b7d009dcd0acd7d37c507258e8
7
+ data.tar.gz: 2eccc4215c84e205cddf9bd6823bb3df16f0c380beb048d97c070d84fd69a70e7323e0e890df9050ff9f33851a309bb947daac9db04721494a8493f259681ac3
@@ -22,6 +22,7 @@ require 'thor'
22
22
  require 'vedeu/log'
23
23
 
24
24
  # Vedeu is a GUI framework for terminal/console applications written in Ruby.
25
+ #
25
26
  module Vedeu
26
27
 
27
28
  extend Forwardable
@@ -43,6 +43,8 @@ module Vedeu
43
43
  #
44
44
  # action :show
45
45
  # # or...
46
+ # actions :show, :list
47
+ # # or...
46
48
  # action_name :show
47
49
  #
48
50
  # # ... some code
@@ -51,12 +53,16 @@ module Vedeu
51
53
  #
52
54
  # Vedeu.trigger(:_goto_, :your_controller, :show, { some: :args })
53
55
  #
54
- # @param action_name [Symbol] THe name of the action.
56
+ # @param action_names [Array<Symbol>, Symbol] A collection of action names
57
+ # or the name of the action.
55
58
  # @return [void]
56
- def action(action_name = nil)
57
- Vedeu::Router.add_action(@controller_name, action_name)
59
+ def action(*action_names)
60
+ action_names.each do |action_name|
61
+ Vedeu::Router.add_action(@controller_name, action_name)
62
+ end
58
63
  end
59
64
  alias_method :action_name, :action
65
+ alias_method :actions, :action
60
66
 
61
67
  end # ClassMethods
62
68
 
@@ -38,6 +38,7 @@ module Vedeu
38
38
  end
39
39
 
40
40
  end # Application
41
+ # :nocov:
41
42
 
42
43
  end # Bindings
43
44
 
@@ -244,7 +244,7 @@ module Vedeu
244
244
  #
245
245
  # @return [void]
246
246
  def resize!
247
- Vedeu.bind(:_resize_, delay: 0.15) { Vedeu.resize }
247
+ Vedeu.bind(:_resize_, delay: 0.25) { Vedeu.resize }
248
248
  end
249
249
 
250
250
  # Unmaximising an interface.
@@ -30,6 +30,7 @@ module Vedeu
30
30
  # area needs more work in Vedeu.
31
31
  #
32
32
  # @todo Fix colours in all terminals. (GL: 2015-04-13)
33
+ #
33
34
  class Colour
34
35
 
35
36
  # @!attribute [r] background
@@ -1,6 +1,7 @@
1
1
  module Vedeu
2
2
 
3
3
  # Namespace for the API configuration and CLI configuration classes.
4
+ #
4
5
  module Config
5
6
 
6
7
  module_function
@@ -14,8 +14,8 @@ module Vedeu
14
14
  #
15
15
  # @param entity [void]
16
16
  # @param name [String]
17
- # @param y [Fixnum]
18
- # @param x [Fixnum]
17
+ # @param y [Fixnum] The row/line position.
18
+ # @param x [Fixnum] The column/character position.
19
19
  # @return [Vedeu::Reposition]
20
20
  def initialize(entity, name, y, x)
21
21
  @entity = entity
@@ -35,7 +35,8 @@ module Vedeu
35
35
  drb_connection_error
36
36
 
37
37
  rescue DRb::DRbBadURI
38
- puts 'Could not connect to DRb server, URI may be bad.'
38
+ Vedeu.log_stdout(message: 'Could not connect to DRb server, URI may ' \
39
+ 'be bad.')
39
40
 
40
41
  :drb_bad_uri
41
42
  end
@@ -79,7 +80,7 @@ module Vedeu
79
80
  drb_connection_error
80
81
 
81
82
  rescue Interrupt
82
- puts 'Client application exited.'
83
+ Vedeu.log_stdout(message: 'Client application exited.')
83
84
 
84
85
  ensure
85
86
  :shutdown
@@ -100,7 +101,7 @@ module Vedeu
100
101
 
101
102
  # @return [Symbol]
102
103
  def drb_connection_error
103
- puts 'Could not connect to DRb server.'
104
+ Vedeu.log_stdout(message: 'Could not connect to DRb server.')
104
105
 
105
106
  :drb_connection_error
106
107
  end
@@ -2,6 +2,7 @@ module Vedeu
2
2
 
3
3
  # @example
4
4
  # Vedeu::TestApplication.build
5
+ #
5
6
  class Subprocess
6
7
 
7
8
  # @param (see #initialize)
@@ -13,6 +13,7 @@ module Vedeu
13
13
  # app.menus = ''
14
14
  # app.views = ''
15
15
  # end
16
+ #
16
17
  class TestApplication
17
18
 
18
19
  # @!attribute [rw] borders
@@ -150,7 +150,7 @@ module Vedeu
150
150
  # @param value [Fixnum]
151
151
  # @return [Fixnum]
152
152
  def height(value)
153
- model.height = value
153
+ model.height = proc { value }
154
154
  end
155
155
 
156
156
  # Returns the height in characters for the number of rows specified.
@@ -182,7 +182,7 @@ module Vedeu
182
182
  # @param value [Fixnum]
183
183
  # @return [Fixnum]
184
184
  def width(value)
185
- model.width = value
185
+ model.width = proc { value }
186
186
  end
187
187
 
188
188
  # Specify the starting x position (column) of the interface.
@@ -36,28 +36,28 @@ module Vedeu
36
36
  # @option attributes options [Hash<Symbol => Boolean>]
37
37
  # @return [Vedeu::Area]
38
38
  def self.from_attributes(attributes = {})
39
- y_yn = Vedeu::Dimension.pair(d: attributes[:y],
40
- dn: attributes[:yn],
41
- d_dn: attributes[:y_yn],
42
- default: attributes[:y_default],
39
+ y_yn = Vedeu::Dimension.pair(d: attributes[:y],
40
+ dn: attributes[:yn],
41
+ d_dn: attributes[:y_yn],
42
+ default: attributes[:y_default],
43
43
  maximised: attributes[:maximised],
44
- centred: attributes[:centred])
45
- x_xn = Vedeu::Dimension.pair(d: attributes[:x],
46
- dn: attributes[:xn],
47
- d_dn: attributes[:x_xn],
48
- default: attributes[:x_default],
44
+ centred: attributes[:centred])
45
+ x_xn = Vedeu::Dimension.pair(d: attributes[:x],
46
+ dn: attributes[:xn],
47
+ d_dn: attributes[:x_xn],
48
+ default: attributes[:x_default],
49
49
  maximised: attributes[:maximised],
50
- centred: attributes[:centred])
50
+ centred: attributes[:centred])
51
51
 
52
52
  new(y: y_yn.first, yn: y_yn.last, x: x_xn.first, xn: x_xn.last)
53
53
  end
54
54
 
55
55
  # Returns a new instance of Vedeu::Area.
56
56
  #
57
- # @param y [Fixnum]
58
- # @param yn [Fixnum]
59
- # @param x [Fixnum]
60
- # @param xn [Fixnum]
57
+ # @param y [Fixnum] The starting row/line position.
58
+ # @param yn [Fixnum] The ending row/line position.
59
+ # @param x [Fixnum] The starting column/character position.
60
+ # @param xn [Fixnum] The ending column/character position.
61
61
  # @return [Vedeu::Area]
62
62
  def initialize(y:, yn:, x:, xn:)
63
63
  @y = y
@@ -153,11 +153,11 @@ module Vedeu
153
153
  @area = Vedeu::Area.from_attributes(
154
154
  y: _y,
155
155
  yn: _yn,
156
- y_yn: @height,
156
+ y_yn: _height,
157
157
  y_default: Vedeu.height,
158
158
  x: _x,
159
159
  xn: _xn,
160
- x_xn: @width,
160
+ x_xn: _width,
161
161
  x_default: Vedeu.width,
162
162
  centred: centred,
163
163
  maximised: maximised,
@@ -192,6 +192,20 @@ module Vedeu
192
192
  @xn.is_a?(Proc) ? @xn.call : @xn
193
193
  end
194
194
 
195
+ # Returns the width of the interface.
196
+ #
197
+ # @return [Fixnum]
198
+ def _width
199
+ @width.is_a?(Proc) ? @width.call : @width
200
+ end
201
+
202
+ # Returns the height of the interface.
203
+ #
204
+ # @return [Fixnum]
205
+ def _height
206
+ @height.is_a?(Proc) ? @height.call : @height
207
+ end
208
+
195
209
  # Returns the default options/attributes for this class.
196
210
  #
197
211
  # @return [Hash]
@@ -14,8 +14,8 @@ module Vedeu
14
14
 
15
15
  # Returns a new instance of Vedeu::PositionIndex.
16
16
  #
17
- # @param y [Fixnum]
18
- # @param x [Fixnum]
17
+ # @param y [Fixnum] The row/line coordinate.
18
+ # @param x [Fixnum] The column/character coordinate.
19
19
  # @return [Vedeu::PositionIndex]
20
20
  def initialize(y, x)
21
21
  @y = y
@@ -29,8 +29,8 @@ module Vedeu
29
29
  # Returns a new instance of Vedeu::PositionValidator.
30
30
  #
31
31
  # @param name [String]
32
- # @param x [Fixnum]
33
- # @param y [Fixnum]
32
+ # @param y [Fixnum] The row/line coordinate.
33
+ # @param x [Fixnum] The column/character coordinate.
34
34
  # @return [Vedeu::PositionValidator]
35
35
  def initialize(name, x, y)
36
36
  @name = name
@@ -9,6 +9,7 @@ module Vedeu
9
9
  # Styles are applied as encountered.
10
10
  #
11
11
  # @see Vedeu::Esc
12
+ #
12
13
  class Style
13
14
 
14
15
  include Vedeu::Common
@@ -44,8 +44,8 @@ module Vedeu
44
44
  # Convert to coordinate indices (cy, cx) e.g. (0, 0)
45
45
  # Fetch the row at cy and return the cell from cx
46
46
  #
47
- # @param y [Fixnum]
48
- # @param x [Fixnum]
47
+ # @param y [Fixnum] The row/line coordinate.
48
+ # @param x [Fixnum] The column/character coordinate.
49
49
  # @return [Vedeu::Char]
50
50
  def read(y, x)
51
51
  cy, cx = Vedeu::PositionIndex[y, x]
@@ -89,8 +89,8 @@ module Vedeu
89
89
  # If the position (y, x) is nil; we're out of bounds.
90
90
  # Otherwise, write the data to (cy, cx).
91
91
  #
92
- # @param y [Fixnum]
93
- # @param x [Fixnum]
92
+ # @param y [Fixnum] The row/line coordinate.
93
+ # @param x [Fixnum] The column/character coordinate.
94
94
  # @param data [Vedeu::Char]
95
95
  # @return [Vedeu::Char]
96
96
  def write(y, x, data)
@@ -4,6 +4,7 @@ module Vedeu
4
4
  #
5
5
  # This class loads all necessary client application files and initializes
6
6
  # Vedeu with this data, then starts the client application.
7
+ #
7
8
  class Bootstrap
8
9
 
9
10
  # @param argv [Array<String>]
@@ -78,8 +78,11 @@ module Vedeu
78
78
  @exit_code = 0
79
79
 
80
80
  rescue StandardError => uncaught_exception
81
- puts uncaught_exception.message
82
- puts uncaught_exception.backtrace.join("\n") if configuration.debug?
81
+ Vedeu.log_stdout(message: uncaught_exception.message)
82
+
83
+ if configuration.debug?
84
+ Vedeu.log_stdout(message: uncaught_exception.backtrace.join("\n"))
85
+ end
83
86
  end
84
87
 
85
88
  protected
@@ -21,6 +21,9 @@ module Vedeu
21
21
  'Cannot store controller without a name attribute.'
22
22
  end
23
23
 
24
+ Vedeu.log(type: :create,
25
+ message: "Adding ':#{controller_name}'")
26
+
24
27
  if registered?(controller_name)
25
28
  storage[controller_name].merge!(klass: klass)
26
29
 
@@ -42,6 +45,9 @@ module Vedeu
42
45
  # @return [void]
43
46
  def add_action(controller_name, action_name)
44
47
  if present?(controller_name) && present?(action_name)
48
+ Vedeu.log(type: :create,
49
+ message: "Adding ':#{action_name}' for ':#{controller_name}'")
50
+
45
51
  if registered?(controller_name)
46
52
  storage[controller_name][:actions] << action_name
47
53
 
@@ -73,6 +79,9 @@ module Vedeu
73
79
  # @return [void]
74
80
  def goto(controller_name, action_name, **args)
75
81
  if action_defined?(action_name, controller_name)
82
+ Vedeu.log(type: :debug,
83
+ message: "Routing: #{controller_name} #{action_name}")
84
+
76
85
  controller_with(controller_name).send(action_name, args)
77
86
  end
78
87
  end
@@ -6,12 +6,10 @@ module Vedeu
6
6
 
7
7
  # :nocov:
8
8
  Signal.trap('INT') do
9
- puts
10
9
  exit(1)
11
10
  end
12
11
 
13
12
  Signal.trap('TERM') do
14
- puts
15
13
  exit(1)
16
14
  end
17
15
 
@@ -1,6 +1,6 @@
1
1
  module Vedeu
2
2
 
3
3
  # The current version of Vedeu.
4
- VERSION = '0.4.63'
4
+ VERSION = '0.4.64'
5
5
 
6
6
  end
@@ -37,11 +37,13 @@ module Vedeu
37
37
  end
38
38
 
39
39
  describe '.action' do
40
- subject { described_model.action(:some_action) }
40
+ subject { described_model.action(:some_action, :other_action) }
41
41
 
42
42
  it {
43
43
  Vedeu::Router.expects(:add_action).
44
44
  with(:some_controller, :some_action)
45
+ Vedeu::Router.expects(:add_action).
46
+ with(:some_controller, :other_action)
45
47
  subject
46
48
  }
47
49
  end
@@ -77,7 +77,7 @@ module Vedeu
77
77
  subject { instance.height(6) }
78
78
 
79
79
  it 'sets the attribute to the value' do
80
- subject.must_equal(6)
80
+ subject.call.must_equal(6)
81
81
  end
82
82
 
83
83
  context 'DSL #height' do
@@ -136,7 +136,7 @@ module Vedeu
136
136
  subject { instance.width(25) }
137
137
 
138
138
  it 'sets the attribute to the value' do
139
- subject.must_equal(25)
139
+ subject.call.must_equal(25)
140
140
  end
141
141
 
142
142
  context 'DSL #width' do
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.authors = ['Gavin Laking']
11
11
  spec.email = ['gavinlaking@gmail.com']
12
12
  spec.summary = 'A terminal case of wonderland.'
13
- spec.description = 'A GUI/TUI framework for building terminal/console ' \
13
+ spec.description = 'A framework for building GUI/TUI terminal/console ' \
14
14
  'applications.'
15
15
  spec.homepage = 'https://github.com/gavinlaking/vedeu'
16
16
  spec.license = 'MIT'
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.4.63
4
+ version: 0.4.64
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gavin Laking
@@ -206,7 +206,7 @@ dependencies:
206
206
  - - '='
207
207
  - !ruby/object:Gem::Version
208
208
  version: 0.19.1
209
- description: A GUI/TUI framework for building terminal/console applications.
209
+ description: A framework for building GUI/TUI terminal/console applications.
210
210
  email:
211
211
  - gavinlaking@gmail.com
212
212
  executables: