dry-files 1.0.2 → 1.1.0

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: 3b415a307ce621ab6601397d6cf2a772ef390210e1591b99f5ab40ccedac6108
4
- data.tar.gz: c63b4c80401dccba0c095fa5a26d1b25c4e50d00f71978037e22b481a384c7db
3
+ metadata.gz: 73391c6f7e4e115941911686c45307707e68fa4ba0f4be5a7cebba14d7eeb042
4
+ data.tar.gz: dcd71ad5b06891df556f0146f2520e4b981024afa06291016e56b194a4f1fb2e
5
5
  SHA512:
6
- metadata.gz: c4b93220b78ec92f7224d9d033d5055b0be5f5f34fc9e187227e3d5c8198f9b9f1e02316295525d04a47709dc3614c40d30e9d43d68f6bbaaaf69f27f442f47c
7
- data.tar.gz: 7cf2972a9be4e35dfc2babaa8bfd3ad8f0ee5646c69b397eb6a334baba97c906d17e7a28177229814eacb99b84839062bdda0a2f5972778f8f498f911ede3d61
6
+ metadata.gz: 392bfc69636d993cd92e8462079079ad000ef6ebe60467eee72d30f9e2726fc04705f05ada482cfe0147320abab56afd91b6b782b25e9f3a042c563590d589fd
7
+ data.tar.gz: 7c3a4723b89339db36f532f7579f6574c593864e6a79cecfc5cc382280d421338fdd2700c1edffb6fb83b5d917102a2c5be63306f2833c555d5250f0a8d9c1da
data/CHANGELOG.md CHANGED
@@ -1,11 +1,22 @@
1
1
  <!--- DO NOT EDIT THIS FILE - IT'S AUTOMATICALLY GENERATED VIA DEVTOOLS --->
2
2
 
3
+ ## 1.1.0 2023-10-18
4
+
5
+
6
+ ### Added
7
+
8
+ - Add `Dry::Files#chmod(path, mode)` to modify file permissions. Provide the mode as an integer
9
+ to match UNIX octal permissions, such as `0o755`. (@timriley in #18)
10
+
11
+
12
+ [Compare v1.0.2...v1.1.0](https://github.com/dry-rb/dry-files/compare/v1.0.2...v1.1.0)
13
+
3
14
  ## 1.0.2 2023-10-03
4
15
 
5
16
 
6
17
  ### Fixed
7
18
 
8
- - Ensure Dry::Files#inject_line_at_block_bottom to not match false positive closing blocks (@jodosha in #17)
19
+ - Ensure `Dry::Files#inject_line_at_block_bottom` to not match false positive closing blocks (@jodosha in #17)
9
20
 
10
21
 
11
22
  [Compare v1.0.1...v1.0.2](https://github.com/dry-rb/dry-files/compare/v1.0.1...v1.0.2)
@@ -131,6 +131,25 @@ module Dry
131
131
  end
132
132
  end
133
133
 
134
+ # Sets UNIX permissions of the file at the given path.
135
+ #
136
+ # Accepts permissions in numeric mode only, best provided as octal numbers matching the
137
+ # standard UNIX octal permission modes, such as `0o544` for a file writeable by its owner and
138
+ # readable by others, or `0o755` for a file writeable by its owner and executable by everyone.
139
+ #
140
+ # @param path [String,Pathname] the path to the file
141
+ # @param mode [Integer] the UNIX permissions mode
142
+ #
143
+ # @raise [Dry::Files::IOError] in case of I/O error
144
+ #
145
+ # @since 1.1.0
146
+ # @api private
147
+ def chmod(path, mode)
148
+ with_error_handling do
149
+ file_utils.chmod(mode, path)
150
+ end
151
+ end
152
+
134
153
  # Returns a new string formed by joining the strings using Operating
135
154
  # System path separator
136
155
  #
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Dry
4
4
  class Files
5
- VERSION = "1.0.2"
5
+ VERSION = "1.1.0"
6
6
  end
7
7
  end
data/lib/dry/files.rb CHANGED
@@ -82,6 +82,25 @@ module Dry
82
82
  adapter.write(path, *content)
83
83
  end
84
84
 
85
+ # Sets UNIX permissions of the file at the given path.
86
+ #
87
+ # Accepts permissions in numeric mode only, best provided as octal numbers matching the
88
+ # standard UNIX octal permission modes, such as `0o544` for a file writeable by its owner and
89
+ # readable by others, or `0o755` for a file writeable by its owner and executable by everyone.
90
+ #
91
+ # @param path [String,Pathname] the path to the file
92
+ # @param mode [Integer] the UNIX permissions mode
93
+ #
94
+ # @raise [Dry::Files::IOError] in case of I/O error
95
+ #
96
+ # @since 1.1.0
97
+ # @api public
98
+ def chmod(path, mode)
99
+ raise Dry::Files::Error, "mode should be an integer (e.g. 0o755)" unless mode.is_a?(Integer)
100
+
101
+ adapter.chmod(path, mode)
102
+ end
103
+
85
104
  # Returns a new string formed by joining the strings using Operating
86
105
  # System path separator
87
106
  #
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.2
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luca Guidi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-03 00:00:00.000000000 Z
11
+ date: 2023-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec