yardstick 0.9.7 → 0.9.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. data/.travis.yml +10 -3
  2. data/Gemfile +1 -1
  3. data/Gemfile.devtools +32 -18
  4. data/README.md +1 -1
  5. data/config/devtools.yml +3 -1
  6. data/config/reek.yml +6 -2
  7. data/config/rubocop.yml +10 -1
  8. data/lib/yardstick.rb +1 -2
  9. data/lib/yardstick/cli.rb +1 -4
  10. data/lib/yardstick/config.rb +5 -4
  11. data/lib/yardstick/document.rb +1 -2
  12. data/lib/yardstick/document_set.rb +2 -4
  13. data/lib/yardstick/measurement.rb +0 -2
  14. data/lib/yardstick/measurement_set.rb +0 -3
  15. data/lib/yardstick/ordered_set.rb +0 -2
  16. data/lib/yardstick/parser.rb +3 -5
  17. data/lib/yardstick/processor.rb +0 -3
  18. data/lib/yardstick/rake/measurement.rb +0 -3
  19. data/lib/yardstick/rake/verify.rb +3 -6
  20. data/lib/yardstick/report_output.rb +0 -3
  21. data/lib/yardstick/rule.rb +2 -0
  22. data/lib/yardstick/version.rb +1 -3
  23. data/lib/yardstick/yard_ext.rb +0 -2
  24. data/spec/integration/yardstick/class_methods/measure_spec.rb +1 -1
  25. data/spec/integration/yardstick/processor/process_string_spec.rb +4 -4
  26. data/spec/unit/yardstick/config/class_methods/coerce_spec.rb +1 -1
  27. data/spec/unit/yardstick/config/for_rule_spec.rb +2 -3
  28. data/spec/unit/yardstick/config/require_exact_threshold_predicate_spec.rb +2 -2
  29. data/spec/unit/yardstick/config/set_defaults_spec.rb +4 -4
  30. data/spec/unit/yardstick/config/verbose_predicate_spec.rb +2 -2
  31. data/spec/unit/yardstick/document/api_predicate_spec.rb +1 -1
  32. data/spec/unit/yardstick/document/file_spec.rb +2 -2
  33. data/spec/unit/yardstick/document/line_spec.rb +2 -2
  34. data/spec/unit/yardstick/document/path_spec.rb +2 -2
  35. data/spec/unit/yardstick/document/tag_text_spec.rb +1 -1
  36. data/spec/unit/yardstick/document/tag_types_spec.rb +1 -1
  37. data/spec/unit/yardstick/document/visibility_spec.rb +2 -2
  38. data/spec/unit/yardstick/parser/class_methods/parse_paths_spec.rb +1 -1
  39. data/spec/unit/yardstick/parser/class_methods/parse_string_spec.rb +16 -3
  40. data/spec/unit/yardstick/processor/process_spec.rb +1 -1
  41. data/spec/unit/yardstick/rake/measurement/yardstick_measure_spec.rb +1 -1
  42. data/spec/unit/yardstick/rake/verify/initialize_spec.rb +1 -1
  43. data/spec/unit/yardstick/rake/verify/verify_measurements_spec.rb +6 -6
  44. data/spec/unit/yardstick/report_output/write_spec.rb +1 -1
  45. data/spec/unit/yardstick/rule/class_methods/coerce_spec.rb +1 -1
  46. data/spec/unit/yardstick/rule/enabled_predicate_spec.rb +1 -1
  47. data/spec/unit/yardstick/rule/initialize_spec.rb +1 -1
  48. data/spec/unit/yardstick/rules/api_tag/private_method/validatable_predicate_spec.rb +1 -1
  49. data/spec/unit/yardstick/rules/api_tag/protected_method/validatable_predicate_spec.rb +1 -1
  50. data/spec/unit/yardstick/rules/summary/delimiter/valid_predicate_spec.rb +1 -1
  51. data/spec/unit/yardstick/rules/summary/length/valid_predicate_spec.rb +1 -1
  52. data/spec/unit/yardstick/rules/summary/presence/valid_predicate_spec.rb +1 -1
  53. data/spec/unit/yardstick/rules/summary/single_line/valid_predicate_spec.rb +1 -1
  54. data/yardstick.gemspec +1 -1
  55. metadata +19 -13
  56. checksums.yaml +0 -7
@@ -1,12 +1,17 @@
1
1
  language: ruby
2
- before_install: gem install bundler
2
+ before_install:
3
+ - gem update bundler
4
+ - bundle --version
5
+ - gem update --system 2.1.11
6
+ - gem --version
3
7
  bundler_args: --without yard guard benchmarks
4
8
  script: "bundle exec rake ci"
5
9
  rvm:
10
+ - 1.8.7
6
11
  - 1.9.3
7
12
  - 2.0.0
8
- - ruby-head
9
13
  - rbx-19mode
14
+ - ruby-head
10
15
  matrix:
11
16
  include:
12
17
  - rvm: jruby-19mode
@@ -14,10 +19,12 @@ matrix:
14
19
  - rvm: jruby-head
15
20
  env: JRUBY_OPTS="$JRUBY_OPTS --debug"
16
21
  allow_failures:
22
+ - rvm: 1.8.7 # mutant fails
17
23
  - rvm: 1.9.3 # mutant fails
18
24
  - rvm: 2.0.0 # mutant fails
19
- - rvm: ruby-head # travis broken
20
25
  - rvm: rbx-19mode # mutant fails
26
+ - rvm: ruby-head # travis broken
27
+ fast_finish: true
21
28
  notifications:
22
29
  irc:
23
30
  channels:
data/Gemfile CHANGED
@@ -5,7 +5,7 @@ source 'https://rubygems.org'
5
5
  gemspec
6
6
 
7
7
  group :development, :test do
