Last active
December 22, 2015 09:58
-
-
Save slottermoser/6455148 to your computer and use it in GitHub Desktop.
Load json gem, installing it first if necessary
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
def load_json_gem | |
if `gem list json -i`.chomp! == "false" | |
puts "Installing json gem..." | |
`sudo gem install json` | |
load_json_gem | |
else | |
require 'rubygems' | |
require 'json' | |
end | |
end | |
load_json_gem | |
body = {:text => "hello"} | |
puts body.to_json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment