vedeu 0.4.39 → 0.4.40

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/docs/applications.md +62 -13
  3. data/lib/vedeu/cursor/cursor.rb +1 -7
  4. data/lib/vedeu/cursor/reposition.rb +1 -16
  5. data/lib/vedeu/distributed/subprocess.rb +2 -2
  6. data/lib/vedeu/events/event.rb +0 -8
  7. data/lib/vedeu/generator/templates/application/app/models/keymaps/_global_.rb +1 -0
  8. data/lib/vedeu/generator/templates/application/app/models/keymaps/_system_.rb +1 -0
  9. data/lib/vedeu/generator/templates/application/app/models/keymaps/name.erb +3 -0
  10. data/lib/vedeu/generator/view.rb +8 -0
  11. data/lib/vedeu/geometry/position.rb +14 -3
  12. data/lib/vedeu/input/keymap.rb +1 -3
  13. data/lib/vedeu/models/cell.rb +16 -5
  14. data/lib/vedeu/models/char.rb +1 -5
  15. data/lib/vedeu/models/menu.rb +1 -3
  16. data/lib/vedeu/output/border.rb +8 -5
  17. data/lib/vedeu/output/renderers/file.rb +1 -5
  18. data/lib/vedeu/output/renderers/json.rb +8 -37
  19. data/lib/vedeu/version.rb +1 -1
  20. data/test/lib/vedeu/buffers/buffer_test.rb +22 -20
  21. data/test/lib/vedeu/cursor/cursor_test.rb +1 -34
  22. data/test/lib/vedeu/geometry/area_test.rb +1 -1
  23. data/test/lib/vedeu/geometry/geometry_test.rb +1 -37
  24. data/test/lib/vedeu/geometry/index_position_test.rb +4 -5
  25. data/test/lib/vedeu/geometry/position_test.rb +11 -1
  26. data/test/lib/vedeu/models/char_test.rb +1 -22
  27. data/test/lib/vedeu/models/interface_test.rb +1 -46
  28. data/test/lib/vedeu/models/menu_test.rb +1 -13
  29. data/test/lib/vedeu/output/border_test.rb +1 -76
  30. data/test/lib/vedeu/output/clear_test.rb +6 -0
  31. data/test/lib/vedeu/output/renderers/json_test.rb +30 -11
  32. data/test/lib/vedeu/output/style_test.rb +1 -4
  33. data/test/lib/vedeu/repositories/collection_test.rb +1 -13
  34. data/test/support/helpers/model_test_class.rb +5 -7
  35. metadata +3 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a3d34a0019ef70ca1ee81a8bf5176d18783c8853
4
- data.tar.gz: 1e0080a183723d3dbf646e5b85017dc097c4725f
3
+ metadata.gz: f097662b914c6da5ad5928cf49ed800854dc0062
4
+ data.tar.gz: ee5e7fc8f279cc4613ae8f1b7df48dd4fb8515bd
5
5
  SHA512:
6
- metadata.gz: cfef5bc83a89b03ee28dc0fd45ed56fdc271d772eb8656f991a2f4859890dbe64fca1c5b21fac4bd275c05a0b78aef1e3c36a32d82d23e39b1d478ea39279774
7
- data.tar.gz: 2209ded0225a88a1a71ef126a89362e6d99ec781d1b97ef662d6e4765a6758ae4445f5ffb95f127e0ace5eea7ce4b7c93a84e93a06b87c9faaa653aa3a826e37
6
+ metadata.gz: c6faaf146d5888abee75910a14b5c3dd1846a738c7d77b19efe2b4d17b4cdf3747ac2f4db03cd48a0bd7b9131516efe5b135487d6be569f132bcdfba0f7107a6
7
+ data.tar.gz: 522fd6ec674864207e9244bb8bbb48c9b35fb8c9db218391b195b7481476e7f4d0b32f14cbf0585a7c469db303249ab5b7f1581e9069889782ed5168093d2b66
data/docs/applications.md CHANGED
@@ -4,26 +4,39 @@ Vedeu has basic tools to generate client application scaffolding, in a similar
4
4
  way to Ruby on Rails. Although not nearly as advanced as the Rails equivalent,
5
5
  hopefully these generators will get you off the ground.
6
6
 
7
- ### Application Structure
7
+ ### Generating a new application
8
8
 
9
9
  |
10
10
  |- app_name/
11
11
  | |
12
12
  |- app/
13
- | |- controllers
14
- | |- helpers
15
- | |- models
16
- | | |- keymaps
17
- | |- views
18
- | |- interfaces
19
- | |- templates
13
+ | |- controllers/
14
+ | | |- application_controller.rb
15
+ | |
16
+ | |- helpers/
17
+ | | |- application_helper.rb
18
+ | |
19
+ | |- models/
20
+ | | |- keymaps/
21
+ | | |- _global_.rb
22
+ | | |- _system_.rb
23
+ | |
24
+ | |- views/
25
+ | |- interfaces/
26
+ | |- templates/
20
27
  |
