harri 0.1.3 → 0.1.4
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 +2 -1
- data/lib/harri/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f97d86dc002eed2bd9e3d9664541fe54b16643a87b4080556c22a19db863036d
|
4
|
+
data.tar.gz: cfb2ed9c3443be16ebf105dbf91e9c2b0c9001390f7f4d30db73393827336011
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5f1aadedf04486fe4cd68ef5f26a8c91f929427af371439b42ff1fc66561854ee48d6cd135121dbbe4cb9a2401b2ead05d2b048b7524e55419ed2a1ac206fb2
|
7
|
+
data.tar.gz: 931469f5823707b7fd41e2da609f407e5328a2dc69d9fbc9a318c0c3b5b71f2dc271aa39263c080ef95076400db81930d0ff4e6ed9e69b3874f01501c4c906ad
|
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
@@ -44,7 +44,7 @@ module Harri
|
|
44
44
|
(?:qualified\s*)? # zero or one literal "qualified" with optional space afterwards
|
45
45
|
(?:as\s+[A-Z]+[a-zA-Z0-9.]*\s*)? # zero or one literal "as `module_name`" with optional space afterwards
|
46
46
|
(?:hiding\s*)? # zero or one literal "hiding" with optional space afterwards
|
47
|
-
(
|
47
|
+
((\((?>[^)(]+|\g<1>)*\)))? # zero or one list of imports (see https://stackoverflow.com/a/35271017)
|
48
48
|
\n? # zero or one linebreak
|
49
49
|
}x
|
50
50
|
end
|
@@ -53,6 +53,7 @@ module Harri
|
|
53
53
|
def self.named_reference_regex(reference)
|
54
54
|
%r{
|
55
55
|
\b#{Regexp.quote reference}\b # match "`reference`" exactly as a single word
|
56
|
+
(?:\s*\(\.\.\))? # zero or one instances of optional space followed by a literal "(..)"
|
56
57
|
(?:\s*,?)? # zero or one instances of optional space followed by zero or one comma
|
57
58
|
\s* # optional space
|
58
59
|
}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.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- rhizomic
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-10-16 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.'
|