vedeu 0.4.31 → 0.4.32

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: 540b0cefffc391e166bd83bc2f8dfe07a787ddc4
4
- data.tar.gz: 97224b316694a699ad7b4c1d042267ec90e35179
3
+ metadata.gz: 2db54587f464686863ae7a86653c4e690522f778
4
+ data.tar.gz: 8d0f17548d624a09022312fd9704632090a73b4a
5
5
  SHA512:
6
- metadata.gz: 2e7b07247d6957c4e032e9c9a4c9b4b760b5008fe4e2d81c86ec18ed7d7ca435fb0bb167d9d95135789e18c5b721267f84aa617d8f220ea4ffbb2efe9eb2a790
7
- data.tar.gz: 46b0f86a2e7d8f2194c102c50ffb83e81d0c0a467476c2b0231461cb1f77c0fb947908566c199687629e0f348b3d7f2636bfdc54720c99e4b98a1ac1faf5d541
6
+ metadata.gz: 5a817ae692b688d3a6f67b70c3f88a2fc2775c2b754fa227e5e7b0610705c4c52a266a631fe4efc169b9c26867141cbf48a1ca2e73acbe3d1a047b451dfa75f2
7
+ data.tar.gz: 5a2423e352bc179911a180df68addaf8b194786dff67ebece988897e4756d5386c71fb8dc97281b47c92665058daeee8d5476ee7445a8e59ed28fa5d1108d23f
@@ -13,7 +13,7 @@ class VedeuBordersApp
13
13
  # Be aware that running an application with debugging enabled will affect
14
14
  # performance.
15
15
  configure do
16
- debug!
16
+ # debug!
17
17
  log '/tmp/vedeu_borders_app.log'
18
18
  end
19
19
 
@@ -13,7 +13,7 @@ class VedeuColoursApp
13
13
  # Be aware that running an application with debugging enabled will affect
14
14
  # performance.
15
15
  configure do
16
- debug!
16
+ # debug!
17
17
  log '/tmp/vedeu_colours_app.log'
18
18
  end
19
19
 
@@ -20,7 +20,7 @@ class VedeuConfigurationApp
20
20
  include Vedeu
21
21
 
22
22
  configure do
23
- debug!
23
+ # debug!
24
24
  log '/tmp/vedeu_configuration_app.log'
25
25
  end
26
26
 
@@ -12,7 +12,7 @@ class VedeuTestApplication
12
12
  # performance.
13
13
  Vedeu.configure do
14
14
  log '/tmp/vedeu_test_helper.log'
15
- debug!
15
+ # debug!
16
16
  drb!
17
17
  drb_host 'localhost'
18
18
  drb_port 21_420
@@ -18,7 +18,7 @@ class VedeuFocusApp
18
18
  # Be aware that running an application with debugging enabled will affect
19
19
  # performance.
20
20
  Vedeu.configure do
21
- debug!
21
+ # debug!
22
22
  log '/tmp/vedeu_focus_app.log'
23
23
  end
24
24
 
@@ -13,7 +13,7 @@ class VedeuGeometryApp
13
13
  # Be aware that running an application with debugging enabled will affect
14
14
  # performance.
15
15
  configure do
16
- debug!
16
+ # debug!
17
17
  log '/tmp/vedeu_geometry_app.log'
18
18
  end
19
19
 
@@ -14,7 +14,7 @@ class HelloWorldApp
14
14
  include Vedeu
15
15
 
16
16
  configure do
17
- debug!
17
+ # debug!
18
18
  log '/tmp/vedeu_hello_world.log'
19
19
  end
20
20
 
@@ -14,7 +14,7 @@ class VedeuMaterialColoursApp
14
14
  # Be aware that running an application with debugging enabled will affect
15
15
  # performance.
16
16
  configure do
17
- debug!
17
+ # debug!
18
18
  log '/tmp/vedeu_material_colours_app.log'
19
19
  # renderers Vedeu::Renderers::File
20
20
  end
@@ -14,7 +14,7 @@ class VedeuPanelApp
14
14
  # Be aware that running an application with debugging enabled will affect
15
15
  # performance.
16
16
  configure do
17
- debug!
17
+ # debug!
18
18
  log '/tmp/vedeu_panel_app.log'
19
19
  # renderers Vedeu::Renderers::File
