gitt 3.8.1 → 3.10.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: 011f24d793d2565425982cb6eeb0d8efc3a9f954590bf86750495c6b97792873
4
- data.tar.gz: ee9f64d17e334f1aa6827c085fb1059b453209f4b5397e7ac400e598de18960e
3
+ metadata.gz: 12f315a5c9312ef9c1d0523e1bd20ceeb16bc3a3a116b07d42c0e9059216c788
4
+ data.tar.gz: 95c0533edb84a4e44e3199d64145e053afce604a19c9b490ea5a47c998039f8e
5
5
  SHA512:
6
- metadata.gz: efe9288bf28a4eac998226055f15bf1ddedeae39dbf4e95c77a6da23faedcd9a3c3b88d8a29db5d7cde1f60273e1bce6c6c2e0d0734964d14e520790b8463d0f
7
- data.tar.gz: '089f62916bc44d0634f408a111163bda264a13ad236ce8156484c096e5d595deae0b2c14466885d084647a3ac23d50a8005546e8f75b1d2847fd4b7239d2dcb5'
6
+ metadata.gz: 2499f6201d6b0d41a7be329a82972b3c80b032788f0e0ed9c7360a13b126a86e86064bb137fc332ec68cf6078e6aae699d22fb3999aa3279f29d049488540202
7
+ data.tar.gz: 10c9d7735ff3d8b4e85dd1e4aa341b461cf8609a5971fb7bcc1c60b57dacb368d5b331c84ba6715be0083e7e928701ebf25d22965d0ebab53088aa1eb10f5335
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.8.1"
5
+ spec.version = "3.10.0"
6
6
  spec.authors = ["Brooke Kuhlmann"]
7
7
  spec.email = ["brooke@alchemists.io"]
8
8
  spec.homepage = "https://alchemists.io/projects/gitt"
@@ -25,8 +25,8 @@ Gem::Specification.new do |spec|
25
25
  spec.required_ruby_version = ">= 3.3", "<= 3.4"
26
26
  spec.add_dependency "core", "~> 1.7"
27
27
  spec.add_dependency "dry-monads", "~> 1.6"
28
- spec.add_dependency "refinements", "~> 12.8"
29
- spec.add_dependency "zeitwerk", "~> 2.6"
28
+ spec.add_dependency "refinements", "~> 12.9"
29
+ spec.add_dependency "zeitwerk", "~> 2.7"
30
30
 
31
31
  spec.extra_rdoc_files = Dir["README*", "LICENSE*"]
32
32
  spec.files = Dir["*.gemspec", "lib/**/*"]
@@ -58,8 +58,8 @@ module Gitt
58
58
  attr_reader :shell, :key_map, :parser
59
59
 
60
60
  def pretty_format
61
- key_map.reduce("") { |string, (key, value)| string + "<#{key}>#{value}</#{key}>%n" }
62
- .then { |structure| %(--pretty=format:"#{structure}") }
61
+ key_map.reduce(+"") { |format, (key, value)| format << "<#{key}>#{value}</#{key}>%n" }
62
+ .then { |format| %(--pretty=format:"#{format}") }
63
63
  end
64
64
 
65
65
  def build_records entries
@@ -23,6 +23,7 @@ module Gitt
23
23
  sha: "%(objectname)",
24
24
  signature: "%(contents:signature)",
25
25
  subject: "%(subject)",
26
+ trailers: "%(trailers)",
26
27
  version: "%(refname)"
27
28
  }.freeze
28
29
 
@@ -88,7 +89,7 @@ module Gitt
88
89
  attr_reader :shell, :key_map, :parser
89
90
 
90
91
  def pretty_format
91
- key_map.reduce("") { |content, (key, value)| content + "<#{key}>#{value}</#{key}>%n" }
92
+ key_map.reduce(+"") { |format, (key, value)| format << "<#{key}>#{value}</#{key}>%n" }
92
93
  .then { |format| %(--format="#{format}") }
93
94
  end
94
95
 