21
- |- bin
22
- |- config
23
- |- lib
24
- |- test
25
- |- vendor
28
+ |- bin/
29
+ | |- app_name
26
30
  |
31
+ |- config/
32
+ | |- add_name
33
+ | |- configuration.rb
34
+ |
35
+ |- lib/
36
+ |- test/
37
+ |- vendor/
38
+ |- application.rb
39
+ |- Gemfile
27
40
 
28
41
  To create the application structure as shown above:
29
42
 
@@ -101,3 +114,39 @@ in the way you expect.
101
114
  This is for third-party code which your application might want to ship with.
102
115
  Usually you will include various Ruby gems to provide functionality, but you
103
116
  might want to do something special.
117
+
118
+
119
+ ### Generating a new view
120
+
121
+ Vedeu also provides a generator to create the files needed for a view. To run
122
+ this, use the following from within the root of the application directory:
123
+
124
+ vedeu view view_name
125
+
126
+ Let's talk about the files it will create and populate:
127
+
128
+ |
129
+ |- app_name/
130
+ | |
131
+ |- app/
132
+ | |- controllers/
133
+ | | |- view_name_controller.rb
134
+ | |
135
+ | |- helpers/
136
+ | | |- view_name_helper.rb
137
+ | |
138
+ | |- models/
139
+ | | |- keymaps/
140
+ | | |- view_name.rb
141
+ | |
142
+ | |- views/
143
+ | |- interfaces/
144
+ | | |- view_name.rb
145
+ | |
146
+ | |- templates/
147
+ | | |- view_name.erb
148
+ | |
149
+ | |- view_name.rb
150
+ |...
151
+
152
+ ####
@@ -61,13 +61,7 @@ module Vedeu
61
61
 
62
62
  @attributes = defaults.merge!(attributes)
63
63
 
64
- @name = @attributes.fetch(:name)
65
- @ox = @attributes.fetch(:ox)
66
- @oy = @attributes.fetch(:oy)
67
- @repository = @attributes.fetch(:repository)
68
- @visible = @attributes.fetch(:visible)
69
- @x = @attributes.fetch(:x)
70
- @y = @attributes.fetch(:y)
64
+ @attributes.each { |key, value| instance_variable_set("@#{key}", value) }
71
65
 
72
66
  @position = Vedeu::Position.new(@y, @x)
73
67
  end
@@ -25,7 +25,7 @@ module Vedeu
25
25
 
26
26
  # @return [Vedeu::Cursor]
27
27
  def to
