pleasant_path 2.0.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile +3 -2
- data/README.md +71 -81
- data/lib/pleasant_path/json/object.rb +4 -5
- data/lib/pleasant_path/json/pathname.rb +1 -1
- data/lib/pleasant_path/version.rb +1 -1
- data/lib/pleasant_path/yaml/pathname.rb +2 -2
- data/pleasant_path.gemspec +5 -4
- metadata +20 -13
- data/.gitignore +0 -9
- data/.travis.yml +0 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5e772187275bf4dea8ba22a68a973e127586a5b9c212cd47bfcf38269c8c5f66
|
|
4
|
+
data.tar.gz: 59e4a89da059811da874ed435c8b060e4fab05ce22765a7bf3c3a122063e7edd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0f23bc5959b08ea5bd2a803ccf42379ce9229d6ab6624c8b2c2f7d287d18861e9b868c5e232fd703fc8a759381a4a1b69851efc2341293ec90fee7c61ab2818a
|
|
7
|
+
data.tar.gz: 6a98f6d9ba1f9b2cba59623b3124deb7b978eb63e0fe9e37b45930541feae2cba04113e1cae4cfcbc102dbecc5212736be218de396ddf4f79805b3c61971f8f6
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
# pleasant_path
|
|
1
|
+
# pleasant_path
|
|
2
2
|
|
|
3
|
-
A [fluent API] for pleasant file IO, written as extensions to core
|
|
4
|
-
objects. See API listing below, or browse the [full documentation].
|
|
3
|
+
A [fluent API][] for pleasant file IO, written as extensions to core
|
|
4
|
+
Ruby objects. See API listing below, or browse the [full documentation][].
|
|
5
5
|
|
|
6
6
|
[fluent API]: https://en.wikipedia.org/wiki/Fluent_interface
|
|
7
7
|
[full documentation]: https://www.rubydoc.info/gems/pleasant_path/
|
|
@@ -22,68 +22,68 @@ objects. See API listing below, or browse the [full documentation].
|
|
|
22
22
|
|
|
23
23
|
The following methods are available:
|
|
24
24
|
|
|
25
|
-
- [Pathname](https://www.rubydoc.info/gems/pleasant_path/Pathname)
|
|
26
|
-
- [
|
|
27
|
-
- [
|
|
28
|
-
- [
|
|
29
|
-
- [
|
|
30
|
-
- [
|
|
31
|
-
- [
|
|
32
|
-
- [
|
|
33
|
-
- [
|
|
34
|
-
- [
|
|
35
|
-
- [
|
|
36
|
-
- [
|
|
37
|
-
- [
|
|
38
|
-
- [
|
|
39
|
-
- [
|
|
40
|
-
- [
|
|
41
|
-
- [
|
|
42
|
-
- [
|
|
43
|
-
- [
|
|
44
|
-
- [
|
|
45
|
-
- [
|
|
46
|
-
- [
|
|
47
|
-
- [
|
|
48
|
-
- [
|
|
49
|
-
- [
|
|
50
|
-
- [
|
|
51
|
-
- [
|
|
52
|
-
- [
|
|
53
|
-
- [
|
|
54
|
-
- [
|
|
55
|
-
- [
|
|
56
|
-
- [
|
|
57
|
-
- [
|
|
58
|
-
- [
|
|
59
|
-
- [
|
|
60
|
-
- [
|
|
61
|
-
- [String](https://www.rubydoc.info/gems/pleasant_path/String)
|
|
62
|
-
- [
|
|
63
|
-
- [
|
|
64
|
-
- [
|
|
65
|
-
- [
|
|
66
|
-
- [
|
|
67
|
-
- [Enumerable](https://www.rubydoc.info/gems/pleasant_path/Enumerable)
|
|
68
|
-
- [
|
|
69
|
-
- [
|
|
70
|
-
- [File](https://www.rubydoc.info/gems/pleasant_path/File)
|
|
71
|
-
- [
|
|
72
|
-
- [
|
|
73
|
-
- [
|
|
74
|
-
- [IO](https://www.rubydoc.info/gems/pleasant_path/IO)
|
|
75
|
-
- [
|
|
76
|
-
- [
|
|
25
|
+
- [`Pathname`](https://www.rubydoc.info/gems/pleasant_path/Pathname)
|
|
26
|
+
- [`::NULL`](https://www.rubydoc.info/gems/pleasant_path/Pathname#NULL-constant)
|
|
27
|
+
- [`#^`](https://www.rubydoc.info/gems/pleasant_path/Pathname:%5E)
|
|
28
|
+
- [`#append_file`](https://www.rubydoc.info/gems/pleasant_path/Pathname:append_file)
|
|
29
|
+
- [`#append_lines`](https://www.rubydoc.info/gems/pleasant_path/Pathname:append_lines)
|
|
30
|
+
- [`#append_text`](https://www.rubydoc.info/gems/pleasant_path/Pathname:append_text)
|
|
31
|
+
- [`#available_name`](https://www.rubydoc.info/gems/pleasant_path/Pathname:available_name)
|
|
32
|
+
- [`#chdir`](https://www.rubydoc.info/gems/pleasant_path/Pathname:chdir)
|
|
33
|
+
- [`#common_path`](https://www.rubydoc.info/gems/pleasant_path/Pathname:common_path)
|
|
34
|
+
- [`#copy`](https://www.rubydoc.info/gems/pleasant_path/Pathname:copy)
|
|
35
|
+
- [`#copy_as`](https://www.rubydoc.info/gems/pleasant_path/Pathname:copy_as)
|
|
36
|
+
- [`#copy_into`](https://www.rubydoc.info/gems/pleasant_path/Pathname:copy_into)
|
|
37
|
+
- [`#delete!`](https://www.rubydoc.info/gems/pleasant_path/Pathname:delete%21)
|
|
38
|
+
- [`#dir?`](https://www.rubydoc.info/gems/pleasant_path/Pathname:dir%3F)
|
|
39
|
+
- [`#dirs`](https://www.rubydoc.info/gems/pleasant_path/Pathname:dirs)
|
|
40
|
+
- [`#dirs_r`](https://www.rubydoc.info/gems/pleasant_path/Pathname:dirs_r)
|
|
41
|
+
- [`#edit_lines`](https://www.rubydoc.info/gems/pleasant_path/Pathname:edit_lines)
|
|
42
|
+
- [`#edit_text`](https://www.rubydoc.info/gems/pleasant_path/Pathname:edit_text)
|
|
43
|
+
- [`#existence`](https://www.rubydoc.info/gems/pleasant_path/Pathname:existence)
|
|
44
|
+
- [`#files`](https://www.rubydoc.info/gems/pleasant_path/Pathname:files)
|
|
45
|
+
- [`#files_r`](https://www.rubydoc.info/gems/pleasant_path/Pathname:files_r)
|
|
46
|
+
- [`#find_dirs`](https://www.rubydoc.info/gems/pleasant_path/Pathname:find_dirs)
|
|
47
|
+
- [`#find_files`](https://www.rubydoc.info/gems/pleasant_path/Pathname:find_files)
|
|
48
|
+
- [`#make_dir`](https://www.rubydoc.info/gems/pleasant_path/Pathname:make_dir)
|
|
49
|
+
- [`#make_dirname`](https://www.rubydoc.info/gems/pleasant_path/Pathname:make_dirname)
|
|
50
|
+
- [`#make_file`](https://www.rubydoc.info/gems/pleasant_path/Pathname:make_file)
|
|
51
|
+
- [`#move`](https://www.rubydoc.info/gems/pleasant_path/Pathname:move)
|
|
52
|
+
- [`#move_as`](https://www.rubydoc.info/gems/pleasant_path/Pathname:move_as)
|
|
53
|
+
- [`#move_into`](https://www.rubydoc.info/gems/pleasant_path/Pathname:move_into)
|
|
54
|
+
- [`#parentname`](https://www.rubydoc.info/gems/pleasant_path/Pathname:parentname)
|
|
55
|
+
- [`#read_lines`](https://www.rubydoc.info/gems/pleasant_path/Pathname:read_lines)
|
|
56
|
+
- [`#rename_basename`](https://www.rubydoc.info/gems/pleasant_path/Pathname:rename_basename)
|
|
57
|
+
- [`#rename_extname`](https://www.rubydoc.info/gems/pleasant_path/Pathname:rename_extname)
|
|
58
|
+
- [`#to_pathname`](https://www.rubydoc.info/gems/pleasant_path/Pathname:to_pathname)
|
|
59
|
+
- [`#write_lines`](https://www.rubydoc.info/gems/pleasant_path/Pathname:write_lines)
|
|
60
|
+
- [`#write_text`](https://www.rubydoc.info/gems/pleasant_path/Pathname:write_text)
|
|
61
|
+
- [`String`](https://www.rubydoc.info/gems/pleasant_path/String)
|
|
62
|
+
- [`#/`](https://www.rubydoc.info/gems/pleasant_path/String:%2F)
|
|
63
|
+
- [`#append_to_file`](https://www.rubydoc.info/gems/pleasant_path/String:append_to_file)
|
|
64
|
+
- [`#path`](https://www.rubydoc.info/gems/pleasant_path/String:path)
|
|
65
|
+
- [`#to_pathname`](https://www.rubydoc.info/gems/pleasant_path/String:to_pathname)
|
|
66
|
+
- [`#write_to_file`](https://www.rubydoc.info/gems/pleasant_path/String:write_to_file)
|
|
67
|
+
- [`Enumerable`](https://www.rubydoc.info/gems/pleasant_path/Enumerable)
|
|
68
|
+
- [`#append_to_file`](https://www.rubydoc.info/gems/pleasant_path/Enumerable:append_to_file)
|
|
69
|
+
- [`#write_to_file`](https://www.rubydoc.info/gems/pleasant_path/Enumerable:write_to_file)
|
|
70
|
+
- [`File`](https://www.rubydoc.info/gems/pleasant_path/File)
|
|
71
|
+
- [`.common_path`](https://www.rubydoc.info/gems/pleasant_path/File.common_path)
|
|
72
|
+
- [`.edit_lines`](https://www.rubydoc.info/gems/pleasant_path/File.edit_lines)
|
|
73
|
+
- [`.edit_text`](https://www.rubydoc.info/gems/pleasant_path/File.edit_text)
|
|
74
|
+
- [`IO`](https://www.rubydoc.info/gems/pleasant_path/IO)
|
|
75
|
+
- [`#read_lines`](https://www.rubydoc.info/gems/pleasant_path/IO:read_lines)
|
|
76
|
+
- [`#write_lines`](https://www.rubydoc.info/gems/pleasant_path/IO:write_lines)
|
|
77
77
|
|
|
78
78
|
|
|
79
79
|
## JSON-related and YAML-related API
|
|
80
80
|
|
|
81
|
-
|
|
82
|
-
files, using the [JSON module] and [YAML module] that are part of
|
|
83
|
-
standard library. Because Ruby does not load these modules by
|
|
84
|
-
|
|
85
|
-
default either. To load these
|
|
86
|
-
standard library modules, use:
|
|
81
|
+
`pleasant_path` also includes methods for interacting with JSON and YAML
|
|
82
|
+
files, using the [JSON module][] and [YAML module][] that are part of
|
|
83
|
+
Ruby's standard library. Because Ruby does not load these modules by
|
|
84
|
+
default, `pleasant_path` does not load its JSON-related and YAML-related
|
|
85
|
+
API by default either. To load these `pleasant_path` APIs **and** the
|
|
86
|
+
relevant standard library modules, use:
|
|
87
87
|
|
|
88
88
|
```ruby
|
|
89
89
|
require "pleasant_path/json"
|
|
@@ -95,29 +95,19 @@ require "pleasant_path/yaml"
|
|
|
95
95
|
|
|
96
96
|
The following methods are available:
|
|
97
97
|
|
|
98
|
-
- Object
|
|
99
|
-
- [write_to_json](https://www.rubydoc.info/gems/pleasant_path/Object:write_to_json)
|
|
100
|
-
- [write_to_yaml](https://www.rubydoc.info/gems/pleasant_path/Object:write_to_yaml)
|
|
101
|
-
- Pathname
|
|
102
|
-
- [load_json](https://www.rubydoc.info/gems/pleasant_path/Pathname:load_json)
|
|
103
|
-
- [load_yaml](https://www.rubydoc.info/gems/pleasant_path/Pathname:load_yaml)
|
|
104
|
-
- [read_json](https://www.rubydoc.info/gems/pleasant_path/Pathname:read_json)
|
|
105
|
-
- [read_yaml](https://www.rubydoc.info/gems/pleasant_path/Pathname:read_yaml)
|
|
98
|
+
- `Object`
|
|
99
|
+
- [`write_to_json`](https://www.rubydoc.info/gems/pleasant_path/Object:write_to_json)
|
|
100
|
+
- [`write_to_yaml`](https://www.rubydoc.info/gems/pleasant_path/Object:write_to_yaml)
|
|
101
|
+
- `Pathname`
|
|
102
|
+
- [`load_json`](https://www.rubydoc.info/gems/pleasant_path/Pathname:load_json)
|
|
103
|
+
- [`load_yaml`](https://www.rubydoc.info/gems/pleasant_path/Pathname:load_yaml)
|
|
104
|
+
- [`read_json`](https://www.rubydoc.info/gems/pleasant_path/Pathname:read_json)
|
|
105
|
+
- [`read_yaml`](https://www.rubydoc.info/gems/pleasant_path/Pathname:read_yaml)
|
|
106
106
|
|
|
107
107
|
|
|
108
108
|
## Installation
|
|
109
109
|
|
|
110
|
-
Install the [gem](https://rubygems.org/gems/pleasant_path)
|
|
111
|
-
|
|
112
|
-
```bash
|
|
113
|
-
$ gem install pleasant_path
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
Then require in your Ruby code:
|
|
117
|
-
|
|
118
|
-
```ruby
|
|
119
|
-
require "pleasant_path"
|
|
120
|
-
```
|
|
110
|
+
Install the [`pleasant_path` gem](https://rubygems.org/gems/pleasant_path).
|
|
121
111
|
|
|
122
112
|
|
|
123
113
|
## Contributing
|
|
@@ -127,4 +117,4 @@ Run `rake test` to run the tests.
|
|
|
127
117
|
|
|
128
118
|
## License
|
|
129
119
|
|
|
130
|
-
[MIT License](
|
|
120
|
+
[MIT License](LICENSE.txt)
|
|
@@ -7,9 +7,9 @@ class Object
|
|
|
7
7
|
#
|
|
8
8
|
# For information about +options+ see
|
|
9
9
|
# {https://docs.ruby-lang.org/en/master/JSON.html#method-i-generate
|
|
10
|
-
# +JSON.generate+}. By default, this method uses
|
|
11
|
-
# {https://docs.ruby-lang.org/en/master/JSON.html#
|
|
12
|
-
# +JSON.
|
|
10
|
+
# +JSON.generate+}. By default, this method uses the default options
|
|
11
|
+
# for {https://docs.ruby-lang.org/en/master/JSON.html#method-i-dump
|
|
12
|
+
# +JSON.dump+}.
|
|
13
13
|
#
|
|
14
14
|
# @example
|
|
15
15
|
# { "key" => "value" }.write_to_json("file.json") # == { "key" => "value" }
|
|
@@ -19,8 +19,7 @@ class Object
|
|
|
19
19
|
# @param options [Hash{Symbol => Object}]
|
|
20
20
|
# @return [self]
|
|
21
21
|
def write_to_json(file, options = {})
|
|
22
|
-
|
|
23
|
-
file.to_pathname.write_text(self.to_json(options))
|
|
22
|
+
file.to_pathname.write_text(JSON.dump(self, nil, nil, options))
|
|
24
23
|
self
|
|
25
24
|
end
|
|
26
25
|
|
|
@@ -14,7 +14,7 @@ class Pathname
|
|
|
14
14
|
#
|
|
15
15
|
# @return [nil, true, false, Numeric, String, Array, Hash]
|
|
16
16
|
def read_yaml
|
|
17
|
-
|
|
17
|
+
YAML.safe_load_file(self)
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
# Reads the file indicated by the Pathname, and parses the contents as
|
|
@@ -31,7 +31,7 @@ class Pathname
|
|
|
31
31
|
#
|
|
32
32
|
# @return [Object]
|
|
33
33
|
def load_yaml
|
|
34
|
-
YAML.
|
|
34
|
+
YAML.unsafe_load_file(self)
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
end
|
data/pleasant_path.gemspec
CHANGED
|
@@ -6,21 +6,22 @@ Gem::Specification.new do |spec|
|
|
|
6
6
|
spec.authors = ["Jonathan Hefner"]
|
|
7
7
|
spec.email = ["jonathan@hefner.pro"]
|
|
8
8
|
|
|
9
|
-
spec.summary = %q{
|
|
9
|
+
spec.summary = %q{Fluent API for pleasant file IO}
|
|
10
10
|
spec.homepage = "https://github.com/jonathanhefner/pleasant_path"
|
|
11
11
|
spec.license = "MIT"
|
|
12
|
-
spec.required_ruby_version = ">=
|
|
12
|
+
spec.required_ruby_version = ">= 3.4"
|
|
13
13
|
|
|
14
|
-
spec.metadata["homepage_uri"] = spec.homepage
|
|
15
14
|
spec.metadata["source_code_uri"] = spec.homepage
|
|
16
15
|
spec.metadata["changelog_uri"] = spec.metadata["source_code_uri"] + "/blob/master/CHANGELOG.md"
|
|
17
16
|
|
|
18
17
|
# Specify which files should be added to the gem when it is released.
|
|
19
18
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
20
19
|
spec.files = Dir.chdir(__dir__) do
|
|
21
|
-
`git ls-files -z`.split("\x0").reject { |f| f.
|
|
20
|
+
`git ls-files -z`.split("\x0").reject { |f| f.start_with?("test/", ".git") }
|
|
22
21
|
end
|
|
23
22
|
spec.bindir = "exe"
|
|
24
23
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
25
24
|
spec.require_paths = ["lib"]
|
|
25
|
+
|
|
26
|
+
spec.add_dependency "json", ">= 2.11"
|
|
26
27
|
end
|
metadata
CHANGED
|
@@ -1,24 +1,34 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pleasant_path
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 3.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jonathan Hefner
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
12
|
-
dependencies:
|
|
13
|
-
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: json
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - ">="
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '2.11'
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - ">="
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: '2.11'
|
|
14
26
|
email:
|
|
15
27
|
- jonathan@hefner.pro
|
|
16
28
|
executables: []
|
|
17
29
|
extensions: []
|
|
18
30
|
extra_rdoc_files: []
|
|
19
31
|
files:
|
|
20
|
-
- ".gitignore"
|
|
21
|
-
- ".travis.yml"
|
|
22
32
|
- CHANGELOG.md
|
|
23
33
|
- Gemfile
|
|
24
34
|
- LICENSE.txt
|
|
@@ -42,10 +52,8 @@ homepage: https://github.com/jonathanhefner/pleasant_path
|
|
|
42
52
|
licenses:
|
|
43
53
|
- MIT
|
|
44
54
|
metadata:
|
|
45
|
-
homepage_uri: https://github.com/jonathanhefner/pleasant_path
|
|
46
55
|
source_code_uri: https://github.com/jonathanhefner/pleasant_path
|
|
47
56
|
changelog_uri: https://github.com/jonathanhefner/pleasant_path/blob/master/CHANGELOG.md
|
|
48
|
-
post_install_message:
|
|
49
57
|
rdoc_options: []
|
|
50
58
|
require_paths:
|
|
51
59
|
- lib
|
|
@@ -53,15 +61,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
53
61
|
requirements:
|
|
54
62
|
- - ">="
|
|
55
63
|
- !ruby/object:Gem::Version
|
|
56
|
-
version: '
|
|
64
|
+
version: '3.4'
|
|
57
65
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
58
66
|
requirements:
|
|
59
67
|
- - ">="
|
|
60
68
|
- !ruby/object:Gem::Version
|
|
61
69
|
version: '0'
|
|
62
70
|
requirements: []
|
|
63
|
-
rubygems_version:
|
|
64
|
-
signing_key:
|
|
71
|
+
rubygems_version: 4.0.10
|
|
65
72
|
specification_version: 4
|
|
66
|
-
summary:
|
|
73
|
+
summary: Fluent API for pleasant file IO
|
|
67
74
|
test_files: []
|
data/.gitignore
DELETED