Class: Guard::Rubybeautify
- Inherits:
-
Plugin
- Object
- Plugin
- Guard::Rubybeautify
- Defined in:
- lib/guard/rubybeautify.rb
Instance Attribute Summary collapse
-
#count ⇒ Object
Returns the value of attribute count.
-
#grace_period ⇒ Object
Returns the value of attribute grace_period.
-
#style ⇒ Object
Returns the value of attribute style.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Rubybeautify
constructor
A new instance of Rubybeautify.
- #run_on_modifications(paths) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Rubybeautify
Returns a new instance of Rubybeautify.
8 9 10 11 12 13 14 15 16 |
# File 'lib/guard/rubybeautify.rb', line 8 def initialize( = {}) super @last_run = 0 = { grace_period: 5, count: 1, style: :tabs }.merge() end |
Instance Attribute Details
#count ⇒ Object
Returns the value of attribute count.
6 7 8 |
# File 'lib/guard/rubybeautify.rb', line 6 def count @count end |
#grace_period ⇒ Object
Returns the value of attribute grace_period.
6 7 8 |
# File 'lib/guard/rubybeautify.rb', line 6 def grace_period @grace_period end |
#style ⇒ Object
Returns the value of attribute style.
6 7 8 |
# File 'lib/guard/rubybeautify.rb', line 6 def style @style end |
Instance Method Details
#run_on_modifications(paths) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/guard/rubybeautify.rb', line 18 def run_on_modifications(paths) if @last_run + [:grace_period] < Time.now.to_i paths.each do |file| Compat::UI.info "Ruby beautify executed against: #{Guard::Compat::UI.color file, :green}" `ruby-beautify #{file} -c #{options[:count]} --#{options[:style].to_s}` end # make sure to set a real last run if we did a beautify. @last_run = Time.now.to_i else Compat::UI.debug "Ruby beautify skipped on #{paths.join}" end end |