harri 0.1.3 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/lib/harri/processor.rb +6 -2
- data/lib/harri/regexes.rb +5 -3
- data/lib/harri/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97430acc5a2e12f35cf3ee43e6ec741a49b912a1f13bdfe41624815b698a82d1
|
4
|
+
data.tar.gz: 1a00e5d8695469dac07dc466924c4edf25942f76f0f580856f271b2e0750526c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ffdf0e148176ab1ec06a472a5b134ab52fd01b80e10b5ccc8b2ab1bc82d6d64c232c4e75097ca8e65cea321778ddddf636cd4d8b3d8f31569cfd72250e35c12f
|
7
|
+
data.tar.gz: 1b0b2d3b910d34f95d0fde81bf50efb6d3b4e391c99e2b5aac0181b2517e25ea5968a7b90f6ee9aaad53ff2cb79dc388adbce7d8627310297eb6e68f17ee812e
|
data/Gemfile.lock
CHANGED
data/lib/harri/processor.rb
CHANGED
@@ -15,12 +15,16 @@ module Harri
|
|
15
15
|
# There are no imports, so the whole module is redundant.
|
16
16
|
text.sub(/^#{Regexp.quote(match[0])}/, "")
|
17
17
|
else
|
18
|
+
module_imports = match[1]
|
19
|
+
return text if !module_imports
|
20
|
+
|
18
21
|
# Filter out specific imports within the module.
|
19
|
-
filtered_imports = import_info[:imports].reduce(
|
22
|
+
filtered_imports = import_info[:imports].reduce(module_imports) do |result, import|
|
20
23
|
reference_regex = Harri::Regexes.named_reference_regex import
|
21
24
|
result.sub reference_regex, ""
|
22
25
|
end
|
23
|
-
|
26
|
+
replaced_imports = match[0].sub module_imports, filtered_imports
|
27
|
+
text.sub match[0], replaced_imports
|
24
28
|
end
|
25
29
|
end
|
26
30
|
end
|
data/lib/harri/regexes.rb
CHANGED
@@ -36,15 +36,16 @@ module Harri
|
|
36
36
|
# Intended to capture a full import declaration within a Haskell module.
|
37
37
|
def self.import_declaration_regex(module_name)
|
38
38
|
%r{
|
39
|
-
^import # literal "import"
|
39
|
+
^import # literal "import" at start of line
|
40
40
|
\s+ # one or more spaces
|
41
41
|
(?:qualified\s*)? # zero or one literal "qualified" with optional space afterwards
|
42
|
-
#{Regexp.quote module_name} # match "
|
42
|
+
#{Regexp.quote module_name} # match "`module_name`"
|
43
|
+
(?!\S) # assert that the next character is not a non-whitespace character (see https://stackoverflow.com/a/18005390)
|
43
44
|
\s* # optional space
|
44
45
|
(?:qualified\s*)? # zero or one literal "qualified" with optional space afterwards
|
45
46
|
(?:as\s+[A-Z]+[a-zA-Z0-9.]*\s*)? # zero or one literal "as `module_name`" with optional space afterwards
|
46
47
|
(?:hiding\s*)? # zero or one literal "hiding" with optional space afterwards
|
47
|
-
(
|
48
|
+
((\((?>[^)(]+|\g<1>)*\)))? # zero or one list of imports (see https://stackoverflow.com/a/35271017)
|
48
49
|
\n? # zero or one linebreak
|
49
50
|
}x
|
50
51
|
end
|
@@ -53,6 +54,7 @@ module Harri
|
|
53
54
|
def self.named_reference_regex(reference)
|
54
55
|
%r{
|
55
56
|
\b#{Regexp.quote reference}\b # match "`reference`" exactly as a single word
|
57
|
+
(?:\s*\(\.\.\))? # zero or one instances of optional space followed by a literal "(..)"
|
56
58
|
(?:\s*,?)? # zero or one instances of optional space followed by zero or one comma
|
57
59
|
\s* # optional space
|
58
60
|
}x
|
data/lib/harri/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: harri
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- rhizomic
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-10-09 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: 'Harri: HAskell Remove Redundant Imports. A way to get GHC to stop harrying
|
14
14
|
you about them.'
|
@@ -56,7 +56,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
56
56
|
- !ruby/object:Gem::Version
|
57
57
|
version: '0'
|
58
58
|
requirements: []
|
59
|
-
rubygems_version: 3.
|
59
|
+
rubygems_version: 3.3.26
|
60
60
|
signing_key:
|
61
61
|
specification_version: 4
|
62
62
|
summary: Removes redundant Haskell imports.
|