@@ -32,30 +32,13 @@ module Gitt
32
32
  :trailers
33
33
  ) do
34
34
  include Directable
35
+ include Trailable
35
36
  include Dry::Monads[:result]
36
37
 
37
38
  def initialize(**)
38
39
  super
39
40
  freeze
40
41
  end
41
-
42
- def find_trailer key
43
- trailers.find { |trailer| trailer.key == key }
44
- .then do |trailer|
45
- return Success trailer if trailer
46
-
47
- Failure "Unable to find trailer for key: #{key.inspect}."
48
- end
49
- end
50
-
51
- def find_trailers key
52
- trailers.select { |trailer| trailer.key == key }
53
- .then { |trailers| Success trailers }
54
- end
55
-
56
- def trailer_value_for(key) = find_trailer(key).fmap(&:value)
57
-
58
- def trailer_values_for(key) = find_trailers(key).fmap { |trailers| trailers.map(&:value) }
59
42
  end
60
43
  end
61
44
  end
@@ -16,8 +16,11 @@ module Gitt
16
16
  :sha,
17
17
  :signature,
18
18
  :subject,
19
+ :trailers,
19
20
  :version
20
21
  ) do
22
+ include Trailable
23
+
21
24
  def initialize(**)
22
25
  super
23
26
  freeze
@@ -16,13 +16,16 @@ module Gitt
16
16
  @model = model
17
17
  end
18
18
 
19
+ # :reek:TooManyStatements
19
20
  def call content
20
21
  attributes = attributer.call content
