ansi 1.4.1 → 1.4.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,9 +7,8 @@ module ANSI
7
7
  # Generally speaking the String#ansi method is the more
8
8
  # elegant approach to modifying a string with codes
9
9
  # via a method call. But in some cases this Mixin's design
10
- # might be preferable. In particular it was primarily
11
- # designed to provide a compatability layer for the
12
- # +colored+ gem.
10
+ # might be preferable. Indeed, it original intent was
11
+ # as a compatability layer for the +colored+ gem.
13
12
 
14
13
  module Mixin
15
14
 
@@ -120,4 +119,3 @@ module ANSI
120
119
  end
121
120
 
122
121
  end
123
-
@@ -25,7 +25,7 @@ module ANSI
25
25
  @out = out
26
26
 
27
27
  @bar_length = 80
28
- @bar_mark = "o"
28
+ @bar_mark = "|"
29
29
  @total_overflow = true
30
30
  @current = 0
31
31
  @previous = 0
@@ -54,6 +54,8 @@ module ANSI
54
54
  def bar_mark=(mark)
55
55
  @bar_mark = String(mark)[0..0]
56
56
  end
57
+ alias_method :barmark=, :bar_mark=
58
+ alias_method :mark=, :bar_mark=
57
59
 
58
60
  def total_overflow=(boolv)
59
61
  @total_overflow = boolv ? true : false
@@ -272,7 +274,8 @@ module ANSI
272
274
  #
273
275
  def colorize(part, style)
274
276
  return part unless style
275
- [style].flatten.inject(part){ |pt, st| ANSI::Code.send(st){pt} }
277
+ #[style].flatten.inject(part){ |pt, st| ANSI::Code.ansi(pt, *st) }
278
+ ANSI::Code.ansi(part, *style)
276
279
  end
277
280
 
278
281
  end
@@ -30,12 +30,12 @@ module ANSI
30
30
 
31
31
  # Get the width of the terminal window.
32
32
  def terminal_width
33
- terminal_size[0]
33
+ terminal_size.first
34
34
  end
35
35
 
36
36
  # Get the height of the terminal window.
37
37
  def terminal_height
38
- terminal_size[1]
38
+ terminal_size.last
39
39
  end
40
40
 
41
41
  end
@@ -19,9 +19,9 @@ module ANSI
19
19
  Curses.init_screen
20
20
  w, r = Curses.cols, Curses.rows
21
21
  Curses.close_screen
22
- return r, w
22
+ return w, r
23
23
  end
24
24
 
25
25
  end
26
26
 
27
- end
27
+ end
@@ -1,9 +1,11 @@
1
1
  module ANSI
2
2
 
3
3
  module Terminal
4
-
5
4
  module_function
6
5
 
6
+ #COLS_FALLBACK = 80
7
+ #ROWS_FALLBACK = 25
8
+
7
9
  #CHARACTER_MODE = "stty" # For Debugging purposes only.
8
10
 
9
11
  #
@@ -42,12 +44,17 @@ module ANSI
42
44
 
43
45
  # A Unix savvy method to fetch the console columns, and rows.
44
46
  def terminal_size
45
- if /solaris/ =~ RUBY_PLATFORM and
46
- `stty` =~ /\brows = (\d+).*\bcolumns = (\d+)/
47
- [$2, $1].map { |c| x.to_i }
47
+ if /solaris/ =~ RUBY_PLATFORM && (`stty` =~ /\brows = (\d+).*\bcolumns = (\d+)/)
48
+ w, r = [$2, $1]
48
49
  else
49
- `stty size`.split.map { |x| x.to_i }.reverse
50
+ w, r = `stty size`.split.reverse
50
51
  end
52
+ w = `tput cols` unless w # last ditch effort to at least get width
53
+
54
+ w = w.to_i if w
55
+ r = r.to_i if r
56
+
57
+ return w, r
51
58
  end
52
59
 
53
60
  end
@@ -29,18 +29,23 @@ module ANSI
29
29
 
30
30
  # A Unix savvy method to fetch the console columns, and rows.
31
31
  def terminal_size
32
- if /solaris/ =~ RUBY_PLATFORM and
33
- `stty` =~ /\brows = (\d+).*\bcolumns = (\d+)/
34
- [$2, $1].map { |c| x.to_i }
32
+ if /solaris/ =~ RUBY_PLATFORM && (`stty` =~ /\brows = (\d+).*\bcolumns = (\d+)/)
33
+ w, r = [$2, $1]
35
34
  else
36
- `stty size`.split.map { |x| x.to_i }.reverse
35
+ w, r = `stty size`.split.reverse
37
36
  end
37
+ w = `tput cols` unless w # last ditch effort to at least get width
38
+
39
+ w = w.to_i if w
40
+ r = r.to_i if r
41
+
42
+ return w, r
38
43
  end
39
44
 
40
45
  # Console screen width (taken from progress bar)
41
46
  #
42
47
  # NOTE: Don't know how portable #screen_width is.
43
- # TODO: How to fit in to system?
48
+ # TODO: How to fit into system?
44
49
  #
45
50
  def screen_width(out=STDERR)