28
- result = @entity.new(name: name,
28
+ result = entity.new(name: name,
29
29
  y: y_position,
30
30
  x: x_position,
31
31
  oy: y,
@@ -63,21 +63,6 @@ module Vedeu
63
63
  @coordinate ||= Vedeu::Coordinate.new(name)
64
64
  end
65
65
 
66
- # @return [Vedeu::Cursor]
67
- def entity
68
- @_entity ||= @entity.new
69
- end
70
-
71
- # @return [Vedeu::Cursor]
72
- def model
73
- @model ||= repository.by_name(name)
74
- end
75
-
76
- # @return [Vedeu::Cursors]
77
- def repository
78
- entity.repository
79
- end
80
-
81
66
  # Returns the cursors x position based on the desired x position.
82
67
  #
83
68
  # @return [Fixnum]
@@ -48,9 +48,9 @@ module Vedeu
48
48
  # @return [Vedeu::TestApplication]
49
49
  attr_reader :application
50
50
 
51
- # @!attribute [rw] pid
51
+ # @!attribute [r] pid
52
52
  # @return [Fixnum]
53
- attr_accessor :pid
53
+ attr_reader :pid
54
54
 
55
55
  private
56
56
 
@@ -162,14 +162,6 @@ module Vedeu
162
162
  # @return [String]
163
163
  attr_reader :name
164
164
 
165
- # @!attribute [rw] deadline
166
- # @return [String]
167
- attr_accessor :deadline
168
-
169
- # @!attribute [rw] executed_at
170
- # @return [String]
171
- attr_accessor :executed_at
172
-
173
165
  private
174
166
 
175
167
  # Execute the code stored in the event closure.
@@ -1,2 +1,3 @@
1
1
  Vedeu.keymap('_global_') do
2
+ # see http://www.rubydoc.info/gems/vedeu/Vedeu/DSL/Keymap
2
3
  end
@@ -1,4 +1,5 @@
1
1
  Vedeu.keymap('_system_') do
2
+ # see http://www.rubydoc.info/gems/vedeu/Vedeu/DSL/Keymap
2
3
  key('e') { Vedeu.trigger(:_exit_) }
3
4
  key(:esc) { Vedeu.trigger(:_mode_switch_) }
4
5
  key(:shift_tab) { Vedeu.trigger(:_focus_previous_) }
@@ -0,0 +1,3 @@
1
+ Vedeu.keymap('<%= object.name %>') do
2
+ # see http://www.rubydoc.info/gems/vedeu/Vedeu/DSL/Keymap
3
+ end
@@ -34,6 +34,8 @@ module Vedeu
34
34
 
35
35
  make_helper_file
36
36
 
37
+ make_keymap_file
38
+
37
39
  make_interface_file
38
40
 
39
41
  make_template_file
@@ -55,6 +57,12 @@ module Vedeu
55
57
  '.' + "/app/helpers/#{name}_helper.rb")
56
58
  end
57
59
 
60
+ # @return [void]
61
+ def make_keymap_file
62
+ make_file(source + '/app/models/keymaps/name.erb',
63
+ '.' + "/app/models/keymaps/#{name}.rb")
64
+ end
65
+
58
66
  # @return [void]
59
67
  def make_interface_file
60
68
  make_file(source + '/app/views/interfaces/name.erb',
@@ -8,12 +8,11 @@ module Vedeu
8
8
  # @!attribute [r] y
9
9
  # @return [Fixnum]
10
10
  attr_reader :y
11
+ alias_method :first, :y
11
12
 
12
13
  # @!attribute [r] x
13
14
  # @return [Fixnum]
14
15
  attr_reader :x
15
-
16
- alias_method :first, :y
17
16
  alias_method :last, :x
18
17
 
19
18
  # Convenience constructor for Vedeu::Position.
@@ -42,12 +41,24 @@ module Vedeu
42
41
  #
43
42
  # @param y [Fixnum] The row/line position.
44
43
  # @param x [Fixnum] The column/character position.
45
- # @return [Position]
44
+ # @return [Vedeu::Position]
46
45
  def initialize(y = 1, x = 1)
47
46
  @y = (y.nil? || y < 1) ? 1 : y
48
47
  @x = (x.nil? || x < 1) ? 1 : x
49
48
  end
50
49
 
50
+ # @param other [Vedeu::Position]
51
+ # @return [Fixnum]
52
+ def <=>(other)
53
+ if y == other.y
54
+ x <=> other.x
55
+
56
+ else
57
+ y <=> other.y
58
+
59
+ end
60
+ end
61
+
51
62
  # An object is equal when its values are the same.
52
63
  #
53
64
  # @param other [Vedeu::Position]
@@ -26,9 +26,7 @@ module Vedeu
26
26
  def initialize(attributes = {})
27
27
  @attributes = defaults.merge!(attributes)
28
28
 
29
- @attributes.each do |key, value|
30
- instance_variable_set("@#{key}", value)
31
- end
29
+ @attributes.each { |key, value| instance_variable_set("@#{key}", value) }
32
30
  end
33
31
 
34
32
  # Add a key to the keymap.
@@ -36,11 +36,9 @@ module Vedeu
36
36
  # @option attributes y [NilClass|Fixnum]
37
37
  # @return [Vedeu::Cell]
38
38
  def initialize(attributes = {})
39
- @colour = attributes[:colour]
40
- @style = attributes[:style]
41
- @value = attributes[:value]
42
- @x = attributes[:x]
43
- @y = attributes[:y]
39
+ @attributes = defaults.merge!(attributes)
40
+
41
+ @attributes.each { |key, value| instance_variable_set("@#{key}", value) }
44
42
  end
45
43
 
46
44
  # An object is equal when its values are the same.
@@ -54,6 +52,19 @@ module Vedeu
54
52
  end
55
53
  alias_method :==, :eql?
56
54
 
55
+ private
56
+
57
+ # @return [Hash<Symbol => void>]
58
+ def defaults
59
+ {
60
+ colour: nil,
61
+ style: nil,
62
+ value: nil,
63
+ x: nil,
64
+ y: nil,
65
+ }
66
+ end
67
+
57
68
  end # Cell
58
69
 
59
70
  end # Vedeu
@@ -14,6 +14,7 @@ module Vedeu
14
14
  # @api private
15
15
  class Char
16
16
 
17
+ include Comparable
17
18
  include Vedeu::Presentation
18
19
 
19
20
  # @!attribute [rw] border
@@ -137,11 +138,6 @@ module Vedeu
137
138
  @to_html ||= Vedeu::HTMLChar.render(self)
138
139
  end
139
140
 
140
- # @return [String]
141
- def to_json
142
- @to_json ||= JSON.generate(to_hash)
143
- end
144
-
145
141
  private
146
142
 
147
143
  # @return [Hash]
@@ -67,9 +67,7 @@ module Vedeu
67
67
  def initialize(attributes = {})
68
68
  @attributes = defaults.merge!(attributes)
69
69
 
70
- @attributes.each do |key, value|
71
- instance_variable_set("@#{key}", value)
72
- end
70
+ @attributes.each { |key, value| instance_variable_set("@#{key}", value) }
73
71
  end
74
72
 
75
73
  # Returns the item from the collection which shares the same index as the
@@ -115,9 +115,7 @@ module Vedeu
115
115
  def initialize(attributes = {})
116
116
  @attributes = defaults.merge!(attributes)
117
117
 
118
- @attributes.each do |key, value|
119
- instance_variable_set("@#{key}", value)
120
- end
118
+ @attributes.each { |key, value| instance_variable_set("@#{key}", value) }
121
119
  end
122
120
 
123
121
  # @return [Fixnum]
@@ -213,13 +211,18 @@ module Vedeu
213
211
 
214
212
  # Renders the top border for the interface.
215
213
  #
214
+ # @note
215
+ # If a title has been specified, then the top border will include this
216
+ # title unless the size of the interface is smaller than the padded title
217
+ # length.
218
+ #
216
219
  # @return [String]
217
220
  def top
218
221
  return [] unless top?
219
222
 
220
223
  out = []
221
224
  out << border(top_left, :top_left, *[y, x]) if left?
222
- if title?
225
+ if title? && width > title_characters.size
223
226
  out << titlebar
224
227
 
225
228
  else
@@ -326,7 +329,7 @@ module Vedeu
326
329
 
327
330
  # @return [Vedeu::Interface]
328
331
  def interface
329
- @interface ||= Vedeu.interfaces.find(name)
332
+ @interface ||= Vedeu.interfaces.by_name(name)
330
333
  end
331
334
 
332
335
  # The default values for a new instance of this class.
@@ -38,6 +38,7 @@ module Vedeu
38
38
  # @!attribute [r] output
39
39
  # @return [Array<Array<Vedeu::Char>>]
40
40
  attr_reader :output
41
+ alias_method :parsed, :output
41
42
 
42
43
  private
43
44
 
@@ -57,11 +58,6 @@ module Vedeu
57
58
  end
58
59
  end
59
60
 
60
- # @return [String]
61
- def parsed
62
- @parsed ||= Vedeu::Compressor.render(output)
63
- end
64
-
65
61
  # @return [Float]
66
62
  def timestamp
67
63
  @timestamp ||= Time.now.to_f
@@ -5,50 +5,21 @@ module Vedeu
5
5
  # Renders a {Vedeu::VirtualBuffer} or {Vedeu::Output} as JSON.
6
6
  #
7
7
  # @api private
8
- class JSON
8
+ class JSON < Vedeu::Renderers::File
9
9
 
10
- # @param output [Array<Array<Vedeu::Char>>]
11
- # @return [String]
12
- def self.render(output)
13
- new(output).render
14
- end
10
+ private
15
11
 
16
- # @param output [Array<Array<Vedeu::Char>>]
17
- # @param path [String]
18
12
  # @return [String]
19
- # def self.to_file(output, path = nil)
20
- # new(output).to_file(path)
21
- # end
22
-
23
- # Returns a new instance of Vedeu::Renderers::JSON.
24
- #
25
- # @param output [Array<Array<Vedeu::Char>>]
26
- # @return [Vedeu::Renderers::JSON]
27
- def initialize(output)
28
- @output = output
29
- end
30
-
31
- # @return [String]
32
- def render
13
+ def parsed
33
14
  return '' if output.nil? || output.empty?
34
15
 
35
- out = ''
36
- Array(output).each do |line|
37
- out << ''
38
- line.each do |char|
39
- out << char.to_json
40
- out << "\n"
41
- end
42
- out << "\n"
43
- end
44
- out
16
+ ::JSON.pretty_generate(sorted)
45
17
  end
46
18
 
47
- protected
48
-
49
- # @!attribute [r] output
50
- # @return [Array<Array<Vedeu::Char>>]
51
- attr_reader :output
19
+ # @return [Array]
20
+ def sorted
21
+ Array(output).flatten.sort { |a, b| a.position <=> b.position }.map { |char| char.to_hash }
22
+ end
52
23
 
53
24
  end # JSON
54
25
 
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.39'
4
+ VERSION = '0.4.40'
5
5
 
6
6
  end
@@ -37,31 +37,13 @@ module Vedeu
37
37
  end
38
38
  end
39
39
 
40
- describe '#back' do
40
+ describe 'accessors' do
41
41
  it { instance.must_respond_to(:back) }
42
- end
43
-
44
- describe '#back=' do
45
42
  it { instance.must_respond_to(:back=) }
46
- end
47
-
48
- describe '#front' do
49
43
  it { instance.must_respond_to(:front) }
50
- end
51
-
52
- describe '#front=' do
53
44
  it { instance.must_respond_to(:front=) }
54
- end
55
-
56
- describe '#previous' do
57
45
  it { instance.must_respond_to(:previous) }
58
- end
59
-
60
- describe '#previous=' do
61
46
  it { instance.must_respond_to(:previous=) }
62
- end
63
-
64
- describe '#name' do
65
47
  it { instance.must_respond_to(:name) }
66
48
  end
67
49
 
@@ -163,11 +145,20 @@ module Vedeu
163
145
  subject { instance.hide }
164
146
 
165
147
  context 'when the interface is visible' do
148
+ # before do
149
+ # Vedeu::Visibility.stubs(:hide)
150
+ # instance.stubs(:clear)
151
+ # end
152
+ # after do
153
+ # Vedeu.interfaces.reset
154
+ # end
155
+
166
156
  # let(:_name) { 'Buffer#hide' }
167
- # let(:interface) { Vedeu.interface('Buffer#hide') {} }
157
+ # let(:interface) { Vedeu.interface('Buffer') {} }
168
158
 
169
159
  # it {
170
160
  # Vedeu::Visibility.expects(:hide).with(interface)
161
+ # instance.expects(:clear)
171
162
  # subject
172
163
  # }
173
164
  end
@@ -186,11 +177,22 @@ module Vedeu
186
177
  end
187
178
 
188
179
  context 'when the interface is not visible' do
180
+ # it { skip }
181
+
182
+ # before do
183
+ # Vedeu::Visibility.stubs(:show)
184
+ # instance.stubs(:render)
185
+ # end
186
+ # after do
187
+ # Vedeu.interfaces.reset
188
+ # end
189
+
189
190
  # let(:_name) { 'Buffer#show' }
190
191
  # let(:interface) { Vedeu.interface('Buffer#show') {} }
191
192
 
192
193
  # it {
193
194
  # Vedeu::Visibility.expects(:show).with(interface)
195
+ # instance.expects(:render)
194
196
  # subject
195
197
  # }
196
198
  end
@@ -39,52 +39,19 @@ module Vedeu
39
39
  it { subject.instance_variable_get('@y').must_equal(8) }
40
40
  end
41
41
 
42
- describe '#attributes' do
42
+ describe 'accessors' do
43
43
  it { instance.must_respond_to(:attributes) }
44
- end
45
-
46
- describe '#name' do
47
44
  it { instance.must_respond_to(:name) }
48
- end
49
-
50
- describe '#ox' do
51
45
  it { instance.must_respond_to(:ox) }
52
- end
53
-
54
- describe '#ox=' do
55
46
  it { instance.must_respond_to(:ox=) }
56
- end
57
-
58
- describe '#oy' do
59
47
  it { instance.must_respond_to(:oy) }
60
- end
61
-
62
- describe '#oy=' do
63
48
  it { instance.must_respond_to(:oy=) }
64
- end
65
-
66
- describe '#state' do
67
49
  it { instance.must_respond_to(:state) }
68
- end
69
-
70
- describe '#visible' do
71
50
  it { instance.must_respond_to(:visible) }
72
51
  it { instance.must_respond_to(:visible?) }
73
- end
74
-
75
- describe '#x' do
76
52
  it { instance.must_respond_to(:x) }
77
- end
78
-
79
- describe '#x=' do
80
53
  it { instance.must_respond_to(:x=) }
81
- end
82
-
83
- describe '#y' do
84
54
  it { instance.must_respond_to(:y) }
85
- end
86
-
87
- describe '#y=' do
88
55
  it { instance.must_respond_to(:y=) }
89
56
  end
90
57
 
@@ -12,7 +12,7 @@ module Vedeu
12
12
  let(:xn) { 21 }
13
13
  let(:offset) { 1 }
14
14
 
15
- describe 'accessors and aliases' do
15
+ describe 'accessors' do
16
16
  it { instance.must_respond_to(:y) }
17
17
  it { instance.must_respond_to(:yn) }
18
18
  it { instance.must_respond_to(:x) }
@@ -51,56 +51,20 @@ module Vedeu
51
51
  end
52
52
  end
53
53
 
54
- describe '#centred' do
54
+ describe 'accessors' do
55
55
  it { instance.must_respond_to(:centred) }
56
- end
57
-
58
- describe '#centred=' do
59
56
  it { instance.must_respond_to(:centred=) }
60
- end
61
-
62
- describe '#attributes' do
63
57
  it { instance.must_respond_to(:attributes) }
64
- end
65
-
66
- describe '#name' do
67
58
  it { instance.must_respond_to(:name) }
68
- end
69
-
70
- describe '#name=' do
71
59
  it { instance.must_respond_to(:name=) }
72
- end
73
-
74
- describe '#height=' do
75
60
  it { instance.must_respond_to(:height=) }
76
- end
77
-
78
- describe '#maximised' do
79
61
  it { instance.must_respond_to(:maximised) }
80
62
  it { instance.must_respond_to(:maximised?) }
81
- end
82
-
83
- describe '#maximised=' do
84
63
  it { instance.must_respond_to(:maximised=) }
85
- end
86
-
87
- describe '#width=' do
88
64
  it { instance.must_respond_to(:width=) }
89
- end
90
-
91
- describe '#x=' do
92
65
  it { instance.must_respond_to(:x=) }
93
- end
94
-
95
- describe '#xn=' do
96
66
  it { instance.must_respond_to(:xn=) }
97
- end
98
-
99
- describe '#y=' do
100
67
  it { instance.must_respond_to(:y=) }
101
- end
102
-
103
- describe '#yn=' do
104
68
  it { instance.must_respond_to(:yn=) }
105
69
  end
106
70
 
@@ -11,11 +11,6 @@ module Vedeu
11
11
  let(:oy) { 3 }
12
12
  let(:ox) { 5 }
13
13
 
14
- describe 'alias methods' do
15
- it { instance.must_respond_to(:first) }
16
- it { instance.must_respond_to(:last) }
17
- end
18
-
19
14
  describe '#initialize' do
20
15
  it { instance.must_be_instance_of(described) }
21
16
  it { instance.instance_variable_get('@oy').must_equal(3) }
@@ -55,6 +50,8 @@ module Vedeu
55
50
  describe '#y' do
56
51
  subject { instance.y }
57
52
 
53
+ it { instance.must_respond_to(:first) }
54
+
58
55
  context 'when iy is <= 0' do
59
56
  let(:iy) { -2 }
60
57
 
@@ -91,6 +88,8 @@ module Vedeu
91
88
  describe '#x' do
92
89
  subject { instance.x }
93
90
 
91
+ it { instance.must_respond_to(:last) }
92
+
94
93
  context 'when ix is <= 0' do
95
94
  let(:ix) { -2 }
96
95
 
@@ -9,8 +9,10 @@ module Vedeu
9
9
  let(:y) { 12 }
10
10
  let(:x) { 19 }
11
11
 
12
- describe 'alias methods' do
12
+ describe 'accessors' do
13
+ it { instance.must_respond_to(:y) }
13
14
  it { instance.must_respond_to(:first) }
15
+ it { instance.must_respond_to(:x) }
14
16
  it { instance.must_respond_to(:last) }
15
17
  end
16
18
 
@@ -26,6 +28,14 @@ module Vedeu
26
28
  it { instance.must_be_instance_of(described) }
27
29
  end
28
30
 
31
+ describe '#<=>' do
32
+ let(:other) {}
33
+
34
+ subject { instance.<=>(other) }
35
+
36
+ # it { skip }
37
+ end
38
+
29
39
  describe '.coerce' do
30
40
  let(:_value) {}
31
41
 
@@ -42,27 +42,12 @@ module Vedeu
42
42
  it { instance.must_respond_to(:value) }
43
43
  end
44
44
 
45
- describe '#border' do
45
+ describe 'accessors' do
46
46
  it { instance.must_respond_to(:border) }
47
- end
48
-
49
- describe '#border=' do
50
47
  it { instance.must_respond_to(:border=) }
51
- end
52
-
53
- describe '#parent' do
54
48
  it { instance.must_respond_to(:parent) }
55
- end
56
-
57
- describe '#parent=' do
58
49
  it { instance.must_respond_to(:parent=) }
59
- end
60
-
61
- describe '#attributes' do
62
50
  it { instance.must_respond_to(:attributes) }
63
- end
64
-
65
- describe '#value=' do
66
51
  it { instance.must_respond_to(:value=) }
67
52
  end
68
53
 
@@ -137,12 +122,6 @@ module Vedeu
137
122
  it { subject.must_be_instance_of(String) }
138
123
  end
139
124
 
140
- describe '#to_json' do
141
- subject { instance.to_json }
142
-
143
- it { subject.must_be_instance_of(String) }
144
- end
145
-
146
125
  describe '#to_s' do
147
126
  subject { instance.to_s }
148
127
 
@@ -47,68 +47,23 @@ module Vedeu
47
47
  it { subject.instance_variable_get('@zindex').must_equal(zindex) }
48
48
  end
49
49
 
50
- describe '#client' do
50
+ describe 'accessors' do
51
51
  it { instance.must_respond_to(:client) }
52
- end
53
-
54
- describe '#client=' do
55
52
  it { instance.must_respond_to(:client=) }
56
- end
57
-
58
- describe '#delay' do
59
53
  it { instance.must_respond_to(:delay) }
60
- end
61
-
62
- describe '#delay=' do
63
54
  it { instance.must_respond_to(:delay=) }
64
- end
65
-
66
- describe '#group' do
67
55
  it { instance.must_respond_to(:group) }
68
- end
69
-
70
- describe '#group=' do
71
56
  it { instance.must_respond_to(:group=) }
72
- end
73
-
74
- describe '#name' do
75
57
  it { instance.must_respond_to(:name) }
76
- end
77
-
78
- describe '#name=' do
79
58
  it { instance.must_respond_to(:name=) }
80
- end
81
-
82
- describe '#parent' do
83
59
  it { instance.must_respond_to(:parent) }
84
- end
85
-
86
- describe '#parent=' do
87
60
  it { instance.must_respond_to(:parent=) }
88
- end
89
-
90
- describe '#zindex' do
91
61
  it { instance.must_respond_to(:zindex) }
92
- end
93
-
94
- describe '#zindex=' do
95
62
  it { instance.must_respond_to(:zindex=) }
96
- end
97
-
98
- describe '#visible' do
99
63
  it { instance.must_respond_to(:visible) }
100
64
  it { instance.must_respond_to(:visible?) }
101
- end
102
-
103
- describe '#visible=' do
104
65
  it { instance.must_respond_to(:visible=) }
105
- end
106
-
107
- describe '#attributes' do
108
66
  it { instance.must_respond_to(:attributes) }
109
- end
110
-
111
- describe '#lines=' do
112
67
  it { instance.must_respond_to(:lines=) }
113
68
  end
114
69
 
@@ -50,23 +50,11 @@ module Vedeu
50
50
  end
51
51
  end
52
52
 
53
- describe '#collection' do
53
+ describe 'accessors' do
54
54
  it { instance.must_respond_to(:collection) }
55
- end
56
-
57
- describe '#collection=' do
58
55
  it { instance.must_respond_to(:collection=) }
59
- end
60
-
61
- describe '#current=' do
62
56
  it { instance.must_respond_to(:current=) }
63
- end
64
-
65
- describe '#name' do
66
57
  it { instance.must_respond_to(:name) }
67
- end
68
-
69
- describe '#name=' do
70
58
  it { instance.must_respond_to(:name=) }
71
59
  end
72
60
 
@@ -77,111 +77,36 @@ module Vedeu
77
77
  end
78
78
  end
79
79
 
80
- describe '#attributes' do
80
+ describe 'accessors' do
81
81
  it { instance.must_respond_to(:attributes) }
82
- end
83
-
84
- describe '#attributes=' do
85
82
  it { instance.must_respond_to(:attributes=) }
86
- end
87
-
88
- describe '#bottom_left' do
89
83
  it { instance.must_respond_to(:bottom_left) }
90
- end
91
-
92
- describe '#bottom_left=' do
93
84
  it { instance.must_respond_to(:bottom_left=) }
94
- end
95
-
96
- describe '#bottom_right' do
97
85
  it { instance.must_respond_to(:bottom_right) }
98
- end
99
-
100
- describe '#bottom_right=' do
101
86
  it { instance.must_respond_to(:bottom_right=) }
102
- end
103
-
104
- describe '#horizontal' do
105
87
  it { instance.must_respond_to(:horizontal) }
106
- end
107
-
108
- describe '#horizontal=' do
109
88
  it { instance.must_respond_to(:horizontal=) }
110
- end
111
-
112
- describe '#show_bottom' do
113
89
  it { instance.must_respond_to(:show_bottom) }
114
90
  it { instance.must_respond_to(:bottom?) }
115
- end
116
-
117
- describe '#show_bottom=' do
118
91
  it { instance.must_respond_to(:show_bottom=) }
119
- end
120
-
121
- describe '#show_left' do
122
92
  it { instance.must_respond_to(:show_left) }
123
93
  it { instance.must_respond_to(:left?) }
124
- end
125
-
126
- describe '#show_left=' do
127
94
  it { instance.must_respond_to(:show_left=) }
128
- end
129
-
130
- describe '#show_right' do
131
95
  it { instance.must_respond_to(:show_right) }
132
96
  it { instance.must_respond_to(:right?) }
133
- end
134
-
135
- describe '#show_right=' do
136
97
  it { instance.must_respond_to(:show_right=) }
137
- end
138
-
139
- describe '#show_top' do
140
98
  it { instance.must_respond_to(:show_top) }
141
99
  it { instance.must_respond_to(:top?) }
142
- end
143
-
144
- describe '#show_top=' do
145
100
  it { instance.must_respond_to(:show_top=) }
146
- end
147
-
148
- describe '#title' do
149
101
  it { instance.must_respond_to(:title) }
150
- end
151
-
152
- describe '#title=' do
153
102
  it { instance.must_respond_to(:title=) }
154
- end
155
-
156
- describe '#top_left' do
157
103
  it { instance.must_respond_to(:top_left) }
158
- end
159
-
160
- describe '#top_left=' do
161
104
  it { instance.must_respond_to(:top_left=) }
162
- end
163
-
164
- describe '#top_right' do
165
105
  it { instance.must_respond_to(:top_right) }
166
- end
167
-
168
- describe '#top_right=' do
169
106
  it { instance.must_respond_to(:top_right=) }
170
- end
171
-
172
- describe '#vertical' do
173
107
  it { instance.must_respond_to(:vertical) }
174
- end
175
-
176
- describe '#vertical=' do
177
108
  it { instance.must_respond_to(:vertical=) }
178
- end
179
-
180
- describe '#name' do
181
109
  it { instance.must_respond_to(:name) }
182
- end
183
-
184
- describe '#enabled' do
185
110
  it { instance.must_respond_to(:enabled) }
186
111
  it { instance.must_respond_to(:enabled?) }
187
112
  end
@@ -33,9 +33,15 @@ module Vedeu
33
33
  end
34
34
 
35
35
  describe '.by_group' do
36
+ let(:group) {}
37
+
36
38
  subject { described.by_group(group) }
37
39
 
38
40
  it { described.must_respond_to(:by_group) }
41
+
42
+ context 'when no group is given' do
43
+ it { subject.must_equal(nil) }
44
+ end
39
45
  end
40
46
 
41
47
  describe '.by_name' do
@@ -7,16 +7,18 @@ module Vedeu
7
7
  describe JSON do
8
8
 
9
9
  let(:described) { Vedeu::Renderers::JSON }
10
- let(:instance) { described.new(output) }
10
+ let(:instance) { described.new(output, options) }
11
11
  let(:output) {}
12
+ let(:options) { {} }
12
13
 
13
14
  describe '#initialize' do
14
15
  it { instance.must_be_instance_of(described) }
15
16
  it { instance.instance_variable_get('@output').must_equal(output) }
17
+ it { instance.instance_variable_get('@options').must_equal(options) }
16
18
  end
17
19
 
18
20
  describe '.render' do
19
- subject { described.render(output) }
21
+ subject { described.render(output, options) }
20
22
 
21
23
  it { subject.must_be_instance_of(String) }
22
24
 
@@ -37,15 +39,32 @@ module Vedeu
37
39
  ]
38
40
  ]
