cuke-patterns 0.1.5 → 0.1.6

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.
data/Rakefile CHANGED
@@ -14,7 +14,7 @@ begin
14
14
  gem.summary = %Q{Makes cucumber step definitions more focused, understandable, searchable and awesomeable.}
15
15
  gem.description = %Q{Makes cucumber step definitions more focused, understandable, searchable and awesomeable.}
16
16
  gem.email = "brendan@usergenic.com"
17
- gem.homepage = "http://github.com/brendan/cuke-patterns"
17
+ gem.homepage = "http://github.com/cloudcrowd/cuke-patterns"
18
18
  gem.authors = ["Brendan Baldwin"]
19
19
  # gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
20
20
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.5
1
+ 0.1.6
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{cuke-patterns}
8
- s.version = "0.1.5"
8
+ s.version = "0.1.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Brendan Baldwin"]
12
- s.date = %q{2010-08-18}
12
+ s.date = %q{2010-12-14}
13
13
  s.description = %q{Makes cucumber step definitions more focused, understandable, searchable and awesomeable.}
14
14
  s.email = %q{brendan@usergenic.com}
15
15
  s.extra_rdoc_files = [
@@ -25,8 +25,10 @@ Gem::Specification.new do |s|
25
25
  "cuke-patterns.gemspec",
26
26
  "features/apply_pattern.feature",
27
27
  "features/apply_pattern_steps.rb",
28
+ "features/multi_capture_patterns.feature",
28
29
  "features/pattern_generator.feature",
29
30
  "features/simple_patterns.feature",
31
+ "features/step_definitions/multi_capture_steps.rb",
30
32
  "features/step_definitions/pattern_generator_steps.rb",
31
33
  "features/step_definitions/simple_pattern_steps.rb",
32
34
  "features/support/env.rb",
@@ -36,17 +38,17 @@ Gem::Specification.new do |s|
36
38
  "lib/cuke-patterns/rb_world_ext.rb",
37
39
  "lib/cuke-patterns/step_mother_ext.rb"
38
40
  ]
