kyanite 0.6.1 → 0.7.0
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/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/operation.rb
DELETED
@@ -1,69 +0,0 @@
|
|
1
|
-
# ruby encoding: utf-8
|
2
|
-
|
3
|
-
|
4
|
-
# http://oreilly.com/catalog/9780596523695/
|
5
|
-
# Ruby Cookbook, by Lucas Carlson and Leonard Richardson
|
6
|
-
# Copyright 2006 O'Reilly Media
|
7
|
-
#
|
8
|
-
class CallTracker
|
9
|
-
|
10
|
-
# Initialize and start the trace.
|
11
|
-
def initialize(show_stack_depth=1)
|
12
|
-
@show_stack_depth = show_stack_depth
|
13
|
-
@to_trace = Hash.new { |h,k| h[k] = {} }
|
14
|
-
start
|
15
|
-
at_exit { stop }
|
16
|
-
end
|
17
|
-
|
18
|
-
# Register a class/method combination as being interesting. Subsequent calls
|
19
|
-
# to the method will be tallied by tally_calls.
|
20
|
-
def register(klass, method_symbol)
|
21
|
-
@to_trace[klass][method_symbol] = {}
|
22
|
-
end
|
23
|
-
|
24
|
-
# Tells the Ruby interpreter to call tally_calls whenever it's about to
|
25
|
-
# do anything interesting.
|
26
|
-
def start
|
27
|
-
set_trace_func method(:tally_calls).to_proc
|
28
|
-
end
|
29
|
-
|
30
|
-
# Stops the profiler, and prints a report of the interesting calls made
|
31
|
-
# while it was running.
|
32
|
-
def stop(out=$stderr)
|
33
|
-
set_trace_func nil
|
34
|
-
report(out)
|
35
|
-
end
|
36
|
-
|
37
|
-
# If the interpreter is about to call a method we find interesting,
|
38
|
-
# increment the count for that method.
|
39
|
-
def tally_calls(event, file, line, symbol, binding, klass)
|
40
|
-
if @to_trace[klass] and @to_trace[klass][symbol] and
|
41
|
-
(event == 'call' or event =='c-call')
|
42
|
-
stack = caller
|
43
|
-
stack = stack[1..(@show_stack_depth ? @show_stack_depth : stack.size)]
|
44
|
-
@to_trace[klass][symbol][stack] ||= 0
|
45
|
-
@to_trace[klass][symbol][stack] += 1
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
# Prints a report of the lines of code that called interesting
|
50
|
-
# methods, sorted so that the the most active lines of code show up
|
51
|
-
# first.
|
52
|
-
def report(out=$stderr)
|
53
|
-
first = true
|
54
|
-
@to_trace.each do |klass, symbols|
|
55
|
-
symbols.each do |symbol, calls|
|
56
|
-
total = calls.inject(0) { |sum, ct| sum + ct[1] }
|
57
|
-
padding = total.to_s.size
|
58
|
-
separator = (klass.is_a? Class) ? '#' : '.'
|
59
|
-
plural = (total == 1) ? '' : 's'
|
60
|
-
stack_join = "\n" + (' ' * (padding+2))
|
61
|
-
first ? first = false : out.puts
|
62
|
-
out.puts "#{total} call#{plural} to #{klass}#{separator}#{symbol}"
|
63
|
-
(calls.sort_by { |caller, times| -times }).each do |caller, times|
|
64
|
-
out.puts " %#{padding}.d #{caller.join(stack_join)}" % times
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
@@ -1,298 +0,0 @@
|
|
1
|
-
# ruby encoding: utf-8
|
2
|
-
|
3
|
-
#== *Rake*
|
4
|
-
#Beispiele siehe Rakefile.rb
|
5
|
-
#* Methode remove_task, um Tasks überschreiben zu können
|
6
|
-
|
7
|
-
|
8
|
-
# ----------------------------------------------------------------------------------------------
|
9
|
-
# Rake initialisieren
|
10
|
-
#
|
11
|
-
|
12
|
-
require 'rake'
|
13
|
-
#require 'rake/testtask'
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
# ----------------------------------------------------------------------------------------------
|
19
|
-
# Ergänzung: Alte Tasks entfernen
|
20
|
-
# sonst kann man sie nämlich nicht überschreiben!
|
21
|
-
# Beispiel: remove_task 'test:plugins'
|
22
|
-
# Quelle: http://matthewbass.com/2007/03/07/overriding-existing-rake-tasks/
|
23
|
-
# dies hier stimmt nicht: http://www.dcmanges.com/blog/modifying-rake-tasks
|
24
|
-
|
25
|
-
Rake::TaskManager.class_eval do
|
26
|
-
def remove_task(task_name)
|
27
|
-
@tasks.delete(task_name.to_s)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def remove_task(task_name)
|
32
|
-
Rake.application.remove_task(task_name)
|
33
|
-
end
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
# -------------------------------------------------------------------------------------------------------
|
39
|
-
# publish
|
40
|
-
#
|
41
|
-
|
42
|
-
# Task :publish
|
43
|
-
#
|
44
|
-
desc 'publish all on github and rubygems, reinstall gem'
|
45
|
-
task :publish => [ :utf8, :redocs, :rubygems_publish, :gem_uninstall, :git_publish, :git_publish_docs, :sleep_15, :utf8, :gem_install] do
|
46
|
-
puts 'done.'
|
47
|
-
end
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
# -------------------------------------------------------------------------------------------------------
|
52
|
-
# git
|
53
|
-
#
|
54
|
-
|
55
|
-
|
56
|
-
# git_publish
|
57
|
-
#
|
58
|
-
desc 'publish actual version to github'
|
59
|
-
task :git_publish => [ :git_add, :git_commit, :git_push ] do
|
60
|
-
puts; puts; puts; puts
|
61
|
-
if Hoe::WINDOZE
|
62
|
-
sh "start https://github.com/#{Kyanite.github_username}/#{Kyanite.projectname} "
|
63
|
-
else
|
64
|
-
puts "done. Visit https://github.com/#{Kyanite.github_username}/#{Kyanite.projectname} "
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
# git_status
|
71
|
-
#
|
72
|
-
desc 'git status'
|
73
|
-
task :git_status do
|
74
|
-
if Hoe::WINDOZE
|
75
|
-
sh "git status "
|
76
|
-
sh 'chcp 65001 > NUL '
|
77
|
-
else
|
78
|
-
sh "sudo git status "
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
# git_add
|
85
|
-
#
|
86
|
-
desc 'git_add -A'
|
87
|
-
task :git_add do
|
88
|
-
if Hoe::WINDOZE
|
89
|
-
sh "git add -A "
|
90
|
-
sh 'chcp 65001 > NUL '
|
91
|
-
else
|
92
|
-
sh "sudo git add -A "
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
# git_commit
|
99
|
-
#
|
100
|
-
desc 'git commit -m'
|
101
|
-
task :git_commit do
|
102
|
-
if Hoe::WINDOZE
|
103
|
-
sh 'git commit -m "---" '
|
104
|
-
sh 'chcp 65001 > NUL '
|
105
|
-
else
|
106
|
-
sh 'sudo git commit -m "---" '
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
|
111
|
-
# git push origin master
|
112
|
-
#
|
113
|
-
desc 'git_push'
|
114
|
-
task :git_push do
|
115
|
-
if Hoe::WINDOZE
|
116
|
-
sh 'git push origin master '
|
117
|
-
sh 'chcp 65001 > NUL '
|
118
|
-
else
|
119
|
-
sh 'sudo git push origin master '
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
# git_publish_docs
|
126
|
-
#
|
127
|
-
desc 'publish docs to github'
|
128
|
-
task :git_publish_docs do
|
129
|
-
puts; puts; puts; puts
|
130
|
-
|
131
|
-
# Repository erstellen, wenn nötig
|
132
|
-
Dir.chdir '/tmp' do
|
133
|
-
sh "#{'sudo ' unless Hoe::WINDOZE }git clone https://github.com/#{Kyanite.github_username}/#{Kyanite.projectname} " do |ok,res|
|
134
|
-
if ok
|
135
|
-
Dir.chdir "/tmp/#{Kyanite.projectname}" do
|
136
|
-
if Hoe::WINDOZE
|
137
|
-
sh 'git checkout --orphan gh-pages '
|
138
|
-
sh 'chcp 65001 > NUL '
|
139
|
-
else
|
140
|
-
sh 'sudo git checkout --orphan gh-pages '
|
141
|
-
end
|
142
|
-
end # do chdir
|
143
|
-
else # not ok
|
144
|
-
sh 'chcp 65001 > NUL ' if Hoe::WINDOZE
|
145
|
-
end
|
146
|
-
end # do sh
|
147
|
-
end # do chdir
|
148
|
-
|
149
|
-
# alles löschen
|
150
|
-
Dir.chdir "/tmp/#{Kyanite.projectname}" do
|
151
|
-
if Hoe::WINDOZE
|
152
|
-
sh 'git rm -rf --ignore-unmatch . '
|
153
|
-
sh 'chcp 65001 > NUL '
|
154
|
-
else
|
155
|
-
sh 'sudo git rm -rf --ignore-unmatch . '
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
# doc rüberkopieren
|
160
|
-
Dir.chdir 'doc' do
|
161
|
-
if Hoe::WINDOZE
|
162
|
-
sh "xcopy /E *.* \\tmp\\#{Kyanite.projectname} "
|
163
|
-
else
|
164
|
-
sh "sudo cp . /tmp/#{Kyanite.projectname} "
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
|
-
# publish
|
169
|
-
Dir.chdir "/tmp/#{Kyanite.projectname}" do
|
170
|
-
if Hoe::WINDOZE
|
171
|
-
sh 'git add -A '
|
172
|
-
sh 'git commit -m "---" --allow-empty'
|
173
|
-
sh 'git push origin +gh-pages ' # C:\Users\Klippstein\_netrc enthält die Login-Daten
|
174
|
-
sh "start http://#{Kyanite.github_username}.github.com/#{Kyanite.projectname} "
|
175
|
-
sh 'chcp 65001 > NUL '
|
176
|
-
else
|
177
|
-
sh 'sudo git add -A '
|
178
|
-
sh 'sudo git commit -m "---" --allow-empty'
|
179
|
-
sh 'sudo git push origin +gh-pages ' # .netrc enthält die Login-Daten
|
180
|
-
puts "done. Visit http://#{Kyanite.github_username}.github.com/#{Kyanite.projectname} "
|
181
|
-
end # if
|
182
|
-
|
183
|
-
end # do chdir
|
184
|
-
|
185
|
-
|
186
|
-
end # do task
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
# -------------------------------------------------------------------------------------------------------
|
192
|
-
# rubygems
|
193
|
-
#
|
194
|
-
|
195
|
-
|
196
|
-
# Task :rubygems_publish
|
197
|
-
#
|
198
|
-
desc 'release actual version to rubygems'
|
199
|
-
task :rubygems_publish do
|
200
|
-
puts; puts; puts; puts
|
201
|
-
ENV["VERSION"] = Kyanite.projectname.to_class.const_get('VERSION')
|
202
|
-
Rake::Task[:release].invoke
|
203
|
-
|
204
|
-
end
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
# Task :gem_uninstall
|
209
|
-
#
|
210
|
-
desc 'uninstall old gem'
|
211
|
-
task :gem_uninstall do
|
212
|
-
puts; puts; puts; puts
|
213
|
-
sh "#{'sudo ' unless Hoe::WINDOZE }gem uninstall #{Kyanite.projectname} --a --ignore-dependencies "
|
214
|
-
end
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
# Task :gem_install
|
219
|
-
#
|
220
|
-
desc 'install gem from rubygems'
|
221
|
-
task :gem_install do
|
222
|
-
puts; puts; puts; puts
|
223
|
-
sh "#{'sudo ' unless Hoe::WINDOZE }gem install #{Kyanite.projectname} "
|
224
|
-
end
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
# -------------------------------------------------------------------------------------------------------
|
232
|
-
# Div
|
233
|
-
#
|
234
|
-
|
235
|
-
# Task :utf8
|
236
|
-
#
|
237
|
-
desc 'Set Codepage to 65001'
|
238
|
-
task :utf8 do
|
239
|
-
|
240
|
-
sh 'chcp 65001 > NUL ' if Hoe::WINDOZE
|
241
|
-
|
242
|
-
end
|
243
|
-
|
244
|
-
|
245
|
-
# Task :version
|
246
|
-
#
|
247
|
-
desc 'VERSION of the current project'
|
248
|
-
task :version do
|
249
|
-
|
250
|
-
version = Kyanite.projectname.to_class.const_get('VERSION')
|
251
|
-
puts "\n#{Kyanite.projectname} (#{version})\n\n"
|
252
|
-
|
253
|
-
end
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
# Task :sleep_5
|
258
|
-
#
|
259
|
-
desc 'Sleep 5 seconds'
|
260
|
-
task :sleep_5 do
|
261
|
-
puts
|
262
|
-
puts
|
263
|
-
puts
|
264
|
-
if Hoe::WINDOZE
|
265
|
-
sh "wait 5"
|
266
|
-
else
|
267
|
-
sh "sleep 5"
|
268
|
-
end
|
269
|
-
|
270
|
-
end
|
271
|
-
|
272
|
-
|
273
|
-
# Task :sleep_15
|
274
|
-
#
|
275
|
-
desc 'Sleep 15 seconds'
|
276
|
-
task :sleep_15 do
|
277
|
-
puts
|
278
|
-
puts
|
279
|
-
puts
|
280
|
-
if Hoe::WINDOZE
|
281
|
-
sh "wait 15"
|
282
|
-
else
|
283
|
-
sh "sleep 15"
|
284
|
-
end
|
285
|
-
|
286
|
-
end
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
# namespace :manifest do
|
292
|
-
# desc 'Recreate Manifest.txt to include ALL files'
|
293
|
-
# task :refresh do
|
294
|
-
# `rake check_manifest | patch -p0 > Manifest.txt`
|
295
|
-
# end
|
296
|
-
# end
|
297
|
-
|
298
|
-
|
@@ -1,28 +0,0 @@
|
|
1
|
-
# ruby encoding: utf-8
|
2
|
-
|
3
|
-
|
4
|
-
class String
|
5
|
-
|
6
|
-
# ---------------------------------------------------------------------------------------------------------------------------------
|
7
|
-
# :section: Operation
|
8
|
-
#
|
9
|
-
|
10
|
-
# Zeigt das Ergebnis eines Matches mit einer Regular Expression. Erleichtert das Entwickeln regulärer Ausdrücke.
|
11
|
-
#
|
12
|
-
def show_regexp(re)
|
13
|
-
if self =~ re
|
14
|
-
"#{$`}<<#{$&}>>#{$'}"
|
15
|
-
else
|
16
|
-
"no match"
|
17
|
-
end # if
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
21
|
-
|
22
|
-
if defined? TransparentNil
|
23
|
-
class NilClass
|
24
|
-
def show_regexp(*a); nil; end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
|
@@ -1,50 +0,0 @@
|
|
1
|
-
# ruby encoding: utf-8
|
2
|
-
require 'test/unit'
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
class UnitTest < Test::Unit::TestCase # :nodoc:
|
7
|
-
|
8
|
-
# Meldet den aktuell durchlaufenden Test
|
9
|
-
def test0 #:nodoc:
|
10
|
-
name = self.class.to_s.gsub(/^.*::/, '')
|
11
|
-
name.gsub!(/^Test/, '')
|
12
|
-
name.gsub!(/^[0-9]+/, '')
|
13
|
-
if name != 'UnitTest'
|
14
|
-
print "\n #{name} "
|
15
|
-
else
|
16
|
-
puts
|
17
|
-
puts
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
end
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
# ---------------------------------------------------------
|
32
|
-
# Ausprobieren
|
33
|
-
#
|
34
|
-
if $0 == __FILE__
|
35
|
-
|
36
|
-
class Test030Blatest < UnitTest # :nodoc:
|
37
|
-
|
38
|
-
def test_bla
|
39
|
-
# 1 / 0
|
40
|
-
assert false
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
end
|
50
|
-
|