diff_parser 1.3.3 → 1.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/diff_parser/diff.rb +10 -6
- data/lib/diff_parser/diff_files_collection.rb +1 -1
- data/lib/diff_parser/file.rb +5 -7
- data/lib/diff_parser/version.rb +1 -1
- data/lib/diff_parser.rb +14 -4
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NjE3OTU3NGU5MzNhZTIzODQ3NWRiOTU0ZmNlNDU2OTNhZmU2ZWU4Yg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MzcxNmQwN2I0ZGI2ZGFjMzY3MmRjOTY3ZjUxYWI0Njg2ZmZmNDMwYg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NGMxYzcwM2E4YjMyYWY1NDRlYjBhNzNkZDEzMGMwYzg2NDI3NjY2NzRiOTQ4
|
10
|
+
NjY3Y2QyNmNlMjJiZjkyZWYzNjJlZGU4ZGRiMjljOGM0NWVkOWRmMzhhMTJm
|
11
|
+
NjRiN2MyM2NhMWQzMTUzZmIxNjkzYTlhYThhZWRhMDUxNzUzNDc=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
Mjk5MTMzZTMyMGU1Y2FlYzlmYjAxNzlhMDhkN2E5MWFhYmQxNmM4NGUzNGEz
|
14
|
+
MmZiNGYyNzBhMmRmODJkNDk0ZmRkNmFlYWIxYTBmODA5ZGNjYjQyNzFjNzI4
|
15
|
+
ODJmNzk5YTBmMTAwZmQxYTJiMjNlYjA4NjlmNjY5MmJmYjI1ODc=
|
data/lib/diff_parser/diff.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
module DiffParser
|
2
2
|
class Diff
|
3
|
+
extend Forwardable
|
4
|
+
|
3
5
|
attr_reader :raw, :info, :commit, :options
|
4
|
-
delegate :github, :repo, :sha
|
6
|
+
delegate [:github, :repo, :sha] => :commit
|
5
7
|
|
6
8
|
def initialize(commit, options)
|
7
9
|
@commit = commit
|
@@ -9,16 +11,18 @@ module DiffParser
|
|
9
11
|
@info = github.commit(repo, sha)
|
10
12
|
|
11
13
|
@raw = Rails.cache.fetch(diff_cache_key) do
|
12
|
-
|
13
|
-
|
14
|
-
if diff.encoding == Encoding::ASCII_8BIT
|
15
|
-
diff.encode('utf-8', 'ASCII-8BIT', invalid: :replace, undef: :replace, replace: '')
|
14
|
+
if raw_diff.encoding == Encoding::ASCII_8BIT
|
15
|
+
raw_diff.encode('utf-8', 'ASCII-8BIT', invalid: :replace, undef: :replace, replace: '')
|
16
16
|
else
|
17
|
-
|
17
|
+
raw_diff
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
+
def raw_diff
|
23
|
+
@raw_diff ||= github.commit(repo, sha, accept: 'application/vnd.github.VERSION.diff')
|
24
|
+
end
|
25
|
+
|
22
26
|
def diff_cache_key
|
23
27
|
"diff-#{repo}-#{sha}"
|
24
28
|
end
|
data/lib/diff_parser/file.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
module DiffParser
|
2
2
|
class File
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
extend Forwardable
|
4
|
+
|
5
|
+
attr_accessor :line_old, :line_new, :lines, :type
|
6
|
+
attr_reader :path, :file_info, :diff, :file_number
|
7
|
+
delegate [:additions, :deletions] => :file_info
|
6
8
|
|
7
9
|
def initialize(path, diff, file_number=0)
|
8
10
|
@path = preprocess_path(path)
|
@@ -36,10 +38,6 @@ module DiffParser
|
|
36
38
|
end
|
37
39
|
end
|
38
40
|
|
39
|
-
def type=(str)
|
40
|
-
@type = str.inquiry
|
41
|
-
end
|
42
|
-
|
43
41
|
def sha
|
44
42
|
diff.sha
|
45
43
|
end
|
data/lib/diff_parser/version.rb
CHANGED
data/lib/diff_parser.rb
CHANGED
@@ -6,11 +6,21 @@ require 'diff_parser/raw_line'
|
|
6
6
|
require 'diff_parser/diff_line'
|
7
7
|
|
8
8
|
module DiffParser
|
9
|
-
|
10
|
-
|
9
|
+
def self.max_changes_to_render
|
10
|
+
@@max_changes_to_render || 500
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.max_changes_to_render=(changes_count)
|
14
|
+
@@max_changes_to_render = changes_count
|
15
|
+
end
|
11
16
|
|
12
|
-
|
13
|
-
|
17
|
+
def self.max_unfolded_diff_size
|
18
|
+
@@max_unfolded_diff_size || 1.megabyte
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.max_unfolded_diff_size=(max_size)
|
22
|
+
@@max_unfolded_diff_size = max_size
|
23
|
+
end
|
14
24
|
|
15
25
|
def self.setup
|
16
26
|
yield self
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: diff_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- stevo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
12
|
-
dependencies:
|
11
|
+
date: 2014-02-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ! '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ! '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
description: Allows parsing diffs for presentation purposes - extracted from marvelous
|
14
28
|
GitLab project
|
15
29
|
email:
|