hjson / hjson-rb Goto Github PK
View Code? Open in Web Editor NEWHjson for Ruby
Home Page: https://hjson.github.io/
License: MIT License
Hjson for Ruby
Home Page: https://hjson.github.io/
License: MIT License
Hi,
I am trying to migrate from JSON to HJSON for config files of my app and I am running into an issue with JSON gem compatibility as HJSON gem requires JSON ~> 2.2.0 while some of the other gems I am using are locked down on older versions of the JSON gem.
Would it be possible to relax the current requirement to a less strict that allows for older versions? I tried to build this gem locally with:
spec.add_runtime_dependency 'json', '>= 1.7.5'
and it seems to be working just fine. I can create a pull request if that would help.
[1] pry(main)> require 'hjson'
=> true
[2] pry(main)> Hjson.parse "1"
ArgumentError: wrong number of arguments (given 2, expected 1)
from /home/app/.rvm/gems/ruby-3.0.1/gems/hjson-0.1.2/lib/hjson/ast/parser.rb:41:in `initialize'
[3] pry(main)> RUBY_VERSION
=> "3.0.1"
I understand it is because of separation of positional and keyword arguments in Ruby 3.0. Sorry I don't know Ruby well to fix it and submit a pull request.
Rubygems has the initial version which was last updated August 07, 2016 and does not contain any of the patches since. Can you please bump the version and submit it?
When I try to load hjson I get the following warning:
/var/lib/gems/2.3.0/gems/hjson-0.1.0/lib/hjson/ast/nodes/string.rb:48: warning: shadowing outer local variable - uffff
Here's the entire ruby script:
#!/usr/bin/ruby -w require 'hjson'
Yes, my script turns on warnings. Still, it seems like a warning worth heeding.
Here are some specs:
Operating system Ubuntu Linux 16.04.1
Kernel and CPU Linux 4.4.0-78-generic on x86_64
ruby 2.3.1p112 (2016-04-26) [x86_64-linux-gnu]
Please let me know if there is other information that would help.
See hjson/hjson#74
Ruby 2.4 deprecated Fixnum
and Bignum
in favor of Integer
. It seems that hjson-rb
needs to replace references to Fixnum
with a reference to Integer
. After simple replacement of the Fixnum
string the library works without warnings and parses the hjson files correctly (it passes all tests as well), but I'm not sure about backward compatibility.
Example:
$ ruby Compiler.rb colors.hjson -o colors.dat
/home/antek/.gem/ruby/2.4.0/gems/hjson-0.1.0/lib/hjson/ast/parser.rb:56: warning: constant ::Fixnum is deprecated
My Ruby version:
$ ruby --version
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
Related links:
@namusyaka I tried to add a travis build (see travis.yml).
I got as far as having it compile but then it errors on the tests (https://travis-ci.org/hjson/hjson-rb), e.g. NoMethodError: undefined method
positive?' for -1:Fixnum`
Do you know what the problem is?
Would be helpful if HJSON reported the line number where a parsing error occurs.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.