gitt 3.1.0 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d4c4eca5127ba8feed6bcb27e0708ac6d4580460a9d9b506f1c195ba071c661e
4
- data.tar.gz: 94787241e549ed1ae3bb6b01a6050b3d88122735fe9c9dcddee3c578f79aaab2
3
+ metadata.gz: 20dc8c5e5078ccaa451f83b7d4795c3e07e76176ba55a2da4e5f24814b64f611
4
+ data.tar.gz: 6dc1a7560a6fb5f608108eea640eb743147b7614d3bf3f8ff82e2f0723963373
5
5
  SHA512:
6
- metadata.gz: 5171c896cb76cf2b6e138f3bd7d4a201bf5d06800dafa11b46ab8a50ffd678164a8cca087609d28cd64c77847eaf90941cdc5dcf69e85b2de8455d421d072b0c
7
- data.tar.gz: c044661633a4d4bc6c83c4340122a43d701f3fa2215ddb3f10e9d20a65203b875dbb7b1f838bbdc19124087fd050de4c2dcb9cf65e34edc219cb632e28ffb57e
6
+ metadata.gz: 060f9c502e3cab68218e3eb51c882bb12277709f27f1d9c1bce001f6b8330d2e2814ad2dc080c287cd75884868386ec96bf980ea4442b88eb5fa3c391a44a76b
7
+ data.tar.gz: 595164979089c252301be01406343faa142a46b3f1c39d45f609206719863d7282cc9454c2e585bf06a1f00ddbd2b26a8b0940a0be8e818fa89c1f188798b8ed
checksums.yaml.gz.sig CHANGED
Binary file
data/gitt.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "gitt"
5
- spec.version = "3.1.0"
5
+ spec.version = "3.2.0"
6
6
  spec.authors = ["Brooke Kuhlmann"]
7
7
  spec.email = ["brooke@alchemists.io"]
8
8
  spec.homepage = "https://alchemists.io/projects/gitt"
@@ -4,7 +4,7 @@ require "refinements/hash"
4
4
 
5
5
  module Gitt
6
6
  module Parsers
7
- # Parses raw commit information to produce a commit record.
7
+ # Parses raw commit to produce a commit record.
8
8
  class Commit
9
9
  using Refinements::Hash
10
10
 
@@ -16,14 +16,11 @@ module Gitt
16
16
  @model = model
17
17
  end
18
18
 
19
- # rubocop:todo Layout/LineLength
20
19
  def call content
21
20
  attributer.call(content)
22
21
  .then { |attributes| process attributes }
23
- .then { |attributes| attributes.merge! statistic_sanitizer.call(attributes.delete(:statistics)) }
24
22
  .then { |attributes| model[**attributes] }
25
23
  end
26
- # rubocop:enable Layout/LineLength
27
24
 
28
25
  private
29
26
 
@@ -32,10 +29,9 @@ module Gitt
32
29
  # :reek:TooManyStatements
33
30
  def process attributes
34
31
  body, trailers = attributes.values_at :body, :trailers
32
+ body = scissors_sanitizer.call body
35
33
 
36
- attributes.transform_with! body: scissors_sanitizer,
37
- signature: signature_sanitizer,
38
- trailers: trailers_sanitizer
34
+ attributes.transform_with! signature: signature_sanitizer, trailers: trailers_sanitizer
39
35
 
40
36
  attributes[:body] =