39
41
  }
40
- it { subject.must_equal(
41
- "{\"border\":\"\",\"colour\":{\"" \
42
- "background\":\"\\u001b[48;2;255;255;255m\"," \
43
- "\"foreground\":\"\\u001b[38;2;255;0;0m\"}," \
44
- "\"parent\":{\"" \
45
- "background\":\"\",\"foreground\":\"\",\"style\":\"\"}," \
46
- "\"position\":{\"y\":5,\"x\":3},\"style\":\"\"," \
47
- "\"value\":\"a\"}\n\n"
48
- ) }
42
+ let(:expected) {
43
+ <<-eos
44
+ [
45
+ {
46
+ \"border\": \"\",
47
+ \"colour\": {
48
+ \"background\": \"\\u001b[48;2;255;255;255m\",
49
+ \"foreground\": \"\\u001b[38;2;255;0;0m\"
50
+ },
51
+ \"parent\": {
52
+ \"background\": \"\",
53
+ \"foreground\": \"\",
54
+ \"style\": \"\"
55
+ },
56
+ \"position\": {
57
+ \"y\": 5,
58
+ \"x\": 3
59
+ },
60
+ \"style\": \"\",
61
+ \"value\": \"a\"
62
+ }
63
+ ]
64
+ eos
65
+ }
66
+
67
+ it { subject.must_equal(expected.chomp) }
49
68
  end