8
- gem 'devtools', git: 'https://github.com/rom-rb/devtools.git'
8
+ gem 'devtools', :git => 'https://github.com/rom-rb/devtools.git'
9
9
  end
10
10
 
11
11
  eval_gemfile 'Gemfile.devtools'
@@ -4,43 +4,57 @@ group :development do
4
4
  gem 'rake', '~> 10.1.0'
5
5
  gem 'rspec', '~> 2.14.1'
6
6
  gem 'yard', '~> 0.8.7'
7
+
8
+ platform :rbx do
9
+ gem 'rubysl-singleton', '~> 2.0.0'
10
+ end
7
11
  end
8
12
 
9
13
  group :yard do
10
- gem 'kramdown', '~> 1.2.0'
14
+ gem 'kramdown', '~> 1.3.0'
11
15
  end
12
16
 
13
17
  group :guard do
14
- gem 'guard', '~> 1.8.1'
15
- gem 'guard-bundler', '~> 1.0.0'
16
- gem 'guard-rspec', '~> 3.0.2'
17
- gem 'guard-rubocop', '~> 0.2.0'
18
- gem 'guard-mutant', '~> 0.0.1'
18
+ gem 'guard', '~> 2.2.4'
19
+ gem 'guard-bundler', '~> 2.0.0'
20
+ gem 'guard-rspec', '~> 4.2.0'
21
+ gem 'guard-rubocop', '~> 1.0.0'
19
22
 
20
23
  # file system change event handling
21
- gem 'listen', '~> 1.3.0'
22
- gem 'rb-fchange', '~> 0.0.6', require: false
23
- gem 'rb-fsevent', '~> 0.9.3', require: false
24
- gem 'rb-inotify', '~> 0.9.0', require: false
24
+ gem 'listen', '~> 2.4.0'
25
+ gem 'rb-fchange', '~> 0.0.6', :require => false
26
+ gem 'rb-fsevent', '~> 0.9.3', :require => false
27
+ gem 'rb-inotify', '~> 0.9.0', :require => false
25
28
 
26
29
  # notification handling
27
- gem 'libnotify', '~> 0.8.0', require: false
28
- gem 'rb-notifu', '~> 0.0.4', require: false
29
- gem 'terminal-notifier-guard', '~> 1.5.3', require: false
30
+ gem 'libnotify', '~> 0.8.0', :require => false
31
+ gem 'rb-notifu', '~> 0.0.4', :require => false
32
+ gem 'terminal-notifier-guard', '~> 1.5.3', :require => false
30
33
  end
31
34
 
32
35
  group :metrics do
33
- gem 'coveralls', '~> 0.6.7'
36
+ gem 'coveralls', '~> 0.7.0'
34
37
  gem 'flay', '~> 2.4.0'
35
- gem 'flog', '~> 4.1.1'
38
+ gem 'flog', '~> 4.2.0'
36
39
  gem 'reek', '~> 1.3.2'
37
- gem 'rubocop', '~> 0.12.0'
38
- gem 'simplecov', '~> 0.7.1'
40
+ gem 'rubocop', '~> 0.16.0'
41
+ gem 'simplecov', '~> 0.8.2'
42
+
43
+ platforms :mri do
44
+ gem 'mutant', '~> 0.3.4'
45
+ end
39
46
 
40
47
  platforms :ruby_19, :ruby_20 do
41
- gem 'mutant', git: 'https://github.com/mbj/mutant.git'
42
48
  gem 'yard-spellcheck', '~> 0.1.5'
43
49
  end
50
+
51
+ platform :rbx do
52
+ gem 'json', '~> 1.8.1'
53
+ gem 'racc', '~> 1.4.10'
54
+ gem 'rubysl-logger', '~> 2.0.0'
55
+ gem 'rubysl-open-uri', '~> 2.0.0'
56
+ gem 'rubysl-prettyprint', '~> 2.0.2'
57
+ end
44
58
  end
45
59
 
46
60
  group :benchmarks do
data/README.md CHANGED
@@ -87,7 +87,7 @@ RUBY
87
87
 
88
88
  ### 4. Configuration
89
89
 
90
- Every rule in Yardstick can be turned off globally and locally. All rules are enabled and threshold is set to maximum by default.
90
+ Every rule in Yardstick can be turned off globally and locally. All rules are enabled and threshold is set to maximum by default (100%). If your documentation coverage is below or above this threshold then yardstick will exit with a nonzero status and print that fact.
91
91
 
92
92
  Default configuration:
