pebblebed 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/pebblebed/uid.rb +18 -5
- data/lib/pebblebed/version.rb +1 -1
- data/spec/uid_spec.rb +51 -9
- metadata +28 -28
data/lib/pebblebed/uid.rb
CHANGED
@@ -27,7 +27,7 @@ module Pebblebed
|
|
27
27
|
def oid=(value)
|
28
28
|
return @oid = nil if value == '' || value.nil?
|
29
29
|
raise InvalidUid, "Invalid oid '#{value}'" unless self.class.valid_oid?(value)
|
30
|
-
@oid = (value.strip != "") ? value : nil
|
30
|
+
@oid = (value.strip != "") ? CGI.unescape(value) : nil
|
31
31
|
end
|
32
32
|
|
33
33
|
def self.raw_parse(string)
|
@@ -36,7 +36,7 @@ module Pebblebed
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def self.valid?(string)
|
39
|
-
begin
|
39
|
+
begin
|
40
40
|
true if new(string)
|
41
41
|
rescue InvalidUid
|
42
42
|
false
|
@@ -53,12 +53,17 @@ module Pebblebed
|
|
53
53
|
end
|
54
54
|
|
55
55
|
def self.valid_klass?(value)
|
56
|
-
|
56
|
+
return false if value =~ /^\.+$/
|
57
|
+
return false if value == ""
|
58
|
+
value.split('.').each do |label|
|
59
|
+
return false unless self.valid_label?(label)
|
60
|
+
end
|
61
|
+
true
|
57
62
|
end
|
58
63
|
|
59
64
|
def self.valid_path?(value)
|
60
65
|
# catches a stupid edge case in ruby where "..".split('.') == [] instead of ["", "", ""]
|
61
|
-
return false if value =~ /^\.+$/
|
66
|
+
return false if value =~ /^\.+$/
|
62
67
|
value.split('.').each do |label|
|
63
68
|
return false unless self.valid_label?(label)
|
64
69
|
end
|
@@ -80,7 +85,15 @@ module Pebblebed
|
|
80
85
|
def to_s
|
81
86
|
"#{@klass}:#{@path}$#{@oid}".chomp("$")
|
82
87
|
end
|
83
|
-
alias_method :to_uid, :to_s
|
88
|
+
alias_method :to_uid, :to_s
|
89
|
+
|
90
|
+
def ==(other)
|
91
|
+
self.to_uid == other.to_uid
|
92
|
+
end
|
93
|
+
|
94
|
+
def eql?(other)
|
95
|
+
self == other
|
96
|
+
end
|
84
97
|
|
85
98
|
end
|
86
99
|
end
|
data/lib/pebblebed/version.rb
CHANGED
data/spec/uid_spec.rb
CHANGED
@@ -43,6 +43,10 @@ describe Pebblebed::Uid do
|
|
43
43
|
-> { Pebblebed::Uid.new("!:$298") }.should raise_error Pebblebed::InvalidUid
|
44
44
|
end
|
45
45
|
|
46
|
+
it "CGI unescapes the incoming oid" do
|
47
|
+
Pebblebed::Uid.new('klass:path$abc+123').oid.should eq('abc 123')
|
48
|
+
end
|
49
|
+
|
46
50
|
it "raises an exception when you modify a uid with an invalid value" do
|
47
51
|
uid = Pebblebed::Uid.new("klass:path$oid")
|
48
52
|
-> { uid.klass = "!" }.should raise_error Pebblebed::InvalidUid
|
@@ -50,19 +54,46 @@ describe Pebblebed::Uid do
|
|
50
54
|
-> { uid.oid = "/" }.should raise_error Pebblebed::InvalidUid
|
51
55
|
end
|
52
56
|
|
53
|
-
describe "
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
57
|
+
describe "klass" do
|
58
|
+
let(:uid) { Pebblebed::Uid.new("klass:path$oid") }
|
59
|
+
|
60
|
+
it "allows sub-klasses" do
|
61
|
+
->{ uid.klass = "sub.sub.class" }.should_not raise_error
|
58
62
|
end
|
59
63
|
|
60
|
-
|
61
|
-
|
64
|
+
describe "is valid" do
|
65
|
+
%w(. - _ 8).each do |nice_character|
|
66
|
+
it "with '#{nice_character}'" do
|
67
|
+
->{ uid.klass = "a#{nice_character}z" }.should_not raise_error
|
68
|
+
end
|
69
|
+
end
|
62
70
|
end
|
63
71
|
|
64
|
-
|
65
|
-
|
72
|
+
describe "is invalid" do
|
73
|
+
%w(! / : $ % $).each do |funky_character|
|
74
|
+
specify "with '#{funky_character}'" do
|
75
|
+
->{ uid.klass = "a#{funky_character}z" }.should raise_error Pebblebed::InvalidUid
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe "oid" do
|
82
|
+
[
|
83
|
+
"abc123",
|
84
|
+
"abc123!@\#$%^&*()[]{}",
|
85
|
+
"abc 123",
|
86
|
+
"alice@example.com",
|
87
|
+
"abc/123",
|
88
|
+
"post:some.path$oid",
|
89
|
+
].each do |oid|
|
90
|
+
specify "'#{oid}' is a valid oid if GCI escaped" do
|
91
|
+
Pebblebed::Uid.valid_oid?(CGI.escape(oid)).should be_true
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
specify "'abc/123' is an invalid oid" do
|
96
|
+
Pebblebed::Uid.valid_oid?('abc/123').should be_false
|
66
97
|
end
|
67
98
|
|
68
99
|
it "can be missing" do
|
@@ -126,4 +157,15 @@ describe Pebblebed::Uid do
|
|
126
157
|
Pebblebed::Uid.new("klass:realm").realm.should eq 'realm'
|
127
158
|
Pebblebed::Uid.new("klass:$3").realm.should eq nil
|
128
159
|
end
|
160
|
+
|
161
|
+
describe "equality" do
|
162
|
+
let(:uid) { "klass:realm$3" }
|
163
|
+
it "is dependent on the actual uid" do
|
164
|
+
Pebblebed::Uid.new("klass:realm$3").should eq Pebblebed::Uid.new("klass:realm$3")
|
165
|
+
end
|
166
|
+
|
167
|
+
it "also works for eql?" do
|
168
|
+
Pebblebed::Uid.new("klass:realm$3").eql?(Pebblebed::Uid.new("klass:realm$3")).should be_true
|
169
|
+
end
|
170
|
+
end
|
129
171
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pebblebed
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,11 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-02-11 00:00:00.000000000Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rspec
|
17
|
-
requirement: &
|
17
|
+
requirement: &70100401716200 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: '0'
|
23
23
|
type: :development
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *70100401716200
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: rake
|
28
|
-
requirement: &
|
28
|
+
requirement: &70100401695520 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ! '>='
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *70100401695520
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: simplecov
|
39
|
-
requirement: &
|
39
|
+
requirement: &70100401693340 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ! '>='
|
@@ -44,10 +44,10 @@ dependencies:
|
|
44
44
|
version: '0'
|
45
45
|
type: :development
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *70100401693340
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: deepstruct
|
50
|
-
requirement: &
|
50
|
+
requirement: &70100401689760 !ruby/object:Gem::Requirement
|
51
51
|
none: false
|
52
52
|
requirements:
|
53
53
|
- - ! '>='
|
@@ -55,10 +55,10 @@ dependencies:
|
|
55
55
|
version: '0'
|
56
56
|
type: :runtime
|
57
57
|
prerelease: false
|
58
|
-
version_requirements: *
|
58
|
+
version_requirements: *70100401689760
|
59
59
|
- !ruby/object:Gem::Dependency
|
60
60
|
name: curb
|
61
|
-
requirement: &
|
61
|
+
requirement: &70100401686640 !ruby/object:Gem::Requirement
|
62
62
|
none: false
|
63
63
|
requirements:
|
64
64
|
- - ~>
|
@@ -66,10 +66,10 @@ dependencies:
|
|
66
66
|
version: 0.8.0
|
67
67
|
type: :runtime
|
68
68
|
prerelease: false
|
69
|
-
version_requirements: *
|
69
|
+
version_requirements: *70100401686640
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: yajl-ruby
|
72
|
-
requirement: &
|
72
|
+
requirement: &70100401685440 !ruby/object:Gem::Requirement
|
73
73
|
none: false
|
74
74
|
requirements:
|
75
75
|
- - ! '>='
|
@@ -77,10 +77,10 @@ dependencies:
|
|
77
77
|
version: '0'
|
78
78
|
type: :runtime
|
79
79
|
prerelease: false
|
80
|
-
version_requirements: *
|
80
|
+
version_requirements: *70100401685440
|
81
81
|
- !ruby/object:Gem::Dependency
|
82
82
|
name: queryparams
|
83
|
-
requirement: &
|
83
|
+
requirement: &70100401682920 !ruby/object:Gem::Requirement
|
84
84
|
none: false
|
85
85
|
requirements:
|
86
86
|
- - ! '>='
|
@@ -88,10 +88,10 @@ dependencies:
|
|
88
88
|
version: '0'
|
89
89
|
type: :runtime
|
90
90
|
prerelease: false
|
91
|
-
version_requirements: *
|
91
|
+
version_requirements: *70100401682920
|
92
92
|
- !ruby/object:Gem::Dependency
|
93
93
|
name: futurevalue
|
94
|
-
requirement: &
|
94
|
+
requirement: &70100401673000 !ruby/object:Gem::Requirement
|
95
95
|
none: false
|
96
96
|
requirements:
|
97
97
|
- - ! '>='
|
@@ -99,10 +99,10 @@ dependencies:
|
|
99
99
|
version: '0'
|
100
100
|
type: :runtime
|
101
101
|
prerelease: false
|
102
|
-
version_requirements: *
|
102
|
+
version_requirements: *70100401673000
|
103
103
|
- !ruby/object:Gem::Dependency
|
104
104
|
name: pathbuilder
|
105
|
-
requirement: &
|
105
|
+
requirement: &70100401670800 !ruby/object:Gem::Requirement
|
106
106
|
none: false
|
107
107
|
requirements:
|
108
108
|
- - ! '>='
|
@@ -110,10 +110,10 @@ dependencies:
|
|
110
110
|
version: '0'
|
111
111
|
type: :runtime
|
112
112
|
prerelease: false
|
113
|
-
version_requirements: *
|
113
|
+
version_requirements: *70100401670800
|
114
114
|
- !ruby/object:Gem::Dependency
|
115
115
|
name: nokogiri
|
116
|
-
requirement: &
|
116
|
+
requirement: &70100401668060 !ruby/object:Gem::Requirement
|
117
117
|
none: false
|
118
118
|
requirements:
|
119
119
|
- - ! '>='
|
@@ -121,10 +121,10 @@ dependencies:
|
|
121
121
|
version: '0'
|
122
122
|
type: :runtime
|
123
123
|
prerelease: false
|
124
|
-
version_requirements: *
|
124
|
+
version_requirements: *70100401668060
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: i18n
|
127
|
-
requirement: &
|
127
|
+
requirement: &70100401664220 !ruby/object:Gem::Requirement
|
128
128
|
none: false
|
129
129
|
requirements:
|
130
130
|
- - ! '>='
|
@@ -132,10 +132,10 @@ dependencies:
|
|
132
132
|
version: '0'
|
133
133
|
type: :runtime
|
134
134
|
prerelease: false
|
135
|
-
version_requirements: *
|
135
|
+
version_requirements: *70100401664220
|
136
136
|
- !ruby/object:Gem::Dependency
|
137
137
|
name: activesupport
|
138
|
-
requirement: &
|
138
|
+
requirement: &70100401649520 !ruby/object:Gem::Requirement
|
139
139
|
none: false
|
140
140
|
requirements:
|
141
141
|
- - ! '>='
|
@@ -143,7 +143,7 @@ dependencies:
|
|
143
143
|
version: '0'
|
144
144
|
type: :runtime
|
145
145
|
prerelease: false
|
146
|
-
version_requirements: *
|
146
|
+
version_requirements: *70100401649520
|
147
147
|
description: Development tools for working with Pebblebed
|
148
148
|
email:
|
149
149
|
- katrina@bengler.no
|
@@ -192,7 +192,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
192
192
|
version: '0'
|
193
193
|
segments:
|
194
194
|
- 0
|
195
|
-
hash: -
|
195
|
+
hash: -3792666451732932107
|
196
196
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
197
197
|
none: false
|
198
198
|
requirements:
|
@@ -201,7 +201,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
201
201
|
version: '0'
|
202
202
|
segments:
|
203
203
|
- 0
|
204
|
-
hash: -
|
204
|
+
hash: -3792666451732932107
|
205
205
|
requirements: []
|
206
206
|
rubyforge_project: pebblebed
|
207
207
|
rubygems_version: 1.8.10
|