README.md in refinements-6.2.2 vs README.md in refinements-6.3.0
- old
+ new
@@ -22,11 +22,13 @@
- [Requires](#requires)
- [Using](#using)
- [Examples](#examples)
- [Array](#array)
- [Big Decimal](#big-decimal)
+ - [File](#file)
- [Hash](#hash)
+ - [Pathname](#pathname)
- [String](#string)
- [Tests](#tests)
- [Versioning](#versioning)
- [Code of Conduct](#code-of-conduct)
- [Contributions](#contributions)
@@ -41,19 +43,25 @@
- Provides Array refinements:
- `#compress` - Removes `nil` and empty values without modifying itself.
- `#compress!` - Removes `nil` and empty values while modifying itself.
- Provides BigDecimal refinements:
- `#inspect` - Allows one to inspect a big decimal with numeric representation.
+- Provides File refinements:
+ - `.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.
- Provides Hash refinements:
- `#except` - Answers new hash with given keys removed without modifying calling hash.
- `#except!` - Answers new hash with given keys removed while modifying calling hash.
- `#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.
- `#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.
+- Provides Pathname refinements:
+ - `#rewrite` - When given a block, it provides the contents of the recently read file for
+ manipulation and immediate writing back to the same file.
- Provides String refinements:
- `#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`).
@@ -90,23 +98,25 @@
...then require the specific refinement, as needed. Example:
require "refinements/arrays"
require "refinements/big_decimals"
+ require "refinements/files"
require "refinements/hashes"
- require "refinements/objects"
+ require "refinements/pathnames"
require "refinements/strings"
### Using
Much like including/extending a module, you'll need modify your object(s) to use the refinement(s):
class Example
using Refinements::Arrays
using Refinements::BigDecimals
+ using Refinements::Files
using Refinements::Hashes
- using Refinements::Objects
+ using Refinements::Pathnames
using Refinements::Strings
end
### Examples
@@ -122,13 +132,16 @@
example.compress! # => ["An", "Example"]
example # => ["An", "Example"]
#### Big Decimal
- big = BigDecimal.new "5.0E-10"
- big.inspect # => "#<BigDecimal:3fd3d458fe84 0.0000000005>"
+ BigDecimal.new("5.0E-10").inspect # => "#<BigDecimal:3fd3d458fe84 0.0000000005>"
+#### File
+
+ File.rewrite("/test.txt") { |content| content.gsub "[placeholder]", "example" }
+
#### Hash
example = {a: 1, b: 2, c: 3}
example.except :a, :b # => {c: 3}
example # => {a: 1, b: 2, c: 3}
@@ -169,9 +182,13 @@
example.reverse_merge! a: 0, c: 3 # => {a: 1, b: 2, c: 3}
example # => {a: 1, b: 2, c: 3}
example = {unit: "221B", street: "Baker Street", city: "London", country: "UK"}
example.use { |unit, street| "#{unit} #{street}" } # => "221B Baker Street"
+
+#### Pathname
+
+ Pathname("/test.txt").rewrite { |content| content.sub "[placeholder]", "example" }
#### String
"example".first # => "e"
"example".first 4 # => "exam"