Class: DiffParser::Diff
- Inherits:
-
Object
- Object
- DiffParser::Diff
- Extended by:
- Forwardable
- Defined in:
- lib/diff_parser/diff.rb
Instance Attribute Summary collapse
-
#commit ⇒ Object
readonly
Returns the value of attribute commit.
-
#info ⇒ Object
readonly
Returns the value of attribute info.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
Instance Method Summary collapse
- #diff_cache_key ⇒ Object
- #files ⇒ Object
-
#initialize(commit, options) ⇒ Diff
constructor
A new instance of Diff.
- #raw_diff ⇒ Object
Constructor Details
#initialize(commit, options) ⇒ Diff
Returns a new instance of Diff.
8 9 10 11 12 13 14 15 16 |
# File 'lib/diff_parser/diff.rb', line 8 def initialize(commit, ) @commit = commit @options = @info = github.commit(repo, sha) @raw = Rails.cache.fetch(diff_cache_key) do raw_diff.force_encoding('UTF-8') end end |
Instance Attribute Details
#commit ⇒ Object (readonly)
Returns the value of attribute commit.
5 6 7 |
# File 'lib/diff_parser/diff.rb', line 5 def commit @commit end |
#info ⇒ Object (readonly)
Returns the value of attribute info.
5 6 7 |
# File 'lib/diff_parser/diff.rb', line 5 def info @info end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/diff_parser/diff.rb', line 5 def @options end |
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
5 6 7 |
# File 'lib/diff_parser/diff.rb', line 5 def raw @raw end |
Instance Method Details
#diff_cache_key ⇒ Object
22 23 24 |
# File 'lib/diff_parser/diff.rb', line 22 def diff_cache_key "diff-#{repo}-#{sha}" end |
#files ⇒ Object
26 27 28 |
# File 'lib/diff_parser/diff.rb', line 26 def files DiffParser::DiffFilesCollection.new(self, ) end |
#raw_diff ⇒ Object
18 19 20 |
# File 'lib/diff_parser/diff.rb', line 18 def raw_diff @raw_diff ||= github.commit(repo, sha, accept: 'application/vnd.github.VERSION.diff') end |