vedeu 0.4.41 → 0.4.42
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 +4 -4
- data/README.md +3 -6
- data/bin/vedeu +1 -50
- data/docs/applications.md +18 -2
- data/lib/vedeu/all.rb +3 -1
- data/lib/vedeu/api.rb +3 -1
- data/lib/vedeu/application/controller.rb +5 -0
- data/lib/vedeu/buffers/buffer.rb +6 -3
- data/lib/vedeu/cli/all.rb +1 -0
- data/lib/vedeu/{generator → cli/generator}/all.rb +3 -3
- data/lib/vedeu/{generator → cli/generator}/application.rb +0 -0
- data/lib/vedeu/{generator → cli/generator}/helpers.rb +4 -11
- data/lib/vedeu/{generator → cli/generator}/templates/application/Gemfile +0 -0
- data/lib/vedeu/{generator → cli/generator}/templates/application/app/controllers/application_controller.erb +0 -0
- data/lib/vedeu/{generator → cli/generator}/templates/application/app/controllers/name.erb +2 -0
- data/lib/vedeu/{generator → cli/generator}/templates/application/app/helpers/application_helper.erb +0 -0
- data/lib/vedeu/{generator → cli/generator}/templates/application/app/helpers/name.erb +0 -0
- data/lib/vedeu/{generator → cli/generator}/templates/application/app/models/keymaps/_global_.rb +0 -0
- data/lib/vedeu/{generator → cli/generator}/templates/application/app/models/keymaps/name.erb +0 -0
- data/lib/vedeu/{generator → cli/generator}/templates/application/app/views/interfaces/name.erb +6 -0
- data/lib/vedeu/{generator → cli/generator}/templates/application/app/views/name.erb +0 -0
- data/lib/vedeu/{generator → cli/generator}/templates/application/app/views/templates/name.erb +0 -0
- data/lib/vedeu/{generator → cli/generator}/templates/application/application.erb +0 -0
- data/lib/vedeu/{generator → cli/generator}/templates/application/bin/name +0 -0
- data/lib/vedeu/{generator → cli/generator}/templates/application/config/app_name.erb +0 -0
- data/lib/vedeu/{generator → cli/generator}/templates/application/config/configuration.erb +0 -0
- data/lib/vedeu/{generator → cli/generator}/templates/application/lib/.gitkeep +0 -0
- data/lib/vedeu/{generator → cli/generator}/templates/application/test/.gitkeep +0 -0
- data/lib/vedeu/{generator → cli/generator}/templates/application/vendor/.gitkeep +0 -0
- data/lib/vedeu/{generator → cli/generator}/view.rb +1 -2
- data/lib/vedeu/cli/main.rb +29 -0
- data/lib/vedeu/dsl/presentation.rb +6 -2
- data/lib/vedeu/dsl/view.rb +2 -1
- data/lib/vedeu/geometry/area.rb +4 -4
- data/lib/vedeu/models/interface.rb +0 -3
- data/lib/vedeu/output/colour.rb +16 -35
- data/lib/vedeu/output/presentation.rb +34 -21
- data/lib/vedeu/output/translator.rb +2 -5
- data/lib/vedeu/repositories/model.rb +4 -13
- data/lib/vedeu/support/common.rb +30 -0
- data/lib/vedeu/version.rb +1 -1
- data/lib/vedeu.rb +2 -0
- data/test/lib/vedeu/application/application_view_test.rb +2 -4
- data/test/lib/vedeu/application/controller_test.rb +26 -0
- data/test/lib/vedeu/application/helper_test.rb +26 -0
- data/test/lib/vedeu/application/view_test.rb +26 -0
- data/test/lib/vedeu/application_test.rb +2 -4
- data/test/lib/vedeu/bootstrap_test.rb +3 -5
- data/test/lib/vedeu/{generator → cli/generator}/application_test.rb +0 -0
- data/test/lib/vedeu/{generator → cli/generator}/helpers_test.rb +1 -9
- data/test/lib/vedeu/{generator → cli/generator}/view_test.rb +0 -0
- data/test/lib/vedeu/cli/main_test.rb +12 -0
- data/test/lib/vedeu/cursor/reposition_test.rb +0 -2
- data/test/lib/vedeu/distributed/subprocess_test.rb +3 -5
- data/test/lib/vedeu/distributed/uri_test.rb +3 -5
- data/test/lib/vedeu/dsl/border_test.rb +0 -17
- data/test/lib/vedeu/dsl/composition_test.rb +0 -8
- data/test/lib/vedeu/dsl/presentation_test.rb +34 -22
- data/test/lib/vedeu/dsl/view_test.rb +1 -0
- data/test/lib/vedeu/events/trigger_test.rb +4 -6
- data/test/lib/vedeu/geometry/geometry_test.rb +15 -14
- data/test/lib/vedeu/models/composition_test.rb +2 -4
- data/test/lib/vedeu/models/focus_test.rb +5 -2
- data/test/lib/vedeu/models/group_test.rb +5 -7
- data/test/lib/vedeu/models/interface_test.rb +12 -16
- data/test/lib/vedeu/models/menu_test.rb +8 -8
- data/test/lib/vedeu/output/border_test.rb +20 -21
- data/test/lib/vedeu/output/colour_test.rb +41 -122
- data/test/lib/vedeu/output/presentation_test.rb +30 -27
- data/test/lib/vedeu/output/translator_test.rb +12 -1
- data/test/lib/vedeu/support/common_test.rb +17 -2
- data/test/test_helper.rb +3 -1
- data/vedeu.gemspec +2 -1
- metadata +53 -31
- data/lib/vedeu/tasks/application.rake +0 -28
- data/lib/vedeu/tasks/vedeu.rake +0 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d52cfaf13c8adfd85fb8d7f29a66133d4d12781c
|
|
4
|
+
data.tar.gz: 901409d56b30fad4859b55f5b188e44a16628b08
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 46f1892cef45301eefbea271b95a06455ce30781e4b5f793cd779adb1c81e83e2f99c833db01d97b171fbfdda163f3fe890dff977d9f6108270bd8ea229b23ba
|
|
7
|
+
data.tar.gz: 752fd49e4627635d187c7d8b73f1773f3be1b1d12a638ae2f0f15e1466a219ac4a16237a869138cb394138571c77b13b112c0b1dccb7b712b4a32f8a16ebeb56
|
data/README.md
CHANGED
|
@@ -21,14 +21,11 @@ Note: You may have trouble running Vedeu with Windows installations. (Pull
|
|
|
21
21
|
|
|
22
22
|
## Installation
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
To install Vedeu, simply:
|
|
25
25
|
|
|
26
|
-
gem 'vedeu'
|
|
27
|
-
|
|
28
|
-
And then execute:
|
|
29
|
-
|
|
30
|
-
$ bundle
|
|
26
|
+
gem install 'vedeu'
|
|
31
27
|
|
|
28
|
+
To use Vedeu's application scaffolding, see the [RubyDoc](http://www.rubydoc.info/gems/vedeu/file/docs/applications.md)
|
|
32
29
|
|
|
33
30
|
## Example
|
|
34
31
|
|
data/bin/vedeu
CHANGED
|
@@ -1,57 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
|
|
3
|
-
require 'rake'
|
|
4
|
-
|
|
5
|
-
bundler_message = 'Bundler is required. Please install bundler with ' \
|
|
6
|
-
"'gem install bundler'"
|
|
7
|
-
|
|
8
|
-
begin
|
|
9
|
-
require 'bundler'
|
|
10
|
-
|
|
11
|
-
rescue LoadError
|
|
12
|
-
puts bundler_message
|
|
13
|
-
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
fail bundler_message unless defined?(Bundler)
|
|
17
|
-
|
|
18
|
-
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
|
|
19
|
-
# load Gem.bin_path('bundler', 'bundle')
|
|
20
|
-
|
|
21
|
-
Bundler.setup
|
|
22
|
-
|
|
23
|
-
Rake.application.init
|
|
24
|
-
|
|
25
3
|
gem_dir = File.expand_path('..', File.dirname(__FILE__))
|
|
26
4
|
$LOAD_PATH.unshift(gem_dir) unless $LOAD_PATH.include?(gem_dir)
|
|
27
5
|
|
|
28
|
-
# Initialize vedeu
|
|
29
6
|
require 'vedeu'
|
|
30
7
|
|
|
31
|
-
|
|
32
|
-
load "#{gem_dir}/lib/vedeu/tasks/vedeu.rake"
|
|
33
|
-
|
|
34
|
-
# Let's go!
|
|
35
|
-
begin
|
|
36
|
-
if ARGV.empty?
|
|
37
|
-
print "\n\e[33mVedeu v#{Vedeu::VERSION}\e[39m\n\n"
|
|
38
|
-
print "\e[4m\e[36mUsage:\e[39m\e[24m\n\n"
|
|
39
|
-
print "\e[32m vedeu new [app_name]\e[39m\n"
|
|
40
|
-
print ' Creates the skeleton file and directory structure for a new '
|
|
41
|
-
print "Vedeu client application.\n\n"
|
|
42
|
-
print "\e[32m vedeu view [view_name]\e[39m\n"
|
|
43
|
-
print " Creates a new view for Vedeu.\n"
|
|
44
|
-
print "\n\n"
|
|
45
|
-
|
|
46
|
-
else
|
|
47
|
-
Rake.application.invoke_task(ARGV.shift)
|
|
48
|
-
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
rescue RuntimeError => exception
|
|
52
|
-
puts 'Vedeu Error: Either the task you specified failed, or the task could ' \
|
|
53
|
-
"not be built.\n"
|
|
54
|
-
puts "Exception: #{exception.class.name}"
|
|
55
|
-
puts "Message: #{exception.message}"
|
|
56
|
-
|
|
57
|
-
end
|
|
8
|
+
Vedeu::CLI::Main.start(ARGV.dup)
|
data/docs/applications.md
CHANGED
|
@@ -4,8 +4,17 @@ 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
|
+
### Installing Vedeu
|
|
8
|
+
|
|
9
|
+
To install Vedeu, simply:
|
|
10
|
+
|
|
11
|
+
gem install 'vedeu'
|
|
12
|
+
|
|
13
|
+
To use Vedeu's application scaffolding, see below:
|
|
14
|
+
|
|
7
15
|
### Generating a new application
|
|
8
16
|
|
|
17
|
+
```bash
|
|
9
18
|
|
|
|
10
19
|
|- app_name/
|
|
11
20
|
| |
|
|
@@ -36,10 +45,13 @@ hopefully these generators will get you off the ground.
|
|
|
36
45
|
|- vendor/
|
|
37
46
|
|- application.rb
|
|
38
47
|
|- Gemfile
|
|
48
|
+
```
|
|
39
49
|
|
|
40
50
|
To create the application structure as shown above:
|
|
41
51
|
|
|
42
|
-
|
|
52
|
+
```bash
|
|
53
|
+
vedeu new app_name
|
|
54
|
+
```
|
|
43
55
|
|
|
44
56
|
Let's talk about each directory and its purpose.
|
|
45
57
|
|
|
@@ -120,10 +132,13 @@ might want to do something special.
|
|
|
120
132
|
Vedeu also provides a generator to create the files needed for a view. To run
|
|
121
133
|
this, use the following from within the root of the application directory:
|
|
122
134
|
|
|
123
|
-
|
|
135
|
+
```bash
|
|
136
|
+
vedeu view view_name
|
|
137
|
+
```
|
|
124
138
|
|
|
125
139
|
Let's talk about the files it will create and populate:
|
|
126
140
|
|
|
141
|
+
```bash
|
|
127
142
|
|
|
|
128
143
|
|- app_name/
|
|
129
144
|
| |
|
|
@@ -147,5 +162,6 @@ Let's talk about the files it will create and populate:
|
|
|
147
162
|
| |
|
|
148
163
|
| |- view_name.rb
|
|
149
164
|
|...
|
|
165
|
+
```
|
|
150
166
|
|
|
151
167
|
####
|
data/lib/vedeu/all.rb
CHANGED
|
@@ -13,7 +13,7 @@ require 'vedeu/repositories/all'
|
|
|
13
13
|
require 'vedeu/api'
|
|
14
14
|
require 'vedeu/bindings'
|
|
15
15
|
|
|
16
|
-
require 'vedeu/generator/all'
|
|
16
|
+
require 'vedeu/cli/generator/all'
|
|
17
17
|
|
|
18
18
|
# load order has not been fully established beyond this point
|
|
19
19
|
|
|
@@ -37,3 +37,5 @@ require 'vedeu/launcher'
|
|
|
37
37
|
require 'vedeu/application/all'
|
|
38
38
|
|
|
39
39
|
require 'vedeu/bootstrap'
|
|
40
|
+
|
|
41
|
+
require 'vedeu/cli/all'
|
data/lib/vedeu/api.rb
CHANGED
|
@@ -75,11 +75,13 @@ module Vedeu
|
|
|
75
75
|
|
|
76
76
|
# @!method interface
|
|
77
77
|
# @see Vedeu::DSL::View.interface
|
|
78
|
+
# @!method render
|
|
79
|
+
# @see Vedeu::DSL::View.render
|
|
78
80
|
# @!method renders
|
|
79
81
|
# @see Vedeu::DSL::View.renders
|
|
80
82
|
# @!method views
|
|
81
83
|
# @see Vedeu::DSL::View.views
|
|
82
|
-
def_delegators Vedeu::DSL::View, :interface, :renders, :views
|
|
84
|
+
def_delegators Vedeu::DSL::View, :interface, :renders, :render, :views
|
|
83
85
|
|
|
84
86
|
# @!method bind
|
|
85
87
|
# @see Vedeu::Event.bind
|
data/lib/vedeu/buffers/buffer.rb
CHANGED
|
@@ -74,7 +74,7 @@ module Vedeu
|
|
|
74
74
|
#
|
|
75
75
|
# @return [Boolean] Whether the buffer targetted has content.
|
|
76
76
|
def back?
|
|
77
|
-
return false if back.nil? || back.
|
|
77
|
+
return false if back.nil? || back.lines.empty?
|
|
78
78
|
|
|
79
79
|
true
|
|
80
80
|
end
|
|
@@ -90,7 +90,7 @@ module Vedeu
|
|
|
90
90
|
#
|
|
91
91
|
# @return [Boolean] Whether the buffer targetted has content.
|
|
92
92
|
def front?
|
|
93
|
-
return false if front.nil? || front.
|
|
93
|
+
return false if front.nil? || front.lines.empty?
|
|
94
94
|
|
|
95
95
|
true
|
|
96
96
|
end
|
|
@@ -99,7 +99,7 @@ module Vedeu
|
|
|
99
99
|
#
|
|
100
100
|
# @return [Boolean] Whether the buffer targetted has content.
|
|
101
101
|
def previous?
|
|
102
|
-
return false if previous.nil? || previous.
|
|
102
|
+
return false if previous.nil? || previous.lines.empty?
|
|
103
103
|
|
|
104
104
|
true
|
|
105
105
|
end
|
|
@@ -199,6 +199,9 @@ module Vedeu
|
|
|
199
199
|
elsif previous?
|
|
200
200
|
[previous.render]
|
|
201
201
|
|
|
202
|
+
elsif visible?
|
|
203
|
+
[interface.render]
|
|
204
|
+
|
|
202
205
|
else
|
|
203
206
|
[]
|
|
204
207
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require_relative 'main'
|
|
File without changes
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
require 'vedeu/support/common'
|
|
2
|
+
|
|
1
3
|
module Vedeu
|
|
2
4
|
|
|
3
5
|
module Generator
|
|
@@ -8,22 +10,13 @@ module Vedeu
|
|
|
8
10
|
# @api private
|
|
9
11
|
module Helpers
|
|
10
12
|
|
|
13
|
+
include Vedeu::Common
|
|
14
|
+
|
|
11
15
|
# @return [String]
|
|
12
16
|
def app_name
|
|
13
17
|
@app_name ||= File.read('./config/app_name')
|
|
14
18
|
end
|
|
15
19
|
|
|
16
|
-
# @param name [String]
|
|
17
|
-
# @return [String]
|
|
18
|
-
def app_name_as_snake_case(name = app_name)
|
|
19
|
-
name.gsub!(/::/, '/')
|
|
20
|
-
name.gsub!(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
|
|
21
|
-
name.gsub!(/([a-z\d])([A-Z])/, '\1_\2')
|
|
22
|
-
name.tr!('-', '_')
|
|
23
|
-
name.downcase!
|
|
24
|
-
name
|
|
25
|
-
end
|
|
26
|
-
|
|
27
20
|
# @param destination [String]
|
|
28
21
|
# @return [void]
|
|
29
22
|
def make_directory(destination)
|
|
File without changes
|
|
File without changes
|
|
@@ -5,6 +5,8 @@ module <%= object.app_name %>
|
|
|
5
5
|
|
|
6
6
|
class <%= object.name_as_class %>Controller < <%= object.app_name -%>::ApplicationController
|
|
7
7
|
|
|
8
|
+
controller_name <%= object.app_name -%>
|
|
9
|
+
|
|
8
10
|
def initialize
|
|
9
11
|
<%= object.app_name %>::<%= object.name_as_class %>View.render(object)
|
|
10
12
|
end
|
data/lib/vedeu/{generator → cli/generator}/templates/application/app/helpers/application_helper.erb
RENAMED
|
File without changes
|
|
File without changes
|
data/lib/vedeu/{generator → cli/generator}/templates/application/app/models/keymaps/_global_.rb
RENAMED
|
File without changes
|
data/lib/vedeu/{generator → cli/generator}/templates/application/app/models/keymaps/name.erb
RENAMED
|
File without changes
|
|
File without changes
|
data/lib/vedeu/{generator → cli/generator}/templates/application/app/views/templates/name.erb
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module Vedeu
|
|
2
|
+
|
|
3
|
+
module CLI
|
|
4
|
+
|
|
5
|
+
class Main < Thor
|
|
6
|
+
|
|
7
|
+
desc 'new <name>', 'Create a skeleton Vedeu client application.'
|
|
8
|
+
def new(name)
|
|
9
|
+
say Vedeu::Generator::Application.generate(name)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# 'Specify the interface name lowercase snakecase; e.g. main_interface'
|
|
13
|
+
desc 'view <name>',
|
|
14
|
+
'Create a new interface within the client application.'
|
|
15
|
+
def view(name)
|
|
16
|
+
Vedeu::Generator::View.generate(name)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
desc 'version',
|
|
20
|
+
'Print the version.'
|
|
21
|
+
def version
|
|
22
|
+
say "vedeu #{Vedeu::VERSION}"
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
end # Main
|
|
26
|
+
|
|
27
|
+
end # CLI
|
|
28
|
+
|
|
29
|
+
end # Vedeu
|
|
@@ -38,14 +38,18 @@ module Vedeu
|
|
|
38
38
|
#
|
|
39
39
|
# @return [String]
|
|
40
40
|
def background(value = '')
|
|
41
|
-
colour(
|
|
41
|
+
model.colour = Vedeu::Colour.coerce(
|
|
42
|
+
background: Vedeu::Background.coerce(value),
|
|
43
|
+
foreground: model.colour.foreground)
|
|
42
44
|
end
|
|
43
45
|
alias_method :bg, :background
|
|
44
46
|
alias_method :bgcolor, :background
|
|
45
47
|
|
|
46
48
|
# @see Vedeu::DSL::Presentation#background
|
|
47
49
|
def foreground(value = '')
|
|
48
|
-
colour(
|
|
50
|
+
model.colour = Vedeu::Colour.coerce(
|
|
51
|
+
foreground: Vedeu::Foreground.coerce(value),
|
|
52
|
+
background: model.colour.background)
|
|
49
53
|
end
|
|
50
54
|
alias_method :fg, :foreground
|
|
51
55
|
alias_method :fgcolor, :foreground
|
data/lib/vedeu/dsl/view.rb
CHANGED
|
@@ -58,11 +58,12 @@ module Vedeu
|
|
|
58
58
|
#
|
|
59
59
|
# @raise [InvalidSyntax] The required block was not given.
|
|
60
60
|
# @return [Array<Interface>]
|
|
61
|
-
def
|
|
61
|
+
def render(&block)
|
|
62
62
|
fail InvalidSyntax, 'block not given' unless block_given?
|
|
63
63
|
|
|
64
64
|
store(:store_immediate, &block)
|
|
65
65
|
end
|
|
66
|
+
alias_method :renders, :render
|
|
66
67
|
|
|
67
68
|
# Deferred view
|
|
68
69
|
#
|
data/lib/vedeu/geometry/area.rb
CHANGED
|
@@ -123,7 +123,7 @@ module Vedeu
|
|
|
123
123
|
# Returns the row above the top by default.
|
|
124
124
|
#
|
|
125
125
|
# @example
|
|
126
|
-
# `top`
|
|
126
|
+
# `top` or `y` is 4.
|
|
127
127
|
#
|
|
128
128
|
# north # => 3
|
|
129
129
|
# north(2) # => 2 (positive goes north)
|
|
@@ -138,7 +138,7 @@ module Vedeu
|
|
|
138
138
|
# Returns the column after right by default.
|
|
139
139
|
#
|
|
140
140
|
# @example
|
|
141
|
-
# `right`
|
|
141
|
+
# `right` or `xn` is 19.
|
|
142
142
|
#
|
|
143
143
|
# east # => 20
|
|
144
144
|
# east(2) # => 21 (positive goes east)
|
|
@@ -153,7 +153,7 @@ module Vedeu
|
|
|
153
153
|
# Returns the row below the bottom by default.
|
|
154
154
|
#
|
|
155
155
|
# @example
|
|
156
|
-
# `bottom`
|
|
156
|
+
# `bottom` or `yn` is 12.
|
|
157
157
|
#
|
|
158
158
|
# south # => 13
|
|
159
159
|
# south(2) # => 14 (positive goes south)
|
|
@@ -168,7 +168,7 @@ module Vedeu
|
|
|
168
168
|
# Returns the column before left by default.
|
|
169
169
|
#
|
|
170
170
|
# @example
|
|
171
|
-
# `left`
|
|
171
|
+
# `left` or `x` is 8.
|
|
172
172
|
#
|
|
173
173
|
# west # => 7
|
|
174
174
|
# west(2) # => 6 (positive goes west)
|
|
@@ -94,7 +94,6 @@ module Vedeu
|
|
|
94
94
|
def lines
|
|
95
95
|
collection.coerce(@lines, self)
|
|
96
96
|
end
|
|
97
|
-
alias_method :content, :lines
|
|
98
97
|
alias_method :value, :lines
|
|
99
98
|
|
|
100
99
|
# Returns a boolean indicating whether the interface has content.
|
|
@@ -103,8 +102,6 @@ module Vedeu
|
|
|
103
102
|
def lines?
|
|
104
103
|
lines.any?
|
|
105
104
|
end
|
|
106
|
-
alias_method :content?, :lines?
|
|
107
|
-
alias_method :value?, :lines?
|
|
108
105
|
|
|
109
106
|
# Returns a boolean indicating whether the interface belongs to a
|
|
110
107
|
# group.
|
data/lib/vedeu/output/colour.rb
CHANGED
|
@@ -33,9 +33,13 @@ module Vedeu
|
|
|
33
33
|
# @api private
|
|
34
34
|
class Colour
|
|
35
35
|
|
|
36
|
-
# @!attribute [r]
|
|
37
|
-
# @return [
|
|
38
|
-
attr_reader :
|
|
36
|
+
# @!attribute [r] background
|
|
37
|
+
# @return [Vedeu::Background]
|
|
38
|
+
attr_reader :background
|
|
39
|
+
|
|
40
|
+
# @!attribute [r] foreground
|
|
41
|
+
# @return [Vedeu::Foreground]
|
|
42
|
+
attr_reader :foreground
|
|
39
43
|
|
|
40
44
|
# @param value []
|
|
41
45
|
# @return [Object]
|
|
@@ -43,11 +47,11 @@ module Vedeu
|
|
|
43
47
|
return value if value.is_a?(self)
|
|
44
48
|
return new unless value.is_a?(Hash)
|
|
45
49
|
|
|
46
|
-
if value[:colour]
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
50
|
+
if value[:colour] && value[:colour].is_a?(self)
|
|
51
|
+
value[:colour]
|
|
52
|
+
|
|
53
|
+
elsif value[:colour] && value[:colour].is_a?(Hash)
|
|
54
|
+
new(value[:colour])
|
|
51
55
|
|
|
52
56
|
elsif value[:background] || value[:foreground]
|
|
53
57
|
new(value)
|
|
@@ -65,14 +69,8 @@ module Vedeu
|
|
|
65
69
|
# @option attributes foreground [String]
|
|
66
70
|
# @return [Vedeu::Colour]
|
|
67
71
|
def initialize(attributes = {})
|
|
68
|
-
@
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
# Returns the background colour as a Vedeu::Background.
|
|
72
|
-
#
|
|
73
|
-
# @return [Vedeu::Background]
|
|
74
|
-
def background
|
|
75
|
-
@background ||= Vedeu::Background.coerce(attributes[:background])
|
|
72
|
+
@background = Vedeu::Background.coerce(attributes[:background])
|
|
73
|
+
@foreground = Vedeu::Foreground.coerce(attributes[:foreground])
|
|
76
74
|
end
|
|
77
75
|
|
|
78
76
|
# Converts the value into a Vedeu::Background.
|
|
@@ -80,7 +78,7 @@ module Vedeu
|
|
|
80
78
|
# @param value [String]
|
|
81
79
|
# @return [String]
|
|
82
80
|
def background=(value)
|
|
83
|
-
@background =
|
|
81
|
+
@background = Vedeu::Background.coerce(value)
|
|
84
82
|
end
|
|
85
83
|
|
|
86
84
|
# An object is equal when its values are the same.
|
|
@@ -93,19 +91,12 @@ module Vedeu
|
|
|
93
91
|
end
|
|
94
92
|
alias_method :==, :eql?
|
|
95
93
|
|
|
96
|
-
# Returns the foreground colour as a Vedeu::Foreground.
|
|
97
|
-
#
|
|
98
|
-
# @return [Vedeu::Foreground]
|
|
99
|
-
def foreground
|
|
100
|
-
@foreground ||= Vedeu::Foreground.coerce(attributes[:foreground])
|
|
101
|
-
end
|
|
102
|
-
|
|
103
94
|
# Converts the value into a Vedeu::Foreground.
|
|
104
95
|
#
|
|
105
96
|
# @param value [String]
|
|
106
97
|
# @return [String]
|
|
107
98
|
def foreground=(value)
|
|
108
|
-
@foreground =
|
|
99
|
+
@foreground = Vedeu::Foreground.coerce(value)
|
|
109
100
|
end
|
|
110
101
|
|
|
111
102
|
# Returns both or either of the converted attributes into a single escape
|
|
@@ -119,16 +110,6 @@ module Vedeu
|
|
|
119
110
|
|
|
120
111
|
private
|
|
121
112
|
|
|
122
|
-
# The default values for a new instance of this class.
|
|
123
|
-
#
|
|
124
|
-
# @return [Hash<Symbol => NilClass>]
|
|
125
|
-
def defaults
|
|
126
|
-
{
|
|
127
|
-
background: '',
|
|
128
|
-
foreground: '',
|
|
129
|
-
}
|
|
130
|
-
end
|
|
131
|
-
|
|
132
113
|
end # Colour
|
|
133
114
|
|
|
134
115
|
end # Vedeu
|
|
@@ -19,19 +19,28 @@ module Vedeu
|
|
|
19
19
|
|
|
20
20
|
# @return [Vedeu::Background]
|
|
21
21
|
def background=(value)
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
self.colour = Vedeu::Colour.coerce(
|
|
23
|
+
background: Vedeu::Background.coerce(value),
|
|
24
|
+
foreground: colour.foreground)
|
|
24
25
|
end
|
|
25
26
|
|
|
26
27
|
# @return [Vedeu::Colour]
|
|
27
28
|
def colour
|
|
28
|
-
@colour ||=
|
|
29
|
+
@colour ||= if attributes[:colour]
|
|
30
|
+
Vedeu::Colour.coerce(attributes[:colour])
|
|
31
|
+
|
|
32
|
+
elsif parent_colour
|
|
33
|
+
Vedeu::Colour.coerce(parent_colour)
|
|
34
|
+
|
|
35
|
+
else
|
|
36
|
+
Vedeu::Colour.new
|
|
37
|
+
|
|
38
|
+
end
|
|
29
39
|
end
|
|
30
40
|
|
|
31
41
|
# @return [Vedeu::Colour]
|
|
32
42
|
def colour=(value)
|
|
33
|
-
@attributes[:colour] = value
|
|
34
|
-
@colour = Vedeu::Colour.coerce(value)
|
|
43
|
+
@colour = attributes[:colour] = Vedeu::Colour.coerce(value)
|
|
35
44
|
end
|
|
36
45
|
|
|
37
46
|
# @return [Vedeu::Foreground]
|
|
@@ -47,8 +56,9 @@ module Vedeu
|
|
|
47
56
|
|
|
48
57
|
# @return [Vedeu::Foreground]
|
|
49
58
|
def foreground=(value)
|
|
50
|
-
|
|
51
|
-
|
|
59
|
+
self.colour = Vedeu::Colour.coerce(
|
|
60
|
+
foreground: Vedeu::Foreground.coerce(value),
|
|
61
|
+
background: colour.background)
|
|
52
62
|
end
|
|
53
63
|
|
|
54
64
|
# @return [Vedeu::Background]
|
|
@@ -80,12 +90,27 @@ module Vedeu
|
|
|
80
90
|
|
|
81
91
|
# @return [String|NilClass]
|
|
82
92
|
def parent_style
|
|
83
|
-
|
|
93
|
+
if parent
|
|
94
|
+
parent.style
|
|
95
|
+
|
|
96
|
+
else
|
|
97
|
+
Vedeu::Style.new
|
|
98
|
+
|
|
99
|
+
end
|
|
84
100
|
end
|
|
85
101
|
|
|
86
102
|
# @return [Vedeu::Style]
|
|
87
103
|
def style
|
|
88
|
-
@style ||=
|
|
104
|
+
@style ||= if attributes[:style]
|
|
105
|
+
Vedeu::Style.coerce(attributes[:style])
|
|
106
|
+
|
|
107
|
+
elsif parent_style
|
|
108
|
+
Vedeu::Style.coerce(parent_style)
|
|
109
|
+
|
|
110
|
+
else
|
|
111
|
+
Vedeu::Style.new
|
|
112
|
+
|
|
113
|
+
end
|
|
89
114
|
end
|
|
90
115
|
|
|
91
116
|
# @return [Vedeu::Style]
|
|
@@ -105,12 +130,6 @@ module Vedeu
|
|
|
105
130
|
|
|
106
131
|
private
|
|
107
132
|
|
|
108
|
-
# @return [void]
|
|
109
|
-
def _colour
|
|
110
|
-
return attributes[:colour] if attributes[:colour]
|
|
111
|
-
return parent_colour if parent && parent_colour
|
|
112
|
-
end
|
|
113
|
-
|
|
114
133
|
# Renders the colour attributes of the receiver and yields (to then render
|
|
115
134
|
# the styles).
|
|
116
135
|
#
|
|
@@ -138,12 +157,6 @@ module Vedeu
|
|
|
138
157
|
[style, yield].join
|
|
139
158
|
end
|
|
140
159
|
|
|
141
|
-
# @return [void]
|
|
142
|
-
def _style
|
|
143
|
-
return attributes[:style] if attributes[:style]
|
|
144
|
-
return parent_style if parent && parent_style
|
|
145
|
-
end
|
|
146
|
-
|
|
147
160
|
end # Presentation
|
|
148
161
|
|
|
149
162
|
end # Vedeu
|