verbal_expressions 0.1.4 → 0.1.5

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.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- NmE5MjQzNTVkNWViNDgxN2VlMWEyOWViMTViOTJiZjIyZDhkNjVjYw==
5
- data.tar.gz: !binary |-
6
- MjI0ZmNhYzA4YTY2Y2ExMTI1MzBmNzE5M2NkNDlmN2ExNmQ4ZDcyNA==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- MjJhNGI0ZWFmZTMxY2NiYzVlZmQ0ZDI2YWQ2OTdkMWY3NWVjMDc1MWNiM2Nj
10
- MmMxMzliMjFhZDNhNWM4ZTRlZGYyYWQxMGMzY2RmZjAwOWEyNzMyMzRjOTI1
11
- NjUyMzYyNGEyZWMzNzdlNTE5NzViY2RiYzFiYzhmNDVmYzAxZGE=
12
- data.tar.gz: !binary |-
13
- NzNhZWMzMDczMGJkYTBhMmNkNzliYjYyN2U4ZWJhOWE3MDQ5Njc5NTM4Nzcw
14
- ZjQ0ODk1MGJmNTU0YTY2YjU1Y2Y4NzM0YjEwOWRmYjdhMDQ1MTAyYTk1Zjg5
15
- OTdkOTQwYzU1MzZlYmJlNWYxZmQ3ZDljNzEwNzI2YWQ5OGUwODE=
2
+ SHA1:
3
+ metadata.gz: 3f18e8d812f0b89607ca041928b731ae10e977e9
4
+ data.tar.gz: 5b4d87a27b4de07bec27ecd40eb2b090ab5f3d63
5
+ SHA512:
6
+ metadata.gz: 194d21467e51bf6c7e52f8baa7f053f95a08bfbc3fb2c0458cca10897283e973e1832517b4d9f6be7d70f0fc2c800a62389927c6af1eacd02671f20cb7dbe4a3
7
+ data.tar.gz: 00eba0ae42979cb3e4161535da5717e7380ef52c06f5d14d65c1c11ec7e3c8ae364d85e823ffad740ce0a7892df8ed88592fc941ccd2d3c403cb1ac9c1edc06a
data/.document CHANGED
File without changes
data/.rspec CHANGED
File without changes
File without changes
data/Gemfile CHANGED
File without changes
File without changes
data/LICENSE CHANGED
File without changes
data/README.md CHANGED
@@ -38,7 +38,7 @@ puts 'Hooray! It works!' if tester.match(test_url)
38
38
  puts 'This works too!' if tester =~ test_url
39
39
 
40
40
  # Print the generated regex:
41
- puts tester.source # => /^(http)(s)?(\:\/\/)(www\.)?([^\ ]*)$/
41
+ puts tester.source # => /^(http)(s)?(\:\/\/)(www\.)?([^\ ]*)$/
42
42
  ```
43
43
 
44
44
  ### Replacing strings
@@ -70,6 +70,13 @@ end
70
70
 
71
71
  match = tester.match('Jerry scored 5 goals!')
72
72
  puts match['goals'] # => 5
73
+
74
+ # Alternative capture syntax
75
+
76
+ tester = VerEx.new do
77
+ find 'scored '
78
+ capture('goals') { word }
79
+ end
73
80
  ```
74
81
 
75
82
  ## API documentation
@@ -77,7 +84,7 @@ puts match['goals'] # => 5
77
84
  I haven't added much documentation to this repo yet, but you can find the documentation for the original JavaScript repo on their [wiki](https://github.com/jehna/VerbalExpressions/wiki). Most of the methods have been ported as of v0.1.0 of the JavaScript repo. Just be sure to use the syntax explained above rather than the dot notation :)
78
85
 
79
86
  ## Contributions
80
- Clone the repo and fork!
87
+ Clone the repo and fork!
81
88
  Pull requests are warmly welcomed!
82
89
 
83
90
  ## Issues
@@ -87,3 +94,7 @@ Pull requests are warmly welcomed!
87
94
  ## Thanks!
88
95
  Thank you to @jehna for coming up with the awesome original idea!
89
96
 
