uiux 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -1
- data/lib/uiux/version.rb +1 -1
- data/lib/uiux.rb +23 -10
- data/uiux.gemspec +1 -0
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1c711b5fdd38488ac661673cbdce55b7bc19c83
|
4
|
+
data.tar.gz: 7de4ccf1036c00b3258879c9fe6202de7dfca635
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e63242501b901f80705a7aefc84a244754aa1bd4f98f46d2ae37b6fef8306d823bd417fb004817f65dc3e6433fc5ebdaae764b8631013404f52044c1c3de5c4
|
7
|
+
data.tar.gz: 95e5cb34f2d7effbd03c3fad7e17c5f4e31e6fb6396aebfbddd8177c29da87ee6da01663bfc347f78cb73ba4a44164f00ab81af36d943a178f92d9976a7fb872
|
data/README.md
CHANGED
@@ -22,7 +22,11 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
25
|
-
|
25
|
+
* `UI.start` block provides start and finish headers with start and end times. This also provides better error display output which also includes the time
|
26
|
+
* `UI.heading` display a green heading with a line return before
|
27
|
+
* `UI.message` display a white message
|
28
|
+
* `UI.error` dispay a red error message
|
29
|
+
* `UI.execute` displays the command to execute, executes it and shows the output and also returns the result for potential further manipulations
|
26
30
|
|
27
31
|
## Development
|
28
32
|
|
data/lib/uiux/version.rb
CHANGED
data/lib/uiux.rb
CHANGED
@@ -8,7 +8,7 @@ module UI
|
|
8
8
|
yield block
|
9
9
|
finished
|
10
10
|
rescue Exception => error
|
11
|
-
puts "\nFailed
|
11
|
+
puts heading_with_columns("\nFailed", '↓', time).color(:red)
|
12
12
|
raise error
|
13
13
|
end
|
14
14
|
|
@@ -25,27 +25,40 @@ module UI
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def self.execute(command)
|
28
|
-
puts '==>
|
28
|
+
puts "#{'==>'.color(:blue)} #{command.bright}"
|
29
29
|
puts result = `#{command}`
|
30
30
|
result
|
31
31
|
end
|
32
32
|
|
33
33
|
def self.time
|
34
|
-
|
35
|
-
"🕑 #{time} 🕑 ".color(:white)
|
34
|
+
"🕑 #{Time.now.utc} 🕑 ".color(:white)
|
36
35
|
end
|
37
36
|
|
38
37
|
private
|
39
38
|
|
40
39
|
def self.start_heading(message)
|
41
|
-
|
42
|
-
puts
|
43
|
-
print message.color(:cyan)
|
44
|
-
puts ' ' * (70 - message.length) + time
|
40
|
+
puts heading_with_columns(nil, '='.color(:cyan), nil)
|
41
|
+
puts heading_with_columns(message.color(:cyan), ' ', time)
|
45
42
|
end
|
46
43
|
|
47
44
|
def self.finished
|
48
|
-
puts "\nFinished
|
49
|
-
puts '='.color(:magenta)
|
45
|
+
puts heading_with_columns("\nFinished".color(:magenta), ' ', time)
|
46
|
+
puts heading_with_columns(nil, '='.color(:magenta), nil)
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.heading_with_columns(first_str, spacer_str, last_str, length = 100)
|
50
|
+
first_str = first_str ? "#{first_str} " : ''
|
51
|
+
last_str = last_str ? " #{last_str}" : ''
|
52
|
+
min_length = str_length("#{first_str}#{last_str}")
|
53
|
+
fail if min_length > length # TODO: Find a better way to handle long input strings
|
54
|
+
reps = (length - min_length) / str_length(spacer_str)
|
55
|
+
"#{first_str}#{spacer_str * reps}#{last_str}"
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.str_length(str)
|
59
|
+
str = str.gsub(/\e\[\d+m/, '') # remove colors
|
60
|
+
str.chars.each_with_object('') do |char, new_str|
|
61
|
+
new_str << char unless char.ascii_only? && (char.ord < 32 || char.ord == 127)
|
62
|
+
end.length
|
50
63
|
end
|
51
64
|
end
|
data/uiux.gemspec
CHANGED
@@ -19,6 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.require_paths = ['lib']
|
20
20
|
|
21
21
|
spec.add_dependency 'rainbow', '~> 2.0'
|
22
|
+
spec.add_dependency 'awesome_print', '~> 1.0'
|
22
23
|
|
23
24
|
spec.add_development_dependency 'bundler', '~> 1.10'
|
24
25
|
spec.add_development_dependency 'rake', '~> 10.0'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uiux
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Endri Gjiri
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: awesome_print
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: bundler
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|