guard-yardstick 0.0.1 → 0.0.2
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/lib/guard/yardstick.rb +34 -6
- data/lib/guard/yardstick/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e30961fcbd2719308deb781c609e613e325916bd
|
4
|
+
data.tar.gz: 4dbe259bcf095ed6070b663d2d52559635f82f6a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e772938511c6cf800bdf781bb3b39552e442b8cfd236dc5039b8a04aac0006d7a8e7b460523c974624b161e4a15e2d093039a98a57225c59ecfc4e8bde7a3053
|
7
|
+
data.tar.gz: 4627760f097b90789312114bcf2bd2016e129ffe7d25517baf38143827e5e0bab4ea19ba4000b70e62727b7543112eb2b6bffdaa7058299034af883324a19eb4
|
data/README.md
CHANGED
data/lib/guard/yardstick.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'guard'
|
2
2
|
require 'guard/plugin'
|
3
|
+
require 'yardstick'
|
3
4
|
|
4
5
|
module Guard
|
5
6
|
class Yardstick < Plugin
|
@@ -8,8 +9,7 @@ module Guard
|
|
8
9
|
super
|
9
10
|
|
10
11
|
@options = {
|
11
|
-
all_on_start: true
|
12
|
-
cli: ['./**/*.rb']
|
12
|
+
all_on_start: true
|
13
13
|
}.merge(options)
|
14
14
|
end
|
15
15
|
|
@@ -19,15 +19,43 @@ module Guard
|
|
19
19
|
|
20
20
|
def run_all
|
21
21
|
UI.info 'Inspecting Yarddoc in all files'
|
22
|
-
|
22
|
+
|
23
|
+
inspect_with_yardstick
|
24
|
+
end
|
25
|
+
|
26
|
+
def run_on_additions(paths)
|
27
|
+
run_partially(paths)
|
28
|
+
end
|
29
|
+
|
30
|
+
def run_on_modifications(paths)
|
31
|
+
run_partially(paths)
|
23
32
|
end
|
24
33
|
|
25
34
|
private
|
26
35
|
|
27
|
-
def
|
28
|
-
|
36
|
+
def run_partially(paths)
|
37
|
+
return if paths.empty?
|
38
|
+
|
39
|
+
displayed_paths = paths.map { |path| smart_path(path) }
|
40
|
+
UI.info "Inspecting Yarddocs: #{displayed_paths.join(' ')}"
|
41
|
+
|
42
|
+
inspect_with_yardstick(paths)
|
43
|
+
end
|
44
|
+
|
45
|
+
def inspect_with_yardstick(paths = [])
|
46
|
+
measurements = ::Yardstick.measure
|
47
|
+
measurements.puts
|
48
|
+
rescue => error
|
49
|
+
UI.error 'The following exception occurred while running guard-yardstick: ' \
|
50
|
+
"#{error.backtrace.first} #{error.message} (#{error.class.name})"
|
51
|
+
end
|
29
52
|
|
30
|
-
|
53
|
+
def smart_path(path)
|
54
|
+
if path.start_with?(Dir.pwd)
|
55
|
+
Pathname.new(path).relative_path_from(Pathname.getwd).to_s
|
56
|
+
else
|
57
|
+
path
|
58
|
+
end
|
31
59
|
end
|
32
60
|
|
33
61
|
end
|