Last active
December 15, 2015 07:29
-
-
Save krames/5223624 to your computer and use it in GitHub Desktop.
Code snippet use to generate rdoc information from Excon::Response
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
| def print_section(obj, i=2) | |
| return if obj.nil? | |
| obj.each_pair do |k, v| | |
| klass = v.nil? ? String : v.class | |
| print " " * i | |
| puts "* '#{k}'<~#{klass}>: -" | |
| print_section(v, i + 1) if v.is_a?(Hash) | |
| print_section(v.first, i + 1) if v.is_a?(Array) | |
| end | |
| end | |
| def print_doc(response, methods=[:headers, :body]) | |
| methods.each do |method| | |
| section = response.send method | |
| next if section.is_a? String | |
| puts " * #{method}<~#{section.class}>:" | |
| print_section section | |
| end | |
| nil | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment