ruby-nuggets 0.6.4 → 0.6.5

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/README CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  == VERSION
4
4
 
5
- This documentation refers to ruby-nuggets version 0.6.4
5
+ This documentation refers to ruby-nuggets version 0.6.5
6
6
 
7
7
 
8
8
  == DESCRIPTION
@@ -38,6 +38,7 @@ Documentation:: <http://prometheus.rubyforge.org/ruby-nuggets>
38
38
  Source code (old):: <http://prometheus.rubyforge.org/svn/scratch/ruby-nuggets>
39
39
  Source code:: <http://github.com/blackwinter/ruby-nuggets>
40
40
  Rubyforge project:: <http://rubyforge.org/projects/prometheus>
41
+ RubyGem:: <http://rubygems.org/gems/ruby-nuggets>
41
42
 
42
43
 
43
44
  == AUTHORS
@@ -47,7 +48,7 @@ Rubyforge project:: <http://rubyforge.org/projects/prometheus>
47
48
 
48
49
  == LICENSE AND COPYRIGHT
49
50
 
50
- Copyright (C) 2007-2010 Jens Wille
51
+ Copyright (C) 2007-2011 Jens Wille
51
52
 
52
53
  ruby-nuggets is free software: you can redistribute it and/or modify it under
53
54
  the terms of the GNU General Public License as published by the Free Software
@@ -1,55 +1,5 @@
1
- #--
2
- ###############################################################################
3
- # #
4
- # A component of ruby-nuggets, some extensions to the Ruby programming #
5
- # language. #
6
- # #
7
- # Copyright (C) 2007 Jens Wille #
8
- # #
9
- # Authors: #
10
- # Jens Wille <jens.wille@uni-koeln.de> #
11
- # #
12
- # ruby-nuggets is free software; you can redistribute it and/or modify it #
13
- # under the terms of the GNU General Public License as published by the Free #
14
- # Software Foundation; either version 3 of the License, or (at your option) #
15
- # any later version. #
16
- # #
17
- # ruby-nuggets is distributed in the hope that it will be useful, but WITHOUT #
18
- # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
19
- # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
20
- # more details. #
21
- # #
22
- # You should have received a copy of the GNU General Public License along #
23
- # with ruby-nuggets. If not, see <http://www.gnu.org/licenses/>. #
24
- # #
25
- ###############################################################################
26
- #++
1
+ require 'nuggets/string/evaluate_mixin'
27
2
 
28
3
  class String