39
- s.homepage = %q{http://github.com/brendan/cuke-patterns}
41
+ s.homepage = %q{http://github.com/cloudcrowd/cuke-patterns}
40
42
  s.rdoc_options = ["--charset=UTF-8"]
41
43
  s.require_paths = ["lib"]
42
- s.rubygems_version = %q{1.3.6}
44
+ s.rubygems_version = %q{1.3.7}
43
45
  s.summary = %q{Makes cucumber step definitions more focused, understandable, searchable and awesomeable.}
44
46
 
45
47
  if s.respond_to? :specification_version then
46
48
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
47
49
  s.specification_version = 3
48
50
 
49
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
51
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
50
52
  else
51
53
  end
52
54
  else
@@ -0,0 +1,19 @@
1
+ Feature: Multi-capture Patterns
2
+ Here are some examples of patterns that yield more than one
3
+ capture from the Regexp into the transform closure.
4
+
5
+ Scenario: :quoted
6
+ When I assign @x to "hello"
7
+ Then @x should be equal to 'hello'
8
+ And @x should be a String
9
+
10
+ Scenario: multiple transform patterns
11
+ When I assign @x to a set of 3 "things"
12
+ Then @x should be equal to ['things','things','things']
13
+ And @x should be an Array
14
+
15
+ Scenario: multiple multi-capture transform patterns
16
+ When I assign @x to "word1" + "word2"
17
+ Then @x should be equal to 'word1word2'
18
+ And @x should be a String
19
+
@@ -1,6 +1,11 @@
1
1
  Feature: Simple Patterns
2
2
  These are some examples of very simple but useful patterns.
3
3
 
4
+ Scenario: :array
5
+ When I assign @x to [1,2,3]
6
+ Then @x should be equal to [1,2,3]
7
+ And @x should be an Array
8
+
4
9
  Scenario: :fixnum
5
10
  When I assign @x to 1
6
11
  Then @x should be equal to 1
@@ -25,16 +30,3 @@ Scenario: :hash
25
30
  When I assign @x to {'a'=>'b','c'=>'d'}
26
31
  Then @x should be equal to {'a'=>'b','c'=>'d'}
27
32
  And @x should be a Hash
28
-
29
- Scenario: :array
30
- When I assign @x to [1,2,3]
31
- Then @x should be equal to [1,2,3]
32
- And @x should be an Array
33
-
34
- Scenario: :string
35
- When I assign @x to "aww yeah"
36
- Then @x should be equal to "aww yeah"
37
- And @x should be a String
38
-
39
-
40
-
@@ -0,0 +1,17 @@
1
+ Pattern :quoted, /"([^"]*)"|'([^']*)'/ do |double, single|
2
+ double.to_s + single.to_s
3
+ end
4
+
5
+ When "I assign :ivar_name to :quoted" do |ivar, quoted|
6
+ instance_variable_set(ivar, quoted)
7
+ end
8
+
9
+ When "I assign :ivar_name to :quoted + :quoted" do |ivar, q1, q2|
10
+ instance_variable_set(ivar, q1+q2)
11
+ end
12
+
13
+ When "I assign :ivar_name to a set of :fixnum :quoted" do |ivar, count, quoted|
14
+ set = []
15
+ 1.upto(count) { set.push(quoted) }
16
+ instance_variable_set(ivar, set)
17
+ end
@@ -1,4 +1,16 @@
1
- When "I assign :ivar_name to :value" do |ivar, value|
1
+ When "I assign :ivar_name to :array" do |ivar, value|
2
+ instance_variable_set(ivar, value)
3
+ end
4
+
5
+ When "I assign :ivar_name to :fixnum" do |ivar, value|
6
+ instance_variable_set(ivar, value)
7
+ end
8
+
9
+ When "I assign :ivar_name to :float" do |ivar, value|
10
+ instance_variable_set(ivar, value)
11
+ end
12
+
13
+ When "I assign :ivar_name to :hash" do |ivar, value|
2
14
  instance_variable_set(ivar, value)
3
15
  end
4
16
 
@@ -13,12 +25,28 @@ end
13
25
  Pattern /a|an/
14
26
  Pattern /is|are/
15
27
 
28
+ Pattern :array, /(\[.*\])/ do |array|
29
+ eval(array)
30
+ end
31
+
16
32
  Pattern :class, /([A-Z]\w*(?:::[A-Z]\w*)*)/ do |class_name|
17
33
  class_name.split(/::/).inject(Object) do |klass, subname|
18
34
  klass.const_get(subname)
19
35
  end
20
36
  end
21
37
 
38
+ Pattern :fixnum, /(-?\d+)/ do |fixnum|
39
+ fixnum.to_i
40
+ end
41
+
42
+ Pattern :float, /(-?\d+\.\d+)/ do |float|
43
+ float.to_f
44
+ end
45
+
46
+ Pattern :hash, /(\{.*\})/ do |hash|
47
+ eval(hash)
48
+ end
49
+
22
50
  Pattern :ivar, /(@\w+)/ do |ivar_name|
23
51
  instance_variable_get(ivar_name)
24
52
  end
