vedeu 0.1.14 → 0.1.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 79cbcf71bd0a9c214cd3764d10cfc21e8b6aeffa
4
- data.tar.gz: 570893355905af7e58d89e64cc419ee361133dd3
3
+ metadata.gz: 395f38280fc3c3c2c08cd35934211d1bf5f2f088
4
+ data.tar.gz: 56e22bfd0a48a8afed5d95577db5d556207f394e
5
5
  SHA512:
6
- metadata.gz: 0d143574721a8b5a0e07eb6fb081c3768fa3c994c28a72303b07f9c1abc3a384262fa8c7abe493dceb5c3069f060b0521c804d1c7cff6bf5864fb2cd9922ba22
7
- data.tar.gz: 502eb3bba9db28fc1ca44b1f6cd7dd017c18fc3d1f0ce6783d23b56459d758d3dd9cd0d1fb6dc54448fc13342b001304123b4914b206e43617f437cfa5980967
6
+ metadata.gz: 358f6eb1e2c13a9e3c6ff57db89165c9799a5b5df066251cf1437443897d210435f08abed2f4a582d7d15b66cef4d0bd0bbfa4c382e1ccb4f631c23afe2542ee
7
+ data.tar.gz: 34dcb6740bdae17988a112977b1b795fb455a926e474e53e41be69b2d30f11396b02333648afe7508a400da5257257a64b2ee963ef79b1f077f1a6297c5be12f
data/lib/vedeu/api/api.rb CHANGED
@@ -1,9 +1,19 @@
1
1
  module Vedeu
2
2
  module API
3
+ # @param name [Symbol] The name of the event which will be triggered later
4
+ # @param delay [Fixnum|Float] Limits the execution of the triggered event to
5
+ # the delay in seconds, effectively throttling the event. A delay of 1.0
6
+ # will mean that even if the event is triggered multiple times a second
7
+ # it will only execute once for that second. Triggers inside the delay are
8
+ # discarded.
9
+ # @param block [Proc] The event to be executed when triggered. This block
10
+ # could be a method call, or the triggering of another event, or sequence
11
+ # of either/both.
3
12
  def event(name, delay = 0, &block)
4
13
  Vedeu.events.event(name, delay, &block)
5
14
  end
6
15
 
16
+ # @api private
7
17
  def events
8
18
  @events ||= API::Events.new do
9
19
  event(:_log_) { |msg| Vedeu.log(msg) }
@@ -15,32 +25,50 @@ module Vedeu
15
25
  end
16
26
  end
17
27
 
28
+ # @return [Fixnum] The total height of the current terminal.
18
29
  def height
19
30
  Terminal.height
20
31
  end
21
32
 
33
+ # @param name [String] The name of the interface. Used to reference the
34
+ # interface throughout your application's execution lifetime.
35
+ # @param block [Proc] A set of attributes which define the features of the
36
+ # interface. TODO: More help.
22
37
  def interface(name, &block)
23
38
  API::Interface.define({ name: name }, &block)
24
39
  end
25
40
 
41
+ # @param key [String] A simulated keypress. Escape sequences are also
42
+ # supported.
26
43
  def keypress(key)
27
44
  trigger(:key, key)
28
- trigger(:_log_, (' ' * 42) + "key: #{key}")
45
+ trigger(:_log_, "Key: #{key}")
29
46
  trigger(:_mode_switch_) if key == :escape
30
47
  end
31
48
 
49
+ # @param message [String] The message you wish to emit to the log
50
+ # file, useful for debugging.
32
51
  def log(message)
33
52
  API::Log.logger.debug(message)
34
53
  end
35
54
 
55
+ # @param name [Symbol] The name of the event you wish to trigger.
56
+ # The event does not have to exist.
57
+ # @param args [Array] Any arguments the event needs to execute correctly.
36
58
  def trigger(name, *args)
37
59
  Vedeu.events.trigger(name, *args)
38
60
  end
39
61
 
62
+ # @param name [String] The name of the interface you wish to use. Typically
63
+ # used when defining interfaces to share geometry. TODO: Example required.
40
64
  def use(name)
41
65
  Vedeu::Interface.new(Vedeu::Store.query(name))
42
66
  end
43
67
 
68
+ # @param name [String] The name of the interface you are targetting for this
69
+ # view.
70
+ # @param block [Proc] The directives you wish to send to this interface.
71
+ # TODO: Example required.
44
72
  def view(name, &block)