50
69
  end
51
70
 
@@ -17,11 +17,8 @@ module Vedeu
17
17
  it { instance.instance_variable_get('@value').must_equal('bold') }
18
18
  end
19
19
 
20
- describe '#value' do
20
+ describe 'accessors' do
21
21
  it { instance.must_respond_to(:value) }
22
- end
23
-
24
- describe '#value=' do
25
22
  it { instance.must_respond_to(:value=) }
26
23
  end
27
24
 
@@ -17,24 +17,12 @@ module Vedeu
17
17
  it { instance.instance_variable_get('@parent').must_equal(parent) }
18
18
  end
19
19
 
20
- describe '#collection' do
20
+ describe 'accessors' do
21
21
  it { instance.must_respond_to(:collection) }
22
22
  it { instance.must_respond_to(:all) }
23
- end
24
-
25
- describe '#parent' do
26
23
  it { instance.must_respond_to(:parent) }
27
- end
28
-
29
- describe '#parent=' do
30
24
  it { instance.must_respond_to(:parent=) }
31
- end
32
-
33
- describe '#name' do
34
25
  it { instance.must_respond_to(:name) }
35
- end
36
-
37
- describe '#name=' do
38
26
  it { instance.must_respond_to(:name=) }
39
27
  end
40
28
 
