rubykhan 0.0.8 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 435f4a3ad9446ea565a088c24b92393a752a4393
4
- data.tar.gz: ea6667b4648599f5995c8f0616e28489a663fe37
3
+ metadata.gz: 6e8c8aace29236b8f54ea38f6122a8edde8426b8
4
+ data.tar.gz: a2d634cdca0ca5a2baa5f85def61df8f4c4d10ea
5
5
  SHA512:
6
- metadata.gz: 043b04ccb29dff4fea8e7d4084831fd0e7d0c0c2e80a4819b38298afb12403bf095c98c2da2a13bb8c6b4f3a94e071c0b0428a7b6f3691d5e374a259f133659c
7
- data.tar.gz: 0d2dd945b5897509dda3376b79204c905770b7a31257687bde27c3b5f886ee3ce0be7ed56885128b9ae0749c0617a77506173061872af83e645519f9f3ea5814
6
+ metadata.gz: ce428b02edb5bf914ba98e12ac7ee35d0c9eff4dbcea5ce77eb6ef60110b248e4cfe433b3b3c1f28826ed6b7fa2b21076caa78e16beaa14e9b1260568aab6f57
7
+ data.tar.gz: 500faabf2eab65667d15f8de381b094a02d8eeab78c715341cb0717ea279e15d8a585091c25e5757e6be8a884becb18139bb1f1a757e08b2833e556b281c169a
data/Gemfile CHANGED
@@ -5,16 +5,13 @@ gem 'rake'
5
5
 
6
6
  group :development do
7
7
  gem 'simplecov'
8
- gem 'jeweler', '~> 1.8.7'
9
8
  gem 'bundler', '~> 1.0'
10
9
  gem 'rdoc', '~> 3.12'
11
- gem 'shoulda', '>=0'
12
10
  end
13
11
 
14
12
  group :test do
15
13
  gem 'webmock'
16
14
  gem 'simplecov'
17
- gem 'coveralls'
15
+ gem 'coveralls', require: false
18
16
  gem 'rspec'
19
- gem 'shoulda-matchers'
20
17
  end
@@ -1,15 +1,7 @@
1
1
  GEM
2
2
  remote: https://rubygems.org/
3
3
  specs:
4
- activesupport (4.0.1)
5
- i18n (~> 0.6, >= 0.6.4)
6
- minitest (~> 4.2)
7
- multi_json (~> 1.3)
8
- thread_safe (~> 0.1)
9
- tzinfo (~> 0.3.37)
10
4
  addressable (2.3.5)
11
- atomic (1.1.14)
12
- builder (3.2.2)
13
5
  coveralls (0.7.0)
14
6
  multi_json (~> 1.3)
15
7
  rest-client
@@ -20,49 +12,13 @@ GEM
20
12
  safe_yaml (~> 0.9.0)
21
13
  diff-lcs (1.2.5)
22
14
  docile (1.1.0)
23
- faraday (0.8.8)
24
- multipart-post (~> 1.2.0)
25
- git (1.2.6)
26
- github_api (0.10.1)
27
- addressable
28
- faraday (~> 0.8.1)
29
- hashie (>= 1.2)
30
- multi_json (~> 1.4)
31
- nokogiri (~> 1.5.2)
32
- oauth2
33
- hashie (2.0.5)
34
- highline (1.6.20)
35
15
  httparty (0.12.0)
36
16
  json (~> 1.8)
37
17
  multi_xml (>= 0.5.2)
38
- httpauth (0.2.0)
39
- i18n (0.6.5)
40
- jeweler (1.8.8)
41
- builder
42
- bundler (~> 1.0)
43
- git (>= 1.2.5)
44
- github_api (= 0.10.1)
45
- highline (>= 1.6.15)
46
- nokogiri (= 1.5.10)
47
- rake
48
- rdoc
49
18
  json (1.8.1)
50
- jwt (0.1.8)
51
- multi_json (>= 1.5)
52
19
  mime-types (2.0)
53
- minitest (4.7.5)
54
20
  multi_json (1.8.2)
55
21
  multi_xml (0.5.5)
56
- multipart-post (1.2.0)
57
- nokogiri (1.5.10)
58
- oauth2 (0.9.2)
59
- faraday (~> 0.8)
60
- httpauth (~> 0.2)
61
- jwt (~> 0.1.4)
62
- multi_json (~> 1.0)
63
- multi_xml (~> 0.5)
64
- rack (~> 1.2)
65
- rack (1.5.2)
66
22
  rake (10.1.0)
67
23
  rdoc (3.12.2)
68
24
  json (~> 1.4)
@@ -77,12 +33,6 @@ GEM
77
33
  diff-lcs (>= 1.1.3, < 2.0)
78
34
  rspec-mocks (2.14.4)
79
35
  safe_yaml (0.9.7)
80
- shoulda (3.5.0)
81
- shoulda-context (~> 1.0, >= 1.0.1)
82
- shoulda-matchers (>= 1.4.1, < 3.0)
83
- shoulda-context (1.1.6)
84
- shoulda-matchers (2.4.0)
85
- activesupport (>= 3.0.0)
86
36
  simplecov (0.8.2)
87
37
  docile (~> 1.1.0)
88
38
  multi_json
@@ -91,10 +41,7 @@ GEM
91
41
  term-ansicolor (1.2.2)
92
42
  tins (~> 0.8)
93
43
  thor (0.18.1)
94
- thread_safe (0.1.3)
95
- atomic
96
44
  tins (0.12.0)
97
- tzinfo (0.3.38)
98
45
  webmock (1.15.0)
99
46
  addressable (>= 2.2.7)
100
47
  crack (>= 0.3.2)
@@ -106,11 +53,8 @@ DEPENDENCIES
106
53
  bundler (~> 1.0)
107
54
  coveralls
108
55
  httparty
109
- jeweler (~> 1.8.7)
110
56
  rake
111
57
  rdoc (~> 3.12)
112
58
  rspec
113
- shoulda
114
- shoulda-matchers
115
59
  simplecov
116
60
  webmock
data/README.md CHANGED
@@ -4,11 +4,9 @@
4
4
 
