Code Monkey home page Code Monkey logo

ruby-jq's Introduction

ruby-jq

Ruby bindings for jq.

see http://stedolan.github.io/jq/.

Gem Version Build Status

Prerequisites

jq requires the Oniguruma library to provide regex support. To install Oniguruma for your system, please follow the instructions in the jq FAQ.

Installation

Add this line to your application's Gemfile:

gem 'ruby-jq'

And then execute:

$ bundle

Or install it yourself as:

$ gem install ruby-jq

Using system libraries

By default, ruby-jq downloads and compiles its own version of libjq. If you would like to use your own version of libjq, you can skip this process by passing the --use-system-libraries flag to gem install, or by setting the RUBYJQ_USE_SYSTEM_LIBRARIES env var.

Usage

require 'jq'

src = <<EOS
[
  "FOO",
  {
    "BAR": [100, 200]
  },
  1.23,
  [1, "2", 3]
]
EOS

jq = JQ(src)

jq.search('.[]') do |value|
  p value
  # => "FOO"
  # => {"BAR"=>[100, 200]}
  # => 1.23
  # => [1, "2", 3]
end

p jq.search('.[]')
# => ["FOO", {"BAR"=>[100, 200]}, 1.23, [1, "2", 3]]

jq = JQ(src, parse_json: false)

jq.search('.[1].BAR') do |value|
  p value
  # => "[100,200]"
end

Query for Hash/Array

require 'jq/extend'

p {'FOO' => 100, 'BAR' => [200, 200]}.jq('.BAR[]')
# => [200, 200]

['FOO', 100, 'BAR', [200, 200]].jq('.[3][]') do |value|
  p value
  # => 200
end

ruby-jq's People

Contributors

winebarrel avatar aergonaut avatar stephenprater avatar

Stargazers

Lipin Pappachan avatar  avatar  avatar Marian Kostyk avatar Adrian Thomas-Prestemon avatar Simon Thiboutôt avatar Thomas Witt avatar Nicolas Rodriguez avatar Thomas Ungstad avatar Krzysztof Wilczyński avatar Petros avatar Anand Dhillon avatar Nikita Fedyashev avatar Blake Girardot avatar Andrew Gerst avatar Klas Stålbröst avatar Re Krass avatar  avatar Vincent Lyons avatar James Whelton avatar Andrey Shramko avatar 大関 金城 秀喜 カシオ avatar Lyshenko Volodymyr avatar Ethan avatar Kalevi Vázquez Tuisku avatar  avatar Seva Baskin avatar Atsushi Yamaguchi avatar Nogweii avatar Anirban Mukhopadhyay avatar Cyril Rohr avatar Aaron Kuehler avatar Ilia Lobsanov avatar Juri Hahn avatar Christoph Grabo avatar  avatar Brian Moelk avatar Abhishek Yadav avatar Owen Nelson avatar Hirohisa Mitsuishi avatar Edgar Ortega avatar Fly Chang avatar moe avatar Daniel Smith avatar Josh Teneycke avatar Johan Eckerström avatar Jon Bardin avatar Joshua Sassel avatar Andrii Dmytrenko avatar Kevin Litchfield avatar  avatar june29 avatar Kenta Murata avatar Shuhei KONDO avatar Yuichiro Suzuki avatar Michikawa Masayoshi avatar Mitsutaka Mimura avatar Hisatoshi Imaoka avatar Sebastian Cohnen avatar  avatar Yuki Kurihara avatar Quentin Rousseau avatar Sean Huber avatar Ritchie Young avatar MOGI Hiromu avatar Tomohiro Hashidate avatar Kazunari Takahashi avatar Subak Systems avatar Kenichi Tsunokawa avatar misoobu avatar Darren Day avatar Brad Skaggs avatar Jip  avatar Jim Park avatar Zachary Drummond avatar Yohei Kawahara avatar Dmitry Filimonov avatar Vladimir Moravec avatar Stephen Paul Weber avatar John Backus avatar Robert Ross avatar Yuki Iwanaga avatar

Watchers

Gustav avatar  avatar Nico Williams avatar James Cloos avatar  avatar

ruby-jq's Issues

gsub is not working correctly

