guard-yardstick 0.1.0 → 1.0.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 +5 -5
- data/.gitignore +1 -0
- data/.yardstick.yml +14 -0
- data/Gemfile +7 -5
- data/Guardfile +5 -2
- data/README.md +3 -3
- data/Rakefile +24 -0
- data/guard-yardstick.gemspec +3 -2
- data/lib/guard/yardstick.rb +20 -8
- data/lib/guard/yardstick/templates/Guardfile +15 -2
- data/lib/guard/yardstick/version.rb +4 -3
- data/spec/spec_helper.rb +2 -0
- data/spec/yardstick_spec.rb +2 -5
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 45459e4845319647f61ae3292f4ea7d77f0d4232031e1f4784cbe3ae84f88076
|
4
|
+
data.tar.gz: a1bf0c8c29630a98c27cd4d1972d3755fca69d10fc1deb2d376aea47f70cf795
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c921eed30033ecbfa0f02b2a2f487bd3dcde502ebfdc6127b5b85f3a7a4b7072731a11544ffdf24de22110e1f35dd6a09d628222fec87b0662a8982febc3345
|
7
|
+
data.tar.gz: c33d8a4e0517564e7eff2e981ac4c0cf45c2b231dd10bce84bc7496f884a1aaea944fdf850f359f00e1c34815f1cb8ec50b16c3c277a9d43111749f780fdfb2d
|
data/.gitignore
CHANGED
data/.yardstick.yml
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
---
|
2
|
+
rules:
|
3
|
+
ApiTag::Presence:
|
4
|
+
enabled: true
|
5
|
+
exclude:
|
6
|
+
- Guard::YardstickVersion.to_s
|
7
|
+
ApiTag::Inclusion:
|
8
|
+
enabled: true
|
9
|
+
exclude:
|
10
|
+
- Guard::YardstickVersion.to_s
|
11
|
+
Summary::Delimiter:
|
12
|
+
enabled: true
|
13
|
+
exclude:
|
14
|
+
- Guard::Yardstick#yardstick_config
|
data/Gemfile
CHANGED
@@ -1,15 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
source 'https://rubygems.org'
|
2
4
|
|
3
5
|
# Specify your gem's dependencies in guard-yardstick.gemspec
|
4
6
|
gemspec
|
5
7
|
|
6
8
|
group :development do
|
7
|
-
gem 'guard'
|
8
|
-
gem 'guard-rubocop'
|
9
|
-
gem 'guard-rspec'
|
10
|
-
gem 'rubocop'
|
9
|
+
gem 'guard-rspec', require: false
|
10
|
+
gem 'guard-rubocop', require: false
|
11
11
|
end
|
12
12
|
|
13
13
|
group :development, :test do
|
14
|
-
gem 'rspec'
|
14
|
+
gem 'rspec', require: false
|
15
|
+
gem 'rubocop', require: false
|
16
|
+
gem 'yardstick', require: false
|
15
17
|
end
|
data/Guardfile
CHANGED
@@ -1,11 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# A sample Guardfile
|
2
4
|
# More info at https://github.com/guard/guard#readme
|
3
5
|
|
4
|
-
guard :yardstick do
|
6
|
+
guard :yardstick, config: '.yardstick.yml' do
|
5
7
|
watch(/.+\.rb$/)
|
8
|
+
watch('.yardstick.yml') { 'lib' }
|
6
9
|
end
|
7
10
|
|
8
|
-
guard :rubocop, all_on_start: true, cli: ['--display-cop-name']do
|
11
|
+
guard :rubocop, all_on_start: true, cli: ['--display-cop-name'] do
|
9
12
|
watch('guard-yardstick.gemspec')
|
10
13
|
watch(/^(|Rakefile|Guardfile)/)
|
11
14
|
watch(/.+\.rb$/)
|
data/README.md
CHANGED
@@ -10,7 +10,7 @@ Add `guard-yardstick` to your `Gemfile`:
|
|
10
10
|
|
11
11
|
```ruby
|
12
12
|
group :development do
|
13
|
-
gem 'guard-yardstick'
|
13
|
+
gem 'guard-yardstick', require: false
|
14
14
|
end
|
15
15
|
```
|
16
16
|
|
@@ -40,11 +40,11 @@ Please read the [Guard usage documentation](https://github.com/guard/guard#readm
|
|
40
40
|
|
41
41
|
*all_on_start:* Same as on any other Guard plugin. Run yardstick on all files on start or not.
|
42
42
|
|
43
|
-
*
|
43
|
+
*config:* Tells yardstick where to find yardsticks configuration file if present.
|
44
44
|
|
45
45
|
|
46
46
|
```ruby
|
47
|
-
guard :yardstick,
|
47
|
+
guard :yardstick, config: './.yardstick.yml' do
|
48
48
|
# ...
|
49
49
|
end
|
50
50
|
```
|
data/Rakefile
CHANGED
@@ -1 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'yaml'
|
4
|
+
|
1
5
|
require 'bundler/gem_tasks'
|
6
|
+
require 'rspec/core/rake_task'
|
7
|
+
|
8
|
+
RSpec::Core::RakeTask.new(:spec)
|
9
|
+
|
10
|
+
require 'rubocop/rake_task'
|
11
|
+
|
12
|
+
RuboCop::RakeTask.new(:rubocop) do |t|
|
13
|
+
t.options = ['--display-cop-names']
|
14
|
+
end
|
15
|
+
|
16
|
+
require 'yardstick/rake/measurement'
|
17
|
+
yardstick_options = YAML.load_file('.yardstick.yml')
|
18
|
+
|
19
|
+
Yardstick::Rake::Measurement.new(:yardstick_measure, yardstick_options)
|
20
|
+
|
21
|
+
require 'yardstick/rake/verify'
|
22
|
+
|
23
|
+
Yardstick::Rake::Verify.new(:yardstick, yardstick_options)
|
24
|
+
|
25
|
+
task default: %i[spec rubocop yardstick]
|
data/guard-yardstick.gemspec
CHANGED
data/lib/guard/yardstick.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'guard/compat/plugin'
|
2
4
|
require 'yardstick'
|
5
|
+
require 'yaml'
|
3
6
|
|
4
7
|
module Guard
|
5
8
|
# A guard plugin to run yardstick on every save
|
@@ -19,9 +22,7 @@ module Guard
|
|
19
22
|
|
20
23
|
@options = {
|
21
24
|
all_on_start: true,
|
22
|
-
|
23
|
-
# https://github.com/dkubb/yardstick/blob/0aa394dd64baf5155775e6be5018d6c9844654b7/lib/yardstick/config.rb#L167
|
24
|
-
path: ['lib/**/*.rb']
|
25
|
+
config: nil
|
25
26
|
}.merge(args)
|
26
27
|
end
|
27
28
|
|
@@ -39,7 +40,7 @@ module Guard
|
|
39
40
|
# @return [Void]
|
40
41
|
def run_all
|
41
42
|
UI.info 'Inspecting Yarddoc in all files'
|
42
|
-
inspect_with_yardstick
|
43
|
+
inspect_with_yardstick
|
43
44
|
end
|
44
45
|
|
45
46
|
# Will run when files are added
|
@@ -70,18 +71,18 @@ module Guard
|
|
70
71
|
displayed_paths = paths.map { |path| smart_path(path) }
|
71
72
|
UI.info "Inspecting Yarddocs: #{displayed_paths.join(' ')}"
|
72
73
|
|
73
|
-
inspect_with_yardstick(paths)
|
74
|
+
inspect_with_yardstick(path: paths)
|
74
75
|
end
|
75
76
|
|
76
77
|
# Runs yardstick and outputs results to STDOUT
|
77
78
|
#
|
78
79
|
# @api private
|
79
80
|
# @return [Void]
|
80
|
-
def inspect_with_yardstick(
|
81
|
-
config = ::Yardstick::Config.coerce(
|
81
|
+
def inspect_with_yardstick(yardstick_options = {})
|
82
|
+
config = ::Yardstick::Config.coerce(yardstick_config(yardstick_options))
|
82
83
|
measurements = ::Yardstick.measure(config)
|
83
84
|
measurements.puts
|
84
|
-
rescue => error
|
85
|
+
rescue StandardError => error
|
85
86
|
UI.error 'The following exception occurred while running ' \
|
86
87
|
"guard-yardstick: #{error.backtrace.first} " \
|
87
88
|
"#{error.message} (#{error.class.name})"
|
@@ -98,5 +99,16 @@ module Guard
|
|
98
99
|
path
|
99
100
|
end
|
100
101
|
end
|
102
|
+
|
103
|
+
# Merge further options with yardstick config file.
|
104
|
+
#
|
105
|
+
# @api private
|
106
|
+
# @return [Hash] Hash of options for yardstick measurement
|
107
|
+
def yardstick_config(extra_options = {})
|
108
|
+
return options unless options[:config]
|
109
|
+
|
110
|
+
yardstick_options = YAML.load_file(options[:config])
|
111
|
+
yardstick_options.merge(extra_options)
|
112
|
+
end
|
101
113
|
end
|
102
114
|
end
|
@@ -1,10 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Options to guard-yardstick
|
2
4
|
# all_on_start: true
|
3
|
-
#
|
5
|
+
# config: nil
|
4
6
|
guard :yardstick do
|
5
7
|
# Typical Rails setup
|
6
|
-
# Set path option
|
8
|
+
# Set path option for yardstick in ,yardstick.yml
|
9
|
+
# ---
|
10
|
+
# path:
|
11
|
+
# - app
|
12
|
+
# - config
|
13
|
+
# - lib
|
14
|
+
# # Also check out the rules config
|
15
|
+
# # https://github.com/dkubb/yardstick#4-configuration
|
16
|
+
#
|
17
|
+
# and pass in the location of the yaml file using the config option
|
18
|
+
# config: '.yardstick.yml'
|
7
19
|
# watch(%r{^app\/(.+)\.rb$})
|
8
20
|
# watch(%r{^config\/initializers\/(.+)\.rb$})
|
21
|
+
# watch('.yardstick.yml') { 'lib' }
|
9
22
|
watch(%r{^lib\/(.+)\.rb$})
|
10
23
|
end
|
@@ -1,10 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Guard
|
2
4
|
# A workaround for declaring `class Yardstick`
|
3
5
|
# before `class Yardstick < Guard` in yardstick.rb
|
4
6
|
module YardstickVersion
|
5
7
|
# http://semver.org/
|
6
|
-
MAJOR =
|
7
|
-
MINOR =
|
8
|
+
MAJOR = 1
|
9
|
+
MINOR = 0
|
8
10
|
PATCH = 0
|
9
11
|
|
10
12
|
# Returns a formatted version string
|
@@ -12,7 +14,6 @@ module Guard
|
|
12
14
|
# @example
|
13
15
|
# Guard::YardstickVersion.to_s # => '0.0.0.2'
|
14
16
|
#
|
15
|
-
# @api public
|
16
17
|
# @return [String]
|
17
18
|
def self.to_s
|
18
19
|
[MAJOR, MINOR, PATCH].join('.')
|
data/spec/spec_helper.rb
CHANGED
data/spec/yardstick_spec.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
RSpec.describe Guard::Yardstick do
|
@@ -14,11 +16,6 @@ RSpec.describe Guard::Yardstick do
|
|
14
16
|
subject { super()[:all_on_start] }
|
15
17
|
it { should be_truthy }
|
16
18
|
end
|
17
|
-
|
18
|
-
describe '[:path]' do
|
19
|
-
subject { super()[:path] }
|
20
|
-
it { should eq(['lib/**/*.rb']) }
|
21
|
-
end
|
22
19
|
end
|
23
20
|
end
|
24
21
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guard-yardstick
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Lee
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: guard
|
@@ -76,6 +76,7 @@ extra_rdoc_files: []
|
|
76
76
|
files:
|
77
77
|
- ".gitignore"
|
78
78
|
- ".rspec"
|
79
|
+
- ".yardstick.yml"
|
79
80
|
- Gemfile
|
80
81
|
- Guardfile
|
81
82
|
- LICENSE.txt
|
@@ -107,11 +108,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
108
|
version: '0'
|
108
109
|
requirements: []
|
109
110
|
rubyforge_project:
|
110
|
-
rubygems_version: 2.
|
111
|
+
rubygems_version: 2.7.6
|
111
112
|
signing_key:
|
112
113
|
specification_version: 4
|
113
114
|
summary: Guard plugin for Yardstick
|
114
115
|
test_files:
|
115
116
|
- spec/spec_helper.rb
|
116
117
|
- spec/yardstick_spec.rb
|
117
|
-
has_rdoc:
|