5
5
  [![Gem Version](https://badge.fury.io/rb/rubykhan.png)](http://badge.fury.io/rb/rubykhan)
6
6
 
7
- [![Coverage Status](https://coveralls.io/repos/abigezunt/rubykhan/badge.png)](https://coveralls.io/r/abigezunt/rubykhan)
7
+ [![Coverage Status](https://coveralls.io/repos/abigezunt/RubyKhan/badge.png)](https://coveralls.io/r/abigezunt/RubyKhan)
8
8
 
9
- [![Build Status](https://travis-ci.org/abigezunt/rubykhan.png?branch=master)](https://travis-ci.org/abigezunt/rubykhan)
10
-
11
- [![Code Climate](https://codeclimate.com/github/abigezunt/rubykhan.png)](https://codeclimate.com/github/abigezunt/rubykhan)
9
+ [![Build Status](https://travis-ci.org/abigezunt/RubyKhan.png?branch=master)](https://travis-ci.org/abigezunt/RubyKhan)
12
10
 
13
11
  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!
14
12
 
@@ -45,12 +43,20 @@ require 'rubykhan'
45
43
  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.
46
44
 
47
45
 
48
- You can see an array of all the topic slugs (which you can use for future queries):
46
+ You can see an array of all the nested topic slugs (which you can use for future queries). The default query is for 'extended_slug' which sounds gross, but which returns an array of nested topics of which you can pull out the most specific titles to look for videos and exercises:
49
47
 
50
48
  ```ruby
51
49
  KhanAcademy::Topic.all
52
50
  ```
53
51
 
52
+ You can also pass in a key and find all the titles, or the urls, or the topic slugs. For example:
53
+
54
+ ```ruby
55
+ KhanAcademy::Topic.all('slug')
56
+ KhanAcademy::Topic.all('title')
57
+ KhanAcademy::Topic.all('node_slug')
58
+ ```
59
+
54
60
  You can also get more information about a topic using the `.get_info` method:
55
61
 
56
62
  ```ruby
@@ -61,7 +67,7 @@ algebra.description
61
67
  algebra.ka_url
62
68
  ```
63
69
 
64
- More specific topics (e.g. "differential-equations") can return videos and exercises.
70
+ More specific topics (e.g. "differential-equations", "buddhist-art", "blood-vessels") can return videos and exercises.
65
71
 
66
72
  ```ruby
67
73
  buddhist_art = KhanAcademy::Playlist.get_exercises("buddhist-art")
@@ -72,10 +78,16 @@ buddhist_art.tutorial_only
72
78
  ```
73
79
 
74
80
  ```ruby
75
- buddhist_art_videos = KhanAcademy::Playlist.get_videos("buddhist-art")
76
- buddhist_art_videos.description
77
- buddhist_art_videos.title
78
- buddhist_art_videos.ka_url
81
+ blood_vessels_videos = KhanAcademy::Playlist.get_videos("blood-vessels")
82
+ blood_vessels_videos.description
83
+ blood_vessels_videos.title
84
+ blood_vessels_videos.ka_url
85
+ ```
86
+
87
+ To see the entire (huge) Topic Tree from Khan academy, use the Topic.tree method:
88
+
89
+ ```ruby
90
+ KhanAcademy::Topic.tree
79
91
  ```
80
92
 
81
93
  More information about the Khan Academy API can be found at the [Khan Academy API Explorer](http://api-explorer.khanacademy.org/api/v1/).
@@ -94,10 +106,3 @@ Q: What's up with the name?
94
106
 
95
107
  A: It's a pun on [Crossing the Rubicon](https://www.khanacademy.org/humanities/history/ancient-medieval/Ancient/v/a-tour-through-ancient-rome-in-320-c-e). Julius Caesar would've used Ruby in his conquest of Gaul, and we want you to be able to use Ruby in your Khan Academy app. :)
96
108
 
97
- ## CONTRIBUTING
98
-
99
- 1. Fork it
100
- 2. Create your feature branch (`git checkout -b my-new-feature`)
101
- 3. Commit your changes (`git commit -am 'Add some feature'`)
102
- 4. Push to the branch (`git push origin my-new-feature`)
103
- 5. Create new Pull Request
@@ -2,68 +2,72 @@ require 'httparty'
2
2
  require 'json'
3
3
 
4
4
 
5
+
5
6
  def values(hsh, key)
6
- return [] if !hsh.kind_of? Hash
7
- v = hsh[key] ? [hsh[key]] : []
8
- hsh.values.select{|i| i.kind_of? Hash or i.kind_of? Array}.each do |val|
9
- if val.kind_of? Hash
10
- v+= values(val, key)
11
- else
12
- val.each {|i| v+= values(i, key)}
13
- end
14
- end
15
- return v
7
+ return [] unless hsh.kind_of? Hash
8
+ v = hsh[key] ? [hsh[key]] : []
9
+ return v
16
10
  end
17
11
 
18
12
 
19
13
  module KhanAcademy
20
14
 
21
- class Topic
15
+ class Topic
16
+ include HTTParty
17
+ format :json
18
+
22
19
  attr_reader :icon_src, :domain_slug, :relative_url, :web_url, :ka_url, :translated_standalone_title, :translated_title, :gplus_url, :id, :old_key_name, :hide, :title, :child_data, :children, :twitter_url, :translated_description, :deleted_mod_time, :logo_image_url, :in_knowledge_map, :description, :x_pos, :node_slug, :deleted, :facebook_url, :backup_timestamp, :render_type, :background_image_url, :background_image_caption, :assessment_progress_key, :topic_page_url, :extended_slug, :slug, :tags, :kind, :in_topic_browser, :sha, :standalone_title, :y_pos, :current_revision_key, :content_kind
23
20
 
24
21
  def initialize(options)
25
- options.each do |key, value|
26
- unless key.to_s.empty?
27
- eval("@#{key}=#{value.inspect}")
22
+ options.each do |key, value|
23
+ unless key.to_s.empty?
24
+ eval("@#{key}=#{value.inspect}")
28
25
  end
29
- end
26
+ end
30
27
  end
31
28
 
32
29
  def self.get_info(topic)
33
30
  uri = "http://www.KhanAcademy.org/api/v1/topic/#{topic}"
34
- options = HTTParty.get(uri)
31
+ options = KhanAcademy::Playlist.get(uri)
35
32
  new(options)
36
33
  end
37
34
 
38
- def self.all
35
+ def self.all(key = "extended_slug")
36
+ uri = "http://www.khanacademy.org/api/v1/topictree"
37
+ options = KhanAcademy::Playlist.get(uri).to_hash
38
+ values(options, key)
39
+ end
40
+
41
+ def self.tree
39
42
  uri = "http://www.khanacademy.org/api/v1/topictree"
40
- options = HTTParty.get(uri).to_hash
41
- values(options, 'slug')
43
+ topictree = KhanAcademy::Playlist.get(uri)
42
44
  end
43
45
 
44
46
  end
45
47
 
46
48
  class Playlist
49
+ include HTTParty
50
+ format :json
47
51
  attr_reader :translated_short_display_name, :assessment_items, :relative_url, :file_name, :author_name, :creation_date, :uses_assessment_items, :all_assessment_item_keys, :ka_url, :v_position, :translated_title, :translated_description_html, :display_name, :tracking_document_url, :tags, :summative, :live, :pretty_display_name, :translated_pretty_display_name, :problem_types, :curated_related_videos, :covers, :h_position, :translated_display_name, :sha1, :name, :prerequisites, :assessment_item_tags, :seconds_per_fast_problem, :short_display_name, :tutorial_only, :current_revision_key, :image_url_256, :content_ki, :translated_youtube_id, :has_questions, :keywords, :duration, :id, :description_html, :title, :progress_key, :edit_slug, :author_names, :deleted_mod_time, :description, :extra_properties, :node_slug, :deleted, :backup_timestamp, :date_added, :download_urls, :translated_youtube_lang, :kind, :url, :ka_user_license, :global_id, :sha, :translated_description, :image_url, :youtube_id, :position, :content_kind, :readable_id
48
52
 
49
53
  def initialize(options)
50
- options.each do |key, value|
51
- unless key.to_s.empty?
52
- eval("@#{key}=#{value.inspect}")
54
+ options.each do |key, value|
55
+ unless key.to_s.empty?
56
+ eval("@#{key}=#{value.inspect}")
53
57
  end
54
- end
58
+ end
55
59
  end
56
60
 
57
61
  def self.get_exercises(topic)
58
62
  uri = "http://www.KhanAcademy.org/api/v1/playlists/#{topic}/exercises"
59
- options = HTTParty.get(uri)
60
- new(options.first)
63
+ options = KhanAcademy::Playlist.get(uri)
64
+ options.collect {|json| new(json)}
61
65
  end
62
66
 
63
67
  def self.get_videos(topic)
64
68
  uri = "http://www.KhanAcademy.org/api/v1/playlists/#{topic}/videos"
65
- options = HTTParty.get(uri)
66
- new(options.first)
69
+ options = KhanAcademy::Playlist.get(uri)
70
+ options.collect {|json| new(json)}
67
71
  end
68
72
 
69
73
  end
@@ -1,3 +1,3 @@
1
1
  module Rubykhan
2
- VERSION = "0.0.8"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["Dan Crews", "Abby Howell"]
10
10
  spec.email = ["abbyghowell@gmail.com", "dancrews@me.com"]
11
11
  spec.description = %q{A Ruby wrapper for the Khan Academy API}
12
- spec.summary = %q{Simplififies API requests}
12
+ spec.summary = %q{Simplifies API requests with a Ruby application.}
13
13
  spec.homepage = "https://github.com/DannyCrews/rubykhan"
14
14
  spec.license = "MIT"
15
15
 
@@ -20,8 +20,6 @@ Gem::Specification.new do |spec|
20
20
  spec.add_development_dependency "rspec"
21
21
  spec.add_development_dependency "bundler", "~> 1.3"
22
22
  spec.add_development_dependency "rake"
23
- spec.add_dependency 'hashie', '~> 2.0'
24
23
  spec.add_dependency 'json', '~> 1.8'
25
- spec.add_dependency 'rash', '~> 0.4'
26
24
  spec.add_dependency 'httparty'
27
25
  end
@@ -0,0 +1 @@
1
+ [{"translated_short_display_name": "Buddhist", "assessment_items": ["ag5zfmtoYW4tYWNhZGVteXIdCxIOQXNzZXNzbWVudEl0ZW0iCXgzYTFlNjcyNAw", "ag5zfmtoYW4tYWNhZGVteXIdCxIOQXNzZXNzbWVudEl0ZW0iCXhlYTU2ZWNlMQw", "ag5zfmtoYW4tYWNhZGVteXIdCxIOQXNzZXNzbWVudEl0ZW0iCXg5OGE0ODc1Mgw", "ag5zfmtoYW4tYWNhZGVteXIdCxIOQXNzZXNzbWVudEl0ZW0iCXhmMzMxY2JhNAw", "ag5zfmtoYW4tYWNhZGVteXIdCxIOQXNzZXNzbWVudEl0ZW0iCXg5ZmVjYzY3Zgw", "ag5zfmtoYW4tYWNhZGVteXIdCxIOQXNzZXNzbWVudEl0ZW0iCXgzZDc4ZTNjYww", "ag5zfmtoYW4tYWNhZGVteXIdCxIOQXNzZXNzbWVudEl0ZW0iCXg3YWZlOGRiNAw", "ag5zfmtoYW4tYWNhZGVteXIlCxIOQXNzZXNzbWVudEl0ZW0iEXhkMzUxNmRiNDhmNzVlZjE5DA", "ag5zfmtoYW4tYWNhZGVteXIdCxIOQXNzZXNzbWVudEl0ZW0iCXg4NzU4MzdjOQw", "ag5zfmtoYW4tYWNhZGVteXIdCxIOQXNzZXNzbWVudEl0ZW0iCXg1YzcyOTljNAw", "ag5zfmtoYW4tYWNhZGVteXIdCxIOQXNzZXNzbWVudEl0ZW0iCXg3ZTJlM2VjNww"], "relative_url": "/exercise/buddhist-art", "file_name": null, "author_name": "Beth", "creation_date": "2013-07-25T22:47:58Z", "uses_assessment_items": true, "all_assessment_item_keys": ["ag5zfmtoYW4tYWNhZGVteXIdCxIOQXNzZXNzbWVudEl0ZW0iCXgzYTFlNjcyNAw", "ag5zfmtoYW4tYWNhZGVteXIdCxIOQXNzZXNzbWVudEl0ZW0iCXhlYTU2ZWNlMQw", "ag5zfmtoYW4tYWNhZGVteXIdCxIOQXNzZXNzbWVudEl0ZW0iCXg5OGE0ODc1Mgw", "ag5zfmtoYW4tYWNhZGVteXIdCxIOQXNzZXNzbWVudEl0ZW0iCXhmMzMxY2JhNAw", "ag5zfmtoYW4tYWNhZGVteXIdCxIOQXNzZXNzbWVudEl0ZW0iCXg5ZmVjYzY3Zgw", "ag5zfmtoYW4tYWNhZGVteXIdCxIOQXNzZXNzbWVudEl0ZW0iCXgzZDc4ZTNjYww", "ag5zfmtoYW4tYWNhZGVteXIdCxIOQXNzZXNzbWVudEl0ZW0iCXg3YWZlOGRiNAw", "ag5zfmtoYW4tYWNhZGVteXIlCxIOQXNzZXNzbWVudEl0ZW0iEXhkMzUxNmRiNDhmNzVlZjE5DA", "ag5zfmtoYW4tYWNhZGVteXIdCxIOQXNzZXNzbWVudEl0ZW0iCXg4NzU4MzdjOQw", "ag5zfmtoYW4tYWNhZGVteXIdCxIOQXNzZXNzbWVudEl0ZW0iCXg1YzcyOTljNAw", "ag5zfmtoYW4tYWNhZGVteXIdCxIOQXNzZXNzbWVudEl0ZW0iCXg3ZTJlM2VjNww"], "ka_url": "http://www.KhanAcademy.org/exercise/buddhist-art", "v_position": 0, "translated_title": "Buddhist Art", "translated_description_html": "", "id": "x5a200d1b", "display_name": "Buddhist Art", "tracking_document_url": null, "description_html": "", "sha": "5cc53e630c8f9752766f8cfd9c3fc0db6c76d76e", "tags": [], "progress_key": "ex5a200d1b", "edit_slug": "edit/e/x5a200d1b", "summative": false, "live": true, "translated_description": "", "pretty_display_name": "Buddhist Art", "deleted_mod_time": null, "description": "", "translated_pretty_display_name": "Buddhist Art", "node_slug": "e/buddhist-art", "deleted": false, "backup_timestamp": "2013-09-29T10:38:26Z", "problem_types": [{"items": [{"sha": "3c89905a245ccb477a9994e79839fae83587ff3f", "live": true, "id": "x3a1e6724"}, {"sha": "365c47d8967912e412924b07b6ca78e41c003dab", "live": true, "id": "xea56ece1"}, {"sha": "72c1b832f68495f2c4c7ca2adb7542e3425a04d7", "live": true, "id": "x98a48752"}, {"sha": "8a09284da73742f27247a452d7a8bf3dcda18313", "live": true, "id": "xf331cba4"}, {"sha": "8f26d3681ddeaf2cf534228ed1b82d79923491e7", "live": true, "id": "x9fecc67f"}, {"sha": "56245500f2180ea1840d5516c1df574003f94364", "live": true, "id": "x3d78e3cc"}, {"sha": "6dfde8cc27962245ff2b303e84bf820e1e0de788", "live": true, "id": "x7afe8db4"}, {"sha": "f093a9e51c0cea106ef7b1512bc99f0776008c7b", "live": true, "id": "xd3516db48f75ef19"}, {"sha": "5d827803897cf744562d1e69164429ab5fbc945c", "live": true, "id": "x875837c9"}, {"sha": "be267c7553fa3b7101fdd1180521e9a3b4b7ce8c", "live": true, "id": "x5c7299c4"}, {"sha": "a9cbb2508a10d599630659524a937c36ced7d5f5", "live": true, "id": "x7e2e3ec7"}], "name": "A"}], "curated_related_videos": [], "covers": [], "h_position": 0, "translated_display_name": "Buddhist Art", "kind": "Exercise", "sha1": "6ad35adda6a0217606c13115f2e47d9a6541af01", "name": "buddhist-art", "prerequisites": [], "assessment_item_tags": [], "title": "Buddhist Art", "global_id": "ex5a200d1b", "seconds_per_fast_problem": 4.0, "short_display_name": "Buddhist", "image_url": "https://ka-exercise-screenshots.s3.amazonaws.com/buddhist-art.png", "tutorial_only": true, "current_revision_key": "5cc53e630c8f9752766f8cfd9c3fc0db6c76d76e", "image_url_256": "https://ka-exercise-screenshots.s3.amazonaws.com/buddhist-art_256.png", "content_kind": "Exercise"}]
@@ -0,0 +1 @@
1
+ [{"translated_youtube_id": "QhiVnFvshZg", "relative_url": "/video/circulatory-system-and-the-heart", "has_questions": false, "keywords": "heart, blood, vein, artery, pulmonary, atrium, ventricle", "ka_url": "http://www.KhanAcademy.org/video/circulatory-system-and-the-heart", "duration": 897, "translated_title": "Circulatory system and the heart", "translated_description_html": "Introduction to the circulatory system and the heart", "id": "23990", "description_html": "Introduction to the circulatory system and the heart", "title": "Circulatory system and the heart", "progress_key": "v23990", "edit_slug": "edit/v/23990", "author_names": ["Sal Khan"], "deleted_mod_time": "2013-07-13T00:03:08Z", "description": "Introduction to the circulatory system and the heart", "extra_properties": null, "node_slug": "v/circulatory-system-and-the-heart", "deleted": false, "backup_timestamp": "2013-09-23T10:33:40Z", "date_added": "2011-02-20T16:31:16Z", "download_urls": {"mp4": "http://s3.amazonaws.com/KA-youtube-converted/QhiVnFvshZg.mp4/QhiVnFvshZg.mp4", "png": "http://s3.amazonaws.com/KA-youtube-converted/QhiVnFvshZg.mp4/QhiVnFvshZg.png", "m3u8": "http://s3.amazonaws.com/KA-youtube-converted/QhiVnFvshZg.m3u8/QhiVnFvshZg.m3u8"}, "translated_youtube_lang": "en", "kind": "Video", "url": "http://www.youtube.com/watch?v=QhiVnFvshZg&feature=youtube_gdata_player", "ka_user_license": "cc-by-nc-sa", "global_id": "v23990", "sha": "d6483ee6ad4bbd4b840674127723f3f168920f4c", "translated_description": "Introduction to the circulatory system and the heart", "image_url": "https://img.youtube.com/vi/QhiVnFvshZg/hqdefault.jpg", "youtube_id": "QhiVnFvshZg", "position": 1, "content_kind": "Video", "readable_id": "circulatory-system-and-the-heart"}, {"translated_youtube_id": "7b6LRebCgb4", "relative_url": "/video/arteries-vs--veins---what-s-the-difference", "has_questions": "live", "keywords": "", "ka_url": "http://www.KhanAcademy.org/video/arteries-vs--veins---what-s-the-difference", "duration": 669, "translated_title": "Arteries vs. veins - what's the difference?", "translated_description_html": "Learn some important differences between arteries (high pressure/low volume) and veins (low pressure/high volume). Rishi is a pediatric infectious disease physician and works at Khan Academy.", "id": "1036157588", "description_html": "Learn some important differences between arteries (high pressure/low volume) and veins (low pressure/high volume). Rishi is a pediatric infectious disease physician and works at Khan Academy.", "title": "Arteries vs. veins - what's the difference?", "progress_key": "v1036157588", "edit_slug": "edit/v/1036157588", "author_names": ["Rishi Desai"], "deleted_mod_time": "2013-07-13T00:03:08Z", "description": "Learn some important differences between arteries (high pressure/low volume) and veins (low pressure/high volume). Rishi is a pediatric infectious disease physician and works at Khan Academy.", "extra_properties": null, "node_slug": "v/arteries-vs--veins---what-s-the-difference", "deleted": false, "backup_timestamp": "2013-09-23T10:33:40Z", "date_added": "2012-09-13T21:08:09Z", "download_urls": {"mp4": "http://s3.amazonaws.com/KA-youtube-converted/7b6LRebCgb4.mp4/7b6LRebCgb4.mp4", "png": "http://s3.amazonaws.com/KA-youtube-converted/7b6LRebCgb4.mp4/7b6LRebCgb4.png", "m3u8": "http://s3.amazonaws.com/KA-youtube-converted/7b6LRebCgb4.m3u8/7b6LRebCgb4.m3u8"}, "translated_youtube_lang": "en", "kind": "Video", "url": "http://www.youtube.com/watch?v=7b6LRebCgb4&feature=youtube_gdata_player", "ka_user_license": "cc-by-nc-sa", "global_id": "v1036157588", "sha": "595d77aab17e8acb9c8d7e46affd3924b6bd0050", "translated_description": "Learn some important differences between arteries (high pressure/low volume) and veins (low pressure/high volume). Rishi is a pediatric infectious disease physician and works at Khan Academy.", "image_url": "https://img.youtube.com/vi/7b6LRebCgb4/hqdefault.jpg", "youtube_id": "7b6LRebCgb4", "position": 2, "content_kind": "Video", "readable_id": "arteries-vs--veins---what-s-the-difference"}, {"translated_youtube_id": "VMwa6yC3r-s", "relative_url": "/video/layers-of-a-blood-vessel", "has_questions": false, "keywords": "", "ka_url": "http://www.KhanAcademy.org/video/layers-of-a-blood-vessel", "duration": 611, "translated_title": "Layers of a blood vessel", "translated_description_html": "Remember the 3 key layers of a blood vessel (Tunica intima, Tunica media, and Tunica externa) and how arteries, veins, and capillaries are all different from one another. Rishi is a pediatric infectious disease physician and works at Khan Academy.", "id": "1036278079", "description_html": "Remember the 3 key layers of a blood vessel (Tunica intima, Tunica media, and Tunica externa) and how arteries, veins, and capillaries are all different from one another. Rishi is a pediatric infectious disease physician and works at Khan Academy.", "title": "Layers of a blood vessel", "progress_key": "v1036278079", "edit_slug": "edit/v/1036278079", "author_names": ["Rishi Desai"], "deleted_mod_time": "2013-07-13T00:03:08Z", "description": "Remember the 3 key layers of a blood vessel (Tunica intima, Tunica media, and Tunica externa) and how arteries, veins, and capillaries are all different from one another. Rishi is a pediatric infectious disease physician and works at Khan Academy.", "extra_properties": null, "node_slug": "v/layers-of-a-blood-vessel", "deleted": false, "backup_timestamp": "2013-09-23T10:33:39Z", "date_added": "2012-09-13T21:08:40Z", "download_urls": {"mp4": "http://s3.amazonaws.com/KA-youtube-converted/VMwa6yC3r-s.mp4/VMwa6yC3r-s.mp4", "png": "http://s3.amazonaws.com/KA-youtube-converted/VMwa6yC3r-s.mp4/VMwa6yC3r-s.png", "m3u8": "http://s3.amazonaws.com/KA-youtube-converted/VMwa6yC3r-s.m3u8/VMwa6yC3r-s.m3u8"}, "translated_youtube_lang": "en", "kind": "Video", "url": "http://www.youtube.com/watch?v=VMwa6yC3r-s&feature=youtube_gdata_player", "ka_user_license": "cc-by-nc-sa", "global_id": "v1036278079", "sha": "3d8bb871360a3720e092231912498591568f04a6", "translated_description": "Remember the 3 key layers of a blood vessel (Tunica intima, Tunica media, and Tunica externa) and how arteries, veins, and capillaries are all different from one another. Rishi is a pediatric infectious disease physician and works at Khan Academy.", "image_url": "https://img.youtube.com/vi/VMwa6yC3r-s/hqdefault.jpg", "youtube_id": "VMwa6yC3r-s", "position": 3, "content_kind": "Video", "readable_id": "layers-of-a-blood-vessel"}, {"translated_youtube_id": "iqRTd1NY-pU", "relative_url": "/video/arteries--arterioles--venules--and-veins", "has_questions": false, "keywords": "", "ka_url": "http://www.KhanAcademy.org/video/arteries--arterioles--venules--and-veins", "duration": 463, "translated_title": "Arteries, arterioles, venules, and veins", "translated_description_html": "Learn the differences between these blood vessels! Rishi is a pediatric infectious disease physician and works at Khan Academy.\n\nThese videos do not provide medical advice and are for informational purposes only. The videos are not intended to be a substitute for professional medical advice, diagnosis or treatment. Always seek the advice of a qualified health provider with any questions you may have regarding a medical condition. Never disregard professional medical advice or delay in seeking it because of something you have read or seen in any Khan Academy video.", "id": "x7ac317cf", "description_html": "Learn the differences between these blood vessels! Rishi is a pediatric infectious disease physician and works at Khan Academy.\n\nThese videos do not provide medical advice and are for informational purposes only. The videos are not intended to be a substitute for professional medical advice, diagnosis or treatment. Always seek the advice of a qualified health provider with any questions you may have regarding a medical condition. Never disregard professional medical advice or delay in seeking it because of something you have read or seen in any Khan Academy video.", "title": "Arteries, arterioles, venules, and veins", "progress_key": "vx7ac317cf", "edit_slug": "edit/v/x7ac317cf", "author_names": ["Rishi Desai"], "deleted_mod_time": "2013-07-13T00:03:07Z", "description": "Learn the differences between these blood vessels! Rishi is a pediatric infectious disease physician and works at Khan Academy.\n\nThese videos do not provide medical advice and are for informational purposes only. The videos are not intended to be a substitute for professional medical advice, diagnosis or treatment. Always seek the advice of a qualified health provider with any questions you may have regarding a medical condition. Never disregard professional medical advice or delay in seeking it because of something you have read or seen in any Khan Academy video.", "extra_properties": {"original_url": ""}, "node_slug": "v/arteries--arterioles--venules--and-veins", "deleted": false, "backup_timestamp": "2013-09-22T10:35:40Z", "date_added": "2013-03-20T23:39:54Z", "download_urls": {"mp4": "http://s3.amazonaws.com/KA-youtube-converted/iqRTd1NY-pU.mp4/iqRTd1NY-pU.mp4", "png": "http://s3.amazonaws.com/KA-youtube-converted/iqRTd1NY-pU.mp4/iqRTd1NY-pU.png", "m3u8": "http://s3.amazonaws.com/KA-youtube-converted/iqRTd1NY-pU.m3u8/iqRTd1NY-pU.m3u8"}, "translated_youtube_lang": "en", "kind": "Video", "url": "http://www.youtube.com/watch?v=iqRTd1NY-pU&feature=youtube_gdata_player", "ka_user_license": "cc-by-nc-sa", "global_id": "vx7ac317cf", "sha": "a6fcbb9a4a6b1a5ad344d7f74f57264acc1c1090", "translated_description": "Learn the differences between these blood vessels! Rishi is a pediatric infectious disease physician and works at Khan Academy.\n\nThese videos do not provide medical advice and are for informational purposes only. The videos are not intended to be a substitute for professional medical advice, diagnosis or treatment. Always seek the advice of a qualified health provider with any questions you may have regarding a medical condition. Never disregard professional medical advice or delay in seeking it because of something you have read or seen in any Khan Academy video.", "image_url": "https://img.youtube.com/vi/iqRTd1NY-pU/hqdefault.jpg", "youtube_id": "iqRTd1NY-pU", "position": 4, "content_kind": "Video", "readable_id": "arteries--arterioles--venules--and-veins"}, {"translated_youtube_id": "hSkIG4MdKqU", "relative_url": "/video/three-types-of-capillaries", "has_questions": false, "keywords": "", "ka_url": "http://www.KhanAcademy.org/video/three-types-of-capillaries", "duration": 557, "translated_title": "Three types of capillaries", "translated_description_html": "Learn the differences between continuous, fenestrated, and discontinuous capillaries, and how they affect the movement of molecules. Rishi is a pediatric infectious disease physician and works at Khan Academy.\n\nThese videos do not provide medical advice and are for informational purposes only. The videos are not intended to be a substitute for professional medical advice, diagnosis or treatment. Always seek the advice of a qualified health provider with any questions you may have regarding a medical condition. Never disregard professional medical advice or delay in seeking it because of something you have read or seen in any Khan Academy video.", "id": "x6451892a", "description_html": "Learn the differences between continuous, fenestrated, and discontinuous capillaries, and how they affect the movement of molecules. Rishi is a pediatric infectious disease physician and works at Khan Academy.\n\nThese videos do not provide medical advice and are for informational purposes only. The videos are not intended to be a substitute for professional medical advice, diagnosis or treatment. Always seek the advice of a qualified health provider with any questions you may have regarding a medical condition. Never disregard professional medical advice or delay in seeking it because of something you have read or seen in any Khan Academy video.", "title": "Three types of capillaries", "progress_key": "vx6451892a", "edit_slug": "edit/v/x6451892a", "author_names": ["Rishi Desai"], "deleted_mod_time": "2013-07-13T00:03:08Z", "description": "Learn the differences between continuous, fenestrated, and discontinuous capillaries, and how they affect the movement of molecules. Rishi is a pediatric infectious disease physician and works at Khan Academy.\n\nThese videos do not provide medical advice and are for informational purposes only. The videos are not intended to be a substitute for professional medical advice, diagnosis or treatment. Always seek the advice of a qualified health provider with any questions you may have regarding a medical condition. Never disregard professional medical advice or delay in seeking it because of something you have read or seen in any Khan Academy video.", "extra_properties": {"original_url": ""}, "node_slug": "v/three-types-of-capillaries", "deleted": false, "backup_timestamp": "2013-09-22T10:35:39Z", "date_added": "2013-03-20T23:40:13Z", "download_urls": {"mp4": "http://s3.amazonaws.com/KA-youtube-converted/hSkIG4MdKqU.mp4/hSkIG4MdKqU.mp4", "png": "http://s3.amazonaws.com/KA-youtube-converted/hSkIG4MdKqU.mp4/hSkIG4MdKqU.png", "m3u8": "http://s3.amazonaws.com/KA-youtube-converted/hSkIG4MdKqU.m3u8/hSkIG4MdKqU.m3u8"}, "translated_youtube_lang": "en", "kind": "Video", "url": "http://www.youtube.com/watch?v=hSkIG4MdKqU&feature=youtube_gdata_player", "ka_user_license": "cc-by-nc-sa", "global_id": "vx6451892a", "sha": "a2910159898ae12e5cc33fbf7c9c6bd8cc858a7e", "translated_description": "Learn the differences between continuous, fenestrated, and discontinuous capillaries, and how they affect the movement of molecules. Rishi is a pediatric infectious disease physician and works at Khan Academy.\n\nThese videos do not provide medical advice and are for informational purposes only. The videos are not intended to be a substitute for professional medical advice, diagnosis or treatment. Always seek the advice of a qualified health provider with any questions you may have regarding a medical condition. Never disregard professional medical advice or delay in seeking it because of something you have read or seen in any Khan Academy video.", "image_url": "https://img.youtube.com/vi/hSkIG4MdKqU/hqdefault.jpg", "youtube_id": "hSkIG4MdKqU", "position": 5, "content_kind": "Video", "readable_id": "three-types-of-capillaries"}, {"translated_youtube_id": "yeX0uDpPBj4", "relative_url": "/video/pre-capillary-sphincters", "has_questions": false, "keywords": "", "ka_url": "http://www.KhanAcademy.org/video/pre-capillary-sphincters", "duration": 260, "translated_title": "Pre-capillary sphincters", "translated_description_html": "Find out how the body controls how much blood flows through a capillary bed. Rishi is a pediatric infectious disease physician and works at Khan Academy.\n\nThese videos do not provide medical advice and are for informational purposes only. The videos are not intended to be a substitute for professional medical advice, diagnosis or treatment. Always seek the advice of a qualified health provider with any questions you may have regarding a medical condition. Never disregard professional medical advice or delay in seeking it because of something you have read or seen in any Khan Academy video.", "id": "x02c66e8b", "description_html": "Find out how the body controls how much blood flows through a capillary bed. Rishi is a pediatric infectious disease physician and works at Khan Academy.\n\nThese videos do not provide medical advice and are for informational purposes only. The videos are not intended to be a substitute for professional medical advice, diagnosis or treatment. Always seek the advice of a qualified health provider with any questions you may have regarding a medical condition. Never disregard professional medical advice or delay in seeking it because of something you have read or seen in any Khan Academy video.", "title": "Pre-capillary sphincters", "progress_key": "vx02c66e8b", "edit_slug": "edit/v/x02c66e8b", "author_names": ["Rishi Desai"], "deleted_mod_time": "2013-07-13T00:03:08Z", "description": "Find out how the body controls how much blood flows through a capillary bed. Rishi is a pediatric infectious disease physician and works at Khan Academy.\n\nThese videos do not provide medical advice and are for informational purposes only. The videos are not intended to be a substitute for professional medical advice, diagnosis or treatment. Always seek the advice of a qualified health provider with any questions you may have regarding a medical condition. Never disregard professional medical advice or delay in seeking it because of something you have read or seen in any Khan Academy video.", "extra_properties": {"original_url": ""}, "node_slug": "v/pre-capillary-sphincters", "deleted": false, "backup_timestamp": "2013-09-23T10:33:41Z", "date_added": "2013-03-20T23:40:30Z", "download_urls": {"mp4": "http://s3.amazonaws.com/KA-youtube-converted/yeX0uDpPBj4.mp4/yeX0uDpPBj4.mp4", "png": "http://s3.amazonaws.com/KA-youtube-converted/yeX0uDpPBj4.mp4/yeX0uDpPBj4.png", "m3u8": "http://s3.amazonaws.com/KA-youtube-converted/yeX0uDpPBj4.m3u8/yeX0uDpPBj4.m3u8"}, "translated_youtube_lang": "en", "kind": "Video", "url": "http://www.youtube.com/watch?v=yeX0uDpPBj4&feature=youtube_gdata_player", "ka_user_license": "cc-by-nc-sa", "global_id": "vx02c66e8b", "sha": "e600d0ee6fdd039ed6578b1cc6bb3c51ce5cb6fe", "translated_description": "Find out how the body controls how much blood flows through a capillary bed. Rishi is a pediatric infectious disease physician and works at Khan Academy.\n\nThese videos do not provide medical advice and are for informational purposes only. The videos are not intended to be a substitute for professional medical advice, diagnosis or treatment. Always seek the advice of a qualified health provider with any questions you may have regarding a medical condition. Never disregard professional medical advice or delay in seeking it because of something you have read or seen in any Khan Academy video.", "image_url": "https://img.youtube.com/vi/yeX0uDpPBj4/hqdefault.jpg", "youtube_id": "yeX0uDpPBj4", "position": 6, "content_kind": "Video", "readable_id": "pre-capillary-sphincters"}]
@@ -1,41 +1,99 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe 'RubyKhan' do
4
- describe '.new' do
4
+
5
+ describe '.new' do
6
+
5
7
  before do
6
8
  stub_request(:get, 'http://www.KhanAcademy.org/api/v1/topic/probability').
7
9
  to_return(body: fixture('probability.json'))
10
+ @probability = KhanAcademy::Topic.get_info('probability')
11
+ end
12
+
13
+ it "makes an API request" do
14
+ expect(a_request(:get, 'http://www.KhanAcademy.org/api/v1/topic/probability')).to have_been_made
8
15
  end
9
16
 
10
17
  it "returns a KhanAcademy::Topic" do
11
- expect(KhanAcademy::Topic.new('probability')).to be_a KhanAcademy::Topic
18
+ expect(@probability).to be_a KhanAcademy::Topic
19
+ end
20
+
21
+ it "returns an object with attributes" do
22
+ expect(@probability.title).to eq "Probability and statistics"
23
+ end
24
+
25
+ end
26
+
27
+ describe 'KhanAcademy::Topic.tree' do
28
+ before do
29
+ stub_request(:get, 'http://www.KhanAcademy.org/api/v1/topictree').
30
+ to_return(body: fixture('topictree.json'))
31
+ @topictree = KhanAcademy::Topic.tree
32
+ end
33
+
34
+ it "makes an api request" do
35
+ expect(a_request(:get, 'http://www.KhanAcademy.org/api/v1/topictree')).to have_been_made
12
36
  end
37
+
13
38
  end
14
39
 
15
- describe 'TopicTree' do
40
+ describe 'KhanAcademy::Topic.all' do
16
41
  before do
17
42
  stub_request(:get, 'http://www.KhanAcademy.org/api/v1/topictree').
18
43
  to_return(body: fixture('topictree.json'))
44
+ @all = KhanAcademy::Topic.all
19
45
  end
20
46
 
21
- it "returns a hash of topics" do
22
- all = KhanAcademy::TopicTree.new
47
+ it "makes an api request" do
23
48
  expect(a_request(:get, 'http://www.KhanAcademy.org/api/v1/topictree')).to have_been_made
49
+ end
24
50
 
25
- expect(all.topics['cs']).to eq "programming"
51
+ it "returns an array of topics" do
52
+ expect(@all).to be_a Array
26
53
  end
54
+
27
55
  end
28
56
 
29
- describe 'new topic' do
57
+ describe "KhanAcademy::Playlist.get_videos" do
30
58
  before do
31
- stub_request(:get, 'http://www.KhanAcademy.org/api/v1/topic/probability').
32
- to_return(body: fixture('probability.json'))
59
+ stub_request(:get, "http://www.KhanAcademy.org/api/v1/playlists/blood-vessels/videos").
60
+ to_return(body: fixture('videos.json'))
61
+ @blood_vessels = KhanAcademy::Playlist.get_videos('blood-vessels')
33
62
  end
34
63
 
35
- it 'fetches a hash about the topic' do
36
- probability = KhanAcademy::Topic.new('probability')
37
- expect(a_request(:get, 'http://www.KhanAcademy.org/api/v1/topic/probability')).to have_been_made
38
- expect(probability.title).to eq "Probability and statistics"
64
+ it "instantiates an array of playlist objects" do
65
+ expect(@blood_vessels).to be_a Array
66
+ expect(@blood_vessels.first).to be_a KhanAcademy::Playlist
67
+ end
68
+
69
+ it "makes an api call" do
70
+ expect(a_request(:get, 'http://www.KhanAcademy.org/api/v1/playlists/blood-vessels/videos')).to have_been_made
71
+ end
72
+
73
+ it "returns an object whose attributes can be accessed with ruby methods" do
74
+ expect(@blood_vessels.first.duration).to eq 897
39
75
  end
40
76
  end
77
+
78
+ describe "KhanAcademy::Playlist.get_exercises" do
79
+ before do
80
+ stub_request(:get, "http://www.KhanAcademy.org/api/v1/playlists/buddhist-art/exercises").
81
+ to_return(body: fixture('exercises.json'))
82
+ @buddhist_art = KhanAcademy::Playlist.get_exercises('buddhist-art')
83
+ end
84
+
85
+ it "instantiates an array of playlist objects" do
86
+ expect(@buddhist_art).to be_a Array
87
+ expect(@buddhist_art.first).to be_a KhanAcademy::Playlist
88
+ end
89
+
90
+ it "makes an api call" do
91
+ expect(a_request(:get, 'http://www.KhanAcademy.org/api/v1/playlists/buddhist-art/exercises')).to have_been_made
92
+ end
93
+
94
+ it "returns an object whose attributes can be accessed with ruby methods" do
95
+ expect(@buddhist_art.first.author_name).to eq "Beth"
96
+ end
97
+ end
98
+
41
99
  end
@@ -1,5 +1,6 @@
1
1
  require 'simplecov'
2
2
  require 'coveralls'
3
+ Coveralls.wear!
3
4
 
4
5
  SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
5
6
  SimpleCov::Formatter::HTMLFormatter,
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubykhan
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Crews
@@ -53,20 +53,6 @@ dependencies:
53
53
  - - '>='
54
54
  - !ruby/object:Gem::Version
55
55
  version: '0'
56
- - !ruby/object:Gem::Dependency
57
- name: hashie
58
- requirement: !ruby/object:Gem::Requirement
59
- requirements:
60
- - - ~>
61
- - !ruby/object:Gem::Version
62
- version: '2.0'
63
- type: :runtime
64
- prerelease: false
65
- version_requirements: !ruby/object:Gem::Requirement
66
- requirements:
67
- - - ~>
68
- - !ruby/object:Gem::Version
69
- version: '2.0'
70
56
  - !ruby/object:Gem::Dependency
71
57
  name: json
72
58
  requirement: !ruby/object:Gem::Requirement
@@ -81,20 +67,6 @@ dependencies:
81
67
  - - ~>
82
68
  - !ruby/object:Gem::Version
83
69
  version: '1.8'
84
- - !ruby/object:Gem::Dependency
85
- name: rash
86
- requirement: !ruby/object:Gem::Requirement
87
- requirements:
88
- - - ~>
89
- - !ruby/object:Gem::Version
90
- version: '0.4'
91
- type: :runtime
92
- prerelease: false
93
- version_requirements: !ruby/object:Gem::Requirement
94
- requirements:
95
- - - ~>
96
- - !ruby/object:Gem::Version
97
- version: '0.4'
98
70
  - !ruby/object:Gem::Dependency
99
71
  name: httparty
100
72
  requirement: !ruby/object:Gem::Requirement
@@ -129,10 +101,11 @@ files:
129
101
  - config.ru
130
102
  - lib/rubykhan.rb
131
103
  - lib/rubykhan/version.rb
132
- - lib/topics.rb
133
104
  - rubykhan.gemspec
105
+ - spec/fixtures/exercises.json
134
106
  - spec/fixtures/probability.json
135
107
  - spec/fixtures/topictree.json
108
+ - spec/fixtures/videos.json
136
109
  - spec/rubykhan_spec.rb
137
110
  - spec/spec_helper.rb
138
111
  homepage: https://github.com/DannyCrews/rubykhan
@@ -158,9 +131,11 @@ rubyforge_project:
158
131
  rubygems_version: 2.0.6
159
132
  signing_key:
160
133
  specification_version: 4
161
- summary: Simplififies API requests
134
+ summary: Simplifies API requests with a Ruby application.
162
135
  test_files:
136
+ - spec/fixtures/exercises.json
163
137
  - spec/fixtures/probability.json
164
138
  - spec/fixtures/topictree.json
139
+ - spec/fixtures/videos.json
165
140
  - spec/rubykhan_spec.rb
166
141
  - spec/spec_helper.rb
@@ -1,100 +0,0 @@
1
-
2
- # class Topic
3
- # attr_reader :topic_slug, :data, :url, :id, :children, :slug, :kind, :tags, :url, :title, :node_slug, :subtopics
4
- # def initialize(topic_slug)
5
- # @topic_slug = topic_slug
6
- # @data = HTTParty.get("http://www.KhanAcademy.org/api/v1/topic/#{@topic_slug}")
7
- # @ka_url = @data['ka_url']
8
- # @id = @data['id']
9
- # @children = @data['children']
10
- # @slug = @data['slug']
11
- # @kind = @data['kind']
12
- # @tags = @data['tags']
13
- # @url = @data['url']
14
- # @title = @data['title']
15
- # @node_slug = @data['node_slug']
16
- # @internal_id = data['internal_id']
17
- # @url = data['url']
18
- # @node_slug = data['node_slug']
19
- # @edit_slug = data['edit_slug']
20
- # @key = data['key']
21
- # @translated_title = data['translated_title']
22
- # if data['children']
23
- # @children = data['children']
24
- # @subtopics = []
25
- # @videos = []
26
- # @exercises = []
27
- # instantiate_subtopics
28
- # end
29
-
30
- # end
31
-
32
- # private
33
-
34
- # def instantiate_subtopics
35
-
36
- # @children.each do |child|
37
- # case child['kind']
38
- # when "Topic"
39
- # begin
40
- # @subtopics << KhanAcademy::Topic.new(child['id'])
41
- # rescue
42
- # @subtopics << KhanAcademy::Subtopic.new(child)
43
- # end
44
- # when "Video"
45
- # @videos << KhanAcademy::Video.new(child)
46
- # when "Exercise"
47
- # @exercises << KhanAcademy::Exercise.new(child)
48
- # end
49
- # end
50
- # end
51
- # end
52
-
53
- # class Subtopic
54
- # attr_reader :data, :kind, :internal_id, :title, :url, :node_slug, :edit_slug, :key, :translated_title, :id
55
- # def initialize(data)
56
- # @data = data
57
- # @kind = data['kind']
58
- # @internal_id = data['internal_id']
59
- # @title = data['title']
60
- # @url = data['url']
61
- # @node_slug = data['node_slug']
62
- # @edit_slug = data['edit_slug']
63
- # @key = data['key']
64
- # @translated_title = data['translated_title']
65
- # @id = data['id']
66
- # end
67
-
68
- # end
69
-
70
- # class Video
71
- # def initialize(data)
72
- # @kind = data['kind']
73
- # @internal_id = data['internal_id']
74
- # @title = data['title']
75
- # @url = data['url']
76
- # @node_slug = data['node_slug']
77
- # @edit_slug = data['edit_slug']
78
- # @key = data['key']
79
- # @translated_title = data['translated_title']
80
- # @id = data['id']
81
- # end
82
- # end
83
-
84
- # class Exercise
85
- # def initialize(data)
86
- # @kind = data['kind']
87
- # @internal_id = data['internal_id']
88
- # @title = data['title']
89
- # @url = data['url']
90
- # @node_slug = data['node_slug']
91
- # @edit_slug = data['edit_slug']
92
- # @key = data['key']
93
- # @translated_title = data['translated_title']
94
- # @id = data['id']
95
- # end
96
- # end
97
-
98
- # end
99
-
100
-