kyanite 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ == 0.5.2 2012-10-09
2
+ * fixed small bug in reduce94
3
+ * mgsub added
4
+
1
5
  == 0.5.1 2012-10-08
2
6
  * improved documentation
3
7
 
data/Manifest.txt CHANGED
@@ -5,7 +5,6 @@ Manifest.txt
5
5
  README.txt
6
6
  Rakefile.rb
7
7
  init.rb
8
- smart_load_path.rb
9
8
  lib/kyanite.rb
10
9
  lib/kyanite/array.rb
11
10
  lib/kyanite/array/array.rb
@@ -44,6 +43,7 @@ lib/kyanite/optimizer.rb
44
43
  lib/kyanite/rake.rb
45
44
  lib/kyanite/range.rb
46
45
  lib/kyanite/set.rb
46
+ lib/kyanite/smart_load_path.rb
47
47
  lib/kyanite/string.rb
48
48
  lib/kyanite/string/cast.rb
49
49
  lib/kyanite/string/chars.rb
@@ -52,6 +52,7 @@ lib/kyanite/string/diff.rb
52
52
  lib/kyanite/string/div.rb
53
53
  lib/kyanite/string/include.rb
54
54
  lib/kyanite/string/list.rb
55
+ lib/kyanite/string/mgsub.rb
55
56
  lib/kyanite/string/nested.rb
56
57
  lib/kyanite/string/random.rb
57
58
  lib/kyanite/string/split.rb
data/Rakefile.rb CHANGED
@@ -3,8 +3,8 @@
3
3
  require 'rubygems'
4
4
  require 'hoe'
5
5
  require 'rake'
6
- # require File.dirname(__FILE__) + '/lib/kyanite'
7
- # require 'kyanite/rake'
6
+ require File.dirname(__FILE__) + '/lib/kyanite'
7
+ require 'kyanite/rake'
8
8
 
9
9
 
10
10
 
@@ -19,7 +19,7 @@ $hoe = Hoe.spec 'kyanite' do | p |
19
19
 
20
20
  p.developer('Bjoern Klippstein', 'klippstein@klippstein.com')
21
21
  p.summary = 'General toolbox like Facets or ActiveSupport.'
22
- p.url = 'http://kyanite.rubyforge.org'
22
+ p.urls = ['http://kyanite.rubyforge.org']
23
23
  p.remote_rdoc_dir = '' # Release to root only one project