45
73
  {
46
74
  interfaces: [
@@ -49,10 +77,14 @@ module Vedeu
49
77
  }
50
78
  end
51
79
 
80
+ # @param block [Proc] Instructs Vedeu to treat all of the 'view' directives
81
+ # therein as one instruction. Useful for redrawing multiple interfaces at
82
+ # once. TODO: Example required.
52
83
  def views(&block)
53
84
  API::Composition.build(&block)
54
85
  end
55
86
 
87
+ # @return [Fixnum] The total width of the current terminal.
56
88
  def width
57
89
  Terminal.width
58
90
  end
@@ -54,6 +54,10 @@ module Vedeu
54
54
  attributes[:group] = value
55
55
  end
56
56
 
57
+ def name(value)
58
+ attributes[:name] = value
59
+ end
60
+
57
61
  def x(value)
58
62
  fail XOutOfBounds if x_out_of_bounds?(value)
59
63
 
data/lib/vedeu/api/log.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'fileutils'
2
+ require 'time'
2
3
 
3
4
  module Vedeu
4
5
  module API
@@ -70,10 +70,12 @@ module Vedeu
70
70
  [(height / 2), (width / 2)]
71
71
  end
72
72
 
73
+ # @return [Fixnum] The total width of the current terminal.
73
74
  def width
74
75
  size.last
75
76
  end
76
77
 
78
+ # @return [Fixnum] The total height of the current terminal.
77
79
  def height
78
80
  size.first
79
81
  end
@@ -56,6 +56,122 @@ module Vedeu
56
56
  it 'raises an exception when the value is out of bounds' do
57
57
  proc { interface.define { height 999 } }.must_raise(InvalidHeight)
58
58
  end
59
+
60
+ it 'allows the setting of colours' do
61
+ Interface.build do
62
+ colour foreground: '#aadd00', background: '#222222'
63
+ end.must_equal(
64
+ {
65
+ name: '',
66
+ group: '',
67
+ lines: [],
68
+ colour: {
69
+ foreground: "#aadd00",
70
+ background: "#222222"
71
+ },
72
+ style: "",
73
+ geometry: {},
74
+ cursor: true,
75
+ delay: 0.0
76
+ }
77
+ )
78
+ end
79
+
80
+ it 'allows the setting of styles' do
81
+ Interface.build do
82
+ style 'underline'
83
+ end.must_equal(
84
+ {
85
+ name: '',
86
+ group: '',
87
+ lines: [],
88
+ colour: {},
89
+ style: "underline",
90
+ geometry: {},
91
+ cursor: true,
92
+ delay: 0.0
93
+ }
94
+ )
95
+ end
96
+
97
+ it 'allows the use of other interfaces for attributes like geometry' do
98
+ IO.console.stub(:winsize, [25, 40]) do
99
+ Vedeu.interface 'my_interface' do
100
+ x 5
101
+ y 5
102
+ width 5
103
+ height 5
104
+ end
105
+ Interface.build do
106
+ name 'my_other_interface'
107
+ y use('my_interface').south
108
+ end.must_equal({
109
+ name: "my_other_interface",
110
+ group: "",
111
+ lines: [],
112
+ colour: {},
113
+ style: "",
114
+ geometry: {
115
+ y: 11
116
+ },
117
+ cursor: true,
118
+ delay: 0.0
119
+ })
120
+ end
121
+ end
122
+
123
+ it 'allows the setting of a delay for events triggered for this ' \
124
+ 'interface' do
125
+ Interface.build do
126
+ delay 1.0
127
+ end.must_equal(
128
+ {
129
+ name: '',
130
+ group: '',
131
+ lines: [],
132
+ colour: {},
133
+ style: "",
134
+ geometry: {},
135
+ cursor: true,
136
+ delay: 1.0
137
+ })
138
+ end
139
+
140
+ it 'allows the interface to be part of a group- useful for creating ' \
141
+ 'separate views' do
142
+ Interface.build do
143
+ group 'my_group'
144
+ end.must_equal(
145
+ {
146
+ name: "",
147
+ group: "my_group",
148
+ lines: [],
149
+ colour: {},
150
+ style: "",
151
+ geometry: {},
152
+ cursor: true,
153
+ delay: 0.0
154
+ }
155
+ )
156
+ end
157
+
158
+ it 'allows the setting of the cursor for the interface to be shown ' \
159
+ 'or hidden' do
160
+ Interface.build do
161
+ cursor false
162
+ end.must_equal(
163
+ {
164
+ name: "",
165
+ group: "",
166
+ lines: [],
167
+ colour: {},
168
+ style: "",
169
+ geometry: {},
170
+ cursor: false,
171
+ delay: 0.0
172
+ }
173
+ )
174
+ end
59
175
  end
60
176
 
61
177
  describe '#build' do
data/vedeu.gemspec CHANGED
@@ -4,10 +4,11 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = 'vedeu'
7
- spec.version = '0.1.14'
7
+ spec.version = '0.1.15'
8
8
  spec.authors = ['Gavin Laking']
9
9
  spec.email = ['gavinlaking@gmail.com']
10
10
  spec.summary = %q{A terminal case of wonderland.}
11
+ spec.description = %q{A GUI framework for terminal/console applications.}
11
12
  spec.homepage = 'https://github.com/gavinlaking/vedeu'
12
13
  spec.license = 'MIT'
13
14
 
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.1.14
4
+ version: 0.1.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gavin Laking
@@ -150,7 +150,7 @@ dependencies:
150
150
  - - '='
151
151
  - !ruby/object:Gem::Version
152
152
  version: 0.9.0
153
- description:
153
+ description: A GUI framework for terminal/console applications.
154
154
  email:
155
155
  - gavinlaking@gmail.com
156
156
  executables: