easy_yaml 0.1.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 +7 -0
- data/.github/workflows/greetings.yml +15 -0
- data/.github/workflows/linter.yml +24 -0
- data/.github/workflows/test.yml +21 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.rubocop.yml +52 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +53 -0
- data/LICENSE.md +21 -0
- data/README.md +109 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/easy_yaml.gemspec +37 -0
- data/lib/easy_yaml.rb +15 -0
- data/lib/easy_yaml/version.rb +3 -0
- data/lib/easy_yaml/yaml_loader.rb +49 -0
- metadata +121 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 10552999bc43d17b5f8a67665b526a67d2a1cdebdbdabd3aadb808645abf2bc7
|
|
4
|
+
data.tar.gz: 87011bc93c2a9ced9ab79ebc99b0673275dc65b3bb62fede53527a2861e3b00e
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 0c93c94a63cd3ce338238b960c1891599d6066caa988fa9f321f4c829f8b1600840482c67d240d02f6ec1cfb8fc5c09b5c15bd7a8a4a210d0bc68da0d05a3e9f
|
|
7
|
+
data.tar.gz: a09eca2e4194d13c067fbf8c086d923580f16f1fff2b69e4cde9032eeff81bda09abf74c0f6b8e09c93afbf5956c5a2e53712c47ae97b3b7eda8cedb46221f18
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
name: Greetings
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
- pull_request
|
|
5
|
+
- issues
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
greeting:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
steps:
|
|
11
|
+
- uses: actions/first-interaction@v1
|
|
12
|
+
with:
|
|
13
|
+
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
|
14
|
+
issue-message: "Thank you for creating your first issue on this repo! 🎉"
|
|
15
|
+
pr-message: "Thank you for creating your first pull request on this repo! 🎉"
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
on: [push]
|
|
2
|
+
|
|
3
|
+
name: Linter
|
|
4
|
+
|
|
5
|
+
jobs:
|
|
6
|
+
run:
|
|
7
|
+
runs-on: ubuntu-latest
|
|
8
|
+
|
|
9
|
+
steps:
|
|
10
|
+
- name: Set up Ruby 2.6
|
|
11
|
+
uses: actions/setup-ruby@v1
|
|
12
|
+
with:
|
|
13
|
+
ruby-version: '2.6.x'
|
|
14
|
+
|
|
15
|
+
- name: Checkout
|
|
16
|
+
uses: actions/checkout@master
|
|
17
|
+
|
|
18
|
+
- name: Install dependencies
|
|
19
|
+
run: |
|
|
20
|
+
gem install rubocop rubocop-performance rubocop-rspec --no-document
|
|
21
|
+
|
|
22
|
+
- name: Run linter
|
|
23
|
+
run: |
|
|
24
|
+
rubocop
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
name: Tests
|
|
2
|
+
|
|
3
|
+
on: [push]
|
|
4
|
+
|
|
5
|
+
jobs:
|
|
6
|
+
run:
|
|
7
|
+
runs-on: ubuntu-latest
|
|
8
|
+
|
|
9
|
+
steps:
|
|
10
|
+
- uses: actions/checkout@v1
|
|
11
|
+
|
|
12
|
+
- name: Set up Ruby 2.6
|
|
13
|
+
uses: actions/setup-ruby@v1
|
|
14
|
+
with:
|
|
15
|
+
ruby-version: 2.6.x
|
|
16
|
+
|
|
17
|
+
- name: Build and test with Rake
|
|
18
|
+
run: |
|
|
19
|
+
gem install bundler
|
|
20
|
+
bundle install --jobs 4 --retry 3
|
|
21
|
+
bundle exec rspec
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
require:
|
|
2
|
+
- rubocop-performance
|
|
3
|
+
- rubocop-rspec
|
|
4
|
+
|
|
5
|
+
Layout/FirstArrayElementIndentation:
|
|
6
|
+
EnforcedStyle: consistent
|
|
7
|
+
|
|
8
|
+
Layout/FirstHashElementIndentation:
|
|
9
|
+
EnforcedStyle: consistent
|
|
10
|
+
|
|
11
|
+
Layout/HashAlignment:
|
|
12
|
+
EnforcedHashRocketStyle: table
|
|
13
|
+
EnforcedColonStyle: table
|
|
14
|
+
|
|
15
|
+
Layout/LineLength:
|
|
16
|
+
Max: 125
|
|
17
|
+
|
|
18
|
+
Metrics/BlockLength:
|
|
19
|
+
Exclude:
|
|
20
|
+
- spec/**/*
|
|
21
|
+
|
|
22
|
+
# Good: foo_37
|
|
23
|
+
# Bad: bar42
|
|
24
|
+
# Exception: s3
|
|
25
|
+
Naming/VariableNumber:
|
|
26
|
+
EnforcedStyle: snake_case
|
|
27
|
+
|
|
28
|
+
RSpec/NestedGroups:
|
|
29
|
+
Max: 4
|
|
30
|
+
|
|
31
|
+
# 👍👍🏻👍🏼👍🏽👍🏾👍🏿
|
|
32
|
+
Style/AsciiComments:
|
|
33
|
+
Enabled: false
|
|
34
|
+
|
|
35
|
+
# Don’t require top-level class documentation comment
|
|
36
|
+
Style/Documentation:
|
|
37
|
+
Enabled: false
|
|
38
|
+
|
|
39
|
+
Style/HashEachMethods:
|
|
40
|
+
Enabled: true
|
|
41
|
+
|
|
42
|
+
Style/FrozenStringLiteralComment:
|
|
43
|
+
Enabled: false
|
|
44
|
+
|
|
45
|
+
Style/HashTransformKeys:
|
|
46
|
+
Enabled: true
|
|
47
|
+
|
|
48
|
+
Style/HashTransformValues:
|
|
49
|
+
Enabled: true
|
|
50
|
+
|
|
51
|
+
Style/MethodDefParentheses:
|
|
52
|
+
EnforcedStyle: require_no_parentheses
|
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
|
10
|
+
orientation.
|
|
11
|
+
|
|
12
|
+
## Our Standards
|
|
13
|
+
|
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
|
15
|
+
include:
|
|
16
|
+
|
|
17
|
+
* Using welcoming and inclusive language
|
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
|
19
|
+
* Gracefully accepting constructive criticism
|
|
20
|
+
* Focusing on what is best for the community
|
|
21
|
+
* Showing empathy towards other community members
|
|
22
|
+
|
|
23
|
+
Examples of unacceptable behavior by participants include:
|
|
24
|
+
|
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
|
26
|
+
advances
|
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
28
|
+
* Public or private harassment
|
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
|
30
|
+
address, without explicit permission
|
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
32
|
+
professional setting
|
|
33
|
+
|
|
34
|
+
## Our Responsibilities
|
|
35
|
+
|
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
|
38
|
+
response to any instances of unacceptable behavior.
|
|
39
|
+
|
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
|
44
|
+
threatening, offensive, or harmful.
|
|
45
|
+
|
|
46
|
+
## Scope
|
|
47
|
+
|
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
|
49
|
+
when an individual is representing the project or its community. Examples of
|
|
50
|
+
representing a project or community include using an official project e-mail
|
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
|
53
|
+
further defined and clarified by project maintainers.
|
|
54
|
+
|
|
55
|
+
## Enforcement
|
|
56
|
+
|
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
58
|
+
reported by contacting the project team at veganstraightedge@gmail.com. All
|
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
|
63
|
+
|
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
|
66
|
+
members of the project's leadership.
|
|
67
|
+
|
|
68
|
+
## Attribution
|
|
69
|
+
|
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
|
72
|
+
|
|
73
|
+
[homepage]: http://contributor-covenant.org
|
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
easy_yaml (0.1.0)
|
|
5
|
+
|
|
6
|
+
GEM
|
|
7
|
+
remote: https://rubygems.org/
|
|
8
|
+
specs:
|
|
9
|
+
ast (2.4.0)
|
|
10
|
+
diff-lcs (1.3)
|
|
11
|
+
jaro_winkler (1.5.4)
|
|
12
|
+
parallel (1.19.1)
|
|
13
|
+
parser (2.7.0.3)
|
|
14
|
+
ast (~> 2.4.0)
|
|
15
|
+
rainbow (3.0.0)
|
|
16
|
+
rake (13.0.1)
|
|
17
|
+
rexml (3.2.4)
|
|
18
|
+
rspec (3.9.0)
|
|
19
|
+
rspec-core (~> 3.9.0)
|
|
20
|
+
rspec-expectations (~> 3.9.0)
|
|
21
|
+
rspec-mocks (~> 3.9.0)
|
|
22
|
+
rspec-core (3.9.0)
|
|
23
|
+
rspec-support (~> 3.9.0)
|
|
24
|
+
rspec-expectations (3.9.0)
|
|
25
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
26
|
+
rspec-support (~> 3.9.0)
|
|
27
|
+
rspec-mocks (3.9.0)
|
|
28
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
29
|
+
rspec-support (~> 3.9.0)
|
|
30
|
+
rspec-support (3.9.0)
|
|
31
|
+
rubocop (0.80.0)
|
|
32
|
+
jaro_winkler (~> 1.5.1)
|
|
33
|
+
parallel (~> 1.10)
|
|
34
|
+
parser (>= 2.7.0.1)
|
|
35
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
36
|
+
rexml
|
|
37
|
+
ruby-progressbar (~> 1.7)
|
|
38
|
+
unicode-display_width (>= 1.4.0, < 1.7)
|
|
39
|
+
ruby-progressbar (1.10.1)
|
|
40
|
+
unicode-display_width (1.6.1)
|
|
41
|
+
|
|
42
|
+
PLATFORMS
|
|
43
|
+
ruby
|
|
44
|
+
|
|
45
|
+
DEPENDENCIES
|
|
46
|
+
bundler (~> 2.0)
|
|
47
|
+
easy_yaml!
|
|
48
|
+
rake (~> 13.0)
|
|
49
|
+
rspec (~> 3.0)
|
|
50
|
+
rubocop
|
|
51
|
+
|
|
52
|
+
BUNDLED WITH
|
|
53
|
+
2.0.2
|
data/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Shane Becker
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# EasyYAML
|
|
2
|
+
|
|
3
|
+
EasyYAML is a simple way to read and load YAML from a file.
|
|
4
|
+
It makes some opinionated assumptions, each of which you can override.
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
|
|
8
|
+
Add this line to your application's `Gemfile`:
|
|
9
|
+
|
|
10
|
+
```ruby
|
|
11
|
+
gem 'easy_yaml'
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
And then execute from the command line:
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
bundle
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Or install it yourself as:
|
|
21
|
+
|
|
22
|
+
```sh
|
|
23
|
+
gem install easy_yaml
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Usage
|
|
27
|
+
|
|
28
|
+
The simplest way to use EasyYAML is:
|
|
29
|
+
|
|
30
|
+
```ruby
|
|
31
|
+
EasyYAML.load('path/to/file.yml')
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
EasyYAML makes a few opinionated assumptions.
|
|
35
|
+
You can override any of these with your own configuration.
|
|
36
|
+
|
|
37
|
+
`EasyYAML.load` always returns a `Hash`.
|
|
38
|
+
|
|
39
|
+
### Required argument
|
|
40
|
+
|
|
41
|
+
**`path`**
|
|
42
|
+
`EasyYAML.load` requires a `path` argument as a `String`.
|
|
43
|
+
|
|
44
|
+
Example:
|
|
45
|
+
|
|
46
|
+
```ruby
|
|
47
|
+
EasyYAML.load 'config/database.yml'
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Optional arguments
|
|
51
|
+
|
|
52
|
+
**`allow_aliases`** (defaults to `true`)
|
|
53
|
+
|
|
54
|
+
By default, EasyYAML assumes that when you're loading a YAML file, you control and trust that YAML file and want to allow following and expanding any YAML aliases in the file.
|
|
55
|
+
|
|
56
|
+
If you don't want to allow aliases in the YAML, you can disable them by passing `allow_aliases: false`.
|
|
57
|
+
|
|
58
|
+
Example:
|
|
59
|
+
|
|
60
|
+
```ruby
|
|
61
|
+
EasyYAML.load 'config/database.yml', allow_aliases: false
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
**`allow_erb`** (defaults to `true`)
|
|
65
|
+
|
|
66
|
+
By default, EasyYAML assumes that when you're loading a YAML file, you control and trust that YAML file and want to allow embedding ERB in the YAML and evaluating it.
|
|
67
|
+
|
|
68
|
+
If you don't want to evaluate ERB in the YAML, you can disable it by passing `allow_erb: false`.
|
|
69
|
+
|
|
70
|
+
Example:
|
|
71
|
+
|
|
72
|
+
```ruby
|
|
73
|
+
EasyYAML.load 'config/database.yml', allow_erb: false
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
**`relative_to_rails_root`** (defaults to `true`)
|
|
77
|
+
|
|
78
|
+
By default, EasyYAML assumes that when you're loading a YAML file that you're doing this from within a Rails app. EasyYAML then prefixes the `path` that you pass into `EasyYAML.load` with `Rails.root`. So, your `path` argument only needs to be a string of the path starting at the root of your Rails app.
|
|
79
|
+
|
|
80
|
+
If you are running EasyYAML outside of a Rails app or if you don't want to load the YAML relative to the Rails app root, you can disable the path prefix by passing `relative_to_rails_root: false`.
|
|
81
|
+
|
|
82
|
+
Example:
|
|
83
|
+
|
|
84
|
+
```ruby
|
|
85
|
+
EasyYAML.load '../../../config/database.yml', relative_to_rails_root: false
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Authors
|
|
89
|
+
|
|
90
|
+
- [Shane Becker @veganstraightedge](https://github.com/veganstraightedge)
|
|
91
|
+
- Add yourself here…
|
|
92
|
+
|
|
93
|
+
## Development
|
|
94
|
+
|
|
95
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
96
|
+
|
|
97
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
98
|
+
|
|
99
|
+
## Contributing
|
|
100
|
+
|
|
101
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/hoverinc/easy_yaml. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
|
102
|
+
|
|
103
|
+
## License
|
|
104
|
+
|
|
105
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
106
|
+
|
|
107
|
+
## Code of Conduct
|
|
108
|
+
|
|
109
|
+
Everyone interacting in the EasyYAML project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/hoverinc/easy_yaml/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require 'bundler/setup'
|
|
4
|
+
require 'easy_yaml'
|
|
5
|
+
|
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
+
|
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
+
# require "pry"
|
|
11
|
+
# Pry.start
|
|
12
|
+
|
|
13
|
+
require 'irb'
|
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/easy_yaml.gemspec
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
|
+
require 'easy_yaml/version'
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = 'easy_yaml'
|
|
7
|
+
spec.version = EasyYAML::VERSION
|
|
8
|
+
spec.authors = ['Shane Becker']
|
|
9
|
+
spec.email = ['veganstraightedge@gmail.com']
|
|
10
|
+
|
|
11
|
+
spec.summary = 'A simple way to safely load a YAML file'
|
|
12
|
+
spec.description = <<~DESCRIPTION.tr("\n", ' ')
|
|
13
|
+
EasyYAML reads a file from a path and uses YAML.safe_load to
|
|
14
|
+
safely load its contents and optionally works with Rails.root
|
|
15
|
+
DESCRIPTION
|
|
16
|
+
spec.homepage = 'https://github.com/hoverinc/easy_yaml'
|
|
17
|
+
spec.license = 'MIT'
|
|
18
|
+
|
|
19
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
|
20
|
+
spec.metadata['source_code_uri'] = 'https://github.com/hoverinc/easy_yaml'
|
|
21
|
+
spec.metadata['changelog_uri'] = 'https://github.com/hoverinc/hyperion/blob/master/CHANGELOG.md'
|
|
22
|
+
|
|
23
|
+
# Specify which files should be added to the gem when it is released.
|
|
24
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
25
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
26
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
spec.bindir = 'exe'
|
|
30
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
31
|
+
spec.require_paths = ['lib']
|
|
32
|
+
|
|
33
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
|
34
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
|
35
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
|
36
|
+
spec.add_development_dependency 'rubocop'
|
|
37
|
+
end
|
data/lib/easy_yaml.rb
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require 'easy_yaml/version'
|
|
2
|
+
require 'easy_yaml/yaml_loader'
|
|
3
|
+
|
|
4
|
+
module EasyYAML
|
|
5
|
+
class << self
|
|
6
|
+
def load path, allow_aliases: true, allow_erb: true, relative_to_rails_root: true
|
|
7
|
+
loaded_yaml = EasyYAML::YAMLLoader.new path,
|
|
8
|
+
allow_aliases: allow_aliases,
|
|
9
|
+
allow_erb: allow_erb,
|
|
10
|
+
relative_to_rails_root: relative_to_rails_root
|
|
11
|
+
|
|
12
|
+
loaded_yaml.to_h
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
require 'yaml'
|
|
2
|
+
require 'erb'
|
|
3
|
+
|
|
4
|
+
module EasyYAML
|
|
5
|
+
class YAMLLoader
|
|
6
|
+
def initialize path, allow_aliases: true, allow_erb: true, relative_to_rails_root: true
|
|
7
|
+
@path = path
|
|
8
|
+
@allow_aliases = allow_aliases
|
|
9
|
+
@allow_erb = allow_erb
|
|
10
|
+
@relative_to_rails_root = relative_to_rails_root
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def to_h
|
|
14
|
+
safe_load
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
private
|
|
18
|
+
|
|
19
|
+
def normalized_path
|
|
20
|
+
@path.tr('\\', '/').split('/')
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def prefix_path
|
|
24
|
+
::Rails.root if @relative_to_rails_root && defined?(::Rails)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def yaml_file_path
|
|
28
|
+
File.join [prefix_path, normalized_path].compact
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def file_path
|
|
32
|
+
Pathname.new File.expand_path(yaml_file_path, __dir__)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def yaml_file
|
|
36
|
+
File.read file_path
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def erb_parsed_yaml
|
|
40
|
+
return yaml_file unless @allow_erb
|
|
41
|
+
|
|
42
|
+
ERB.new(yaml_file).result
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def safe_load
|
|
46
|
+
YAML.safe_load(erb_parsed_yaml, aliases: @allow_aliases)
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: easy_yaml
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Shane Becker
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2020-02-28 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '2.0'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '2.0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '13.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '13.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rspec
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '3.0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '3.0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: rubocop
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '0'
|
|
69
|
+
description: 'EasyYAML reads a file from a path and uses YAML.safe_load to safely
|
|
70
|
+
load its contents and optionally works with Rails.root '
|
|
71
|
+
email:
|
|
72
|
+
- veganstraightedge@gmail.com
|
|
73
|
+
executables: []
|
|
74
|
+
extensions: []
|
|
75
|
+
extra_rdoc_files: []
|
|
76
|
+
files:
|
|
77
|
+
- ".github/workflows/greetings.yml"
|
|
78
|
+
- ".github/workflows/linter.yml"
|
|
79
|
+
- ".github/workflows/test.yml"
|
|
80
|
+
- ".gitignore"
|
|
81
|
+
- ".rspec"
|
|
82
|
+
- ".rubocop.yml"
|
|
83
|
+
- CODE_OF_CONDUCT.md
|
|
84
|
+
- Gemfile
|
|
85
|
+
- Gemfile.lock
|
|
86
|
+
- LICENSE.md
|
|
87
|
+
- README.md
|
|
88
|
+
- Rakefile
|
|
89
|
+
- bin/console
|
|
90
|
+
- bin/setup
|
|
91
|
+
- easy_yaml.gemspec
|
|
92
|
+
- lib/easy_yaml.rb
|
|
93
|
+
- lib/easy_yaml/version.rb
|
|
94
|
+
- lib/easy_yaml/yaml_loader.rb
|
|
95
|
+
homepage: https://github.com/hoverinc/easy_yaml
|
|
96
|
+
licenses:
|
|
97
|
+
- MIT
|
|
98
|
+
metadata:
|
|
99
|
+
homepage_uri: https://github.com/hoverinc/easy_yaml
|
|
100
|
+
source_code_uri: https://github.com/hoverinc/easy_yaml
|
|
101
|
+
changelog_uri: https://github.com/hoverinc/hyperion/blob/master/CHANGELOG.md
|
|
102
|
+
post_install_message:
|
|
103
|
+
rdoc_options: []
|
|
104
|
+
require_paths:
|
|
105
|
+
- lib
|
|
106
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
107
|
+
requirements:
|
|
108
|
+
- - ">="
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: '0'
|
|
111
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
|
+
requirements:
|
|
113
|
+
- - ">="
|
|
114
|
+
- !ruby/object:Gem::Version
|
|
115
|
+
version: '0'
|
|
116
|
+
requirements: []
|
|
117
|
+
rubygems_version: 3.0.6
|
|
118
|
+
signing_key:
|
|
119
|
+
specification_version: 4
|
|
120
|
+
summary: A simple way to safely load a YAML file
|
|
121
|
+
test_files: []
|