regex2string 0.0.1
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 +7 -0
- data/.gitignore +1 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +43 -0
- data/README.md +10 -0
- data/lib/regex2string.rb +9 -0
- data/lib/regex2string/regexp.rb +7 -0
- data/lib/regex2string/unmatched.rb +20 -0
- data/lib/regex2string/version.rb +3 -0
- data/regex2string.gemspec +27 -0
- data/spec/spec_helper.rb +8 -0
- data/spec/unmatched_spec.rb +19 -0
- metadata +126 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 000aa164b4e296de91ac6748293efced35d0200d
|
4
|
+
data.tar.gz: 9c66df63aa511fb24bd11bcc55bbe89e5f350420
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: cf6902591339e66989a74ba351e42d1eb00221d8974d6d313cace825e7812f779afec405f9ce95b3253a7de4c8759c5e21cfd6d870691428c16dcef142f36c33
|
7
|
+
data.tar.gz: 98b5a5eb9ffa10faa22ee68805a0049841034fc428bc8cf1f9653d97ac37970889bf57e482b1c701350d3196e64596e9a2029c1f65a4e6b3a640522f211f43e5
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
.rvmrc
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
regex2string (0.0.1)
|
5
|
+
faker
|
6
|
+
randexp
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: http://rubygems.org/
|
10
|
+
specs:
|
11
|
+
coderay (1.1.0)
|
12
|
+
diff-lcs (1.2.5)
|
13
|
+
faker (1.3.0)
|
14
|
+
i18n (~> 0.5)
|
15
|
+
ffi (1.9.3-java)
|
16
|
+
i18n (0.6.9)
|
17
|
+
method_source (0.8.2)
|
18
|
+
pry (0.9.12.6-java)
|
19
|
+
coderay (~> 1.0)
|
20
|
+
method_source (~> 0.8)
|
21
|
+
slop (~> 3.4)
|
22
|
+
spoon (~> 0.0)
|
23
|
+
randexp (0.1.7)
|
24
|
+
rspec (2.14.1)
|
25
|
+
rspec-core (~> 2.14.0)
|
26
|
+
rspec-expectations (~> 2.14.0)
|
27
|
+
rspec-mocks (~> 2.14.0)
|
28
|
+
rspec-core (2.14.8)
|
29
|
+
rspec-expectations (2.14.5)
|
30
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
31
|
+
rspec-mocks (2.14.6)
|
32
|
+
slop (3.5.0)
|
33
|
+
spoon (0.0.4)
|
34
|
+
ffi
|
35
|
+
|
36
|
+
PLATFORMS
|
37
|
+
java
|
38
|
+
|
39
|
+
DEPENDENCIES
|
40
|
+
bundler (~> 1.3)
|
41
|
+
pry
|
42
|
+
regex2string!
|
43
|
+
rspec (~> 2.14.1)
|
data/README.md
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
This is a wrapper around the randexp gem that also allows for generatingg unmatched string and can be used in testing.
|
2
|
+
|
3
|
+
To use: gem install regex2string
|
4
|
+
|
5
|
+
|
6
|
+
/abcd/.generate_matched #generates a string that matches the regex
|
7
|
+
|
8
|
+
/abcd/.generate_unmatched #generates a string that does not match the regex
|
9
|
+
|
10
|
+
/abcd/.generate_unmatched(10) #generates a string of length 10 that does not match the regex
|
data/lib/regex2string.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
module Regex2String
|
2
|
+
class Unmatched
|
3
|
+
attr_accessor :regex
|
4
|
+
attr_accessor :char_count
|
5
|
+
|
6
|
+
def initialize(regex, char_count)
|
7
|
+
@regex = regex
|
8
|
+
@char_count = char_count
|
9
|
+
end
|
10
|
+
|
11
|
+
def generate_unmatched
|
12
|
+
rand_string = Faker::Lorem.characters(@char_count)
|
13
|
+
while (true)
|
14
|
+
break unless @regex.match rand_string
|
15
|
+
rand_string = Faker::Lorem.characters(@char_count)
|
16
|
+
end
|
17
|
+
rand_string
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'regex2string/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "regex2string"
|
8
|
+
spec.version = "0.0.1"
|
9
|
+
spec.summary = "Wraps randexp to generate invalid string as well"
|
10
|
+
spec.date = "2014-04-01"
|
11
|
+
spec.description = "Wraps randexp to generate invalid string as well"
|
12
|
+
spec.authors = ["Ankur Maheshwari"]
|
13
|
+
spec.email = ["amaheshwari@systango.com"]
|
14
|
+
spec.homepage = "http://systango.com/"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "randexp"
|
22
|
+
spec.add_dependency "faker"
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
25
|
+
spec.add_development_dependency "rspec", "~> 2.14.1"
|
26
|
+
spec.add_development_dependency "pry"
|
27
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require File.expand_path('../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
describe "Unmatched strings" do
|
4
|
+
it "should generate unmatched string for a given regex" do
|
5
|
+
s = /abcd/.generate_unmatched
|
6
|
+
/abcd/.match(s).should be_nil
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should generate unmatched string of the specified_length for a given regex" do
|
10
|
+
s = /abcd/.generate_unmatched(10)
|
11
|
+
/abcd/.match(s).should be_nil
|
12
|
+
s.length.should eq 10
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should generate matched string" do
|
16
|
+
s = /abcd/.generate
|
17
|
+
/abcd/.match(s).should_not be_nil
|
18
|
+
end
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: regex2string
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ankur Maheshwari
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-04-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: randexp
|
15
|
+
version_requirements: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
requirement: !ruby/object:Gem::Requirement
|
21
|
+
requirements:
|
22
|
+
- - '>='
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: '0'
|
25
|
+
prerelease: false
|
26
|
+
type: :runtime
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: faker
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
requirement: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
prerelease: false
|
40
|
+
type: :runtime
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
version_requirements: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.3'
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ~>
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '1.3'
|
53
|
+
prerelease: false
|
54
|
+
type: :development
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 2.14.1
|
62
|
+
requirement: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ~>
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 2.14.1
|
67
|
+
prerelease: false
|
68
|
+
type: :development
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry
|
71
|
+
version_requirements: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
requirement: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - '>='
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
prerelease: false
|
82
|
+
type: :development
|
83
|
+
description: Wraps randexp to generate invalid string as well
|
84
|
+
email:
|
85
|
+
- amaheshwari@systango.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- .gitignore
|
91
|
+
- Gemfile
|
92
|
+
- Gemfile.lock
|
93
|
+
- README.md
|
94
|
+
- lib/regex2string.rb
|
95
|
+
- lib/regex2string/regexp.rb
|
96
|
+
- lib/regex2string/unmatched.rb
|
97
|
+
- lib/regex2string/version.rb
|
98
|
+
- regex2string.gemspec
|
99
|
+
- spec/spec_helper.rb
|
100
|
+
- spec/unmatched_spec.rb
|
101
|
+
homepage: http://systango.com/
|
102
|
+
licenses: []
|
103
|
+
metadata: {}
|
104
|
+
post_install_message:
|
105
|
+
rdoc_options: []
|
106
|
+
require_paths:
|
107
|
+
- lib
|
108
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - '>='
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '0'
|
113
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
requirements: []
|
119
|
+
rubyforge_project:
|
120
|
+
rubygems_version: 2.2.2
|
121
|
+
signing_key:
|
122
|
+
specification_version: 4
|
123
|
+
summary: Wraps randexp to generate invalid string as well
|
124
|
+
test_files:
|
125
|
+
- spec/spec_helper.rb
|
126
|
+
- spec/unmatched_spec.rb
|