21
- attributes.transform_with! author_email: email_sanitizer,
22
- authored_at: date_sanitizer,
23
- committed_at: date_sanitizer,
24
- committer_email: email_sanitizer,
25
- version: version_serializer
22
+ body, trailers = attributes.values_at :body, :trailers
23
+ sanitize attributes
24
+
25
+ attributes[:body] = (
26
+ trailers ? body.sub(/\n??#{Regexp.escape trailers}\n??/, "") : body
27
+ ).to_s.chomp
28
+
26
29
  model[**attributes]
27
30
  end
28
31
 
@@ -30,10 +33,21 @@ module Gitt
30
33
 
31
34
  attr_reader :attributer, :sanitizers, :model
32
35
 
36
+ def sanitize attributes
37
+ attributes.transform_with! author_email: email_sanitizer,
38
+ authored_at: date_sanitizer,
39
+ committed_at: date_sanitizer,
40
+ committer_email: email_sanitizer,
41
+ trailers: trailers_sanitizer,
42
+ version: version_serializer
43
+ end
44
+
33
45
  def date_sanitizer = sanitizers.fetch :date
34
46
 
35
47
  def email_sanitizer = sanitizers.fetch :email
36
48
 
49
+ def trailers_sanitizer = sanitizers.fetch :trailers
50
+
37
51
  def version_serializer = sanitizers.fetch :version
38
52
  end
39
53
  end
@@ -6,7 +6,7 @@ module Gitt
6
6
  date: Date,
7
7
  email: Email,
8
8
  lines: Lines,
9
- paragraphs: Paragraphs,
9
+ paragraphs: Paragraphs.new,
10
10
  scissors: Scissors,
11
11
  signature: Signature,
12
12
  statistic: Statistic.new,
@@ -1,9 +1,53 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "core"
4
+ require "refinements/array"
5
+ require "strscan"
4
6
 
5
7
  module Gitt
6
8
  module Sanitizers
7
- Paragraphs = -> text { text ? text.split("\n\n").map(&:chomp) : Core::EMPTY_ARRAY }
9
+ # Detects and parses paragraphs (including code blocks).
10
+ class Paragraphs
11
+ using Refinements::Array
12
+
13
+ PATTERN = /
14
+ ( # Condition start.
15
+ (?:\..*?\n)? # Optional ASCII Doc label.
16
+ (?:\[.*\]\n)? # Optional ASCII Doc directive.
17
+ [-_=+\.\*]{4} # ASCII Doc block start.
18
+ [\s\S]*? # Lazy block content of any character.
19
+ [-_=+\.\*]{4} # ASCII Doc block end.
20
+ | # Or.
21
+ ``` # Markdown start.
22
+ [\s\S]*? # Lazy block content of any character.
23
+ ``` # Markdown end.
24
+ ) # Condition end.
25
+ /mx
26
+
27
+ def initialize pattern: PATTERN, client: StringScanner
28
+ @pattern = pattern
29
+ @client = client
30
+ end
31
+
32
+ def call(text) = scan(client.new(text.to_s))
33
+
34
+ private
35
+
36
+ attr_reader :pattern, :client
37
+
38
+ # :reek:FeatureEnvy
39
+ def scan scanner, collection = []
40
+ until scanner.eos?
41
+ match = scanner.scan_until pattern
42
+
43
+ break collection << scanner.string[scanner.rest].tap(&:strip!).split("\n\n") unless match
44
+
45
+ collection << scanner.pre_match.strip
46
+ collection << scanner.captures
47
+ end
48
+
49
+ collection.tap(&:flatten!).tap(&:compress!)
50
+ end
51
+ end
8
52
  end
9
53
  end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Gitt
4
+ # Provides shared behavior for objects that have trailers.
5
+ module Trailable
6
+ def find_trailer key
7
+ trailers.find { |trailer| trailer.key == key }
8
+ .then do |trailer|
9
+ return Success trailer if trailer
10
+
11
+ Failure "Unable to find trailer for key: #{key.inspect}."
12
+ end
13
+ end
14
+
15
+ def find_trailers key
16
+ trailers.select { |trailer| trailer.key == key }
17
+ .then { |trailers| Success trailers }
18
+ end
19
+
20
+ def trailer_value_for(key) = find_trailer(key).fmap(&:value)
21
+
22
+ def trailer_values_for(key) = find_trailers(key).fmap { |trailers| trailers.map(&:value) }
23
+ end
24
+ 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.8.1
4
+ version: 3.10.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-09-04 00:00:00.000000000 Z
38
+ date: 2024-10-18 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: core
@@ -71,28 +71,28 @@ dependencies:
71
71
  requirements:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
- version: '12.8'
74
+ version: '12.9'
75
75
  type: :runtime
76
76
  prerelease: false
77
77
  version_requirements: !ruby/object:Gem::Requirement
78
78
  requirements:
79
79
  - - "~>"
80
80
  - !ruby/object:Gem::Version
81
- version: '12.8'
81
+ version: '12.9'
82
82
  - !ruby/object:Gem::Dependency
83
83
  name: zeitwerk
84
84
  requirement: !ruby/object:Gem::Requirement
85
85
  requirements:
86
86
  - - "~>"
87
87
  - !ruby/object:Gem::Version
88
- version: '2.6'
88
+ version: '2.7'
89
89
  type: :runtime
90
90
  prerelease: false
91
91
  version_requirements: !ruby/object:Gem::Requirement
92
92
  requirements:
93
93
  - - "~>"
94
94
  - !ruby/object:Gem::Version
95
- version: '2.6'
95
+ version: '2.7'
96
96
  description:
97
97
  email:
98
98
  - brooke@alchemists.io
@@ -135,6 +135,7 @@ files:
135
135
  - lib/gitt/sanitizers/trailers.rb
136
136
  - lib/gitt/sanitizers/version.rb
137
137
  - lib/gitt/shell.rb
138
+ - lib/gitt/trailable.rb
138
139
  homepage: https://alchemists.io/projects/gitt
139
140
  licenses:
140
141
  - Hippocratic-2.1
@@ -164,7 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
164
165
  - !ruby/object:Gem::Version
165
166
  version: '0'
166
167
  requirements: []
167
- rubygems_version: 3.5.18
168
+ rubygems_version: 3.5.21
168
169
  signing_key:
169
170
  specification_version: 4
170
171
  summary: A monadic Object API for the Git CLI.
metadata.gz.sig CHANGED
Binary file