cql 0.1.2 → 0.1.3
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/spec/filter_feature_dsl_spec.rb +485 -485
- data/spec/filter_sso_spec.rb +287 -278
- data/spec/map_reduce_spec.rb +131 -131
- data/spec/select_feature_dsl_spec.rb +49 -49
- data/spec/select_scen_outline_dsl_spec.rb +125 -125
- data/spec/select_scenario_dsl_spec.rb +72 -72
- data/spec/unit_spec.rb +21 -21
- metadata +6 -9
- data/lib/dsl.rb +0 -64
- data/lib/map_reduce.rb +0 -139
- data/lib/repo.rb +0 -34
@@ -1,73 +1,73 @@
|
|
1
|
-
require 'rspec'
|
2
|
-
require File.dirname(__FILE__) + "/../lib/repo"
|
3
|
-
|
4
|
-
describe "select" do
|
5
|
-
|
6
|
-
describe "single value, multiple results" do
|
7
|
-
it 'should get scenario line number' do
|
8
|
-
gr = CQL::Repository.new File.expand_path(File.dirname(__FILE__)) + "/../fixtures/features/scenario/simple2"
|
9
|
-
result = gr.query do
|
10
|
-
select line
|
11
|
-
from scenarios
|
12
|
-
end
|
13
|
-
result.should == [{"line"=> 6}, {"line"=> 11}, {"line"=> 16}, {"line"=> 21}]
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'should get scenario name' do
|
17
|
-
gr = CQL::Repository.new File.expand_path(File.dirname(__FILE__)) + "/../fixtures/features/scenario/simple2"
|
18
|
-
result = gr.query do
|
19
|
-
select name
|
20
|
-
from scenarios
|
21
|
-
end
|
22
|
-
result.should == [{"name"=> "Testing the slurping"}, {"name"=> "Testing again"},
|
23
|
-
{"name"=> "Testing yet again"}, {"name"=> "Testing yet again part 2"}]
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'should get scenario name from multiple feature files' do
|
27
|
-
gr = CQL::Repository.new File.expand_path(File.dirname(__FILE__)) + "/../fixtures/features/scenario/simple"
|
28
|
-
result = gr.query do
|
29
|
-
select name
|
30
|
-
from scenarios
|
31
|
-
end
|
32
|
-
result.should == [{"name"=> "Has a table"}, {"name"=> "Testing the slurping 1"},
|
33
|
-
{"name"=> "Testing the slurping not to be found"}, {"name"=> "Testing the slurping 2"},
|
34
|
-
{"name"=> "Testing the slurping 3"}, {"name"=> "Testing again"},
|
35
|
-
{"name"=> "Testing yet again"}, {"name"=> "Testing yet again part 2"}]
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
describe "multiple values" do
|
40
|
-
it 'should get multiple scenarios as a list of maps' do
|
41
|
-
gr = CQL::Repository.new File.expand_path(File.dirname(__FILE__)) + "/../fixtures/features/scenario/simple2"
|
42
|
-
result = gr.query do
|
43
|
-
select line, name
|
44
|
-
from scenarios
|
45
|
-
end
|
46
|
-
result.should == [{'line'=>6, 'name'=>"Testing the slurping"}, {'line'=>11, 'name'=>"Testing again"},
|
47
|
-
{'line'=>16, 'name'=>"Testing yet again"}, {'line'=>21, 'name'=>"Testing yet again part 2"}]
|
48
|
-
end
|
49
|
-
|
50
|
-
it "should select all" do
|
51
|
-
gr = CQL::Repository.new File.expand_path(File.dirname(__FILE__)) + "/../fixtures/features/scenario/table"
|
52
|
-
expected = {"all"=>{"keyword"=>"Scenario", "name"=>"Has a table", "line"=>3,
|
53
|
-
"description"=>"", "id"=>"simple;has-a-table", "type"=>"scenario",
|
54
|
-
"steps"=>[{"keyword"=>"Given ", "name"=>"Something", "line"=>4,
|
55
|
-
"rows"=>[{"cells"=>["a", "a"], "line"=>5}, {"cells"=>["s", "a"], "line"=>6},
|
56
|
-
{"cells"=>["s", "s"], "line"=>7}]},
|
57
|
-
{"keyword"=>"Then ", "name"=>"something else", "line"=>8}]}}
|
58
|
-
|
59
|
-
result = gr.query do
|
60
|
-
select all
|
61
|
-
from scenarios
|
62
|
-
end
|
63
|
-
result.should == expected
|
64
|
-
|
65
|
-
result = gr.query do
|
66
|
-
select complete
|
67
|
-
from scenarios
|
68
|
-
end
|
69
|
-
result.should == expected
|
70
|
-
end
|
71
|
-
|
72
|
-
end
|
1
|
+
require 'rspec'
|
2
|
+
require File.dirname(__FILE__) + "/../lib/repo"
|
3
|
+
|
4
|
+
describe "select" do
|
5
|
+
|
6
|
+
describe "single value, multiple results" do
|
7
|
+
it 'should get scenario line number' do
|
8
|
+
gr = CQL::Repository.new File.expand_path(File.dirname(__FILE__)) + "/../fixtures/features/scenario/simple2"
|
9
|
+
result = gr.query do
|
10
|
+
select line
|
11
|
+
from scenarios
|
12
|
+
end
|
13
|
+
result.should == [{"line"=> 6}, {"line"=> 11}, {"line"=> 16}, {"line"=> 21}]
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should get scenario name' do
|
17
|
+
gr = CQL::Repository.new File.expand_path(File.dirname(__FILE__)) + "/../fixtures/features/scenario/simple2"
|
18
|
+
result = gr.query do
|
19
|
+
select name
|
20
|
+
from scenarios
|
21
|
+
end
|
22
|
+
result.should == [{"name"=> "Testing the slurping"}, {"name"=> "Testing again"},
|
23
|
+
{"name"=> "Testing yet again"}, {"name"=> "Testing yet again part 2"}]
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should get scenario name from multiple feature files' do
|
27
|
+
gr = CQL::Repository.new File.expand_path(File.dirname(__FILE__)) + "/../fixtures/features/scenario/simple"
|
28
|
+
result = gr.query do
|
29
|
+
select name
|
30
|
+
from scenarios
|
31
|
+
end
|
32
|
+
result.should == [{"name"=> "Has a table"}, {"name"=> "Testing the slurping 1"},
|
33
|
+
{"name"=> "Testing the slurping not to be found"}, {"name"=> "Testing the slurping 2"},
|
34
|
+
{"name"=> "Testing the slurping 3"}, {"name"=> "Testing again"},
|
35
|
+
{"name"=> "Testing yet again"}, {"name"=> "Testing yet again part 2"}]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "multiple values" do
|
40
|
+
it 'should get multiple scenarios as a list of maps' do
|
41
|
+
gr = CQL::Repository.new File.expand_path(File.dirname(__FILE__)) + "/../fixtures/features/scenario/simple2"
|
42
|
+
result = gr.query do
|
43
|
+
select line, name
|
44
|
+
from scenarios
|
45
|
+
end
|
46
|
+
result.should == [{'line'=>6, 'name'=>"Testing the slurping"}, {'line'=>11, 'name'=>"Testing again"},
|
47
|
+
{'line'=>16, 'name'=>"Testing yet again"}, {'line'=>21, 'name'=>"Testing yet again part 2"}]
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should select all" do
|
51
|
+
gr = CQL::Repository.new File.expand_path(File.dirname(__FILE__)) + "/../fixtures/features/scenario/table"
|
52
|
+
expected = {"all"=>{"keyword"=>"Scenario", "name"=>"Has a table", "line"=>3,
|
53
|
+
"description"=>"", "id"=>"simple;has-a-table", "type"=>"scenario",
|
54
|
+
"steps"=>[{"keyword"=>"Given ", "name"=>"Something", "line"=>4,
|
55
|
+
"rows"=>[{"cells"=>["a", "a"], "line"=>5}, {"cells"=>["s", "a"], "line"=>6},
|
56
|
+
{"cells"=>["s", "s"], "line"=>7}]},
|
57
|
+
{"keyword"=>"Then ", "name"=>"something else", "line"=>8}]}}
|
58
|
+
|
59
|
+
result = gr.query do
|
60
|
+
select all
|
61
|
+
from scenarios
|
62
|
+
end
|
63
|
+
result.should == expected
|
64
|
+
|
65
|
+
result = gr.query do
|
66
|
+
select complete
|
67
|
+
from scenarios
|
68
|
+
end
|
69
|
+
result.should == expected
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
73
|
end
|
data/spec/unit_spec.rb
CHANGED
@@ -1,22 +1,22 @@
|
|
1
|
-
require 'rspec'
|
2
|
-
require File.dirname(__FILE__) + "/../lib/repo"
|
3
|
-
|
4
|
-
describe "cql" do
|
5
|
-
|
6
|
-
describe "tag searcher" do
|
7
|
-
it "should be able to search for tags" do
|
8
|
-
tags_given = [{"name"=>"@one", "line"=>3}, {"name"=>"@four", "line"=>3}, {"name"=>"@six", "line"=>3}, {"name"=>"@seven", "line"=>3}]
|
9
|
-
CQL::MapReduce.has_tags(tags_given, ["@one", "@four"]).should eql true
|
10
|
-
|
11
|
-
tags_given = [{"name"=>"@two", "line"=>3}, {"name"=>"@four", "line"=>3}, {"name"=>"@six", "line"=>3}, {"name"=>"@seven", "line"=>3}]
|
12
|
-
CQL::MapReduce.has_tags(tags_given, ["@one", "@four"]).should eql false
|
13
|
-
|
14
|
-
tags_given = [{"name"=>"@two", "line"=>3}, {"name"=>"@four", "line"=>3}, {"name"=>"@six", "line"=>3}, {"name"=>"@seven", "line"=>3}]
|
15
|
-
CQL::MapReduce.has_tags(tags_given, ["@four"]).should eql true
|
16
|
-
|
17
|
-
tags_given = [{"name"=>"@two", "line"=>3}, {"name"=>"@four", "line"=>3}, {"name"=>"@six", "line"=>3}, {"name"=>"@seven", "line"=>3}]
|
18
|
-
CQL::MapReduce.has_tags(tags_given, ["@four", "@two", "@six", "@seven"]).should eql true
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
1
|
+
require 'rspec'
|
2
|
+
require File.dirname(__FILE__) + "/../lib/repo"
|
3
|
+
|
4
|
+
describe "cql" do
|
5
|
+
|
6
|
+
describe "tag searcher" do
|
7
|
+
it "should be able to search for tags" do
|
8
|
+
#tags_given = [{"name"=>"@one", "line"=>3}, {"name"=>"@four", "line"=>3}, {"name"=>"@six", "line"=>3}, {"name"=>"@seven", "line"=>3}]
|
9
|
+
#CQL::MapReduce.has_tags(tags_given, ["@one", "@four"]).should eql true
|
10
|
+
#
|
11
|
+
#tags_given = [{"name"=>"@two", "line"=>3}, {"name"=>"@four", "line"=>3}, {"name"=>"@six", "line"=>3}, {"name"=>"@seven", "line"=>3}]
|
12
|
+
#CQL::MapReduce.has_tags(tags_given, ["@one", "@four"]).should eql false
|
13
|
+
#
|
14
|
+
#tags_given = [{"name"=>"@two", "line"=>3}, {"name"=>"@four", "line"=>3}, {"name"=>"@six", "line"=>3}, {"name"=>"@seven", "line"=>3}]
|
15
|
+
#CQL::MapReduce.has_tags(tags_given, ["@four"]).should eql true
|
16
|
+
#
|
17
|
+
#tags_given = [{"name"=>"@two", "line"=>3}, {"name"=>"@four", "line"=>3}, {"name"=>"@six", "line"=>3}, {"name"=>"@seven", "line"=>3}]
|
18
|
+
#CQL::MapReduce.has_tags(tags_given, ["@four", "@two", "@six", "@seven"]).should eql true
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
22
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-09-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: gherkin
|
@@ -81,15 +81,12 @@ executables: []
|
|
81
81
|
extensions: []
|
82
82
|
extra_rdoc_files: []
|
83
83
|
files:
|
84
|
-
- lib/dsl.rb
|
85
|
-
- lib/map_reduce.rb
|
86
|
-
- lib/repo.rb
|
87
84
|
- spec/filter_feature_dsl_spec.rb
|
88
85
|
- spec/filter_sso_spec.rb
|
89
86
|
- spec/map_reduce_spec.rb
|
90
87
|
- spec/select_feature_dsl_spec.rb
|
91
|
-
- spec/select_scen_outline_dsl_spec.rb
|
92
88
|
- spec/select_scenario_dsl_spec.rb
|
89
|
+
- spec/select_scen_outline_dsl_spec.rb
|
93
90
|
- spec/unit_spec.rb
|
94
91
|
homepage:
|
95
92
|
licenses: []
|
@@ -123,15 +120,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
120
|
version: '0'
|
124
121
|
requirements: []
|
125
122
|
rubyforge_project:
|
126
|
-
rubygems_version: 1.8.
|
123
|
+
rubygems_version: 1.8.24
|
127
124
|
signing_key:
|
128
125
|
specification_version: 3
|
129
|
-
summary:
|
126
|
+
summary: cucumber-0.1.3
|
130
127
|
test_files:
|
131
128
|
- spec/filter_feature_dsl_spec.rb
|
132
129
|
- spec/filter_sso_spec.rb
|
133
130
|
- spec/map_reduce_spec.rb
|
134
131
|
- spec/select_feature_dsl_spec.rb
|
135
|
-
- spec/select_scen_outline_dsl_spec.rb
|
136
132
|
- spec/select_scenario_dsl_spec.rb
|
133
|
+
- spec/select_scen_outline_dsl_spec.rb
|
137
134
|
- spec/unit_spec.rb
|
data/lib/dsl.rb
DELETED
@@ -1,64 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/map_reduce"
|
2
|
-
module CQL
|
3
|
-
DSL_KEYWORDS = %w(features scenario_outlines scenarios all step_lines examples name)
|
4
|
-
module Dsl
|
5
|
-
(CQL::QUERY_VALUES + CQL::DSL_KEYWORDS).each do |method_name|
|
6
|
-
define_method(method_name) { |*args|
|
7
|
-
return method_name if args.size == 0
|
8
|
-
{method_name=>args}
|
9
|
-
}
|
10
|
-
end
|
11
|
-
|
12
|
-
%w(sc_gt sc_gte sc_lt sc_lte soc_gt soc_gte soc_lt soc_lte ssoc_gt ssoc_gte ssoc_lt ssoc_lte tc_lt tc_lte tc_gt tc_gte lc_lt lc_lte lc_gt lc_gte).each do |meth|
|
13
|
-
define_method(meth) { |num| {meth=>num} }
|
14
|
-
end
|
15
|
-
|
16
|
-
alias :everything :all
|
17
|
-
alias :complete :all
|
18
|
-
|
19
|
-
def select *what
|
20
|
-
@what = what
|
21
|
-
end
|
22
|
-
|
23
|
-
def from where
|
24
|
-
@from = where
|
25
|
-
@data
|
26
|
-
end
|
27
|
-
|
28
|
-
def tags *tags
|
29
|
-
return "tags" if tags.size == 0
|
30
|
-
{'tags'=>tags}
|
31
|
-
end
|
32
|
-
|
33
|
-
def with filter
|
34
|
-
if filter.has_key? 'name'
|
35
|
-
@data = CQL::MapReduce.filter_features(@data, 'feature'=>filter['name'])
|
36
|
-
elsif @from == 'features'
|
37
|
-
filter.each { |k, v| @data = CQL::MapReduce.filter_features(@data, k=>v) }
|
38
|
-
elsif @from == 'scenarios'
|
39
|
-
filter.each { |k, v|
|
40
|
-
@data = CQL::MapReduce.filter_sso2(@data, k=>v)
|
41
|
-
}
|
42
|
-
end
|
43
|
-
@data
|
44
|
-
end
|
45
|
-
|
46
|
-
class Query
|
47
|
-
include Dsl
|
48
|
-
attr_reader :data, :what
|
49
|
-
|
50
|
-
def initialize features, &block
|
51
|
-
@data = features
|
52
|
-
@data = self.instance_eval(&block)
|
53
|
-
|
54
|
-
@data= CQL::MapReduce.filter_sso(@data, 'what'=>@from[0, @from.size-1]) if @from != "features"
|
55
|
-
result = Array.new(@data.size)
|
56
|
-
result = result.map {|e|{}}
|
57
|
-
@what.each do |w|
|
58
|
-
CQL::MapReduce.send(w, @data).each_with_index { |e, i| result[i][w]=e }
|
59
|
-
end
|
60
|
-
@data = result.size == 1 ? result.first : result
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
data/lib/map_reduce.rb
DELETED
@@ -1,139 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/dsl"
|
2
|
-
require 'set'
|
3
|
-
module CQL
|
4
|
-
QUERY_VALUES = %w(name uri line description type steps id tags examples)
|
5
|
-
|
6
|
-
class MapReduce
|
7
|
-
CQL::QUERY_VALUES.each do |property|
|
8
|
-
define_singleton_method(property) do |input|
|
9
|
-
input = [input] if input.class != Array
|
10
|
-
input.map { |a| a[property] }
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
%w(all everything complete).each do |method_name|
|
15
|
-
define_singleton_method(method_name) { |input| input }
|
16
|
-
end
|
17
|
-
|
18
|
-
def self.step_lines input
|
19
|
-
input = [input] if input.class != Array
|
20
|
-
steps(input).map do |scen|
|
21
|
-
scen.map { |line| line['keyword'] + line['name'] }
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.filter_features input, args
|
26
|
-
if args.has_key?('feature') && args['feature'][0].class == String
|
27
|
-
input = input.find_all { |feature| feature['name'] == args['feature'][0] }
|
28
|
-
elsif args.has_key?('feature') && args['feature'][0].class == Regexp
|
29
|
-
input = input.find_all { |feature| feature['name'] =~ args['feature'][0] }
|
30
|
-
end
|
31
|
-
|
32
|
-
%w(sc_gt sc_gte sc_lt sc_lte soc_gt soc_gte soc_lt soc_lte ssoc_gt ssoc_gte ssoc_lt ssoc_lte).each do |fn|
|
33
|
-
if args.has_key?(fn)
|
34
|
-
what, operator = fn.split "_"
|
35
|
-
desc = {"sc"=>["Scenario"], "soc"=>["Scenario Outline"], "ssoc"=>["Scenario", "Scenario Outline"]}
|
36
|
-
operator_map = {"lt"=>'<', 'lte'=>'<=', 'gt'=>'>', 'gte'=>'>='}
|
37
|
-
input = input.find_all do |feature|
|
38
|
-
size = feature['elements'].find_all { |e| desc[what].include? e['keyword'] }.size
|
39
|
-
size.send(operator_map[operator], args[fn])
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
%w(tc_lt tc_lte tc_gt tc_gte).each do |fn|
|
45
|
-
what, operator = fn.split "_"
|
46
|
-
operator_map = {"lt"=>'<', 'lte'=>'<=', 'gt'=>'>', 'gte'=>'>='}
|
47
|
-
if args.has_key?(fn)
|
48
|
-
input = input.find_all do |feature|
|
49
|
-
feature['tags'] && feature['tags'].size.send(operator_map[operator], args[fn])
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
input = input.find_all { |feature| has_tags feature['tags'], args['tags'] } if args.has_key? 'tags'
|
55
|
-
input
|
56
|
-
end
|
57
|
-
|
58
|
-
def self.filter_sso input, args
|
59
|
-
results = []
|
60
|
-
input = filter_features(input, 'feature'=>args['feature']) if args.has_key?('feature')
|
61
|
-
input.each do |feature|
|
62
|
-
feature['elements'].each do |element|
|
63
|
-
results.push element if element['type'] == args['what']
|
64
|
-
end
|
65
|
-
end
|
66
|
-
results
|
67
|
-
end
|
68
|
-
|
69
|
-
def self.filter_sso2 input, args
|
70
|
-
%w(tc_lt tc_lte tc_gt tc_gte).each do |fn|
|
71
|
-
what, operator = fn.split "_"
|
72
|
-
operator_map = {"lt"=>'<', 'lte'=>'<=', 'gt'=>'>', 'gte'=>'>='}
|
73
|
-
if args.has_key?(fn)
|
74
|
-
input.each_with_index do |feature, index|
|
75
|
-
filtered_elements= feature['elements'].find_all do |sso|
|
76
|
-
sso['tags'].size.send(operator_map[operator], args[fn])
|
77
|
-
end
|
78
|
-
input[index]['elements'] = filtered_elements
|
79
|
-
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
%w(lc_lt lc_lte lc_gt lc_gte).each do |fn|
|
85
|
-
what, operator = fn.split "_"
|
86
|
-
operator_map = {"lt"=>'<', 'lte'=>'<=', 'gt'=>'>', 'gte'=>'>='}
|
87
|
-
if args.has_key?(fn)
|
88
|
-
input.each_with_index do |feature, index|
|
89
|
-
filtered_elements= feature['elements'].find_all do |sso|
|
90
|
-
sso['steps'].size.send(operator_map[operator], args[fn])
|
91
|
-
end
|
92
|
-
input[index]['elements'] = filtered_elements
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
if args.has_key? 'line'
|
98
|
-
input.each_with_index do |feature, index|
|
99
|
-
filtered_elements= feature['elements'].find_all do |sso|
|
100
|
-
raw_step_lines = sso['steps'].map { |sl| sl['name'] }
|
101
|
-
line_to_match = args['line'].first
|
102
|
-
result = nil
|
103
|
-
if line_to_match.class == String
|
104
|
-
result = raw_step_lines.include? line_to_match
|
105
|
-
elsif line_to_match.class == Regexp
|
106
|
-
result = raw_step_lines.find { |line| line =~ line_to_match }
|
107
|
-
if result.class == String
|
108
|
-
result = result.size > 0
|
109
|
-
else
|
110
|
-
result = false
|
111
|
-
end
|
112
|
-
end
|
113
|
-
result
|
114
|
-
end
|
115
|
-
input[index]['elements'] = filtered_elements
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
input
|
120
|
-
end
|
121
|
-
|
122
|
-
def self.tag_set input
|
123
|
-
tags = Set.new
|
124
|
-
input.each do |feature|
|
125
|
-
feature['elements'].each do |element|
|
126
|
-
break if element['tags'] == nil
|
127
|
-
element['tags'].each { |tag| tags.add tag['name'] }
|
128
|
-
end
|
129
|
-
end
|
130
|
-
tags.to_a
|
131
|
-
end
|
132
|
-
|
133
|
-
def self.has_tags given, search
|
134
|
-
return false if given == nil
|
135
|
-
search.count { |tag_for_search| given.map { |t| t["name"] }.include?(tag_for_search) }==search.size
|
136
|
-
end
|
137
|
-
|
138
|
-
end
|
139
|
-
end
|
data/lib/repo.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
require 'gherkin/parser/parser'
|
2
|
-
require 'gherkin/formatter/json_formatter'
|
3
|
-
require 'stringio'
|
4
|
-
require File.dirname(__FILE__) + "/dsl"
|
5
|
-
|
6
|
-
module CQL
|
7
|
-
class Repository
|
8
|
-
include Dsl
|
9
|
-
attr_reader :parsed_feature_files
|
10
|
-
|
11
|
-
def initialize features_home_dir
|
12
|
-
@parsed_feature_files = load_features(list_features(features_home_dir))
|
13
|
-
end
|
14
|
-
|
15
|
-
def query &block
|
16
|
-
Query.new(parsed_feature_files.clone, &block).data
|
17
|
-
end
|
18
|
-
|
19
|
-
private
|
20
|
-
def list_features base_dir
|
21
|
-
Dir.glob(base_dir + "/**/*.feature")
|
22
|
-
end
|
23
|
-
|
24
|
-
def load_features sources
|
25
|
-
io = StringIO.new
|
26
|
-
formatter = Gherkin::Formatter::JSONFormatter.new(io)
|
27
|
-
parser = Gherkin::Parser::Parser.new(formatter)
|
28
|
-
sources.each { |s| parser.parse(IO.read(s), s, 0) }
|
29
|
-
formatter.done
|
30
|
-
JSON.parse(io.string)
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
34
|
-
end
|