jq works as I expected from bash:

$ jq '.name|gsub("\\s+";"-")' <<< '{"name": "sample json"}'
"sample-json"

but not the same from ruby-jq:

> require 'jq/extend'
> {name: 'sample json'}.jq('.name | gsub("\\\\s+";"-")')
 => ["-"]

Heroku deploy

Has anyone successfully installed this gem on Heroku?

By using this Gemfile:

source 'https://rubygems.org'
ruby '2.5.1'
gem 'ruby-jq', '0.1.8'

gives the following error:

remote:        Installing ruby-jq 0.1.8 with native extensions
remote:        Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
remote:        
remote:        current directory:
remote:        /tmp/build_51f60a8fa8fbc737fef3a88df336683a/vendor/bundle/ruby/2.5.0/gems/ruby-jq-0.1.8/ext
remote:        /tmp/build_51f60a8fa8fbc737fef3a88df336683a/vendor/ruby-2.5.1/bin/ruby -r
remote:        ./siteconf20190612-486-ddne65.rb extconf.rb
remote:        Buildling jq using packaged libraries.
remote: Downloading jq-1.6.tar.gz
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz 
remote: Downloading jq-1.6.tar.gz
remote:        Extracting jq-1.6.tar.gz into tmp/x86_64-linux-gnu/ports/jq/1.6... OK
remote:        Running 'autoreconf' for jq 1.6... OK
remote:        Running 'configure' for jq 1.6... OK
remote:        Running 'compile' for jq 1.6... ERROR, review
remote:        '/tmp/build_51f60a8fa8fbc737fef3a88df336683a/vendor/bundle/ruby/2.5.0/gems/ruby-jq-0.1.8/ext/tmp/x86_64-linux-gnu/ports/jq/1.6/compile.log'
remote:        to see what happened. Last lines are:
remote:        ========================================================================
remote:          GEN      src/builtin.inc
remote:        fatal: not a git repository (or any parent up to mount point /)
remote:        Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
remote:          GEN      src/version.h
remote:        fatal: not a git repository (or any parent up to mount point /)
remote:        Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
remote:        make  all-recursive
remote:        make[1]: Entering directory
remote:        '/tmp/build_51f60a8fa8fbc737fef3a88df336683a/vendor/bundle/ruby/2.5.0/gems/ruby-jq-0.1.8/ext/tmp/x86_64-linux-gnu/ports/jq/1.6/jq-jq-1.6'
remote:        Making all in modules/oniguruma
remote:        make[2]: Entering directory
remote:        '/tmp/build_51f60a8fa8fbc737fef3a88df336683a/vendor/bundle/ruby/2.5.0/gems/ruby-jq-0.1.8/ext/tmp/x86_64-linux-gnu/ports/jq/1.6/jq-jq-1.6/modules/oniguruma'
remote:        make[2]: *** No rule to make target 'all'.  Stop.
remote:        make[2]: Leaving directory
remote:        '/tmp/build_51f60a8fa8fbc737fef3a88df336683a/vendor/bundle/ruby/2.5.0/gems/ruby-jq-0.1.8/ext/tmp/x86_64-linux-gnu/ports/jq/1.6/jq-jq-1.6/modules/oniguruma'
remote:        Makefile:1086: recipe for target 'all-recursive' failed
remote:        make[1]: *** [all-recursive] Error 1
remote:        make[1]: Leaving directory
remote:        '/tmp/build_51f60a8fa8fbc737fef3a88df336683a/vendor/bundle/ruby/2.5.0/gems/ruby-jq-0.1.8/ext/tmp/x86_64-linux-gnu/ports/jq/1.6/jq-jq-1.6'
remote:        Makefile:763: recipe for target 'all' failed
remote:        make: *** [all] Error 2
remote:        ========================================================================
remote:        *** extconf.rb failed ***
remote:        Could not create Makefile due to some reason, probably lack of necessary
remote:        libraries and/or headers.  Check the mkmf.log file for more details.  You may
remote:        need configuration options.
remote:        
remote:        Provided configuration options:
remote:        	--with-opt-dir
remote:        	--without-opt-dir
remote:        	--with-opt-include
remote:        	--without-opt-include=${opt-dir}/include
remote:        	--with-opt-lib
remote:        	--without-opt-lib=${opt-dir}/lib
remote:        	--with-make-prog
remote:        	--without-make-prog
remote:        	--srcdir=.
remote:        	--curdir
remote:        --ruby=/tmp/build_51f60a8fa8fbc737fef3a88df336683a/vendor/ruby-2.5.1/bin/$(RUBY_BASE_NAME)
remote:        	--use-system-libraries
remote:        /tmp/build_51f60a8fa8fbc737fef3a88df336683a/vendor/bundle/ruby/2.5.0/gems/mini_portile2-2.4.0/lib/mini_portile2/mini_portile.rb:402:in
remote:        `block in execute': Failed to complete compile task (RuntimeError)
remote:        from
remote:        /tmp/build_51f60a8fa8fbc737fef3a88df336683a/vendor/bundle/ruby/2.5.0/gems/mini_portile2-2.4.0/lib/mini_portile2/mini_portile.rb:373:in
remote:        `chdir'
remote:        from
remote:        /tmp/build_51f60a8fa8fbc737fef3a88df336683a/vendor/bundle/ruby/2.5.0/gems/mini_portile2-2.4.0/lib/mini_portile2/mini_portile.rb:373:in
remote:        `execute'
remote:        from
remote:        /tmp/build_51f60a8fa8fbc737fef3a88df336683a/vendor/bundle/ruby/2.5.0/gems/mini_portile2-2.4.0/lib/mini_portile2/mini_portile.rb:115:in
remote:        `compile'
remote:        from
remote:        /tmp/build_51f60a8fa8fbc737fef3a88df336683a/vendor/bundle/ruby/2.5.0/gems/mini_portile2-2.4.0/lib/mini_portile2/mini_portile.rb:154:in
remote:        `cook'
remote:        	from extconf.rb:25:in `<main>'
remote:        
remote:        extconf failed, exit code 1
remote:        
remote:        Gem files will remain installed in
remote:        /tmp/build_51f60a8fa8fbc737fef3a88df336683a/vendor/bundle/ruby/2.5.0/gems/ruby-jq-0.1.8
remote:        for inspection.
remote:        Results logged to
remote:        /tmp/build_51f60a8fa8fbc737fef3a88df336683a/vendor/bundle/ruby/2.5.0/extensions/x86_64-linux/2.5.0/ruby-jq-0.1.8/gem_make.out
remote:        
remote:        An error occurred while installing ruby-jq (0.1.8), and Bundler cannot continue.
remote:        Make sure that `gem install ruby-jq -v '0.1.8'` succeeds before bundling.
remote:        
remote:        In Gemfile:
remote:          ruby-jq
remote: 
remote:  !
remote:  !     Failed to install gems via Bundler.
remote:  !
remote:  !     Push rejected, failed to compile Ruby app.

