Hokkaido 0.0.5 → 0.0.6

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.
@@ -1,3 +1,3 @@
1
1
  module Hokkaido
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -1,127 +1,102 @@
1
- Motion::Project::App.setup do |app|
2
- app.files << File.expand_path(File.join(File.dirname(__FILE__),'ansicolor.rb'))
3
- end
4
- module Hokkaido
5
- module Term
6
- # The ANSIColor module can be used for namespacing and mixed into your own
7
- # classes.
8
- module ANSIColor
9
- # :stopdoc:
10
- ATTRIBUTES = [
11
- [ :clear , 0 ],
12
- [ :reset , 0 ], # synonym for :clear
13
- [ :bold , 1 ],
14
- [ :dark , 2 ],
15
- [ :italic , 3 ], # not widely implemented
16
- [ :underline , 4 ],
17
- [ :underscore , 4 ], # synonym for :underline
18
- [ :blink , 5 ],
19
- [ :rapid_blink , 6 ], # not widely implemented
20
- [ :negative , 7 ], # no reverse because of String#reverse
21
- [ :concealed , 8 ],
22
- [ :strikethrough, 9 ], # not widely implemented
23
- [ :black , 30 ],
24
- [ :red , 31 ],
25
- [ :green , 32 ],
26
- [ :yellow , 33 ],
27
- [ :blue , 34 ],
28
- [ :magenta , 35 ],
29
- [ :cyan , 36 ],
30
- [ :white , 37 ],
31
- [ :on_black , 40 ],
32
- [ :on_red , 41 ],
33
- [ :on_green , 42 ],
34
- [ :on_yellow , 43 ],
35
- [ :on_blue , 44 ],
36
- [ :on_magenta , 45 ],
37
- [ :on_cyan , 46 ],
38
- [ :on_white , 47 ],
39
- ]
40
-
41
- ATTRIBUTE_NAMES = ATTRIBUTES.transpose.first
42
- # :startdoc:
43
-
44
- # Returns true, if the coloring function of this module
45
- # is switched on, false otherwise.
46
- def self.coloring?
47
- @coloring
48
- end
49
-
50
- # Turns the coloring on or off globally, so you can easily do
51
- # this for example:
52
- # Cucumber::Term::ANSIColor::coloring = STDOUT.isatty
53
- def self.coloring=(val)
54
- @coloring = val
55
- end
56
- self.coloring = true
1
+ #require 'term/ansicolor/version'
57
2
 
58
- ATTRIBUTES.each do |c, v|
59
- # Module#eval is disabled in motion# eval %Q{
60
- def #{c}(string = nil)
61
- result = ''
62
- result << "\e[#{v}m" if Hokkaido::Term::ANSIColor.coloring?
63
- if block_given?
64
- result << yield
65
- elsif string
66
- result << string
67
- elsif respond_to?(:to_str)
68
- result << to_str
69
- else
70
- return result #only switch on
71
- end
72
- result << "\e[0m" if Hokkaido::Term::ANSIColor.coloring?
73
- result
74
- end
75
- }
76
- end
3
+ module Term
4
+ # The ANSIColor module can be used for namespacing and mixed into your own
5
+ # classes.
6
+ module ANSIColor
7
+ # :stopdoc:
8
+ ATTRIBUTES = [
9
+ [ :clear , 0 ],
10
+ [ :reset , 0 ], # synonym for :clear
11
+ [ :bold , 1 ],
12
+ [ :dark , 2 ],
13
+ [ :italic , 3 ], # not widely implemented
14
+ [ :underline , 4 ],
15
+ [ :underscore , 4 ], # synonym for :underline
16
+ [ :blink , 5 ],
17
+ [ :rapid_blink , 6 ], # not widely implemented
18
+ [ :negative , 7 ], # no reverse because of String#reverse
19
+ [ :concealed , 8 ],
20
+ [ :strikethrough, 9 ], # not widely implemented
21
+ [ :black , 30 ],
22
+ [ :red , 31 ],
23
+ [ :green , 32 ],
24
+ [ :yellow , 33 ],
25
+ [ :blue , 34 ],
26
+ [ :magenta , 35 ],
27
+ [ :cyan , 36 ],
28
+ [ :white , 37 ],
29
+ [ :on_black , 40 ],
30
+ [ :on_red , 41 ],
31
+ [ :on_green , 42 ],
32
+ [ :on_yellow , 43 ],
33
+ [ :on_blue , 44 ],
34
+ [ :on_magenta , 45 ],
35
+ [ :on_cyan , 46 ],
36
+ [ :on_white , 47 ],
37
+ ]
77
38
 
