gherkin_language 0.1.3 → 0.1.4
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/README.md +2 -0
- data/Rakefile +1 -1
- data/bin/gherkin_language +7 -1
- data/features/correct.feature +14 -0
- data/features/exception.feature +1 -1
- data/features/glossary.feature +3 -1
- data/features/report.feature +3 -1
- data/features/tag.feature +3 -3
- data/gherkin_language.gemspec +2 -2
- data/lib/gherkin_language.rb +4 -3
- data/lib/gherkin_language/language_tool_process.rb +6 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f3ff47e5efcaf5646238231cfc30a418a320d9a2
|
4
|
+
data.tar.gz: 435a443e36b153809de0fc9b0706e2a68cc1c6b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dbbed75c28198258ec1213db2bfaf63762cefc28ee1311cb2c4dfaf4052469f6160b411117b8f9bce0cdd4ce440b5d6c92e710a7bdcb6ebc10549d33c6a5913a
|
7
|
+
data.tar.gz: 5e00377cc5240362ac380f978e0b6caeeb40e43f448144b5150db8acda394545bb645e7947380430ff4e52b054ebe7a6df59246861ad414cd29e833ad08ca1d4
|
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
|
+
By default it will accept unknown words. For warnings about unknown words add `--unknown-words`.
|
29
|
+
|
28
30
|
Get a readability report using `--readability`. It indicates, which files are not good readable.
|
29
31
|
|
30
32
|
|
data/Rakefile
CHANGED
data/bin/gherkin_language
CHANGED
@@ -26,9 +26,15 @@ OptionParser.new do |opts|
|
|
26
26
|
opts.on('--readability', 'readbility by file') do |readability|
|
27
27
|
options[:readability] = readability
|
28
28
|
end
|
29
|
+
opts.on('--unknown-words', 'determine unknown words') do |unknown_words|
|
30
|
+
options[:unknown_words] = unknown_words
|
31
|
+
end
|
29
32
|
end.parse!
|
30
33
|
|
31
|
-
language = GherkinLanguage.new(
|
34
|
+
language = GherkinLanguage.new(
|
35
|
+
options.key?(:no_cache),
|
36
|
+
options.key?(:ngram),
|
37
|
+
options.key?(:unknown_words))
|
32
38
|
|
33
39
|
if options.key? :sentences
|
34
40
|
ARGV.each { |file| puts language.extract_sentences language.parse file }
|
data/features/correct.feature
CHANGED
@@ -39,3 +39,17 @@ Feature: Correct
|
|
39
39
|
"""
|
40
40
|
|
41
41
|
"""
|
42
|
+
|
43
|
+
Scenario: Scenario without Given
|
44
|
+
Given a file named "test.feature" with:
|
45
|
+
"""
|
46
|
+
Feature: Test
|
47
|
+
Scenario: Test
|
48
|
+
When execute
|
49
|
+
Then verify
|
50
|
+
"""
|
51
|
+
When I run `ruby report.rb`
|
52
|
+
Then it should pass with exactly:
|
53
|
+
"""
|
54
|
+
|
55
|
+
"""
|
data/features/exception.feature
CHANGED
@@ -14,6 +14,7 @@ Feature: Exception
|
|
14
14
|
language.ignore 'EN_A_VS_AN'
|
15
15
|
language.analyze 'test.feature'
|
16
16
|
exit language.report
|
17
|
+
|
17
18
|
"""
|
18
19
|
|
19
20
|
Scenario: Accept ignored rules
|
@@ -48,6 +49,5 @@ Feature: Exception
|
|
48
49
|
Context: Given a test when exicute then pass
|
49
50
|
Replacements: execute
|
50
51
|
References: test.feature
|
51
|
-
1 unknown words: exicute
|
52
52
|
|
53
53
|
"""
|
data/features/glossary.feature
CHANGED
@@ -10,7 +10,9 @@ Feature: Glossary
|
|
10
10
|
require 'gherkin_language'
|
11
11
|
|
12
12
|
no_cache = true
|
13
|
-
|
13
|
+
ngram = false
|
14
|
+
unknown_words = true
|
15
|
+
language = GherkinLanguage.new no_cache, ngram, unknown_words
|
14
16
|
language.analyze 'test.feature'
|
15
17
|
exit language.report
|
16
18
|
|
data/features/report.feature
CHANGED
@@ -10,7 +10,9 @@ Feature: Report
|
|
10
10
|
require 'gherkin_language'
|
11
11
|
|
12
12
|
no_cache = true
|
13
|
-
|
13
|
+
ngram = false
|
14
|
+
unknown_words = true
|
15
|
+
language = GherkinLanguage.new no_cache, ngram, unknown_words
|
14
16
|
language.analyze 'test.feature'
|
15
17
|
exit language.report
|
16
18
|
|
data/features/tag.feature
CHANGED
@@ -10,7 +10,9 @@ Feature: Tag
|
|
10
10
|
require 'gherkin_language'
|
11
11
|
|
12
12
|
no_cache = true
|
13
|
-
|
13
|
+
ngram = false
|
14
|
+
unknown_words = true
|
15
|
+
language = GherkinLanguage.new no_cache, ngram, unknown_words
|
14
16
|
puts language.tag ['tag.feature']
|
15
17
|
|
16
18
|
"""
|
@@ -35,6 +37,4 @@ Feature: Tag
|
|
35
37
|
execute[execute/VB,execute/VBP,B-VP]
|
36
38
|
then[then/JJ,then/NN,then/RB,I-VP]
|
37
39
|
pass[pass/JJ,pass/NN,pass/VB,pass/VBP,I-VP]"["/'',B-ADVP]][</S>,O]
|
38
|
-
|
39
|
-
|
40
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 = '2016-02-
|
3
|
+
s.version = '0.1.4'
|
4
|
+
s.date = '2016-02-28'
|
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
@@ -18,7 +18,7 @@ require 'digest'
|
|
18
18
|
|
19
19
|
# gherkin utilities
|
20
20
|
class GherkinLanguage
|
21
|
-
def initialize(no_cache = false, ngram = false)
|
21
|
+
def initialize(no_cache = false, ngram = false, unknown_words = false)
|
22
22
|
path = "~/.gherkin_language/#{LanguageToolProcess::VERSION}/accepted_paragraphs.yml"
|
23
23
|
@settings_path = File.expand_path path
|
24
24
|
@accepted_paragraphs = {}
|
@@ -29,8 +29,9 @@ class GherkinLanguage
|
|
29
29
|
end
|
30
30
|
@references = {}
|
31
31
|
@line_to_reference = {}
|
32
|
-
@exceptions =
|
32
|
+
@exceptions = %w(SENTENCE_FRAGMENT) # sentences starting with 'When' are perfectly fine in gherkin
|
33
33
|
@ngram = ngram
|
34
|
+
@unknown_words = unknown_words
|
34
35
|
end
|
35
36
|
|
36
37
|
def ignore(exception)
|
@@ -115,7 +116,7 @@ class GherkinLanguage
|
|
115
116
|
|
116
117
|
def report
|
117
118
|
return 0 if @references.keys.empty?
|
118
|
-
language = LanguageToolProcess.new @
|
119
|
+
language = LanguageToolProcess.new(@ngram, @unknown_words)
|
119
120
|
language.start!
|
120
121
|
|
121
122
|
@references.keys.each do |sentence|
|
@@ -21,7 +21,7 @@ class LanguageToolProcess
|
|
21
21
|
NGRAM_VERSION = 'ngrams-en-20150817'.freeze
|
22
22
|
NGRAM_URL = "https://languagetool.org/download/ngram-data/#{NGRAM_VERSION}.zip".freeze
|
23
23
|
|
24
|
-
def initialize(ngrams = false)
|
24
|
+
def initialize(ngrams = false, unknown_words = false)
|
25
25
|
path = Dir.tmpdir
|
26
26
|
download(path, URL) unless File.exist? "#{path}/#{VERSION}/languagetool-commandline.jar"
|
27
27
|
if ngrams
|
@@ -32,6 +32,7 @@ class LanguageToolProcess
|
|
32
32
|
@p = nil
|
33
33
|
@reference_line = 0
|
34
34
|
@errors = []
|
35
|
+
@check_unknown_words = unknown_words
|
35
36
|
@unknown_words = []
|
36
37
|
@ngrams = ngrams
|
37
38
|
use_user_glossary "#{path}/#{VERSION}" if File.exist? '.glossary'
|
@@ -57,8 +58,10 @@ class LanguageToolProcess
|
|
57
58
|
@unknown_words = []
|
58
59
|
@reference_line = 0
|
59
60
|
Dir.chdir("#{@path}/#{VERSION}/") do
|
60
|
-
command = 'java -jar languagetool-commandline.jar
|
61
|
-
command +=
|
61
|
+
command = 'java -jar languagetool-commandline.jar '
|
62
|
+
command += '--list-unknown ' if @check_unknown_words
|
63
|
+
command += '--api --language en-US '
|
64
|
+
command += "--languagemodel #{@ngrams_path}" if @ngrams
|
62
65
|
@p = IO.popen("#{command} -", 'r+')
|
63
66
|
end
|
64
67
|
end
|
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.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefan Rohe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02-
|
11
|
+
date: 2016-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gherkin
|
@@ -116,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
116
116
|
version: '0'
|
117
117
|
requirements: []
|
118
118
|
rubyforge_project:
|
119
|
-
rubygems_version: 2.2.
|
119
|
+
rubygems_version: 2.2.2
|
120
120
|
signing_key:
|
121
121
|
specification_version: 4
|
122
122
|
summary: Gherkin Language
|