guard-rubybeautify 0.90.0 → 0.90.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 211d01579dc13c1c6ca8a05769c266d76f499db2
4
- data.tar.gz: 8449a81944705829b6af604621a27bbbd284ad07
3
+ metadata.gz: 2d62ceacb441d0b41d7794856247b838694448a0
4
+ data.tar.gz: 6d482e3b5abb2e1b423a3e74d3cf45ddd3c9d7c2
5
5
  SHA512:
6
- metadata.gz: dbb8231b2019496d25046bfe0e65457ee00b4cf37a33c16fffadf1c1add9573b80d5286d99a6f7fe9f1a84d19df535351430d228d371b2e7d8e48cb68cfc5f88
7
- data.tar.gz: 795f4e52638ee9be52cc1eb03bde13ce06732470633de5ff6b6f1346d37afaed501b68aa54cec1e1b708be6df42a5cd136bcf36c26a2aeac83a62c7c7a054c0e
6
+ metadata.gz: 2886e2ace088d8c678e32c4ba3702ff22e8b888484c000ce055f8131d8ab3284eaec01d7e79b1739c83c156a2b477c90450afa6656a2c0d175e064f3a2a34e57
7
+ data.tar.gz: d9a5ca41bb48deb3d1989f6ab43ab01c9519770688bda95d49a1703d742b15a8358da2c4ace72263bd2b74b0ef27dfefdc94a21cb93c2c49b22188ef3dbfda70
data/README.md CHANGED
@@ -36,6 +36,17 @@ or call
36
36
 
37
37
  to have a section added automatically.
38
38
 
39
+ ### Options
40
+
41
+ This guard also comes with three options built in:
42
+ * count: 1 # The count of indent chars.
43
+ * style: :tabs # the type, tab or spaces.
44
+ * grace_period: 5 # amount of time to not trigger further beautifies (stops loops).
45
+
46
+ `grace_period` is the only one that is unique to this gem. It's the period of time to *not* monitor for changes. Since the gem will trigger an overwrite, this can trigger specs and doc generation. Which then trigger more beautifies, that trigger more of the other guards.
47
+
48
+ To avoid this, set this to a period longer then a single modification runs. Since this has no global mode, you don't need to worry about what happens when you press `enter`. It will only impact open files that are saved.
49
+
39
50
  ## Development
40
51
 
41
52
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
data/WHATSNEW.md ADDED
@@ -0,0 +1,2 @@
1
+ # 0.90.1
2
+ - Moved towards a timer based method since guard threads and that cannot be blocked.
@@ -1,5 +1,5 @@
1
1
  module Guard
2
2
  module RubybeautifyVersion
3
- VERSION = "0.90.0"
3
+ VERSION = "0.90.1"
4
4
  end
5
5
  end
@@ -2,27 +2,30 @@ require "guard/rubybeautify/version"
2
2
  require 'guard/compat/plugin'
3
3
 
4
4
  module Guard
5
- class Rubybeautify < Plugin
6
- attr_accessor :count, :style
5
+ class Rubybeautify < Plugin
6
+ attr_accessor :count, :style, :grace_period
7
7
 
8
- def initialize(options = {})
9
- super
10
- @options = {
11
- count: 1,
12
- style: :tabs
13
- }.merge(options)
14
- end
8
+ def initialize(options = {})
9
+ super
10
+ @last_run = 0
11
+ @options = {
12
+ grace_period: 5,
13
+ count: 1,
14
+ style: :tabs
15
+ }.merge(options)
16
+ end
15
17
 
16
- def run_on_modifications(paths)
17
- unless @beautified
18
- @beautified = true
19
- paths.each do |file|
20
- `ruby-beautify #{file} --overwrite`
21
- Compat::UI.info "Ruby beautify executed against #{file}"
22
- end
18
+ def run_on_modifications(paths)
19
+ if @last_run + options[:grace_period] < Time.now.to_i
20
+ paths.each do |file|
21
+ Compat::UI.info "Ruby beautify executed against: #{Guard::Compat::UI.color file, :green}"
22
+ `ruby-beautify #{file} --overwrite`
23
+ end
24
+ # make sure to set a real last run if we did a beautify.
25
+ @last_run = Time.now.to_i
23
26
  else
24
- @beautified = false
25
- end
26
- end
27
- end
27
+ Compat::UI.debug "Ruby beautify skipped on #{paths.join}"
28
+ end
29
+ end
30
+ end
28
31
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-rubybeautify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.90.0
4
+ version: 0.90.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ernie Brodeur
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-06-23 00:00:00.000000000 Z
11
+ date: 2015-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: guard-compat
@@ -80,6 +80,7 @@ files:
80
80
  - Gemfile
81
81
  - README.md
82
82
  - Rakefile
83
+ - WHATSNEW.md
83
84
  - bin/console
84
85
  - bin/setup
85
86
  - guard-rubybeautify.gemspec