24
24
  p.extra_deps = [ ['activesupport', '>= 3.2.8'],
25
25
  ['facets', '>= 2.9.3'],
@@ -34,19 +34,18 @@ end
34
34
  # Local Tasks
35
35
  #
36
36
 
37
- # remove_task 'release_to_gemcutter'
38
- # remove_task 'ridocs'
39
- # Dir['tasks/**/*.rake'].each { |t| load t }
40
- # remove_task 'rdoc'
41
- # remove_task 'docs'
42
- # remove_task 'audit'
43
- # remove_task 'dcov'
44
- # remove_task 'debug_email'
45
- # remove_task 'debug_gem'
46
- # remove_task 'default'
47
- # remove_task 'deps:email'
48
- # remove_task 'multi'
49
- # remove_task 'newb'
37
+ remove_task 'ridocs'
38
+ Dir['tasks/**/*.rake'].each { |t| load t }
39
+ remove_task 'rdoc'
40
+ remove_task 'docs'
41
+ remove_task 'audit'
42
+ remove_task 'dcov'
43
+ remove_task 'debug_email'
44
+ remove_task 'debug_gem'
45
+ remove_task 'default'
46
+ remove_task 'deps:email'
47
+ remove_task 'multi'
48
+ remove_task 'newb'
50
49
 
51
50
 
52
51
 
data/lib/kyanite.rb CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
 
8
8
  if $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
9
- puts 'Path schon aktuell'
9
+ #puts 'Path schon aktuell'
10
10
  else
11
11
  $:.unshift(File.dirname(__FILE__))
12
12
  end
@@ -57,7 +57,7 @@ end
57
57
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
58
58
  #
59
59
  module Kyanite
60
- VERSION = '0.5.1'
60
+ VERSION = '0.5.2'
61
61
  end
62
62
 
63
63
 
@@ -68,7 +68,7 @@ module KKernel
68
68
  __file__ = caller[0] unless __file__
69
69
  dir_caller =File.dirname(__file__)
70
70
 
71
- puts "dircaller " + dir_caller
71
+ #puts "smart_load_path " + dir_caller
72
72
 
73
73
  patharray = dir_caller.split('/')
74
74
  patharray = dir_caller.split("\\") if patharray.size == 1
@@ -0,0 +1,6 @@
1
+ # ruby encoding: utf-8
2
+ # smart load path für die Anwendung via installiertem gem
3
+ require 'kyanite/general/kernel'
4
+
5
+
6
+
@@ -7,7 +7,7 @@ require 'kyanite/string/diff'
7
7
  require 'kyanite/string/div'
8
8
  require 'kyanite/string/include'
9
9
  require 'kyanite/string/list'
10
- #require 'kyanite/string/mgsub'
10
+ require 'kyanite/string/mgsub'
11
11
  require 'kyanite/string/nested'
12
12
  require 'kyanite/string/random'
13
13
  require 'kyanite/string/split'
@@ -3,18 +3,18 @@ require File.join(File.dirname(__FILE__), '..', '..', '..', 'smart_load_path.rb'
3
3
  require 'kyanite/string/chars_const'
4
4
 
5
5
 
6
- # unless defined? MYSQL_REPLACES
7
- # MYSQL_REPLACES = [
8
- # [/ä/, 'a'],
9
- # [/ö/, 'o'],
10
- # [/ü/, 'u'],
11
- # [/Ä/, 'a'],
12
- # [/Ö/, 'o'],
13
- # [/Ü/, 'u'],
14
- # [/ss/, 'ß'],
15
- # [/SS/, 'ß']
16
- # ]
17
- # end
6
+ unless defined? MYSQL_REPLACES
7
+ MYSQL_REPLACES = [
8
+ [/ä/, 'a'],
9
+ [/ö/, 'o'],
10
+ [/ü/, 'u'],
11
+ [/Ä/, 'a'],
12
+ [/Ö/, 'o'],
13
+ [/Ü/, 'u'],
14
+ [/ss/, 'ß'],
15
+ [/SS/, 'ß']
16
+ ]
17
+ end
18
18
 
19
19
 
20
20
 
@@ -36,12 +36,13 @@ class String
36
36
  # See TestKyaniteStringChars for tests and examples.
37
37
  #
38
38
  def reduce94( options={} )
39
- dup.reduce94!
39
+ dup.reduce94!(options)
40
40
  end
41
41
 
42
42
  # See TestKyaniteStringChars for tests and examples.
43
43
  #
44
- def reduce94!( options={} )
44
+ def reduce94!( options={} )
45
+ self.gsub!( 'ß', options[:german_sz] ) if options[:german_sz]
45
46
  self.tr!(TR_FULL, TR_REDUCED)
46
47
  self.delete!('^ -~')
47
48
  self
@@ -61,12 +62,15 @@ class String
61
62
  # See TestKyaniteStringChars for tests and examples.
62
63
  #
63
64
  def reduce53!( options={} )
65
+
64
66
  if options[:camelcase]
65
67
  self.gsub!(/([A-Z]+)([A-Z][a-z])/,'\1-\2')
66
68
  self.gsub!(/([a-z\d])([A-Z])/,'\1-\2')
67
69
  end
70
+
71
+ self.gsub!( 'ß', options[:german_sz] ) if options[:german_sz]
68
72
  self.tr!('abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')
69
- self.gsub!( 'ß', options[:german_sz] ) if options[:german_sz]
73
+
70
74
  self.tr!(TR_FULL, TR_REDUCED.downcase)
71
75
  unless options[:space]
72
76
  self.delete!('^- A-Za-z')
@@ -177,7 +181,8 @@ if $0 == __FILE__ then
177
181
 
178
182
  #require 'perception'
179
183
 
180
- puts 'über'.capitalize
184
+ #puts "Hallo"
185
+ puts 'Scheiße'.reduce94(:german_sz => 'z')
181
186
 
182
187
 
183
188
 
@@ -0,0 +1,44 @@
1
+ # ruby encoding: utf-8
2
+ # ü
3
+ require File.join(File.dirname(__FILE__), '..', '..', '..', 'smart_load_path.rb' ); smart_load_path if $0 == __FILE__
4
+ require 'kyanite/string/mgsub'
5
+
6
+
7
+ class String
8
+
9
+ # ---------------------------------------------------------------------------------------------------------------------------------
10
+ # :section: mgsub
11
+ #
12
+
13
+ # Mehrere Patterns mit einer RegExp replacen.
14
+ # Ruby Cookbook Seite 32
15
+ # "between".mgsub([[/ee/, 'AA'], [/e/, 'E']]) # Good code
16
+ # => "bEtwAAn"
17
+ #
18
+ def mgsub(key_value_pairs=[].freeze)
19
+ regexp_fragments = key_value_pairs.collect { |k,v| k }
20
+ gsub(Regexp.union(*regexp_fragments)) do |match|
21
+ key_value_pairs.detect{|k,v| k =~ match}[1]
22
+ end
23
+ end
24
+ # http://oreilly.com/catalog/9780596523695/
25
+ # Ruby Cookbook, by Lucas Carlson and Leonard Richardson
26
+ # Copyright 2006 O'Reilly Media
27
+
28
+ end # class
29
+
30
+
31
+ class NilClass
32
+ def mgsub(*a); nil; end
33
+ end
34
+
35
+
36
+
37
+ # -----------------------------------------------------------------------------------------
38
+ # ausprobieren
39
+ #
40
+ if $0 == __FILE__ then
41
+
42
+ puts "between".mgsub([[/ee/, 'AA'], [/e/, 'E']])
43
+
44
+ end # if
data/test/_start_all.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # ruby encoding: utf-8
1
2
  #!/usr/bin/env ruby
2
3
  #
3
4
  # Führt alle Tests aus
@@ -112,14 +112,16 @@ ENDOFSTRING
112
112
  assert_equal 'scheiße', 'SCHEIßE'.downcase2
113
113
  assert_equal 'Scheise', 'Scheiße'.reduce94
114
114
  assert_equal 'SCHEIsE', 'Scheiße'.reduce53
115
- assert_equal 'SCHEIzE', 'Scheiße'.reduce53(:german_sz => 'z')
115
+ assert_equal 'SCHEIZE', 'Scheiße'.reduce53(:german_sz => 'z')
116
116
  assert_equal 'SCHEIZE', 'Scheiße'.reduce53(:german_sz => 'Z')
117
117
  assert_equal 'SCHEISSE', 'Scheiße'.reduce53(:german_sz => 'SS')
118
118
 
119
119
  # geht vielleicht in Ruby 1.9
120
- # assert_equal 'Scheize', 'Scheiße'.reduce94(:german_sz => 'z')
121
- # assert_equal 'ScheiZe', 'Scheiße'.reduce94(:german_sz => 'Z')
122
- # assert_equal 'Scheisse', 'Scheiße'.reduce94(:german_sz => 'ss')
120
+ assert_equal 'Scheize', 'Scheiße'.reduce94(:german_sz => 'z')
121
+ assert_equal 'ScheiZe', 'Scheiße'.reduce94(:german_sz => 'Z')
122
+ assert_equal 'Scheisse', 'Scheiße'.reduce94(:german_sz => 'ss')
123
+ assert_equal 'Schei$e', 'Scheiße'.reduce94(:german_sz => '$')
124
+ assert_equal 'Schei$e', 'Schei$e'.reduce94
123
125
  end
124
126
 
125
127
 
@@ -0,0 +1,53 @@
1
+ # ruby encoding: utf-8
2
+ require File.join(File.dirname(__FILE__), '..', '..', 'smart_load_path.rb' ); smart_load_path if $0 == __FILE__
3
+ require 'kyanite/unit_test'
4
+ require 'kyanite/string/mgsub'
5
+
6
+
7
+
8
+ # Tests for String
9
+ #
10
+ class TestKyaniteStringMgsub < UnitTest
11
+
12
+ def test_mgsub
13
+ assert_equal 'bEtwAAn', 'between'.mgsub([[/ee/, 'AA'], [/e/, 'E']])
14
+ end
15
+
16
+
17
+
18
+
19
+
20
+ end # class
21
+
22
+
23
+
24
+
25
+
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
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kyanite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-08 00:00:00.000000000 Z
12
+ date: 2012-10-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -109,7 +109,6 @@ files:
109
109
  - README.txt
110
110
  - Rakefile.rb
111
111
  - init.rb
112
- - smart_load_path.rb
113
112
  - lib/kyanite.rb
114
113
  - lib/kyanite/array.rb
115
114
  - lib/kyanite/array/array.rb
@@ -148,6 +147,7 @@ files:
148
147
  - lib/kyanite/rake.rb
149
148
  - lib/kyanite/range.rb
150
149
  - lib/kyanite/set.rb
150
+ - lib/kyanite/smart_load_path.rb
151
151
  - lib/kyanite/string.rb
152
152
  - lib/kyanite/string/cast.rb
153
153
  - lib/kyanite/string/chars.rb
@@ -156,6 +156,7 @@ files:
156
156
  - lib/kyanite/string/div.rb
157
157
  - lib/kyanite/string/include.rb
158
158
  - lib/kyanite/string/list.rb
159
+ - lib/kyanite/string/mgsub.rb
159
160
  - lib/kyanite/string/nested.rb
160
161
  - lib/kyanite/string/random.rb
161
162
  - lib/kyanite/string/split.rb
@@ -188,8 +189,9 @@ files:
188
189
  - test/test_range.rb
189
190
  - test/test_set.rb
190
191
  - test/test_tree.rb
192
+ - test/string/test_mgsub.rb
191
193
  - .gemtest
192
- homepage:
194
+ homepage: http://kyanite.rubyforge.org
193
195
  licenses: []
194
196
  post_install_message:
195
197
  rdoc_options:
@@ -231,6 +233,7 @@ test_files:
231
233
  - test/string/test_chars.rb
232
234
  - test/string/test_diff.rb
233
235
  - test/string/test_list.rb
236
+ - test/string/test_mgsub.rb
234
237
  - test/string/test_nested.rb
235
238
  - test/string/test_split.rb
236
239
  - test/test_dictionary.rb
data/smart_load_path.rb DELETED
@@ -1,6 +0,0 @@
1
-
2
- require File.join( File.dirname(__FILE__), 'lib', 'kyanite', 'general', 'kernel.rb' )
3
- # require 'perception'
4
- require 'ap' # awesome_print
5
-
6
-