41
37
  (trailers ? body.sub(/\n??#{Regexp.escape trailers}\n??/, "") : body).chomp
@@ -59,6 +55,11 @@ module Gitt
59
55
  attributes[:lines] = lines_sanitizer.call attributes[:raw]
60
56
  end
61
57
 
58
+ # :reek:FeatureEnvy
59
+ def process_statistics attributes
60
+ attributes.merge! statistic_sanitizer.call(attributes.delete(:statistics))
61
+ end
62
+
62
63
  def lines_sanitizer = sanitizers.fetch :lines
63
64
 
64
65
  def paragraphs_sanitizer = sanitizers.fetch :paragraphs
@@ -22,7 +22,7 @@ module Gitt
22
22
  authored_at: date_sanitizer,
23
23
  committed_at: date_sanitizer,
24
24
  committer_email: email_sanitizer,
25
- version: -> value { value.delete_prefix "refs/tags/" if value }
25
+ version: version_serializer
26
26
  model[**attributes]
27
27
  end
28
28
 
@@ -30,9 +30,11 @@ module Gitt
30
30
 
31
31
  attr_reader :attributer, :sanitizers, :model
32
32
 
33
- def date_sanitizer = sanitizers.fetch(:date)
33
+ def date_sanitizer = sanitizers.fetch :date
34
34
 
35
- def email_sanitizer = sanitizers.fetch(:email)
35
+ def email_sanitizer = sanitizers.fetch :email
36
+
37
+ def version_serializer = sanitizers.fetch :version
36
38
  end
37
39
  end
38
40
  end
@@ -5,23 +5,27 @@ module Gitt
5
5
  # Parses raw trailer data to produce a trailer record.
6
6
  class Trailer
7
7
  PATTERN = /
8
- (?<key>\A.+) # Key (anchored to start of line).
9
- (?<delimiter>:) # Colon delimiter.
10
- (?<space>\s?) # Space (optional).
11
- (?<value>.*?) # Value.
12
- \Z # End of line.
8
+ \A # Start of line.
9
+ (?<key>.+) # Key.
10
+ (?<delimiter>:) # Colon delimiter.
11
+ (?<space>\s?) # Space (optional).
12
+ (?<value>.*?) # Value.
13
+ \Z # End of line.
13
14
  /x
14
15
 
15
- def initialize pattern: PATTERN, model: Models::Trailer
16
+ EMPTY = Models::Trailer[key: nil, value: nil]
17
+
18
+ def initialize pattern: PATTERN, model: Models::Trailer, empty: EMPTY
16
19
  @pattern = pattern
17
20
  @model = model
18
- @empty = model[key: nil, value: nil].to_h
21
+ @empty = empty
19
22
  end
20
23
 
21
24
  def call content
25
+ return empty if content.start_with? "#"
26
+
22
27
  content.match(pattern)
23
- .then { |data| data ? data.named_captures(symbolize_names: true) : empty }
24
- .then { |attributes| model[**attributes] }
28
+ .then { |data| data ? model[**data.named_captures(symbolize_names: true)] : empty }
25
29
  end
26
30
 
27
31
  private
@@ -10,7 +10,8 @@ module Gitt
10
10
  scissors: Scissors,
11
11
  signature: Signature,
12
12
  statistic: Statistic.new,
13
- trailers: Trailers.new
13
+ trailers: Trailers.new,
14
+ version: Version
14
15
  }.freeze
15
16
  end
16
17
  end
@@ -4,6 +4,6 @@ require "core"
4
4
 
5
5
  module Gitt
6
6
  module Sanitizers
7
- Date = -> value { value.sub(/\s.+\Z/, Core::EMPTY_STRING) if value }
7
+ Date = -> text { text.sub(/\s.+\Z/, Core::EMPTY_STRING) if text }
8
8
  end
9
9
  end
@@ -4,6 +4,6 @@ require "core"
4
4
 
5
5
  module Gitt
6
6
  module Sanitizers
7
- Email = -> value { value.tr "<>", Core::EMPTY_STRING if value }
7
+ Email = -> text { text.tr "<>", Core::EMPTY_STRING if text }
8
8
  end
9
9
  end
@@ -4,6 +4,6 @@ require "core"
4
4
 
5
5
  module Gitt
6
6
  module Sanitizers
7
- Lines = -> value { value ? value.split("\n") : Core::EMPTY_ARRAY }
7
+ Lines = -> text { text ? text.split("\n") : Core::EMPTY_ARRAY }
8
8
  end
9
9
  end
@@ -4,6 +4,6 @@ require "core"
4
4
 
5
5
  module Gitt
6
6
  module Sanitizers
7
- Paragraphs = -> value { value ? value.split("\n\n").map(&:chomp) : Core::EMPTY_ARRAY }
7
+ Paragraphs = -> text { text ? text.split("\n\n").map(&:chomp) : Core::EMPTY_ARRAY }
8
8
  end
9
9
  end
@@ -4,6 +4,6 @@ require "core"
4
4
 
5
5
  module Gitt
6
6
  module Sanitizers
7
- Scissors = -> value { value.sub(/^#\s-.+\s>8\s-.+/m, Core::EMPTY_STRING) if value }
7
+ Scissors = -> text { text.sub(/^#\s-.+\s>8\s-.+/m, Core::EMPTY_STRING) if text }
8
8
  end
9
9
  end
@@ -2,8 +2,8 @@
2
2
 
3
3
  module Gitt
4
4
  module Sanitizers
5
- Signature = lambda do |value|
6
- case value
5
+ Signature = lambda do |text|
6
+ case text
7
7
  when "B" then "Bad"
8
8
  when "E" then "Error"
9
9
  when "G" then "Good"
@@ -8,10 +8,10 @@ module Gitt
8
8
  @parser = parser
9
9
  end
10
10
 
11
- def call value
12
- String(value).split("\n")
13
- .map { |text| parser.call text }
14
- .reject(&:empty?)
11
+ def call text
12
+ String(text).split("\n")
13
+ .map { |line| parser.call line }
14
+ .reject(&:empty?)
15
15
  end
16
16
 
17
17
  private
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "core"
4
+
5
+ module Gitt
6
+ module Sanitizers
7
+ Version = -> text { text.delete_prefix "refs/tags/" if text }
8
+ end
9
+ end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitt
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
4
+ version: 3.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brooke Kuhlmann
@@ -35,7 +35,7 @@ cert_chain:
35
35
  3n5C8/6Zh9DYTkpcwPSuIfAga6wf4nXc9m6JAw8AuMLaiWN/r/2s4zJsUHYERJEu
36
36
  gZGm4JqtuSg8pYjPeIJxS960owq+SfuC+jxqmRA54BisFCv/0VOJi7tiJVY=
37
37
  -----END CERTIFICATE-----
38
- date: 2024-02-13 00:00:00.000000000 Z
38
+ date: 2024-03-03 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: core
@@ -133,6 +133,7 @@ files:
133
133
  - lib/gitt/sanitizers/signature.rb
134
134
  - lib/gitt/sanitizers/statistic.rb
135
135
  - lib/gitt/sanitizers/trailers.rb
136
+ - lib/gitt/sanitizers/version.rb
136
137
  - lib/gitt/shell.rb
137
138
  homepage: https://alchemists.io/projects/gitt
138
139
  licenses:
metadata.gz.sig CHANGED
Binary file