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

Bump minimum Ruby version to v2.1.0? #747

Closed
friedbunny opened this issue Feb 20, 2017 · 2 comments
Closed

Bump minimum Ruby version to v2.1.0? #747

friedbunny opened this issue Feb 20, 2017 · 2 comments

Comments

@friedbunny
Copy link
Collaborator

As of jazzy v0.7.4, the effective minimum Ruby version became v2.1.0 — b0e5c4b#diff-598546a0c342527401dade0e669b6772R431 switched to Psych.safe_load(), which was added in v2.1.0.

It would be trivial to fix Ruby 2.0.0 support:

diff --git a/lib/jazzy/config.rb b/lib/jazzy/config.rb
index af3fafd..2c072f4 100644
--- a/lib/jazzy/config.rb
+++ b/lib/jazzy/config.rb
@@ -428,7 +428,12 @@ module Jazzy
     def read_config_file(file)
       case File.extname(file)
         when '.json'         then JSON.parse(File.read(file))
-        when '.yaml', '.yml' then YAML.safe_load(File.read(file))
+        when '.yaml', '.yml' then
+          if YAML.respond_to?('safe_load') # ruby >= 2.1.0
+            YAML.safe_load(File.read(file))
+          else
+            YAML.load(File.read(file))
+          end
         else raise "Config file must be .yaml or .json, but got #{file.inspect}"
       end
     end

... but, given that Ruby 2.0 has been deprecated for a year, should jazzy bump its Ruby requirement to 2.1.0 instead?

Refs mapbox/mapbox-gl-native#8119.

/cc @jpsim @kkaefer

@kkaefer
Copy link

kkaefer commented Feb 20, 2017

2.0 seems to be the version that is installed by default on macOS.

@friedbunny
Copy link
Collaborator Author

For clarity/posterity, here is the error you encounter when running jazzy v0.7.4 with Ruby 2.0.0:

/Library/Ruby/Gems/2.0.0/gems/jazzy-0.7.4/lib/jazzy/config.rb:431:in `read_config_file': undefined method `safe_load' for Psych:Module (NoMethodError)
	from /Library/Ruby/Gems/2.0.0/gems/jazzy-0.7.4/lib/jazzy/config.rb:393:in `parse_config_file'
	from /Library/Ruby/Gems/2.0.0/gems/jazzy-0.7.4/lib/jazzy/config.rb:341:in `parse!'
	from /Library/Ruby/Gems/2.0.0/gems/jazzy-0.7.4/bin/jazzy:15:in `<top (required)>'
	from /usr/local/bin/jazzy:23:in `load'
	from /usr/local/bin/jazzy:23:in `<main>'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants