clit 0.0.1 → 0.0.2
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.
- data/clit.gemspec +2 -1
- data/lib/clit.rb +9 -3
- data/lib/clit/theme.rb +6 -15
- data/lib/clit/themes/compatible.rb +15 -3
- data/lib/clit/themes/fancy.rb +15 -3
- metadata +17 -2
- data/lib/clit/themes/default.rb +0 -12
data/clit.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new {|s|
|
2
2
|
s.name = 'clit'
|
3
|
-
s.version = '0.0.
|
3
|
+
s.version = '0.0.2'
|
4
4
|
s.author = 'meh.'
|
5
5
|
s.email = 'meh@schizofreni.co'
|
6
6
|
s.homepage = 'http://github.com/meh/ruby-clit'
|
@@ -12,5 +12,6 @@ Gem::Specification.new {|s|
|
|
12
12
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
13
13
|
s.require_paths = ['lib']
|
14
14
|
|
15
|
+
s.add_runtime_dependency 'ruby-terminfo'
|
15
16
|
s.add_runtime_dependency 'colorb'
|
16
17
|
}
|
data/lib/clit.rb
CHANGED
@@ -20,7 +20,9 @@ class Clit < BasicObject
|
|
20
20
|
raise ArgumentError, "#{name} already exists"
|
21
21
|
end
|
22
22
|
|
23
|
-
@themes[name] = ::Class.new(::Clit::Theme, &block).instance
|
23
|
+
@themes[name] = ::Class.new(::Clit::Theme, &block).instance.tap {|t|
|
24
|
+
t.instance_variable_set :@name, name
|
25
|
+
}
|
24
26
|
end
|
25
27
|
|
26
28
|
def self.theme (name)
|
@@ -35,8 +37,12 @@ class Clit < BasicObject
|
|
35
37
|
themes[name]
|
36
38
|
end
|
37
39
|
|
38
|
-
def initialize (name =
|
39
|
-
|
40
|
+
def initialize (name = nil)
|
41
|
+
if ::ENV['CLIT_THEME']
|
42
|
+
theme ::ENV['CLIT_THEME'].to_sym
|
43
|
+
else
|
44
|
+
theme :compatible
|
45
|
+
end
|
40
46
|
end
|
41
47
|
|
42
48
|
def theme (name = nil)
|
data/lib/clit/theme.rb
CHANGED
@@ -10,27 +10,18 @@
|
|
10
10
|
|
11
11
|
require 'singleton'
|
12
12
|
require 'colorb'
|
13
|
+
require 'terminfo'
|
13
14
|
|
14
15
|
class Clit::Theme
|
15
16
|
include Singleton
|
16
17
|
|
17
|
-
|
18
|
-
methods - Object.instance_methods - [:functions]
|
19
|
-
end
|
20
|
-
|
21
|
-
def log (text)
|
22
|
-
puts text
|
23
|
-
end
|
18
|
+
attr_reader :name
|
24
19
|
|
25
|
-
def
|
26
|
-
|
27
|
-
end
|
28
|
-
|
29
|
-
def warn (text)
|
30
|
-
puts text
|
20
|
+
def functions
|
21
|
+
methods - Object.instance_methods - [:functions, :name]
|
31
22
|
end
|
32
23
|
|
33
|
-
def
|
34
|
-
|
24
|
+
def new_line
|
25
|
+
print "\n"
|
35
26
|
end
|
36
27
|
end
|
@@ -10,14 +10,26 @@
|
|
10
10
|
|
11
11
|
Clit.define_theme :compatible do
|
12
12
|
def info (text)
|
13
|
-
|
13
|
+
puts "#{?*.blue} #{text}"
|
14
14
|
end
|
15
15
|
|
16
16
|
def warn (text)
|
17
|
-
|
17
|
+
puts "#{?*.yellow} #{text}"
|
18
18
|
end
|
19
19
|
|
20
20
|
def error (text)
|
21
|
-
|
21
|
+
puts "#{?*.red} #{text}"
|
22
|
+
end
|
23
|
+
|
24
|
+
def success (text)
|
25
|
+
puts "#{?+.green} #{text}"
|
26
|
+
end
|
27
|
+
|
28
|
+
def failure (text)
|
29
|
+
puts "#{?-.red} #{text}"
|
30
|
+
end
|
31
|
+
|
32
|
+
def separator
|
33
|
+
puts ('-' * TermInfo.screen_size[1]).black.bold
|
22
34
|
end
|
23
35
|
end
|
data/lib/clit/themes/fancy.rb
CHANGED
@@ -11,14 +11,26 @@
|
|
11
11
|
|
12
12
|
Clit.define_theme :fancy do
|
13
13
|
def info (text)
|
14
|
-
|
14
|
+
puts "#{?ℹ.blue} #{text}"
|
15
15
|
end
|
16
16
|
|
17
17
|
def warn (text)
|
18
|
-
|
18
|
+
puts "#{?⚠.yellow} #{text}"
|
19
19
|
end
|
20
20
|
|
21
21
|
def error (text)
|
22
|
-
|
22
|
+
puts "#{?❗.red} #{text}"
|
23
|
+
end
|
24
|
+
|
25
|
+
def success (text)
|
26
|
+
puts "#{?✔.green} #{text}"
|
27
|
+
end
|
28
|
+
|
29
|
+
def failure (text)
|
30
|
+
puts "#{?✘.red} #{text}"
|
31
|
+
end
|
32
|
+
|
33
|
+
def separator
|
34
|
+
puts ('─' * TermInfo.screen_size[1]).black.bold
|
23
35
|
end
|
24
36
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,6 +11,22 @@ bindir: bin
|
|
11
11
|
cert_chain: []
|
12
12
|
date: 2012-08-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: ruby-terminfo
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
14
30
|
- !ruby/object:Gem::Dependency
|
15
31
|
name: colorb
|
16
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -40,7 +56,6 @@ files:
|
|
40
56
|
- lib/clit.rb
|
41
57
|
- lib/clit/theme.rb
|
42
58
|
- lib/clit/themes/compatible.rb
|
43
|
-
- lib/clit/themes/default.rb
|
44
59
|
- lib/clit/themes/fancy.rb
|
45
60
|
homepage: http://github.com/meh/ruby-clit
|
46
61
|
licenses: []
|
data/lib/clit/themes/default.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
#--
|
2
|
-
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
3
|
-
# Version 2, December 2004
|
4
|
-
#
|
5
|
-
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
6
|
-
# TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
7
|
-
#
|
8
|
-
# 0. You just DO WHAT THE FUCK YOU WANT TO.
|
9
|
-
#++
|
10
|
-
|
11
|
-
Clit.define_theme :default do
|
12
|
-
end
|