cliner 1.0.33

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 6e0b4d55ee5124b9949be326d7f0ee90a43452403704e94038a76164bef0dad5
4
+ data.tar.gz: 2e72d6ced8308d32cce443734ac1a50e9582d59807339b554f32dd2c4d4ca6e2
5
+ SHA512:
6
+ metadata.gz: a7b4515c3e489b999845d795c71c1102a7ad91f680b11a1874e410f878db75d5ed5bc64616d35c302ab3b1c35b98d8d481731b2e26d42ef96489bd019d737dc2
7
+ data.tar.gz: 8045f631e8561fa5b9d5154e11939bd4af5cf4b47672dc13cfc7f2a29f0401d0ef4329ebddbafadd2d496919335a04a4422466cba7f159e46d4f879eb2ef0605
data/README.md ADDED
@@ -0,0 +1,18 @@
1
+ [![forthebadge](https://forthebadge.com/images/badges/built-with-love.svg)](https://www.gobolinux.org/)
2
+ [![forthebadge](https://forthebadge.com/images/badges/made-with-ruby.svg)](https://www.ruby-lang.org/en/)
3
+ [![Gem Version](https://badge.fury.io/rb/cliner.svg)](https://badge.fury.io/rb/cliner)
4
+
5
+ ## The cliner project
6
+
7
+ This project is really small - it will just display a horizontal line.
8
+
9
+ The primary use case is to display this line for commandline applications.
10
+
11
+ This line can be colourized. You can also show the current time format,
12
+ e. g. in hh:mm:ss format.
13
+
14
+ Examples:
15
+
16
+ Cliner.cliner :show_time
17
+ string = Cliner.cliner :show_time, :default, :default, :return_as_string
18
+
data/bin/cliner ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ require 'cliner/module.rb'
6
+
7
+ Cliner[]
data/cliner.gemspec ADDED
@@ -0,0 +1,46 @@
1
+ # =========================================================================== #
2
+ # Gemspec for Project Cliner.
3
+ # =========================================================================== #
4
+ require 'cliner/version/version.rb'
5
+ require 'roebe'
6
+
7
+ Gem::Specification.new { |s|
8
+
9
+ s.name = 'cliner'
10
+ s.version = Cliner::VERSION
11
+ s.date = Time.now.strftime('%Y-%m-%d')
12
+
13
+ DESCRIPTION = <<-EOF
14
+
15
+ This small gem just provides one method called
16
+ cliner.
17
+
18
+ cliner means "colourized liner", and it basically
19
+ only makes a coloured line. Yes, that's it. :D
20
+
21
+ May not seem useful for anyone else at all, but
22
+ I found that I often need to use it. Use cases
23
+ include passing in a Hash such as via:
24
+
25
+ cliner token: 'X'
26
+
27
+ For more documentation please see the homepage
28
+ of this gem.
29
+
30
+ EOF
31
+
32
+ s.summary = DESCRIPTION
33
+ s.description = DESCRIPTION
34
+
35
+ s.authors = ['Robert A. Heiler']
36
+ s.email = Roebe.email?
37
+ s.files = Dir['**/*']
38
+ s.homepage = 'https://rubygems.org/gems/cliner'
39
+ s.licenses = 'MIT'
40
+ s.executables = Dir['bin/*'].map { |f| File.basename(f) }
41
+
42
+ s.required_ruby_version = '>= '+Roebe.third_most_stable_version_of_ruby
43
+ s.required_rubygems_version = '>= '+Gem::VERSION
44
+ s.rubygems_version = '>= '+Gem::VERSION
45
+
46
+ }
data/doc/README.gen ADDED
@@ -0,0 +1,16 @@
1
+ ADD_RUBY_BADGE
2
+
3
+ ## The cliner project
4
+
5
+ This project is really small - it will just display a horizontal line.
6
+
7
+ The primary use case is to display this line for commandline applications.
8
+
9
+ This line can be colourized. You can also show the current time format,
10
+ e. g. in hh:mm:ss format.
11
+
12
+ Examples:
13
+
14
+ Cliner.cliner :show_time
15
+ string = Cliner.cliner :show_time, :default, :default, :return_as_string
16
+
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ require 'cliner/module.rb' # Pull in the main Cliner-module here.
6
+
7
+ include Cliner
@@ -0,0 +1,228 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ module Cliner
6
+
7
+ require 'cliner/colours.rb'
8
+ require 'cliner/token.rb'
9
+ require 'cliner/time.rb'
10
+
11
+ # ========================================================================= #
12
+ # === Cliner.cliner
13
+ #
14
+ # This method will output a line.
15
+ #
16
+ # The third argument is optional - we can use a specific colour with it.
17
+ #
18
+ # Usage examples:
19
+ #
20
+ # Cliner.cliner '','',BLUE
21
+ # Cliner.cliner token: 'X'
22
+ # Cliner.cliner :show_time
23
+ # Cliner.cliner :show_time, :default, :default, :return_as_string
24
+ # Cliner.cliner colour: :green
25
+ # Cliner.cliner use_colour: :dodgerblue
26
+ # Cliner.cliner use_colour: :konsole_dodgerblue
27
+ # Cliner.cliner(:show_time) { use_n_tokens: 30 }
28
+ #
29
+ # ========================================================================= #
30
+ def self.cliner(
31
+ which_token_to_use = Cliner.token?,
32
+ how_often_to_use_that_token = :default,
33
+ # ===================================================================== #
34
+ # The following is a bit hard to understand, so let's break it down.
35
+ # We need to first query whether the constant Cliner is defined.
36
+ # If it is, we can tap into a module method, but if it is not,
37
+ # we have to default to nil.
38
+ # ===================================================================== #
39
+ use_colour = (
40
+ (Object.const_defined? :Cliner) ? Cliner.use_colours? : nil
41
+ ),
42
+ output_the_result = true # <- Whether to output the result.
43
+ )
44
+ show_time = false # Default.
45
+ case use_colour
46
+ # ======================================================================= #
47
+ # === :default
48
+ # ======================================================================= #
49
+ when :default
50
+ use_colour = (Object.const_defined? :Cliner) ? Cliner.use_colours? : nil
51
+ end
52
+ case output_the_result
53
+ when :return_as_string
54
+ output_the_result = false
55
+ end
56
+ case which_token_to_use
57
+ # ======================================================================= #
58
+ # === :show_time
59
+ # ======================================================================= #
60
+ when :show_time
61
+ which_token_to_use = Cliner.token?
62
+ show_time = true
63
+ # ======================================================================= #
64
+ # === :return_time
65
+ # ======================================================================= #
66
+ when :return_time
67
+ which_token_to_use = Cliner.token?
68
+ show_time = true
69
+ output_the_result = false
70
+ when :default
71
+ which_token_to_use = Cliner.token?
72
+ end
73
+ default_token = Cliner.token?
74
+ append = ''.dup
75
+ case how_often_to_use_that_token
76
+ # ======================================================================= #
77
+ # === :default
78
+ # ======================================================================= #
79
+ when :default
80
+ how_often_to_use_that_token = 80
81
+ end
82
+ if how_often_to_use_that_token.to_s.empty?
83
+ how_often_to_use_that_token = 80
84
+ end
85
+ # ======================================================================= #
86
+ # === Hash input for which_token_to_use
87
+ #
88
+ # Check if we use a hash for the variable which_token_to_use next.
89
+ # ======================================================================= #
90
+ if which_token_to_use.is_a? Hash
91
+ # ===================================================================== #
92
+ # === :colour
93
+ # ===================================================================== #
94
+ if which_token_to_use.has_key? :colour
95
+ use_colour = which_token_to_use.delete :colour
96
+ elsif which_token_to_use.has_key? :colours
97
+ use_colour = which_token_to_use.delete :colours
98
+ elsif which_token_to_use.has_key? :use_colour
99
+ use_colour = which_token_to_use.delete :use_colour
100
+ end
101
+ # ===================================================================== #
102
+ # === :length
103
+ # ===================================================================== #
104
+ if which_token_to_use.has_key? :length
105
+ how_often_to_use_that_token = which_token_to_use.delete(:length)
106
+ which_token_to_use = default_token
107
+ elsif which_token_to_use.has_key? :token
108
+ which_token_to_use = which_token_to_use[:token]
109
+ # ===================================================================== #
110
+ # === :use_this_token
111
+ # ===================================================================== #
112
+ elsif which_token_to_use.has_key? :use_this_token
113
+ which_token_to_use = which_token_to_use[:use_this_token]
114
+ else
115
+ which_token_to_use = Cliner.token? # Default value. Reassign it here.
116
+ end
117
+ end
118
+ # ======================================================================= #
119
+ # === Handle colours given as the first argument
120
+ # ======================================================================= #
121
+ if which_token_to_use.is_a? Symbol
122
+ use_colour = which_token_to_use
123
+ which_token_to_use = Cliner.token?
124
+ end
125
+ if which_token_to_use.to_s.empty?
126
+ which_token_to_use = Cliner.token?
127
+ end
128
+ how_often_to_use_that_token = how_often_to_use_that_token.to_i
129
+ result = ''.dup
130
+ case use_colour # case tag
131
+ when :do_not_use_colours
132
+ use_colour = false
133
+ end
134
+ # ======================================================================= #
135
+ # === Handle colours next
136
+ # ======================================================================= #
137
+ if use_colour and !use_colour.is_a?(TrueClass) # Must not be the boolean "true".
138
+ # ===================================================================== #
139
+ # === Handle symbols
140
+ # ===================================================================== #
141
+ if use_colour.is_a? Symbol # If it is a symbol, convert it.
142
+ if use_colour.to_s.start_with? 'konsole_' # For instance, :konsole_slateblue
143
+ # ================================================================= #
144
+ # === Handle konsole colours next
145
+ # ================================================================= #
146
+ _ = use_colour.to_s.sub(/^konsole_/,'')
147
+ use_colour = ::Colours.send(_.to_sym) if Object.const_defined? :Colours
148
+ else
149
+ use_colour = Colours.send(use_colour.to_sym) { :omit_end }
150
+ end
151
+ # ===================================================================== #
152
+ # === Is it a valid colour?
153
+ # ===================================================================== #
154
+ elsif Colours.is_a_valid_colour?(use_colour)
155
+ use_colour = Colours.beautiful(use_colour)
156
+ end
157
+ result = result.dup if result.frozen? # Unfreeze the String.
158
+ result << use_colour.to_s # Append the colour.
159
+ append << Colours.rev
160
+ end
161
+ if result.frozen?
162
+ result = result.dup
163
+ end
164
+ # ======================================================================= #
165
+ # Handle show_time next:
166
+ # ======================================================================= #
167
+ if show_time
168
+ _ = return_hhmmss
169
+ how_often_to_use_that_token -= (_.size + 3)
170
+ end
171
+ result << which_token_to_use * how_often_to_use_that_token # The latter must be an Integer at all times.
172
+ if show_time
173
+ # ===================================================================== #
174
+ # We have to pad the resulting string a little bit:
175
+ # ===================================================================== #
176
+ result[3,0] = " #{_} "
177
+ end
178
+ result << append
179
+ if output_the_result
180
+ if respond_to? :e
181
+ e result
182
+ else
183
+ puts result
184
+ end
185
+ else # Else return it.
186
+ return result
187
+ end
188
+ if block_given?
189
+ yield
190
+ cliner(
191
+ which_token_to_use,
192
+ how_often_to_use_that_token,
193
+ use_colour
194
+ )
195
+ end
196
+ end
197
+
198
+ end
199
+
200
+ # =========================================================================== #
201
+ # === cliner
202
+ #
203
+ # Usage examples:
204
+ #
205
+ # cliner '','',BLUE
206
+ # cliner :token => 'X'
207
+ # cliner :colour => :green
208
+ # cliner use_colour: :dodgerblue
209
+ # cliner use_colour: :seagreen
210
+ # cliner use_colour: :konsole_dodgerblue
211
+ #
212
+ # =========================================================================== #
213
+ def cliner(
214
+ which_token_to_use = Cliner.token?,
215
+ how_often_to_use_that_token = 80,
216
+ use_colour = (
217
+ (Object.const_defined? :Cliner) ? Cliner.use_colours? : nil
218
+ ),
219
+ output_the_result = true
220
+ )
221
+ Cliner.cliner(
222
+ which_token_to_use,
223
+ how_often_to_use_that_token,
224
+ use_colour,
225
+ output_the_result
226
+ )
227
+
228
+ end
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ module Cliner
6
+
7
+ # ========================================================================= #
8
+ # === @use_this_colour
9
+ #
10
+ # By default we will not use any colours.
11
+ # ========================================================================= #
12
+ @use_this_colour = nil
13
+
14
+ # ========================================================================= #
15
+ # === Cliner.set_colour
16
+ #
17
+ # Use this method to designate a special colour to use.
18
+ # ========================================================================= #
19
+ def self.set_colour(
20
+ i = 'lightblue'
21
+ )
22
+ @use_this_colour = i
23
+ end; self.instance_eval { alias colour= set_colour } # === Cliner.colour=
24
+
25
+ # ========================================================================= #
26
+ # === Cliner.use_colours?
27
+ # ========================================================================= #
28
+ def self.use_colours?
29
+ @use_this_colour
30
+ end
31
+
32
+ end
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # You can also assign a default colour to use, via the
6
+ # Cliner.set_colour() method call.
7
+ # =========================================================================== #
8
+ # require 'cliner/module.rb'
9
+ # =========================================================================== #
10
+ module Cliner
11
+
12
+ require 'cliner/cliner.rb'
13
+ require 'cliner/colours.rb'
14
+ require 'cliner/token.rb'
15
+
16
+ # ========================================================================= #
17
+ # === Cliner.reset
18
+ # ========================================================================= #
19
+ def self.reset
20
+ Cliner.set_colour nil
21
+ end
22
+
23
+ # ========================================================================= #
24
+ # === Cliner[]
25
+ #
26
+ # This module-method accepts one argument, which is how many '=' we will
27
+ # use. By default we will show 80 '=' tokens.
28
+ # ========================================================================= #
29
+ def self.[](n_times = 80)
30
+ cliner(
31
+ ASSIGNMENT_TOKEN,
32
+ n_times,
33
+ nil,
34
+ false # false for "return the result".
35
+ )
36
+ end
37
+
38
+ end
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'cliner/time.rb'
6
+ # Cliner.return_hhmmss
7
+ # =========================================================================== #
8
+ module Cliner
9
+
10
+ # ========================================================================= #
11
+ # === Cliner.return_hhmmss
12
+ #
13
+ # This method will return hh:mm:ss, such as in "10:58:32".
14
+ # ========================================================================= #
15
+ def self.return_hhmmss
16
+ Time.now.strftime('%H:%M:%S')
17
+ end
18
+
19
+ end
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'cliner/token.rb'
6
+ # =========================================================================== #
7
+ module Cliner
8
+
9
+ # ========================================================================= #
10
+ # === ASSIGNMENT_TOKEN
11
+ # ========================================================================= #
12
+ ASSIGNMENT_TOKEN = '='
13
+
14
+ # ========================================================================= #
15
+ # === Cliner.token?
16
+ # ========================================================================= #
17
+ def self.token?
18
+ ASSIGNMENT_TOKEN
19
+ end
20
+
21
+ end
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ module Cliner
6
+
7
+ # ========================================================================= #
8
+ # === VERSION
9
+ # ========================================================================= #
10
+ VERSION = '1.0.33'
11
+
12
+ # ========================================================================= #
13
+ # === LAST_UPDATE
14
+ # ========================================================================= #
15
+ LAST_UPDATE = '08.08.2022'
16
+
17
+ end
data/lib/cliner.rb ADDED
@@ -0,0 +1 @@
1
+ require 'cliner/cliner.rb'
@@ -0,0 +1,43 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ require 'cliner/autoinclude'
6
+ require 'colours/colours_e_autoinclude.rb'
7
+
8
+ e 'Now testing the project called '+sfancy('cliner')+'.'
9
+ cliner
10
+ e "(1) Next we will set the colour lightblue via Cliner.colour = 'lightblue'"
11
+ Cliner.colour = 'lightblue'
12
+ cliner
13
+ e '(2) The above line should be in blue. We will next restore to the'
14
+ e 'default again via Cliner.reset'
15
+ Cliner.reset
16
+ cliner
17
+ e '(3) Now testing different size-length of cliner(), or more '\
18
+ 'accurately, cliner length: 88:'
19
+ cliner length: 88
20
+
21
+ # =========================================================================== #
22
+ # === Testing some colours
23
+ # =========================================================================== #
24
+ e '(4) Now via colours (lightblue, red, cyan):'
25
+ cliner :lightblue
26
+ cliner :red
27
+ cliner :cyan
28
+ # =========================================================================== #
29
+ # === Testing Konsole-related colours
30
+ # =========================================================================== #
31
+ e '(5) Now via Konsole-colours (Colours.orange then Colours.slateblue):'
32
+ cliner colours: :konsole_orange
33
+ cliner colours: :konsole_slateblue
34
+ e
35
+
36
+ # =========================================================================== #
37
+ # === Testing - as token
38
+ # =========================================================================== #
39
+ e "(6) Now we test using the token: '-'"
40
+ cliner token: '-'
41
+ e
42
+
43
+ e "That's it! We have finished testing this tiny project."
metadata ADDED
@@ -0,0 +1,77 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cliner
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.33
5
+ platform: ruby
6
+ authors:
7
+ - Robert A. Heiler
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-08-08 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: |2+
14
+
15
+ This small gem just provides one method called
16
+ cliner.
17
+
18
+ cliner means "colourized liner", and it basically
19
+ only makes a coloured line. Yes, that's it. :D
20
+
21
+ May not seem useful for anyone else at all, but
22
+ I found that I often need to use it. Use cases
23
+ include passing in a Hash such as via:
24
+
25
+ cliner token: 'X'
26
+
27
+ For more documentation please see the homepage
28
+ of this gem.
29
+
30
+ email: shevy@inbox.lt
31
+ executables:
32
+ - cliner
33
+ extensions: []
34
+ extra_rdoc_files: []
35
+ files:
36
+ - README.md
37
+ - bin/cliner
38
+ - cliner.gemspec
39
+ - doc/README.gen
40
+ - lib/cliner.rb
41
+ - lib/cliner/autoinclude.rb
42
+ - lib/cliner/cliner.rb
43
+ - lib/cliner/colours.rb
44
+ - lib/cliner/module.rb
45
+ - lib/cliner/time.rb
46
+ - lib/cliner/token.rb
47
+ - lib/cliner/version/version.rb
48
+ - test/testing_cliner.rb
49
+ homepage: https://rubygems.org/gems/cliner
50
+ licenses:
51
+ - MIT
52
+ metadata: {}
53
+ post_install_message:
54
+ rdoc_options: []
55
+ require_paths:
56
+ - lib
57
+ required_ruby_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 2.5.8
62
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: 3.3.18
67
+ requirements: []
68
+ rubygems_version: 3.3.18
69
+ signing_key:
70
+ specification_version: 4
71
+ summary: 'This small gem just provides one method called cliner. cliner means "colourized
72
+ liner", and it basically only makes a coloured line. Yes, that''s it. :D May not
73
+ seem useful for anyone else at all, but I found that I often need to use it. Use
74
+ cases include passing in a Hash such as via: cliner token: ''X'' For more documentation
75
+ please see the homepage of this gem.'
76
+ test_files: []
77
+ ...