dry-files 1.0.1 → 1.0.2
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/CHANGELOG.md +10 -0
- data/LICENSE +1 -1
- data/README.md +4 -12
- data/lib/dry/files/version.rb +1 -1
- data/lib/dry/files.rb +30 -5
- 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: 3b415a307ce621ab6601397d6cf2a772ef390210e1591b99f5ab40ccedac6108
|
4
|
+
data.tar.gz: c63b4c80401dccba0c095fa5a26d1b25c4e50d00f71978037e22b481a384c7db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c4b93220b78ec92f7224d9d033d5055b0be5f5f34fc9e187227e3d5c8198f9b9f1e02316295525d04a47709dc3614c40d30e9d43d68f6bbaaaf69f27f442f47c
|
7
|
+
data.tar.gz: 7cf2972a9be4e35dfc2babaa8bfd3ad8f0ee5646c69b397eb6a334baba97c906d17e7a28177229814eacb99b84839062bdda0a2f5972778f8f498f911ede3d61
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
<!--- DO NOT EDIT THIS FILE - IT'S AUTOMATICALLY GENERATED VIA DEVTOOLS --->
|
2
2
|
|
3
|
+
## 1.0.2 2023-10-03
|
4
|
+
|
5
|
+
|
6
|
+
### Fixed
|
7
|
+
|
8
|
+
- Ensure Dry::Files#inject_line_at_block_bottom to not match false positive closing blocks (@jodosha in #17)
|
9
|
+
|
10
|
+
|
11
|
+
[Compare v1.0.1...v1.0.2](https://github.com/dry-rb/dry-files/compare/v1.0.1...v1.0.2)
|
12
|
+
|
3
13
|
## 1.0.1 2022-11-21
|
4
14
|
|
5
15
|
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,29 +1,21 @@
|
|
1
1
|
<!--- this file is synced from dry-rb/template-gem project -->
|
2
2
|
[gem]: https://rubygems.org/gems/dry-files
|
3
3
|
[actions]: https://github.com/dry-rb/dry-files/actions
|
4
|
-
[codacy]: https://www.codacy.com/gh/dry-rb/dry-files
|
5
|
-
[chat]: https://dry-rb.zulipchat.com
|
6
|
-
[inchpages]: http://inch-ci.org/github/dry-rb/dry-files
|
7
4
|
|
8
|
-
# dry-files [][gem]
|
11
|
-
[][actions]
|
12
|
-
[][codacy]
|
13
|
-
[][codacy]
|
14
|
-
[][inchpages]
|
5
|
+
# dry-files [][gem] [][actions]
|
15
6
|
|
16
7
|
## Links
|
17
8
|
|
18
9
|
* [User documentation](https://dry-rb.org/gems/dry-files)
|
19
10
|
* [API documentation](http://rubydoc.info/gems/dry-files)
|
11
|
+
* [Forum](https://discourse.dry-rb.org)
|
20
12
|
|
21
13
|
## Supported Ruby versions
|
22
14
|
|
23
15
|
This library officially supports the following Ruby versions:
|
24
16
|
|
25
|
-
* MRI `>=
|
26
|
-
* jruby `>= 9.
|
17
|
+
* MRI `>= 3.0.0`
|
18
|
+
* jruby `>= 9.4` (not tested on CI)
|
27
19
|
|
28
20
|
## License
|
29
21
|
|
data/lib/dry/files/version.rb
CHANGED
data/lib/dry/files.rb
CHANGED
@@ -841,6 +841,11 @@ module Dry
|
|
841
841
|
# @since 0.3.0
|
842
842
|
# @api private
|
843
843
|
class Delimiter
|
844
|
+
# @since 1.0.2
|
845
|
+
# @api private
|
846
|
+
SPACE_MATCHER_GENERAL = /[[:space:]]*/
|
847
|
+
private_constant :SPACE_MATCHER_GENERAL
|
848
|
+
|
844
849
|
# @since 0.3.0
|
845
850
|
# @api private
|
846
851
|
attr_reader :opening, :closing
|
@@ -853,6 +858,26 @@ module Dry
|
|
853
858
|
@closing = closing
|
854
859
|
freeze
|
855
860
|
end
|
861
|
+
|
862
|
+
# @since 1.0.2
|
863
|
+
# @api private
|
864
|
+
def opening_matcher
|
865
|
+
matcher(opening)
|
866
|
+
end
|
867
|
+
|
868
|
+
# @since 1.0.2
|
869
|
+
# @api private
|
870
|
+
def closing_matcher
|
871
|
+
matcher(closing)
|
872
|
+
end
|
873
|
+
|
874
|
+
private
|
875
|
+
|
876
|
+
# @since 1.0.2
|
877
|
+
# @api private
|
878
|
+
def matcher(delimiter)
|
879
|
+
/#{SPACE_MATCHER_GENERAL}\b#{delimiter}\b(?:#{SPACE_MATCHER_GENERAL}|#{NEW_LINE_MATCHER})/
|
880
|
+
end
|
856
881
|
end
|
857
882
|
|
858
883
|
# @since 0.1.0
|
@@ -862,12 +887,12 @@ module Dry
|
|
862
887
|
|
863
888
|
# @since 0.3.0
|
864
889
|
# @api private
|
865
|
-
NEW_LINE_MATCHER = /#{NEW_LINE}\z
|
890
|
+
NEW_LINE_MATCHER = /#{NEW_LINE}\z/
|
866
891
|
private_constant :NEW_LINE_MATCHER
|
867
892
|
|
868
893
|
# @since 0.3.0
|
869
894
|
# @api private
|
870
|
-
EMPTY_LINE = /\A\z
|
895
|
+
EMPTY_LINE = /\A\z/
|
871
896
|
private_constant :EMPTY_LINE
|
872
897
|
|
873
898
|
# @since 0.1.0
|
@@ -887,7 +912,7 @@ module Dry
|
|
887
912
|
|
888
913
|
# @since 0.1.0
|
889
914
|
# @api private
|
890
|
-
SPACE_MATCHER = /\A[[:space:]]
|
915
|
+
SPACE_MATCHER = /\A[[:space:]]*/
|
891
916
|
private_constant :SPACE_MATCHER
|
892
917
|
|
893
918
|
# @since 0.3.0
|
@@ -967,9 +992,9 @@ module Dry
|
|
967
992
|
# @since 0.3.0
|
968
993
|
# @api private
|
969
994
|
def closing_block_index(content, starting, path, target, delimiter, count_offset = 0) # rubocop:disable Metrics/ParameterLists
|
970
|
-
blocks_count = content.count { |line| line.match?(delimiter.
|
995
|
+
blocks_count = content.count { |line| line.match?(delimiter.opening_matcher) } + count_offset
|
971
996
|
matching_line = content.find do |line|
|
972
|
-
blocks_count -= 1 if line.match?(delimiter.
|
997
|
+
blocks_count -= 1 if line.match?(delimiter.closing_matcher)
|
973
998
|
line if blocks_count.zero?
|
974
999
|
end
|
975
1000
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dry-files
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luca Guidi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -67,7 +67,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
requirements: []
|
70
|
-
rubygems_version: 3.
|
70
|
+
rubygems_version: 3.3.26
|
71
71
|
signing_key:
|
72
72
|
specification_version: 4
|
73
73
|
summary: file utilities
|