rmtools 1.1.4 → 1.1.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. data/History.txt +9 -0
  2. data/Manifest.txt +1 -0
  3. data/README.txt +2 -2
  4. data/Rakefile +2 -2
  5. data/lib/rmtools.rb +4 -2
  6. data/lib/rmtools/b.rb +1 -0
  7. data/lib/rmtools/console.rb +2 -1
  8. data/lib/rmtools/console/coloring.rb +4 -3
  9. data/lib/rmtools/console/highlight.rb +2 -1
  10. data/lib/rmtools/console/printing.rb +1 -0
  11. data/lib/rmtools/conversions.rb +2 -1
  12. data/lib/rmtools/conversions/enum.rb +1 -0
  13. data/lib/rmtools/conversions/int.rb +1 -0
  14. data/lib/rmtools/conversions/string.rb +1 -0
  15. data/lib/rmtools/core.rb +2 -1
  16. data/lib/rmtools/core/aliases.rb +1 -0
  17. data/lib/rmtools/core/arguments.rb +1 -0
  18. data/lib/rmtools/core/class.rb +1 -0
  19. data/lib/rmtools/core/deprecation.rb +1 -0
  20. data/lib/rmtools/core/js.rb +13 -13
  21. data/lib/rmtools/core/kernel.rb +1 -0
  22. data/lib/rmtools/core/module.rb +15 -10
  23. data/lib/rmtools/core/proc.rb +4 -0
  24. data/lib/rmtools/core/regexp.rb +1 -0
  25. data/lib/rmtools/core/string_compliance.rb +36 -8
  26. data/lib/rmtools/db.rb +2 -1
  27. data/lib/rmtools/db/active_record.rb +1 -0
  28. data/lib/rmtools/debug.rb +2 -1
  29. data/lib/rmtools/debug/binding.rb +7 -6
  30. data/lib/rmtools/debug/highlight.rb +3 -2
  31. data/lib/rmtools/debug/logging.rb +3 -3
  32. data/lib/rmtools/debug/observing.rb +6 -1
  33. data/lib/rmtools/debug/timer.rb +2 -1
  34. data/lib/rmtools/debug/traceback.rb +3 -2
  35. data/lib/rmtools/debug_notrace.rb +2 -1
  36. data/lib/rmtools/enumerable.rb +2 -1
  37. data/lib/rmtools/enumerable/array.rb +1 -1
  38. data/lib/rmtools/enumerable/array_iterators.rb +2 -1
  39. data/lib/rmtools/enumerable/common.rb +1 -0
  40. data/lib/rmtools/enumerable/hash.rb +1 -0
  41. data/lib/rmtools/enumerable/object_space.rb +2 -1
  42. data/lib/rmtools/experimental.rb +2 -1
  43. data/lib/rmtools/experimental/blackhole.rb +1 -0
  44. data/lib/rmtools/experimental/dumps.rb +1 -0
  45. data/lib/rmtools/experimental/numeric.rb +1 -0
  46. data/lib/rmtools/experimental/rails_backtrace.rb +1 -0
  47. data/lib/rmtools/experimental/tree.rb +1 -0
  48. data/lib/rmtools/fs.rb +2 -1
  49. data/lib/rmtools/fs/dir.rb +2 -1
  50. data/lib/rmtools/fs/file.rb +2 -1
  51. data/lib/rmtools/fs/io.rb +9 -11
  52. data/lib/rmtools/fs/tools.rb +2 -1
  53. data/lib/rmtools/functional.rb +2 -1
  54. data/lib/rmtools/functional/fold.rb +1 -0
  55. data/lib/rmtools/functional/string_to_proc.rb +1 -0
  56. data/lib/rmtools/functional/unfold.rb +1 -0
  57. data/lib/rmtools/install.rb +1 -1
  58. data/lib/rmtools/ip.rb +2 -1
  59. data/lib/rmtools/ip/numeric.rb +1 -0
  60. data/lib/rmtools/ip/string.rb +1 -0
  61. data/lib/rmtools/lang.rb +2 -1
  62. data/lib/rmtools/lang/ansi.rb +1 -0
  63. data/lib/rmtools/lang/cyrillic.rb +2 -1
  64. data/lib/rmtools/lang/regexp.rb +2 -1
  65. data/lib/rmtools/lang/shortcuts.rb +2 -1
  66. data/lib/rmtools/load.rb +3 -2
  67. data/lib/rmtools/rand.rb +2 -1
  68. data/lib/rmtools/rand/array.rb +2 -1
  69. data/lib/rmtools/rand/enum.rb +1 -0
  70. data/lib/rmtools/rand/range.rb +2 -1
  71. data/lib/rmtools/rand/string.rb +1 -1
  72. data/lib/rmtools/require.rb +7 -6
  73. data/lib/rmtools/text.rb +2 -1
  74. data/lib/rmtools/text/string_parse.rb +4 -3
  75. data/lib/rmtools/text/string_simple.rb +1 -0
  76. data/lib/rmtools/text/string_split.rb +3 -2
  77. data/lib/rmtools/text/textilize.rb +1 -0
  78. data/lib/rmtools/time.rb +2 -1
  79. data/lib/rmtools/time/global.rb +1 -0
  80. data/lib/rmtools/time/russian.rb +1 -0
  81. data/lib/rmtools/xml.rb +2 -1
  82. data/lib/rmtools/xml/document.rb +1 -0
  83. data/lib/rmtools/xml/finders.rb +2 -1
  84. data/lib/rmtools/xml/libxml.rb +3 -2
  85. data/lib/rmtools/xml/node.rb +1 -0
  86. data/lib/rmtools/xml/string.rb +2 -1
  87. data/lib/rmtools/xml/xpath.rb +1 -0
  88. data/lib/rmtools_no_b.rb +2 -0
  89. data/lib/rmtools_nodebug.rb +3 -1
  90. data/lib/rmtools_notrace.rb +4 -2
  91. metadata +6 -5
