rmtools 1.2.7 → 1.2.8
Sign up to get free protection for your applications and to get access to all the features.
- data/README.txt +24 -2
- data/Rakefile +2 -2
- data/lib/rmtools/enumerable/array.rb +10 -10
- data/lib/rmtools/text/string_scanner.rb +1 -1
- data/lib/rmtools/xml/xpath.rb +6 -5
- metadata +5 -5
data/README.txt
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
Copyright (c) 2010-
|
2
|
-
|
1
|
+
Copyright (c) 2010-2012
|
2
|
+
Baev Sergey <tinbka@gmail.com>
|
3
3
|
|
4
4
|
This work is licensed under the same license as Ruby language.
|
5
5
|
|
@@ -8,6 +8,28 @@ Methods for basic classes addon collection.
|
|
8
8
|
|
9
9
|
== CHANGES
|
10
10
|
|
11
|
+
== Version 1.2.8
|
12
|
+
|
13
|
+
* StringScanner#each changed to compare `cbs' keys with @matched by number in ruby 1.8 and by first character in ruby 1.9, since ?x in 1.9 returns string instead of a charcode
|
14
|
+
* Updated LibXML::XML::XPath to search elements with multiple classes
|
15
|
+
|
16
|
+
== Version 1.2.7
|
17
|
+
|
18
|
+
* String#hl and #ghl: console-highlight pattern in string
|
19
|
+
* True#call and False#call in order to pass boolean values as callable argument
|
20
|
+
* ActiveRecord::Relation#any? and #empty?, ActiveRecord::Base.insert_unless_exist (using execute) and .select_rand
|
21
|
+
* Added couple of handlers into Array#method_missing
|
22
|
+
* File.modify now can process files by glob-patterns and correctly use multiple gsub! inside passed block
|
23
|
+
* RMTools.read now can read from list of files in order
|
24
|
+
* Upped RMTools.timer accuracy
|
25
|
+
* Optimized Array#-, #+, #& and #| for when one of arrays is empty; added Array#diff
|
26
|
+
* Optimized Object#to_json and String#from_json: use JSON stdlib for ruby 1.9. Object#to_json_safe: timeout'ed conversion
|
27
|
+
* String#cut_line and #split_to_lines optimized for use in Ruby 1.9
|
28
|
+
* Removed String#bytes because it duplicate ruby 1.9 method
|
29
|
+
* static VALUE rb_ary_count_items moved from Array#count to Array#arrange
|
30
|
+
* Fixed Module#self_name
|
31
|
+
* RMTools::CodeReader is still unstable though
|
32
|
+
|
11
33
|
== Version 1.2.0
|
12
34
|
|
13
35
|
* Renamed debug/ to dev/, slightly restructured lib/rmtools/ and require handlers: requrie 'rmtools' for common applications and 'rmtools_dev' for irb and maybe dev environment
|
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.2.
|
5
|
+
RMTOOLS_VERSION = '1.2.8'
|
6
6
|
begin
|
7
7
|
require 'hoe'
|
8
8
|
config = Hoe.spec 'rmtools' do
|
9
|
-
developer("
|
9
|
+
developer("Sergey Baev", "tinbka@gmail.com")
|
10
10
|
|
11
11
|
self.summary = 'Yet another Ruby applied lib'
|
12
12
|
self.description = 'Applied library primarily for debug and text/arrays/files processing purposes.'
|
@@ -3,19 +3,19 @@ require 'active_support/core_ext/array'
|
|
3
3
|
RMTools::require 'functional/fold'
|
4
4
|
|
5
5
|
class Array
|
6
|
-
#
|
7
|
-
#
|
6
|
+
# builtin methods overwrite
|
7
|
+
# why should we do zillions of cycles just for ensure A | [] = A - [] = A or A & [] = []
|
8
8
|
# though - and & should be improved within C-extension to break loop when no items have lost in self
|
9
9
|
alias union |
|
10
|
-
alias
|
10
|
+
alias coallition +
|
11
11
|
alias subtraction -
|
12
12
|
alias intersection &
|
13
|
-
private :union, :
|
13
|
+
private :union, :coallition, :subtraction, :intersection
|
14
14
|
|
15
15
|
def |(ary)
|
16
16
|
if empty?
|
17
17
|
ary.uniq
|
18
|
-
elsif ary.respond_to
|
18
|
+
elsif ary.respond_to? :empty? and ary.empty?
|
19
19
|
dup
|
20
20
|
else union(ary)
|
21
21
|
end
|
@@ -23,27 +23,27 @@ class Array
|
|
23
23
|
|
24
24
|
def +(ary)
|
25
25
|
if empty?
|
26
|
-
if ary.respond_to
|
26
|
+
if ary.respond_to? :empty? and ary.empty?
|
27
27
|
[]
|
28
28
|
else ary.dup
|
29
29
|
end
|
30
|
-
elsif ary.respond_to
|
30
|
+
elsif ary.respond_to? :empty? and ary.empty?
|
31
31
|
dup
|
32
|
-
else
|
32
|
+
else coallition(ary)
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
36
|
def -(ary)
|
37
37
|
if empty?
|
38
38
|
[]
|
39
|
-
elsif ary.respond_to
|
39
|
+
elsif ary.respond_to? :empty? and ary.empty?
|
40
40
|
dup
|
41
41
|
else subtraction(ary)
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
45
|
def &(ary)
|
46
|
-
if empty? or (ary.respond_to
|
46
|
+
if empty? or (ary.respond_to? :empty? and ary.empty?)
|
47
47
|
[]
|
48
48
|
else intersection(ary)
|
49
49
|
end
|
data/lib/rmtools/xml/xpath.rb
CHANGED
@@ -5,16 +5,17 @@ module LibXML
|
|
5
5
|
Finders = {}
|
6
6
|
|
7
7
|
def self.filter(xpath)
|
8
|
-
|
8
|
+
xpath = xpath.strip
|
9
|
+
return xpath[1..-1] if xpath[0] == ?!
|
9
10
|
if x = Finders[xpath]; return x end
|
10
11
|
if xpath[%r{\[@?\w+([^\w!]=).+?\]}]
|
11
12
|
raise XML::Error, "can't process '#{$1}' operator"
|
12
13
|
end
|
13
14
|
x = xpath.dup
|
14
|
-
x.gsub! %r{([^\\])\s*>\s*}, '\1/'
|
15
|
+
x.gsub! %r{([^\\]|\A)\s*>\s*}, '\1/'
|
15
16
|
x.gsub! %r{([^\\])\s+}, '\1//'
|
16
|
-
x.gsub! %r{\.([\w-]+)([\[\{/]|\Z)}
|
17
|
-
x.gsub! %r{#([\w-]+)([\[\{
|
17
|
+
x.gsub! %r{(\.([\w-]+))+(?=[\[\{/]|\Z)} do |m| "[@class=\"#{m.split('.')[1..-1]*' '}\"]" end
|
18
|
+
x.gsub! %r{#([\w-]+)([\[\{/.]|\Z)}, '[@id="\1"]\2'
|
18
19
|
x.gsub! %r{(^|/)([^.#\w*/'"])}, '\1*\2'
|
19
20
|
x.gsub! %r{\[([a-z]+)}, '[@\1'
|
20
21
|
x.gsub! %r{(\[(?:@\w+!?=)?)['"]?([^'"\]@]+)['"]?\]}, '\1"\2"]'
|
@@ -24,7 +25,7 @@ module LibXML
|
|
24
25
|
}(\[(@\w+(!?="[^"]+")?|"[^"]+")\])*#{# attributes [@href!="pics/xynta.jpeg"]
|
25
26
|
}(\[-?\d+\]|\{[^\}]+\})?#{ # inruby-filters (see finder functions ^)
|
26
27
|
})+$}
|
27
|
-
raise XML::Error, "can't process `#{xpath}
|
28
|
+
raise XML::Error, "can't process `#{xpath}`; #{x}"
|
28
29
|
end
|
29
30
|
x = '//'+x if x !~ %r{^[./]}
|
30
31
|
x.sub! %r{^/}, './'
|
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:
|
4
|
+
hash: 15
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 1.2.
|
9
|
+
- 8
|
10
|
+
version: 1.2.8
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
|
-
-
|
13
|
+
- Sergey Baev
|
14
14
|
autorequire:
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-
|
18
|
+
date: 2012-07-27 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: rake
|