wetube 0.0.1

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/.gitignore ADDED
@@ -0,0 +1,23 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+
19
+ ## Ignore simplecov results
20
+ /coverage
21
+
22
+ ## Ignore VCR cassettes
23
+ /fixtures
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ rspec --require rspec/pride --format RSpec::Pride
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'json'
4
+ gem 'rest-client'
5
+ gem 'hashie'
6
+ gem 'pry'
7
+
8
+ group :test do
9
+ gem 'rspec-pride'
10
+ gem 'rspec'
11
+ gem 'simplecov', :require => false
12
+ end
13
+
14
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Geoff Schorkopf
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # WetubeGem
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'wetube'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install wetube
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/lib/wetube.rb ADDED
@@ -0,0 +1,18 @@
1
+ require "wetube/version"
2
+ require "json"
3
+ require "hashie"
4
+ require "rest-client"
5
+ require "wetube/conversation"
6
+ require "wetube/playlist"
7
+
8
+ module Wetube
9
+ class Server
10
+ def self.get_resource(url)
11
+ RestClient.get url
12
+ end
13
+
14
+ def self.post_resource(url, params = {})
15
+ RestClient.post url, params
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,35 @@
1
+ module Wetube
2
+ class Conversation
3
+
4
+ def self.conversation_url
5
+ "http://localhost:3000"
6
+ end
7
+
8
+ def self.find_url(id)
9
+ "#{conversation_url}/conversations/#{id}.json"
10
+ end
11
+
12
+ def self.create_url(conversation_id)
13
+ "#{conversation_url}/conversations/#{conversation_id}/messages.json"
14
+ end
15
+
16
+ def self.find(id)
17
+ response = Server.get_resource find_url(id)
18
+ handle_json response
19
+ end
20
+
21
+ def self.create_message(conversation_id, params)
22
+ response = Server.post_resource(create_url(conversation_id), {message: params})
23
+ handle_json response
24
+ end
25
+
26
+ def self.handle_json(response)
27
+ json = JSON.parse response
28
+ assign_params_from_json(json)
29
+ end
30
+
31
+ def self.assign_params_from_json(data)
32
+ Hashie::Mash.new(data)
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,34 @@
1
+ module Wetube
2
+ class Playlist
3
+ def self.playlist_url
4
+ "http://localhost:3001"
5
+ end
6
+
7
+ def self.find_url(id)
8
+ "#{playlist_url}/playlists/#{id}.json"
9
+ end
10
+
11
+ def self.create_url
12
+ "#{playlist_url}/videos.json"
13
+ end
14
+
15
+ def self.find(id)
16
+ response = Server.get_resource find_url(id)
17
+ handle_json response
18
+ end
19
+
20
+ def self.find_or_create_video(playlist_id, params)
21
+ response = Server.post_resource(create_url, {video: params, playlist_id: playlist_id})
22
+ handle_json response
23
+ end
24
+
25
+ def self.handle_json(response)
26
+ json = JSON.parse response
27
+ assign_params_from_json(json)
28
+ end
29
+
30
+ def self.assign_params_from_json(data)
31
+ Hashie::Mash.new(data)
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,3 @@
1
+ module Wetube
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,12 @@
1
+ require 'simplecov'
2
+ SimpleCov.start
3
+
4
+ require 'wetube'
5
+
6
+ RSpec.configure do |config|
7
+ config.treat_symbols_as_metadata_keys_with_true_values = true
8
+ config.run_all_when_everything_filtered = true
9
+ config.filter_run :focus
10
+
11
+ config.order = 'random'
12
+ end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ describe Wetube::Conversation do
4
+ describe ".find" do
5
+ before :each do
6
+ response = "{\"id\":1,\"created_at\":\"2013-06-12T21:13:32Z\",\"messages\":[{\"content\":\"Hey, ASL\",\"id\":1,\"user_id\":1}]}"
7
+ Wetube::Server.stub(:get_resource).and_return(response)
8
+ end
9
+
10
+ it "returns a hashie of found conversation" do
11
+ result = described_class.find(1)
12
+ expect(result.id).to eq 1
13
+ expect(result.created_at).to eq '2013-06-12T21:13:32Z'
14
+ end
15
+
16
+ it "returns all messages belonging to the conversation" do
17
+ result = described_class.find(1)
18
+ expect(result.messages.first.content).to eq 'Hey, ASL'
19
+ end
20
+ end
21
+
22
+ describe ".create_message" do
23
+ before :each do
24
+ response = "{\"content\":\"18, M, Burger King\",\"id\":1,\"user_id\":1}"
25
+ Wetube::Server.stub(:post_resource).and_return(response)
26
+ end
27
+
28
+ it "creates and returns hashie of message" do
29
+ result = described_class.create_message(1, "message content")
30
+ expect(result.content).to eq "18, M, Burger King"
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,34 @@
1
+ require 'spec_helper'
2
+ require 'pry'
3
+
4
+ describe Wetube::Playlist do
5
+ describe ".find" do
6
+ before(:each) do
7
+ response = "{\"id\":1,\"created_at\":\"2013-06-13T21:41:22Z\",\"videos\":[{\"duration\":null,\"id\":1,\"title\":\"Something\",\"uploaded_at\":null,\"uploader\":null,\"url\":\"http://www.youtube.com/something\"},{\"duration\":null,\"id\":2,\"title\":\"Something else\",\"uploaded_at\":null,\"uploader\":null,\"url\":\"http://www.youtube.com/something_else\"}]}"
8
+ Wetube::Server.stub(:get_resource).and_return(response)
9
+ end
10
+
11
+ it "returns a hashie of found playlist" do
12
+ result = described_class.find(1)
13
+ expect(result.id).to eq 1
14
+ expect(result.created_at).to eq "2013-06-13T21:41:22Z"
15
+ end
16
+
17
+ it "returns all videos belonging to the playlist" do
18
+ result = described_class.find(1)
19
+ expect(result.videos.first.title).to eq 'Something'
20
+ end
21
+ end
22
+
23
+ describe ".find_or_create_video" do
24
+ before :each do
25
+ response = "{\"duration\":null,\"id\":2,\"title\":\"Something else\",\"uploaded_at\":null,\"uploader\":null,\"url\":\"http://www.youtube.com/something_else\"}"
26
+ Wetube::Server.stub(:post_resource).and_return(response)
27
+ end
28
+
29
+ it "finds/creates and returns hashie of video" do
30
+ result = described_class.find_or_create_video(1, {title: "Stubbed", url: "Stubbed"})
31
+ expect(result.title).to eq "Something else"
32
+ end
33
+ end
34
+ end
data/wetube.gemspec ADDED
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'wetube/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "wetube"
8
+ gem.version = Wetube::VERSION
9
+ gem.authors = ["Paul Blackwell", "Logan Sears", "Geoff Schorkopf", "Kyle Suss"]
10
+ gem.email = ["gschorkopf@gmail.com"]
11
+ gem.description = %q{The WeTube gem was constructed to communicate with various API services in the gSchool service-oriented design project.}
12
+ gem.summary = %q{Simultaneous video watching! At your fingertips! Order today!}
13
+ gem.homepage = "http://www.github.com/diasporism/wetube"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+ end
metadata ADDED
@@ -0,0 +1,66 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: wetube
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Paul Blackwell
9
+ - Logan Sears
10
+ - Geoff Schorkopf
11
+ - Kyle Suss
12
+ autorequire:
13
+ bindir: bin
14
+ cert_chain: []
15
+ date: 2013-06-13 00:00:00.000000000 Z
16
+ dependencies: []
17
+ description: The WeTube gem was constructed to communicate with various API services
18
+ in the gSchool service-oriented design project.
19
+ email:
20
+ - gschorkopf@gmail.com
21
+ executables: []
22
+ extensions: []
23
+ extra_rdoc_files: []
24
+ files:
25
+ - .gitignore
26
+ - .rspec
27
+ - Gemfile
28
+ - LICENSE.txt
29
+ - README.md
30
+ - Rakefile
31
+ - lib/wetube.rb
32
+ - lib/wetube/conversation.rb
33
+ - lib/wetube/playlist.rb
34
+ - lib/wetube/version.rb
35
+ - spec/spec_helper.rb
36
+ - spec/wetube/conversation_spec.rb
37
+ - spec/wetube/playlist_spec.rb
38
+ - wetube.gemspec
39
+ homepage: http://www.github.com/diasporism/wetube
40
+ licenses: []
41
+ post_install_message:
42
+ rdoc_options: []
43
+ require_paths:
44
+ - lib
45
+ required_ruby_version: !ruby/object:Gem::Requirement
46
+ none: false
47
+ requirements:
48
+ - - ! '>='
49
+ - !ruby/object:Gem::Version
50
+ version: '0'
51
+ required_rubygems_version: !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ! '>='
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ requirements: []
58
+ rubyforge_project:
59
+ rubygems_version: 1.8.24
60
+ signing_key:
61
+ specification_version: 3
62
+ summary: Simultaneous video watching! At your fingertips! Order today!
63
+ test_files:
64
+ - spec/spec_helper.rb
65
+ - spec/wetube/conversation_spec.rb
66
+ - spec/wetube/playlist_spec.rb