README.adoc in refinements-7.4.0 vs README.adoc in refinements-7.5.0
- old
+ new
@@ -25,37 +25,39 @@
** `.utc` - Answers new DateTime object for current UTC date/time.
* *Files*:
** `#rewrite` - When given a file path and a block, it provides the contents of the recently read
file for manipulation and immediate writing back to the same file.
* *Hashes*:
-** `#except` - Answers new hash with given keys removed without modifying calling hash.
-** `#except!` - Answers new hash with given keys removed while modifying calling hash.
+** `#except` - Answers new hash with given keys removed without modifying itself.
+** `#except!` - Answers new hash with given keys removed while modifying itself.
** `#symbolize_keys` - Converts keys to symbols without modifying itself.
** `#symbolize_keys!` - Converts keys to symbols while modifying itself.
** `#deep_merge` - Merges deeply nested hashes together without modifying itself.
** `#deep_merge!` - Merges deeply nested hashes together while modifying itself.
** `#deep_symbolize_keys` - Symbolizes keys of nested hash without modifying itself. Does not handle
nested arrays, though.
** `#deep_symbolize_keys!` - Symbolizes keys of nested hash while modifying itself. Does not handle
nested arrays, though.
** `#recurse` - Applies block to nested hash. Does not handle nested arrays, though.
-** `#rekey` - Transforms keys per mapping (size of mapping can vary).
-** `#reverse_merge` - Merges calling hash into passed in hash without modifying calling hash.
-** `#reverse_merge!` - Merges calling hash into passed in hash while modifying calling hash.
+** `#rekey` - Transforms keys per mapping (size of mapping can vary) without modifying itself.
+** `#rekey!` - Transforms keys per mapping (size of mapping can vary) while modifying itself.
+** `#reverse_merge` - Merges calling hash into passed in hash without modifying itself.
+** `#reverse_merge!` - Merges calling hash into passed in hash while modifying itself.
** `#use` - Passes each hash value as a block argument for further processing.
* *Pathnames*:
+** `Pathname` - Conversion function (refined from `Kernel`) which can cast `nil` into a pathname.
** `#name` - Answers file name without extension.
** `#copy` - Copies file from current location to new location.
** `#directories` - Answers all or filtered directories for current path.
** `#extensions` - Answers file extensions as an array.
** `#files` - Answers all or filtered files for current path.
** `#relative_parent_from` - Answers relative path from parent directory. This is a complement to
`#relative_path_from`.
** `#make_ancestors` - Ensures all ancestor directories are created for a path.
** `#rewrite` - When given a block, it provides the contents of the recently read file for
manipulation and immediate writing back to the same file.
-** `#touch` - Updates access and modification times to current time for path.
+** `#touch` - Updates access and modification times for path. Defaults to current time.
* *Strings*:
** `#first` - Answers first character of a string or first set of characters if given a number.
** `#last` - Answers last character of a string or last set of characters if given a number.
** `#blank?` - Answers `true`/`false` based on whether string is blank or not
(i.e. `<space>`, `\n`, `\t`, `\r`).
@@ -67,12 +69,12 @@
** `#to_bool` - Answers string as a boolean.
== Requirements
. https://www.ruby-lang.org[Ruby 2.7.x].
-. A solid understanding of https://www.youtube.com/watch?v=qXC9Gk4dCEw[Ruby refinements and lexical
-scope].
+. A solid understanding of link:https://www.alchemists.io/articles/ruby_refinements[Ruby refinements
+ and lexical scope].
== Setup
=== Production
@@ -242,11 +244,16 @@
example.recurse(&:symbolize_keys) # => {a: {b: 1}}
example.recurse(&:invert) # => {{"b" => 1} => "a"}
example = {a: 1, b: 2, c: 3}
example.rekey a: :amber, b: :blue # => {amber: 1, blue: 2, c: 3}
+example # => {a: 1, b: 2, c: 3}
+example = {a: 1, b: 2, c: 3}
+example.rekey! a: :amber, b: :blue # => {amber: 1, blue: 2, c: 3}
+example # => {amber: 1, blue: 2, c: 3}
+
example = {a: 1, b: 2}
example.reverse_merge a: 0, c: 3 # => {a: 1, b: 2, c: 3}
example # => {a: 1, b: 2}
example = {a: 1, b: 2}
@@ -259,10 +266,12 @@
==== Pathname
[source,ruby]
----
+Pathname(nil) # => Pathname("")
+
Pathname("example.txt").name # => Pathname("example")
Pathname("input.txt").copy Pathname("output.txt")
Pathname("/example").directories # => [Pathname("a"), Pathname("b")]
@@ -280,10 +289,10 @@
Pathname("/one/two").exist? # => false
Pathname("/test.txt").rewrite { |content| content.sub "[placeholder]", "example" }
Pathname("example.txt").touch
-Pathname("example.txt").touch accessed_at: Time.now - 1, modified_at: Time.now - 1
+Pathname("example.txt").touch at: Time.now - 1
----
==== String
[source,ruby]