vedeu 0.4.37 → 0.4.38

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: e29978c4b64039fc130cc5bad584e48e4ab08a6d
4
- data.tar.gz: b88b3581a5d9db259b16536802ce766ac00fd524
3
+ metadata.gz: eba167b2296986a617d87379d671da43b1fdfde5
4
+ data.tar.gz: f680e8ca3c7fc1cf653a331b06f6b254069f1549
5
5
  SHA512:
6
- metadata.gz: c2d7cf78b2fe8c5282fd1f3c4f3d25210d258a2db632d1cb7cdf6214c743e54141b104af5868f33fab97a0de017e0e17db663511ffb4d49ef805fa48032c3d12
7
- data.tar.gz: d880b25648befe1cabb5441c2e62a5b08b2391abfdf684b25c8063233784c36252a86460dfeb0c52217d2600b1e318cb5ef8a20b22f22a6c640692a58a6c8b7c
6
+ metadata.gz: 62dfe9eec435c85f18d7b0556ae6d1f0549d4d442144a13dd816c80370b046e03566b0bc2f972a2e6f556832c9e4eb9cb807103f38cb25e77e9a09b4ca0cbbeb
7
+ data.tar.gz: aa1b63928e5bd9eed88413945780f5ba202a7f211d9abb96c71432d02cebaf8362c0617a69078af61d900a0c82868793531540824106560c6a063f60da02f6f8
@@ -20,6 +20,9 @@ class VedeuBordersApp
20
20
  configure do
21
21
  # debug!
22
22
  log '/tmp/vedeu_borders_app.log'
23
+ raw!
24
+ run_once!
25
+ standalone!
23
26
  end
24
27
 
25
28
  interface 'default_border' do
@@ -74,7 +74,7 @@ class VedeuMaterialColoursApp
74
74
  key('k') { Vedeu.trigger(:_view_up_, 'other_interface') }
75
75
  key('l') { Vedeu.trigger(:_view_right_, 'other_interface') }
76
76
 
77
- key('t') do
77
+ key('t') do
78
78
  Vedeu.trigger(:_toggle_interface_, 'main_interface')
79
79
  Vedeu.trigger(:_toggle_interface_, 'other_interface')
80
80
  end
@@ -125,6 +125,18 @@ module Vedeu
125
125
  Vedeu::Position.new(cursor.y, cursor.x) if cursor
126
126
  end
127
127
 
128
+ # Move the cursor to a relative position inside the interface.
129
+ #
130
+ # @todo
131
+ # - The content of the interface needs to be a consideration.
132
+ # - If the screen size changes, what should happen to the cursor.
133
+ # - How do we represent cursors which are deliberately positioned outside
134
+ # of the viewable area?
135
+ #
136
+ Vedeu.bind(:_cursor_reposition_) do |name, y, x|
137
+ Vedeu::Reposition.to(Vedeu::Cursor, name, y, x)
138
+ end
139
+
128
140
  # @see {Vedeu::Move}
129
141
  Vedeu.bind(:_cursor_reset_) { |name| Vedeu.trigger(:_cursor_origin_, name) }
130
142
 
@@ -3,3 +3,4 @@ require 'vedeu/repositories/all'
3
3
  require_relative 'cursor'
4
4
  require_relative 'move'
5
5
  require_relative 'refresh_cursor'
6
+ require_relative 'reposition'
@@ -16,13 +16,13 @@ module Vedeu
16
16
  # @return [String]
17
17
  attr_reader :name
18
18
 
19
- # @!attribute [r] ox
19
+ # @!attribute [rw] ox
20
20
  # @return [Fixnum]
21
- attr_reader :ox
21
+ attr_accessor :ox
22
22
 
23
- # @!attribute [r] oy
23
+ # @!attribute [rw] oy
24
24
  # @return [Fixnum]
25
- attr_reader :oy
25
+ attr_accessor :oy
26
26
 
27
27
  # @!attribute [r] state
28
28
  # @return [Boolean|Symbol]
@@ -33,13 +33,13 @@ module Vedeu
33
33
  attr_reader :visible
34
34
  alias_method :visible?, :visible
35
35
 
36
- # @!attribute [r] x
36
+ # @!attribute [rw] x
37
37
  # @return [Fixnum]
38
- attr_reader :x
38
+ attr_accessor :x
39
39
 
40
- # @!attribute [r] y
40
+ # @!attribute [rw] y
41
41
  # @return [Fixnum]
42
- attr_reader :y
42
+ attr_accessor :y
43
43
 
44
44
  # Returns a new instance of Vedeu::Cursor.
45
45
  #