93
93
  ```yaml
@@ -1,2 +1,4 @@
1
1
  ---
2
- unit_test_timeout: 0.3
2
+ unit_test_timeout: 0.1
3
+ fail_on_branch:
4
+ - "master"
@@ -13,7 +13,9 @@ ClassVariable:
13
13
  exclude: []
14
14
  ControlParameter:
15
15
  enabled: true
16
- exclude: []
16
+ exclude:
17
+ # False positive
18
+ - Yardstick::OrderedSet#initialize
17
19
  DataClump:
18
20
  enabled: true
19
21
  exclude: []
@@ -68,8 +70,10 @@ TooManyStatements:
68
70
  exclude:
69
71
  - Yardstick::CLI#self.option_parser
70
72
  - Yardstick::CLI#self.parse_config
71
- - Yardstick::Config#set_defaults
72
73
  - Yardstick::Config#self.normalize_hash
74
+ - Yardstick::Config#defaults=
75
+ - Yardstick::Config#set_defaults
76
+ - Yardstick::Rake::Verify#initialize
73
77
  max_statements: 3
74
78
  UncommunicativeMethodName:
75
79
  enabled: true
@@ -5,6 +5,7 @@ AllCops:
5
5
  - 'Gemfile.devtools'
6
6
  Excludes:
7
7
  - '**/vendor/**'
8
+ - '**/benchmarks/**'
8
9
 
9
10
  # Avoid parameter lists longer than five parameters.
10
11
  ParameterLists:
@@ -29,7 +30,7 @@ CollectionMethods:
29
30
  # sections of code and visually separate them. When the keyword is at the same
30
31
  # level I think it sort of blends in with the def keywords and makes it harder
31
32
  # to scan the code and see where the sections are.
32
- AccessControl:
33
+ AccessModifierIndentation:
33
34
  Enabled: false
34
35
 
35
36
  # Limit line length
@@ -47,3 +48,11 @@ IfUnlessModifier:
47
48
  # Do not use sprintf instead of String#%.
48
49
  FavorSprintf:
49
50
  Enabled: false
51
+
52
+ # Not all trivial readers/writers can be defined with attr_* methods
53
+ TrivialAccessors:
54
+ Enabled: false
55
+
56
+ # Enforce Ruby 1.8-compatible hash syntax
57
+ HashSyntax:
58
+ EnforcedStyle: hash_rockets
@@ -1,9 +1,9 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require 'set'
3
4
  require 'pathname'
4
5
  require 'delegate'
5
6
 
6
- require 'backports'
7
7
  require 'yard'
8
8
 
9
9
  require 'yardstick/ordered_set'
@@ -81,5 +81,4 @@ module Yardstick
81
81
  def self.round_percentage(percentage)
82
82
  (percentage * 10).floor / 10.0
83
83
  end
84
-
85
84
  end # module Yardstick
@@ -3,10 +3,8 @@
3
3
  require 'optparse'
4
4
 
5
5
  module Yardstick
6
-
7
6
  # Handle the yardstick command line interface
8
7
  class CLI
9
-
10
8
  # Parse the command line options, and run the command
11
9
  #
12
10
  # @example
@@ -38,7 +36,7 @@ module Yardstick
38
36
  args << '--help' if args.empty?
39
37
  options = {}
40
38
  option_parser(options).parse!(args)
41
- Config.new(options.merge(path: args))
39
+ Config.new(options.merge(:path => args))
42
40
  rescue OptionParser::InvalidOption => error
43
41
  display_exit(error.message)
44
42
  end
@@ -75,6 +73,5 @@ module Yardstick
75
73
  class << self
76
74
  private :option_parser, :parse_config, :display_exit
77
75
  end
78
-
79
76
  end # module CLI
80
77
  end # module Yardstick
@@ -80,9 +80,10 @@ module Yardstick
80
80
  #
81
81
  # @api private
82
82
  def self.normalize_hash(hash)
83
- hash.each_with_object({}) do |(key, value), normalized_hash|
83
+ hash.reduce({}) do |normalized_hash, (key, value)|
84
84
  normalized_value = value.is_a?(Hash) ? normalize_hash(value) : value
85
85
  normalized_hash[key.to_sym] = normalized_value
86
+ normalized_hash
86
87
  end
87
88
  end
88
89
 
@@ -98,7 +99,7 @@ module Yardstick
98
99
  #
99
100
  # @api private
100
101
  def initialize(options = {}, &block)
101
- set_defaults(options)
102
+ self.defaults = options
102
103
 
103
104
  yield(self) if block_given?
104
105
  end
@@ -116,7 +117,7 @@ module Yardstick
116
117
  if key
117
118
  RuleConfig.new(@rules.fetch(key.to_sym, {}))
118
119
  else
119
- raise InvalidRule, "every rule must begin with #{NAMESPACE_PREFIX}"
120
+ fail InvalidRule, "every rule must begin with #{NAMESPACE_PREFIX}"
120
121
  end
121
122
  end
122
123
 
@@ -160,7 +161,7 @@ module Yardstick
160
161
  # @return [undefined]
161
162
  #
162
163
  # @api private
163
- def set_defaults(options)
164
+ def defaults=(options)
164
165
  @threshold = options.fetch(:threshold, 100)
165
166
  @verbose = options.fetch(:verbose, true)
166
167
  @path = options.fetch(:path, 'lib/**/*.rb')
@@ -1,7 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Yardstick
4
-
5
4
  # Wraps a yard docstring to make a nicer interface
6
5
  class Document
7
6
  @registered_rules = Set.new
@@ -82,7 +81,7 @@ module Yardstick
82
81
  # true if tag exists
83
82
  #
84
83
  # @api private
85
- def has_tag?(name)
84
+ def has_tag?(name) # rubocop:disable PredicateName
86
85
  @docstring.has_tag?(name)
87
86
  end
88
87
 
@@ -1,10 +1,8 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Yardstick
4
-
5
4
  # A set of yardstick documents
6
5
  class DocumentSet < OrderedSet
7
-
8
6
  # Measure documents using given config
9
7
  #
10
8
  # @return [Yardstick::MeasurementSet]
@@ -12,10 +10,10 @@ module Yardstick
12
10
  #
13
11
  # @api private
14
12
  def measure(config)
15
- each_with_object(MeasurementSet.new) do |document, set|
13
+ reduce(MeasurementSet.new) do |set, document|
16
14
  set.merge(Document.measure(document, config))
15
+ set
17
16
  end
18
17
  end
19
-
20
18
  end
21
19
  end
@@ -1,7 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Yardstick
4
-
5
4
  # A measurement given a constraint on the docs
6
5
  class Measurement
7
6
  # Return a Measurement instance
@@ -97,6 +96,5 @@ module Yardstick
97
96
  return :skip if !@rule.enabled? || !@rule.validatable?
98
97
  @rule.valid?
99
98
  end
100
-
101
99
  end # class Measurement
102
100
  end # module Yardstick
@@ -1,10 +1,8 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Yardstick
4
-
5
4
  # A set of yardstick measurements
6
5
  class MeasurementSet < OrderedSet
7
-
8
6
  # The total number of measurements
9
7
  #
10
8
  # @example
@@ -127,6 +125,5 @@ module Yardstick
127
125
  def total_text
128
126
  'Total: %d' % total
129
127
  end
130
-
131
128
  end # class MeasurementSet
132
129
  end # module Yardstick
@@ -1,7 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Yardstick
4
-
5
4
  # A base class for an ordered set
6
5
  class OrderedSet
7
6
  include Enumerable
@@ -114,6 +113,5 @@ module Yardstick
114
113
  def index(entry)
115
114
  @index[entry]
116
115
  end
117
-
118
116
  end # class OrderedSet
119
117
  end # module Yardstick
@@ -1,10 +1,8 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Yardstick
4
-
5
4
  # Parses files and strings using YARD
6
5
  class Parser
7
-
8
6
  # Measure files specified in the paths
9
7
  #
10
8
  # @return [Array<Document>]
@@ -36,8 +34,9 @@ module Yardstick
36
34
  #
37
35
  # @api private
38
36
  def self.documents
39
- method_objects.each_with_object(DocumentSet.new) do |method_object, set|
37
+ method_objects.reduce(DocumentSet.new) do |set, method_object|
40
38
  set << Document.new(method_object.docstring)
39
+ set
41
40
  end
42
41
  end
43
42
  private_class_method :documents
@@ -50,12 +49,11 @@ module Yardstick
50
49
  # @api private
51
50
  def self.method_objects
52
51
  YARD::Registry.all(:method).sort_by do |method_object|
53
- [method_object.file, method_object.line]
52
+ [method_object.file || '', method_object.line || 0]
54
53
  end
55
54
  ensure
56
55
  YARD::Registry.clear
57
56
  end
58
57
  private_class_method :method_objects
59
-
60
58
  end
61
59
  end
@@ -1,10 +1,8 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Yardstick
4
-
5
4
  # Handle procesing a docstring or path of files
6
5
  class Processor
7
-
8
6
  # Initializes new Processor instance
9
7
  #
10
8
  # @param [Yardstick::Config] config
@@ -50,6 +48,5 @@ module Yardstick
50
48
  def paths
51
49
  Array(@config.path).map(&:to_s)
52
50
  end
53
-
54
51
  end # class Processor
55
52
  end # module Yardstick
@@ -8,10 +8,8 @@ require 'yardstick'
8
8
 
9
9
  module Yardstick
10
10
  module Rake
11
-
12
11
  # A rake task for measuring docs in a set of files
13
12
  class Measurement < ::Rake::TaskLib
14
-
15
13
  # Initializes a Measurement task
16
14
  #
17
15
  # @example
@@ -57,7 +55,6 @@ module Yardstick
57
55
  desc "Measure docs in #{@config.path} with yardstick"
58
56
  task(@name) { yardstick_measure }
59
57
  end
60
-
61
58
  end # class Measurement
62
59
  end # module Rake
63
60
  end # module Yardstick
@@ -7,10 +7,8 @@ require 'yardstick'
7
7
 
8
8
  module Yardstick
9
9
  module Rake
10
-
11
10
  # A rake task for verifying the doc thresholds
12
11
  class Verify < ::Rake::TaskLib
13
-
14
12
  # Initialize a Verify task
15
13
  #
16
14
  # @example
@@ -93,7 +91,7 @@ module Yardstick
93
91
  # @api private
94
92
  def assert_threshold
95
93
  unless @threshold
96
- raise 'threshold must be set'
94
+ fail 'threshold must be set'
97
95
  end
98
96
  end
99
97
 
@@ -107,7 +105,7 @@ module Yardstick
107
105
  # @api private
108
106
  def assert_meets_threshold
109
107
  if lower_coverage?
110
- raise "YARD-Coverage must be at least #{@threshold}% but was #{total_coverage}%"
108
+ fail "YARD-Coverage must be at least #{@threshold}% but was #{total_coverage}%"
111
109
  end
112
110
  end
113
111
 
@@ -121,7 +119,7 @@ module Yardstick
121
119
  # @api private
122
120
  def assert_matches_threshold
123
121
  if @config.require_exact_threshold? && higher_coverage?
124
- raise "YARD-Coverage has increased above the threshold of #{@threshold}% to #{total_coverage}%. You should update your threshold value."
122
+ fail "YARD-Coverage has increased above the threshold of #{@threshold}% to #{total_coverage}%. You should update your threshold value."
125
123
  end
126
124
  end
127
125
 
@@ -144,7 +142,6 @@ module Yardstick
144
142
  def higher_coverage?
145
143
  total_coverage > @threshold
146
144
  end
147
-
148
145
  end # class Verify
149
146
  end # module Rake
150
147
  end # module Yardstick
@@ -1,10 +1,8 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Yardstick
4
-
5
4
  # Handles writing reports
6
5
  class ReportOutput
7
-
8
6
  # Coerces string path into proper output object
9
7
  #
10
8
  # @param [String, Pathname] target
@@ -52,6 +50,5 @@ module Yardstick
52
50
  def to_s
53
51
  @target.to_s
54
52
  end
55
-
56
53
  end
57
54
  end
@@ -1,5 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require 'forwardable'
4
+
3
5
  module Yardstick
4
6
  # Base class of every rule
5
7
  #
@@ -1,8 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Yardstick
4
-
5
4
  # Gem version
6
- VERSION = '0.9.7'.freeze
7
-
5
+ VERSION = '0.9.8'.freeze
8
6
  end # module Yardstick
@@ -1,11 +1,9 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module YARD #:nodoc: all
4
-
5
4
  # Test if JRuby head is being used
6
5
  JRUBY_19MODE = RUBY_VERSION >= '1.9' && RUBY_ENGINE == 'jruby'
7
6
 
8
7
  # Fix jruby-head to use the ruby 1.8 parser until their ripper port is working
9
8
  Parser::SourceParser.parser_type = :ruby18 if JRUBY_19MODE
10
-
11
9
  end # module YARD
@@ -13,7 +13,7 @@ describe Yardstick, '.measure' do
13
13
 
14
14
  describe 'with a config' do
15
15
  before :all do
16
- config = Yardstick::Config.new(path: Yardstick::ROOT.join('lib', 'yardstick.rb'))
16
+ config = Yardstick::Config.new(:path => Yardstick::ROOT.join('lib', 'yardstick.rb'))
17
17
  @measurements = Yardstick.measure(config)
18
18
  end
19
19
 
@@ -55,8 +55,8 @@ describe Yardstick::Document, '#process_string' do
55
55
 
56
56
  describe 'without a method summary when validations are turned off' do
57
57
  let(:config) do
58
- Yardstick::Config.new(rules: {
59
- 'Summary::Presence'.to_sym => { enabled: false }
58
+ Yardstick::Config.new(:rules => {
59
+ 'Summary::Presence'.to_sym => { :enabled => false }
60
60
  })
61
61
  end
62
62
  let(:method) { 'def test(value); end' }
@@ -70,8 +70,8 @@ describe Yardstick::Document, '#process_string' do
70
70
 
71
71
  describe 'without a method summary when validations are turned off for given class' do
72
72
  let(:config) do
73
- Yardstick::Config.new(rules: {
74
- 'Summary::Presence'.to_sym => { enabled: true, exclude: %w[World] }
73
+ Yardstick::Config.new(:rules => {
74
+ 'Summary::Presence'.to_sym => { :enabled => true, :exclude => %w[World] }
75
75
  })
76
76
  end
77
77
  let(:method) { 'class World; def test(value); end; end' }
@@ -12,7 +12,7 @@ describe Yardstick::Config, '.coerce' do
12
12
 
13
13
  it 'coerces hash' do
14
14
  rules = subject.instance_variable_get(:@rules)
15
- expect(rules).to eql(foo: 'bar')
15
+ expect(rules).to eql(:foo => 'bar')
16
16
  end
17
17
  end
18
18
 
@@ -1,13 +1,12 @@
1
1
  # encoding: utf-8
2
2
 
3
-
4
3
  require 'spec_helper'
5
4
 
6
5
  describe Yardstick::Config, '#for_rule' do
7
6
  subject { described_class.new(options).for_rule(rule_class) }
8
7
 
9
8
  let(:options) do
10
- { rules: { 'Summary::Presence'.to_sym => { enabled: false } } }
9
+ { :rules => { 'Summary::Presence'.to_sym => { :enabled => false } } }
11
10
  end
12
11
 
13
12
  let(:rule_config) { double('RuleConfig') }
@@ -16,7 +15,7 @@ describe Yardstick::Config, '#for_rule' do
16
15
  let(:rule_class) { Yardstick::Rules::Summary::Presence }
17
16
 
18
17
  before do
19
- allow(Yardstick::RuleConfig).to receive(:new).with(enabled: false)
18
+ allow(Yardstick::RuleConfig).to receive(:new).with(:enabled => false)
20
19
  .and_return(rule_config)
21
20
  end
22
21
 
@@ -6,13 +6,13 @@ describe Yardstick::Config, '#require_exact_threshold?' do
6
6
  subject { described_class.new(config).require_exact_threshold? }
7
7
 
8
8
  context 'when set to true' do
9
- let(:config) { { require_exact_threshold: true } }
9
+ let(:config) { { :require_exact_threshold => true } }
10
10
 
11
11
  it { should be(true) }
12
12
  end
13
13
 
14
14
  context 'when set to false' do
15
- let(:config) { { require_exact_threshold: false } }
15
+ let(:config) { { :require_exact_threshold => false } }
16
16
 
17
17
  it { should be(false) }
18
18
  end
@@ -24,10 +24,10 @@ describe Yardstick::Config, '#set_defaults' do
24
24
  context 'when with options' do
25
25
  let(:options) do
26
26
  {
27
- threshold: 15,
28
- verbose: false,
29
- path: 'tmp/*.rb',
30
- require_exact_threshold: false
27
+ :threshold => 15,
28
+ :verbose => false,
29
+ :path => 'tmp/*.rb',
30
+ :require_exact_threshold => false
31
31
  }
32
32
  end
33
33
 
@@ -6,13 +6,13 @@ describe Yardstick::Config, '#verbose?' do
6
6
  subject { described_class.new(config).verbose? }
7
7
 
8
8
  context 'when set to true' do
9
- let(:config) { { verbose: true } }
9
+ let(:config) { { :verbose => true } }
10
10
 
11
11
  it { should be(true) }
12
12
  end
13
13
 
14
14
  context 'when set to false' do
15
- let(:config) { { verbose: false } }
15
+ let(:config) { { :verbose => false } }
16
16
 
17
17
  it { should be(false) }
18
18
  end
@@ -8,7 +8,7 @@ describe Yardstick::Document, '#api?' do
8
8
  let(:docstring) { double('docstring') }
9
9
 
10
10
  before do
11
- docstring.stub(:tag).with('api') { double(text: 'private') }
11
+ docstring.stub(:tag).with('api') { double(:text => 'private') }
12
12
  end
13
13
 
14
14
  context 'when tag is equal' do
@@ -5,8 +5,8 @@ require 'spec_helper'
5
5
  describe Yardstick::Document, '#file' do
6
6
  subject { described_class.new(docstring).file }
7
7
 
8
- let(:docstring) { double('docstring', object: object) }
9
- let(:object) { double('object', file: '/foo/bar.rb') }
8
+ let(:docstring) { double('docstring', :object => object) }
9
+ let(:object) { double('object', :file => '/foo/bar.rb') }
10
10
 
11
11
  it { should be_kind_of(Pathname) }
12
12
 
@@ -5,8 +5,8 @@ require 'spec_helper'
5
5
  describe Yardstick::Document, '#line' do
6
6
  subject { described_class.new(docstring).line }
7
7
 
8
- let(:docstring) { double('docstring', object: object) }
9
- let(:object) { double('object', line: 3) }
8
+ let(:docstring) { double('docstring', :object => object) }
9
+ let(:object) { double('object', :line => 3) }
10
10
 
11
11
  it { should be(3) }
12
12
  end
@@ -5,8 +5,8 @@ require 'spec_helper'
5
5
  describe Yardstick::Document, '#path' do
6
6
  subject { described_class.new(docstring).path }
7
7
 
8
- let(:docstring) { double('docstring', object: object) }
9
- let(:object) { double('object', path: 'Foo#bar') }
8
+ let(:docstring) { double('docstring', :object => object) }
9
+ let(:object) { double('object', :path => 'Foo#bar') }
10
10
 
11
11
  it { should eq('Foo#bar') }
12
12
  end
@@ -7,7 +7,7 @@ describe Yardstick::Document, '#tag_text' do
7
7
 
8
8
  let(:name) { 'api' }
9
9
  let(:docstring) { double('docstring') }
10
- let(:yard_tag) { double(text: 'private') }
10
+ let(:yard_tag) { double(:text => 'private') }
11
11
 
12
12
  before do
13
13
  docstring.stub(:tag).with(name) { yard_tag }
@@ -7,7 +7,7 @@ describe Yardstick::Document, '#tag_types' do
7
7
 
8
8
  let(:name) { 'tag name' }
9
9
  let(:docstring) { double('docstring') }
10
- let(:yard_tag) { double(types: types) }
10
+ let(:yard_tag) { double(:types => types) }
11
11
  let(:types) { %w[type1 type2] }
12
12
 
13
13
  before do
@@ -5,8 +5,8 @@ require 'spec_helper'
5
5
  describe Yardstick::Document, '#visibility' do
6
6
  subject { described_class.new(docstring).visibility }
7
7
 
8
- let(:docstring) { double('docstring', object: object) }
9
- let(:object) { double('object', visibility: visibility) }
8
+ let(:docstring) { double('docstring', :object => object) }
9
+ let(:object) { double('object', :visibility => visibility) }
10
10
 
11
11
  context 'when true' do
12
12
  let(:visibility) { true }
@@ -6,7 +6,7 @@ describe Yardstick::Parser, '.parse_paths' do
6
6
  subject(:document_set) { described_class.parse_paths(paths) }
7
7
 
8
8
  let(:paths) { double('paths') }
9
- let(:method_object) { double(file: 'foo.rb', line: 4, docstring: docstring) }
9
+ let(:method_object) { double(:file => 'foo.rb', :line => 4, :docstring => docstring) }
10
10
  let(:docstring) { double('docstring') }
11
11
 
12
12
  before do
@@ -5,13 +5,15 @@ require 'spec_helper'
5
5
  describe Yardstick::Parser, '.parse_string' do
6
6
  subject(:document_set) { described_class.parse_string(string) }
7
7
 
8
- let(:string) { double('string', to_str: 'body') }
9
- let(:method_object) { double(file: 'foo.rb', line: 4, docstring: docstring) }
8
+ let(:string) { double('string', :to_str => 'body') }
9
+ let(:method_object) { double(:file => 'foo.rb', :line => 4, :docstring => docstring) }
10
10
  let(:docstring) { double('docstring') }
11
11
 
12
+ let(:method_objects) { [method_object] }
13
+
12
14
  before do
13
15
  YARD.should_receive(:parse_string).with('body')
14
- YARD::Registry.stub(:all).with(:method).and_return([method_object])
16
+ YARD::Registry.stub(:all).with(:method).and_return(method_objects)
15
17
  end
16
18
 
17
19
  it { should be_a(Yardstick::DocumentSet) }
@@ -25,4 +27,15 @@ describe Yardstick::Parser, '.parse_string' do
25
27
 
26
28
  its(:docstring) { should eq(docstring) }
27
29
  end
30
+
31
+ context 'when method one object does not have file information' do
32
+ let(:method_objects) do
33
+ [
34
+ method_object,
35
+ double(:file => nil, :line => nil, :docstring => docstring)
36
+ ]
37
+ end
38
+
39
+ it { should be_a(Yardstick::DocumentSet) }
40
+ end
28
41
  end
@@ -5,7 +5,7 @@ require 'spec_helper'
5
5
  describe Yardstick::Processor, '#process' do
6
6
  subject { described_class.new(config).process }
7
7
 
8
- let(:config) { double('config', path: path) }
8
+ let(:config) { double('config', :path => path) }
9
9
  let(:path) { Pathname('foo/bar.rb') }
10
10
  let(:documents) { double('document set') }
11
11
 
@@ -6,7 +6,7 @@ require 'yardstick/rake/measurement'
6
6
  describe Yardstick::Rake::Measurement, '#yardstick_measure' do
7
7
  subject { described_class.new(:yardstick_measure, options).yardstick_measure }
8
8
 
9
- let(:config) { double('config', path: 'tmp', output: report_writer) }
9
+ let(:config) { double('config', :path => 'tmp', :output => report_writer) }
10
10
  let(:report_writer) { double('report writer') }
11
11
  let(:options) { double('options') }
12
12
  let(:measurements) { double('measurements') }
@@ -7,7 +7,7 @@ describe Yardstick::Rake::Verify, '#initialize' do
7
7
  context 'with custom arguments' do
8
8
  subject(:task) { described_class.new(:verify, options) }
9
9
 
10
- let(:config) { Yardstick::Config.new(threshold: 90) }
10
+ let(:config) { Yardstick::Config.new(:threshold => 90) }
11
11
  let(:options) { double('options') }
12
12
 
13
13
  before do
@@ -8,7 +8,7 @@ describe Yardstick::Rake::Verify, '#verify_measurements' do
8
8
  capture_stdout { described_class.new(:verify, options).verify_measurements }
9
9
  end
10
10
 
11
- let(:config) { Yardstick::Config.new(threshold: 90) }
11
+ let(:config) { Yardstick::Config.new(:threshold => 90) }
12
12
  let(:options) { double('options') }
13
13
 
14
14
  before do
@@ -17,7 +17,7 @@ describe Yardstick::Rake::Verify, '#verify_measurements' do
17
17
  end
18
18
 
19
19
  context 'when verbose' do
20
- let(:measurements) { double('measurements', coverage: 0.9) }
20
+ let(:measurements) { double('measurements', :coverage => 0.9) }
21
21
 
22
22
  it 'outputs coverage' do
23
23
  measure
@@ -26,7 +26,7 @@ describe Yardstick::Rake::Verify, '#verify_measurements' do
26
26
  end
27
27
 
28
28
  context 'when not verbose' do
29
- let(:measurements) { double('measurements', coverage: 0.9) }
29
+ let(:measurements) { double('measurements', :coverage => 0.9) }
30
30
 
31
31
  before do
32
32
  config.verbose = false
@@ -39,7 +39,7 @@ describe Yardstick::Rake::Verify, '#verify_measurements' do
39
39
  end
40
40
 
41
41
  context 'when lower coverage' do
42
- let(:measurements) { double('measurements', coverage: 0.434) }
42
+ let(:measurements) { double('measurements', :coverage => 0.434) }
43
43
 
44
44
  it 'outputs coverage' do
45
45
  expect { measure }.to raise_error
@@ -53,7 +53,7 @@ describe Yardstick::Rake::Verify, '#verify_measurements' do
53
53
  end
54
54
 
55
55
  context 'when higher coverage' do
56
- let(:measurements) { double('measurements', coverage: 0.9989) }
56
+ let(:measurements) { double('measurements', :coverage => 0.9989) }
57
57
 
58
58
  it 'outputs coverage' do
59
59
  expect { measure }.to raise_error
@@ -67,7 +67,7 @@ describe Yardstick::Rake::Verify, '#verify_measurements' do
67
67
  end
68
68
 
69
69
  context 'when higher coverage without exact threshold requirement' do
70
- let(:measurements) { double('measurements', coverage: 1) }
70
+ let(:measurements) { double('measurements', :coverage => 1) }
71
71
 
72
72
  before do
73
73
  config.require_exact_threshold = false
@@ -9,7 +9,7 @@ describe Yardstick::ReportOutput, 'write' do
9
9
  end
10
10
  end
11
11
 
12
- let(:target) { double('Pathname', dirname: dirname) }
12
+ let(:target) { double('Pathname', :dirname => dirname) }
13
13
  let(:dirname) { double }
14
14
 
15
15
  before do
@@ -7,7 +7,7 @@ describe Yardstick::Rule, '.coerce' do
7
7
 
8
8
  let(:document) { DocumentMock.new }
9
9
  let(:config) { double('config') }
10
- let(:rule_config) { Yardstick::RuleConfig.new(enabled: false) }
10
+ let(:rule_config) { Yardstick::RuleConfig.new(:enabled => false) }
11
11
 
12
12
  before do
13
13
  config.stub(:for_rule).with(described_class) { rule_config }
@@ -5,7 +5,7 @@ require 'spec_helper'
5
5
  describe Yardstick::Rule, '#enabled?' do
6
6
  subject { described_class.new(document, config).enabled? }
7
7
 
8
- let(:document) { double('document', path: 'Foo#bar') }
8
+ let(:document) { double('document', :path => 'Foo#bar') }
9
9
  let(:config) { double('RuleConfig') }
10
10
  let(:return_value) { double('Boolean') }
11
11
 
@@ -16,7 +16,7 @@ describe Yardstick::Rule, '#initialize' do
16
16
  context 'when rule config is given' do
17
17
  subject { described_class.new(document, config) }
18
18
 
19
- let(:config) { Yardstick::RuleConfig.new(enabled: false) }
19
+ let(:config) { Yardstick::RuleConfig.new(:enabled => false) }
20
20
 
21
21
  it { should be_a(described_class) }
22
22
 
@@ -5,7 +5,7 @@ require 'spec_helper'
5
5
  describe Yardstick::Rules::ApiTag::PrivateMethod, '#validatable?' do
6
6
  subject { described_class.new(document).validatable? }
7
7
 
8
- let(:document) { double('document', visibility: visibility) }
8
+ let(:document) { double('document', :visibility => visibility) }
9
9
 
10
10
  context 'when protected visibility' do
11
11
  let(:visibility) { :private }
@@ -5,7 +5,7 @@ require 'spec_helper'
5
5
  describe Yardstick::Rules::ApiTag::ProtectedMethod, '#validatable?' do
6
6
  subject { described_class.new(document).validatable? }
7
7
 
8
- let(:document) { double('document', visibility: visibility) }
8
+ let(:document) { double('document', :visibility => visibility) }
9
9
 
10
10
  context 'when protected visibility' do
11
11
  let(:visibility) { :protected }
@@ -5,7 +5,7 @@ require 'spec_helper'
5
5
  describe Yardstick::Rules::Summary::Delimiter, '#valid?' do
6
6
  subject { described_class.new(document).valid? }
7
7
 
8
- let(:document) { double('document', summary_text: text) }
8
+ let(:document) { double('document', :summary_text => text) }
9
9
 
10
10
  context 'without a dot' do
11
11
  let(:text) { 'A summary' }
@@ -5,7 +5,7 @@ require 'spec_helper'
5
5
  describe Yardstick::Rules::Summary::Length, '#valid?' do
6
6
  subject { described_class.new(document).valid? }
7
7
 
8
- let(:document) { double('document', summary_text: text) }
8
+ let(:document) { double('document', :summary_text => text) }
9
9
 
10
10
  context 'with short summary' do
11
11
  let(:text) { 'A summary' }
@@ -5,7 +5,7 @@ require 'spec_helper'
5
5
  describe Yardstick::Rules::Summary::Presence, '#valid?' do
6
6
  subject { described_class.new(document).valid? }
7
7
 
8
- let(:document) { double('document', summary_text: text) }
8
+ let(:document) { double('document', :summary_text => text) }
9
9
 
10
10
  context 'with summary' do
11
11
  let(:text) { 'A summary' }
@@ -5,7 +5,7 @@ require 'spec_helper'
5
5
  describe Yardstick::Rules::Summary::SingleLine, '#valid?' do
6
6
  subject { described_class.new(document).valid? }
7
7
 
8
- let(:document) { double('document', summary_text: text) }
8
+ let(:document) { double('document', :summary_text => text) }
9
9
 
10
10
  context 'with one line summary' do
11
11
  let(:text) { 'A summary' }
@@ -18,7 +18,7 @@ Gem::Specification.new do |gem|
18
18
  gem.extra_rdoc_files = %w[LICENSE README.md CONTRIBUTING.md TODO]
19
19
  gem.executables = %w[yardstick]
20
20
 
21
- gem.add_runtime_dependency('yard', '~> 0.8', '>= 0.8.7')
21
+ gem.add_runtime_dependency('yard', '~> 0.8', '>= 0.8.7.2')
22
22
 
23
23
  gem.add_development_dependency('bundler', '~> 1.3', '>= 1.3.5')
24
24
  end
metadata CHANGED
@@ -1,53 +1,58 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yardstick
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.7
4
+ version: 0.9.8
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Dan Kubb
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2013-09-15 00:00:00.000000000 Z
12
+ date: 2014-01-15 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: yard
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
19
  - - ~>
18
20
  - !ruby/object:Gem::Version
19
21
  version: '0.8'
20
- - - '>='
22
+ - - ! '>='
21
23
  - !ruby/object:Gem::Version
22
- version: 0.8.7
24
+ version: 0.8.7.2
23
25
  type: :runtime
24
26
  prerelease: false
25
27
  version_requirements: !ruby/object:Gem::Requirement
28
+ none: false
26
29
  requirements:
27
30
  - - ~>
28
31
  - !ruby/object:Gem::Version
29
32
  version: '0.8'
30
- - - '>='
33
+ - - ! '>='
31
34
  - !ruby/object:Gem::Version
32
- version: 0.8.7
35
+ version: 0.8.7.2
33
36
  - !ruby/object:Gem::Dependency
34
37
  name: bundler
35
38
  requirement: !ruby/object:Gem::Requirement
39
+ none: false
36
40
  requirements:
37
41
  - - ~>
38
42
  - !ruby/object:Gem::Version
39
43
  version: '1.3'
40
- - - '>='
44
+ - - ! '>='
41
45
  - !ruby/object:Gem::Version
42
46
  version: 1.3.5
43
47
  type: :development
44
48
  prerelease: false
45
49
  version_requirements: !ruby/object:Gem::Requirement
50
+ none: false
46
51
  requirements:
47
52
  - - ~>
48
53
  - !ruby/object:Gem::Version
49
54
  version: '1.3'
50
- - - '>='
55
+ - - ! '>='
51
56
  - !ruby/object:Gem::Version
52
57
  version: 1.3.5
53
58
  description: Measure YARD documentation coverage
@@ -207,26 +212,27 @@ files:
207
212
  homepage: https://github.com/dkubb/yardstick
208
213
  licenses:
209
214
  - MIT
210
- metadata: {}
211
215
  post_install_message:
212
216
  rdoc_options: []
213
217
  require_paths:
214
218
  - lib
215
219
  required_ruby_version: !ruby/object:Gem::Requirement
220
+ none: false
216
221
  requirements:
217
- - - '>='
222
+ - - ! '>='
218
223
  - !ruby/object:Gem::Version
219
224
  version: '0'
220
225
  required_rubygems_version: !ruby/object:Gem::Requirement
226
+ none: false
221
227
  requirements:
222
- - - '>='
228
+ - - ! '>='
223
229
  - !ruby/object:Gem::Version
224
230
  version: '0'
225
231
  requirements: []
226
232
  rubyforge_project:
227
- rubygems_version: 2.0.2
233
+ rubygems_version: 1.8.23
228
234
  signing_key:
229
- specification_version: 4
235
+ specification_version: 3
230
236
  summary: A tool for verifying YARD documentation coverage
231
237
  test_files:
232
238
  - spec/integration/yardstick/class_methods/measure_spec.rb
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 9c2137c6b2747b94bf79c7d18f96f3046b88cad1
4
- data.tar.gz: 3b701a6a2923c7925ff69040a03befa7a6a6ba85
5
- SHA512:
6
- metadata.gz: 2cd3503aa97404404f678d781a4f144f73cf80662389cef07a2252af4236ffe51b10311e274847b457c1ce2cd4c4da44e7b4225f0a23c51704f0d50ee1258bf1
7
- data.tar.gz: dc976e0b2f8477add7b52a5bdf2142bea4e5d22150601da3e0e8e493cfe1794c851eb83d14e8bef81ee6f0788865986d38a0f1ac301cd9bf124809c7d212ad48