kyanite 0.3.7 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. data/0_rake_test.bat +12 -0
  2. data/1_rake_install_gem.bat +20 -0
  3. data/3_rake_deploy.bat +4 -0
  4. data/4_ruby_script_console.bat +12 -0
  5. data/Div +23 -0
  6. data/History.txt +4 -2
  7. data/License.txt +21 -2
  8. data/Manifest.txt +46 -29
  9. data/README.txt +26 -33
  10. data/Rakefile.rb +6 -6
  11. data/config/website.yml +2 -0
  12. data/lib/kyanite.rb +46 -2
  13. data/lib/kyanite/array/array.rb +15 -14
  14. data/lib/kyanite/array/array2.rb +1 -1
  15. data/lib/kyanite/dictionary.rb +17 -2
  16. data/lib/kyanite/enumerable/enumerable_enumerables.rb +19 -9
  17. data/lib/kyanite/enumerable/enumerable_numerics.rb +25 -19
  18. data/lib/kyanite/enumerable/enumerable_strings.rb +14 -6
  19. data/lib/kyanite/enumerable/structure.rb +45 -29
  20. data/lib/kyanite/general/callerutils.rb +9 -1
  21. data/lib/kyanite/general/classutils.rb +59 -78
  22. data/lib/kyanite/general/kernel.rb +21 -3
  23. data/lib/kyanite/general/nil.rb +34 -12
  24. data/lib/kyanite/general/object.rb +25 -3
  25. data/lib/kyanite/general/true_false.rb +28 -10
  26. data/lib/kyanite/general/undoable.rb +24 -0
  27. data/lib/kyanite/hash.rb +43 -28
  28. data/lib/kyanite/numeric/float.rb +12 -5
  29. data/lib/kyanite/numeric/integer.rb +16 -9
  30. data/lib/kyanite/numeric/numeric.rb +19 -11
  31. data/lib/kyanite/operation/regexp.rb +5 -1
  32. data/lib/kyanite/optimizer.rb +31 -16
  33. data/lib/kyanite/range.rb +15 -8
  34. data/lib/kyanite/set.rb +35 -6
  35. data/lib/kyanite/string/cast.rb +18 -7
  36. data/lib/kyanite/string/chars.rb +24 -17
  37. data/lib/kyanite/string/diff.rb +14 -5
  38. data/lib/kyanite/string/div.rb +8 -1
  39. data/lib/kyanite/string/include.rb +13 -5
  40. data/lib/kyanite/string/list.rb +3 -3
  41. data/lib/kyanite/string/mgsub.rb +6 -2
  42. data/lib/kyanite/string/nested.rb +22 -3
  43. data/lib/kyanite/string/random.rb +4 -0
  44. data/lib/kyanite/string/split.rb +15 -7
  45. data/lib/kyanite/symbol.rb +14 -0
  46. data/lib/kyanite/tree.rb +10 -4
  47. data/script/console +10 -0
  48. data/script/console.cmd +1 -0
  49. data/script/destroy +14 -0
  50. data/script/destroy.cmd +1 -0
  51. data/script/generate +14 -0
  52. data/script/generate.cmd +1 -0
  53. data/script/txt2html +82 -0
  54. data/script/txt2html.cmd +1 -0
  55. data/tasks/deployment.rake +92 -0
  56. data/tasks/documentation.rake +28 -0
  57. data/tasks/environment.rake +7 -0
  58. data/test/array/test_matrix2.rb +1 -0
  59. data/test/enumerable/test_enumerable_numerics.rb +3 -2
  60. data/test/general/test_classutils.rb +3 -0
  61. data/test/general/test_nil.rb +1 -0
  62. data/test/general/test_object.rb +2 -1
  63. data/test/general/test_true_false.rb +1 -0
  64. data/test/numeric/test_numeric_integer.rb +2 -0
  65. data/test/string/test_cast.rb +4 -0
  66. data/test/string/test_chars.rb +3 -0
  67. data/test/string/test_diff.rb +3 -0
  68. data/test/string/test_list.rb +2 -0
  69. data/test/string/test_nested.rb +2 -0
  70. data/test/string/test_split.rb +3 -0
  71. data/test/test_dictionary.rb +3 -0
  72. data/test/test_hash.rb +2 -0
  73. data/test/test_optimizer.rb +14 -14
  74. data/test/test_range.rb +1 -0
  75. data/test/test_tree.rb +1 -1
  76. metadata +48 -31