20
20
  end
@@ -58,8 +58,6 @@ module Vedeu
58
58
  runner { main_sequence }
59
59
  end
60
60
 
61
- Vedeu.trigger(:_drb_stop_)
62
-
63
61
  output
64
62
  end
65
63
 
@@ -74,9 +74,6 @@ module Vedeu
74
74
  # events. Please see those events for their behaviour.
75
75
  Vedeu.bind(:_resize_, delay: 0.15) { Vedeu.resize }
76
76
 
77
- Vedeu.bind(:tick) { |t| Vedeu.log(type: :debug, message: "Tick: #{t}") }
78
- Vedeu.bind(:tock) { |t| Vedeu.log(type: :debug, message: "Tock: #{t}") }
79
-
80
77
  # Hide the cursor of the named interface or interface currently in focus.
81
78
  Vedeu.bind(:_cursor_hide_) do |name|
82
79
  Vedeu::Visibility.for_cursor(name).hide
@@ -257,7 +257,7 @@ module Vedeu
257
257
  drb_height: 25,
258
258
  drb_width: 80,
259
259
  interactive: true,
260
- log: '/tmp/vedeu.log',
260
+ log: nil,
261
261
  once: false,
262
262
  renderers: [Vedeu::Renderers::Terminal],
263
263
  stdin: nil,
@@ -72,9 +72,6 @@ module Vedeu
72
72
  #
73
73
  # @return [Vedeu::Colour]
74
74
  def colour(attributes = {})
75
- attributes.delete_if do |k, v|
76
- [:background, :foreground].include?(k) == false || v.nil? || v.empty?
77
- end
78
75
  model.colour = Vedeu::Colour.coerce(attributes)
79
76
  end
80
77
 
@@ -35,20 +35,16 @@ module Vedeu
35
35
  # @return [Vedeu::Area]
36
36
  def self.from_attributes(y:, yn:, y_yn:, y_default:,
37
37
  x:, xn:, x_xn:, x_default:, options:)
38
- y_yn = Vedeu::Dimension.pair({
39
- d: y,
40
- dn: yn,
41
- d_dn: y_yn,
42
- default: y_default,
43
- options: options,
44
- })
45
- x_xn = Vedeu::Dimension.pair({
46
- d: x,
47
- dn: xn,
48
- d_dn: x_xn,
49
- default: x_default,
50
- options: options,
51
- })
38
+ y_yn = Vedeu::Dimension.pair(d: y,
39
+ dn: yn,
40
+ d_dn: y_yn,
41
+ default: y_default,
42
+ options: options)
43
+ x_xn = Vedeu::Dimension.pair(d: x,
44
+ dn: xn,
45
+ d_dn: x_xn,
46
+ default: x_default,
47
+ options: options)
52
48
 
53
49
  from_dimensions(y_yn: y_yn, x_xn: x_xn)
54
50
  end
@@ -81,6 +81,7 @@ module Vedeu
81
81
  y_range[index]
82
82
 
83
83
  end
84
+
84
85
  validate_y(value)
85
86
  end
86
87
 
@@ -106,6 +107,7 @@ module Vedeu
106
107
  x_range[index]
107
108
 
108
109
  end
110
+
109
111
  validate_x(value)
110
112
  end
111
113
 
@@ -2,53 +2,51 @@ module Vedeu
2
2
 
3
3
  # Provides the main loop for a Vedeu application.
4
4
  #
5
- # Each time Vedeu starts one cycle in the application loop, it triggers the
6
- # `:tick` event. A completion of that cycle will trigger `:tock`. This can be
7
- # used by the client application for timing amongst other things.
8
5
  class MainLoop
9
6
 
10
7
  trap('SIGTERM') { stop! }
11
8
  trap('TERM') { stop! }
12
9
  trap('INT') { stop! }
13
10
 
14
- # :nocov:
15
- # Start the main loop.
16
- #
17
- # @return [void]
18
- # @yieldreturn [void] The client application.
19
- def self.start!
20
- @started = true
21
- @loop = true
11
+ class << self
22
12
 
23
- while @loop
24
- yield
13
+ # :nocov:
14
+ # Start the main loop.
15
+ #
16
+ # @return [void]
17
+ # @yieldreturn [void] The client application.
18
+ def start!
19
+ @started = true
20
+ @loop = true
25
21
 