@@ -110,11 +110,12 @@ module CukePatterns
110
110
  regexp.to_s.gsub(/\\\\|\\\(|\(\?/,'').scan(/\(/).length
111
111
  end
112
112
 
113
+ # Given a Step Definition's string aka 'matcher' and its Proc, generate a Regexp and
114
+ # new Proc by replacing all the Patterns in the String matcher with their Regexps etc.
113
115
  def convert_cuke_patterns_and_proc(matcher, proc)
114
116
 
115
117
  matcher_regexp = "^"
116
118
 
117
- pattern_counter = 0
118
119
  capture_counter = 0
119
120
 
120
121
  # Split the string by non-alphanumeric, underscore or leading-colon characters
@@ -131,12 +132,11 @@ module CukePatterns
131
132
 
132
133
  proc = convert_cuke_pattern_proc_arguments(
133
134
  proc, conversion_proc,
134
- pattern_counter, pattern_capture_count) if conversion_proc
135
+ capture_counter, pattern_capture_count) if conversion_proc
135
136
 
136
- pattern_counter += 1 unless pattern_capture_count == 0
137
137
  capture_counter += pattern_capture_count
138
138
 
139
- matcher_regexp << "(?:#{regexp})"
139
+ matcher_regexp << regexp.to_s
140
140
 
141
141
  end
142
142
 
@@ -149,6 +149,9 @@ module CukePatterns
149
149
  # the arguments yielded to the original_block (arg_count) at the offset.
150
150
  def convert_cuke_pattern_proc_arguments(original_proc, conversion_proc, offset, arg_count)
151
151
 
152
+ # The number of arguments of the new Proc should be the number of arguments of the
153
+ # old Proc with the change that an argument in the old Proc will potentialy now be
154
+ # converted into a multiple-capture.
152
155
  arity = original_proc.arity + arg_count - 1
153
156
  arg_list = (1..arity).map{|n| "arg#{n}"}.join(",")
154
157
 
@@ -157,6 +160,7 @@ module CukePatterns
157
160
 
158
161
  new_proc = instance_eval(<<-ruby, file, line)
159
162
  Proc.new do |#{arg_list}|
163
+
160
164
  args = [#{arg_list}]
161
165
  arg_range = offset..(offset + arg_count - 1)
162
166
  converted_args = instance_exec(*args[arg_range], &conversion_proc)
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cuke-patterns
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 23
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 1
8
- - 5
9
- version: 0.1.5
9
+ - 6
10
+ version: 0.1.6
10
11
  platform: ruby
11
12
  authors:
12
13
  - Brendan Baldwin
@@ -14,7 +15,7 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-08-18 00:00:00 -07:00
18
+ date: 2010-12-14 00:00:00 -08:00
18
19
  default_executable:
19
20
  dependencies: []
20
21
 
@@ -36,8 +37,10 @@ files:
36
37
  - cuke-patterns.gemspec
37
38
  - features/apply_pattern.feature
38
39
  - features/apply_pattern_steps.rb
40
+ - features/multi_capture_patterns.feature
39
41
  - features/pattern_generator.feature
40
42
  - features/simple_patterns.feature
43
+ - features/step_definitions/multi_capture_steps.rb
41
44
  - features/step_definitions/pattern_generator_steps.rb
42
45
  - features/step_definitions/simple_pattern_steps.rb
43
46
  - features/support/env.rb
@@ -47,7 +50,7 @@ files:
47
50
  - lib/cuke-patterns/rb_world_ext.rb
48
51
  - lib/cuke-patterns/step_mother_ext.rb
49
52
  has_rdoc: true
50
- homepage: http://github.com/brendan/cuke-patterns
53
+ homepage: http://github.com/cloudcrowd/cuke-patterns
51
54
  licenses: []
52
55
 
53
56
  post_install_message:
@@ -56,23 +59,27 @@ rdoc_options:
56
59
  require_paths:
57
60
  - lib
58
61
  required_ruby_version: !ruby/object:Gem::Requirement
62
+ none: false
59
63
  requirements:
60
64
  - - ">="
61
65
  - !ruby/object:Gem::Version
66
+ hash: 3
62
67
  segments:
63
68
  - 0
64
69
  version: "0"
65
70
  required_rubygems_version: !ruby/object:Gem::Requirement
71
+ none: false
66
72
  requirements:
67
73
  - - ">="
68
74
  - !ruby/object:Gem::Version
75
+ hash: 3
69
76
  segments:
70
77
  - 0
71
78
  version: "0"
72
79
  requirements: []
73
80
 
74
81
  rubyforge_project:
75
- rubygems_version: 1.3.6
82
+ rubygems_version: 1.3.7
76
83
  signing_key:
77
84
  specification_version: 3
78
85
  summary: Makes cucumber step definitions more focused, understandable, searchable and awesomeable.