gherkin_readability 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c95a0fbaeb4d85bd01be2e5d236fe64e0377b813
4
- data.tar.gz: b667a4d2006fb2c9ad2d8bbaea60d51f4990741d
3
+ metadata.gz: f74dea223b57a5464602efa142839ab830801706
4
+ data.tar.gz: 6ba4a14b709b0a0ce74c05c4002f8155a198ff67
5
5
  SHA512:
6
- metadata.gz: 883d17fff6f2e77d72607430d8dc5511fd1949b55d4b120e9f8310700ce13537fc266034e8c28a6f5ac39f3aaeaa84f1f27626931c3164dc60b80e62b07ef147
7
- data.tar.gz: bdfe3af27284bb00b0a771cdee0989a127e8e98a5d6ae005d04a76255397a27efe80dde024fbcb56671e25416a8794e6362e970046e68cac9c154a51142b5ff1
6
+ metadata.gz: bbdec8abcb32f2e3538c4596430f8aca8e6cc738b2425a7802a25cb7ea049215f7b7e5786f77c29c8f1e4af5d665b039bbfde5dd363f6b2b19635eaeb3ce464a
7
+ data.tar.gz: 05e43fc346538457d32fd745248ed766632b646d037ebc5ee1e1d6878d12e243eb29c3476d9a92f9bc8847ba6154ac316916d832c909a22d8f603d2356009733
data/.rubocop.yml CHANGED
@@ -13,7 +13,7 @@ Metrics/AbcSize:
13
13
  # Offense count: 1
14
14
  # Configuration parameters: CountComments.
15
15
  Metrics/ClassLength:
16
- Max: 121
16
+ Max: 137
17
17
 
18
18
  # Offense count: 8
19
19
  # Configuration parameters: AllowURI, URISchemes.
data/Rakefile CHANGED
@@ -12,7 +12,7 @@ task test: :cucumber
12
12
 
13
13
  desc 'Publishes the Gem'
14
14
  task push: :build do
15
- sh 'gem push gherkin_readability-0.0.1.gem'
15
+ sh 'gem push gherkin_readability-0.0.2.gem'
16
16
  end
17
17
 
18
18
  desc 'Checks ruby style'
@@ -8,10 +8,20 @@ OptionParser.new do |opts|
8
8
  opts.on('--[no-]summary', 'Print summary') do |summary|
9
9
  options[:summary] = summary
10
10
  end
11
+ opts.on('--below [THRESHOLD]', 'Selects just files below the threshold') do |threshold|
12
+ options[:below] = threshold.to_i
13
+ end
14
+ opts.on('--above [THRESHOLD]', 'Selects just files above the threshold') do |threshold|
15
+ options[:above] = threshold.to_i
16
+ end
11
17
  end.parse!
12
18
 
13
19
  readability = GherkinReadability.new
14
20
 
15
21
  readability.analyze ARGV
16
22
 
17
- readability.report if options.key? :summary
23
+ readability.select_below! options[:below] if options.key? :below
24
+ readability.select_above! options[:above] if options.key? :above
25
+
26
+ readability.report
27
+ readability.summary if options.key? :summary
@@ -12,6 +12,7 @@ Feature: Rate
12
12
  readability = GherkinReadability.new
13
13
 
14
14
  readability.analyze %w(default.feature test.feature)
15
+ readability.report
15
16
 
16
17
  """
17
18
  And a file named "default.feature" with:
@@ -12,7 +12,7 @@ Feature: Summary
12
12
  readability = GherkinReadability.new
13
13
 
14
14
  readability.analyze %w(default.feature test.feature)
15
- readability.report
15
+ readability.summary
16
16
 
17
17
  """
18
18
  And a file named "default.feature" with:
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'gherkin_readability'
3
- s.version = '0.0.1'
4
- s.date = '2015-10-31'
3
+ s.version = '0.0.2'
4
+ s.date = '2015-11-10'
5
5
  s.summary = 'Gherkin Readability'
6
6
  s.description = 'Check readability of Gherkin Files'
7
7
  s.authors = ['Stefan Rohe']
@@ -23,12 +23,31 @@ class GherkinReadability
23
23
  sentences = extract_sentences parse(file)
24
24
  @readability_by_file[file] = readability sentences
25
25
  end
26
+ end
27
+
28
+ def select_below!(threshold)
29
+ filtered = {}
30
+ @readability_by_file.each do |file, rating|
31
+ filtered[file] = rating if rating <= threshold
32
+ end
33
+ @readability_by_file = filtered
34
+ end
35
+
36
+ def select_above!(threshold)
37
+ filtered = {}
38
+ @readability_by_file.each do |file, rating|
39
+ filtered[file] = rating if rating >= threshold
40
+ end
41
+ @readability_by_file = filtered
42
+ end
43
+
44
+ def report
26
45
  @readability_by_file.sort { |lhs, rhs| lhs[1] <=> rhs[1] }.reverse_each do |file, rating|
27
46
  puts "#{rating.round}: #{file}"
28
47
  end
29
48
  end
30
49
 
31
- def report
50
+ def summary
32
51
  average_readability = 0
33
52
  @readability_by_file.each do |_, rating|
34
53
  average_readability += rating
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gherkin_readability
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
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-31 00:00:00.000000000 Z
11
+ date: 2015-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gherkin
@@ -106,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
106
  version: '0'
107
107
  requirements: []
108
108
  rubyforge_project:
109
- rubygems_version: 2.2.3
109
+ rubygems_version: 2.2.5
110
110
  signing_key:
111
111
  specification_version: 4
112
112
  summary: Gherkin Readability