Skip to content

Instantly share code, notes, and snippets.

@yuya-matsushima
Last active August 29, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuya-matsushima/795e7384c094c725ca87 to your computer and use it in GitHub Desktop.
Save yuya-matsushima/795e7384c094c725ca87 to your computer and use it in GitHub Desktop.
Middleman Directory API Test (Ruby 1.9.3)
# Middleman Directory API test
# Ruby v1.9.3-p551 (rbenv)
require 'open-uri'
require 'json'
amicus = 'https://directory.middlemanapp.com/api/amicus.json'
uri = ::URI.parse(amicus)
p uri.read
# "\x1F\x8B\b\x00\x00\x00\x00\x00\x00\x03%\x8E1\x0F\x820\x14\x84\xFF\xCA\xCB\x9B\x81\x12\xA3\x0El\xEA\xE2\xA0\x13n\xEA\xF0\x84\x06\x1AK\xDB\xF0^5\x84\xF0\xDF\xADa\xBB\\\xEE\xBB\xBB\x19\x1D\r\x1A+<\f\xA6\x89\x8C\x19\xB6\x9A\x9B\xD1\x041\xDE%\xFB|\xBB^vp\xF4\xC6\xEA1X\x12\r\xDB\xA2\xCC\xA0&\xE6\fN~\bI\xC0#\x96\xE5f\x0Fu\xE4\t\xBEFz \x185\a\xEF\xD8|4X\x9A|\x14 \xD7B\f\xB9\xF8\xBC\xFD\xD74\x89\xF5N;\xE1\"\x8DZ\xE3\xDE\x8C\xD5\x8C]\xC2\xE3+\r\xF7\"\x81+\xA5V\xA3Hq\xE5Hz\xCF\x8A\xD6\xA7K\x86B]\x82\xEE\xCF\xE5\az\xFD\xFCx\xC6\x00\x00\x00"
#
p ::JSON.parse(uri.read)
# Error
# unexpected token at ~
other_server = 'https://raw.githubusercontent.com/yterajima/middleman-api-test/master/amicus.json'
uri = ::URI.parse(other_server)
p uri.read
# "{\"name\":\"Amicus\",\"description\":\"HTML5 Boilerplate 4.0, Sass, Compass \\u0026 Susy with a responsive layout and up-to-date components.\",\"links\":{\"github\":\"https://github.com/nathos/amicus\"},\"tags\":[]}\n"
#
p ::JSON.parse(uri.read)
#{"name"=>"Amicus", "description"=>"HTML5 Boilerplate 4.0, Sass, Compass & Susy with a responsive layout and up-to-date components.", "links"=>{"github"=>"https://github.com/nathos/amicus"}, "tags"=>[]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment