Improving your Ruby experience

Create a .irbrc file with the following contents:

require 'irbtools'
require "awesome_print"
AwesomePrint.irb!

Now when you get output you can have it nicely printed by "awesome-print". For example:

g> irb
Welcome to IRB. You are using ruby 2.1.3p242 (2014-09-19 revision 47630) [x86_64-linux-gnu]. Have fun ;)
>> require 'canvas-api'
true
>> canvas = Canvas::API.new(:host => "https://kth.instructure.com", :token => "8..K")
#

Look at the list of folders:

>> canvas.get("/api/v1/courses/11/folders")
[
    [0] {
                      "id" => 224,
                    "name" => "course files",
               "full_name" => "course files",
              "context_id" => 11,
            "context_type" => "Course",
        "parent_folder_id" => nil,
              "created_at" => "2016-06-10T08:16:13Z",
              "updated_at" => "2016-06-10T08:16:13Z",
                 "lock_at" => nil,
               "unlock_at" => nil,
                "position" => nil,
                  "locked" => false,
             "folders_url" => "https://kth.instructure.com/api/v1/folders/224/folders",
               "files_url" => "https://kth.instructure.com/api/v1/folders/224/files",
             "files_count" => 9,
           "folders_count" => 6,
                  "hidden" => nil,
         "locked_for_user" => false,
         "hidden_for_user" => false,
         "for_submissions" => false
    },
    [1] {
                      "id" => 343,
                    "name" => "GQM-test-20160623c",
               "full_name" => "course files/GQM-test-20160623c",
              "context_id" => 11,
            "context_type" => "Course",
        "parent_folder_id" => 224,
              "created_at" => "2016-06-22T17:58:57Z",
              "updated_at" => "2016-06-22T17:58:57Z",
                 "lock_at" => nil,
               "unlock_at" => nil,
                "position" => 16,
                  "locked" => false,
             "folders_url" => "https://kth.instructure.com/api/v1/folders/343/folders",
               "files_url" => "https://kth.instructure.com/api/v1/folders/343/files",
             "files_count" => 3,
           "folders_count" => 0,
                  "hidden" => nil,
         "locked_for_user" => false,
         "hidden_for_user" => false,
         "for_submissions" => false
    },
    [2] {
                      "id" => 314,
                    "name" => "II2202-Fall-2014",
               "full_name" => "course files/II2202-Fall-2014",
              "context_id" => 11,
            "context_type" => "Course",
        "parent_folder_id" => 224,
              "created_at" => "2016-06-21T05:14:47Z",
              "updated_at" => "2016-06-21T05:14:47Z",
                 "lock_at" => nil,
               "unlock_at" => nil,
                "position" => 3,
                  "locked" => false,
             "folders_url" => "https://kth.instructure.com/api/v1/folders/314/folders",
               "files_url" => "https://kth.instructure.com/api/v1/folders/314/files",
             "files_count" => 1,
           "folders_count" => 0,
                  "hidden" => nil,
         "locked_for_user" => false,
         "hidden_for_user" => false,
         "for_submissions" => false
    },
    [3] {
                      "id" => 311,
                    "name" => "II2202-Fall-2015",
               "full_name" => "course files/II2202-Fall-2015",
              "context_id" => 11,
            "context_type" => "Course",
        "parent_folder_id" => 224,
              "created_at" => "2016-06-20T12:15:10Z",
              "updated_at" => "2016-06-20T12:15:10Z",
                 "lock_at" => nil,
               "unlock_at" => nil,
                "position" => 2,
                  "locked" => false,
             "folders_url" => "https://kth.instructure.com/api/v1/folders/311/folders",
               "files_url" => "https://kth.instructure.com/api/v1/folders/311/files",
             "files_count" => 5,
           "folders_count" => 0,
                  "hidden" => nil,
         "locked_for_user" => false,
         "hidden_for_user" => false,
         "for_submissions" => false
    },
    [4] {
                      "id" => 283,
                    "name" => "II2202-Fall-2016",
               "full_name" => "course files/II2202-Fall-2016",
              "context_id" => 11,
            "context_type" => "Course",
        "parent_folder_id" => 224,
              "created_at" => "2016-06-15T12:13:51Z",
              "updated_at" => "2016-06-15T12:13:51Z",
                 "lock_at" => nil,
               "unlock_at" => nil,
                "position" => 1,
                  "locked" => false,
             "folders_url" => "https://kth.instructure.com/api/v1/folders/283/folders",
               "files_url" => "https://kth.instructure.com/api/v1/folders/283/files",
             "files_count" => 1,
           "folders_count" => 0,
                  "hidden" => nil,
         "locked_for_user" => false,
         "hidden_for_user" => false,
         "for_submissions" => false
    },
    [5] {
                      "id" => 321,
                    "name" => "Test-folder",
               "full_name" => "course files/Test-folder",
              "context_id" => 11,
            "context_type" => "Course",
        "parent_folder_id" => 224,
              "created_at" => "2016-06-21T13:23:42Z",
              "updated_at" => "2016-06-21T13:23:42Z",
                 "lock_at" => nil,
               "unlock_at" => nil,
                "position" => 4,
                  "locked" => false,
             "folders_url" => "https://kth.instructure.com/api/v1/folders/321/folders",
               "files_url" => "https://kth.instructure.com/api/v1/folders/321/files",
             "files_count" => 0,
           "folders_count" => 0,
                  "hidden" => nil,
         "locked_for_user" => false,
         "hidden_for_user" => false,
         "for_submissions" => false
    },
    [6] {
                      "id" => 348,
                    "name" => "unfiled",
               "full_name" => "course files/unfiled",
              "context_id" => 11,
            "context_type" => "Course",
        "parent_folder_id" => 224,
              "created_at" => "2016-06-23T03:10:06Z",
              "updated_at" => "2016-06-23T03:10:06Z",
                 "lock_at" => nil,
               "unlock_at" => nil,
                "position" => 20,
                  "locked" => false,
             "folders_url" => "https://kth.instructure.com/api/v1/folders/348/folders",
               "files_url" => "https://kth.instructure.com/api/v1/folders/348/files",
             "files_count" => 1,
           "folders_count" => 0,
                  "hidden" => nil,
         "locked_for_user" => false,
         "hidden_for_user" => false,
         "for_submissions" => false
    }
]
>> 

For further information about awesome-print see https://github.com/awesome-print/awesome_print Links to an external site.

 

For further information about irbtools see https://github.com/janlelis/irbtools Links to an external site.