data/History.txt CHANGED
@@ -7,3 +7,12 @@
7
7
  * Fixed some bugs
8
8
  * Divided by semantics
9
9
  * Compatible with ruby 1.8.7 (2010-08-16 patchlevel 302)
10
+
11
+ === Version 1.1.6
12
+
13
+ * Rewrited few functions
14
+ * Fixed bug with RDoc and RI
15
+ * Compatible with 1.9
16
+ * Binding#start_interaction and RMTools::Observer for debugging purposes
17
+ * To require any file from lib/rmtools now RMTools::require is used
18
+ * In order to not overload Rails apps initialization tracing is lightened and gem now may be also required as "rmtools_nodebug" and "rmtools_notrace"
data/Manifest.txt CHANGED
@@ -93,6 +93,7 @@ lib/rmtools/conversions/int.rb
93
93
  lib/rmtools/enumerable.rb
94
94
  lib/rmtools_notrace.rb
95
95
  lib/rmtools_nodebug.rb
96
+ lib/rmtools_no_b.rb
96
97
  ./Rakefile
97
98
  ./Manifest.txt
98
99
  ./License.txt
data/README.txt CHANGED
@@ -1,5 +1,5 @@
1
- Copyright (c) 2010
2
- Anonymous <tinbka@gmail.com>
1
+ Copyright (c) 2010-2011
2
+ Shinku <tinbka@gmail.com>
3
3
 
4
4
  This work is licensed under the same license as Ruby language.
5
5
 
data/Rakefile CHANGED
@@ -2,11 +2,11 @@ require 'rake'
2
2
  require 'lib/rmtools/install'
3
3
  compile_manifest
4
4
 
5
- RMTOOLS_VERSION = '1.1.4'
5
+ RMTOOLS_VERSION = '1.1.6'
6
6
  begin
7
7
  require 'hoe'
8
8
  config = Hoe.spec 'rmtools' do |h|
9
- h.developer("Shinku Templar", "tinbka@gmail.com")
9
+ h.developer("Shinku", "tinbka@gmail.com")
10
10
 
11
11
  h.summary = 'Yet another Ruby applied framework'
12
12
  h.description = h.paragraphs_of('README.txt', 2..3).join("\n\n")
data/lib/rmtools.rb CHANGED
@@ -1,4 +1,6 @@
1
+ # encoding: utf-8
1
2
  SCRIPT_LINES__ = {} unless defined? SCRIPT_LINES__
2
3
  require 'rmtools/load'
3
- require_with_path 'debug'
4
- require_with_path 'console'
4
+ RMTools::require 'b'
5
+ RMTools::require 'debug'
6
+ RMTools::require 'console'
data/lib/rmtools/b.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  # {obj.b -> self or false} with python logic
2
3
  # Since 2.3.8 active_support has analogue: #presence
3
4
 
@@ -1 +1,2 @@
1
- require_with_path __FILE__, '*'
1
+ # encoding: utf-8
2
+ RMTools::require __FILE__, '*'
@@ -1,4 +1,5 @@
1
- require_with_path 'enumerable/hash'
1
+ # encoding: utf-8
2
+ RMTools::require 'enumerable/hash'
2
3
 
3
4
  module RMTools
4
5
 
