string19 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/Readme.md CHANGED
@@ -21,7 +21,7 @@ Usage
21
21
  end
22
22
  end
23
23
 
24
- String19::Wrapped.wrap(:foo) if String19::IS_19
24
+ String19::Wrapped.wrap(:foo) if String19::IS_18
25
25
  String19('').foo.size == 4
26
26
 
27
27
  # to add a new delegated method (result is not modified)
@@ -31,7 +31,7 @@ Usage
31
31
  end
32
32
  end
33
33
 
34
- String19::Wrapped.delegate(:foo) if String19::IS_19
34
+ String19::Wrapped.delegate(:foo) if String19::IS_18
35
35
 
36
36
  String19('').foo == 42
37
37
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
@@ -1,5 +1,5 @@
1
1
  module String19
2
2
  class BlankSlate
3
- instance_methods.each { |m| undef_method m unless m =~ /^(__|instance_|should)/ }
3
+ instance_methods.each { |m| undef_method m unless m =~ /^(__|instance_|should|respond_to\?)/ }
4
4
  end
5
5
  end
data/lib/string19.rb CHANGED
@@ -23,11 +23,11 @@ if String19::IS_18
23
23
  end
24
24
 
25
25
  def bytesize
26
- to_s18.size
26
+ to_s.size
27
27
  end
28
28
 
29
29
  def bytes
30
- to_s18.bytes
30
+ to_s.bytes
31
31
  end
32
32
 
33
33
  def encoding
@@ -43,15 +43,11 @@ if String19::IS_18
43
43
  end
44
44
 
45
45
  def ==(other)
46
- other = other.to_s18 if other.is_a?(String19::Wrapper)
47
- other.is_a?(String) and to_s18 == other
46
+ other = other.to_s if other.is_a?(String19::Wrapper)
47
+ other.is_a?(String) and to_s == other
48
48
  end
49
49
 
50
50
  def to_s
51
- self
52
- end
53
-
54
- def to_s18
55
51
  @chars.to_s
56
52
  end
57
53
 
@@ -60,8 +56,8 @@ if String19::IS_18
60
56
  end
61
57
 
62
58
  def index(what, offset=0)
63
- s = to_s18
64
- offset = self[0...offset].to_s18.size
59
+ s = to_s
60
+ offset = self[0...offset].to_s.size
65
61
  return unless found = s.index(what, offset)
66
62
  String19(s[0...found]).size
67
63
  end
@@ -78,7 +74,7 @@ if String19::IS_18
78
74
  end
79
75
  end
80
76
 
81
- wrap *%w[dup slice slice! []]
77
+ wrap :dup, :slice, :slice!, :[], :inspect
82
78
  delegate :size
83
79
  end
84
80
  end
@@ -53,6 +53,19 @@ describe String19 do
53
53
  String19('äåé').should_not == ['äåé']
54
54
  end
55
55
 
56
+ describe :to_s do
57
+ it "returns a string19" do
58
+ pending 'making #{} work is top priority'
59
+ String19('äåé').to_s.size.should == 3
60
+ end
61
+
62
+ it "is the same" do
63
+ pending 'making #{} work is top priority'
64
+ a = String19('äåé')
65
+ a.to_s.object_id.should == a.object_id
66
+ end
67
+ end
68
+
56
69
  describe :index do
57
70
  it "has nil index" do
58
71
  String19("bb").index('a').should == nil
@@ -105,4 +118,20 @@ describe String19 do
105
118
  String19("ßä").bytes.to_a.should == [195, 159, 195, 164]
106
119
  end
107
120
  end
121
+
122
+ describe :respond_to? do
123
+ it "is true for mapped methods" do
124
+ String19('x').respond_to?(:valid_encoding?).should == true
125
+ end
126
+
127
+ it "is false for not mapped methods" do
128
+ String19('x').respond_to?(:foo).should == false
129
+ end
130
+ end
131
+
132
+ describe 'replacement' do
133
+ it "behaves like a string" do
134
+ "#{String19('xxx')}".should == "xxx"
135
+ end
136
+ end
108
137
  end
data/string19.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{string19}
8
- s.version = "0.0.2"
8
+ s.version = "0.0.3"
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"]
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: string19
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Michael Grosser