78
- # Regular expression that is used to scan for ANSI-sequences while
79
- # uncoloring strings.
80
- COLORED_REGEXP = /\e\[(?:[34][0-7]|[0-9])?m/
39
+ ATTRIBUTE_NAMES = ATTRIBUTES.transpose.first
40
+ # :startdoc:
81
41
 
42
+ # Returns true, if the coloring function of this module
43
+ # is switched on, false otherwise.
44
+ def self.coloring?
45
+ @coloring
46
+ end
82
47
 
83
- def self.included(klass)
84
- if version_is_greater_than_18? and klass == String
85
- ATTRIBUTES.delete(:clear)
86
- ATTRIBUTE_NAMES.delete(:clear)
87
- end
88
- end
48
+ # Turns the coloring on or off globally, so you can easily do
49
+ # this for example:
50
+ # Term::ANSIColor::coloring = STDOUT.isatty
51
+ def self.coloring=(val)
52
+ @coloring = val
53
+ end
54
+ self.coloring = true
89
55
 
90
- # Returns an uncolored version of the string, that is all
91
- # ANSI-sequences are stripped from the string.
92
- def uncolored(string = nil) # :yields:
93
- if block_given?
94
- yield.gsub(COLORED_REGEXP, '')
95
- elsif string
96
- string.gsub(COLORED_REGEXP, '')
97
- elsif respond_to?(:to_str)
98
- to_str.gsub(COLORED_REGEXP, '')
99
- else
100
- ''
101
- end
102
- end
56
+ ATTRIBUTES.each do |c, v|
57
+ eval %Q{
58
+ def #{c}(string = nil)
59
+ result = ''
60
+ result << "\e[#{v}m" if Term::ANSIColor.coloring?
61
+ if block_given?
62
+ result << yield
63
+ elsif string
64
+ result << string
65
+ elsif respond_to?(:to_str)
66
+ result << to_str
67
+ else
68
+ return result #only switch on
69
+ end
70
+ result << "\e[0m" if Term::ANSIColor.coloring?
71
+ result
72
+ end
73
+ }
74
+ end
103
75
 
104
- module_function
76
+ # Regular expression that is used to scan for ANSI-sequences while
77
+ # uncoloring strings.
78
+ COLORED_REGEXP = /\e\[(?:[34][0-7]|[0-9])?m/
105
79
 
106
- # Returns an array of all Hokkaido::Term::ANSIColor attributes as symbols.
107
- def attributes
108
- ATTRIBUTE_NAMES
80
+ # Returns an uncolored version of the string, that is all
81
+ # ANSI-sequences are stripped from the string.
82
+ def uncolored(string = nil) # :yields:
83
+ if block_given?
84
+ yield.gsub(COLORED_REGEXP, '')
85
+ elsif string
86
+ string.gsub(COLORED_REGEXP, '')
87
+ elsif respond_to?(:to_str)
88
+ to_str.gsub(COLORED_REGEXP, '')
89
+ else
90
+ ''
109
91
  end
110
- extend self
92
+ end
111
93
 
112
- private
94
+ module_function
113
95
 
114
- def version_is_greater_than_18?
115
- version = RUBY_VERSION.split('.')
116
- version.map! &:to_i
117
- version[0] >= 1 && version[1] > 8
118
- end
96
+ # Returns an array of all Term::ANSIColor attributes as symbols.
97
+ def attributes
98
+ ATTRIBUTE_NAMES
119
99
  end
120
- end
121
- end
122
-
123
- class String
124
- def colorize(sym)
125
- Hokkaido::Term::ANSIColor.send(sym, self)
100
+ extend self
126
101
  end
127
102
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Hokkaido
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: