gherkin_language 0.0.9 → 0.1.0
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 +4 -4
- data/.rubocop.yml +1 -1
- data/Gemfile +3 -2
- data/bin/gherkin_language +5 -0
- data/features/readability.feature +47 -0
- data/gherkin_language.gemspec +4 -3
- data/lib/gherkin_language.rb +27 -0
- metadata +19 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d845d6ef0a078c47dca82dbf52e8f3c2ec582315
|
4
|
+
data.tar.gz: 58d2b113ee3fc79522e71923e8b05dac5b861878
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0672226fa52098d827610ad1fec13b641e58fbf2aa08c87369c794f26393e75d11c80aa6f58653e066860e0e41207dac7ece6fb34aba0012deca52574eff21a9
|
7
|
+
data.tar.gz: 6f4949dd6382fe18c24f582d9e1f0ab0d79f9375ff1d31b973ec53ef0db8c900b8e1cc2c55cc91b8a295099c52df37a1269c770d2df1fe43f6ec12b4132aa2db
|
data/.rubocop.yml
CHANGED
data/Gemfile
CHANGED
data/bin/gherkin_language
CHANGED
@@ -23,6 +23,9 @@ OptionParser.new do |opts|
|
|
23
23
|
opts.on('--ignore [EXCEPTIONS]', 'ignore exceptions, Separated by ","') do |exceptions|
|
24
24
|
options[:ignore] = exceptions.split ','
|
25
25
|
end
|
26
|
+
opts.on('--readability', 'readbility by file') do |readability|
|
27
|
+
options[:readability] = readability
|
28
|
+
end
|
26
29
|
end.parse!
|
27
30
|
|
28
31
|
language = GherkinLanguage.new(options.key?(:no_cache), options.key?(:ngram))
|
@@ -36,6 +39,8 @@ if options.key? :tag
|
|
36
39
|
exit
|
37
40
|
end
|
38
41
|
|
42
|
+
language.determine_readability_by_file(ARGV) if options.key? :readability
|
43
|
+
|
39
44
|
ARGV.each { |file| language.analyze file }
|
40
45
|
|
41
46
|
if options.key? :ignore
|
@@ -0,0 +1,47 @@
|
|
1
|
+
Feature: Readability
|
2
|
+
As a Business Analyst
|
3
|
+
I want to be informed about non readable features
|
4
|
+
so that I know when I need to restructure
|
5
|
+
|
6
|
+
Background:
|
7
|
+
Given a file named "readability.rb" with:
|
8
|
+
"""
|
9
|
+
$LOAD_PATH << '../../lib'
|
10
|
+
require 'gherkin_language'
|
11
|
+
|
12
|
+
no_cache = true
|
13
|
+
ngrams = false
|
14
|
+
language = GherkinLanguage.new(no_cache, ngrams)
|
15
|
+
language.determine_readability_by_file %w(default.feature unreadable.feature)
|
16
|
+
exit language.report
|
17
|
+
|
18
|
+
"""
|
19
|
+
And a file named "default.feature" with:
|
20
|
+
"""
|
21
|
+
Feature: Default
|
22
|
+
Scenario: Tag
|
23
|
+
Given a test
|
24
|
+
When execute
|
25
|
+
Then pass
|
26
|
+
"""
|
27
|
+
|
28
|
+
Scenario: Sort by readability
|
29
|
+
Given a file named "unreadable.feature" with:
|
30
|
+
"""
|
31
|
+
Feature: Unreadable busting complexity check
|
32
|
+
Scenario: nonsense and unreadable
|
33
|
+
Given a fancy-hyper non-readable and quite complex test specification
|
34
|
+
When consider to execute that
|
35
|
+
Then verification is successful
|
36
|
+
"""
|
37
|
+
When I run `ruby readability.rb`
|
38
|
+
Then it should pass with exactly:
|
39
|
+
"""
|
40
|
+
Readability. Sorted from best to worst readable feature
|
41
|
+
|
42
|
+
119: default.feature
|
43
|
+
30: unreadable.feature
|
44
|
+
|
45
|
+
2 files analyzed. Average readability is 74
|
46
|
+
|
47
|
+
"""
|
data/gherkin_language.gemspec
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'gherkin_language'
|
3
|
-
s.version = '0.0
|
4
|
-
s.date = '2015-10-
|
3
|
+
s.version = '0.1.0'
|
4
|
+
s.date = '2015-10-11'
|
5
5
|
s.summary = 'Gherkin Language'
|
6
|
-
s.description = 'Check language of Gherkin Files'
|
6
|
+
s.description = 'Check language and readability of Gherkin Files'
|
7
7
|
s.authors = ['Stefan Rohe']
|
8
8
|
s.homepage = 'http://github.com/funkwerk/gherkin_language/'
|
9
9
|
s.files = `git ls-files`.split("\n")
|
10
10
|
s.executables = s.files.grep(%r{^bin/}) { |file| File.basename(file) }
|
11
11
|
s.add_runtime_dependency 'gherkin', ['>= 2.12.2']
|
12
12
|
s.add_runtime_dependency 'term-ansicolor', ['>= 1.3.2']
|
13
|
+
s.add_runtime_dependency 'syllables', ['>= 0.1.4']
|
13
14
|
s.add_development_dependency 'aruba', ['>= 0.6.2']
|
14
15
|
end
|
data/lib/gherkin_language.rb
CHANGED
@@ -46,6 +46,33 @@ class GherkinLanguage
|
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
+
def determine_readability_by_file(files)
|
50
|
+
puts "Readability. Sorted from best to worst readable feature\n\n" if files.length > 1
|
51
|
+
readability_by_file = {}
|
52
|
+
files.each do |file|
|
53
|
+
sentences = extract_sentences parse(file)
|
54
|
+
readability_by_file[file] = readability sentences
|
55
|
+
end
|
56
|
+
average_readability = 0
|
57
|
+
readability_by_file.sort { |lhs, rhs| lhs[1] <=> rhs[1] }.reverse_each do |file, rating|
|
58
|
+
puts "#{rating.round}: #{file}"
|
59
|
+
average_readability += rating / files.length
|
60
|
+
end
|
61
|
+
puts "\n#{files.length} files analyzed. Average readability is #{average_readability.round}" if files.length > 1
|
62
|
+
end
|
63
|
+
|
64
|
+
def readability(sentences)
|
65
|
+
require 'syllables'
|
66
|
+
|
67
|
+
total_words = 0
|
68
|
+
total_syllabels = 0
|
69
|
+
Syllables.new(sentences.join '\n').to_h.each do |_word, syllabels|
|
70
|
+
total_words += 1
|
71
|
+
total_syllabels += syllabels
|
72
|
+
end
|
73
|
+
206.835 - 1.015 * (total_words / sentences.length) - 84.6 * (total_syllabels / total_words)
|
74
|
+
end
|
75
|
+
|
49
76
|
def accepted?(sentence)
|
50
77
|
return false if @accepted_paragraphs.nil?
|
51
78
|
key = :without_glossary
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gherkin_language
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefan Rohe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gherkin
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 1.3.2
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: syllables
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.1.4
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.1.4
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: aruba
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,7 +66,7 @@ dependencies:
|
|
52
66
|
- - ">="
|
53
67
|
- !ruby/object:Gem::Version
|
54
68
|
version: 0.6.2
|
55
|
-
description: Check language of Gherkin Files
|
69
|
+
description: Check language and readability of Gherkin Files
|
56
70
|
email:
|
57
71
|
executables:
|
58
72
|
- gherkin_language
|
@@ -71,6 +85,7 @@ files:
|
|
71
85
|
- features/correct.feature
|
72
86
|
- features/exception.feature
|
73
87
|
- features/glossary.feature
|
88
|
+
- features/readability.feature
|
74
89
|
- features/report.feature
|
75
90
|
- features/sentences.feature
|
76
91
|
- features/support/env.rb
|
@@ -100,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
115
|
version: '0'
|
101
116
|
requirements: []
|
102
117
|
rubyforge_project:
|
103
|
-
rubygems_version: 2.2.
|
118
|
+
rubygems_version: 2.2.3
|
104
119
|
signing_key:
|
105
120
|
specification_version: 4
|
106
121
|
summary: Gherkin Language
|