string19 0.0.1 → 0.0.2

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.
Files changed (5) hide show
  1. data/Readme.md +21 -0
  2. data/VERSION +1 -1
  3. data/lib/string19.rb +11 -4
  4. data/string19.gemspec +3 -4
  5. metadata +8 -6
data/Readme.md CHANGED
@@ -14,6 +14,27 @@ Usage
14
14
  # on 1.8 AND 1.9
15
15
  String19("Á§ÐÁ§Ð").size == 6
16
16
 
17
+ # to add a new wrapped method (result is a String19)
18
+ class String
19
+ def foo
20
+ 'fäää'
21
+ end
22
+ end
23
+
24
+ String19::Wrapped.wrap(:foo) if String19::IS_19
25
+ String19('').foo.size == 4
26
+
27
+ # to add a new delegated method (result is not modified)
28
+ class String
29
+ def foo
30
+ 42
31
+ end
32
+ end
33
+
34
+ String19::Wrapped.delegate(:foo) if String19::IS_19
35
+
36
+ String19('').foo == 42
37
+
17
38
  Author
18
39
  ======
19
40
  [Michael Grosser](http://grosser.it)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
data/lib/string19.rb CHANGED
@@ -66,13 +66,20 @@ if String19::IS_18
66
66
  String19(s[0...found]).size
67
67
  end
68
68
 
69
- %w[slice slice! []].each do |wrapped|
70
- eval("def #{wrapped}(*args, &block); String19(@chars.#{wrapped}(*args, &block)); end")
69
+ def self.wrap(*args)
70
+ args.each do |method|
71
+ eval("def #{method}(*args, &block); String19(@chars.#{method}(*args, &block)); end")
72
+ end
71
73
  end
72
74
 
73
- %w[size].each do |delegated|
74
- eval("def #{delegated}(*args, &block); @chars.#{delegated}(*args, &block); end")
75
+ def self.delegate(*args)
76
+ args.each do |method|
77
+ eval("def #{method}(*args, &block); @chars.#{method}(*args, &block); end")
78
+ end
75
79
  end
80
+
81
+ wrap *%w[dup slice slice! []]
82
+ delegate :size
76
83
  end
77
84
  end
78
85
  else
data/string19.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{string19}
8
- s.version = "0.0.1"
8
+ s.version = "0.0.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Michael Grosser"]
12
- s.date = %q{2011-01-15}
12
+ s.date = %q{2011-01-16}
13
13
  s.email = %q{michael@grosser.it}
14
14
  s.files = [
15
15
  "Gemfile",
@@ -26,7 +26,7 @@ Gem::Specification.new do |s|
26
26
  ]
27
27
  s.homepage = %q{http://github.com/grosser/string19}
28
28
  s.require_paths = ["lib"]
29
- s.rubygems_version = %q{1.3.7}
29
+ s.rubygems_version = %q{1.4.2}
30
30
  s.summary = %q{A Ruby string that behaves like 1.9 and runs on 1.8}
31
31
  s.test_files = [
32
32
  "spec/spec_helper.rb",
@@ -34,7 +34,6 @@ Gem::Specification.new do |s|
34
34
  ]
35
35
 
36
36
  if s.respond_to? :specification_version then
37
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
38
37
  s.specification_version = 3
39
38
 
40
39
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: string19
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
4
+ hash: 27
5
+ prerelease:
5
6
  segments:
6
7
  - 0
7
8
  - 0
8
- - 1
9
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
10
11
  platform: ruby
11
12
  authors:
12
13
  - Michael Grosser
@@ -14,7 +15,7 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2011-01-15 00:00:00 +01:00
18
+ date: 2011-01-16 00:00:00 +01:00
18
19
  default_executable:
19
20
  dependencies: []
20
21
 
@@ -52,7 +53,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
52
53
  requirements:
53
54
  - - ">="
54
55
  - !ruby/object:Gem::Version
55
- hash: -691162189
56
+ hash: 3
56
57
  segments:
57
58
  - 0
58
59
  version: "0"
@@ -61,13 +62,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
61
62
  requirements:
62
63
  - - ">="
63
64
  - !ruby/object:Gem::Version
65
+ hash: 3
64
66
  segments:
65
67
  - 0
66
68
  version: "0"
67
69
  requirements: []
68
70
 
69
71
  rubyforge_project:
70
- rubygems_version: 1.3.7
72
+ rubygems_version: 1.4.2
71
73
  signing_key:
72
74
  specification_version: 3
73
75
  summary: A Ruby string that behaves like 1.9 and runs on 1.8