regexp-examples 0.0.0 → 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f72e32a8b9c2934cb90f1d32d3e50c8f735b0dac
4
- data.tar.gz: fa76e5281143d5d14a9b7b3207ea2ea28915ea47
3
+ metadata.gz: 90a3c94b7ce9d60074ab46c196d6fab9cc19552c
4
+ data.tar.gz: 75f7bff2b43831f82dc0c5250a59adab1c993084
5
5
  SHA512:
6
- metadata.gz: 72348eafa1f3257eca9761c088293057eef0018825541f773993c04f1d579279431b06389a3185f4f8e5bb98e7ce0f331ae89aa53750f20b6fccee0cac3b6187
7
- data.tar.gz: d4e3ac8e6951a3707eed765ed2373d25949bc7ea32281a75c173da11df03db4962d71e0a2ca339f5fc74370b97b596331bd93d65632557c82081a2d2728db933
6
+ metadata.gz: 1a4eba9d6f17c34a9f482a4bf73bed58f2541dc5233c6582ac683053fba3b23b21a8672ad0dda631ad38562870e17aa5293e828f121e46b2c1408d893ba50756
7
+ data.tar.gz: 2de1f70fe0299072a07a60d86e549a3c71ba3f3ce31572e4e9df37acb7bb8e69a7f72ce2b568a95c2647bc1b47fa914605a41f3105c25ddc7131841e5751c916
data/.gitignore CHANGED
@@ -12,3 +12,4 @@
12
12
  *.o
13
13
  *.a
14
14
  mkmf.log
15
+ tags
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/Gemfile CHANGED
@@ -1,4 +1,6 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
+ gem 'rspec', group: :test
4
+
3
5
  # Specify your gem's dependencies in regexp-examples.gemspec
4
6
  gemspec
data/README.md CHANGED
@@ -1,6 +1,29 @@
1
- # Regexp::Examples
1
+ # regexp-examples
2
2
 
3
- TODO: Write a gem description
3
+ Extends the Regexp class with the method: Regexp#examples
4
+
5
+ This method generates a list of (some\*) strings that will match the given regular expression
6
+
7
+ \* If the regex has an infinite number of possible srings that match it, such as `/a*b+c{2,}/`,
8
+ or a huge number of possible matches, such as `/.\w/`, then only a subset of these will be listed.
9
+
10
+ ## Usage
11
+
12
+ ```ruby
13
+ /a*/.examples #=> [''. 'a', 'aa']
14
+ /b+/.examples #=> ['b', 'bb']
15
+ /this|is|awesome/.examples #=> ['this', 'is', 'awesome']
16
+ /foo-.{1,}-bar/.examples #=> ['foo-a-bar', 'foo-b-bar', 'foo-c-bar', 'foo-d-bar', 'foo-e-bar',
17
+ # 'foo-aa-bar', 'foo-bb-bar', 'foo-cc-bar', 'foo-dd-bar', 'foo-ee-bar', 'foo-aaa-bar', 'foo-bbb-bar',
18
+ # 'foo-ccc-bar', 'foo-ddd-bar', 'foo-eee-bar']
19
+ /https?:\/\/(www\.)?github\.com/.examples #=> ['http://github.com',
20
+ # 'http://www.github.com', 'https://github.com', 'https://www.github.com']
21
+ /(I(N(C(E(P(T(I(O(N)))))))))*/.examples #=> ["", "INCEPTION", "INCEPTIONINCEPTION"]
22
+ /what about (backreferences\?) \1/.examples #=> ['what about backreferences? backreferences?']
23
+ ```
24
+
25
+ The current version is still very much under development, and contains various bugs/missing features...
26
+ However, when completed, this will hopefully work for ALL regular expressions, *except for lookarounds*!
4
27
 
5
28
  ## Installation
6
29
 
@@ -18,10 +41,6 @@ Or install it yourself as:
18
41
 
19
42
  $ gem install regexp-examples
20
43
 