@@ -35,19 +35,17 @@ module Vedeu
35
35
  def initialize(attributes = {})
36
36
  @attributes = defaults.merge!(attributes)
37
37
 
38
- @colour = @attributes[:colour]
39
- @name = @attributes[:name]
40
- @style = @attributes[:style]
41
- @repository = Vedeu::RepositoryTestModule
38
+ @attributes.each { |key, value| instance_variable_set("@#{key}", value) }
42
39
  end
43
40
 
44
41
  private
45
42
 
46
43
  def defaults
47
44
  {
48
- colour: {},
49
- name: '',
50
- style: [],
45
+ colour: {},
46
+ name: '',
47
+ repository: Vedeu::RepositoryTestModule,
48
+ style: [],
51
49
  }
52
50
  end
53
51
 
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.39
4
+ version: 0.4.40
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-29 00:00:00.000000000 Z
11
+ date: 2015-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aruba
@@ -385,6 +385,7 @@ files:
385
385
  - lib/vedeu/generator/templates/application/app/helpers/name.erb
386
386
  - lib/vedeu/generator/templates/application/app/models/keymaps/_global_.rb
387
387
  - lib/vedeu/generator/templates/application/app/models/keymaps/_system_.rb
388
+ - lib/vedeu/generator/templates/application/app/models/keymaps/name.erb
388
389
  - lib/vedeu/generator/templates/application/app/views/interfaces/name.erb
389
390
  - lib/vedeu/generator/templates/application/app/views/name.erb
390
391
  - lib/vedeu/generator/templates/application/app/views/templates/name.erb