29
-
30
- # call-seq:
31
- # str.evaluate(binding = TOPLEVEL_BINDING) => new_str
32
- #
33
- # Basically turns Kernel#eval into an instance method of String -- inspired
34
- # by Ruby Cookbook example 1.3. This allows to pre-populate strings with
35
- # substitution expressions ("#{...}") that can get evaluated in a different
36
- # environment (= +binding+) at a later point.
37
- def evaluate(binding = TOPLEVEL_BINDING)
38
- eval(%Q{%Q{#{self}}}, binding)
39
- end
40
-
41
- end
42
-
43
- if $0 == __FILE__
44
- s = 'bl#{a}blub'
45
- p s
46
-
47
- def foo(bar) # :nodoc:
48
- a = 'ub'
49
- bar.evaluate(binding)
50
- end
51
-
52
- p foo(s)
53
-
54
- p 'a"b"c'.evaluate(binding)
4
+ include Nuggets::String::EvaluateMixin
55
5
  end
@@ -0,0 +1,45 @@
1
+ #--
2
+ ###############################################################################
3
+ # #
4
+ # A component of ruby-nuggets, some extensions to the Ruby programming #
5
+ # language. #
6
+ # #
7
+ # Copyright (C) 2007-2011 Jens Wille #
8
+ # #
9
+ # Authors: #
10
+ # Jens Wille <jens.wille@uni-koeln.de> #
11
+ # #
12
+ # ruby-nuggets is free software; you can redistribute it and/or modify it #
13
+ # under the terms of the GNU General Public License as published by the Free #
14
+ # Software Foundation; either version 3 of the License, or (at your option) #
15
+ # any later version. #
16
+ # #
17
+ # ruby-nuggets is distributed in the hope that it will be useful, but WITHOUT #
18
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
19
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
20
+ # more details. #
21
+ # #
22
+ # You should have received a copy of the GNU General Public License along #
23
+ # with ruby-nuggets. If not, see <http://www.gnu.org/licenses/>. #
24
+ # #
25
+ ###############################################################################
26
+ #++
27
+
28
+ module Nuggets
29
+ class String
30
+ module EvaluateMixin
31
+
32
+ # call-seq:
33
+ # str.evaluate(binding = TOPLEVEL_BINDING) => new_str
34
+ #
35
+ # Basically turns Kernel#eval into an instance method of String -- inspired
36
+ # by Ruby Cookbook example 1.3. This allows to pre-populate strings with
37
+ # substitution expressions ("#{...}") that can get evaluated in a different
38
+ # environment (= +binding+) at a later point.
39
+ def evaluate(binding = TOPLEVEL_BINDING)
40
+ eval(%Q{"#{gsub(/\\*"/) { |m| "#{"\\" * m.length}#{m}" }}"}, binding)
41
+ end
42
+
43
+ end
44
+ end
45
+ end
@@ -69,7 +69,7 @@ module Nuggets
69
69
  #
70
70
  # Count number of characters in _str_.
71
71
  def char_count
72
- count_by_re(/./m)
72
+ count_by_re(/./um)
73
73
  end
74
74
  alias_method :wc_m, :char_count
75
75
 
@@ -32,32 +32,57 @@ module Util
32
32
  extend self
33
33
 
34
34
  ATTRIBUTES = {
35
- '0' => nil, # clear
36
- '1' => 'font-weight: bold', # bold
37
- '2' => '', # dark
38
- '3' => 'font-style: italic', # italic -- not widely implemented
39
- '4' => 'text-decoration: underline', # underline
40
- '5' => 'text-decoration: blink', # blink
41
- '6' => 'text-decoration: blink', # rapid blink -- not widely implemented
42
- '7' => '', # negative
43
- '8' => '', # concealed
44
- '9' => 'text-decoration: line-through', # strikethrough -- not widely implemented
45
- '30' => 'color: black', # black
46
- '31' => 'color: red', # red
47
- '32' => 'color: green', # green
48
- '33' => 'color: yellow', # yellow
49
- '34' => 'color: blue', # blue
50
- '35' => 'color: magenta', # magenta
51
- '36' => 'color: cyan', # cyan
52
- '37' => 'color: white', # white
53
- '40' => 'background-color: black', # on black
54
- '41' => 'background-color: red', # on red
55
- '42' => 'background-color: green', # on green
56
- '43' => 'background-color: yellow', # on yellow
57
- '44' => 'background-color: blue', # on blue
58
- '45' => 'background-color: magenta', # on magenta
59
- '46' => 'background-color: cyan', # on cyan
60
- '47' => 'background-color: white' # on white
35
+ '0' => nil, # clear
36
+ '1' => 'font-weight: bold', # bold
37
+ '2' => '', # dark
38
+ '3' => 'font-style: italic', # italic -- not widely implemented
39
+ '4' => 'text-decoration: underline', # underline
40
+ '5' => 'text-decoration: blink', # blink
41
+ '6' => 'text-decoration: blink', # rapid blink -- not widely implemented
42
+ '7' => '', # reverse
43
+ '8' => 'opacity: 0', # concealed
44
+ '9' => 'text-decoration: line-through', # strikethrough -- not widely implemented
45
+ '22' => 'font-weight: normal', # bold off
46
+ '23' => 'font-style: normal', # italic off
47
+ '24' => 'text-decoration: none', # underline off
48
+ '25' => 'text-decoration: none', # blink off
49
+ '27' => '', # reverse off
50
+ '28' => 'opacity: 1', # concealed off
51
+ '29' => 'text-decoration: none', # strikethrough off
52
+ '30' => 'color: black', # black
53
+ '31' => 'color: maroon', # red
54
+ '32' => 'color: green', # green
55
+ '33' => 'color: olive', # yellow
56
+ '34' => 'color: navy', # blue
57
+ '35' => 'color: purple', # magenta
58
+ '36' => 'color: teal', # cyan
59
+ '37' => 'color: silver', # white
60
+ '39' => 'color: silver', # default (white)
61
+ '40' => 'background-color: black', # on black
62
+ '41' => 'background-color: maroon', # on red
63
+ '42' => 'background-color: green', # on green
64
+ '43' => 'background-color: olive', # on yellow
65
+ '44' => 'background-color: navy', # on blue
66
+ '45' => 'background-color: purple', # on magenta
67
+ '46' => 'background-color: teal', # on cyan
68
+ '47' => 'background-color: silver', # on white
69
+ '49' => 'background-color: black', # on default (black)
70
+ '90' => 'color: gray', # bright black
71
+ '91' => 'color: red', # bright red
72
+ '92' => 'color: lime', # bright green
73
+ '93' => 'color: yellow', # bright yellow
74
+ '94' => 'color: blue', # bright blue
75
+ '95' => 'color: fuchsia', # bright magenta
76
+ '96' => 'color: cyan', # bright cyan
77
+ '97' => 'color: white', # bright white
78
+ '100' => 'background-color: gray', # on bright black
79
+ '101' => 'background-color: red', # on bright red
80
+ '102' => 'background-color: lime', # on bright green
81
+ '103' => 'background-color: yellow', # on bright yellow
82
+ '104' => 'background-color: blue', # on bright blue
83
+ '105' => 'background-color: fuchsia', # on bright magenta
84
+ '106' => 'background-color: cyan', # on bright cyan
85
+ '107' => 'background-color: white' # on bright white
61
86
  }
62
87
 
63
88
  ATTRIBUTES_RE = Regexp.union(*ATTRIBUTES.keys)
@@ -84,7 +109,7 @@ module Util
84
109
  end
85
110
 
86
111
  def style(attributes)
87
- STYLE % attributes.map { |code| ATTRIBUTES[code] }.join('; ')
112
+ STYLE % ATTRIBUTES.values_at(*attributes).join('; ')
88
113
  end
89
114
 
90
115
  end
@@ -4,7 +4,7 @@ module Nuggets
4
4
 
5
5
  MAJOR = 0
6
6
  MINOR = 6
7
- TINY = 4
7
+ TINY = 5
8
8
 
9
9
  class << self
10
10
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-nuggets
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
5
- prerelease: false
4
+ hash: 13
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 6
9
- - 4
10
- version: 0.6.4
9
+ - 5
10
+ version: 0.6.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jens Wille
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-12-17 00:00:00 +01:00
18
+ date: 2011-01-06 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -83,6 +83,7 @@ files:
83
83
  - lib/nuggets/numeric/to_multiple.rb
84
84
  - lib/nuggets/string/xor_mixin.rb
85
85
  - lib/nuggets/string/capitalize_first.rb
86
+ - lib/nuggets/string/evaluate_mixin.rb
86
87
  - lib/nuggets/string/evaluate.rb
87
88
  - lib/nuggets/string/wc_mixin.rb
88
89
  - lib/nuggets/string/nsub.rb
@@ -134,15 +135,15 @@ licenses: []
134
135
 
135
136
  post_install_message:
136
137
  rdoc_options:
137
- - --title
138
- - ruby-nuggets Application documentation
139
- - --main
140
- - README
141
- - --line-numbers
142
138
  - --inline-source
139
+ - --all
143
140
  - --charset
144
141
  - UTF-8
145
- - --all
142
+ - --main
143
+ - README
144
+ - --title
145
+ - ruby-nuggets Application documentation
146
+ - --line-numbers
146
147
  require_paths:
147
148
  - lib
148
149
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -166,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
166
167
  requirements: []
167
168
 
168
169
  rubyforge_project: prometheus
169
- rubygems_version: 1.3.7
170
+ rubygems_version: 1.4.1
170
171
  signing_key:
171
172
  specification_version: 3
172
173
  summary: Some extensions to the Ruby programming language.