README.md in rubykhan-0.0.3 vs README.md in rubykhan-0.0.4

- old
+ new

@@ -8,79 +8,86 @@ [![Build Status](https://travis-ci.org/abigezunt/rubykhan.png?branch=master)](https://travis-ci.org/abigezunt/rubykhan) [![Code Climate](https://codeclimate.com/github/abigezunt/rubykhan.png)](https://codeclimate.com/github/abigezunt/rubykhan) -```ruby -gem 'rubykhan' -``` +This is a wrapper for the [Khan Academy API](http://api-explorer.khanacademy.org/api/v1/). It is a work in progress, and only supports part of the API. Any assistance with implementing extra calls would be appreciated! -```ruby -require 'rubykhan' -``` +## Installation -## Accessing the Khan Academy API +Add this line to your application's Gemfile: -Information from Khan academy's API is accessed through topic keywords called "slugs" that you can use in your API requests. Topics are arranged hierarchically from the most general (e.g. "math", "science", "humanities") to the very specific. - -To see the whole topic tree hash, you can instantiate a Topic Tree object: - ```ruby -all = KhanAcademy::TopicTree.new +gem 'rubykhan' ``` -And you can inspect the whole hierarchy to see what is returned via json: +And then execute: ```ruby -all.topictree +$ bundle ``` -You can also retrieve a hash of just the topic slugs to choose from for your further queries: +Or install it yourself as: ```ruby -all.topics +$ gem install rubykhan ``` -Another API query returns more detailed information about a topic, including its children, which can be other, more specific topics, or videos and exercises. The most specific sub-sub-topics have videos and exercises, but the top-level topics don't, so you won't get any exercises for a topic like "math" or even something as specific as "algebra", but the topic "solving-linear-equations-and-inequalities does return some exercises. It sometimes takes several queries to get to that level. +## Usage -To query about a topic, instantiate a topic object: +So far, this gem only accesses the publically available parts of the API, but you can request an API key and use OmniAuth to authenticate users using their Khan Academy logins, and to access specific information about users. Try this [Khan Academy OmniAuth gem](https://github.com/dipil-saud/omniauth-khan-academy). +In your main.rb file: + ```ruby -getty_museum = KhanAcademy::Topic.new('getty-museum') +require 'rubykhan' ``` -You can access the json response directly with the `.json` method: +Information from Khan academy's API is accessed through topic keywords called "slugs" that you can use in your API requests. Topics are arranged hierarchically from the most general (e.g. "math", "science", "humanities") to the very specific. -```ruby -getty_museum.json -``` -You can also access many attributes with ruby attribute accessor methods: +You can see an array of all the topic slugs (which you can use for future queries): ```ruby -description = getty_museum.description -title = getty_museum.title -url = getty_museum.url -parent_topic = getty_museum.parent_topic +KhanAcademy::Topic.all ``` -To see the list of related subtopics and videos: +You can also get more information about a topic using the `.get_info` method: ```ruby -children = getty_museum.children +algebra = KhanAcademy::Topic.get_info('algebra') + +algebra.title +algebra.description +algebra.ka_url ``` +More specific topics (e.g. "differential-equations") can return videos and exercises. + ```ruby -algebra = KhanAcademy::Topic.new('algebra') -algebra.subtopics +buddhist_art = KhanAcademy::Playlist.get_exercises("buddhist-art") +buddhist_art.image_url +buddhist_art.prerequisites +buddhist_art.title +buddhist_art.tutorial_only ``` ```ruby -linear_equations = KhanAcademy::Topic.new('solving-linear-equations-and-inequalities') -linear_equations.subtopics +buddhist_art_videos = KhanAcademy::Playlist.get_videos("buddhist-art") +buddhist_art_videos.description +buddhist_art_videos.title +buddhist_art_videos.ka_url ``` More information about the Khan Academy API can be found at the [Khan Academy API Explorer](http://api-explorer.khanacademy.org/api/v1/). + +## Contributing + +1. Fork it +2. Create your feature branch (`git checkout -b my-new-feature`) +3. Commit your changes (`git commit -am 'Add some feature'`) +4. Push to the branch (`git push origin my-new-feature`) +5. Create new Pull Request ## FAQ: Q: What's up with the name?