wally 0.0.15 → 0.0.16
Sign up to get free protection for your applications and to get access to all the features.
- data/config.ru +1 -1
- data/example-features/has-lots-of-tags.feature +2 -2
- data/example-features/multiple-scenarios.feature +7 -0
- data/features/list_tags.feature +20 -0
- data/lib/wally.rb +1 -0
- data/lib/wally/application.rb +5 -10
- data/lib/wally/counts_tags.rb +27 -0
- data/lib/wally/public/skin.css +4 -0
- data/lib/wally/version.rb +1 -1
- data/lib/wally/views/index.haml +1 -0
- data/lib/wally/views/layout.haml +6 -0
- data/lib/wally/views/search.haml +14 -11
- data/spec/wally/counts_tags_spec.rb +42 -0
- metadata +26 -20
data/config.ru
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
require './lib/
|
1
|
+
require './lib/wally'
|
2
2
|
run Sinatra::Application
|
@@ -0,0 +1,20 @@
|
|
1
|
+
Feature: List Tags
|
2
|
+
In order to be informed of all tags
|
3
|
+
As a stakeholder
|
4
|
+
I want a list of tags to be displayed
|
5
|
+
|
6
|
+
Scenario: Multiple tags
|
7
|
+
Given a feature file named "sample.feature" with the contents:
|
8
|
+
"""
|
9
|
+
@tag1
|
10
|
+
Feature: Tag Feature
|
11
|
+
@tag2 @multiple
|
12
|
+
Scenario: Tag Scenario 1
|
13
|
+
@tag3 @multiple
|
14
|
+
Scenario: Tag Scenario 2
|
15
|
+
"""
|
16
|
+
When I visit the home page
|
17
|
+
Then I should see a link to "@tag1 (1)" with the url "/search?q=@tag1"
|
18
|
+
And I should see a link to "@tag2 (1)" with the url "/search?q=@tag2"
|
19
|
+
And I should see a link to "@tag3 (1)" with the url "/search?q=@tag3"
|
20
|
+
And I should see a link to "@multiple (2)" with the url "/search?q=@multiple"
|
data/lib/wally.rb
CHANGED
data/lib/wally/application.rb
CHANGED
@@ -7,16 +7,11 @@ configure do
|
|
7
7
|
set :haml, { :ugly=>true }
|
8
8
|
end
|
9
9
|
|
10
|
-
def features_path
|
11
|
-
ARGV.first || "features"
|
12
|
-
end
|
13
|
-
|
14
|
-
def lists_features
|
15
|
-
Wally::ListsFeatures.new(features_path)
|
16
|
-
end
|
17
|
-
|
18
10
|
before do
|
19
|
-
|
11
|
+
features_path = ARGV.first || "features"
|
12
|
+
@lists_features = Wally::ListsFeatures.new(features_path)
|
13
|
+
@features = @lists_features.features
|
14
|
+
@tag_count = Wally::CountsTags.new(@lists_features).count_tags
|
20
15
|
end
|
21
16
|
|
22
17
|
get '/?' do
|
@@ -32,7 +27,7 @@ end
|
|
32
27
|
|
33
28
|
get '/search/?' do
|
34
29
|
if params[:q]
|
35
|
-
@search_results = Wally::SearchFeatures.new(lists_features).find(:query => params[:q])
|
30
|
+
@search_results = Wally::SearchFeatures.new(@lists_features).find(:query => params[:q])
|
36
31
|
end
|
37
32
|
haml :search
|
38
33
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Wally
|
2
|
+
class CountsTags
|
3
|
+
def initialize lists_features
|
4
|
+
@lists_features = lists_features
|
5
|
+
end
|
6
|
+
|
7
|
+
def count_tags
|
8
|
+
@lists_features.features.inject(Hash.new(0)) do |tag_count, feature|
|
9
|
+
if feature["tags"]
|
10
|
+
feature["tags"].each do |tag|
|
11
|
+
tag_count[tag["name"]] += 1
|
12
|
+
end
|
13
|
+
end
|
14
|
+
if feature["elements"]
|
15
|
+
feature["elements"].each do |element|
|
16
|
+
if element["tags"]
|
17
|
+
element["tags"].each do |tag|
|
18
|
+
tag_count[tag["name"]] += 1
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
tag_count
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/wally/public/skin.css
CHANGED
data/lib/wally/version.rb
CHANGED
data/lib/wally/views/index.haml
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
|
data/lib/wally/views/layout.haml
CHANGED
@@ -17,6 +17,12 @@
|
|
17
17
|
%input.btn{:type => "submit", :id => "search", :value => "Search"}
|
18
18
|
%div.container-fluid
|
19
19
|
%div.sidebar
|
20
|
+
- if @tag_count.any?
|
21
|
+
%h2 Tags
|
22
|
+
- @tag_count.each do |tag, count|
|
23
|
+
%span.label.notice
|
24
|
+
%a{:href => "/search?q=#{tag}"}
|
25
|
+
= "#{tag} (#{count})"
|
20
26
|
%h2
|
21
27
|
Features
|
22
28
|
%ul
|
data/lib/wally/views/search.haml
CHANGED
@@ -7,18 +7,21 @@
|
|
7
7
|
%a{:href => "/search?q=#{@search_results.suggestion}"}
|
8
8
|
= @search_results.suggestion
|
9
9
|
%ul
|
10
|
-
- @search_results.items.each do |
|
10
|
+
- @search_results.items.map {|i| i.feature["id"] }.uniq.each do |current_feature_id|
|
11
|
+
- root_search_result = @search_results.items.find { |r| r.feature["id"] == current_feature_id }
|
11
12
|
%li
|
12
|
-
%a{:href => "/features/#{
|
13
|
-
=
|
14
|
-
- if
|
15
|
-
= haml :tag_links, {:locals => {:tags =>
|
13
|
+
%a{:href => "/features/#{root_search_result.feature["id"]}"}
|
14
|
+
= root_search_result.feature["name"]
|
15
|
+
- if root_search_result.feature["tags"]
|
16
|
+
= haml :tag_links, {:locals => {:tags => root_search_result.feature["tags"]}, :layout => false}
|
17
|
+
|
16
18
|
%ul
|
17
|
-
-
|
18
|
-
|
19
|
-
%
|
20
|
-
|
21
|
-
|
22
|
-
|
19
|
+
- @search_results.items.select { |r| r.feature["id"] == current_feature_id }.each do |search_result|
|
20
|
+
- if search_result.scenario && search_result.scenario["id"]
|
21
|
+
%li
|
22
|
+
%a{:href => "/features/#{search_result.scenario["id"].gsub(";", "/scenario/")}"}
|
23
|
+
= search_result.scenario["name"]
|
24
|
+
- if search_result.scenario["tags"]
|
25
|
+
= haml :tag_links, {:locals => {:tags => search_result.scenario["tags"]}, :layout => false}
|
23
26
|
- else
|
24
27
|
%p Where's Wally? This search returned no results.
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "..", "spec_helper")
|
2
|
+
require 'fileutils'
|
3
|
+
require "wally/counts_tags"
|
4
|
+
|
5
|
+
module Wally
|
6
|
+
describe CountsTags do
|
7
|
+
before do
|
8
|
+
FileUtils.mkdir_p "application-features"
|
9
|
+
end
|
10
|
+
|
11
|
+
after do
|
12
|
+
FileUtils.rm_rf "application-features"
|
13
|
+
end
|
14
|
+
|
15
|
+
def write_feature(name, contents)
|
16
|
+
File.open("application-features/#{name}", "w") do |file|
|
17
|
+
file.write(contents)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
it "counts feature tags" do
|
22
|
+
write_feature("feature-1.feature", "@tag1 @tag2\nFeature: Feature 1")
|
23
|
+
write_feature("feature-2.feature", "@tag2 @tag2\nFeature: Feature 2")
|
24
|
+
lists_features = ListsFeatures.new("application-features")
|
25
|
+
|
26
|
+
CountsTags.new(lists_features).count_tags.should == {
|
27
|
+
"@tag1" => 1,
|
28
|
+
"@tag2" => 3
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
it "counts scenario tags" do
|
33
|
+
write_feature("feature-1.feature", "Feature: Feature 1\n@tag1@tag1\nScenario: Scenario 1")
|
34
|
+
write_feature("feature-2.feature", "Feature: Feature 2\n@tag3@tag1\nScenario: Scenario 1")
|
35
|
+
lists_features = ListsFeatures.new("application-features")
|
36
|
+
CountsTags.new(lists_features).count_tags.should == {
|
37
|
+
"@tag1" => 3,
|
38
|
+
"@tag3" => 1
|
39
|
+
}
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wally
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.16
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-11-
|
12
|
+
date: 2011-11-24 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sinatra
|
16
|
-
requirement: &
|
16
|
+
requirement: &70288097150820 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70288097150820
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: haml
|
27
|
-
requirement: &
|
27
|
+
requirement: &70288097150260 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70288097150260
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rdiscount
|
38
|
-
requirement: &
|
38
|
+
requirement: &70288097149660 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70288097149660
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: gherkin
|
49
|
-
requirement: &
|
49
|
+
requirement: &70288097149000 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70288097149000
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: komainu
|
60
|
-
requirement: &
|
60
|
+
requirement: &70288097134480 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70288097134480
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: cucumber
|
71
|
-
requirement: &
|
71
|
+
requirement: &70288097133960 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70288097133960
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: capybara
|
82
|
-
requirement: &
|
82
|
+
requirement: &70288097133180 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70288097133180
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: rspec
|
93
|
-
requirement: &
|
93
|
+
requirement: &70288097132520 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ! '>='
|
@@ -98,10 +98,10 @@ dependencies:
|
|
98
98
|
version: '0'
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *70288097132520
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: fakefs
|
104
|
-
requirement: &
|
104
|
+
requirement: &70288097131960 !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
107
|
- - ! '>='
|
@@ -109,7 +109,7 @@ dependencies:
|
|
109
109
|
version: '0'
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
|
-
version_requirements: *
|
112
|
+
version_requirements: *70288097131960
|
113
113
|
description: ''
|
114
114
|
email:
|
115
115
|
- andrew.vos@gmail.com
|
@@ -128,7 +128,9 @@ files:
|
|
128
128
|
- example-features/example-with-background.feature
|
129
129
|
- example-features/example_with_tags.feature
|
130
130
|
- example-features/has-lots-of-tags.feature
|
131
|
+
- example-features/multiple-scenarios.feature
|
131
132
|
- features/browse_features.feature
|
133
|
+
- features/list_tags.feature
|
132
134
|
- features/search_features.feature
|
133
135
|
- features/step_definitions/browse_features_steps.rb
|
134
136
|
- features/step_definitions/search_features_steps.rb
|
@@ -136,6 +138,7 @@ files:
|
|
136
138
|
- features/support/env.rb
|
137
139
|
- lib/wally.rb
|
138
140
|
- lib/wally/application.rb
|
141
|
+
- lib/wally/counts_tags.rb
|
139
142
|
- lib/wally/lists_features.rb
|
140
143
|
- lib/wally/public/bootstrap.min.css
|
141
144
|
- lib/wally/public/skin.css
|
@@ -150,6 +153,7 @@ files:
|
|
150
153
|
- lib/wally/views/search.haml
|
151
154
|
- lib/wally/views/tag_links.haml
|
152
155
|
- spec/spec_helper.rb
|
156
|
+
- spec/wally/counts_tags_spec.rb
|
153
157
|
- spec/wally/lists_features_spec.rb
|
154
158
|
- spec/wally/search_features_spec.rb
|
155
159
|
- wally.gemspec
|
@@ -179,11 +183,13 @@ specification_version: 3
|
|
179
183
|
summary: ''
|
180
184
|
test_files:
|
181
185
|
- features/browse_features.feature
|
186
|
+
- features/list_tags.feature
|
182
187
|
- features/search_features.feature
|
183
188
|
- features/step_definitions/browse_features_steps.rb
|
184
189
|
- features/step_definitions/search_features_steps.rb
|
185
190
|
- features/step_definitions/steps.rb
|
186
191
|
- features/support/env.rb
|
187
192
|
- spec/spec_helper.rb
|
193
|
+
- spec/wally/counts_tags_spec.rb
|
188
194
|
- spec/wally/lists_features_spec.rb
|
189
195
|
- spec/wally/search_features_spec.rb
|