ruby-nuggets 0.2.6.257 → 0.2.7.259

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  == VERSION
4
4
 
5
- This documentation refers to ruby-nuggets version 0.2.6
5
+ This documentation refers to ruby-nuggets version 0.2.7
6
6
 
7
7
 
8
8
  == DESCRIPTION
@@ -0,0 +1,2 @@
1
+ # whatever you prefer to call it...
2
+ require File.join(File.dirname(__FILE__), 'singleton_class')
@@ -36,8 +36,10 @@ class Object
36
36
  end
37
37
 
38
38
  alias_method :virtual_class, :singleton_class
39
+ alias_method :ghost_class, :singleton_class
39
40
  alias_method :eigenclass, :singleton_class
40
41
  alias_method :metaclass, :singleton_class
42
+ alias_method :uniclass, :singleton_class
41
43
 
42
44
  end
43
45
 
@@ -0,0 +1,2 @@
1
+ # whatever you prefer to call it...
2
+ require File.join(File.dirname(__FILE__), 'singleton_class')
@@ -25,6 +25,41 @@ module Util
25
25
  end
26
26
 
27
27
  def extract_source(num_lines = nil)
28
+ lines = extract_source_from_script_lines(num_lines)
29
+
30
+ # try to make sure we correctly extracted the method definition
31
+ lines.first =~ /\b#{name}\b/ ? lines : extract_source_from_r2r || lines
32
+ end
33
+
34
+ def to_s(num_lines = nil)
35
+ str = "# File #{file}, line #{line}"
36
+
37
+ case lines = extract_source(num_lines)
38
+ when Array
39
+ num = line - 1
40
+ width = (num + lines.size).to_s.length
41
+
42
+ lines.map! { |l| "%0#{width}d: %s" % [num += 1, l] }
43
+
44
+ "#{' ' * width} #{str}\n#{lines}"
45
+ when String
46
+ "#{str}#{lines}"
47
+ else
48
+ str
49
+ end
50
+ end
51
+
52
+ def klass
53
+ self[:class]
54
+ end
55
+
56
+ def method_missing(method, *args)
57
+ has_key?(method) ? self[method] : super
58
+ end
59
+
60
+ private
61
+
62
+ def extract_source_from_script_lines(num_lines = nil)
28
63
  return unless Object.const_defined?(:SCRIPT_LINES__)
29
64
  return unless script_lines = SCRIPT_LINES__[file]
30
65
 
@@ -64,29 +99,16 @@ module Util
64
99
  1
65
100
  end
66
101
 
67
- lines = script_lines[start, num_lines]
68
-
69
- # try to make sure we correctly extracted the method definition
70
- if lines.first =~ /\b#{name}\b/ || !Object.const_defined?(:Ruby2Ruby)
71
- lines
72
- else
73
- # use Ruby2Ruby as a last resort. but note that it only
74
- # ever finds the *latest*, i.e. currently active, method
75
- # definition, not necessarily the one we're looking for.
76
- "#### [R2R] ####\n#{Ruby2Ruby.translate(klass, name)}"
77
- end
102
+ script_lines[start, num_lines]
78
103
  end
79
104
 
80
- def to_s(num_lines = nil)
81
- "# File #{file}, line #{line}\n#{extract_source(num_lines).map { |l| " #{l}" }}"
82
- end
83
-
84
- def klass
85
- self[:class]
86
- end
105
+ def extract_source_from_r2r
106
+ return unless Object.const_defined?(:Ruby2Ruby)
87
107
 
88
- def method_missing(method, *args)
89
- has_key?(method) ? self[method] : super
108
+ # use Ruby2Ruby as a last resort. but note that it only
109
+ # ever finds the *latest*, i.e. currently active, method
110
+ # definition, not necessarily the one we're looking for.
111
+ " [R2R]\n#{Ruby2Ruby.translate(klass, name)}"
90
112
  end
91
113
 
92
114
  end
@@ -207,9 +229,7 @@ module Util
207
229
 
208
230
  def find_by_name(*names)
209
231
  conditions = names.last.is_a?(Hash) ? names.pop : {}
210
- names.inject([]) { |memo, name|
211
- memo += find(conditions.merge(:name => name.to_s))
212
- }
232
+ find(conditions.merge(:name => names.map { |m| m.to_s }))
213
233
  end
214
234
 
215
235
  def find_one_by_name_or_class(name_or_class, conditions = {})
@@ -4,7 +4,7 @@ module Nuggets
4
4
 
5
5
  MAJOR = 0
6
6
  MINOR = 2
7
- TINY = 6
7
+ TINY = 7
8
8
 
9
9
  class << self
10
10
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-nuggets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6.257
4
+ version: 0.2.7.259
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jens Wille
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-07-23 00:00:00 +02:00
12
+ date: 2008-07-24 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -25,66 +25,67 @@ extra_rdoc_files:
25
25
  - README
26
26
  files:
27
27
  - lib/nuggets.rb
28
- - lib/nuggets/integer/to_binary_s.rb
29
- - lib/nuggets/integer/factorial.rb
30
- - lib/nuggets/version.rb
31
- - lib/nuggets/object/metaclass.rb
32
- - lib/nuggets/object/singleton_class.rb
33
- - lib/nuggets/object/virtual_class.rb
34
- - lib/nuggets/object/eigenclass.rb
35
- - lib/nuggets/object/blank.rb
36
- - lib/nuggets/object/msend.rb
37
- - lib/nuggets/enumerable/agrep.rb
38
- - lib/nuggets/enumerable/all_any_extended.rb
39
- - lib/nuggets/enumerable/minmax.rb
40
28
  - lib/nuggets/all.rb
41
- - lib/nuggets/string/sub_with_md.rb
29
+ - lib/nuggets/version.rb
30
+ - lib/nuggets/io/agrep.rb
31
+ - lib/nuggets/io/modes.rb
32
+ - lib/nuggets/file/which.rb
33
+ - lib/nuggets/integer/factorial.rb
34
+ - lib/nuggets/integer/to_binary_s.rb
35
+ - lib/nuggets/array/to_hash.rb
36
+ - lib/nuggets/array/shuffle.rb
37
+ - lib/nuggets/array/format.rb
38
+ - lib/nuggets/array/in_order.rb
39
+ - lib/nuggets/array/combination.rb
40
+ - lib/nuggets/array/flatten_once.rb
41
+ - lib/nuggets/array/rand.rb
42
+ - lib/nuggets/array/monotone.rb
43
+ - lib/nuggets/uri/exist.rb
44
+ - lib/nuggets/uri/content_type.rb
45
+ - lib/nuggets/proc/bind.rb
46
+ - lib/nuggets/string/word_wrap.rb
42
47
  - lib/nuggets/string/msub.rb
43
48
  - lib/nuggets/string/case.rb
49
+ - lib/nuggets/string/sub_with_md.rb
44
50
  - lib/nuggets/string/evaluate.rb
45
- - lib/nuggets/string/word_wrap.rb
46
51
  - lib/nuggets/string/nsub.rb
47
52
  - lib/nuggets/string/capitalize_first.rb
48
- - lib/nuggets/hash/in_order.rb
49
- - lib/nuggets/hash/insert.rb
50
- - lib/nuggets/proc/bind.rb
51
- - lib/nuggets/array/rand.rb
52
- - lib/nuggets/array/to_hash.rb
53
- - lib/nuggets/array/flatten_once.rb
54
- - lib/nuggets/array/in_order.rb
55
- - lib/nuggets/array/shuffle.rb
56
- - lib/nuggets/array/monotone.rb
57
- - lib/nuggets/array/format.rb
58
- - lib/nuggets/array/combination.rb
53
+ - lib/nuggets/object/blank.rb
54
+ - lib/nuggets/object/metaclass.rb
55
+ - lib/nuggets/object/uniclass.rb
56
+ - lib/nuggets/object/singleton_class.rb
57
+ - lib/nuggets/object/ghost_class.rb
58
+ - lib/nuggets/object/eigenclass.rb
59
+ - lib/nuggets/object/virtual_class.rb
60
+ - lib/nuggets/object/msend.rb
61
+ - lib/nuggets/numeric/limit.rb
59
62
  - lib/nuggets/numeric/between.rb
60
63
  - lib/nuggets/numeric/signum.rb
61
- - lib/nuggets/numeric/limit.rb
62
64
  - lib/nuggets/numeric/to_multiple.rb
63
- - lib/nuggets/util/added_methods/init.rb
64
- - lib/nuggets/util/added_methods.rb
65
- - lib/nuggets/util/ansicolor2css.rb
66
- - lib/nuggets/util/content_type.rb
67
65
  - lib/nuggets/util/dotted_decimal.rb
68
66
  - lib/nuggets/util/i18n.rb
69
- - lib/nuggets/file/which.rb
70
- - lib/nuggets/uri/content_type.rb
71
- - lib/nuggets/uri/exist.rb
72
- - lib/nuggets/io/modes.rb
73
- - lib/nuggets/io/agrep.rb
67
+ - lib/nuggets/util/ansicolor2css.rb
68
+ - lib/nuggets/util/content_type.rb
69
+ - lib/nuggets/util/added_methods.rb
70
+ - lib/nuggets/util/added_methods/init.rb
71
+ - lib/nuggets/enumerable/minmax.rb
72
+ - lib/nuggets/enumerable/all_any_extended.rb
73
+ - lib/nuggets/enumerable/agrep.rb
74
+ - lib/nuggets/hash/in_order.rb
75
+ - lib/nuggets/hash/insert.rb
74
76
  - COPYING
75
- - HEADER
77
+ - Rakefile
76
78
  - README
77
79
  - ChangeLog
78
- - Rakefile
79
80
  has_rdoc: true
80
81
  homepage: http://prometheus.rubyforge.org/ruby-nuggets
81
82
  post_install_message:
82
83
  rdoc_options:
83
- - --line-numbers
84
+ - --all
84
85
  - --main
85
86
  - README
87
+ - --line-numbers
86
88
  - --inline-source
87
- - --all
88
89
  - --title
89
90
  - ruby-nuggets Application documentation
90
91
  - --charset
data/HEADER DELETED
@@ -1,27 +0,0 @@
1
- #--
2
- ###############################################################################
3
- # #
4
- # A component of ruby-nuggets, some extensions to the Ruby programming #
5
- # language. #
6
- # #
7
- # Copyright (C) 2007-2008 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
-