26
- safe_exit_point!
27
- end
28
- rescue VedeuInterrupt
29
- Vedeu.log(type: :debug, message: 'Vedeu execution interrupted, exiting.')
30
- end
31
- # :nocov:
22
+ while @loop
23
+ yield
32
24
 
33
- # Signal that we wish to terminate the running application.
34
- #
35
- # @return [void]
36
- def self.stop!
37
- @loop = false
38
- end
25
+ safe_exit_point!
26
+ end
27
+ rescue VedeuInterrupt
28
+ Vedeu.log(type: :debug,
29
+ message: 'Vedeu execution interrupted, exiting.')
39
30
 
40
- # Check the application has started and we wish to continue running.
41
- #
42
- # @raise [VedeuInterrupt] When we wish to terminate the running application.
43
- # @return [void]
44
- def self.safe_exit_point!
45
- if @started && !@loop
46
- fail VedeuInterrupt
31
+ end
32
+ # :nocov:
47
33
 
48
- else
49
- Vedeu.trigger(:tock, Time.now.to_f)
34
+ # Signal that we wish to terminate the running application.
35
+ #
36
+ # @return [void]
37
+ def stop!
38
+ @loop = false
39
+ end
50
40
 
41
+ # Check the application has started and we wish to continue running.
42
+ #
43
+ # @raise [VedeuInterrupt] When we wish to terminate the running
44
+ # application.
45
+ # @return [void]
46
+ def safe_exit_point!
47
+ fail VedeuInterrupt if @started && !@loop
51
48
  end
49
+
52
50
  end
53
51
 
54
52
  end # MainLoop
@@ -101,8 +101,8 @@ module Vedeu
101
101
  # @return [TrueClass]
102
102
  def logger
103
103
  MonoLogger.new(log_file).tap do |log|
104
- log.formatter = proc do |_, time, _, message|
105
- formatted_message(message, time)
104
+ log.formatter = proc do |_, _, _, message|
105
+ formatted_message(message)
106
106
  end
107
107
  end
108
108
  end
@@ -110,21 +110,16 @@ module Vedeu
110
110
  private
111
111
 
112
112
  # @param message [String]
113
- # @param time [Time]
114
113
  # @return [String]
115
- def formatted_message(message, time = Time.now)
116
- [timestamp(time.utc.iso8601), message, "\n"].join
117
- end
118
-
119
- # @return [Boolean]
120
- def enabled?
121
- Vedeu::Configuration.debug?
114
+ def formatted_message(message)
115
+ [timestamp, message, "\n"].join
122
116
  end
123
117
 
124
118
  # @return [String]
125
119
  def log_file
126
120
  Vedeu::Configuration.log
127
121
  end
122
+ alias_method :enabled?, :log_file
128
123
 
129
124
  # @param type [Symbol] The type of log message.
130
125
  # @param body [String] The log message itself.
@@ -161,17 +156,21 @@ module Vedeu
161
156
  }
162
157
  end
163
158
 
164
- # Returns a formatted (red, underlined) UTC timestamp,
165
- # eg. 2014-10-24T12:34:56Z
159
+ # Returns a formatted timestamp.
160
+ # eg. [137.7824]
166
161
  #
167
- # @param utc_time [String]
168
162
  # @return [String]
169
- def timestamp(utc_time)
170
- return '' if @last_seen == utc_time
171
-
172
- @last_seen = utc_time
163
+ def timestamp
164
+ @now = Time.now.to_f
165
+ @time = 0.0 unless @time
166
+ @last = @now unless @last
167
+
168
+ unless @last == @time
169
+ @time += (@now - @last).round(4)
170
+ @last = @now
171
+ end
173
172
 
174
- "\n\e[4m\e[31m" + utc_time + "\e[39m\e[24m\n"
173
+ "[#{'%7.4f' % @time.to_s}] ".rjust(7)
175
174
  end
176
175
 
177
176
  end # Log eigenclass
@@ -18,14 +18,10 @@ module Vedeu
18
18
  fail InvalidSyntax, 'block not given' unless block_given?
19
19
 
20
20
  if raw_mode?
21
- Vedeu.log(type: :info, message: "Terminal entering 'raw' mode")
22
-
23
- console.raw { initialize_screen { yield } }
21
+ console.raw { initialize_screen(mode) { yield } }
24
22
 