21
- ## Usage
22
-
23
- TODO: Write usage instructions here
24
-
25
44
  ## Contributing
26
45
 
27
46
  1. Fork it ( https://github.com/[my-github-username]/regexp-examples/fork )
@@ -29,3 +48,4 @@ TODO: Write usage instructions here
29
48
  3. Commit your changes (`git commit -am 'Add some feature'`)
30
49
  4. Push to the branch (`git push origin my-new-feature`)
31
50
  5. Create a new Pull Request
51
+ 6. Don't forget to add tests!!
@@ -1,15 +1,2 @@
1
1
  Dir[File.dirname(__FILE__) + '/regexp-examples/*.rb'].each {|file| require file }
2
2
 
3
- # TODO: DEBUG. DELETE THIS.
4
- #require 'pry'
5
- #RegexpExamples::show(/a*/)
6
- #RegexpExamples::show(/a+/)
7
- #RegexpExamples::show(/a?/)
8
- #RegexpExamples::show(/a{1,2}/)
9
- #RegexpExamples::show(/a{1,}/)
10
- #RegexpExamples::show(/https?:\/\/(www\.)?google\.com/) # AWWW YEEEAHH!
11
- #RegexpExamples::show(/a|b/)
12
- #RegexpExamples::show(/(a)/)
13
- #RegexpExamples::show(/((a))\1\2/)
14
- #
15
- #binding.pry
@@ -1,22 +1,53 @@
1
1
  module RegexpExamples
2
- class BackReferenceTracker
3
- @filled_groups = {}
4
- class << self
5
- attr_accessor :filled_groups
2
+ class CaptureGroupResult < String
3
+ attr_reader :group_id, :subgroups
4
+ def initialize(group_id, subgroups, values)
5
+ @group_id = group_id
6
+ @subgroups = subgroups
7
+ super(values)
8
+ end
6
9
 
7
- def add_filled_group(num, group)
8
- @filled_groups[num] = group
9
- end
10
+ # Overridden in order to preserve the @group_id and @subgroups
11
+ def *(int)
12
+ self.class.new(group_id, subgroups, super)
13
+ end
14
+ def gsub(regex)
15
+ self.class.new(group_id, subgroups, super)
10
16
  end
11
17
  end
12
18
 
13
19
  class BackReferenceReplacer
14
- def substitute_backreferences(full_example)
15
- # TODO: Update this for named capture groups
16
- # TODO: Define this magic __X__ pattern as a constant? Maybe?
17
- full_example.gsub!(/__(\d+)__/) do |_|
18
- BackReferenceTracker.filled_groups[$1.to_i]
20
+ def substitute_backreferences(full_examples)
21
+ full_examples.map! do |full_example|
22
+ if full_example.is_a? String
23
+ [full_example]
24
+ else
25
+ full_example.map! do |partial_example|
26
+ partial_example.gsub(/__(\d+)__/) do |match|
27
+ find_backref_for(full_example, $1.to_i)
28
+ end
29
+ end
30
+ end
31
+ end
32
+ full_examples
33
+ end
34
+
35
+ private
36
+ def find_backref_for(full_example, group_id)
37
+ full_example.each do |partial_example|
38
+ next unless partial_example.respond_to?(:group_id)
39
+ case
40
+ when partial_example.group_id == group_id
41
+ return partial_example
42
+ when sub_partial_example = find_backref_for(partial_example.subgroups, group_id)
43
+ # TODO: This line does NOT work for all nested backreference groups
44
+ # Need to revisit this logic and find a better solution, if possible
45
+ return sub_partial_example.result.detect{|sub_partial_result| partial_example.include? sub_partial_result}
46
+ end
19
47
  end
48
+ nil
20
49
  end
50
+
21
51
  end
52
+
22
53
  end
@@ -2,10 +2,36 @@ module RegexpExamples
2
2
  # Number of times to repeat for Star and Plus repeaters
3
3
  TIMES = 2
4
4
 
5
- # Set of chars for Dot and negated [^] char groups
6
- #CHARS = [("a".."z").to_a, ("A".."Z").to_a, ".", ",", ";"].flatten
7
- #TODO: Make these character sets more complete
8
- #e.g. Sets for \d, \w, \h, \s
9
- CHARS = %w{a b c d e}
5
+ # Maximum number of characters returned from a char set, to reduce output spam
6
+ # For example:
7
+ # If MaxGroupResults = 5, then
8
+ # \d = [0, 1, 2, 3, 4]
9
+ MaxGroupResults = 5
10
+
11
+ module CharSets
12
+ Lower = Array('a'..'z')
13
+ Upper = Array('A'..'Z')
14
+ Digit = Array('0'..'9')
15
+ Punct = [33..47, 58..64, 91..96, 123..126].map { |r| r.map { |val| val.chr } }.flatten
16
+ Any = Lower | Upper | Digit | Punct
17
+ end
18
+
19
+ # Map of special regex characters, to their associated character sets
20
+ BackslashCharMap = {
21
+ 'd' => CharSets::Digit,
22
+ 'D' => CharSets::Lower | CharSets::Upper | CharSets::Punct,
23
+ 'w' => CharSets::Lower | CharSets::Upper | CharSets::Digit | ['_'],
24
+ 'W' => CharSets::Punct.reject { |val| val == '_' },
25
+ 's' => [' ', "\t", "\n", "\r", "\v", "\f"],
26
+ 'S' => CharSets::Any - [' ', "\t", "\n", "\r", "\v", "\f"],
27
+
28
+ 't' => ["\t"], # tab
29
+ 'n' => ["\n"], # new line
30
+ 'r' => ["\r"], # carriage return
31
+ 'f' => ["\f"], # form feed
32
+ 'a' => ["\a"], # alarm
33
+ 'v' => ["\v"], # vertical tab
34
+ 'e' => ["\e"], # escape
35
+ }
10
36
  end
11
37
 
@@ -18,13 +18,17 @@ module RegexpExamples
18
18
  @negative = false
19
19
  end
20
20
 
21
- # TODO: Can I make this more legible?
22
- # Ranges a-b
21
+ init_backslash_chars
22
+ init_ranges
23
+ end
24
+
25
+ def init_ranges
23
26
  # save first and last "-" if present
24
27
  first = nil
25
28
  last = nil
26
29
  first = @chars.shift if @chars.first == "-"
27
30
  last = @chars.pop if @chars.last == "-"
31
+ # Replace all instances of e.g. ["a" "-" "z"] with ["a", "b", ..., "z"]
28
32
  while i = @chars.index("-")
29
33
  @chars[i-1..i+1] = (@chars[i-1]..@chars[i+1]).to_a
30
34
  end
@@ -32,9 +36,24 @@ module RegexpExamples
32
36
  @chars.unshift(first) if first
33
37
  @chars.push(last) if last
34
38
  end
39
+
40
+ def init_backslash_chars
41
+ @chars.each_with_index do |char, i|
42
+ if char == "\\"
43
+ if BackslashCharMap.keys.include?(@chars[i+1])
44
+ @chars[i..i+1] = BackslashCharMap[@chars[i+1]]
45
+ elsif @chars[i+1] == "\\"
46
+ @chars.delete_at(i+1)
47
+ else
48
+ @chars.delete_at(i)
49
+ end
50
+ end
51
+ end
52
+ end
53
+
35
54
  def result
36
55
  if @negative
37
- CHARS - @chars
56
+ CharSets::Any - @chars
38
57
  else
39
58
  @chars
40
59
  end
@@ -43,25 +62,26 @@ module RegexpExamples
43
62
 
44
63
  class DotGroup
45
64
  def result
46
- CHARS
65
+ CharSets::Any
47
66
  end
48
67
  end
49
68
 
50
69
  class MultiGroup
51
- attr_reader :group_num
52
- def initialize(groups, group_num)
70
+ attr_reader :group_id
71
+ def initialize(groups, group_id)
53
72
  @groups = groups
54
- @group_num = group_num
73
+ @group_id = group_id
55
74
  end
56
75
 
57
76
  # Generates the result of each contained group
58
77
  # and adds the filled group of each result to
59
78
  # itself
60
79
  def result
61
- strings = @groups.map {|x| x.result}
62
- result = RegexpExamples::permutations_of_strings(strings)
63
- result.each {|x| BackReferenceTracker.add_filled_group(@group_num, x)}
64
- result
80
+ strings = @groups.map {|repeater| repeater.result}
81
+ subgroups = @groups.select{ |repeater| repeater.group.respond_to? :group_id}.map{|repeater| repeater.group}
82
+ RegexpExamples::permutations_of_strings(strings).map do |result|
83
+ group_id ? CaptureGroupResult.new(group_id, subgroups, result) : result
84
+ end
65
85
  end
66
86
  end
67
87
 
@@ -72,15 +92,14 @@ module RegexpExamples
72
92
  end
73
93
 
74
94
  class OrGroup
75
- def initialize(repeaters)
76
- @repeaters = repeaters
95
+ def initialize(left_repeaters, right_repeaters)
96
+ @repeaters = left_repeaters.concat(right_repeaters)
77
97
  end
78
98
 
79
99
  def result
80
- repeaters_results = @repeaters.map do |repeater|
81
- repeater.result
100
+ @repeaters.map do |repeater|
101
+ RegexpExamples::permutations_of_strings(repeater.result)
82
102
  end
83
- RegexpExamples::permutations_of_strings(repeaters_results)
84
103
  end
85
104
  end
86
105
 
@@ -7,10 +7,12 @@ module RegexpExamples
7
7
  # For example:
8
8
  # permutations_of_strings [ ['a'], ['b'], ['c', 'd', 'e'] ] #=> ['acb', 'abd', 'abe']
9
9
  # permutations_of_strings [ ['a', 'b'], ['c', 'd'] ] #=> [ 'ac', 'ad', 'bc', 'bd' ]
10
- def self.permutations_of_strings(arrays_of_strings)
11
- return arrays_of_strings[0] if arrays_of_strings.size == 1
10
+ def self.permutations_of_strings(arrays_of_strings, options={})
12
11
  first = arrays_of_strings.shift
13
- first.product( permutations_of_strings(arrays_of_strings) ).map {|x| x.flatten.join}
12
+ return first if arrays_of_strings.empty?
13
+ first.product( permutations_of_strings(arrays_of_strings, options) ).map do |result|
14
+ options[:no_join] ? result.flatten : result.flatten.join
15
+ end
14
16
  end
15
17
 
16
18
  # TODO: For debugging only!! Delete this before v1.0
@@ -10,8 +10,9 @@ module RegexpExamples
10
10
  def parse
11
11
  repeaters = []
12
12
  while @current_position < regexp_string.length
13
- group = parse_group
13
+ group = parse_group(repeaters)
14
14
  break if group.is_a? MultiGroupEnd
15
+ repeaters = [] if group.is_a? OrGroup
15
16
  @current_position += 1
16
17
  repeaters << parse_repeater(group)
17
18
  end
@@ -20,7 +21,7 @@ module RegexpExamples
20
21
 
21
22
  private
22
23
 
23
- def parse_group
24
+ def parse_group(repeaters)
24
25
  char = regexp_string[@current_position]
25
26
  case char
26
27
  when '('
@@ -32,7 +33,7 @@ module RegexpExamples
32
33
  when '.'
33
34
  group = parse_dot_group
34
35
  when '|'
35
- group = parse_or_group
36
+ group = parse_or_group(repeaters)
36
37
  when '\\'
37
38
  group = parse_after_backslash_group
38
39
  else
@@ -43,13 +44,17 @@ module RegexpExamples
43
44
 
44
45
  def parse_after_backslash_group
45
46
  @current_position += 1
46
- case regexp_string[@current_position..-1]
47
- when /^(\d+)/
47
+ case
48
+ when regexp_string[@current_position..-1] =~ /^(\d+)/
48
49
  group = parse_backreference_group($&)
50
+ when BackslashCharMap.keys.include?(regexp_string[@current_position])
51
+ group = CharGroup.new(
52
+ BackslashCharMap[regexp_string[@current_position]])
53
+ # TODO: There are also a bunch of multi-char matches to watch out for:
54
+ # http://en.wikibooks.org/wiki/Ruby_Programming/Syntax/Literals
49
55
  else
50
56
  group = parse_single_char_group( regexp_string[@current_position] )
51
- # TODO: What about cases like \n, \(, \^, etc?
52
- # SpecialCharsAfterBackslash ?
57
+ # TODO: What about cases like \A, \z, \Z ?
53
58
  end
54
59
  group
55
60
  end
@@ -88,9 +93,19 @@ module RegexpExamples
88
93
  def parse_char_group
89
94
  chars = []
90
95
  @current_position += 1
91
- # TODO: What about the sneaky edge case of /...[]a-z].../ ?
92
- until regexp_string[@current_position].chr == ']'
93
- chars << regexp_string[@current_position].chr
96
+ if regexp_string[@current_position] == ']'
97
+ # Beware of the sneaky edge case:
98
+ # /[]]/ (match "]")
99
+ chars << ']'
100
+ @current_position += 1
101
+ end
102
+ until regexp_string[@current_position] == ']' \
103
+ && !regexp_string[0..@current_position-1].match(/[^\\](\\{2})*\\\z/)
104
+ # Beware of having an ODD number of "\" before the "]", e.g.
105
+ # /[\]]/ (match "]")
106
+ # /[\\]/ (match "\")
107
+ # /[\\\]]/ (match "\" or "]")
108
+ chars << regexp_string[@current_position]
94
109
  @current_position += 1
95
110
  end
96
111
  CharGroup.new(chars)
@@ -100,10 +115,10 @@ module RegexpExamples
100
115
  DotGroup.new
101
116
  end
102
117
 
103
- def parse_or_group
118
+ def parse_or_group(left_repeaters)
104
119
  @current_position += 1
105
- repeaters = parse
106
- OrGroup.new(repeaters)
120
+ right_repeaters = parse
121
+ OrGroup.new(left_repeaters, right_repeaters)
107
122
  end
108
123
 
109
124
 
@@ -1,14 +1,14 @@
1
1
  class Regexp
2
2
  module Examples
3
3
  def examples
4
- regexp_string = self.inspect[1..-2]
5
4
  partial_examples =
6
- RegexpExamples::Parser.new(regexp_string)
5
+ RegexpExamples::Parser.new(source)
7
6
  .parse
8
7
  .map {|repeater| repeater.result}
9
- full_examples = RegexpExamples::permutations_of_strings(partial_examples)
10
- full_examples.map{ |full_example| RegexpExamples::BackReferenceReplacer.new.substitute_backreferences(full_example)}
11
- full_examples
8
+ full_examples = RegexpExamples::permutations_of_strings(partial_examples.dup, no_join: true)
9
+ full_examples_with_backrefs = \
10
+ RegexpExamples::BackReferenceReplacer.new.substitute_backreferences(full_examples)
11
+ full_examples_with_backrefs.map(&:join)
12
12
  end
13
13
  end
14
14
  include Examples
@@ -1,15 +1,16 @@
1
1
  module RegexpExamples
2
2
  class BaseRepeater
3
+ attr_reader :group
3
4
  def initialize(group)
4
5
  @group = group
5
6
  end
6
7
 
7
8
  def result(min_repeats, max_repeats)
8
- group_result = @group.result
9
+ group_results = @group.result[0 .. MaxGroupResults-1]
9
10
  results = []
10
11
  min_repeats.upto(max_repeats) do |repeats|
11
- group_result.each do |result|
12
- results << result * repeats
12
+ group_results.each do |group_result|
13
+ results << group_result * repeats
13
14
  end
14
15
  end
15
16
  results.uniq
@@ -1,3 +1,3 @@
1
1
  module RegexpExamples
2
- VERSION = '0.0.0'
2
+ VERSION = '0.0.1'
3
3
  end
@@ -0,0 +1,89 @@
1
+ describe Regexp, "#examples" do
2
+ def self.examples_exist_and_match(*regexps)
3
+ regexps.each do |regexp|
4
+ it do
5
+ regexp_examples = regexp.examples
6
+ expect(regexp_examples).not_to be_empty
7
+ regexp_examples.each { |example| expect(example).to match(/\A(?:#{regexp.source})\z/) }
8
+ # Note: /\A...\z/ is used, to prevent misleading examples from passing the test.
9
+ # For example, we don't want things like:
10
+ # /a*/.examples to include "xyz"
11
+ # /a|b/.examples to include "bad"
12
+ end
13
+ end
14
+ end
15
+
16
+ context 'returns matching strings' do
17
+ context "for basic repeaters" do
18
+ examples_exist_and_match(
19
+ /a/,
20
+ /a*/,
21
+ /a+/,
22
+ /a?/,
23
+ /a{1}/,
24
+ /a{1,}/,
25
+ /a{1,2}/
26
+ )
27
+ end
28
+
29
+ context "for basic groups" do
30
+ examples_exist_and_match(
31
+ /[a]/,
32
+ /(a)/,
33
+ /a|b/,
34
+ /./
35
+ )
36
+ end
37
+
38
+ context "for complex char groups (square brackets)" do
39
+ examples_exist_and_match(
40
+ /[abc]/,
41
+ /[a-c]/,
42
+ /[abc-e]/,
43
+ /[^a-zA-Z]/,
44
+ /[\w]/,
45
+ /[]]/, # TODO: How to suppress annoying warnings on this test?
46
+ /[\]]/,
47
+ /[\\]/,
48
+ /[\\\]]/,
49
+ /[\n-\r]/,
50
+ /[\-]/,
51
+ /[%-+]/ # This regex is "supposed to" match some surprising things!!!
52
+ )
53
+ end
54
+
55
+ context "for escaped characters" do
56
+ examples_exist_and_match(
57
+ /\w/,
58
+ /\s/,
59
+ /\d/,
60
+ /\t/,
61
+ /\n/,
62
+ /\f/,
63
+ /\a/,
64
+ /\v/,
65
+ /\e/
66
+ )
67
+ end
68
+
69
+ context "for backreferences" do
70
+ examples_exist_and_match(
71
+ /(repeat) \1/,
72
+ /(ref1) (ref2) \1 \2/,
73
+ /((ref2)ref1) \1 \2/,
74
+ /((ref1and2)) \1 \2/
75
+ )
76
+ end
77
+
78
+ context "for complex patterns" do
79
+ # Longer combinations of the above
80
+ examples_exist_and_match(
81
+ /https?:\/\/(www\.)github\.com/,
82
+ /(I(N(C(E(P(T(I(O(N)))))))))*/,
83
+ /[\w]{1}/,
84
+ /((a?b*c+)) \1/,
85
+ /((a?b*c+)?) \1/
86
+ )
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,91 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # The generated `.rspec` file contains `--require spec_helper` which will cause this
4
+ # file to always be loaded, without a need to explicitly require it in any files.
5
+ #
6
+ # Given that it is always loaded, you are encouraged to keep this file as
7
+ # light-weight as possible. Requiring heavyweight dependencies from this file
8
+ # will add to the boot time of your test suite on EVERY test run, even for an
9
+ # individual file that may not need all of that loaded. Instead, consider making
10
+ # a separate helper file that requires the additional dependencies and performs
11
+ # the additional setup, and require it from the spec files that actually need it.
12
+ #
13
+ # The `.rspec` file also contains a few flags that are not defaults but that
14
+ # users commonly want.
15
+ #
16
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
17
+ require './lib/regexp-examples.rb'
18
+ require 'pry'
19
+ RSpec.configure do |config|
20
+ # rspec-expectations config goes here. You can use an alternate
21
+ # assertion/expectation library such as wrong or the stdlib/minitest
22
+ # assertions if you prefer.
23
+ config.expect_with :rspec do |expectations|
24
+ # This option will default to `true` in RSpec 4. It makes the `description`
25
+ # and `failure_message` of custom matchers include text for helper methods
26
+ # defined using `chain`, e.g.:
27
+ # be_bigger_than(2).and_smaller_than(4).description
28
+ # # => "be bigger than 2 and smaller than 4"
29
+ # ...rather than:
30
+ # # => "be bigger than 2"
31
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
32
+ end
33
+
34
+ # rspec-mocks config goes here. You can use an alternate test double
35
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
36
+ config.mock_with :rspec do |mocks|
37
+ # Prevents you from mocking or stubbing a method that does not exist on
38
+ # a real object. This is generally recommended, and will default to
39
+ # `true` in RSpec 4.
40
+ mocks.verify_partial_doubles = true
41
+ end
42
+
43
+ # The settings below are suggested to provide a good initial experience
44
+ # with RSpec, but feel free to customize to your heart's content.
45
+ =begin
46
+ # These two settings work together to allow you to limit a spec run
47
+ # to individual examples or groups you care about by tagging them with
48
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
49
+ # get run.
50
+ config.filter_run :focus
51
+ config.run_all_when_everything_filtered = true
52
+
53
+ # Limits the available syntax to the non-monkey patched syntax that is recommended.
54
+ # For more details, see:
55
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
56
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
57
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
58
+ config.disable_monkey_patching!
59
+
60
+ # This setting enables warnings. It's recommended, but in some cases may
61
+ # be too noisy due to issues in dependencies.
62
+ config.warnings = true
63
+
64
+ # Many RSpec users commonly either run the entire suite or an individual
65
+ # file, and it's useful to allow more verbose output when running an
66
+ # individual spec file.
67
+ if config.files_to_run.one?
68
+ # Use the documentation formatter for detailed output,
69
+ # unless a formatter has already been configured
70
+ # (e.g. via a command-line flag).
71
+ config.default_formatter = 'doc'
72
+ end
73
+
74
+ # Print the 10 slowest examples and example groups at the
75
+ # end of the spec run, to help surface which specs are running
76
+ # particularly slow.
77
+ config.profile_examples = 10
78
+
79
+ # Run specs in random order to surface order dependencies. If you find an
80
+ # order dependency and want to debug it, you can fix the order by providing
81
+ # the seed, which is printed after each run.
82
+ # --seed 1234
83
+ config.order = :random
84
+
85
+ # Seed global randomization in this process using the `--seed` CLI option.
86
+ # Setting this allows you to use `--seed` to deterministically reproduce
87
+ # test failures related to randomization by passing the same `--seed` value
88
+ # as the one that triggered the failure.
89
+ Kernel.srand config.seed
90
+ =end
91
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: regexp-examples
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Lord
@@ -45,6 +45,7 @@ extensions: []
45
45
  extra_rdoc_files: []
46
46
  files:
47
47
  - ".gitignore"
48
+ - ".rspec"
48
49
  - Gemfile
49
50
  - LICENSE.txt
50
51
  - README.md
@@ -59,6 +60,8 @@ files:
59
60
  - lib/regexp-examples/repeaters.rb
60
61
  - lib/regexp-examples/version.rb
61
62
  - regexp-examples.gemspec
63
+ - spec/regexp-examples_spec.rb
64
+ - spec/spec_helper.rb
62
65
  homepage: http://rubygems.org/gems/regexp-examples
63
66
  licenses:
64
67
  - MIT
@@ -83,4 +86,6 @@ rubygems_version: 2.2.2
83
86
  signing_key:
84
87
  specification_version: 4
85
88
  summary: Extends the Regexp class with '#examples'
86
- test_files: []
89
+ test_files:
90
+ - spec/regexp-examples_spec.rb
91
+ - spec/spec_helper.rb