@@ -58,12 +59,12 @@ module RMTools
58
59
  Painter = Coloring.new
59
60
  ['sub', 'gsub', 'sub!', 'gsub!'].each {|m|
60
61
  Coloring.module_eval "
61
- def #{m.sub 'sub', 'hl'} str, pattern, color=:red_bold
62
+ def #{m.sub('sub') {'hl'}} str, pattern, color=:red_bold
62
63
  str.#{m}(pattern) {|word| send color, word}
63
64
  end
64
65
  "
65
66
  module_eval "
66
- def #{m.sub 'sub', 'hl'} str, pattern, color=:red_bold
67
+ def #{m.sub('sub') {'hl'}} str, pattern, color=:red_bold
67
68
  str.#{m}(pattern) {|word| Painter.send color, word}
68
69
  end
69
70
  "
@@ -1,4 +1,5 @@
1
- require_with_path 'console/coloring'
1
+ # encoding: utf-8
2
+ RMTools::require 'console/coloring'
2
3
 
3
4
  class String
4
5
 
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  module RMTools
2
3
 
3
4
  # transparent print: print text (or object details) and erase it
@@ -1 +1,2 @@
1
- require_with_path __FILE__, '*'
1
+ # encoding: utf-8
2
+ RMTools::require __FILE__, '*'
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require 'cgi'
2
3
 
3
4
  module Enumerable
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  class Integer
2
3
 
3
4
  def kb; self*1024 end
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require 'cgi'
2
3
 
3
4
  class String
data/lib/rmtools/core.rb CHANGED
@@ -1 +1,2 @@
1
- require_with_path __FILE__, '*'
1
+ # encoding: utf-8
2
+ RMTools::require __FILE__, '*'
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  class Object
2
3
  alias :resto :respond_to?
3
4
  alias :requrie :require # most frequent typo, lol
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  class Array
2
3
 
3
4
  # a, b, opts = [<hash1>].fetch_opts([<hash2>, <object1>]) may work unintuitive:
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  class Class
2
3
 
3
4
  # define python-style initializer
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  class Object
2
3
  # class Klass
3
4
  # def old_method *argv
@@ -26,20 +26,20 @@ end
26
26
  class String
27
27
  if !method_defined? :plus
28
28
  alias :plus :+
29
- end
30
-
31
- # immutable:
32
- # '123' + 95 # => '12395'
33
- # '123'.plus 95 # => raise TypeError
34
- # mutable:
35
- # '123' << 95 # => '12395'
36
- # '123'.concat 95 # => '123_'
37
- def +(str)
38
- plus str.to_s
39
- end
40
29
 
41
- def <<(str)
42
- concat str.to_s
30
+ # immutable:
31
+ # '123' + 95 # => '12395'
32
+ # '123'.plus 95 # => raise TypeError
33
+ # mutable:
34
+ # '123' << 95 # => '12395'
35
+ # '123'.concat 95 # => '123_'
36
+ def +(str)
37
+ plus str.to_s
38
+ end
39
+
40
+ def <<(str)
41
+ concat str.to_s
42
+ end
43
43
  end
44
44
 
45
45
  end
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  module Kernel
2
3
 
3
4
  # re-require
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require 'active_support/core_ext/module/remove_method'
2
3
 
3
4
  class Module
@@ -47,11 +48,13 @@ private
47
48
  # end
48
49
  def decorate f1, f2
49
50
  f1_clone = f1.to_s.dup
50
- f1_clone.bump! '_' while method_defined? f1_clone.to_sym
51
- class_eval do
52
- alias :"#{f1_clone}" :"#{f1}"
53
- define_method(f1) {|*args| send(f2, *args, &method(f1_clone))}
54
- end
51
+ f1_clone.bump! '_' while private_method_defined? f1_clone.to_sym
52
+ class_eval(<<-EVAL, __FILE__, __LINE__+1
53
+ alias #{f1_clone} #{f1}
54
+ private :#{f1_clone}
55
+ def #{f1}(*args) #{f2}(*args, &method(:#{f1_clone})) end
56
+ EVAL
57
+ )
55
58
  end
56
59
 
57
60
  # some FP, example:
@@ -71,11 +74,13 @@ private
71
74
  # end
72
75
  def decorated_fof f1, f2
73
76
  f1_clone = f1.to_s.dup
74
- f1_clone.bump! '_' while method_defined? f1_clone
75
- class_eval do
76
- alias :"#{f1_clone}" :"#{f1}"
77
- define_method(f1) {send(f2, &method(f1_clone))}
78
- end
77
+ f1_clone.bump! '_' while private_method_defined? f1_clone
78
+ class_eval(<<-EVAL, __FILE__, __LINE__+1
79
+ alias #{f1_clone} #{f1}
80
+ private :#{f1_clone}
81
+ def #{f1}() #{f2}(&method(:#{f1_clone})) end
82
+ EVAL
83
+ )
79
84
  end
80
85
 
81
86
  end
@@ -15,4 +15,8 @@ class Proc
15
15
  proc
16
16
  end
17
17
 
18
+ if RUBY_VERSION < '1.9'
19
+ def source_location; str.match(/([^@]+):(\d+)>$/)[1..2] end
20
+ end
21
+
18
22
  end
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  class Regexp
2
3
 
3
4
  def | re
@@ -1,31 +1,59 @@
1
+ # encoding: utf-8
1
2
  class String
2
3
 
3
4
  if RUBY_VERSION < "1.9"
4
5
  def ord; self[0] end
6
+
7
+ # TODO?
8
+ # [g]sub[!] in ruby 1.8 takes the second arg which can operate \1, \2 etc keys as if it were MatchData parts
9
+ # Though, in ruby 1.9 it ignores (without exception) the second arg and only pay attention to block. I can emulate ruby 1.8 second-arg-behaviour but
10
+ # block passed to old method must be of the same context as that method's caller
11
+ # in order to $~, $1 and such variables to work (and blocks with them are actualy used i.e. in Readline).
12
+ # So now I'm afraid it useless to redefine these methods for 1.9 but I'll try some to hack it in C-ext
13
+ =begin
5
14
  else
6
- # BUGFIX?
7
15
  alias :sub19 :sub
8
16
  alias :sub19! :sub!
9
17
  alias :gsub19 :gsub
10
18
  alias :gsub19! :gsub!
11
19
 
20
+ def sub a,b=nil,&c
21
+ if b
22
+ if b=~/\\\d/
23
+ b = b.gsub19(/\\\d/) {|m| "\#$#{m[1]}"}
24
+ sub19(a) {eval "\"#{b}\""}
25
+ else sub19(a) {b} end
26
+ else gsub19(a, &c) end
27
+ end
28
+
12
29
  def sub! a,b=nil,&c
13
30
  if b
14
31
  if b=~/\\\d/
15
- b = b.sub19!(/\\\d/) {|m| "\#{$#{m[1,1]}}"}
32
+ b = b.gsub19(/\\\d/) {|m| "\#$#{m[1]}"}
16
33
  sub19!(a) {eval "\"#{b}\""}
17
34
  else sub19!(a) {b} end
18
- else sub19! a,&c end
35
+ else sub19!(a, &c) end
19
36
  end
20
37
 
21
- def sub a,b=nil,&c
38
+ def gsub a,b=nil,&c
22
39
  if b
23
40
  if b=~/\\\d/
24
- b = b.sub19(/\\\d/) {|m| "\#{$#{m[1,1]}}"}
25
- sub19(a) {eval "\"#{b}\""}
26
- else sub19(a) {b} end
27
- else sub19 a,&c end
41
+ b = b.gsub19(/\\\d/) {|m| "\#$#{m[1]}"}
42
+ gsub19(a) {eval "\"#{b}\""}
43
+ else gsub19(a) {b} end
44
+ else gsub19(a, &c) end
45
+ end
46
+
47
+ def gsub! a,b=nil,&c
48
+ if b
49
+ if b=~/\\\d/
50
+ b = b.gsub19(/\\\d/) {|m| "\#$#{m[1]}"}
51
+ p a
52
+ gsub19!(a) {p "\"#{b}\""; p $~; p eval "\"#{b}\""; p eval "\"#{b}\""}
53
+ else gsub19!(a) {b} end
54
+ else gsub19!(a, &c) end
28
55
  end
56
+ =end
29
57
  end
30
58
 
31
59
  end
data/lib/rmtools/db.rb CHANGED
@@ -1,7 +1,8 @@
1
+ # encoding: utf-8
1
2
  begin
2
3
  require 'active_record'
3
4
  ActiveRecord::Base
4
- require_with_path __FILE__, 'active_record'
5
+ RMTools::require __FILE__, 'active_record'
5
6
  rescue Exception
6
7
  nil
7
8
  end
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require 'active_record'
2
3
 
3
4
  module ActiveRecord
data/lib/rmtools/debug.rb CHANGED
@@ -1 +1,2 @@
1
- require_with_path __FILE__, '*'
1
+ # encoding: utf-8
2
+ RMTools::require __FILE__, '*'
@@ -1,5 +1,6 @@
1
- require_with_path 'debug/logging'
2
- require_with_path 'debug/present'
1
+ # encoding: utf-8
2
+ RMTools::require 'debug/logging'
3
+ RMTools::require 'debug/present'
3
4
 
4
5
  class Binding
5
6
 
@@ -41,16 +42,16 @@ class Binding
41
42
  # end
42
43
  def start_interaction(sandbox=true)
43
44
  $__env__ = inspect_env
45
+ puts "Caller trace:"
44
46
  Kernel.puts RMTools.format_trace(caller(2)).join("\n")
47
+ puts "Environment:"
45
48
  $__env__.present
46
49
  $__binding__ = self
47
- if defined? SCRIPT_LINES__
48
- SCRIPT_LINES__['(irb#1)'] = []
50
+ if defined? SCRIPT_LINES__ and (file = caller(0)[0].parse(:caller).file) =~ /^\(irb/
51
+ SCRIPT_LINES__["(#{file[1..-2].next_version '#'})"] = []
49
52
  end
50
53
 
51
- $log << "entering irb"
52
54
  $__MAIN__.irb$__binding__
53
- $log << "exiting irb"
54
55
 
55
56
  if sandbox
56
57
  self.eval($__env__.keys.map {|k, v| "#{k} = $__env__[#{k.inspect}]" if k != 'self'} * '; ')
@@ -1,4 +1,5 @@
1
- require_with_path 'console/coloring'
1
+ # encoding: utf-8
2
+ RMTools::require 'console/coloring'
2
3
 
3
4
  module RMTools
4
5
 
@@ -17,7 +18,7 @@ end
17
18
  class Proc
18
19
 
19
20
  def inspect
20
- "#{str=to_s}: #{@string ? Painter.green(@string) : "\n"+RMTools.highlighted_line(*str.match(/([^@]+):(\d+)>$/)[1..2])}"
21
+ "#{str=to_s}: #{@string ? Painter.green(@string) : "\n"+RMTools.highlighted_line(*source_location)}"
21
22
  end
22
23
 
23
24
  end
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
- require_with_path 'console/coloring'
3
- require_with_path 'text/string_parse'
4
- require_with_path 'b'
2
+ RMTools::require 'console/coloring'
3
+ RMTools::require 'text/string_parse'
4
+ RMTools::require 'b'
5
5
 
6
6
  module RMTools
7
7
 
@@ -1,7 +1,12 @@
1
- require_with_path 'debug/binding'
1
+ # encoding: utf-8
2
+ RMTools::require 'debug/binding'
2
3
  require 'active_support/core_ext/class'
3
4
 
4
5
  module RMTools
6
+
7
+ # Makes binding stack as well as caller stack,
8
+ # which can be used to catch errors and directly operate within context
9
+ # in which error has been occured.
5
10
  class Observer
6
11
  cattr_reader :ignore_path, :ignore_gems, :ignore_names, :ignore_all_gems
7
12
  cattr_accessor :keep_binding_stack
@@ -1,4 +1,5 @@
1
- require_with_path 'console/coloring'
1
+ # encoding: utf-8
2
+ RMTools::require 'console/coloring'
2
3
 
3
4
  module RMTools
4
5
 
@@ -1,5 +1,6 @@
1
- require_with_path 'debug/highlight'
2
- require_with_path 'debug/logging'
1
+ # encoding: utf-8
2
+ RMTools::require 'debug/highlight'
3
+ RMTools::require 'debug/logging'
3
4
 
4
5
  module RMTools
5
6
 
@@ -1 +1,2 @@
1
- require_with_path 'debug', '{binding,logging,present,timer}'
1
+ # encoding: utf-8
2
+ RMTools::require 'debug', '{binding,logging,present,timer}'
@@ -1 +1,2 @@
1
- require_with_path __FILE__, '*'
1
+ # encoding: utf-8
2
+ RMTools::require __FILE__, '*'
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
  require 'active_support/core_ext/array'
3
- require_with_path 'functional/fold'
3
+ RMTools::require 'functional/fold'
4
4
 
5
5
  class Array
6
6
 
@@ -1,4 +1,5 @@
1
- require_with_path 'enumerable/array'
1
+ # encoding: utf-8
2
+ RMTools::require 'enumerable/array'
2
3
 
3
4
  unless defined? RMTools::Iterators
4
5
 
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require 'set'
2
3
 
3
4
  module Enumerable
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require 'active_support/core_ext/hash'
2
3
 
3
4
  class Hash
@@ -1,4 +1,5 @@
1
- require_with_path 'enumerable/common'
1
+ # encoding: utf-8
2
+ RMTools::require 'enumerable/common'
2
3
 
3
4
  module ObjectSpace
4
5
  extend Enumerable
@@ -1 +1,2 @@
1
- require_with_path __FILE__, '*'
1
+ # encoding: utf-8
2
+ RMTools::require __FILE__, '*'
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  class BlackHole
2
3
 
3
4
  # abc = BlackHole.new
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  class Array
2
3
 
3
4
  def dump(depth=5)
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  class Float
2
3
 
3
4
  def partial(range=100)
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  module RMTools
2
3
  def highlighted_line_html file, line
3
4
  if File.file?(file)
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  class Array
2
3
 
3
4
  def to_tree(set_keys=false)
data/lib/rmtools/fs.rb CHANGED
@@ -1 +1,2 @@
1
- require_with_path __FILE__, '*'
1
+ # encoding: utf-8
2
+ RMTools::require __FILE__, '*'
@@ -1,4 +1,5 @@
1
- require_with_path 'fs/file'
1
+ # encoding: utf-8
2
+ RMTools::require 'fs/file'
2
3
 
3
4
  class Dir
4
5
 
@@ -1,4 +1,5 @@
1
- require_with_path 'fs/io'
1
+ # encoding: utf-8
2
+ RMTools::require 'fs/io'
2
3
 
3
4
  class File
4
5
 
data/lib/rmtools/fs/io.rb CHANGED
@@ -15,22 +15,20 @@ module RMTools
15
15
 
16
16
  def rw(df, value=nil)
17
17
  return false if value.nil?
18
- df.gsub!('\\', '/')
18
+ df = df.tr '\\', '/'
19
19
  path = File.dirname(df)
20
20
  FileUtils.mkpath(path) if !File.directory?(path)
21
- mode = RUBY_VERSION > '1.9' ? :wb : 'wb'
22
- File.open(df, mode) {|f| f << value}
21
+ File.open(df, File::CREAT|File::WRONLY|File::TRUNC) {|f| f << value}
23
22
  value.size
24
23
  end
25
24
 
26
25
  def write(df, value='', pos=0)
27
26
  return false if value.nil?
28
- df.gsub!('\\', '/')
27
+ df = df.tr '\\', '/'
29
28
  path = File.dirname(df)
30
29
  FileUtils.mkpath(path) if !File.directory?(path)
31
30
  if pos == 0
32
- mode = RUBY_VERSION > '1.9' ? :ab : 'ab'
33
- File.open(df, mode) {|f| f << value}
31
+ File.open(df, File::CREAT|File::WRONLY|File::APPEND) {|f| f << value}
34
32
  else
35
33
  if pos < 0
36
34
  if !File.file?(df)
@@ -40,17 +38,17 @@ module RMTools
40
38
  end
41
39
  pos = size - pos
42
40
  end
43
- File.open(df, 'r+') {|f| f.pos = pos; f << value}
41
+ File.open(df, File::CREAT|File::WRONLY) {|f| f.pos = pos; f << value}
44
42
  end
45
43
  value.size
46
44
  end
47
45
 
48
- def read(df, mode=(RUBY_VERSION > '1.9' ? :rb : 'rb'))
49
- df.gsub!('\\', '/')
46
+ def read(df)
47
+ df = df.tr '\\', '/'
50
48
  if File.file?(df)
51
- File.open(df, mode) {|f| f.read}
49
+ File.open(df, File::RDONLY) {|f| f.read}
52
50
  else
53
- STDERR.puts "#{df} is missed!"
51
+ STDERR.puts "couldn't read from #{df.inspect}; file missed"
54
52
  end
55
53
  end
56
54
 
@@ -1,4 +1,5 @@
1
- require_with_path 'fs/io'
1
+ # encoding: utf-8
2
+ RMTools::require 'fs/io'
2
3
 
3
4
  module RMTools
4
5
 
@@ -1 +1,2 @@
1
- require_with_path __FILE__, '*'
1
+ # encoding: utf-8
2
+ RMTools::require __FILE__, '*'
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  module Enumerable
2
3
 
3
4
  def foldl(o, m=nil)
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  # String#to_proc
2
3
  #
3
4
  # See http://weblog.raganwald.com/2007/10/stringtoproc.html ( Subscribe in a reader)
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  class Object
2
3
 
3
4
  # &splitter must return a pair
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
  require File.expand_path('require', File.dirname(__FILE__))
3
- require_with_path 'fs'
3
+ RMTools::require 'fs'
4
4
  require 'digest/md5'
5
5
 
6
6
  def ext_files_not_modified(ext_name='rmtools', version='\d')
data/lib/rmtools/ip.rb CHANGED
@@ -1 +1,2 @@
1
- require_with_path __FILE__, '*'
1
+ # encoding: utf-8
2
+ RMTools::require __FILE__, '*'
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  class Integer
2
3
 
3
4
  def from_ip
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require 'scanf'
2
3
 
3
4
  class String
data/lib/rmtools/lang.rb CHANGED
@@ -1 +1,2 @@
1
- require_with_path __FILE__, '*'
1
+ # encoding: utf-8
2
+ RMTools::require __FILE__, '*'
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require 'iconv'
2
3
 
3
4
  module RMTools
@@ -1,4 +1,5 @@
1
- require_with_path 'lang/ansi'
1
+ # encoding: utf-8
2
+ RMTools::require 'lang/ansi'
2
3
 
3
4
  class String
4
5
  include RMTools::Cyrillic
@@ -1,4 +1,5 @@
1
- require_with_path 'lang/cyrillic'
1
+ # encoding: utf-8
2
+ RMTools::require 'lang/cyrillic'
2
3
 
3
4
  class Regexp
4
5
 
@@ -1,4 +1,5 @@
1
- require_with_path 'lang/ansi'
1
+ # encoding: utf-8
2
+ RMTools::require 'lang/ansi'
2
3
 
3
4
  class String
4
5
  # Actually, for short strings and 1251<->65001 it's much faster to use predefined ANSI2UTF and UTF2ANSI procs
data/lib/rmtools/load.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require 'active_support'
2
3
 
3
4
  module RMTools
@@ -5,11 +6,11 @@ module RMTools
5
6
  VERSION = IO.read(File.join dir, '..', '..', 'Rakefile').match(/RMTOOLS_VERSION = '(.+?)'/)[1]
6
7
 
7
8
  require File.expand_path('require', dir)
8
- [ 'core', 'enumerable', 'text', 'b', 'time', 'functional',
9
+ [ 'core', 'enumerable', 'text', 'time', 'functional',
9
10
  'conversions', 'ip', 'lang', 'rand',
10
11
  'fs', 'db', 'xml',
11
12
  '../rmtools.so'
12
- ].each {|file| require_with_path file}
13
+ ].each {|file| RMTools::require file}
13
14
  end
14
15
 
15
16
  # Comment out in case of any method conflicts
data/lib/rmtools/rand.rb CHANGED
@@ -1 +1,2 @@
1
- require_with_path __FILE__, '*'
1
+ # encoding: utf-8
2
+ RMTools::require __FILE__, '*'
@@ -1,4 +1,5 @@
1
- require_with_path 'rand/enum'
1
+ # encoding: utf-8
2
+ RMTools::require 'rand/enum'
2
3
 
3
4
  module RMTools
4
5
 
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  module Enumerable
2
3
 
3
4
  def rand
@@ -1,4 +1,5 @@
1
- require_with_path 'rand/enum'
1
+ # encoding: utf-8
2
+ RMTools::require 'rand/enum'
2
3
 
3
4
  class Range
4
5
 
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
- require_with_path 'lang/ansi'
2
+ RMTools::require 'lang/ansi'
3
3
 
4
4
  module RMTools
5
5
  begin
@@ -1,13 +1,14 @@
1
- module Kernel
2
- # ` require_with_path __FILE__, "*" ' requires all ruby files from dir named as file
3
- # ` require_with_path "folder", "file" ' requires file.rb from dir `folder' in working directory
4
- # `require_with_path "file" ' requires 'file.rb' from working directory
5
- def require_with_path(location, mask=nil)
1
+ # encoding: utf-8
2
+ module RMTools
3
+ # ` RMTools::require __FILE__, "*" ' requires all ruby files from dir named as file
4
+ # ` RMTools::require "folder", "file" ' requires file.rb from dir `folder' in working directory
5
+ # `RMTools::require "file" ' requires 'file.rb' from working directory
6
+ def self.require(location, mask=nil)
6
7
  if !mask
7
8
  location, mask = File.dirname(__FILE__), location # /path/to/gems/rmtools
8
9
  end
9
10
  mask += '.rb' unless mask['.']
10
11
  location = File.expand_path(location).chomp('.rb')
11
- Dir.glob(File.join location, mask) {|file| require file}
12
+ Dir.glob(File.join location, mask) {|file| Kernel.require file}
12
13
  end
13
14
  end
data/lib/rmtools/text.rb CHANGED
@@ -1 +1,2 @@
1
- require_with_path __FILE__, '*'
1
+ # encoding: utf-8
2
+ RMTools::require __FILE__, '*'
@@ -1,4 +1,5 @@
1
- require_with_path 'conversions/string'
1
+ # encoding: utf-8
2
+ RMTools::require 'conversions/string'
2
3
 
3
4
  class String
4
5
  CALLER_RE = %r{^(.*?([^/\\]+?))#{ # ( path ( file ) )
@@ -48,12 +49,12 @@ class String
48
49
  end
49
50
 
50
51
  def parseuri
51
- deprecation "Use String#parse(:uri) instead."
52
+ deprecate_method "Use String#parse(:uri) instead."
52
53
  parse :uri
53
54
  end
54
55
 
55
56
  def parseip(range=nil)
56
- deprecation "Use String#parse(:ip#{'_range' if range}) instead."
57
+ deprecate_method "Use String#parse(:ip#{'_range' if range}) instead."
57
58
  parse :"ip#{'_range' if range}"
58
59
  end
59
60
 
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  class String
2
3
 
3
4
  def inline
@@ -1,5 +1,6 @@
1
- require_with_path 'text/string_simple'
2
- require_with_path 'enumerable/array_iterators'
1
+ # encoding: utf-8
2
+ RMTools::require 'text/string_simple'
3
+ RMTools::require 'enumerable/array_iterators'
3
4
 
4
5
  class String
5
6
 
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  module RMTools
2
3
 
3
4
  def dump_recurse(obj, depth, maxdepth)
data/lib/rmtools/time.rb CHANGED
@@ -1 +1,2 @@
1
- require_with_path __FILE__, '*'
1
+ # encoding: utf-8
2
+ RMTools::require __FILE__, '*'
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  module RMTools
2
3
 
3
4
  def puttime(ms=nil)
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  class String
2
3
 
3
4
  def digit_date
data/lib/rmtools/xml.rb CHANGED
@@ -1,7 +1,8 @@
1
+ # encoding: utf-8
1
2
  begin
2
3
  require 'xml'
3
4
  LibXML::XML
4
- require_with_path __FILE__, 'libxml'
5
+ RMTools::require __FILE__, 'libxml'
5
6
  rescue Exception
6
7
  nil
7
8
  end
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  module LibXML::XML
2
3
 
3
4
  class Document
@@ -1,4 +1,5 @@
1
- require_with_path 'text/string_scanner'
1
+ # encoding: utf-8
2
+ RMTools::require 'text/string_scanner'
2
3
 
3
4
  module LibXML::XML
4
5
  DefaultNS = {}
@@ -1,6 +1,7 @@
1
+ # encoding: utf-8
1
2
  require 'xml'
2
- require_with_path 'xml/{xpath,finders,node,document,string}'
3
- require_with_path 'enumerable/common'
3
+ RMTools::require 'xml/{xpath,finders,node,document,string}'
4
+ RMTools::require 'enumerable/common'
4
5
 
5
6
  module LibXML::XML
6
7
  Error.reset_handler
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  module LibXML::XML
2
3
 
3
4
  class Node
@@ -1,4 +1,5 @@
1
- require_with_path 'lang/shortcuts'
1
+ # encoding: utf-8
2
+ RMTools::require 'lang/shortcuts'
2
3
 
3
4
  class String
4
5
 
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  module LibXML
2
3
 
3
4
  module XML::XPath
@@ -0,0 +1,2 @@
1
+ # encoding: utf-8
2
+ require 'rmtools/load'
@@ -1 +1,3 @@
1
- require 'rmtools/load'
1
+ # encoding: utf-8
2
+ require 'rmtools/load'
3
+ RMTools::require 'b'
@@ -1,4 +1,6 @@
1
+ # encoding: utf-8
1
2
  SCRIPT_LINES__ = {} unless defined? SCRIPT_LINES__
2
3
  require 'rmtools/load'
3
- require_with_path 'debug_notrace'
4
- require_with_path 'console'
4
+ RMTools::require 'b'
5
+ RMTools::require 'debug_notrace'
6
+ RMTools::require 'console'
metadata CHANGED
@@ -1,21 +1,21 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rmtools
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 1
9
- - 4
10
- version: 1.1.4
9
+ - 6
10
+ version: 1.1.6
11
11
  platform: ruby
12
12
  authors:
13
- - Shinku Templar
13
+ - Shinku
14
14
  autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-02-20 00:00:00 +03:00
18
+ date: 2011-02-24 00:00:00 +03:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -177,6 +177,7 @@ files:
177
177
  - lib/rmtools/enumerable.rb
178
178
  - lib/rmtools_notrace.rb
179
179
  - lib/rmtools_nodebug.rb
180
+ - lib/rmtools_no_b.rb
180
181
  - ./Rakefile
181
182
  - ./Manifest.txt
182
183
  - ./License.txt