@@ -0,0 +1,95 @@
1
+ module Vedeu
2
+
3
+ # @api private
4
+ class Reposition
5
+
6
+ # @return [Vedeu::Cursor]
7
+ # @see Vedeu::Reposition.new
8
+ def self.to(entity, name, y, x)
9
+ new(entity, name, y, x).to
10
+ end
11
+
12
+ # @param entity []
13
+ # @param name [String]]
14
+ # @param y [Fixnum]
15
+ # @param x [Fixnum]
16
+ # @return [Vedeu::Reposition]
17
+ def initialize(entity, name, y, x)
18
+ @entity = entity
19
+ @name = name
20
+ @y = y
21
+ @x = x
22
+ end
23
+
24
+ # @return [Vedeu::Cursor]
25
+ def to
26
+ result = @entity.new(name: name,
27
+ y: y_position,
28
+ x: x_position,
29
+ oy: y,
30
+ ox: x).store
31
+
32
+ Vedeu.trigger(:_clear_, name)
33
+ Vedeu.trigger(:_refresh_, name)
34
+ Vedeu.trigger(:_refresh_cursor_, name)
35
+
36
+ result
37
+ end
38
+
39
+ protected
40
+
41
+ # @!attribute [r] entity
42
+ # @return [String]
43
+ attr_reader :entity
44
+
45
+ # @!attribute [r] name
46
+ # @return [String]
47
+ attr_reader :name
48
+
49
+ # @!attribute [r] x
50
+ # @return [Fixnum]
51
+ attr_reader :x
52
+
53
+ # @!attribute [r] y
54
+ # @return [Fixnum]
55
+ attr_reader :y
56
+
57
+ private
58
+
59
+ # @return [Coordinate]
60
+ def coordinate
61
+ @coordinate ||= Vedeu::Coordinate.new(name)
62
+ end
63
+
64
+ # @return [Vedeu::Cursor]
65
+ def entity
66
+ @_entity ||= @entity.new
67
+ end
68
+
69
+ # @return [Vedeu::Cursor]
70
+ def model
71
+ @model ||= repository.by_name(name)
72
+ end
73
+
74
+ # @return [Vedeu::Cursors]
75
+ def repository
76
+ entity.repository
77
+ end
78
+
79
+ # Returns the cursors x position based on the desired x position.
80
+ #
81
+ # @return [Fixnum]
82
+ def x_position
83
+ coordinate.x_position(x)
84
+ end
85
+
86
+ # Returns the cursors y position based on the desired y position.
87
+ #
88
+ # @return [Fixnum]
89
+ def y_position
90
+ coordinate.y_position(y)
91
+ end
92
+
93
+ end # Reposition
94
+
95
+ end # Vedeu
@@ -23,6 +23,7 @@ module Vedeu
23
23
  make_directory_structure
24
24
 
25
25
  copy_gemfile
26
+ copy_application_bootstrapper
26
27
  copy_application_controller
27
28
  copy_application_helper
28
29
  copy_global_keymap
@@ -37,9 +38,11 @@ module Vedeu
37
38
 
38
39
  # @return [void]
39
40
  def make_directory_structure
40
- directories.each do |directory|
41
- FileUtils.mkdir_p(name + directory)
42
- end
41
+ directories.each { |directory| make_directory(name + directory) }
42
+ end
43
+
44
+ def copy_application_bootstrapper
45
+ make_file(source + '/application.erb', "#{name}/application.rb")
43
46
  end
44
47
 
45
48
  # @return [void]
@@ -49,21 +52,20 @@ module Vedeu
49
52
  end
50
53
 
51
54
  # @return [void]
52
- def copy_application_helper
53
- make_file(source + '/app/helpers/application_helper.erb',
54
- name + '/app/helpers/application_helper.rb')
55
+ def copy_application_executable
56
+ copy_file(source + '/bin/name', "#{name}/bin/#{name}")
55
57
  end
56
58
 
57
59
  # @return [void]
58
- def copy_application_executable
59
- FileUtils.cp(source + '/bin/name',
60
- "#{name}/bin/#{name}")
60
+ def copy_application_helper
61
+ make_file(source + '/app/helpers/application_helper.erb',
62
+ name + '/app/helpers/application_helper.rb')
61
63
  end
62
64
 
63
65
  # @return [void]
64
66
  def copy_configuration
65
- FileUtils.cp(source + '/config/configuration.rb',
66
- "#{name}/config/configuration.rb")
67
+ copy_file(source + '/config/configuration.rb',
68
+ "#{name}/config/configuration.rb")
67
69
  end
68
70
 
69
71
  # @return [void]
@@ -74,7 +76,7 @@ module Vedeu
74
76
 
75
77
  # @return [void]
76
78
  def copy_gemfile
77
- FileUtils.cp(source + '/Gemfile', "#{name}/Gemfile")
79
+ copy_file(source + '/Gemfile', "#{name}/Gemfile")
78
80
  end
79
81
 
80
82
  # @return [void]
@@ -84,14 +86,14 @@ module Vedeu
84
86
 
85
87
  # @return [void]
86
88
  def copy_global_keymap
87
- FileUtils.cp(source + '/app/models/keymaps/_global_.rb',
88
- "#{name}/app/models/keymaps/_global_.rb")
89
+ copy_file(source + '/app/models/keymaps/_global_.rb',
90
+ "#{name}/app/models/keymaps/_global_.rb")
89
91
  end
90
92
 
91
93
  # @return [void]
92
94
  def copy_system_keymap
93
- FileUtils.cp(source + '/app/models/keymaps/_system_.rb',
94
- "#{name}/app/models/keymaps/_system_.rb")
95
+ copy_file(source + '/app/models/keymaps/_system_.rb',
96
+ "#{name}/app/models/keymaps/_system_.rb")
95
97
  end
96
98
 
97
99
  # @return [Array<String>]
@@ -20,15 +20,40 @@ module Vedeu
20
20
  name
21
21
  end
22
22
 
