wetube 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -18,7 +18,16 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- TODO: Write usage instructions here
21
+ 1.9.3-p374 > Wetube::Playlist.find(5)
22
+ => #<Hashie::Mash created_at="2013-06-13T22:23:50Z" id=5 videos=[]>
23
+ 1.9.3-p374 > Wetube::Playlist.find_or_create_video(5, {title: "Yolo", url: "Nola"})
24
+ => #<Hashie::Mash duration=nil id=3 title="Yolo" uploaded_at=nil uploader=nil url="Nola">
25
+ 1.9.3-p374 > Wetube::Playlist.find(5)
26
+ => #<Hashie::Mash created_at="2013-06-13T22:23:50Z" id=5 videos=[#<Hashie::Mash duration=nil id=3 title="Yolo" uploaded_at=nil uploader=nil url="Nola">]>
27
+ 1.9.3-p374 > Wetube::Playlist.find(5).videos
28
+ => [#<Hashie::Mash duration=nil id=3 title="Yolo" uploaded_at=nil uploader=nil url="Nola">]
29
+ 1.9.3-p374 > Wetube::Playlist.find(5).videos.first
30
+ => #<Hashie::Mash duration=nil id=3 title="Yolo" uploaded_at=nil uploader=nil url="Nola">
22
31
 
23
32
  ## Contributing
24
33
 
@@ -4,6 +4,7 @@ require "hashie"
4
4
  require "rest-client"
5
5
  require "wetube/conversation"
6
6
  require "wetube/playlist"
7
+ require "wetube/theater"
7
8
 
8
9
  module Wetube
9
10
  class Server
@@ -1,16 +1,15 @@
1
1
  module Wetube
2
2
  class Conversation
3
-
4
- def self.conversation_url
3
+ def self.base_url
5
4
  "http://localhost:3000"
6
5
  end
7
6
 
8
7
  def self.find_url(id)
9
- "#{conversation_url}/conversations/#{id}.json"
8
+ "#{base_url}/conversations/#{id}.json"
10
9
  end
11
10
 
12
11
  def self.create_url(conversation_id)
13
- "#{conversation_url}/conversations/#{conversation_id}/messages.json"
12
+ "#{base_url}/conversations/#{conversation_id}/messages.json"
14
13
  end
15
14
 
16
15
  def self.find(id)
@@ -1,29 +1,29 @@
1
1
  module Wetube
2
2
  class Playlist
3
- def self.playlist_url
3
+ def self.base_url
4
4
  "http://localhost:3001"
5
5
  end
6
6
 
7
7
  def self.find_url(id)
8
- "#{playlist_url}/playlists/#{id}.json"
8
+ "#{base_url}/playlists/#{id}.json"
9
9
  end
10
10
 
11
11
  def self.create_url
12
- "#{playlist_url}/videos.json"
12
+ "#{base_url}/videos.json"
13
13
  end
14
14
 
15
15
  def self.find(id)
16
16
  response = Server.get_resource find_url(id)
17
- handle_json response
17
+ handle_json(response)
18
18
  end
19
19
 
20
20
  def self.find_or_create_video(playlist_id, params)
21
21
  response = Server.post_resource(create_url, {video: params, playlist_id: playlist_id})
22
- handle_json response
22
+ handle_json(response)
23
23
  end
24
24
 
25
25
  def self.handle_json(response)
26
- json = JSON.parse response
26
+ json = JSON.parse(response)
27
27
  assign_params_from_json(json)
28
28
  end
29
29
 
@@ -0,0 +1,26 @@
1
+ module Wetube
2
+ class Theater
3
+ def self.create_conversation_url
4
+ "#{Conversation.base_url}/conversations.json"
5
+ end
6
+
7
+ def self.create_playlist_url
8
+ "#{Playlist.base_url}/playlists.json"
9
+ end
10
+
11
+ def self.create
12
+ conversation, playlist = gather_theater_components
13
+
14
+ conversation_id = JSON.parse(conversation)['id']
15
+ playlist_id = JSON.parse(playlist)['id']
16
+
17
+ Hashie::Mash.new(
18
+ playlist_id: playlist_id,
19
+ conversation_id: conversation_id)
20
+ end
21
+
22
+ def self.gather_theater_components
23
+ [Server.post_resource(create_conversation_url), Server.post_resource(create_playlist_url)]
24
+ end
25
+ end
26
+ end
@@ -1,3 +1,3 @@
1
1
  module Wetube
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ describe Wetube::Theater do
4
+ describe ".create" do
5
+ before :each do
6
+ created_components = ["{\"id\":2}", "{\"id\":1}"]
7
+ Wetube::Theater.stub(:gather_theater_components).and_return(created_components)
8
+ end
9
+
10
+ it "should create a conversation" do
11
+ result = described_class.create
12
+ expect(result.conversation_id).to eq 2
13
+ expect(result.playlist_id).to eq 1
14
+ end
15
+ end
16
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wetube
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2013-06-13 00:00:00.000000000 Z
15
+ date: 2013-06-15 00:00:00.000000000 Z
16
16
  dependencies: []
17
17
  description: The WeTube gem was constructed to communicate with various API services
18
18
  in the gSchool service-oriented design project.
@@ -31,10 +31,12 @@ files:
31
31
  - lib/wetube.rb
32
32
  - lib/wetube/conversation.rb
33
33
  - lib/wetube/playlist.rb
34
+ - lib/wetube/theater.rb
34
35
  - lib/wetube/version.rb
35
36
  - spec/spec_helper.rb
36
37
  - spec/wetube/conversation_spec.rb
37
38
  - spec/wetube/playlist_spec.rb
39
+ - spec/wetube/theater_spec.rb
38
40
  - wetube.gemspec
39
41
  homepage: http://www.github.com/diasporism/wetube
40
42
  licenses: []
@@ -56,7 +58,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
56
58
  version: '0'
57
59
  requirements: []
58
60
  rubyforge_project:
59
- rubygems_version: 1.8.24
61
+ rubygems_version: 1.8.25
60
62
  signing_key:
61
63
  specification_version: 3
62
64
  summary: Simultaneous video watching! At your fingertips! Order today!
@@ -64,3 +66,5 @@ test_files:
64
66
  - spec/spec_helper.rb
65
67
  - spec/wetube/conversation_spec.rb
66
68
  - spec/wetube/playlist_spec.rb
69
+ - spec/wetube/theater_spec.rb
70
+ has_rdoc: