ruby-nuggets 0.2.4.255 → 0.2.5.256

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/HEADER ADDED
@@ -0,0 +1,27 @@
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
+
data/README CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  == VERSION
4
4
 
5
- This documentation refers to ruby-nuggets version 0.2.4
5
+ This documentation refers to ruby-nuggets version 0.2.5
6
6
 
7
7
 
8
8
  == DESCRIPTION
@@ -5,6 +5,8 @@
5
5
  # - multi-line statements in irb (extract_source)
6
6
  # - polishing!
7
7
 
8
+ require 'ruby2ruby'
9
+
8
10
  module AddedMethods
9
11
 
10
12
  extend self
@@ -57,11 +59,21 @@ module AddedMethods
57
59
  1
58
60
  end
59
61
 
60
- script_lines[start, num_lines].map { |l| " #{l}" }
62
+ lines = script_lines[start, num_lines]
63
+
64
+ # try to make sure we correctly extracted the method definition
65
+ if lines.first =~ /\b#{name}\b/
66
+ lines
67
+ else
68
+ # use Ruby2Ruby as a last resort. but note that it only
69
+ # ever finds the *latest*, i.e. currently active, method
70
+ # definition, not necessarily the one we're looking for.
71
+ "#### [R2R] ####\n#{Ruby2Ruby.translate(klass, name)}"
72
+ end
61
73
  end
62
74
 
63
75
  def to_s(num_lines = nil)
64
- "# File #{file}, line #{line}\n#{extract_source(num_lines)}"
76
+ "# File #{file}, line #{line}\n#{extract_source(num_lines).map { |l| " #{l}" }}"
65
77
  end
66
78
 
67
79
  def klass
@@ -195,6 +207,15 @@ module AddedMethods
195
207
  }
196
208
  end
197
209
 
210
+ def find_one_by_name_or_class(name_or_class, conditions = {})
211
+ (name_or_class.is_a?(Class) ?
212
+ find_by_class(name_or_class) :
213
+ find_by_name(name_or_class)
214
+ ).last
215
+ end
216
+
217
+ alias_method :[], :find_one_by_name_or_class
218
+
198
219
  private
199
220
 
200
221
  def singleton_class(klass = self)
@@ -283,7 +304,7 @@ module AddedMethods
283
304
  am.update(
284
305
  :file => HISTFILENAME,
285
306
  :line => Readline::HISTORY.size,
286
- :source => Readline::HISTORY[-1]
307
+ :source => begin Readline::HISTORY[-1] rescue IndexError end
287
308
  )
288
309
  else
289
310
  file, line, _ = where(callstack).split(':')
@@ -4,7 +4,7 @@ module Nuggets
4
4
 
5
5
  MAJOR = 0
6
6
  MINOR = 2
7
- TINY = 4
7
+ TINY = 5
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.4.255
4
+ version: 0.2.5.256
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-13 00:00:00 +02:00
12
+ date: 2008-07-15 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -25,65 +25,66 @@ extra_rdoc_files:
25
25
  - README
26
26
  files:
27
27
  - lib/nuggets.rb
28
- - lib/nuggets/all.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
28
  - 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
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
+ - lib/nuggets/all.rb
41
+ - lib/nuggets/string/sub_with_md.rb
47
42
  - lib/nuggets/string/msub.rb
48
43
  - lib/nuggets/string/case.rb
49
- - lib/nuggets/string/sub_with_md.rb
50
44
  - lib/nuggets/string/evaluate.rb
45
+ - lib/nuggets/string/word_wrap.rb
51
46
  - lib/nuggets/string/nsub.rb
52
47
  - lib/nuggets/string/capitalize_first.rb
53
- - lib/nuggets/object/blank.rb
54
- - lib/nuggets/object/metaclass.rb
55
- - lib/nuggets/object/singleton_class.rb
56
- - lib/nuggets/object/eigenclass.rb
57
- - lib/nuggets/object/virtual_class.rb
58
- - lib/nuggets/object/msend.rb
59
- - lib/nuggets/numeric/limit.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
60
59
  - lib/nuggets/numeric/between.rb
61
60
  - lib/nuggets/numeric/signum.rb
61
+ - lib/nuggets/numeric/limit.rb
62
62
  - lib/nuggets/numeric/to_multiple.rb
63
- - lib/nuggets/util/dotted_decimal.rb
64
- - lib/nuggets/util/i18n.rb
63
+ - lib/nuggets/util/added_methods/init.rb
64
+ - lib/nuggets/util/added_methods.rb
65
65
  - lib/nuggets/util/ansicolor2css.rb
66
66
  - lib/nuggets/util/content_type.rb
67
- - lib/nuggets/util/added_methods.rb
68
- - lib/nuggets/util/added_methods/init.rb
69
- - lib/nuggets/enumerable/minmax.rb
70
- - lib/nuggets/enumerable/all_any_extended.rb
71
- - lib/nuggets/enumerable/agrep.rb
72
- - lib/nuggets/hash/in_order.rb
73
- - lib/nuggets/hash/insert.rb
67
+ - lib/nuggets/util/dotted_decimal.rb
68
+ - 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
74
74
  - COPYING
75
- - Rakefile
75
+ - HEADER
76
76
  - README
77
77
  - ChangeLog
78
+ - Rakefile
78
79
  has_rdoc: true
79
80
  homepage: http://prometheus.rubyforge.org/ruby-nuggets
80
81
  post_install_message:
81
82
  rdoc_options:
82
- - --all
83
+ - --line-numbers
83
84
  - --main
84
85
  - README
85
- - --line-numbers
86
86
  - --inline-source
87
+ - --all
87
88
  - --title
88
89
  - ruby-nuggets Application documentation
89
90
  - --charset