23
+ # @param destination [String]
24
+ # @return [void]
25
+ def make_directory(destination)
26
+ Vedeu.log_stdout(type: :create, message: "#{destination}")
27
+
28
+ FileUtils.mkdir_p(destination)
29
+ end
30
+
31
+ # @param source [String]
32
+ # @param destination [String]
33
+ # @return [void]
34
+ def copy_file(source, destination)
35
+ Vedeu.log_stdout(type: :create, message: "#{destination}")
36
+
37
+ FileUtils.cp(source, destination)
38
+ end
39
+
23
40
  # @param source [String]
24
41
  # @param destination [String]
25
42
  # @return [void]
26
43
  def make_file(source, destination)
27
- Vedeu.log_stdout(type: :create, message: "Writing: '#{destination}'")
44
+ Vedeu.log_stdout(type: :create, message: "#{destination}")
28
45
 
29
46
  File.write(destination, parse(source))
30
47
  end
31
48
 
49
+ # @param destination [String]
50
+ # @return [void]
51
+ def touch_file(destination)
52
+ Vedeu.log_stdout(type: :create, message: "#{destination}")
53
+
54
+ FileUtils.touch(destination)
55
+ end
56
+
32
57
  # @return [String]
33
58
  def name
34
59
  @_name ||= @name.downcase
@@ -1,4 +1,4 @@
1
- module YourAppName
1
+ module <%= object.name_as_class %>
2
2
 
3
3
  class Application
4
4
 
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __FILE__)
3
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
4
4
 
5
5
  require 'bundler/setup' # Set up gems listed in the Gemfile.
6
6
 
@@ -55,7 +55,7 @@ module Vedeu
55
55
 
56
56
  # @return [void]
57
57
  def make_template_file
58
- FileUtils.touch('.' + "/app/views/templates/#{name}.erb")
58
+ touch_file('.' + "/app/views/templates/#{name}.erb")
59
59
  end
60
60
 
61
61
  # @return [void]
@@ -95,8 +95,23 @@ module Vedeu
95
95
 
96
96
  update
97
97
  end
98
- alias_method :next, :next_item
99
- alias_method :focus_next, :next_item
98
+ alias_method :next, :next_item
99
+
100
+ # Put the next visible interface relative to the current interfaces in
101
+ # focus.
102
+ #
103
+ # @return [String]
104
+ def next_visible_item
105
+ return update unless visible_items?
106
+
107
+ loop do
108
+ storage.rotate!
109
+ break if Vedeu.interfaces.by_name(current).visible?
110
+ end
111
+
112
+ update
113
+ end
114
+ alias_method :focus_next, :next_visible_item
100
115
 
101
116
  # Put the previous interface relative to the current interface in focus.
102
117
  #
@@ -109,9 +124,24 @@ module Vedeu
109
124
 
110
125
  update
111
126
  end
112
- alias_method :prev, :prev_item
113
- alias_method :previous, :prev_item
114
- alias_method :focus_previous, :prev_item
127
+ alias_method :prev, :prev_item
128
+ alias_method :previous, :prev_item
129
+
130
+ # Put the previous visible interface relative to the current interfaces in
131
+ # focus.
132
+ #
133
+ # @return [String]
134
+ def prev_visible_item
135
+ return update unless visible_items?
136
+
137
+ loop do
138
+ storage.rotate!(-1)
139
+ break if Vedeu.interfaces.by_name(current).visible?
140
+ end
141
+
142
+ update
143
+ end
144
+ alias_method :focus_previous, :prev_visible_item
115
145
 
116
146
  # Refresh the interface in focus.
117
147
  #
@@ -176,6 +206,11 @@ module Vedeu
176
206
  []
177
207
  end
178
208
 
209
+ # @return [Boolean]
210
+ def visible_items?
211
+ storage.any? { |name| Vedeu.interfaces.by_name(name).visible? }
212
+ end
213
+
179
214
  end # Focus
180
215
 
181
216
  end # Vedeu
@@ -40,7 +40,6 @@ module Vedeu
40
40
  # @param value []
41
41
  # @return [Object]
42
42
  def self.coerce(value)
43
- # Vedeu::ColourCoercer.coerce(value)
44
43
  return value if value.is_a?(self)
45
44
  return new unless value.is_a?(Hash)
46
45
 
@@ -1,4 +1,3 @@
1
- require_relative 'colour_coercer'
2
1
  require_relative 'common'
3
2
  require_relative 'options'
4
3
  require_relative 'template'
@@ -97,8 +97,11 @@ module Vedeu
97
97
  #
98
98
  # @return [TrueClass]
99
99
  def log(message:, force: false, type: :info)
100
- logger.debug([message_type(type),
101
- message_body(type, message)]) if enabled? || force
100
+ output = [message_type(type), message_body(type, message)]
101
+
102
+ logger.debug(output) if enabled? || force
103
+
104
+ output
102
105
  end
103
106
 
104
107
  # @return [TrueClass]
@@ -111,6 +114,8 @@ module Vedeu
111
114
  $stderr.puts [message_type(type), message_body(type, message)].join
112
115
  end
113
116
 
117
+ private
118
+
114
119
  # @return [TrueClass]
115
120
  def logger
116
121
  MonoLogger.new(log_file).tap do |log|
@@ -120,8 +125,6 @@ module Vedeu
120
125
  end
