verbal_expressions 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/Gemfile +1 -0
- data/Gemfile.lock +5 -0
- data/VERSION +1 -1
- data/lib/verbal_expressions.rb +6 -2
- data/spec/spec_helper.rb +4 -0
- data/spec/verbal_expressions_spec.rb +154 -0
- data/verbal_expressions.gemspec +5 -2
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NmE5MjQzNTVkNWViNDgxN2VlMWEyOWViMTViOTJiZjIyZDhkNjVjYw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MjI0ZmNhYzA4YTY2Y2ExMTI1MzBmNzE5M2NkNDlmN2ExNmQ4ZDcyNA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MjJhNGI0ZWFmZTMxY2NiYzVlZmQ0ZDI2YWQ2OTdkMWY3NWVjMDc1MWNiM2Nj
|
10
|
+
MmMxMzliMjFhZDNhNWM4ZTRlZGYyYWQxMGMzY2RmZjAwOWEyNzMyMzRjOTI1
|
11
|
+
NjUyMzYyNGEyZWMzNzdlNTE5NzViY2RiYzFiYzhmNDVmYzAxZGE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NzNhZWMzMDczMGJkYTBhMmNkNzliYjYyN2U4ZWJhOWE3MDQ5Njc5NTM4Nzcw
|
14
|
+
ZjQ0ODk1MGJmNTU0YTY2YjU1Y2Y4NzM0YjEwOWRmYjdhMDQ1MTAyYTk1Zjg5
|
15
|
+
OTdkOTQwYzU1MzZlYmJlNWYxZmQ3ZDljNzEwNzI2YWQ5OGUwODE=
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -52,6 +52,10 @@ GEM
|
|
52
52
|
rspec-expectations (2.14.0)
|
53
53
|
diff-lcs (>= 1.1.3, < 2.0)
|
54
54
|
rspec-mocks (2.14.1)
|
55
|
+
simplecov (0.7.1)
|
56
|
+
multi_json (~> 1.0)
|
57
|
+
simplecov-html (~> 0.7.1)
|
58
|
+
simplecov-html (0.7.1)
|
55
59
|
|
56
60
|
PLATFORMS
|
57
61
|
ruby
|
@@ -61,3 +65,4 @@ DEPENDENCIES
|
|
61
65
|
jeweler (~> 1.8.4)
|
62
66
|
rdoc (~> 3.12)
|
63
67
|
rspec (~> 2.14.0)
|
68
|
+
simplecov
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.4
|
data/lib/verbal_expressions.rb
CHANGED
@@ -100,7 +100,7 @@ class VerEx < Regexp
|
|
100
100
|
|
101
101
|
def multiple(value)
|
102
102
|
value = sanitize(value)
|
103
|
-
value += "+"
|
103
|
+
value += "+"
|
104
104
|
add(value)
|
105
105
|
end
|
106
106
|
|
@@ -127,7 +127,11 @@ class VerEx < Regexp
|
|
127
127
|
add(")")
|
128
128
|
end
|
129
129
|
|
130
|
-
|
130
|
+
def capture(name = nil, &block)
|
131
|
+
begin_capture(name)
|
132
|
+
yield
|
133
|
+
end_capture
|
134
|
+
end
|
131
135
|
|
132
136
|
private
|
133
137
|
|
data/spec/spec_helper.rb
CHANGED
@@ -1,8 +1,12 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
SimpleCov.start
|
3
|
+
|
1
4
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
5
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
6
|
require 'rspec'
|
4
7
|
require 'verbal_expressions'
|
5
8
|
|
9
|
+
|
6
10
|
# Requires supporting files with custom matchers and macros, etc,
|
7
11
|
# in ./support/ and its subdirectories.
|
8
12
|
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
@@ -19,6 +19,20 @@ describe VerEx do
|
|
19
19
|
matcher.match('Jerry scored 5 goals!')['goals'].should == '5'
|
20
20
|
end
|
21
21
|
|
22
|
+
context 'with a block' do
|
23
|
+
|
24
|
+
let(:matcher) do
|
25
|
+
VerEx.new do
|
26
|
+
find 'scored '
|
27
|
+
capture('goals') { word }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'Successfully captures player by index' do
|
32
|
+
matcher.match('Jerry scored 5 goals!')['goals'].should == '5'
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
22
36
|
end
|
23
37
|
|
24
38
|
describe 'without name' do
|
@@ -36,6 +50,18 @@ describe VerEx do
|
|
36
50
|
matcher.match('Jerry scored 5 goals!')[1].should == 'Jerry'
|
37
51
|
end
|
38
52
|
|
53
|
+
context 'with a block' do
|
54
|
+
let(:matcher) do
|
55
|
+
VerEx.new do
|
56
|
+
start_of_line
|
57
|
+
capture { word }
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'Successfully captures player by index' do
|
62
|
+
matcher.match('Jerry scored 5 goals!')[1].should == 'Jerry'
|
63
|
+
end
|
64
|
+
end
|
39
65
|
end
|
40
66
|
|
41
67
|
end
|
@@ -65,6 +91,134 @@ describe VerEx do
|
|
65
91
|
end
|
66
92
|
end
|
67
93
|
|
94
|
+
describe '#alternatively' do
|
95
|
+
|
96
|
+
describe 'matches a link' do
|
97
|
+
|
98
|
+
let(:matcher) do
|
99
|
+
VerEx.new do
|
100
|
+
find 'http://'
|
101
|
+
alternatively
|
102
|
+
find 'ftp://'
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
it 'matches ftp://' do
|
107
|
+
matcher.match('ftp://ftp.google.com/').should be_true
|
108
|
+
end
|
109
|
+
|
110
|
+
it 'matches http://' do
|
111
|
+
matcher.match('http://www.google.com').should be_true
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
describe '#anything' do
|
117
|
+
|
118
|
+
let(:matcher) do
|
119
|
+
VerEx.new do
|
120
|
+
anything
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
it 'matches anything' do
|
125
|
+
matcher.match('The quick brown fox jumps over the lazy dog.').should be_true
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
describe '#any_of' do
|
130
|
+
|
131
|
+
let(:matcher) do
|
132
|
+
VerEx.new do
|
133
|
+
any_of 'aeiou'
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
it 'finds a vowel' do
|
138
|
+
matcher.match('fox').should be_true
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
describe '#multiple' do
|
143
|
+
|
144
|
+
it 'matches 1111' do
|
145
|
+
matcher = VerEx.new do
|
146
|
+
multiple '1'
|
147
|
+
end
|
148
|
+
|
149
|
+
matcher.match('111111111').should be_true
|
150
|
+
end
|
151
|
+
|
152
|
+
it 'matches multiple +s' do
|
153
|
+
matcher = VerEx.new do
|
154
|
+
multiple '+'
|
155
|
+
end
|
156
|
+
|
157
|
+
matcher.match('++++').should be_true
|
158
|
+
end
|
159
|
+
|
160
|
+
it 'captures multiple successfully' do
|
161
|
+
matcher = VerEx.new do
|
162
|
+
capture('mult') { multiple '+' }
|
163
|
+
end
|
164
|
+
|
165
|
+
matcher.match('+++++')['mult'].should == '+++++'
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
describe '#line_break' do
|
170
|
+
|
171
|
+
let(:multiline) do
|
172
|
+
%Q{
|
173
|
+
I'm a multiline
|
174
|
+
string.
|
175
|
+
}
|
176
|
+
end
|
177
|
+
|
178
|
+
it 'fails without line break' do
|
179
|
+
matcher = VerEx.new do
|
180
|
+
line_break
|
181
|
+
end
|
182
|
+
|
183
|
+
matcher.match('hello world').should be_false
|
184
|
+
end
|
185
|
+
|
186
|
+
it 'works as line_break' do
|
187
|
+
matcher = VerEx.new do
|
188
|
+
line_break
|
189
|
+
end
|
190
|
+
|
191
|
+
matcher.match(multiline).should be_true
|
192
|
+
end
|
193
|
+
|
194
|
+
it 'works as br' do
|
195
|
+
matcher = VerEx.new do
|
196
|
+
br
|
197
|
+
end
|
198
|
+
|
199
|
+
matcher.match(multiline).should be_true
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
describe '#range' do
|
204
|
+
|
205
|
+
it 'works with a range of numbers' do
|
206
|
+
matcher = VerEx.new do
|
207
|
+
range '0', '9'
|
208
|
+
end
|
209
|
+
|
210
|
+
matcher.match('5').should be_true
|
211
|
+
end
|
212
|
+
|
213
|
+
it 'works with a range of letters' do
|
214
|
+
matcher = VerEx.new do
|
215
|
+
range 'A', 'Z'
|
216
|
+
end
|
217
|
+
|
218
|
+
matcher.match('Q').should be_true
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
68
222
|
describe 'URL Regex Test' do
|
69
223
|
|
70
224
|
let(:matcher) do
|
data/verbal_expressions.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "verbal_expressions"
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Ryan Endacott"]
|
12
|
-
s.date = "2013-
|
12
|
+
s.date = "2013-08-06"
|
13
13
|
s.description = "Verbal Expressions is a library that makes constructing difficult regular expressions simple and easy!"
|
14
14
|
s.email = "rzeg24@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -45,17 +45,20 @@ Gem::Specification.new do |s|
|
|
45
45
|
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
46
46
|
s.add_development_dependency(%q<bundler>, ["~> 1.3.5"])
|
47
47
|
s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
|
48
|
+
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
48
49
|
else
|
49
50
|
s.add_dependency(%q<rspec>, ["~> 2.14.0"])
|
50
51
|
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
51
52
|
s.add_dependency(%q<bundler>, ["~> 1.3.5"])
|
52
53
|
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
54
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
53
55
|
end
|
54
56
|
else
|
55
57
|
s.add_dependency(%q<rspec>, ["~> 2.14.0"])
|
56
58
|
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
57
59
|
s.add_dependency(%q<bundler>, ["~> 1.3.5"])
|
58
60
|
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
61
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
59
62
|
end
|
60
63
|
end
|
61
64
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: verbal_expressions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Endacott
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-08-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - ~>
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 1.8.4
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simplecov
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ! '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ! '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
description: Verbal Expressions is a library that makes constructing difficult regular
|
70
84
|
expressions simple and easy!
|
71
85
|
email: rzeg24@gmail.com
|