Is there a working buildpack for heroku out there? I tried the following without success:

json key is symbol

my json like this {:abc=>"123",:abb=>"123"},but use {}.jq('.')
retune {"abc"=>"123".....}
so how can keep zhe key is symbol

string output?

I don't see anyway to have string output.

I'm interested in jq because of output formatting, especially --sort-keys.

I don't see this library allowing for the use of jq formatting, I'm just seeing the filtering side of jq.

scan() with grouping returns empty string

I'm having a case where scan() returns empty string.

Using the jq command:

echo '{ "foo": "thisthat" }' | jq '.foo | scan("this(.+)")'

Output:

[
  "that"
]

Using ruby-jq gem:

irb(main):001:0> require 'jq'
=> true
irb(main):002:0> JQ::VERSION
=> "0.2.1"
irb(main):002:0> JQ('{ "foo": "thisthat" }').search('.foo | scan("this(.+)")')
=> [[""]]

I can only reproduce the problem when deployed to heroku. To reproduce the problem click the deploy button at https://github.com/voke/heroku-jq-debugger (which includes the libjq 1.6 buildpack)

Run heroku run console --app YOUR_APP_NAME and follow the steps above.


First I thought it must be an oniguruma issue since regexp is used. But gsub command works as expected.

My second guess was that since my local version of jq (installed via homebrew) and the ruby-jq gem returns the correct output the problem must be within my buildpack. But running the jq command at heroku also returns the correct output.