121
126
  end
122
127
 
123
- private
124
-
125
128
  # @param message [String]
126
129
  # @return [String]
127
130
  def formatted_message(message)
@@ -183,7 +186,7 @@ module Vedeu
183
186
  @last = @now
184
187
  end
185
188
 
186
- "[#{format(@time.to_s, '%7.4f')}] ".rjust(7)
189
+ "[#{format('%7.4f', @time.to_s)}] ".rjust(7)
187
190
  end
188
191
 
189
192
  end # Log eigenclass
@@ -28,12 +28,13 @@ module Vedeu
28
28
  @started = Time.now.to_f
29
29
  end
30
30
 
31
+ # Write an entry to the log file stating how long a section of code took in
32
+ # milliseconds. Useful for debugging performance.
33
+ #
31
34
  # @return [void]
32
35
  def measure
33
36
  work = yield
34
37
 
35
- elapsed = ((Time.now.to_f - started) * 1000).round(3)
36
-
37
38
  Vedeu.log(type: :timer, message: "#{message} took #{elapsed}ms.")
38
39
 
39
40
  work
@@ -49,6 +50,13 @@ module Vedeu
49
50
  # @return [String]
50
51
  attr_reader :message
51
52
 
53
+ # Returns the elapsed time in milliseconds with 3 decimal places.
54
+ #
55
+ # @return [Float]
56
+ def elapsed
57
+ ((Time.now.to_f - started) * 1000).round(3)
58
+ end
59
+
52
60
  end # Timer
53
61
 
54
62
  end # Vedeu
data/lib/vedeu/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Vedeu
2
2
 
3
3
  # The current version of Vedeu.
4
- VERSION = '0.4.37'
4
+ VERSION = '0.4.38'
5
5
 
6
6
  end
@@ -30,6 +30,8 @@ module Vedeu
30
30
  it { Vedeu.events.registered?(:_cursor_right_).must_equal(true) }
31
31
  it { Vedeu.events.registered?(:_cursor_up_).must_equal(true) }
32
32
  it { Vedeu.events.registered?(:_cursor_origin_).must_equal(true) }
33
+ it { Vedeu.events.registered?(:_cursor_position_).must_equal(true) }
34
+ it { Vedeu.events.registered?(:_cursor_reposition_).must_equal(true) }
33
35
  it { Vedeu.events.registered?(:_cursor_reset_).must_equal(true) }
34
36
  end
35
37
 
@@ -22,7 +22,10 @@ module Vedeu
22
22
  describe '#start' do
23
23
  subject { instance.start }
24
24
 
25
-
25
+ it {
26
+ Vedeu::Launcher.expects(:execute!)
27
+ subject
28
+ }
26
29
  end
27
30
 
28
31
  end # Bootstrap
@@ -51,10 +51,18 @@ module Vedeu
51
51
  it { instance.must_respond_to(:ox) }
52
52
  end
53
53
 
54
+ describe '#ox=' do
55
+ it { instance.must_respond_to(:ox=) }
56
+ end
57
+
54
58
  describe '#oy' do
55
59
  it { instance.must_respond_to(:oy) }
56
60
  end
57
61
 
62
+ describe '#oy=' do
63
+ it { instance.must_respond_to(:oy=) }
64
+ end
65
+
58
66
  describe '#state' do
59
67
  it { instance.must_respond_to(:state) }
60
68
  end
@@ -68,10 +76,18 @@ module Vedeu
68
76
  it { instance.must_respond_to(:x) }
69
77
  end
70
78
 
79
+ describe '#x=' do
80
+ it { instance.must_respond_to(:x=) }
81
+ end
82
+
71
83
  describe '#y' do
72
84
  it { instance.must_respond_to(:y) }
73
85
  end
74
86
 
87
+ describe '#y=' do
88
+ it { instance.must_respond_to(:y=) }
89
+ end
90
+
75
91
  describe '#hide_cursor' do
76
92
  subject { instance.hide_cursor }
77
93
 
@@ -0,0 +1,47 @@
1
+ require 'test_helper'
2
+
3
+ module Vedeu
4
+
5
+ describe Reposition do
6
+
7
+ let(:described) { Vedeu::Reposition }
8
+ let(:instance) { described.new(entity, _name, y, x) }
9
+ let(:entity) { Vedeu::Cursor }
10
+ let(:_name) { 'reposition' }
11
+ let(:x) { 4 }
12
+ let(:y) { 7 }
13
+
14
+ before do
15
+ Vedeu::Cursor.new(name: _name, x: 1, y: 1, ox: 1, oy: 1)
16
+ Vedeu.stubs(:trigger)
17
+ end
18
+
19
+ after { Vedeu.cursors.reset }
20
+
21
+ describe '#initialize' do
22
+ subject { instance }
23
+
24
+ it { instance.must_be_instance_of(Vedeu::Reposition) }
25
+ it { instance.instance_variable_get('@entity').must_equal(entity) }
26
+ it { instance.instance_variable_get('@name').must_equal(_name) }
27
+ it { instance.instance_variable_get('@x').must_equal(x) }
28
+ it { instance.instance_variable_get('@y').must_equal(y) }
29
+ end
30
+
31
+ describe '.to' do
32
+ it { described.must_respond_to(:to) }
33
+ end
34
+
35
+ describe '#to' do
36
+ subject { instance.to }
37
+
38
+ it { subject.must_be_instance_of(entity) }
39
+ it { subject.x.must_equal(5) }
40
+ it { subject.y.must_equal(8) }
41
+ it { subject.ox.must_equal(4) }
42
+ it { subject.oy.must_equal(7) }
43
+ end
44
+
45
+ end # Reposition
46
+
47
+ end # Vedeu
@@ -21,31 +21,11 @@ module Vedeu
21
21
  end
