Class: OverridesTracker::Util
- Inherits:
-
Object
- Object
- OverridesTracker::Util
- Defined in:
- lib/overrides_tracker/util.rb
Class Method Summary collapse
Class Method Details
.method_hash(method) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/overrides_tracker/util.rb', line 7 def method_hash method begin { :sha => method_sha(method), :location => method.source_location, :body => outdented_method_body(method), } rescue { :sha => method.hash, :location => nil, :body => nil, } end end |
.method_sha(method) ⇒ Object
29 30 31 |
# File 'lib/overrides_tracker/util.rb', line 29 def method_sha method Digest::SHA1.hexdigest(method.source.gsub(/\s+/, ' ')) end |
.outdented_method_body(method) ⇒ Object
23 24 25 26 27 |
# File 'lib/overrides_tracker/util.rb', line 23 def outdented_method_body method body = method.source indent = body.match(/^\W+/).to_s body.lines.map{|l| l.sub(indent, '')}.join end |