heroku run "cd jq && echo '{ \"foo\": \"thisthat\" }' | ./jq '.foo | scan(\"this(.+)\")'" --app YOUR_APP_NAME

Output:

[
  "that"
]

Do you have any idea what the issue may be?

Handle errors thrown inside block

Using the following snippet:

require 'jq'
puts JQ::VERSION # => 0.1.8

JQ('[1,2]').search('.[]') do |value|
  21 / 0
end

I expect divided by 0 (ZeroDivisionError) but program terminates with error:

Assertion failed: (jv_get_kind(inv) == JV_KIND_INVALID), function jv_invalid_get_msg, file src/jv.c, line 111.

The program fails at: https://github.com/winebarrel/ruby-jq/blob/master/ext/jq_core.c#L69

So I added a simple test:

specify 'raise errors thrown inside block' do
  expect {
    JQ('[1,2]').search('.[]') do |value|
      21 / 0
    end
  }.to raise_error(ZeroDivisionError)
end

I'm not familiar with C but the following code seems to fix it:

if (*status == 0 && jv_invalid_has_msg(jv_copy(result))) {
  jv msg = jv_invalid_get_msg(result);
  *errmsg = rb_str_new2(jv_string_value(msg));
  jv_free(msg);
} else {
  jv_free(result);
}

While installing "ruby-jq" getting compilation error, "implicit declaration of function 'lgamma_r' is invalid in C99"

Platform : MacOS Big Sur 11.4

gem install ruby-jq -v '0.2.1'
Building native extensions. This could take a while...
ERROR: Error installing ruby-jq:
ERROR: Failed to build gem native extension.

current directory: /Users/maheshchaudhar/.rvm/rubies/ruby-2.7.1/lib/ruby/gems/2.7.0/gems/ruby-jq-0.2.1/ext

/Users/maheshchaudhar/.rvm/rubies/ruby-2.7.1/bin/ruby -I /Users/maheshchaudhar/.rvm/rubies/ruby-2.7.1/lib/ruby/2.7.0 -r ./siteconf20210614-41011-1bck1mq.rb extconf.rb
Buildling jq using packaged libraries.
Downloading jq-1.6.tar.gz
Extracting jq-1.6.tar.gz into tmp/x86_64-apple-darwin20.5.0/ports/jq/1.6... OK
Running 'autoreconf' for jq 1.6... OK
Running 'configure' for jq 1.6... OK
Running 'compile' for jq 1.6... ERROR, review '/Users/maheshchaudhar/.rvm/rubies/ruby-2.7.1/lib/ruby/gems/2.7.0/gems/ruby-jq-0.2.1/ext/tmp/x86_64-apple-darwin20.5.0/ports/jq/1.6/compile.log' to see what happened. Last lines are:

src/libm.h:218:9: warning: 'gamma' is deprecated: first deprecated in macOS 10.9 [-Wdeprecated-declarations]
LIBM_DD(gamma)
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/math.h:755:15: note: 'gamma' has been explicitly marked deprecated here
extern double gamma(double)
^
In file included from src/builtin.c:157:
src/libm.h:278:9: warning: 'significand' is deprecated: first deprecated in macOS 10.9 - Use 2*frexp( ) or scalbn(x, -ilogb(x)) instead. [-Wdeprecated-declarations]
LIBM_DD(significand)
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/math.h:758:15: note: 'significand' has been explicitly marked deprecated here
extern double significand(double)
^
src/builtin.c:194:31: error: implicit declaration of function 'lgamma_r' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
jv ret = JV_ARRAY(jv_number(lgamma_r(jv_number_value(input), &sign)));
^
3 warnings and 1 error generated.
make[2]: *** [src/builtin.lo] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.