46
51
  default_width = ENV['COLUMNS'] || 76
@@ -60,4 +65,4 @@ module ANSI
60
65
 
61
66
  end
62
67
 
63
- end
68
+ end
@@ -1,7 +1,6 @@
1
- # ANSI module contains all the ANSI related classes.
2
1
  module ANSI
3
2
  # Returns Hash table of project metadata.
4
- def self.meta
3
+ def self.metadata
5
4
  @spec ||= (
6
5
  require 'yaml'
7
6
  YAML.load(File.new(File.dirname(__FILE__) + '/../ansi.yml'))
@@ -10,7 +9,7 @@ module ANSI
10
9
 
11
10
  # Check metadata for missing constants.
12
11
  def self.const_missing(name)
13
- meta[name.to_s.downcase] || super(name)
12
+ metadata[name.to_s.downcase] || super(name)
14
13
  end
15
14
  end
16
15
 
File without changes
File without changes
File without changes
@@ -0,0 +1,8 @@
1
+ = ANSI::Terminal
2
+
3
+ We should be ables to get the terminal width via the `terminal_width` method.
4
+
5
+ width = ANSI::Terminal.terminal_width
6
+
7
+ Fixnum.assert === width
8
+
@@ -0,0 +1 @@
1
+ require 'ae'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ansi
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.4.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2011-11-10 00:00:00.000000000 Z
13
+ date: 2012-01-29 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: detroit
17
- requirement: &29129100 !ruby/object:Gem::Requirement
17
+ requirement: &31273700 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: '0'
23
23
  type: :development
24
24
  prerelease: false
25
- version_requirements: *29129100
25
+ version_requirements: *31273700
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: qed
28
- requirement: &29128360 !ruby/object:Gem::Requirement
28
+ requirement: &31273100 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
- version_requirements: *29128360
36
+ version_requirements: *31273100
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: lemon
39
- requirement: &29127740 !ruby/object:Gem::Requirement
39
+ requirement: &31272580 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ! '>='
@@ -44,13 +44,15 @@ dependencies:
44
44
  version: '0'
45
45
  type: :development
46
46
  prerelease: false
47
- version_requirements: *29127740
48
- description: ! 'The ANSI project is a collection of ANSI escape code related libraries
49
- enabling
47
+ version_requirements: *31272580
48
+ description: ! 'The ANSI project is a superlative collection of ANSI escape code related
49
+ libraries
50
50
 
51
- ANSI code based colorization and stylization of output. It is very nice for
51
+ enabling ANSI colorization and stylization of console output. Byte for byte
52
52
 
53
- beautifying shell output.'
53
+ ANSI is the best ANSI code library available for the Ruby programming
54
+
55
+ language.'
54
56
  email:
55
57
  - transfire@gmail.com
56
58
  executables: []
@@ -59,12 +61,12 @@ extra_rdoc_files:
59
61
  - HISTORY.rdoc
60
62
  - README.rdoc
61
63
  - QED.rdoc
62
- - NOTICE.rdoc
63
- - LICENSE.rdoc
64
+ - COPYING.rdoc
64
65
  files:
65
66
  - .ruby
66
67
  - .yardopts
67
68
  - lib/ansi/bbcode.rb
69
+ - lib/ansi/chain.rb
68
70
  - lib/ansi/chart.rb
69
71
  - lib/ansi/code.rb
70
72
  - lib/ansi/columns.rb
@@ -84,18 +86,19 @@ files:
84
86
  - lib/ansi/terminal.rb
85
87
  - lib/ansi/version.rb
86
88
  - lib/ansi.rb
87
- - lib/ansi.rbz
88
89
  - lib/ansi.yml
89
90
  - qed/01_ansicode.rdoc
90
- - qed/02_bbcode.rdoc
91
+ - qed/02_core.rdoc
91
92
  - qed/03_logger.rdoc
92
93
  - qed/04_progressbar.rdoc
93
94
  - qed/05_mixin.rdoc
94
95
  - qed/06_string.rdoc
95
96
  - qed/07_columns.rdoc
96
97
  - qed/08_table.rdoc
97
- - qed/09_diff.rb
98
- - qed/10_core.rdoc
98
+ - qed/09_diff.rdoc
99
+ - qed/10_bbcode.rdoc
100
+ - qed/11_terminal.rdoc
101
+ - qed/applique/ae.rb
99
102
  - qed/applique/output.rb
100
103
  - test/case_ansicode.rb
101
104
  - test/case_bbcode.rb
@@ -105,8 +108,7 @@ files:
105
108
  - HISTORY.rdoc
106
109
  - README.rdoc
107
110
  - QED.rdoc
108
- - NOTICE.rdoc
109
- - LICENSE.rdoc
111
+ - COPYING.rdoc
110
112
  homepage: http://rubyworks.github.com/ansi
111
113
  licenses: []
112
114
  post_install_message:
@@ -1,156 +0,0 @@
1
- = COPYRIGHT NOTICES
2
-
3
- == ANSI
4
-
5
- Copyright:: (c) 2009 Rubyworks
6
- License:: BSD-2-Clause
7
- Website:: http://rubyworks.github.com/ansi
8
-
9
- Copyright 2009 Rubyworks. All rights reserved.
10
-
11
- Redistribution and use in source and binary forms, with or without modification, are
12
- permitted provided that the following conditions are met:
13
-
14
- 1. Redistributions of source code must retain the above copyright notice, this list of
15
- conditions and the following disclaimer.
16
-
17
- 2. Redistributions in binary form must reproduce the above copyright notice, this list
18
- of conditions and the following disclaimer in the documentation and/or other materials
19
- provided with the distribution.
20
-
21
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY EXPRESS OR IMPLIED
22
- WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
23
- FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
24
- OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
27
- ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
29
- ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
-
31
- (http://spdx.org/licenses/BSD-2-Clause)
32
-
33
-
34
- == ProgressBar
35
-
36
- Copyright:: (C) 2001 Satoru Takabayashi
37
- License:: Ruby License
38
- Website:: http://0xcc.net/ruby-progressbar/
39
-
40
- ProgressBar class is based on the original ProgressBar by Satoru Takabayashi.
41
-
42
- Ruby/ProgressBar - a text progress bar library
43
-
44
- Copyright (C) 2001-2005 Satoru Takabayashi <satoru@namazu.org>
45
- All rights reserved.
46
- This is free software with ABSOLUTELY NO WARRANTY.
47
-
48
- You can redistribute it and/or modify it under the terms
49
- of Ruby's license.
50
-
51
-
52
- == HighLine (Terminal Extensions)
53
-
54
- Copyright:: (c) 2006 Gray Productions
55
- License:: Ruby License
56
- Website:: http://highline.rubyforge.org/
57
-
58
- The terminal extensions are based on HighLine's SystemExtensions
59
- by James Edward Gray II.
60
-
61
- Copyright 2006 Gray Productions
62
-
63
- Distributed under the user's choice of the {GPL Version 2}[http://www.gnu.org/licenses/old-licenses/gpl-2.0.html]
64
- (see GPL-2.0.txt for details) or the {Ruby software license}[http://www.ruby-lang.org/en/LICENSE.txt]
65
- by James Edward Gray II and Greg Brown.
66
-
67
- Please email James[mailto:james@grayproductions.net] with any questions.
68
-
69
-
70
- == BBCode
71
-
72
- Copyright:: (c) 2002 Thomas-Ivo Heinen
73
- License:: Ruby License
74
-
75
- BBCode module is a derivative of BBCode by Thomas-Ivo Heinen.
76
-
77
- Copyright (c) 2002 Thomas-Ivo Heinen
78
-
79
- This module is free software. You may use, modify, and/or redistribute this
80
- software under the same terms as Ruby.
81
-
82
- This program is distributed in the hope that it will be useful, but WITHOUT
83
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
84
- FOR A PARTICULAR PURPOSE.
85
-
86
-
87
- == Rainbow (XTerm Color Support)
88
-
89
- Copyright:: (c) Marcin Kulik
90
- License:: MIT
91
- Website:: http://github.com/sickill/rainbow
92
-
93
- Rainbox provided the bases for building the XTerm 256 color code
94
- support into the ANSI::Code module.
95
-
96
- Copyright (c) Marcin Kulik
97
-
98
- Permission is hereby granted, free of charge, to any person obtaining
99
- a copy of this software and associated documentation files (the
100
- "Software"), to deal in the Software without restriction, including
101
- without limitation the rights to use, copy, modify, merge, publish,
102
- distribute, sublicense, and/or sell copies of the Software, and to
103
- permit persons to whom the Software is furnished to do so, subject to
104
- the following conditions:
105
-
106
- The above copyright notice and this permission notice shall be
107
- included in all copies or substantial portions of the Software.
108
-
109
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
110
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
111
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
112
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
113
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
114
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
115
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
116
-
117
-
118
- == Paint
119
-
120
- Copyright:: (c) 2011 Jan Lelis
121
- Website:: https://github.com/janlelis/paint
122
-
123
- Some of the latest ANSI code names, and inspiration to check out Rainbow
124
- and include XTerm 256 color codes, came from Paint.
125
-
126
- Copyright (c) 2011 Jan Lelis
127
-
128
- Permission is hereby granted, free of charge, to any person obtaining
129
- a copy of this software and associated documentation files (the
130
- "Software"), to deal in the Software without restriction, including
131
- without limitation the rights to use, copy, modify, merge, publish,
132
- distribute, sublicense, and/or sell copies of the Software, and to
133
- permit persons to whom the Software is furnished to do so, subject to
134
- the following conditions:
135
-
136
- The above copyright notice and this permission notice shall be
137
- included in all copies or substantial portions of the Software.
138
-
139
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
140
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
141
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
142
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
143
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
144
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
145
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
146
-
147
-
148
- == ANSIColor
149
-
150
- Copyright:: (c) 2002 Florian Frank
151
- Website:: http://flori.github.com/term-ansicolor
152
-
153
- Albeit the code no long bares much if any resemblance to it, the ANSI Code
154
- module (and subsequently the Constants module) originated with the
155
- ANSIColor library by Florian Frank.
156
-