22
22
 
23
23
  describe '.generate' do
24
- subject { described.generate(_name) }
24
+ it { described.must_respond_to(:generate) }
25
25
  end
26
26
 
27
27
  describe '#generate' do
28
- it { instance.must_respond_to(:generate) }
29
- end
30
-
31
- describe '#name_as_class' do
32
- subject { instance.name_as_class }
33
-
34
- context 'when the name is a single value' do
35
- let(:_name) { 'VEDEU' }
36
-
37
- it { subject.must_equal('Vedeu') }
38
- end
39
-
40
- context 'when the name is an underscored value' do
41
- it { subject.must_equal('MyFirstApp') }
42
- end
43
-
44
- context 'when the name contains hyphens' do
45
- let(:_name) { 'hyphenated-APP' }
46
-
47
- it { subject.must_equal('HyphenatedApp')}
48
- end
28
+ subject { instance.generate }
49
29
  end
50
30
 
51
31
  end # Application
@@ -20,11 +20,11 @@ module Vedeu
20
20
  let(:instance) { Vedeu::Generator::HelpersTestClass.new(_name) }
21
21
  let(:_name) { 'my_first_app' }
22
22
 
23
- # describe '#app_name' do
24
- # subject { instance.app_name }
23
+ describe '#app_name' do
24
+ subject { instance.app_name }
25
25
 
26
- # it { subject.must_equal('MyFirstApp') }
27
- # end
26
+ # it { subject.must_equal('MyFirstApp') }
27
+ end
28
28
 
29
29
  describe '#app_name_as_snake_case' do
30
30
  let(:_name) { 'MyFirstApp' }
@@ -34,6 +34,19 @@ module Vedeu
34
34
  it { subject.must_equal('my_first_app') }
35
35
  end
36
36
 
37
+ describe '#make_directory' do
38
+ let(:destination) {}
39
+
40
+ subject { instance.make_directory(destination) }
41
+ end
42
+
43
+ describe '#copy_file' do
44
+ let(:source) {}
45
+ let(:destination) {}
46
+
47
+ subject { instance.copy_file(source, destination) }
48
+ end
49
+
37
50
  describe '#make_file' do
38
51
  let(:source) {}
39
52
  let(:destination) {}
@@ -41,6 +54,12 @@ module Vedeu
41
54
  subject { instance.make_file(source, destination) }
42
55
  end
43
56
 
57
+ describe '#touch_file' do
58
+ let(:destination) {}
59
+
60
+ subject { instance.touch_file(destination) }
61
+ end
62
+
44
63
  describe '#name' do
45
64
  let(:_name) { 'My_First_APP' }
46
65
 
@@ -54,15 +73,27 @@ module Vedeu
54
73
  describe '#name_as_class' do
55
74
  subject { instance.name_as_class }
56
75
 
57
- it { subject.must_be_instance_of(String) }
76
+ context 'when the name is a single value' do
77
+ let(:_name) { 'VEDEU' }
78
+
79
+ it { subject.must_equal('Vedeu') }
80
+ end
81
+
82
+ context 'when the name is an underscored value' do
83
+ it { subject.must_equal('MyFirstApp') }
84
+ end
85
+
86
+ context 'when the name contains hyphens' do
87
+ let(:_name) { 'hyphenated-APP' }
58
88
 
59
- it { subject.must_equal('MyFirstApp') }
89
+ it { subject.must_equal('HyphenatedApp')}
90
+ end
60
91
  end
61
92
 
62
- describe '#parse_file' do
93
+ describe '#parse' do
63
94
  let(:source) {}
64
95
 
65
- subject { instance.parse_file(source) }
96
+ subject { instance.parse(source) }
66
97
  end
67
98
 
68
99
  describe '#source' do
@@ -21,11 +21,11 @@ module Vedeu
21
21
  end
22
22
 
23
23
  describe '.generate' do
24
- subject { described.generate(_name) }
24
+ it { described.must_respond_to(:generate) }
25
25
  end
26
26
 
27
27
  describe '#generate' do
28
- it { instance.must_respond_to(:generate) }
28
+ subject { instance.generate }
29
29
  end
30
30
 
31
31
  end # View
@@ -9,9 +9,6 @@ module Vedeu
9
9
  before do
10
10
  Focus.reset
11
11
  Vedeu.interfaces.reset
12
- Vedeu.interface('thallium') {}
13
- Vedeu.interface('lead') {}
14
- Vedeu.interface('bismuth') {}
15
12
  end
16
13
  after do
17
14
  Vedeu::Focus.reset
@@ -163,6 +160,36 @@ module Vedeu
163
160
  end
164
161
  end
165
162
 
