kyanite 0.6.1 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Div +6 -32
- data/{History.txt → History.rdoc} +8 -0
- data/{License.txt → License.rdoc} +0 -0
- data/Manifest.txt +6 -21
- data/README.rdoc +44 -0
- data/Rakefile.rb +19 -68
- data/console.rb +2 -4
- data/lib/kyanite.rb +151 -14
- data/lib/kyanite/array.rb +127 -4
- data/lib/kyanite/basics.rb +3 -7
- data/lib/kyanite/dictionary.rb +19 -21
- data/lib/kyanite/enumerable/enumerable_enumerables.rb +22 -24
- data/lib/kyanite/enumerable/enumerable_numerics.rb +51 -49
- data/lib/kyanite/enumerable/enumerable_strings.rb +18 -25
- data/lib/kyanite/enumerable/structure.rb +46 -58
- data/lib/kyanite/general/callerutils.rb +30 -28
- data/lib/kyanite/general/classutils.rb +73 -63
- data/lib/kyanite/general/kernel.rb +45 -64
- data/lib/kyanite/general/object.rb +22 -46
- data/lib/kyanite/general/true_false.rb +33 -27
- data/lib/kyanite/general/undoable.rb +12 -16
- data/lib/kyanite/hash.rb +63 -58
- data/lib/kyanite/numeric.rb +14 -1
- data/lib/kyanite/numeric/float.rb +32 -22
- data/lib/kyanite/numeric/integer.rb +12 -20
- data/lib/kyanite/optimizer.rb +41 -24
- data/lib/kyanite/range.rb +42 -22
- data/lib/kyanite/set.rb +56 -63
- data/lib/kyanite/string.rb +1 -2
- data/lib/kyanite/string/cast.rb +61 -37
- data/lib/kyanite/string/chars.rb +66 -36
- data/lib/kyanite/string/chars_const.rb +4 -3
- data/lib/kyanite/string/diff.rb +64 -34
- data/lib/kyanite/string/include.rb +16 -9
- data/lib/kyanite/string/list.rb +38 -8
- data/lib/kyanite/string/misc.rb +64 -0
- data/lib/kyanite/string/nested.rb +39 -22
- data/lib/kyanite/string/random.rb +117 -47
- data/lib/kyanite/string/split.rb +84 -45
- data/lib/kyanite/symbol.rb +30 -21
- data/lib/kyanite/tree.rb +33 -28
- data/test/_start_all.rb +18 -15
- data/test/array/test_array.rb +5 -7
- data/test/enumerable/test_enumerable_enumerables.rb +11 -15
- data/test/enumerable/test_enumerable_numerics.rb +50 -54
- data/test/enumerable/test_enumerable_strings.rb +8 -11
- data/test/enumerable/test_structure.rb +6 -8
- data/test/general/test_classutils.rb +9 -9
- data/test/general/test_object.rb +4 -5
- data/test/general/test_true_false.rb +4 -5
- data/test/numeric/test_numeric_integer.rb +6 -6
- data/test/string/test_cast.rb +4 -5
- data/test/string/test_chars.rb +6 -7
- data/test/string/test_diff.rb +4 -5
- data/test/string/test_list.rb +4 -5
- data/test/string/test_misc.rb +58 -0
- data/test/string/test_nested.rb +4 -5
- data/test/string/test_split.rb +10 -5
- data/test/test_dictionary.rb +4 -6
- data/test/test_hash.rb +5 -7
- data/test/test_optimizer.rb +4 -5
- data/test/test_range.rb +8 -9
- data/test/test_set.rb +7 -7
- data/test/test_tree.rb +7 -10
- data/version.rb +8 -0
- metadata +32 -33
- data/README.txt +0 -47
- data/lib/kyanite/array/array.rb +0 -140
- data/lib/kyanite/array/array2.rb +0 -142
- data/lib/kyanite/array/matrix2.rb +0 -120
- data/lib/kyanite/hoe.rb +0 -2
- data/lib/kyanite/matrix2.rb +0 -2
- data/lib/kyanite/numeric/numeric.rb +0 -54
- data/lib/kyanite/operation.rb +0 -5
- data/lib/kyanite/operation/call_tracker.rb +0 -69
- data/lib/kyanite/operation/hoe.rb +0 -12
- data/lib/kyanite/operation/rake.rb +0 -298
- data/lib/kyanite/operation/regexp.rb +0 -28
- data/lib/kyanite/operation/unit_test.rb +0 -50
- data/lib/kyanite/rake.rb +0 -2
- data/lib/kyanite/smart_load_path.rb +0 -6
- data/lib/kyanite/string/div.rb +0 -28
- data/lib/kyanite/string/mgsub.rb +0 -43
- data/lib/kyanite/unit_test.rb +0 -2
- data/test/array/test_matrix2.rb +0 -166
- data/test/string/test_mgsub.rb +0 -58
data/lib/kyanite/rake.rb
DELETED
data/lib/kyanite/string/div.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
# ruby encoding: utf-8
|
2
|
-
|
3
|
-
|
4
|
-
class String
|
5
|
-
|
6
|
-
# ---------------------------------------------------------------------------------------------------------------------------------
|
7
|
-
# :section: Div
|
8
|
-
#
|
9
|
-
|
10
|
-
# Wörter zählen
|
11
|
-
def count_words
|
12
|
-
n = 0
|
13
|
-
scan(/\b\S+\b/) { n += 1}
|
14
|
-
n
|
15
|
-
end
|
16
|
-
|
17
|
-
|
18
|
-
end
|
19
|
-
|
20
|
-
|
21
|
-
if defined? TransparentNil
|
22
|
-
class NilClass
|
23
|
-
|
24
|
-
# Rückgabe: 0
|
25
|
-
def count_words; 0; end
|
26
|
-
|
27
|
-
end
|
28
|
-
end
|
data/lib/kyanite/string/mgsub.rb
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
# ruby encoding: utf-8
|
2
|
-
# ü
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
class String
|
7
|
-
|
8
|
-
# ---------------------------------------------------------------------------------------------------------------------------------
|
9
|
-
# :section: mgsub
|
10
|
-
#
|
11
|
-
|
12
|
-
# Mehrere Patterns mit einer RegExp replacen.
|
13
|
-
# Ruby Cookbook Seite 32
|
14
|
-
# "between".mgsub([[/ee/, 'AA'], [/e/, 'E']]) # Good code
|
15
|
-
# => "bEtwAAn"
|
16
|
-
#
|
17
|
-
def mgsub(key_value_pairs=[].freeze)
|
18
|
-
regexp_fragments = key_value_pairs.collect { |k,v| k }
|
19
|
-
gsub(Regexp.union(*regexp_fragments)) do |match|
|
20
|
-
key_value_pairs.detect{|k,v| k =~ match}[1]
|
21
|
-
end
|
22
|
-
end
|
23
|
-
# http://oreilly.com/catalog/9780596523695/
|
24
|
-
# Ruby Cookbook, by Lucas Carlson and Leonard Richardson
|
25
|
-
# Copyright 2006 O'Reilly Media
|
26
|
-
|
27
|
-
end # class
|
28
|
-
|
29
|
-
if defined? TransparentNil
|
30
|
-
class NilClass
|
31
|
-
def mgsub(*a); nil; end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
|
36
|
-
# -----------------------------------------------------------------------------------------
|
37
|
-
# ausprobieren
|
38
|
-
#
|
39
|
-
if $0 == __FILE__ then
|
40
|
-
|
41
|
-
puts "between".mgsub([[/ee/, 'AA'], [/e/, 'E']])
|
42
|
-
|
43
|
-
end # if
|
data/lib/kyanite/unit_test.rb
DELETED
data/test/array/test_matrix2.rb
DELETED
@@ -1,166 +0,0 @@
|
|
1
|
-
# ruby encoding: utf-8
|
2
|
-
# ü
|
3
|
-
if $0 == __FILE__
|
4
|
-
require File.join(File.dirname(__FILE__), '..', '..', 'smart_load_path.rb' )
|
5
|
-
smart_load_path
|
6
|
-
end
|
7
|
-
|
8
|
-
require 'transparent_nil' unless defined? TransparentNil
|
9
|
-
require 'kyanite/unit_test'
|
10
|
-
require 'kyanite/matrix2'
|
11
|
-
require 'transparent_nil'
|
12
|
-
|
13
|
-
# require 'benchmark'
|
14
|
-
# include Benchmark
|
15
|
-
|
16
|
-
|
17
|
-
# Tests for Matrix2
|
18
|
-
class TestKyaniteMatrix2 < UnitTest
|
19
|
-
|
20
|
-
|
21
|
-
#
|
22
|
-
# Normale Matrix testen: Zellen und Zeilen
|
23
|
-
#
|
24
|
-
def test_matrix_zellen_und_zeilen
|
25
|
-
# Initialisierung
|
26
|
-
zeile0 = ['Ueberschrift', 'Spalte1', 'Spalte2']
|
27
|
-
zeile1 = ['Zeile1', 'Wert 1.1', 'Wert 1.2']
|
28
|
-
zeile2 = ['Zeile2', 'Wert 2.1', 'Wert 2.2']
|
29
|
-
zeile3 = ['Zeile3', 'Wert 3.1', 'Wert 3.2', 'Wert 3.3']
|
30
|
-
zeile4 = ['Zeile4', 'Wert 4.1', 'Wert 4.2']
|
31
|
-
|
32
|
-
table = [zeile0, zeile1, zeile2, zeile3, zeile4] # dies ist noch ein Array
|
33
|
-
mymatrix = Matrix2.new(table) # und dies ist eine Matrix2
|
34
|
-
assert_kind_of Matrix2, mymatrix
|
35
|
-
|
36
|
-
|
37
|
-
# Zellen-Funktionen testen
|
38
|
-
assert_equal 'Wert 2.2', mymatrix[2][2]
|
39
|
-
mymatrix.set_element!(2,2,'Hallo 2.2')
|
40
|
-
assert_equal 'Hallo 2.2', mymatrix[2][2]
|
41
|
-
|
42
|
-
|
43
|
-
# Zeilen-Funktionen testen
|
44
|
-
assert_equal zeile2, mymatrix.row(2)
|
45
|
-
assert_equal mymatrix.row(2).size, mymatrix.column_size
|
46
|
-
assert_nil mymatrix.row(99)
|
47
|
-
assert_nil mymatrix.row(-99)
|
48
|
-
assert_equal 0, mymatrix.row(99).size
|
49
|
-
mymatrix.set_row!(3, zeile4)
|
50
|
-
assert_equal mymatrix.row(3), mymatrix.row(4)
|
51
|
-
mymatrix[3][0] = 'Z3'
|
52
|
-
mymatrix.set_element!(3,0,'ZEILE3')
|
53
|
-
mymatrix.set_element!(3,1,'WERT 3.1')
|
54
|
-
mymatrix.set_element!(3,2,'WERT 3.2')
|
55
|
-
assert_not_equal mymatrix.row(3), mymatrix.row(4)
|
56
|
-
|
57
|
-
zeile5 = ['Zeile5', 'Wert 5.1', 'Wert 5.2']
|
58
|
-
mymatrix.set_row!(5, zeile5)
|
59
|
-
end
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
#
|
65
|
-
# Normale Matrix testen: resize_to_header
|
66
|
-
#
|
67
|
-
def test_resize_to_header
|
68
|
-
# Erneute Initialisierung
|
69
|
-
zeile0 = ['Ueberschrift', 'Spalte1', 'Spalte2']
|
70
|
-
zeile1 = ['Zeile1', 'Wert 1.1', 'Wert 1.2']
|
71
|
-
zeile2 = ['Zeile2', 'Wert 2.1']
|
72
|
-
zeile3 = ['Zeile3', 'Wert 3.1', 'Wert 3.2', 'Wert 3.3']
|
73
|
-
zeile4 = ['Zeile4', 'Wert 4.1', 'Wert 4.2']
|
74
|
-
zeile5 = ['Zeile5']
|
75
|
-
mymatrix = Matrix2.new([zeile0, zeile1, zeile2, zeile3, zeile4, zeile5])
|
76
|
-
|
77
|
-
|
78
|
-
# clean4view(0) testen -- Resize to header
|
79
|
-
assert_equal 16, mymatrix.flatten.size
|
80
|
-
assert_equal 18, mymatrix.clean4view(0).flatten.size
|
81
|
-
assert_equal 16, mymatrix.flatten.size
|
82
|
-
mymatrix.clean4view!(0)
|
83
|
-
assert_equal 18, mymatrix.flatten.size
|
84
|
-
assert_equal 18, mymatrix.clean4view(0).flatten.size
|
85
|
-
assert_kind_of Matrix2, mymatrix.clean4view(0)
|
86
|
-
mymatrix.clean4view!
|
87
|
-
assert_kind_of Matrix2, mymatrix
|
88
|
-
end
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
#
|
94
|
-
# Normale Matrix testen: Spalten
|
95
|
-
#
|
96
|
-
def test_spalten
|
97
|
-
# Erneute Initialisierung
|
98
|
-
zeile0 = ['Ueberschrift', 'Spalte1', 'Spalte2']
|
99
|
-
zeile1 = ['Zeile1', 'Wert 1.1', 'Wert 1.2']
|
100
|
-
zeile2 = ['Zeile2', 'Wert 2.1']
|
101
|
-
zeile3 = ['Zeile3', 'Wert 3.1', 'Wert 3.2', 'Wert 3.3']
|
102
|
-
zeile4 = ['Zeile4', 'Wert 4.1', 'Wert 4.2']
|
103
|
-
zeile5 = ['Zeile5']
|
104
|
-
mymatrix = Matrix2.new([zeile0, zeile1, zeile2, zeile3, zeile4, zeile5])
|
105
|
-
|
106
|
-
# Spalten-Funktionen testen
|
107
|
-
assert_equal mymatrix.column(2).size, mymatrix.row_size
|
108
|
-
assert_nil mymatrix.column(99)
|
109
|
-
assert_nil mymatrix.column(-99)
|
110
|
-
assert_equal 0, mymatrix.column(99).size
|
111
|
-
spalte2 = mymatrix.column(2)
|
112
|
-
mymatrix.set_column!(3, spalte2)
|
113
|
-
mymatrix.set_column!(4, spalte2)
|
114
|
-
assert_equal mymatrix.column(2), mymatrix.column(3)
|
115
|
-
assert_equal mymatrix.column(2), mymatrix.column(4)
|
116
|
-
assert_equal 30, mymatrix.flatten.size
|
117
|
-
end
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
#
|
122
|
-
# Matrix mit Fehlern testen
|
123
|
-
#
|
124
|
-
def test_fehlerhalte_matrix
|
125
|
-
# Erneute Initialisierung
|
126
|
-
zeile0 = ['X', 'Spalte1', nil, 'Spalte3']
|
127
|
-
zeile1 = [ nil, 'Wert 1.1', 'Wert 1.2','Wert 1.3']
|
128
|
-
zeile2 = []
|
129
|
-
zeile3 = nil
|
130
|
-
zeile4 = ['Zeile4', 'Wert 4.1', 'Wert 4.2']
|
131
|
-
zeile5 = [ nil , nil, nil, nil, nil, nil, nil, nil]
|
132
|
-
zeile6 = ['Zeile6', nil, 'Wert 6.2', 'Wert 6.3']
|
133
|
-
zeile7 = ['Zeile7', 'Wert 7.1', 'Wert 7.2', 'Wert 7.3']
|
134
|
-
zeile8 = ['Zeile8', 'Wert 8.1', nil, 'Wert 8.3']
|
135
|
-
zeile9 = ['Zeile9', 'Wert 9.1', nil, 'Wert 9.3', 'Wert 9.4']
|
136
|
-
|
137
|
-
|
138
|
-
assert_not_nil zeile0.row_to_nil
|
139
|
-
assert_nil zeile1.row_to_nil
|
140
|
-
assert_nil zeile2.row_to_nil
|
141
|
-
assert_nil zeile3.row_to_nil
|
142
|
-
assert_not_nil zeile4.row_to_nil
|
143
|
-
assert_nil zeile5.row_to_nil
|
144
|
-
assert_not_nil zeile6.row_to_nil
|
145
|
-
|
146
|
-
|
147
|
-
errormatrix = Matrix2.new([zeile0, zeile1, zeile2, zeile3, zeile4, zeile5, zeile6, zeile7, zeile8, zeile9])
|
148
|
-
|
149
|
-
|
150
|
-
# assert_equal 37, errormatrix.flatten.size
|
151
|
-
# assert_equal 40, errormatrix.clean4view(0).flatten.size
|
152
|
-
# assert_equal 24, errormatrix.clean4view(1).flatten.size
|
153
|
-
# assert_equal 18, errormatrix.clean4view(2).flatten.size
|
154
|
-
|
155
|
-
end
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
end # class
|
data/test/string/test_mgsub.rb
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
# ruby encoding: utf-8
|
2
|
-
# ü
|
3
|
-
if $0 == __FILE__
|
4
|
-
require File.join(File.dirname(__FILE__), '..', '..', 'smart_load_path.rb' )
|
5
|
-
smart_load_path
|
6
|
-
end
|
7
|
-
|
8
|
-
require 'kyanite/unit_test'
|
9
|
-
require 'kyanite/string/mgsub'
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
# Tests for String
|
14
|
-
#
|
15
|
-
class TestKyaniteStringMgsub < UnitTest
|
16
|
-
|
17
|
-
def test_mgsub
|
18
|
-
assert_equal 'bEtwAAn', 'between'.mgsub([[/ee/, 'AA'], [/e/, 'E']])
|
19
|
-
end
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
end # class
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|