dry-files 1.0.1 → 1.0.2

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: aeceff289982d160ec9a1687677a09ce2d204b4ee1c1f724361ebca4afbf2a5e
4
- data.tar.gz: b667c59ffa7e9b74f0a4fb2a63f1b8a8e1e4018f2ee150c310fd0e9fb1f82612
3
+ metadata.gz: 3b415a307ce621ab6601397d6cf2a772ef390210e1591b99f5ab40ccedac6108
4
+ data.tar.gz: c63b4c80401dccba0c095fa5a26d1b25c4e50d00f71978037e22b481a384c7db
5
5
  SHA512:
6
- metadata.gz: 4faeaa5354a10101957a33a1434ec943c872d06c5dc4ccffceec78cb905c70e322ce579537ec612de5f0796db4d6e85ddeabbb92269c9e17eed4cf8e1ced336a
7
- data.tar.gz: 510106844dbb56009e77c8c1570c8d83e55257d7f22cbbd5d4d351eae9ebe1dec76d4736049e84bc647467d222313922acf745b6ee1443284e632afdd263d2bd
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
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2015-2022 dry-rb team
3
+ Copyright (c) 2015-2023 dry-rb team
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of
6
6
  this software and associated documentation files (the "Software"), to deal in
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 [![Join the chat at https://dry-rb.zulipchat.com](https://img.shields.io/badge/dry--rb-join%20chat-%23346b7a.svg)][chat]
9
-
10
- [![Gem Version](https://badge.fury.io/rb/dry-files.svg)][gem]
11
- [![CI Status](https://github.com/dry-rb/dry-files/workflows/ci/badge.svg)][actions]
12
- [![Codacy Badge](https://api.codacy.com/project/badge/Grade/71200ee8d70b412c9e21c20b8b3b3688)][codacy]
13
- [![Codacy Badge](https://api.codacy.com/project/badge/Coverage/71200ee8d70b412c9e21c20b8b3b3688)][codacy]
14
- [![Inline docs](http://inch-ci.org/github/dry-rb/dry-files.svg?branch=main)][inchpages]
5
+ # dry-files [![Gem Version](https://badge.fury.io/rb/dry-files.svg)][gem] [![CI Status](https://github.com/dry-rb/dry-files/workflows/ci/badge.svg)][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 `>= 2.7.0`
26
- * jruby `>= 9.3` (postponed until 2.7 is supported)
17
+ * MRI `>= 3.0.0`
18
+ * jruby `>= 9.4` (not tested on CI)
27
19
 
28
20
  ## License
29
21
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Dry
4
4
  class Files
5
- VERSION = "1.0.1"
5
+ VERSION = "1.0.2"
6
6
  end
7
7
  end
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/.freeze
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/.freeze
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:]]*/.freeze
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.opening) } + count_offset
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.closing)
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.1
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: 2022-11-21 00:00:00.000000000 Z
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.1.6
70
+ rubygems_version: 3.3.26
71
71
  signing_key:
72
72
  specification_version: 4
73
73
  summary: file utilities