dry-files 1.0.0 → 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: b9b554d01289fcefe3eb4159a0d832a55544de168d9df3d68db65d017526debd
4
- data.tar.gz: cfe09c1716f6046421111bd848a81c9a0785b195f4a612c348c2054cdf6aa805
3
+ metadata.gz: 3b415a307ce621ab6601397d6cf2a772ef390210e1591b99f5ab40ccedac6108
4
+ data.tar.gz: c63b4c80401dccba0c095fa5a26d1b25c4e50d00f71978037e22b481a384c7db
5
5
  SHA512:
6
- metadata.gz: 2e6142b107d2deafc6bb1b98412fee75be75e05934e940fd8227abd8079cff9b4078d064a5e8ae90339b95a9852a189bab199d3ec5f4de5e6001e13b22be7cde
7
- data.tar.gz: 53abdcbd822a4dbc78dac59308454fe46738e21448d3faeca7eae8e80d6a0725b06f7d614c4e736bba0107719c45229765a16ea84b529aad3a4445d882859500
6
+ metadata.gz: c4b93220b78ec92f7224d9d033d5055b0be5f5f34fc9e187227e3d5c8198f9b9f1e02316295525d04a47709dc3614c40d30e9d43d68f6bbaaaf69f27f442f47c
7
+ data.tar.gz: 7cf2972a9be4e35dfc2babaa8bfd3ad8f0ee5646c69b397eb6a334baba97c906d17e7a28177229814eacb99b84839062bdda0a2f5972778f8f498f911ede3d61
data/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
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
+
13
+ ## 1.0.1 2022-11-21
14
+
15
+
16
+ ### Fixed
17
+
18
+ - Do not introduce multiple newlines in `Dry::Files#append` (@timriley in #14)
19
+
20
+
21
+ [Compare v1.0.0...v1.0.1](https://github.com/dry-rb/dry-files/compare/v1.0.0...v1.0.1)
22
+
3
23
  ## 1.0.0 2022-11-04
4
24
 
5
25
 
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.0"
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
@@ -933,6 +958,8 @@ module Dry
933
958
  # @since 0.1.0
934
959
  # @api private
935
960
  def newline(line = nil)
961
+ return line if line.to_s.end_with?(NEW_LINE)
962
+
936
963
  "#{line}#{NEW_LINE}"
937
964
  end
938
965
 
@@ -965,9 +992,9 @@ module Dry
965
992
  # @since 0.3.0
966
993
  # @api private
967
994
  def closing_block_index(content, starting, path, target, delimiter, count_offset = 0) # rubocop:disable Metrics/ParameterLists
968
- blocks_count = content.count { |line| line.match?(delimiter.opening) } + count_offset
995
+ blocks_count = content.count { |line| line.match?(delimiter.opening_matcher) } + count_offset
969
996
  matching_line = content.find do |line|
970
- blocks_count -= 1 if line.match?(delimiter.closing)
997
+ blocks_count -= 1 if line.match?(delimiter.closing_matcher)
971
998
  line if blocks_count.zero?
972
999
  end
973
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.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: 2022-11-04 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