Provided configuration options:
--with-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/Users/maheshchaudhar/.rvm/rubies/ruby-2.7.1/bin/$(RUBY_BASE_NAME)
--use-system-libraries
/Users/maheshchaudhar/.rvm/rubies/ruby-2.7.1/lib/ruby/gems/2.7.0/gems/mini_portile2-2.6.1/lib/mini_portile2/mini_portile.rb:443:in block in execute': Failed to complete compile task (RuntimeError) from /Users/maheshchaudhar/.rvm/rubies/ruby-2.7.1/lib/ruby/gems/2.7.0/gems/mini_portile2-2.6.1/lib/mini_portile2/mini_portile.rb:409:in chdir'
from /Users/maheshchaudhar/.rvm/rubies/ruby-2.7.1/lib/ruby/gems/2.7.0/gems/mini_portile2-2.6.1/lib/mini_portile2/mini_portile.rb:409:in execute' from /Users/maheshchaudhar/.rvm/rubies/ruby-2.7.1/lib/ruby/gems/2.7.0/gems/mini_portile2-2.6.1/lib/mini_portile2/mini_portile.rb:137:in compile'
from /Users/maheshchaudhar/.rvm/rubies/ruby-2.7.1/lib/ruby/gems/2.7.0/gems/mini_portile2-2.6.1/lib/mini_portile2/mini_portile.rb:180:in cook' from extconf.rb:27:in

'

extconf failed, exit code 1

Gem files will remain installed in /Users/maheshchaudhar/.rvm/rubies/ruby-2.7.1/lib/ruby/gems/2.7.0/gems/ruby-jq-0.2.1 for inspection.
Results logged to /Users/maheshchaudhar/.rvm/rubies/ruby-2.7.1/lib/ruby/gems/2.7.0/extensions/x86_64-darwin-20/2.7.0/ruby-jq-0.2.1/gem_make.out
maheshchaudhar@Mahesh-Chaudhars-2021-MacBook-Pro coupa_developme

Cannot compile rubygem with non standard library location

Hello, if I try and point to a jq library file, the gem compilation fails with the following message

gem install --local ~/Downloads/ruby-jq-0.1.5.gem -- --with-jqlib=/Users/svs/tmp/usr/local/lib/libjq.dylib
Building native extensions with: '--with-jqlib=/tmp/usr/local/lib/libjq'
This could take a while...
ERROR:  Error installing /Users/svs/Downloads/ruby-jq-0.1.5.gem:
    ERROR: Failed to build gem native extension.

    /Users/svs/.rvm/rubies/ruby-2.1.2/bin/ruby -r ./siteconf20150523-1410-ksk5z5.rb extconf.rb --with-jqlib=/tmp/usr/local/lib/libjq
checking for main() in -l/tmp/usr/local/lib/libjq... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/Users/svs/.rvm/rubies/ruby-2.1.2/bin/ruby
    --with-jqlib

extconf failed, exit code 1

Gem files will remain installed in /Users/svs/.rvm/gems/ruby-2.1.2/gems/ruby-jq-0.1.5 for inspection.
Results logged to /Users/svs/.rvm/gems/ruby-2.1.2/extensions/x86_64-darwin-13/2.1.0-static/ruby-jq-0.1.5/gem_make.out

Also, the have_library doesn't seem to recognize the library file

[3] pry(main)> have_library('/Users/svs/tmp/usr/local/lib/jq')
checking for main() in -l/Users/svs/tmp/usr/local/lib/jq... no
=> false
[4] pry(main)> have_library('/Users/svs/tmp/usr/local/lib/jq.dylib')
checking for main() in -l/Users/svs/tmp/usr/local/lib/jq.dylib... no
=> false

I compiled the jq library and ran a make install to install it to standard folder and that is recognized by the system

[5] pry(main)> have_library('jq')
checking for main() in -ljq... yes
=> true

What am I doing wrong?

I need to be able to compile the gem using a compiler directive for the path to the shared library so that I can make a heroku buildpack for ruby-jq.

Please help.

arrays unexpectedly wrapping return values

This gem seems to deviate from the jq binary with regards to the return type of certain queries. Specifically, arrays are wrapping the return value in a number of situations.

Line 22 of spec/jq_spec.rb has

expect(JQ('"Zzz"').search('.')).to eq(['Zzz'])

But running the same query with the jq binary gives

echo '"Zzz"' | jq '.'
# "Zzz"

Why is the addition of the array the appropriate behaviour?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.