97
+
98
+
99
+ [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/ryan-endacott/verbal_expressions/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
100
+
data/Rakefile CHANGED
File without changes
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.4
1
+ 0.1.5
@@ -71,9 +71,29 @@ class VerEx < Regexp
71
71
  add('\t')
72
72
  end
73
73
 
74
- # Any alphanumeric
74
+ # Any single alphanumeric
75
+ def letter
76
+ add('\w')
77
+ end
78
+
79
+ # Any word (multiple alphanumerics)
75
80
  def word
76
- add('\w+')
81
+ one_or_more { letter }
82
+ end
83
+
84
+ # Any single digit
85
+ def digit
86
+ add('\d')
87
+ end
88
+
89
+ # Any integer (multiple digits)
90
+ def integer
91
+ one_or_more { digit }
92
+ end
93
+
94
+ # Any whitespace character
95
+ def whitespace()
96
+ add('\s+')
77
97
  end
78
98
 
79
99
  # Any given character
@@ -82,6 +102,19 @@ class VerEx < Regexp
82
102
  add("[#{value}]")
83
103
  end
84
104
 
105
+ #At least one of some other thing
106
+ def one_or_more(&b)
107
+ add("(?:")
108
+ yield
109
+ add(")+")
110
+ end
111
+
112
+ def zero_or_more(&b)
113
+ add("(?:")
114
+ yield
115
+ add(")*")
116
+ end
117
+
85
118
  alias_method :any, :any_of
86
119
 
87
120
  # Usage: range( from, to [, from, to ... ] )
@@ -113,7 +146,6 @@ class VerEx < Regexp
113
146
  find(value) if value
114
147
  end
115
148
 
116
-
117
149
  # Capture groups (can optionally name)
118
150
  def begin_capture(name = nil)
119
151
  if name
File without changes
@@ -219,6 +219,129 @@ describe VerEx do
219
219
  end
220
220
  end
221
221
 
222
+ describe '#one_or_more' do
223
+ it 'works with one word' do
224
+ matcher = VerEx.new do
225
+ one_or_more{ word }
226
+ end
227
+
228
+ matcher.match('hello').should be_true
229
+ end
230
+
231
+ it 'works with multiple words separated with whitespace' do
232
+ matcher = VerEx.new do
233
+ one_or_more{
234
+ word
235
+ zero_or_more{ whitespace }
236
+ }
237
+ end
238
+
239
+ matcher.match('this is sparta')[0].should == "this is sparta"
240
+ end
241
+
242
+ it 'works with multiple words separated with whitespace' do
243
+ matcher = VerEx.new do
244
+ one_or_more{
245
+ word
246
+ zero_or_more{ whitespace }
247
+ }
248
+ end
249
+
250
+ matcher.match('111 333 777')[0].should == "111 333 777"
251
+ end
252
+ end
253
+
254
+ describe '#zero_or_more' do
255
+ it 'works with zero things' do
256
+ matcher = VerEx.new do
257
+ zero_or_more{
258
+ word
259
+ }
260
+ end
261
+ matcher.match('<><>').should be_true
262
+ end
263
+
264
+ it 'works with multiple things' do
265
+ matcher = VerEx.new do
266
+ zero_or_more{
267
+ word
268
+ zero_or_more{ whitespace }
269
+ }
270
+ end
271
+ matcher.match('eye of the tiger')[0].should == "eye of the tiger"
272
+ end
273
+ end
274
+
275
+ describe '#letter' do
276
+
277
+ it 'works with a single alphanumeric' do
278
+ matcher = VerEx.new do
279
+ start_of_line
280
+ letter
281
+ end_of_line
282
+ end
283
+ matcher.match('a').should be_true
284
+ matcher.match('A').should be_true
285
+ matcher.match('0').should be_true
286
+ matcher.match('_').should be_true
287
+ end
288
+
289
+ it 'fails with a non-alphanumeric' do
290
+ matcher = VerEx.new do
291
+ start_of_line
292
+ letter
293
+ end_of_line
294
+ end
295
+ matcher.match('!').should be_false
296
+ matcher.match('/').should be_false
297
+ matcher.match('(').should be_false
298
+ end
299
+
300
+ it 'fails with multiple alphanumerics' do
301
+ matcher = VerEx.new do
302
+ start_of_line
303
+ letter
304
+ end_of_line
305
+ end
306
+ matcher.match('abc').should be_false
307
+ end
308
+ end
309
+
310
+ describe '#word' do
311
+
312
+ it 'works with a single alphanumeric' do
313
+ matcher = VerEx.new do
314
+ start_of_line
315
+ word
316
+ end_of_line
317
+ end
318
+ matcher.match('a').should be_true
319
+ matcher.match('A').should be_true
320
+ matcher.match('0').should be_true
321
+ matcher.match('_').should be_true
322
+ end
323
+
324
+ it 'fails with a non-alphanumeric' do
325
+ matcher = VerEx.new do
326
+ start_of_line
327
+ word
328
+ end_of_line
329
+ end
330
+ matcher.match('!').should be_false
331
+ matcher.match('/').should be_false
332
+ matcher.match('(').should be_false
333
+ end
334
+
335
+ it 'works with multiple alphanumerics' do
336
+ matcher = VerEx.new do
337
+ start_of_line
338
+ word
339
+ end_of_line
340
+ end
341
+ matcher.match('abc').should be_true
342
+ end
343
+ end
344
+
222
345
  describe 'URL Regex Test' do
223
346
 
224
347
  let(:matcher) do
@@ -2,14 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
+ # stub: verbal_expressions 0.1.5 ruby lib
5
6
 
6
7
  Gem::Specification.new do |s|
7
8
  s.name = "verbal_expressions"
8
- s.version = "0.1.4"
9
+ s.version = "0.1.5"
9
10
 
10
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib"]
11
13
  s.authors = ["Ryan Endacott"]
12
- s.date = "2013-08-06"
14
+ s.date = "2014-06-04"
13
15
  s.description = "Verbal Expressions is a library that makes constructing difficult regular expressions simple and easy!"
14
16
  s.email = "rzeg24@gmail.com"
15
17
  s.extra_rdoc_files = [
@@ -33,8 +35,7 @@ Gem::Specification.new do |s|
33
35
  ]
34
36
  s.homepage = "http://github.com/ryan-endacott/verbal_expressions"
35
37
  s.licenses = ["MIT"]
36
- s.require_paths = ["lib"]
37
- s.rubygems_version = "2.0.5"
38
+ s.rubygems_version = "2.2.2"
38
39
  s.summary = "Library that makes difficult regular expressions easy!"
39
40
 
40
41
  if s.respond_to? :specification_version then
metadata CHANGED
@@ -1,83 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: verbal_expressions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
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-08-06 00:00:00.000000000 Z
11
+ date: 2014-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: 2.14.0
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 2.14.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rdoc
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '3.12'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '3.12'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: 1.3.5
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: 1.3.5
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: jeweler
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: 1.8.4
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: 1.8.4
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: simplecov
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ! '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ! '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  description: Verbal Expressions is a library that makes constructing difficult regular
@@ -89,9 +89,9 @@ extra_rdoc_files:
89
89
  - LICENSE
90
90
  - README.md
91
91
  files:
92
- - .document
93
- - .rspec
94
- - .travis.yml
92
+ - ".document"
93
+ - ".rspec"
94
+ - ".travis.yml"
95
95
  - Gemfile
96
96
  - Gemfile.lock
97
97
  - LICENSE
@@ -112,17 +112,17 @@ require_paths:
112
112
  - lib
113
113
  required_ruby_version: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ! '>='
115
+ - - ">="
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
118
  required_rubygems_version: !ruby/object:Gem::Requirement
119
119
  requirements:
120
- - - ! '>='
120
+ - - ">="
121
121
  - !ruby/object:Gem::Version
122
122
  version: '0'
123
123
  requirements: []
124
124
  rubyforge_project:
125
- rubygems_version: 2.0.5
125
+ rubygems_version: 2.2.2
126
126
  signing_key:
127
127
  specification_version: 4
128
128
  summary: Library that makes difficult regular expressions easy!