guard-yardstick 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: 70281bd8873f56a754d7b1676d0e10b4b6ac57d5
4
- data.tar.gz: 98a6e991a4391e003ce0eb11975e33301841b1c8
3
+ metadata.gz: e30961fcbd2719308deb781c609e613e325916bd
4
+ data.tar.gz: 4dbe259bcf095ed6070b663d2d52559635f82f6a
5
5
  SHA512:
6
- metadata.gz: 66ff4161396f810a48d794758c848ce15be8b65f3f53378478d35ec4eb0078965d98abcaff75898e39744964c2357fa3566c5d44b19485556a9b396e5012ae49
7
- data.tar.gz: 00e4bd3594619dae551aa8b20a6f084fc0bb1821130f66124f0d4d2eb509c37dc1bec88acb963119d26ac02cf9818f234fe8bb1bfa083a0b272aa0870a027af5
6
+ metadata.gz: e772938511c6cf800bdf781bb3b39552e442b8cfd236dc5039b8a04aac0006d7a8e7b460523c974624b161e4a15e2d093039a98a57225c59ecfc4e8bde7a3053
7
+ data.tar.gz: 4627760f097b90789312114bcf2bd2016e129ffe7d25517baf38143827e5e0bab4ea19ba4000b70e62727b7543112eb2b6bffdaa7058299034af883324a19eb4
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ [![Gem Version](https://badge.fury.io/rb/guard-yardstick.svg)](http://badge.fury.io/rb/guard-yardstick)
2
+
1
3
  # guard-yardstick
2
4
 
3
5
  guard-yardstick will automatically check your code for missing yardocs
@@ -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
- system(build_command)
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 build_command
28
- cli = options[:cli].join(' ')
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
- "bundle exec yardstick #{cli}"
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
@@ -5,7 +5,7 @@ module Guard
5
5
  # http://semver.org/
6
6
  MAJOR = 0
7
7
  MINOR = 0
8
- PATCH = 1
8
+ PATCH = 2
9
9
 
10
10
  def self.to_s
11
11
  [MAJOR, MINOR, PATCH].join('.')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-yardstick
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
  - Nathan Lee