Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for ruby 3.2.0 #7

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Hieracles Changelog
=======================

### 0.4.4 - 2023-01-06
- fix lib/hieracles/node.rb params function to load YAML properly
when moving to ruby3.2.0 / psych4 and the alias parsing behaviour
change.
- fix deprecated exists? method for File:Class in favor to exist?
(exists? is deprecated)

### 0.4.3 - 2020-03-31
- fix formatting for console colors

Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,14 @@ shar `find rubygem-hieracles` > rubygem-hieracles.shar
- on https://bugs.freebsd.org submit the new version


GEM packaging
-------------

- edit the CHANGELOG.md file (bump version/add the necessary comments)
- `gem build hieracles.gemspec`
- `gem install [--user-install] ./hieracles-X.Y.Z.gem`


Todo
--------------
- add json format (done)
Expand Down
Binary file added hieracles-0.4.4.gem
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might not want to commit this file in the repo.

Binary file not shown.
4 changes: 2 additions & 2 deletions lib/hieracles/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ def load_facts(file, format)
end

def resolve_path(path)
if File.exists?(File.expand_path(path))
if File.exist?(File.expand_path(path))
File.expand_path(path)
elsif File.exists?(File.expand_path(File.join(@basepath, path)))
elsif File.exist?(File.expand_path(File.join(@basepath, path)))
File.expand_path(File.join(@basepath, path))
else
raise IOError, "File #{path} not found."
Expand Down
9 changes: 8 additions & 1 deletion lib/hieracles/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,14 @@ def paths(without_common = true)
def params(without_common = true)
params = {}
files(without_common).each do |f|
data = YAML.load_file(File.join(@config.basepath, f))

# Patch to work on ruby3.2.0
begin
data = YAML.load_file(File.join(@config.basepath, f), aliases: true)
rescue ArgumentError
data = YAML.load_file(File.join(@config.basepath, f))
end

if data
s = to_shallow_hash(data)
s.each do |k,v|
Expand Down