gherkin_language 0.1.0 → 0.1.1
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/Dockerfile +13 -0
- data/Gemfile +1 -1
- data/README.md +2 -0
- data/Rakefile +4 -2
- data/features/confused_words.feature +2 -0
- data/features/readability.feature +24 -4
- data/features/support/env.rb +1 -1
- data/features/tag.feature +4 -15
- data/gherkin_language.gemspec +2 -2
- data/lib/gherkin_language.rb +5 -3
- data/lib/gherkin_language/language_tool_process.rb +7 -7
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a590ba82c3ddcfadb69cdb406e9f748ffde3ab8
|
4
|
+
data.tar.gz: 9e1b9775fdff0c5da5189c3a5f6ba39f165e19e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7fa9d18fbde5d760c308a421a81c6e865738797d8f979bcaa39d557c96ee7174cd89840e0597ddd940dc502dc6f13442ed478404338caff28dd4e70d6c6a4d28
|
7
|
+
data.tar.gz: a787411778379f5b51cc50119d2ac86f8efef1b32ac97591879700f761657e78502219419e170523eeed3efb16690da9e064f1fa6bc4ccf3d272e64b4dcf6acd
|
data/Dockerfile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
FROM ruby
|
2
|
+
MAINTAINER think@hotmail.de
|
3
|
+
|
4
|
+
# TODO: activate --ngram
|
5
|
+
RUN \
|
6
|
+
apt-get update && \
|
7
|
+
apt-get install -y unzip default-jre && \
|
8
|
+
gem install gherkin_language --no-format-exec && \
|
9
|
+
echo "Feature: Empty" > /tmp/empty.feature && \
|
10
|
+
gherkin_language /tmp/empty.feature && \
|
11
|
+
rm /tmp/empty.feature
|
12
|
+
|
13
|
+
CMD gherkin_language
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -25,6 +25,8 @@ To ignore specific rules, mention them with an `--ignore RULE`. This allows to b
|
|
25
25
|
|
26
26
|
To check for confused words, based on ngrams, add `--ngram`. Please note, that it requires much disk space and time.
|
27
27
|
|
28
|
+
Get a readability report using `--readability`. It indicates, which files are not good readable.
|
29
|
+
|
28
30
|
|
29
31
|
Glossary
|
30
32
|
--------
|
data/Rakefile
CHANGED
@@ -18,7 +18,7 @@ task test: :cucumber
|
|
18
18
|
|
19
19
|
desc 'Publishes the Gem'
|
20
20
|
task push: :build do
|
21
|
-
sh 'gem push gherkin_language-0.
|
21
|
+
sh 'gem push gherkin_language-0.1.1.gem'
|
22
22
|
end
|
23
23
|
|
24
24
|
desc 'Checks ruby style'
|
@@ -27,7 +27,9 @@ task :rubocop do
|
|
27
27
|
end
|
28
28
|
|
29
29
|
task :cucumber do
|
30
|
-
|
30
|
+
options = %w()
|
31
|
+
options.push '--tags ~@slow' unless ENV['slow']
|
32
|
+
sh "cucumber #{options * ' '}"
|
31
33
|
end
|
32
34
|
|
33
35
|
task :lint do
|
@@ -1,3 +1,4 @@
|
|
1
|
+
@slow
|
1
2
|
Feature: Confused Words
|
2
3
|
As a Business Analyst
|
3
4
|
I want to be informed for confused words
|
@@ -34,6 +35,7 @@ Feature: Confused Words
|
|
34
35
|
Context: Given I do not now where it is when execute then pass
|
35
36
|
Replacements: know
|
36
37
|
References: test.feature
|
38
|
+
|
37
39
|
"""
|
38
40
|
|
39
41
|
Scenario: Accept non confused words
|
@@ -12,7 +12,7 @@ Feature: Readability
|
|
12
12
|
no_cache = true
|
13
13
|
ngrams = false
|
14
14
|
language = GherkinLanguage.new(no_cache, ngrams)
|
15
|
-
language.determine_readability_by_file %w(default.feature
|
15
|
+
language.determine_readability_by_file %w(default.feature test.feature)
|
16
16
|
exit language.report
|
17
17
|
|
18
18
|
"""
|
@@ -25,8 +25,8 @@ Feature: Readability
|
|
25
25
|
Then pass
|
26
26
|
"""
|
27
27
|
|
28
|
-
Scenario: Sort
|
29
|
-
Given a file named "
|
28
|
+
Scenario: Sort poor readable
|
29
|
+
Given a file named "test.feature" with:
|
30
30
|
"""
|
31
31
|
Feature: Unreadable busting complexity check
|
32
32
|
Scenario: nonsense and unreadable
|
@@ -40,8 +40,28 @@ Feature: Readability
|
|
40
40
|
Readability. Sorted from best to worst readable feature
|
41
41
|
|
42
42
|
119: default.feature
|
43
|
-
30:
|
43
|
+
30: test.feature
|
44
44
|
|
45
45
|
2 files analyzed. Average readability is 74
|
46
46
|
|
47
47
|
"""
|
48
|
+
|
49
|
+
Scenario: Sort highly readable
|
50
|
+
Given a file named "test.feature" with:
|
51
|
+
"""
|
52
|
+
Feature: Test
|
53
|
+
Scenario: Test
|
54
|
+
When execute
|
55
|
+
Then test
|
56
|
+
"""
|
57
|
+
When I run `ruby readability.rb`
|
58
|
+
Then it should pass with exactly:
|
59
|
+
"""
|
60
|
+
Readability. Sorted from best to worst readable feature
|
61
|
+
|
62
|
+
120: test.feature
|
63
|
+
119: default.feature
|
64
|
+
|
65
|
+
2 files analyzed. Average readability is 120
|
66
|
+
|
67
|
+
"""
|
data/features/support/env.rb
CHANGED
data/features/tag.feature
CHANGED
@@ -26,26 +26,15 @@ Feature: Tag
|
|
26
26
|
Then it should pass with exactly:
|
27
27
|
"""
|
28
28
|
<S>
|
29
|
-
[[[/null]
|
30
|
-
"["
|
31
|
-
|
32
|
-
"["/'']
|
33
|
-
,[,/,,O]
|
34
|
-
"["/``,O]
|
35
|
-
Tag[tag/NN:UN,tag/VB,tag/VBP]
|
36
|
-
"["/'']
|
37
|
-
,[,/,,O]
|
38
|
-
"["/``,O]
|
39
|
-
Given[Given/NNP,B-VP]
|
29
|
+
[[[/null]"["/``]Test[Test/NNP]"["/''],[,/,,O]
|
30
|
+
"["/``,O]Tag[tag/NN:UN,tag/VB,tag/VBP]"["/''],[,/,,O]
|
31
|
+
"["/``,O]Given[Given/NNP,B-VP]
|
40
32
|
a[a/DT,B-NP-singular]
|
41
33
|
test[test/JJ,test/NN,test/VB,test/VBP,E-NP-singular]
|
42
34
|
when[when/WRB,B-ADVP]
|
43
35
|
execute[execute/VB,execute/VBP,B-VP]
|
44
36
|
then[then/JJ,then/NN,then/RB,I-VP]
|
45
|
-
pass[pass/JJ,pass/NN,pass/VB,pass/VBP,I-VP]
|
46
|
-
"["/'',B-ADVP]
|
47
|
-
]
|
48
|
-
[</S>,O]
|
37
|
+
pass[pass/JJ,pass/NN,pass/VB,pass/VBP,I-VP]"["/'',B-ADVP]][</S>,O]
|
49
38
|
|
50
39
|
|
51
40
|
"""
|
data/gherkin_language.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'gherkin_language'
|
3
|
-
s.version = '0.1.
|
4
|
-
s.date = '
|
3
|
+
s.version = '0.1.1'
|
4
|
+
s.date = '2016-01-17'
|
5
5
|
s.summary = 'Gherkin Language'
|
6
6
|
s.description = 'Check language and readability of Gherkin Files'
|
7
7
|
s.authors = ['Stefan Rohe']
|
data/lib/gherkin_language.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
+
gem 'gherkin', '2.12.2'
|
3
|
+
|
2
4
|
require 'gherkin/formatter/json_formatter'
|
3
5
|
require 'gherkin/parser/parser'
|
4
6
|
require 'gherkin_language/error'
|
@@ -66,7 +68,7 @@ class GherkinLanguage
|
|
66
68
|
|
67
69
|
total_words = 0
|
68
70
|
total_syllabels = 0
|
69
|
-
Syllables.new(sentences.join
|
71
|
+
Syllables.new(sentences.join('\n')).to_h.each do |_word, syllabels|
|
70
72
|
total_words += 1
|
71
73
|
total_syllabels += syllabels
|
72
74
|
end
|
@@ -76,7 +78,7 @@ class GherkinLanguage
|
|
76
78
|
def accepted?(sentence)
|
77
79
|
return false if @accepted_paragraphs.nil?
|
78
80
|
key = :without_glossary
|
79
|
-
key = hash(File.read
|
81
|
+
key = hash(File.read('.glossary')) if File.exist? '.glossary'
|
80
82
|
|
81
83
|
return false unless @accepted_paragraphs.key? key
|
82
84
|
@accepted_paragraphs[key].include? hash sentence
|
@@ -147,7 +149,7 @@ class GherkinLanguage
|
|
147
149
|
@references.each do |sentence, _refs|
|
148
150
|
next if used_refs.include? sentence
|
149
151
|
key = :without_glossary
|
150
|
-
key = hash(File.read
|
152
|
+
key = hash(File.read('.glossary')) if File.exist? '.glossary'
|
151
153
|
|
152
154
|
@accepted_paragraphs[key] = Set.new [] unless @accepted_paragraphs.key? key
|
153
155
|
@accepted_paragraphs[key].add hash sentence
|
@@ -16,10 +16,10 @@ require 'digest'
|
|
16
16
|
class LanguageToolProcess
|
17
17
|
attr_accessor :errors, :unknown_words
|
18
18
|
|
19
|
-
VERSION = 'LanguageTool-3.1'
|
20
|
-
URL = "https://www.languagetool.org/download/#{VERSION}.zip"
|
21
|
-
NGRAM_VERSION = 'ngrams-en-20150817'
|
22
|
-
NGRAM_URL = "https://languagetool.org/download/ngram-data/#{NGRAM_VERSION}.zip"
|
19
|
+
VERSION = 'LanguageTool-3.1'.freeze
|
20
|
+
URL = "https://www.languagetool.org/download/#{VERSION}.zip".freeze
|
21
|
+
NGRAM_VERSION = 'ngrams-en-20150817'.freeze
|
22
|
+
NGRAM_URL = "https://languagetool.org/download/ngram-data/#{NGRAM_VERSION}.zip".freeze
|
23
23
|
|
24
24
|
def initialize(ngrams = false)
|
25
25
|
path = Dir.tmpdir
|
@@ -77,9 +77,9 @@ class LanguageToolProcess
|
|
77
77
|
end
|
78
78
|
p.close
|
79
79
|
end
|
80
|
-
output.
|
81
|
-
output.
|
82
|
-
output.
|
80
|
+
output.tr!(' ', "\n")
|
81
|
+
output.tr!(']', "]\n")
|
82
|
+
output.tr!("\n\n", "\n")
|
83
83
|
output
|
84
84
|
end
|
85
85
|
|
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.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefan Rohe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gherkin
|
@@ -75,6 +75,7 @@ extra_rdoc_files: []
|
|
75
75
|
files:
|
76
76
|
- ".rubocop.yml"
|
77
77
|
- ".travis.yml"
|
78
|
+
- Dockerfile
|
78
79
|
- Gemfile
|
79
80
|
- Guardfile
|
80
81
|
- LICENSE
|
@@ -115,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
115
116
|
version: '0'
|
116
117
|
requirements: []
|
117
118
|
rubyforge_project:
|
118
|
-
rubygems_version: 2.2.
|
119
|
+
rubygems_version: 2.2.5
|
119
120
|
signing_key:
|
120
121
|
specification_version: 4
|
121
122
|
summary: Gherkin Language
|