Class: MethodLog::API
- Inherits:
-
Object
- Object
- MethodLog::API
- Defined in:
- lib/method_log/api.rb
Instance Method Summary collapse
- #diffs(method_identifier, options = {}) ⇒ Object
- #history(method_identifier, options = {}) ⇒ Object
-
#initialize(repository) ⇒ API
constructor
A new instance of API.
Constructor Details
#initialize(repository) ⇒ API
Returns a new instance of API.
7 8 9 |
# File 'lib/method_log/api.rb', line 7 def initialize(repository) @repository = repository end |
Instance Method Details
#diffs(method_identifier, options = {}) ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/method_log/api.rb', line 30 def diffs(method_identifier, = {}) Enumerator.new do |yielder| history(method_identifier, ).each_cons(2) do |(commit, parent)| diff = MethodDiff.new(parent, commit) unless diff.empty? yielder << [commit, diff] end end end end |
#history(method_identifier, options = {}) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/method_log/api.rb', line 11 def history(method_identifier, = {}) = { stop_at_latest_introduction_of_method: true }.merge() Enumerator.new do |yielder| last_method_commit = nil @repository.commits().each do |commit| last_source_file = last_method_commit && last_method_commit.source_file if last_source_file && commit.contains?(last_source_file) last_method_commit.update(commit) else method_definition = commit.find(method_identifier, last_source_file) yielder << last_method_commit if last_method_commit last_method_commit = MethodCommit.new(commit, method_definition) yielder << last_method_commit break if [:stop_at_latest_introduction_of_method] && method_definition.nil? end end end end |