25
23
  else
26
- Vedeu.log(type: :info, message: "Terminal entering 'cooked' mode")
27
-
28
- console.cooked { initialize_screen { yield } }
24
+ console.cooked { initialize_screen(mode) { yield } }
29
25
 
30
26
  end
31
27
  ensure
@@ -53,8 +49,6 @@ module Vedeu
53
49
 
54
50
  end
55
51
 
56
- Vedeu.trigger(:tick, Time.now.to_f)
57
-
58
52
  keys_or_cmd
59
53
  end
60
54
  alias_method :read, :input
@@ -90,8 +84,11 @@ module Vedeu
90
84
  true
91
85
  end
92
86
 
87
+ # @param mode [Symbol]
93
88
  # @return [void]
94
- def initialize_screen
89
+ def initialize_screen(mode)
90
+ Vedeu.log(type: :info, message: "Terminal entering '#{mode}' mode")
91
+
95
92
  output(Esc.string('screen_init'))
96
93
 
97
94
  yield if block_given?
@@ -136,8 +133,6 @@ module Vedeu
136
133
  #
137
134
  # @return [Symbol]
138
135
  def cooked_mode!
139
- Vedeu.log(type: :info, message: "Terminal switching to 'cooked' mode")
140
-
141
136
  @mode = :cooked
142
137
  end
143
138
 
@@ -153,8 +148,6 @@ module Vedeu
153
148
  #
154
149
  # @return [Symbol]
155
150
  def raw_mode!
156
- Vedeu.log(type: :info, message: "Terminal switching to 'raw' mode")
157
-
158
151
  @mode = :raw
159
152
  end
160
153
 
@@ -23,10 +23,10 @@ module Vedeu
23
23
 
24
24
  # @param block [Proc]
25
25
  # @return [void]
26
- def measure(&block)
26
+ def measure
27
27
  work = yield
28
28
 
29
- elapsed = ((Time.now.to_f - started) * 1000).to_i
29
+ elapsed = ((Time.now.to_f - started) * 1000).round(3)
30
30
 
31
31
  Vedeu.log(type: :timer, message: "#{message} took #{elapsed}ms.")
32
32
 
@@ -1,3 +1,5 @@
1
1
  module Vedeu
2
- VERSION = '0.4.31'
2
+
3
+ VERSION = '0.4.32'
4
+
3
5
  end
@@ -20,8 +20,6 @@ module Vedeu
20
20
  it { Vedeu.events.registered?(:_refresh_group_).must_equal(true) }
21
21
  it { Vedeu.events.registered?(:_resize_).must_equal(true) }
22
22
  it { Vedeu.events.registered?(:_show_group_).must_equal(true) }
23
- it { Vedeu.events.registered?(:tick).must_equal(true) }
24
- it { Vedeu.events.registered?(:tock).must_equal(true) }
25
23
  end
26
24
 
27
25
  context 'the cursor specific events are defined' do
@@ -50,16 +50,6 @@ module Vedeu
50
50
 
51
51
  it { subject.must_be_instance_of(Vedeu::Colour) }
52
52
 
53
- context 'with an invalid attribute' do
54
- let(:attributes) { { invalid: background, foreground: foreground } }
55
-
56
- it 'sets only the valid attributes' do
57
- subject.attributes.must_equal(
58
- background: '', foreground: '#ff00ff'
59
- )
60
- end
61
- end
62
-
63
53
  context 'with an empty value' do
64
54
  let(:attributes) { { background: background, foreground: '' } }
65
55
 
@@ -26,10 +26,6 @@ module Vedeu
26
26
  context 'when the loop is not running' do
27
27
  end
28
28
  end
29
-
30
- context 'when the application has not started' do
31
- it { Vedeu.expects(:trigger); subject }
32
- end
33
29
  end
34
30
 
35
31
  end # MainLoop
@@ -30,7 +30,7 @@ module Vedeu
30
30
 
31
31
  it {
32
32
  Vedeu.expects(:log).with(type: :timer,
33
- message: "Testing took 0ms.")
33
+ message: "Testing took 0.0ms.")
34
34
  subject
35
35
  }
36
36
  end
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.31
4
+ version: 0.4.32
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gavin Laking