opn 1.0.57
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.
Potentially problematic release.
This version of opn might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/lib/opn/colours.rb +30 -0
- data/lib/opn/module.rb +338 -0
- data/lib/opn/opn.rb +19 -0
- data/lib/opn/version/version.rb +17 -0
- data/lib/opn.rb +5 -0
- data/opn.gemspec +71 -0
- data/test/testing_opn.rb +64 -0
- metadata +76 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b63622c6a25d4cdf9842e7c148b36bb21ff7811f9a9254c23430130bd4ca1e3d
|
4
|
+
data.tar.gz: e30204f1cb07c058f35923d63c7b506d3446c40f638da6aa259d07b642ec895c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0d4fa9ea9b77dbae41eeb3cd339b065fa684c244e46ffe6189cbc2680ea9deaa7dd864ed56ba25f825d4c7953de4839ea315e5991f1ec5c0e6b0d3e4d1a1a17d
|
7
|
+
data.tar.gz: 51a7bc5ab2fa10639c3b36646379aa077719f8ce285da958f76f2a414b1250aabc166948e84b46990d5efd4db1ac97115aa9b2ad236c1f04ef8f075083360f4a
|
data/lib/opn/colours.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
module Opn
|
6
|
+
|
7
|
+
# ========================================================================= #
|
8
|
+
# === @use_colours
|
9
|
+
#
|
10
|
+
# Whether to use colours.
|
11
|
+
# ========================================================================= #
|
12
|
+
@use_colours = true
|
13
|
+
|
14
|
+
# ========================================================================= #
|
15
|
+
# === Opn.use_colours?
|
16
|
+
# ========================================================================= #
|
17
|
+
def self.use_colours?
|
18
|
+
@use_colours
|
19
|
+
end
|
20
|
+
|
21
|
+
# ========================================================================= #
|
22
|
+
# === Opn.disable_colours
|
23
|
+
#
|
24
|
+
# We can disable colours too.
|
25
|
+
# ========================================================================= #
|
26
|
+
def self.disable_colours
|
27
|
+
@use_colours = false
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
data/lib/opn/module.rb
ADDED
@@ -0,0 +1,338 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
require 'opn/version/version.rb'
|
6
|
+
require 'opn/colours.rb'
|
7
|
+
|
8
|
+
module Opn
|
9
|
+
|
10
|
+
# ========================================================================= #
|
11
|
+
# === @be_verbose
|
12
|
+
#
|
13
|
+
# Whether we will be verbose or whether we will be not.
|
14
|
+
# ========================================================================= #
|
15
|
+
@be_verbose = true
|
16
|
+
|
17
|
+
# ========================================================================= #
|
18
|
+
# === Opn.be_verbose?
|
19
|
+
# ========================================================================= #
|
20
|
+
def self.be_verbose?
|
21
|
+
@be_verbose
|
22
|
+
end
|
23
|
+
|
24
|
+
# ========================================================================= #
|
25
|
+
# === Opn.namespace
|
26
|
+
#
|
27
|
+
# This is a simplified variant, if you just need the namespace.
|
28
|
+
#
|
29
|
+
# If you need more flexibility, then use Opn.opn() directly - it will
|
30
|
+
# support more arguments.
|
31
|
+
# ========================================================================= #
|
32
|
+
def self.namespace(
|
33
|
+
input, optional_extra_arguments = nil
|
34
|
+
)
|
35
|
+
Opn.opn(namespace: input) { optional_extra_arguments }
|
36
|
+
end
|
37
|
+
|
38
|
+
# ========================================================================= #
|
39
|
+
# === Opn.opn
|
40
|
+
#
|
41
|
+
# This is the main method of this project.
|
42
|
+
#
|
43
|
+
# If we wish to be silent or set other options, we can do this:
|
44
|
+
#
|
45
|
+
# Opn.opn :be_silent
|
46
|
+
# Opn.opn :no_newline
|
47
|
+
# Opn.opn :no_colours
|
48
|
+
# Opn.opn(namespace: 'YoThere')
|
49
|
+
# Opn.opn(namespace: '→')
|
50
|
+
# Opn.opn(namespace: 'YoThere', be_verbose: false)
|
51
|
+
#
|
52
|
+
# Since as of September 2017, we can also pad the output if a key called
|
53
|
+
# :padding is passed. The argument should be like this:
|
54
|
+
#
|
55
|
+
# padding: 18
|
56
|
+
#
|
57
|
+
# This means to use up to 18 characters, padding via ' '.
|
58
|
+
# ========================================================================= #
|
59
|
+
def self.opn(
|
60
|
+
use_colours = Opn.use_colours?,
|
61
|
+
be_verbose = be_verbose?,
|
62
|
+
use_this_as_namespace = ''
|
63
|
+
)
|
64
|
+
# ======================================================================= #
|
65
|
+
# === Default values
|
66
|
+
#
|
67
|
+
# First, some default variables for intrinsic behaviour of this method.
|
68
|
+
# ======================================================================= #
|
69
|
+
shall_we_append_a_colon_character = true # By default, we append ':'.
|
70
|
+
append_newline = false
|
71
|
+
use_padding = false
|
72
|
+
may_we_display_anything = true # If true then we will show output.
|
73
|
+
# ======================================================================= #
|
74
|
+
# Hardcoded colours follow next.
|
75
|
+
# ======================================================================= #
|
76
|
+
grey = "\e[1;30m"
|
77
|
+
green = "\e[0;32m"
|
78
|
+
# ======================================================================= #
|
79
|
+
# Next keep a link towards the colour that we will use.
|
80
|
+
# ======================================================================= #
|
81
|
+
use_this_colour = grey
|
82
|
+
reset_terminal = "\e[0;37m"
|
83
|
+
|
84
|
+
# ======================================================================= #
|
85
|
+
# Work on the first argument given to this method next:
|
86
|
+
# ======================================================================= #
|
87
|
+
case use_colours
|
88
|
+
when :default
|
89
|
+
use_colours = Opn.use_colours?
|
90
|
+
when :use_colours
|
91
|
+
use_colours = true
|
92
|
+
when :no_colours
|
93
|
+
use_colours = false
|
94
|
+
be_verbose = be_verbose?
|
95
|
+
when :no_newline # This is the default anyway.
|
96
|
+
when :newline
|
97
|
+
append_newline = true
|
98
|
+
when :be_silent, :be_quiet
|
99
|
+
use_colours = @use_colours # This is the default. We restore it here.
|
100
|
+
be_verbose = false
|
101
|
+
when :be_verbose
|
102
|
+
use_colours = Opn.use_colours?
|
103
|
+
be_verbose = be_verbose?
|
104
|
+
end
|
105
|
+
case be_verbose
|
106
|
+
when nil
|
107
|
+
be_verbose = be_verbose?
|
108
|
+
when :be_quiet
|
109
|
+
be_verbose = false
|
110
|
+
end
|
111
|
+
# ======================================================================= #
|
112
|
+
# use_this_as_namespace = File.basename(__FILE__) # Could use this here.
|
113
|
+
# use_this_as_namespace = caller[0]
|
114
|
+
# ======================================================================= #
|
115
|
+
the_caller = caller
|
116
|
+
if use_this_as_namespace.empty? # This is the default case then.
|
117
|
+
if the_caller.size > 1
|
118
|
+
use_this_as_namespace = the_caller[1]
|
119
|
+
else
|
120
|
+
use_this_as_namespace = the_caller.first
|
121
|
+
end
|
122
|
+
end
|
123
|
+
# ======================================================================= #
|
124
|
+
# === use_colours
|
125
|
+
#
|
126
|
+
# Next, we will handle the case when use_colours is a Hash. This may
|
127
|
+
# quite often be the case, as a Hash is more flexible than most other
|
128
|
+
# "types" in Ruby.
|
129
|
+
#
|
130
|
+
# This can be used for e. g. namespace: 'RBT::Compile'
|
131
|
+
# ======================================================================= #
|
132
|
+
if use_colours.is_a? Hash
|
133
|
+
copy = use_colours.dup # Keep a reference copy here.
|
134
|
+
# =================================================================== #
|
135
|
+
# === :append_colon
|
136
|
+
# =================================================================== #
|
137
|
+
if use_colours.has_key? :append_colon
|
138
|
+
shall_we_append_a_colon_character = use_colours.delete(:append_colon)
|
139
|
+
end
|
140
|
+
if use_colours.has_key? :use_this_as_namespace
|
141
|
+
use_this_as_namespace = use_colours.fetch(:use_this_as_namespace)
|
142
|
+
elsif use_colours.has_key? :use_this_namespace
|
143
|
+
use_this_as_namespace = use_colours.fetch(:use_this_namespace)
|
144
|
+
elsif use_colours.has_key? :namespace
|
145
|
+
use_this_as_namespace = use_colours.fetch(:namespace)
|
146
|
+
end
|
147
|
+
if use_colours.has_key? :use_opn
|
148
|
+
may_we_display_anything = use_colours.fetch(:use_opn)
|
149
|
+
end
|
150
|
+
if use_colours.has_key? :be_verbose
|
151
|
+
be_verbose = use_colours.delete(:be_verbose)
|
152
|
+
end
|
153
|
+
use_colours = true # Restore the default again here, since it was a Hash before.
|
154
|
+
# ===================================================================== #
|
155
|
+
# Check for more keys though:
|
156
|
+
# ===================================================================== #
|
157
|
+
if copy.has_key? :use_colours
|
158
|
+
use_colours = copy.delete(:use_colours)
|
159
|
+
end
|
160
|
+
# ===================================================================== #
|
161
|
+
# === :trailing_colon
|
162
|
+
# ===================================================================== #
|
163
|
+
if copy.has_key? :trailing_colon
|
164
|
+
shall_we_append_a_colon_character = copy.delete(:trailing_colon)
|
165
|
+
# ===================================================================== #
|
166
|
+
# === :no_trailing
|
167
|
+
# ===================================================================== #
|
168
|
+
elsif copy.has_key? :no_trailing
|
169
|
+
shall_we_append_a_colon_character = copy.delete(:no_trailing)
|
170
|
+
end
|
171
|
+
# ===================================================================== #
|
172
|
+
# === Check for :padding value
|
173
|
+
# ===================================================================== #
|
174
|
+
if copy.has_key? :padding
|
175
|
+
use_padding = true
|
176
|
+
use_this_padding = copy.delete(:padding).to_i # Must be an Integer.
|
177
|
+
end
|
178
|
+
end
|
179
|
+
# ======================================================================= #
|
180
|
+
# Check for Hash as namespace.
|
181
|
+
# ======================================================================= #
|
182
|
+
if use_this_as_namespace.is_a?(Hash) and
|
183
|
+
use_this_as_namespace.has_key?(:namespace)
|
184
|
+
use_this_as_namespace = use_this_as_namespace.delete(:namespace)
|
185
|
+
end
|
186
|
+
# ======================================================================= #
|
187
|
+
# Next we split on the namespace, but this may be problematic when
|
188
|
+
# our input contains more than one ':' such as 'RBT::Compile'.
|
189
|
+
# In this case, we assume that the user is smarter than we are,
|
190
|
+
# and we will NOT split on such input provided.
|
191
|
+
# ======================================================================= #
|
192
|
+
if use_this_as_namespace.is_a? String
|
193
|
+
unless use_this_as_namespace.include? '::' # ^^^ See above for the explanation.
|
194
|
+
use_this_as_namespace = File.basename(use_this_as_namespace.split(':').first)
|
195
|
+
end
|
196
|
+
if use_this_as_namespace.include? '_' # Assume Camelcase provided here.
|
197
|
+
use_this_as_namespace = use_this_as_namespace.split('_').map(&:capitalize).join
|
198
|
+
else # Else upcase the first argument always.
|
199
|
+
if use_this_as_namespace.frozen?
|
200
|
+
use_this_as_namespace = use_this_as_namespace.dup
|
201
|
+
end
|
202
|
+
use_this_as_namespace[0,1] = use_this_as_namespace[0,1].upcase
|
203
|
+
end
|
204
|
+
# ======================================================================= #
|
205
|
+
# Do some sanitizing next, by getting rid of .rb entries.
|
206
|
+
# ======================================================================= #
|
207
|
+
use_this_as_namespace = use_this_as_namespace.sub(/\.rb/,'')
|
208
|
+
end
|
209
|
+
# ======================================================================= #
|
210
|
+
# Handle blocks next.
|
211
|
+
# ======================================================================= #
|
212
|
+
if block_given?
|
213
|
+
yielded = yield
|
214
|
+
case yielded
|
215
|
+
when :no_trailing_colon,
|
216
|
+
:no_trailing_character,
|
217
|
+
:no_trailing_char,
|
218
|
+
:no_trailing,
|
219
|
+
:no_colon,
|
220
|
+
:no_semicolon,
|
221
|
+
:short
|
222
|
+
shall_we_append_a_colon_character = false
|
223
|
+
when :show_only_the_name_of_the_class, :display_only_last_name
|
224
|
+
# =================================================================== #
|
225
|
+
# In this case, show only the name of the main class. But only
|
226
|
+
# if the namespace includes a '::'.
|
227
|
+
# =================================================================== #
|
228
|
+
if use_this_as_namespace.include? '::'
|
229
|
+
use_this_as_namespace = use_this_as_namespace.split('::').last
|
230
|
+
end
|
231
|
+
# ===================================================================== #
|
232
|
+
# === :no_colours
|
233
|
+
# ===================================================================== #
|
234
|
+
when :no_colours, :disable_colours
|
235
|
+
Opn.disable_colours
|
236
|
+
# ===================================================================== #
|
237
|
+
# Next, we ought to handle Hashes passed to this method via a block.
|
238
|
+
# ===================================================================== #
|
239
|
+
when Hash
|
240
|
+
# =================================================================== #
|
241
|
+
# === :append_colon
|
242
|
+
# =================================================================== #
|
243
|
+
if yielded.has_key? :append_colon
|
244
|
+
shall_we_append_a_colon_character = yielded.delete(:append_colon)
|
245
|
+
end
|
246
|
+
if yielded.has_key?(:use_this_as_namespace)
|
247
|
+
use_this_as_namespace = yielded.delete :use_this_as_namespace
|
248
|
+
elsif yielded.has_key?(:use_this_namespace)
|
249
|
+
use_this_as_namespace = yielded.delete :use_this_namespace
|
250
|
+
elsif yielded.has_key?(:namespace)
|
251
|
+
use_this_as_namespace = yielded.delete :namespace
|
252
|
+
elsif yielded.has_key?(:trailing_colon)
|
253
|
+
shall_we_append_a_colon_character = yielded.delete(:trailing_colon)
|
254
|
+
elsif yielded.has_key?(:use_colours)
|
255
|
+
use_colours = yielded.delete(:use_colours)
|
256
|
+
end
|
257
|
+
if yielded.has_key? :use_this_colour
|
258
|
+
use_this_colour = return_escape_sequence_for_this_colour(
|
259
|
+
yielded[:use_this_colour]
|
260
|
+
)
|
261
|
+
end
|
262
|
+
end
|
263
|
+
end
|
264
|
+
_ = ''.dup
|
265
|
+
if use_colours
|
266
|
+
_ << use_this_colour
|
267
|
+
end
|
268
|
+
# ======================================================================= #
|
269
|
+
# Determine whether we shall append a colon character next:
|
270
|
+
# ======================================================================= #
|
271
|
+
if shall_we_append_a_colon_character
|
272
|
+
unless use_this_as_namespace.end_with? '→' # The → is a general exception.
|
273
|
+
use_this_as_namespace << ':'
|
274
|
+
end
|
275
|
+
end
|
276
|
+
use_this_as_namespace << ' ' if use_this_as_namespace.end_with? ':'
|
277
|
+
# ======================================================================= #
|
278
|
+
# Honour padding-operations onto the main Namespace next.
|
279
|
+
# ======================================================================= #
|
280
|
+
if use_padding
|
281
|
+
use_this_as_namespace = use_this_as_namespace.ljust(use_this_padding)
|
282
|
+
end
|
283
|
+
# ======================================================================= #
|
284
|
+
# Add the separator here.
|
285
|
+
# ======================================================================= #
|
286
|
+
_ << use_this_as_namespace
|
287
|
+
_ << green+reset_terminal if use_colours
|
288
|
+
_ << "\n" if append_newline
|
289
|
+
if may_we_display_anything
|
290
|
+
print _ if be_verbose
|
291
|
+
end
|
292
|
+
return _
|
293
|
+
end
|
294
|
+
|
295
|
+
# ========================================================================= #
|
296
|
+
# === Opn.opne
|
297
|
+
#
|
298
|
+
# To test this, do:
|
299
|
+
# Opn.opne 'Hello world!'
|
300
|
+
# ========================================================================= #
|
301
|
+
def self.opne(i = '')
|
302
|
+
Opn.opn
|
303
|
+
puts i
|
304
|
+
end
|
305
|
+
|
306
|
+
# ========================================================================= #
|
307
|
+
# === opne
|
308
|
+
# ========================================================================= #
|
309
|
+
def opne(i = '')
|
310
|
+
Opn.opne(i)
|
311
|
+
end
|
312
|
+
|
313
|
+
# ========================================================================= #
|
314
|
+
# === Opn.return_escape_sequence_for_this_colour
|
315
|
+
#
|
316
|
+
# This method can return the proper colour code.
|
317
|
+
# ========================================================================= #
|
318
|
+
def self.return_escape_sequence_for_this_colour(
|
319
|
+
i = :green
|
320
|
+
)
|
321
|
+
i = i.to_sym
|
322
|
+
case i
|
323
|
+
when :grey
|
324
|
+
i = "\e[0;30m"
|
325
|
+
when :green
|
326
|
+
i = "\e[0;32m"
|
327
|
+
end
|
328
|
+
i
|
329
|
+
end
|
330
|
+
|
331
|
+
# ========================================================================= #
|
332
|
+
# === Opn.cadetblue
|
333
|
+
# ========================================================================= #
|
334
|
+
def self.cadetblue(i)
|
335
|
+
"\e[38;2;70;130;180m#{i}\e[0;37m"
|
336
|
+
end
|
337
|
+
|
338
|
+
end
|
data/lib/opn/opn.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
require 'opn/module.rb'
|
6
|
+
|
7
|
+
# =========================================================================== #
|
8
|
+
# === opn (opn tag)
|
9
|
+
#
|
10
|
+
# This method will give the name of this script, with (optionally)
|
11
|
+
# colours.
|
12
|
+
# =========================================================================== #
|
13
|
+
def opn(
|
14
|
+
use_colours = :default,
|
15
|
+
be_verbose = true,
|
16
|
+
namespace = ''
|
17
|
+
)
|
18
|
+
Opn.opn(use_colours, be_verbose, namespace)
|
19
|
+
end; alias output_program_name opn # === output_program_name
|
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
module Opn
|
6
|
+
|
7
|
+
# ========================================================================= #
|
8
|
+
# === VERSION
|
9
|
+
# ========================================================================= #
|
10
|
+
VERSION = '1.0.57'
|
11
|
+
|
12
|
+
# ========================================================================= #
|
13
|
+
# === LAST_UPDATE
|
14
|
+
# ========================================================================= #
|
15
|
+
LAST_UPDATE = '15.08.2021'
|
16
|
+
|
17
|
+
end
|
data/lib/opn.rb
ADDED
data/opn.gemspec
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
# =========================================================================== #
|
2
|
+
# Gemspec for Project Opn.
|
3
|
+
# =========================================================================== #
|
4
|
+
require 'opn/version/version.rb'
|
5
|
+
require 'roebe/toplevel_methods/misc.rb'
|
6
|
+
require 'roebe'
|
7
|
+
|
8
|
+
Gem::Specification.new { |s|
|
9
|
+
|
10
|
+
s.name = 'opn'
|
11
|
+
s.version = Opn::VERSION
|
12
|
+
s.date = Time.now.strftime('%Y-%m-%d')
|
13
|
+
|
14
|
+
s.summary = <<-EOF
|
15
|
+
|
16
|
+
This library is called opn. It will simply output the
|
17
|
+
name of the class. Optionally, you can assign another
|
18
|
+
namespace to report with. For an explanation, just
|
19
|
+
look at the few examples under the test/ directory.
|
20
|
+
|
21
|
+
Why did I write it?
|
22
|
+
|
23
|
+
I wrote many different ruby classes, and sometimes they will
|
24
|
+
report information to me, but I don't know which file wrote
|
25
|
+
this. So I wanted to simply have output prefaced with the
|
26
|
+
name of the class in question, optionally to be colourized
|
27
|
+
as well, since that helps me on the commandline.
|
28
|
+
|
29
|
+
The name "opn" stands for "output program name".
|
30
|
+
|
31
|
+
Version 1.0.2 now has a proper module, called Opn,
|
32
|
+
and Opn has only one method called opn().
|
33
|
+
|
34
|
+
|
35
|
+
EOF
|
36
|
+
|
37
|
+
s.description = <<-EOF
|
38
|
+
|
39
|
+
This library is called opn. It will simply output the
|
40
|
+
name of the class. Optionally, you can assign another
|
41
|
+
namespace to report with. For an explanation, just
|
42
|
+
look at the few examples under the test/ directory.
|
43
|
+
|
44
|
+
Why did I write it?
|
45
|
+
|
46
|
+
I wrote many different ruby classes, and sometimes they will
|
47
|
+
report information to me, but I don't know which file wrote
|
48
|
+
this. So I wanted to simply have output prefaced with the
|
49
|
+
name of the class in question, optionally to be colourized
|
50
|
+
as well, since that helps me on the commandline.
|
51
|
+
|
52
|
+
The name "opn" stands for "output program name".
|
53
|
+
|
54
|
+
Version 1.0.2 now has a proper module, called Opn,
|
55
|
+
and Opn has only one method called opn().
|
56
|
+
|
57
|
+
EOF
|
58
|
+
require 'roebe'
|
59
|
+
s.extra_rdoc_files = %w()
|
60
|
+
|
61
|
+
s.authors = ['Robert A. Heiler']
|
62
|
+
s.email = Roebe.email?
|
63
|
+
s.files = Dir['**/*']
|
64
|
+
s.license = 'MIT'
|
65
|
+
s.homepage = 'https://rubygems.org/gems/opn'
|
66
|
+
|
67
|
+
s.required_ruby_version = '>= '+Roebe.third_most_stable_version_of_ruby
|
68
|
+
s.required_rubygems_version = '>= '+Gem::VERSION
|
69
|
+
s.rubygems_version = '>= '+Gem::VERSION
|
70
|
+
|
71
|
+
}
|
data/test/testing_opn.rb
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# =========================================================================== #
|
4
|
+
require 'colour_e/autoinclude'
|
5
|
+
require 'opn/module'
|
6
|
+
require 'cliner'
|
7
|
+
|
8
|
+
NAMESPACE = inspect
|
9
|
+
|
10
|
+
# =========================================================================== #
|
11
|
+
# === palegoldenrod
|
12
|
+
# =========================================================================== #
|
13
|
+
def palegoldenrod(i)
|
14
|
+
::Colours.palegoldenrod(i)
|
15
|
+
end
|
16
|
+
MAIN_NAMESPACE = { namespace: 'RBT::Compile' }
|
17
|
+
e ::Colours.slateblue('Seven (7)')+' examples for Opn.opn will come next -'
|
18
|
+
e 'and one example for Opn.namespace():'
|
19
|
+
cliner
|
20
|
+
e "(1) First, we test "+palegoldenrod("Opn.opn(namespace: 'YoThere')")
|
21
|
+
Opn.opn(namespace: 'YoThere'); e
|
22
|
+
cliner
|
23
|
+
e '(2) Next, we test '+palegoldenrod('Opn.opn(:no_colours)')
|
24
|
+
Opn.opn(:no_colours); e
|
25
|
+
cliner
|
26
|
+
e '(3) Next, we test '+palegoldenrod('Opn.opn')
|
27
|
+
Opn.opn; e
|
28
|
+
cliner
|
29
|
+
e '(4) Next, we test '+palegoldenrod('Opn.opn(use_colours: false)')
|
30
|
+
Opn.opn(use_colours: false); e
|
31
|
+
cliner
|
32
|
+
e '(5) Next, we test '+palegoldenrod('Opn.opn(MAIN_NAMESPACE)')+' - 4 times in total'
|
33
|
+
Opn.opn(MAIN_NAMESPACE); e
|
34
|
+
cliner
|
35
|
+
Opn.opn(MAIN_NAMESPACE); e
|
36
|
+
Opn.opn(MAIN_NAMESPACE); e
|
37
|
+
Opn.opn(MAIN_NAMESPACE); e
|
38
|
+
cliner
|
39
|
+
e '(6) Next, we will use the main namespace again but without '\
|
40
|
+
'colours.'
|
41
|
+
e ' So: '+palegoldenrod('Opn.opn(namespace: MAIN_NAMESPACE, use_colours: false)')
|
42
|
+
Opn.opn(namespace: MAIN_NAMESPACE, use_colours: false); e
|
43
|
+
cliner
|
44
|
+
e '(7) Next, testing '+palegoldenrod('Opn.namespace NAMESPACE')
|
45
|
+
Opn.namespace NAMESPACE; e
|
46
|
+
cliner
|
47
|
+
e '(8) Next, testing '+palegoldenrod('Opn.namespace("→")')
|
48
|
+
Opn.namespace('→'); e 'Hello there!'
|
49
|
+
cliner
|
50
|
+
e '(9) Next, testing '+palegoldenrod('Opn.namespace("John→Doe")')
|
51
|
+
Opn.namespace('John→Doe'); e 'Hello there!'
|
52
|
+
cliner
|
53
|
+
e '(10) Next, testing '+palegoldenrod('Opn.opn(padding: 18)')
|
54
|
+
Opn.opn(padding: 18); e 'Hello there!'
|
55
|
+
Opn.opn(padding: 12); e 'Hello there!'
|
56
|
+
Opn.opn(padding: 22); e 'Hello there!'
|
57
|
+
cliner
|
58
|
+
e '(11) Next, testing '+palegoldenrod('Opn.opn({:namespace=>"RBT::CreateAppDirSkeleton", :use_colours=>true, :use_opn=>false})')
|
59
|
+
Opn.opn(
|
60
|
+
{:namespace=>"RBT::CreateProgram", :use_colours=>true, :use_opn=>false}
|
61
|
+
)
|
62
|
+
cliner
|
63
|
+
e '(12) Next testing '+palegoldenrod('Opn.opn {{ use_this_colour: :green }}')+':'
|
64
|
+
Opn.opn {{ use_this_colour: :green }}; e
|
metadata
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: opn
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.57
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Robert A. Heiler
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-08-15 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: |2+
|
14
|
+
|
15
|
+
This library is called opn. It will simply output the
|
16
|
+
name of the class. Optionally, you can assign another
|
17
|
+
namespace to report with. For an explanation, just
|
18
|
+
look at the few examples under the test/ directory.
|
19
|
+
|
20
|
+
Why did I write it?
|
21
|
+
|
22
|
+
I wrote many different ruby classes, and sometimes they will
|
23
|
+
report information to me, but I don't know which file wrote
|
24
|
+
this. So I wanted to simply have output prefaced with the
|
25
|
+
name of the class in question, optionally to be colourized
|
26
|
+
as well, since that helps me on the commandline.
|
27
|
+
|
28
|
+
The name "opn" stands for "output program name".
|
29
|
+
|
30
|
+
Version 1.0.2 now has a proper module, called Opn,
|
31
|
+
and Opn has only one method called opn().
|
32
|
+
|
33
|
+
email: shevy@inbox.lt
|
34
|
+
executables: []
|
35
|
+
extensions: []
|
36
|
+
extra_rdoc_files: []
|
37
|
+
files:
|
38
|
+
- lib/opn.rb
|
39
|
+
- lib/opn/colours.rb
|
40
|
+
- lib/opn/module.rb
|
41
|
+
- lib/opn/opn.rb
|
42
|
+
- lib/opn/version/version.rb
|
43
|
+
- opn.gemspec
|
44
|
+
- test/testing_opn.rb
|
45
|
+
homepage: https://rubygems.org/gems/opn
|
46
|
+
licenses:
|
47
|
+
- MIT
|
48
|
+
metadata: {}
|
49
|
+
post_install_message:
|
50
|
+
rdoc_options: []
|
51
|
+
require_paths:
|
52
|
+
- lib
|
53
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: 2.5.8
|
58
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 3.2.24
|
63
|
+
requirements: []
|
64
|
+
rubygems_version: 3.2.24
|
65
|
+
signing_key:
|
66
|
+
specification_version: 4
|
67
|
+
summary: This library is called opn. It will simply output the name of the class.
|
68
|
+
Optionally, you can assign another namespace to report with. For an explanation,
|
69
|
+
just look at the few examples under the test/ directory. Why did I write it? I
|
70
|
+
wrote many different ruby classes, and sometimes they will report information to
|
71
|
+
me, but I don't know which file wrote this. So I wanted to simply have output prefaced
|
72
|
+
with the name of the class in question, optionally to be colourized as well, since
|
73
|
+
that helps me on the commandline. The name "opn" stands for "output program name". Version
|
74
|
+
1.0.2 now has a proper module, called Opn, and Opn has only one method called opn().
|
75
|
+
test_files: []
|
76
|
+
...
|