163
+ describe '#next_visible_item' do
164
+ before do
165
+ Vedeu.interface('gold') { visible true }
166
+ Vedeu.interface('silver') { visible true }
167
+ Vedeu.interface('platinum') { visible false }
168
+ end
169
+
170
+ it 'the next visible interface is focussed when the method is called' do
171
+ Focus.next_visible_item.must_equal('silver')
172
+ end
173
+
174
+ context 'when there are no visible interfaces' do
175
+ before do
176
+ Vedeu.interface('gold') { visible false }
177
+ Vedeu.interface('silver') { visible false }
178
+ Vedeu.interface('platinum') { visible false }
179
+ end
180
+
181
+ it 'puts the first interface defined in focus' do
182
+ Focus.next_visible_item.must_equal('gold')
183
+ end
184
+ end
185
+
186
+ context 'when there are no interfaces' do
187
+ before { Vedeu::Focus.reset }
188
+
189
+ it { Focus.next_visible_item.must_equal(false) }
190
+ end
191
+ end
192
+
166
193
  describe '#prev_item' do
167
194
  it 'the previous interface is focussed when the method is called' do
168
195
  Focus.add('thallium')
@@ -178,6 +205,36 @@ module Vedeu
178
205
  end
179
206
  end
180
207
 
208
+ describe '#prev_visible_item' do
209
+ before do
210
+ Vedeu.interface('gold') { visible true }
211
+ Vedeu.interface('silver') { visible true }
212
+ Vedeu.interface('platinum') { visible false }
213
+ end
214
+
215
+ it 'the previous visible interface is focussed when the method is called' do
216
+ Focus.prev_visible_item.must_equal('silver')
217
+ end
218
+
219
+ context 'when there are no visible interfaces' do
220
+ before do
221
+ Vedeu.interface('gold') { visible false }
222
+ Vedeu.interface('silver') { visible false }
223
+ Vedeu.interface('platinum') { visible false }
224
+ end
225
+
226
+ it 'puts the first interface defined in focus' do
227
+ Focus.prev_visible_item.must_equal('gold')
228
+ end
229
+ end
230
+
231
+ context 'when there are no interfaces' do
232
+ before { Vedeu::Focus.reset }
233
+
234
+ it { Focus.prev_visible_item.must_equal(false) }
235
+ end
236
+ end
237
+
181
238
  describe '#refresh' do
182
239
  before do
183
240
  Focus.add('thallium')
@@ -43,6 +43,7 @@ module Vedeu
43
43
 
44
44
  it { subject.must_be_instance_of(described) }
45
45
  it { subject.attributes.must_equal(attributes) }
46
+ it { subject.to_s.must_equal("\e[38;2;34;0;34m\e[48;2;255;0;255m") }
46
47
  end
47
48
 
48
49
  context 'when the value is a Hash' do
@@ -62,6 +63,7 @@ module Vedeu
62
63
 
63
64
  it { subject.must_be_instance_of(described) }
64
65
  it { subject.attributes.must_equal(attributes) }
66
+ it { subject.to_s.must_equal("\e[38;2;0;255;0m\e[48;2;0;34;0m") }
65
67
  end
66
68
 
67
69
  context 'when the value of :colour is a Hash' do
@@ -79,6 +81,9 @@ module Vedeu
79
81
  background: '#7700ff',
80
82
  foreground: '',
81
83
  }) }
84
+ it {
85
+ subject.to_s.must_equal("\e[48;2;119;0;255m")
86
+ }
82
87
  end
83
88
 
84
89
  context 'and a :foreground is defined' do
@@ -95,6 +100,9 @@ module Vedeu
95
100
  background: '',
96
101
  foreground: '#220077',
97
102
  }) }
103
+ it {
104
+ subject.to_s.must_equal("\e[38;2;34;0;119m")
105
+ }
98
106
  end
99
107
 
100
108
  context 'and neither a :background or :foreground is defined' do
@@ -109,6 +117,7 @@ module Vedeu
109
117
  background: '',
110
118
  foreground: '',
111
119
  }) }
120
+ it { subject.to_s.must_equal('') }
112
121
  end
113
122
  end
114
123
  end
@@ -126,6 +135,7 @@ module Vedeu
126
135
  background: '#000022',
127
136
  foreground: '',
128
137
  }) }
138
+ it { subject.to_s.must_equal("\e[48;2;0;0;34m") }
129
139
  end
130
140
 
131
141
  context 'when the hash has a :foreground defined' do
@@ -140,6 +150,7 @@ module Vedeu
140
150
  background: '',
141
151
  foreground: '#aadd00',
142
152
  }) }
153
+ it { subject.to_s.must_equal("\e[38;2;170;221;0m") }
143
154
  end
144
155
 
145
156
  context 'when neither a :background or :foreground is defined' do
@@ -154,6 +165,7 @@ module Vedeu
154
165
  background: '',
155
166
  foreground: '',
156
167
  }) }
168
+ it { subject.to_s.must_equal('') }
157
169
  end
158
170
  end
159
171
  end
@@ -5,26 +5,16 @@ module Vedeu
5
5
  describe Log do
6
6
 
7
7
  let(:described) { Vedeu::Log }
8
- let(:_message) {}
9
- let(:force) {}
10
- let(:type) {}
8
+ let(:_message) { 'Some message...' }
9
+ let(:force) { false }
10
+ let(:type) { :info }
11
11
 
12
12
  describe '.log' do
13
13
  subject { described.log(message: _message, force: force, type: type) }
14
14
 
15
- context 'when logging has been forced' do
16
- # it { skip }
17
- end
18
-
19
- context 'when logging has not been forced' do
20
- context 'when the configuration requests logging' do
21
- # it { skip }
22
- end
23
-
24
- context 'when the configuration does not request logging' do
25
- # it { skip }
26
- end
27
- end
15
+ it { subject.must_equal(
16
+ ["\e[97m[info] \e[39m", "\e[39mSome message...\e[39m"]
17
+ ) }
28
18
  end
29
19
 
30
20
  describe '.log_stdout' do
@@ -53,12 +43,6 @@ module Vedeu
53
43
  }
54
44
  end
55
45
 
56
- describe '.logger' do
57
- subject { described.logger }
58
-
59
- # it { skip }
60
- end
61
-
62
46
  end # Log
63
47
 
64
48
  end # Vedeu
data/vedeu.gemspec CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
22
22
 
23
23
  spec.add_development_dependency 'aruba', '0.6.2'
24
24
  spec.add_development_dependency 'cucumber', '2.0.0'
25
- spec.add_development_dependency 'guard', '2.12.6'
25
+ spec.add_development_dependency 'guard', '2.12.7'
26
26
  spec.add_development_dependency 'guard-bundler', '2.1.0'
27
27
  spec.add_development_dependency 'guard-minitest', '2.4.4'
28
28
  spec.add_development_dependency 'inch', '0.6.3'
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.4.37
4
+ version: 0.4.38
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-06-25 00:00:00.000000000 Z
11
+ date: 2015-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aruba
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - '='
46
46
  - !ruby/object:Gem::Version
47
- version: 2.12.6
47
+ version: 2.12.7
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - '='
53
53
  - !ruby/object:Gem::Version
54
- version: 2.12.6
54
+ version: 2.12.7
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: guard-bundler
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -340,6 +340,7 @@ files:
340
340
  - lib/vedeu/cursor/cursor.rb
341
341
  - lib/vedeu/cursor/move.rb
342
342
  - lib/vedeu/cursor/refresh_cursor.rb
343
+ - lib/vedeu/cursor/reposition.rb
343
344
  - lib/vedeu/debug.rb
344
345
  - lib/vedeu/distributed/all.rb
345
346
  - lib/vedeu/distributed/client.rb
@@ -386,7 +387,7 @@ files:
386
387
  - lib/vedeu/generator/templates/application/app/views/interfaces/name.erb
387
388
  - lib/vedeu/generator/templates/application/app/views/name.erb
388
389
  - lib/vedeu/generator/templates/application/app/views/templates/name.erb
389
- - lib/vedeu/generator/templates/application/application.rb
390
+ - lib/vedeu/generator/templates/application/application.erb
390
391
  - lib/vedeu/generator/templates/application/bin/name
391
392
  - lib/vedeu/generator/templates/application/config/app_name.erb
392
393
  - lib/vedeu/generator/templates/application/config/configuration.rb
@@ -484,7 +485,6 @@ files:
484
485
  - lib/vedeu/storage/fifo_store.rb
485
486
  - lib/vedeu/storage/store.rb
486
487
  - lib/vedeu/support/all.rb
487
- - lib/vedeu/support/colour_coercer.rb
488
488
  - lib/vedeu/support/common.rb
489
489
  - lib/vedeu/support/log.rb
490
490
  - lib/vedeu/support/options.rb
@@ -515,6 +515,7 @@ files:
515
515
  - test/lib/vedeu/cursor/cursor_test.rb
516
516
  - test/lib/vedeu/cursor/move_test.rb
517
517
  - test/lib/vedeu/cursor/refresh_cursor_test.rb
518
+ - test/lib/vedeu/cursor/reposition_test.rb
518
519
  - test/lib/vedeu/distributed/client_test.rb
519
520
  - test/lib/vedeu/distributed/server_test.rb
520
521
  - test/lib/vedeu/distributed/subprocess_test.rb
@@ -617,7 +618,6 @@ files:
617
618
  - test/lib/vedeu/storage/conveyor_store_test.rb
618
619
  - test/lib/vedeu/storage/fifo_store_test.rb
619
620
  - test/lib/vedeu/storage/store_test.rb
620
- - test/lib/vedeu/support/colour_coercer_test.rb
621
621
  - test/lib/vedeu/support/common_test.rb
622
622
  - test/lib/vedeu/support/log_test.rb
623
623
  - test/lib/vedeu/support/options_test.rb
@@ -679,6 +679,7 @@ test_files:
679
679
  - test/lib/vedeu/cursor/cursor_test.rb
680
680
  - test/lib/vedeu/cursor/move_test.rb
681
681
  - test/lib/vedeu/cursor/refresh_cursor_test.rb
682
+ - test/lib/vedeu/cursor/reposition_test.rb
682
683
  - test/lib/vedeu/distributed/client_test.rb
683
684
  - test/lib/vedeu/distributed/server_test.rb
684
685
  - test/lib/vedeu/distributed/subprocess_test.rb
@@ -781,7 +782,6 @@ test_files:
781
782
  - test/lib/vedeu/storage/conveyor_store_test.rb
782
783
  - test/lib/vedeu/storage/fifo_store_test.rb
