wetube 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +10 -1
- data/lib/wetube.rb +1 -0
- data/lib/wetube/conversation.rb +3 -4
- data/lib/wetube/playlist.rb +6 -6
- data/lib/wetube/theater.rb +26 -0
- data/lib/wetube/version.rb +1 -1
- data/spec/wetube/theater_spec.rb +16 -0
- metadata +7 -3
data/README.md
CHANGED
@@ -18,7 +18,16 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
-
|
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
|
|
data/lib/wetube.rb
CHANGED
data/lib/wetube/conversation.rb
CHANGED
@@ -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
|
-
"#{
|
8
|
+
"#{base_url}/conversations/#{id}.json"
|
10
9
|
end
|
11
10
|
|
12
11
|
def self.create_url(conversation_id)
|
13
|
-
"#{
|
12
|
+
"#{base_url}/conversations/#{conversation_id}/messages.json"
|
14
13
|
end
|
15
14
|
|
16
15
|
def self.find(id)
|
data/lib/wetube/playlist.rb
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
module Wetube
|
2
2
|
class Playlist
|
3
|
-
def self.
|
3
|
+
def self.base_url
|
4
4
|
"http://localhost:3001"
|
5
5
|
end
|
6
6
|
|
7
7
|
def self.find_url(id)
|
8
|
-
"#{
|
8
|
+
"#{base_url}/playlists/#{id}.json"
|
9
9
|
end
|
10
10
|
|
11
11
|
def self.create_url
|
12
|
-
"#{
|
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
|
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
|
22
|
+
handle_json(response)
|
23
23
|
end
|
24
24
|
|
25
25
|
def self.handle_json(response)
|
26
|
-
json = JSON.parse
|
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
|
data/lib/wetube/version.rb
CHANGED
@@ -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.
|
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-
|
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.
|
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:
|