@@ -5,12 +5,12 @@ class String
5
5
 
6
6
 
7
7
  # ---------------------------------------------------------------------------------------------------------------------------------
8
- # :section: overlap / diff
9
- #
8
+ # :section: Overlap / Diff
9
+ # See TestKyaniteStringDiff for tests and examples.
10
10
 
11
11
  # Gibt den gemeinsamen Teil zweier Strings aus (von vorne gezählt).
12
12
  #
13
- # Beispiele & Tests siehe TestString#test_overlap
13
+ # Beispiele & Tests siehe TestKyaniteStringDiff#test_overlap
14
14
  def overlap(b)
15
15
  return '' if b.nil?
16
16
  b = b.to_str
@@ -26,7 +26,7 @@ class String
26
26
  # Im Zweifelsfall immer den längsten String.
27
27
  # Wenn dann immer noch Zweifel, dann self.
28
28
  #
29
- # Beispiele & Tests siehe TestString#test_diff
29
+ # Beispiele & Tests siehe TestKyaniteStringDiff#test_diff
30
30
  def diff(b)
31
31
  return self if b.nil?
32
32
  b = b.to_str
@@ -46,7 +46,7 @@ class String
46
46
  # Waren beide gleichlang, so erhält man self.
47
47
  # overlapdiff braucht genauso viel Zeit wie diff alleine.
48
48
  #
49
- # Beispiele & Tests siehe TestString#test_overlapdiff
49
+ # Beispiele & Tests siehe TestKyaniteStringDiff#test_overlapdiff
50
50
  def overlapdiff(b)
51
51
  return '', self if b.nil?
52
52
  b = b.to_str
@@ -66,8 +66,17 @@ end
66
66
 
67
67
 
68
68
  class NilClass
69
+
70
+ # Rückgabe: Leerer String,
71
+ # siehe String#overlap
69
72
  def overlap(*a); ''; end
73
+
74
+ # Rückgabe: b,
75
+ # siehe String#diff
70
76
  def diff(b); b; end
77
+
78
+ # Rückgabe: ['', b],
79
+ # siehe String#overlapdiff
71
80
  def overlapdiff(b); ['', b]; end
72
81
  end
73
82
 
@@ -3,6 +3,10 @@
3
3
 
4
4
  class String
5
5
 
6
+ # ---------------------------------------------------------------------------------------------------------------------------------
7
+ # :section: Div
8
+ #
9
+
6
10
  # Wörter zählen
7
11
  def count_words
8
12
  n = 0
@@ -15,5 +19,8 @@ end
15
19
 
16
20
 
17
21
  class NilClass
18
- def count_words; 0; end
22
+
23
+ # Rückgabe: 0
24
+ def count_words; 0; end
25
+
19
26
  end
@@ -1,12 +1,17 @@
1
1
 
2
2
  class String
3
+
4
+ # ---------------------------------------------------------------------------------------------------------------------------------
5
+ # :section: include
6
+ #
7
+
3
8
  alias :old_include? :include?
4
9
 
5
- # Nimmt jetzt auch ein Array an.
6
- # Die Array-Elemente werden ODER-verknüpft, d.h.
7
- # include? ist true, wenn für mindestens eines der Elemente include? true ist.
8
- # Alle Strings includen '', [] oder nil.
9
- # Andersherum enthält nil niemals irgendwas (nil.include? => false)
10
+ # [ ] Nimmt jetzt auch ein Array an.
11
+ # [ ] Die Array-Elemente werden ODER-verknüpft, d.h.
12
+ # [ ] include? ist true, wenn für mindestens eines der Elemente include? true ist.
13
+ # [ ] Alle Strings includen '', [] oder nil.
14
+ # [ ] Andersherum enthält nil niemals irgendwas (nil.include? => false)
10
15
  def include?(input)
11
16
  return true if input.nil?
12
17
  return true if input.empty?
@@ -23,6 +28,9 @@ end
23
28
 
24
29
 