783
784
  - test/lib/vedeu/storage/store_test.rb
784
- - test/lib/vedeu/support/colour_coercer_test.rb
785
785
  - test/lib/vedeu/support/common_test.rb
786
786
  - test/lib/vedeu/support/log_test.rb
787
787
  - test/lib/vedeu/support/options_test.rb
@@ -1,97 +0,0 @@
1
- module Vedeu
2
-
3
- class ColourCoercer
4
-
5
- # @param value [Vedeu::Colour|Hash<Symbol => Fixnum|String|Symbol>]
6
- # @return [Vedeu::Colour]
7
- def self.coerce(value)
8
- new(value).coerce
9
- end
10
-
11
- # @param value [Hash<Symbol => Fixnum|String|Symbol>]
12
- def self.from_hash(value)
13
- new(value).from_hash
14
- end
15
-
16
- # @param value [Vedeu::Colour|Hash<Symbol => Fixnum|String|Symbol]
17
- # @return [Vedeu::ColourCoercer]
18
- def initialize(value)
19
- @value = value
20
- end
21
-
22
- # @return [Vedeu::Colour]
23
- def coerce
24
- return value if colour?
25
-
26
- if hash?
27
- Vedeu::ColourCoercer.from_hash(value)
28
-
29
- else
30
- build
31
-
32
- end
33
- end
34
-
35
- # @return [Vedeu::Colour]
36
- def from_hash
37
- return build unless value
38
-
39
- if colour_key?
40
- Vedeu::ColourCoercer.coerce(value[:colour])
41
-
42
- elsif background? || foreground?
43
- build_from_hash(value)
44
-
45
- else
46
- build
47
-
48
- end
49
- end
50
-
51
- protected
52
-
53
- # @!attribute [r] colour
54
- # @return [void]
55
- attr_reader :value
56
-
57
- private
58
-
59
- # @return [Vedeu::Colour]
60
- def build
61
- Vedeu::Colour.new
62
- end
63
-
64
- # @param value [Hash<Symbol => Fixnum|String|Symbol>]
65
- # @return [Vedeu::Colour]
66
- def build_from_hash(value)
67
- Vedeu::Colour.new(value)
68
- end
69
-
70
- # @return [Boolean]
71
- def colour?
72
- value.is_a?(Vedeu::Colour)
73
- end
74
-
75
- # @return [Boolean]
76
- def hash?
77
- value.is_a?(Hash)
78
- end
79
-
80
- # @return [Boolean]
81
- def background?
82
- value.key?(:background)
83
- end
84
-
85
- # @return [Boolean]
86
- def colour_key?
87
- value.key?(:colour)
88
- end
89
-
90
- # @return [Boolean]
91
- def foreground?
92
- value.key?(:foreground)
93
- end
94
-
95
- end # ColourCoercer
96
-
97
- end # Vedeu
@@ -1,85 +0,0 @@
1
- require 'test_helper'
2
-
3
- module Vedeu
4
-
5
- describe ColourCoercer do
6
-
7
- let(:described) { Vedeu::ColourCoercer }
8
- let(:instance) { described.new(_value) }
9
- let(:_value) { }
10
-
11
- describe '#initialize' do
12
- subject { instance }
13
- end
14
-
15
- describe '.coerce' do
16
- it { described.must_respond_to(:coerce) }
17
- end
18
-
19
- describe '.from_hash' do
20
- it { described.must_respond_to(:from_hash) }
21
- end
22
-
23
- describe '#coerce' do
24
- subject { instance.coerce }
25
-
26
- context 'when no value is given' do
27
- it { subject.must_be_instance_of(Vedeu::Colour) }
28
- end
29
-
30
- context 'when a value is given' do
31
- context 'when the value is a Vedeu::Colour' do
32
- let(:_value) { Vedeu::Colour.new }
33
-
34
- it { subject.must_equal(_value) }
35
- end
36
-
37
- context 'when the value is a Hash' do
38
- let(:_value) { { } }
39
-
40
- it {
41
- Vedeu::ColourCoercer.expects(:from_hash).with(_value)
42
- subject
43
- }
44
- end
45
- end
46
- end
47
-
48
- describe '#from_hash' do
49
- subject { instance.from_hash }
50
-
51
- context 'when no value is given' do
52
- it { subject.must_be_instance_of(Vedeu::Colour) }
53
- end
54
-
55
- context 'when a value is given' do
56
- context 'when the value has a :colour key' do
57
- let(:_value) { { colour: colour_value } }
58
- let(:colour_value) { Vedeu::Colour.new }
59
-
60
- it {
61
- Vedeu::ColourCoercer.expects(:coerce).with(colour_value)
62
- subject
63
- }
64
- end
65
-
66
- context 'when the value has a :background or :foreground key' do
67
- let(:_value) { { background: '#000000', foreground: '#ffffff' } }
68
-
69
- it {
70
- Vedeu::Colour.expects(:new).with(_value)
71
- subject
72
- }
73
- end
74
-
75
- context 'when the value is empty or has unhandled keys' do
76
- let(:_value) { { unhandled: :some_value } }
77
-
78
- it { subject.must_be_instance_of(Vedeu::Colour) }
79
- end
80
- end
81
- end
82
-
83
- end # ColourCoercer
84
-
85
- end # Vedeu