lib/git_fame/result.rb in git_fame-2.5.3 vs lib/git_fame/result.rb in git_fame-3.0.0
- old
+ new
@@ -1,6 +1,31 @@
+# frozen_string_literal: true
+
module GitFame
- class Result < Struct.new(:data, :success)
- def to_s; data; end
- def success?; success; end
+ class Result < Base
+ attribute :contributions, Types.Array(Contribution)
+
+ # @return [Array<Author>]
+ def authors
+ contributions.map(&:author)
+ end
+
+ # @return [Array<String>]
+ def commits
+ contributions.flat_map do |c|
+ c.commits.to_a
+ end
+ end
+
+ # @return [Array<String>]
+ def files
+ contributions.flat_map do |c|
+ c.files.to_a
+ end
+ end
+
+ # @return [Integer]
+ def lines
+ contributions.sum(&:lines)
+ end
end
-end
\ No newline at end of file
+end