25
30
  class NilClass
31
+
32
+ # Rückgabe: false
33
+ # redundante Definition!
26
34
  def include?(*a); false; end
27
35
  end
28
36
 
@@ -5,11 +5,11 @@ require 'kyanite/symbol'
5
5
  class String
6
6
 
7
7
  # ---------------------------------------------------------------------------------------------------------------------------------
8
- # :section: Listen / Datenbank
9
- #
8
+ # :section: List / Database
9
+ # See TestKyaniteStringList for tests and examples.
10
10
 
11
11
 
12
- # Listet Text auf. Beispiele siehe Tests!
12
+ # Listet Text auf. Beispiele siehe TestKyaniteStringList
13
13
  def list_with( elemente, options = {}, &block )
14
14
 
15
15
  options = { :pre => %q{'},
@@ -1,10 +1,14 @@
1
1
 
2
2
  class String
3
+
4
+ # ---------------------------------------------------------------------------------------------------------------------------------
5
+ # :section: mgsub
6
+ #
3
7
 
4
8
  # Mehrere Patterns mit einer RegExp replacen.
5
9
  # Ruby Cookbook Seite 32
6
- # "between".mgsub([[/ee/, 'AA'], [/e/, 'E']]) # Good code
7
- # => "bEtwAAn"
10
+ # "between".mgsub([[/ee/, 'AA'], [/e/, 'E']]) # Good code
11
+ # => "bEtwAAn"
8
12
  #
9
13
  def mgsub(key_value_pairs=[].freeze)
10
14
  regexp_fragments = key_value_pairs.collect { |k,v| k }
@@ -1,5 +1,10 @@
1
1
 
2
2
  class String
3
+
4
+ # ---------------------------------------------------------------------------------------------------------------------------------
5
+ # :section: Nested
6
+ # See TestKyaniteStringNested for tests and examples.
7
+ #
3
8
 
4
9
 
5
10
  # Gibt die passende gegenteilige Klammer zurück
@@ -8,6 +13,9 @@ class String
8
13
  # ']'.anti -> '['
9
14
  # '<hallo>'.anti -> '</hallo>'
10
15
  # '</hallo>'.anti -> '<hallo>'
16
+ #
17
+ # See TestKyaniteStringNested for tests and examples.
18
+ #
11
19
  def anti
12
20
  if self.size == 1
13
21
  return self.tr('([{<)]}>',')]}>([{<')
@@ -26,6 +34,9 @@ class String
26
34
  # Findet das nächste zueinander passende Klammerpaar ab Position start.
27
35
  # Liefert die Positionen der Klammern als Range.
28
36
  # Bsp.: 'Hallo(welt)wort'.index_bracket -> 5..10
37
+ #
38
+ # See TestKyaniteStringNested for tests and examples.
39
+ #
29
40
  def index_bracket( pattern=nil, start=0, last_found = nil )
30
41
  return nil if self.empty?
31
42
  pattern = /[{<\[]/ unless pattern
@@ -63,7 +74,9 @@ class String
63
74
 
64
75
 
65
76
  # Wendet den Block auf eine hierarchisch definierte Auswahl des Strings an.
66
- # Beispiele siehe Tests.
77
+ #
78
+ # See TestKyaniteStringNested for tests and examples.
79
+ #
67
80
  def mask( options={}, &block )
68
81
 
69
82
  # vorbereiten
@@ -176,7 +189,10 @@ class String
176
189
  end # def
177
190
 
178
191
 
179
- # Liefert die Verschachtelungstiefe
192
+ # Liefert die Verschachtelungstiefe.
193
+ #
194
+ # See TestKyaniteStringNested for tests and examples.
195
+ #
180
196
  def nestinglevel(pattern=/[{<(\[]/)
181
197
  result = 0
182
198
  self.mask( :level_start => 0,
@@ -202,10 +218,13 @@ end # class
202
218
 
203
219
 
204
220
  class NilClass
221
+
222
+ # Rückgabe: 0
223
+ def nestinglevel; 0; end
224
+
205
225
  def anti; nil; end
206
226
  def index_bracket; nil; end
207
227
  def mask(*a); nil; end
208
- def nestinglevel; 0; end
209
228
  end
210
229
 
211
230
 
@@ -44,6 +44,10 @@ end
44
44
 
45
45
  class String
46
46
 
47
+ # ---------------------------------------------------------------------------------------------------------------------------------
48
+ # :section: Random
49
+ #
50
+
47
51
  # Zufällige Reihenfolge
48
52
  def shuffle(separator=//)
49
53
  split(separator).shuffle.join('')
@@ -6,13 +6,17 @@
6
6
  require 'kyanite/array/array'
7
7
 
8
8
 
9
+
10
+ class String
11
+
9
12
  # ---------------------------------------------------------------------------------------------------------------------------------
10
- # :section: Aufsplitten
13
+ # :section: Split
14
+ # See TestKyaniteStringSplit for tests and examples.
11
15
  #
12
- # Aus {Facets/String}[http://facets.rubyforge.org/rdoc/Core/classes/String.html] eingefügt:
13
- # * <tt>shatter(re)</tt> :: Breaks a string up into an array based on a regular expression. Similar to +scan+, but includes the matches.
14
- #
15
- class String
16
+ # Aus {Facets/String}[http://facets.rubyforge.org/doc/api/core/classes/String.html]eingefügt:
17
+ # [ ] *shatter*(re)
18
+ # [ ] Breaks a string up into an array based on a regular expression. Similar to +scan+, but includes the matches.
19
+
16
20
 
17
21
 
18
22
  # Returns _n_ characters of the string. If _n_ is positive
@@ -117,7 +121,7 @@ class String
117
121
  # Trennt numerische Teile ab und entfernt abschließende Whitespaces, Bindestriche, Unterstriche und Punkte.
118
122
  # Wird z.B. für die Generierung des Doku-Pfades verwendet.
119
123
  #
120
- # Tests siehe TestKyaniteStringClear
124
+ # Tests siehe TestKyaniteStringSplit
121
125
  def without_versioninfo
122
126
  shatter(/\d+/)[0].strip.chomp('_').chomp('-').chomp('.')
123
127
  end
@@ -126,8 +130,12 @@ end
126
130
 
127
131
 
128
132
  class NilClass
129
- def nchar(*a); nil; end
133
+
134
+ # Rückgabe: Leerer String,
135
+ # siehe String#split
130
136
  def cut(*a); ''; end
137
+
138
+ def nchar(*a); nil; end
131
139
  def split_by_index(*a); nil; end
132
140
  def extract(*a); nil; end
133
141
  def split_numeric; nil; end
@@ -1,17 +1,31 @@
1
1
 
2
+
3
+ # [ | Kyanite | *Object* | Array | Set | Enumerable | Hash | ] | Object | String | *Symbol* | Numeric |
4
+ #
5
+ # ---
6
+ #
7
+ # == *Symbol*
8
+ #
9
+ #
2
10
  class Symbol
3
11
 
12
+ # Rückgabe: false
4
13
  def empty?; false; end
14
+
15
+ # Rückgabe: self
5
16
  def dup; self; end
6
17
 
18
+ # wie gleichlautende String-Funktion
7
19
  def +(other)
8
20
  (self.to_s + other.to_s).to_sym
9
21
  end
10
22
 
23
+ # wie gleichlautende String-Funktion
11
24
  def <=>(other)
12
25
  self.to_s <=> other.to_s
13
26
  end
14
27
 
28
+ # wie gleichlautende String-Funktion
15
29
  def size
16
30
  self.to_s.size
17
31
  end
@@ -2,10 +2,16 @@
2
2
 
3
3
  require 'tree'
4
4
 
5
- # -----------------------------------------------------------------------------------------
6
- # Ergänzungen zu rubytree 0.5.2
7
- #
8
- module Tree
5
+
6
+ module Tree # :nodoc:
7
+
8
+ # [ | *Kyanite* | Object | Array | Set | Enumerable | Hash | ] | Kyanite | TrueClass | FalseClass | NilClass | *Div* |
9
+ # [ ] | Div | <b>Tree::TreeNode</b> | Optimizer |
10
+ # ---
11
+ #
12
+ # == *Ergänzungen* *zu* *rubytree* *0.5.2*
13
+ # See TestKyaniteTree for tests and examples.
14
+ #
9
15
  class TreeNode
10
16
  attr_reader :childrenHash
11
17
 
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ # File: script/console
3
+ irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
4
+
5
+ libs = " -r irb/completion"
6
+ # Perhaps use a console_lib to store any extra methods I may want available in the cosole
7
+ # libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
8
+ libs << " -r #{File.dirname(__FILE__) + '/../lib/kyanite.rb'}"
9
+ puts "Welcome to Kyanite gem"
10
+ exec "#{irb} #{libs} --simple-prompt --noreadline"
@@ -0,0 +1 @@
1
+ @ruby script/console %*
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/destroy'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Destroy.new.run(ARGV)
@@ -0,0 +1 @@
1
+ @ruby script/destroy %*
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/generate'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Generate.new.run(ARGV)
@@ -0,0 +1 @@
1
+ @ruby script/generate %*
@@ -0,0 +1,82 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ GEM_NAME = 'kyanite' # what ppl will type to install your gem
4
+ RUBYFORGE_PROJECT = 'kyanite'
5
+
6
+ require 'rubygems'
7
+ begin
8
+ require 'newgem'
9
+ require 'rubyforge'
10
+ rescue LoadError
11
+ puts "\n\nGenerating the website requires the newgem RubyGem"
12
+ puts "Install: gem install newgem\n\n"
13
+ exit(1)
14
+ end
15
+ require 'redcloth'
16
+ require 'syntax/convertors/html'
17
+ require 'erb'
18
+ require File.dirname(__FILE__) + "/../lib/#{GEM_NAME}/version.rb"
19
+
20
+ version = Kyanite::VERSION::STRING
21
+ download = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
22
+
23
+ def rubyforge_project_id
24
+ RubyForge.new.autoconfig["group_ids"][RUBYFORGE_PROJECT]
25
+ end
26
+
27
+ class Fixnum
28
+ def ordinal
29
+ # teens
30
+ return 'th' if (10..19).include?(self % 100)
31
+ # others
32
+ case self % 10
33
+ when 1: return 'st'
34
+ when 2: return 'nd'
35
+ when 3: return 'rd'
36
+ else return 'th'
37
+ end
38
+ end
39
+ end
40
+
41
+ class Time
42
+ def pretty
43
+ return "#{mday}#{mday.ordinal} #{strftime('%B')} #{year}"
44
+ end
45
+ end
46
+
47
+ def convert_syntax(syntax, source)
48
+ return Syntax::Convertors::HTML.for_syntax(syntax).convert(source).gsub(%r!^<pre>|</pre>$!,'')
49
+ end
50
+
51
+ if ARGV.length >= 1
52
+ src, template = ARGV
53
+ template ||= File.join(File.dirname(__FILE__), '/../website/template.html.erb')
54
+ else
55
+ puts("Usage: #{File.split($0).last} source.txt [template.html.erb] > output.html")
56
+ exit!
57
+ end
58
+
59
+ template = ERB.new(File.open(template).read)
60
+
61
+ title = nil
62
+ body = nil
63
+ File.open(src) do |fsrc|
64
+ title_text = fsrc.readline
65
+ body_text_template = fsrc.read
66
+ body_text = ERB.new(body_text_template).result(binding)
67
+ syntax_items = []
68
+ body_text.gsub!(%r!<(pre|code)[^>]*?syntax=['"]([^'"]+)[^>]*>(.*?)</\1>!m){
69
+ ident = syntax_items.length
70
+ element, syntax, source = $1, $2, $3
71
+ syntax_items << "<#{element} class='syntax'>#{convert_syntax(syntax, source)}</#{element}>"
72
+ "syntax-temp-#{ident}"
73
+ }
74
+ title = RedCloth.new(title_text).to_html.gsub(%r!<.*?>!,'').strip
75
+ body = RedCloth.new(body_text).to_html
76
+ body.gsub!(%r!(?:<pre><code>)?syntax-temp-(\d+)(?:</code></pre>)?!){ syntax_items[$1.to_i] }
77
+ end
78
+ stat = File.stat(src)
79
+ created = stat.ctime
80
+ modified = stat.mtime
81
+
82
+ $stdout << template.result(binding)