diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0cb6eeb --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +/.bundle/ +/.yardoc +/Gemfile.lock +/_yardoc/ +/coverage/ +/doc/ +/pkg/ +/spec/reports/ +/tmp/ diff --git a/.rspec b/.rspec new file mode 100644 index 0000000..8c18f1a --- /dev/null +++ b/.rspec @@ -0,0 +1,2 @@ +--format documentation +--color diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..9cd3461 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,5 @@ +sudo: false +language: ruby +rvm: + - 2.3.1 +before_install: gem install bundler -v 1.13.6 diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..77003c2 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,74 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, gender identity and expression, level of experience, +nationality, personal appearance, race, religion, or sexual identity and +orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or +advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at boristoet80@gmail.com. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at [http://contributor-covenant.org/version/1/4][version] + +[homepage]: http://contributor-covenant.org +[version]: http://contributor-covenant.org/version/1/4/ diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..e474e52 --- /dev/null +++ b/Gemfile @@ -0,0 +1,4 @@ +source 'https://rubygems.org' + +# Specify your gem's dependencies in vimeo_me2.gemspec +gemspec diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..d83a9ff --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2016 Boris + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..ed858e5 --- /dev/null +++ b/README.md @@ -0,0 +1,41 @@ +# VimeoMe2 + +Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/vimeo_me2`. To experiment with that code, run `bin/console` for an interactive prompt. + +TODO: Delete this and the text above, and describe your gem + +## Installation + +Add this line to your application's Gemfile: + +```ruby +gem 'vimeo_me2' +``` + +And then execute: + + $ bundle + +Or install it yourself as: + + $ gem install vimeo_me2 + +## Usage + +TODO: Write usage instructions here + +## Development + +After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. + +To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org). + +## Contributing + +Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/vimeo_me2. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct. + + +## License + +The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT). + diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..b7e9ed5 --- /dev/null +++ b/Rakefile @@ -0,0 +1,6 @@ +require "bundler/gem_tasks" +require "rspec/core/rake_task" + +RSpec::Core::RakeTask.new(:spec) + +task :default => :spec diff --git a/bin/console b/bin/console new file mode 100755 index 0000000..84fe0e3 --- /dev/null +++ b/bin/console @@ -0,0 +1,14 @@ +#!/usr/bin/env ruby + +require "bundler/setup" +require "vimeo_me2" + +# You can add fixtures and/or initialization code here to make experimenting +# with your gem easier. You can also use a different console, if you like. + +# (If you use this, don't forget to add pry to your Gemfile!) +# require "pry" +# Pry.start + +require "irb" +IRB.start diff --git a/bin/setup b/bin/setup new file mode 100755 index 0000000..dce67d8 --- /dev/null +++ b/bin/setup @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +set -euo pipefail +IFS=$'\n\t' +set -vx + +bundle install + +# Do any other automated setup that you need to do here diff --git a/lib/vimeo_me2.rb b/lib/vimeo_me2.rb new file mode 100644 index 0000000..05ec071 --- /dev/null +++ b/lib/vimeo_me2.rb @@ -0,0 +1,7 @@ +$:.unshift(File.dirname(__FILE__)) +require "vimeo_me2/user" +require "vimeo_me2/video" +require "vimeo_me2/version" + +module VimeoMe2 +end diff --git a/lib/vimeo_me2/http/http_request.rb b/lib/vimeo_me2/http/http_request.rb new file mode 100644 index 0000000..7106471 --- /dev/null +++ b/lib/vimeo_me2/http/http_request.rb @@ -0,0 +1,78 @@ +require 'httparty' +$:.unshift(File.dirname(__FILE__)) +require "oauth/verify" + +module VimeoMe2 + module Http + + class HttpRequest + include VimeoMe2::Http::OAuth::Verify + + attr_reader :last_request + + def initialize(token=nil) + @token = token + reset_request + end + + def make_http_request(method, endpoint) + call = HTTParty.public_send(method, prefix_endpoint(endpoint), http_request) + validate_response!(call) + reset_request + return JSON.parse(call) if call.is_a? Hash + return call + end + + def set_token token + set_auth_header(token) + end + + private + + def request_uri uri=nil + "#{@base_uri}#{uri}" + end + + def reset_request + @headers = {} + @body = {} + set_auth_header(@token) unless @token.nil? + end + + def add_header(key, value) + @headers[key.to_sym] = value + end + + def add_headers(additional) + @headers.merge!(additional) if additional.instance_of? Hash + end + + def set_auth_header token + add_header('authorization', "Bearer #{token}") + end + + def http_request + return {headers:@headers, body:@body} + end + + def prefix_endpoint endpoint + /https?/.match(endpoint) ? endpoint : "https://api.vimeo.com#{endpoint}" + end + + # Raises an exception if the response does contain a +stat+ different from "ok" + def validate_response!(call) + raise "empty call" unless call + @last_request = call + unless call.response.code.in? %w(200 201 204) + error = JSON.parse(call) + if error + raise RequestFailed, "#{call.response.code}: #{call.response.msg}, explanation: #{error['error']}" + else + raise RequestFailed, "Error: #{call.response.code}: #{call.response.msg}, no error message" + end + end + end + end + + end +end diff --git a/lib/vimeo_me2/http/oauth/verify.rb b/lib/vimeo_me2/http/oauth/verify.rb new file mode 100644 index 0000000..1db0f7d --- /dev/null +++ b/lib/vimeo_me2/http/oauth/verify.rb @@ -0,0 +1,29 @@ +module VimeoMe2 + module Http + module OAuth + module Verify + + private + def verify_oauth_token + req = make_http_request('get','/oauth/verify') + return req['scope'].split + end + + def get_access_level + @access_level || @access_level = verify_oauth_token + end + + def check_authorization(type=nil) + error = "Authorization is required for this action and you have not provided a valid token." + raise RequestFailed, error unless @headers[:authorization] + if type + error = "The request you are making requires a token with #{type} access, + the token you have provided does not have that authority." + allowed_types = get_access_level + raise RequestFailed, error unless @headers[:authorization] unless type.in? allowed_types + end + end + end + end + end +end diff --git a/lib/vimeo_me2/user.rb b/lib/vimeo_me2/user.rb new file mode 100644 index 0000000..b8311b8 --- /dev/null +++ b/lib/vimeo_me2/user.rb @@ -0,0 +1,36 @@ +$:.unshift(File.dirname(__FILE__)) +require "user/upload" +require "user/album" +require "user/category" +require "user/channel" +require "user/feed" +require "user/followers" +require "user/following" +require "user/groups" +require "user/likes" +require "http/http_request" + +module VimeoMe2 + class RequestFailed < StandardError; end + + class User < VimeoMe2::Http::HttpRequest + include VimeoMe2::UserMethods::Album + include VimeoMe2::UserMethods::Upload + include VimeoMe2::UserMethods::Category + include VimeoMe2::UserMethods::Channel + include VimeoMe2::UserMethods::Feed + include VimeoMe2::UserMethods::Followers + include VimeoMe2::UserMethods::Following + include VimeoMe2::UserMethods::Groups + include VimeoMe2::UserMethods::Likes + + attr_accessor :video + + def initialize(token, user_id = nil) + @token = token + @base_uri = user_id ? "/users/#{user_id}" : "/me" + reset_request + end + + end +end diff --git a/lib/vimeo_me2/user/album.rb b/lib/vimeo_me2/user/album.rb new file mode 100644 index 0000000..330344d --- /dev/null +++ b/lib/vimeo_me2/user/album.rb @@ -0,0 +1,88 @@ +module VimeoMe2 + module UserMethods + module Album + + # Get a list of albums for the current user. + def get_album_list + check_authorization + make_http_request('get', request_uri("/albums") ) + end + + # Get one album by it's ID + # @param [String] album_id The Id of the album. + def get_album album_id + check_authorization + make_http_request('get', request_uri("/albums/#{album_id}") ) + end + + # Create a new album + # @param [String] name The name of the album. + # @param [String] description The description of the album. + def create_album(name, description) + check_authorization('create') + @body['name'] = name + @body['description'] = description + make_http_request('post', request_uri("/albums") ) + end + + # Edit an album + # @param [String] name The name of the album. + # @param [String] description The description of the album. + def edit_album(album_id, name=nil, description=nil) + check_authorization('edit') + @body['name'] = name if name + @body['description'] = description if description + make_http_request('patch', request_uri("/albums/#{album_id}") ) + end + + # Delete one album by it's ID + # @param [String] album_id The Id of the album. + def delete_album album_id + check_authorization('delete') + make_http_request('delete', request_uri("/albums/#{album_id}") ) + end + + # Get video's of album + # @param [String] album_id The Id of the album. + def get_album_videos album_id + check_authorization + make_http_request('get', request_uri("/albums/#{album_id}/videos") ) + end + + # Put multiple video's in an album + # @param [String] album_id The Id of the album. + # @param [String] videos String of video URIs seperated by comma + # @param [Array] videos Array of video URIs + def add_videos_to_album album_id, videos + check_authorization('edit') + @body['videos'] = videos if videos.is_a? String + @body['videos'] = videos.join(',') if videos.is_a? Array + make_http_request('put', request_uri("/albums/#{album_id}") ) + end + + # Add single video to an album + # @param [String] album_id The Id of the album. + # @param [String] video_id The Id of the video. + def add_video_to_album album_id, video_id + check_authorization('edit') + make_http_request('put',request_uri("/albums/#{album_id}/videos/#{video_id}") ) + end + + # Check if video exists in an album + # @param [String] album_id The Id of the album. + # @param [String] video_id The Id of the video. + def check_video_in_album album_id, video_id + check_authorization! + make_http_request('get',request_uri("/albums/#{album_id}/videos/#{video_id}") ) + end + + # Remove video from an album + # @param [String] album_id The Id of the album. + # @param [String] video_id The Id of the video. + def remove_video_from_album album_id, video_id + check_authorization('edit') + make_http_request('delete',request_uri("/albums/#{album_id}/videos/#{video_id}") ) + end + end + end +end diff --git a/lib/vimeo_me2/user/category.rb b/lib/vimeo_me2/user/category.rb new file mode 100644 index 0000000..4703f87 --- /dev/null +++ b/lib/vimeo_me2/user/category.rb @@ -0,0 +1,33 @@ +module VimeoMe2 + module UserMethods + module Category + + # Get all the categories a user follows + def get_all_user_categories + check_authorization + make_http_request('get',request_uri("/categories") ) + end + + # Check for a category + # @param [String] category The name of the category. + def check_category category + check_authorization + make_http_request('get', request_uri("/categories/#{category}") ) + end + + # Subscribe to a category + # @param [String] category The name of the category. + def subscribe_to_category category + check_authorization('interact') + make_http_request('put', request_uri("/categories/#{category}") ) + end + + # Unsubscribe for a category + # @param [String] category The name of the category. + def unsubscribe_from_category category + check_authorization('interact') + make_http_request('delete', request_uri("/categories/#{category}")) + end + end + end +end diff --git a/lib/vimeo_me2/user/channel.rb b/lib/vimeo_me2/user/channel.rb new file mode 100644 index 0000000..bcd84a7 --- /dev/null +++ b/lib/vimeo_me2/user/channel.rb @@ -0,0 +1,33 @@ +module VimeoMe2 + module UserMethods + module Channel + + # Get all the channels a user follows + def view_all_channels + check_authorization + make_http_request('get', request_uri("/channels") ) + end + + # Check for a Channel + # @param [String] channel_id The ID of the channel. + def check_channel channel_id + check_authorization + make_http_request('get', request_uri("/channels/#{channel_id}") ) + end + + # Subscribe to a Channel + # @param [String] channel_id The ID of the channel. + def subscribe_to_channel channel_id + check_authorization('interact') + make_http_request('put', request_uri("/channels/#{channel_id}") ) + end + + # Unsubscribe for a Channel + # @param [String] channel_id The ID of the channel. + def unsubscribe_from_channel channel_id + check_authorization('interact') + make_http_request('delete', request_uri("/channels/#{channel_id}") ) + end + end + end +end diff --git a/lib/vimeo_me2/user/feed.rb b/lib/vimeo_me2/user/feed.rb new file mode 100644 index 0000000..9f2164c --- /dev/null +++ b/lib/vimeo_me2/user/feed.rb @@ -0,0 +1,11 @@ +module VimeoMe2 + module UserMethods + module Feed + # Get all the channels a user follows + def view_all_videos_in_feed + check_authorization('private') + make_http_request('get', request_uri("/feed") ) + end + end + end +end diff --git a/lib/vimeo_me2/user/followers.rb b/lib/vimeo_me2/user/followers.rb new file mode 100644 index 0000000..0e01271 --- /dev/null +++ b/lib/vimeo_me2/user/followers.rb @@ -0,0 +1,13 @@ +module VimeoMe2 + module UserMethods + module Followers + + # Get all user followers + def get_all_followers + check_authorization + make_http_request('get', request_uri("/followers") ) + end + + end + end +end diff --git a/lib/vimeo_me2/user/following.rb b/lib/vimeo_me2/user/following.rb new file mode 100644 index 0000000..e9acb60 --- /dev/null +++ b/lib/vimeo_me2/user/following.rb @@ -0,0 +1,48 @@ +module VimeoMe2 + module UserMethods + module Following + + # View followed users + def view_followed_users + check_authorization + make_http_request('get','/me/following') + end + + # Add a list of users to follow + # + # @param [String] users String of user URIs to follow + # @param [Array] users Array of user URIs to follow + def follow_users users + check_authorization('interact') + @body['users'] = users if users.is_a? String + @body['users'] = user.join(',') if users.is_a? Array + make_http_request('post', request_uri("/following") ) + end + + # Check if user is following a specific user + # + # @param [String] user_id String of user ID + def check_if_following_user user_id + check_authorization + make_http_request('get', request_uri("/following/#{user_id}") ) + end + + # Follow a specific user + # + # @param [String] user_id String of user ID + def follow_user user_id + check_authorization + make_http_request('post', request_uri("/following/#{user_id}") ) + end + + # Unfollow a specific user + # + # @param [String] user_id String of user ID + def unfollow_user user_id + check_authorization + make_http_request('delete', request_uri("/following/#{user_id}") ) + end + + end + end +end diff --git a/lib/vimeo_me2/user/groups.rb b/lib/vimeo_me2/user/groups.rb new file mode 100644 index 0000000..6c09349 --- /dev/null +++ b/lib/vimeo_me2/user/groups.rb @@ -0,0 +1,32 @@ +module VimeoMe2 + module UserMethods + module Groups + # Get all the groups a user joined + def view_all_groups + check_authorization + make_http_request('get', request_uri("/groups") ) + end + + # Check for a joined group + # @param [String] group_id The ID of the group. + def check_if_user_joined_group group_id + check_authorization + make_http_request('get', request_uri("/groups/#{group_id}") ) + end + + # Subscribe to a Group + # @param [String] group_id The name of the Group. + def subscribe_to_channel group_id + check_authorization('interact') + make_http_request('put', request_uri("/groups/#{group_id}") ) + end + + # Unsubscribe for a Group + # @param [String] group_id The name of the Group. + def unsubscribe_from_channel group_id + check_authorization('interact') + make_http_request('delete', request_uri("/groups/#{group_id}") ) + end + end + end +end diff --git a/lib/vimeo_me2/user/likes.rb b/lib/vimeo_me2/user/likes.rb new file mode 100644 index 0000000..2213b4a --- /dev/null +++ b/lib/vimeo_me2/user/likes.rb @@ -0,0 +1,32 @@ +module VimeoMe2 + module UserMethods + module Likes + # Get all your likes + def view_all_likes + check_authorization + make_http_request('get', request_uri("/likes") ) + end + + # Check if video is liked + # @param [String] video_id The ID of the group. + def check_if_liked video_id + check_authorization + make_http_request('get', request_uri("/likes/#{video_id}") ) + end + + # Like a video + # @param [String] video_id The name of the Group. + def like_video video_id + check_authorization('interact') + make_http_request('put', request_uri("/likes/#{video_id}") ) + end + + # Unlike a video + # @param [String] video_id The ID of the Video. + def unlinke_video video_id + check_authorization('interact') + make_http_request('delete', request_uri("/likes/#{video_id}") ) + end + end + end +end diff --git a/lib/vimeo_me2/user/upload.rb b/lib/vimeo_me2/user/upload.rb new file mode 100644 index 0000000..f868d22 --- /dev/null +++ b/lib/vimeo_me2/user/upload.rb @@ -0,0 +1,64 @@ +module VimeoMe2 + module UserMethods + module Upload + + # Upload a video object to the authenticated account + # + # @param [File] video A File that contains a valid video format + def upload_video video + @video = video + check_authorization('upload') + check_file_format! + check_user_quota! + @ticket = get_upload_ticket + start_upload(@ticket['upload_link_secure']) + verify_upload(@ticket['upload_link_secure'], @ticket['complete_uri']) + end + + private + + # get an upload ticket which is neede for the upload + def get_upload_ticket + @body[:type] = "streaming" + make_http_request('post','/me/videos') + end + + # start the upload + def start_upload endpoint + add_header('content-type', @video.content_type) + add_header('content-length', @video.size.to_s) + @video.rewind + @body = @video.read(@video.size).to_s + return make_http_request('put', endpoint) + end + + # Verify the upload + def verify_upload endpoint, complete_uri + add_header('content-length', "0") + add_header('content-range', 'bytes */*') + verify_upload = make_http_request('put', endpoint) + if verify_upload.range.max.max == @video.size + end_upload(complete_uri) + end + end + + # End the upload is the upload was verified + # + # @param [String] complete_uri The complete uri to end upload + def end_upload complete_uri + deleter = make_http_request('delete', complete_uri) + if deleter.code == 201 + puts "Succesfull uploaded to Vimeo" + end + end + + def check_file_format! + + end + + def check_user_quota! + + end + end + end +end diff --git a/lib/vimeo_me2/version.rb b/lib/vimeo_me2/version.rb new file mode 100644 index 0000000..37a24fd --- /dev/null +++ b/lib/vimeo_me2/version.rb @@ -0,0 +1,3 @@ +module VimeoMe2 + VERSION = "0.1.0" +end diff --git a/lib/vimeo_me2/video.rb b/lib/vimeo_me2/video.rb new file mode 100644 index 0000000..90cc01a --- /dev/null +++ b/lib/vimeo_me2/video.rb @@ -0,0 +1,39 @@ +$:.unshift(File.dirname(__FILE__)) +require "http/http_request" +require "video/comment" + +module VimeoMe2 + class Video < VimeoMe2::Http::HttpRequest + include VimeoMe2::VideoMethods::Comment + + attr_reader :video + + def initialize(token, video_id) + @token = token + @base_uri = "/videos/#{video_id}" + reset_request + @video = get_video + end + + def delete + check_authorization('delete') + make_http_request('delete', request_uri ) + end + + def edit options = {} + check_authorization('edit') + @body = options + make_http_request('patch', request_uri ) + end + + def categories + make_http_request('get', request_uri('/categories')) + end + + private + + def get_video + JSON.parse(make_http_request('get', request_uri)) + end + end +end diff --git a/lib/vimeo_me2/video/comment.rb b/lib/vimeo_me2/video/comment.rb new file mode 100644 index 0000000..7324f97 --- /dev/null +++ b/lib/vimeo_me2/video/comment.rb @@ -0,0 +1,32 @@ +module VimeoMe2 + module VideoMethods + module Comment + + def comments + make_http_request('get', request_uri('/comments')) + end + + def add_comment text + check_authorization('interact') + @body['text'] = text + make_http_request('post', request_uri('/comments')) + end + + def view_comment comment_id + make_http_request('get', request_uri("/comments/#{comment_id}")) + end + + def edit_comment comment_id, text + check_authorization('edit') + @body['text'] = text + make_http_request('patch', request_uri("/comments/#{comment_id}")) + end + + def delete_comment comment_id + check_authorization('delete') + make_http_request('delete', request_uri("/comments/#{comment_id}")) + end + + end + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..a34ae0f --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,2 @@ +$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__) +require "vimeo_me2" diff --git a/spec/vimeo_me2_spec.rb b/spec/vimeo_me2_spec.rb new file mode 100644 index 0000000..64a2d86 --- /dev/null +++ b/spec/vimeo_me2_spec.rb @@ -0,0 +1,11 @@ +require "spec_helper" + +describe VimeoMe2 do + it "has a version number" do + expect(VimeoMe2::VERSION).not_to be nil + end + + it "does something useful" do + expect(false).to eq(true) + end +end diff --git a/vimeo_me2.gemspec b/vimeo_me2.gemspec new file mode 100644 index 0000000..f357cc9 --- /dev/null +++ b/vimeo_me2.gemspec @@ -0,0 +1,38 @@ +# coding: utf-8 +lib = File.expand_path('../lib', __FILE__) +$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) +require 'vimeo_me2/version' + +Gem::Specification.new do |spec| + spec.name = "vimeo_me2" + spec.version = VimeoMe2::VERSION + spec.authors = ["Boris"] + spec.email = ["boristoet80@gmail.com"] + + spec.summary = "Temp" + spec.description = "Temp" + spec.homepage = "TODO: Put your gem's website or public repo URL here." + spec.license = "MIT" + + # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host' + # to allow pushing to a single host or delete this section to allow pushing to any host. + if spec.respond_to?(:metadata) + spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'" + else + raise "RubyGems 2.0 or newer is required to protect against " \ + "public gem pushes." + end + + spec.files = `git ls-files -z`.split("\x0").reject do |f| + f.match(%r{^(test|spec|features)/}) + end + spec.bindir = "exe" + spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } + spec.require_paths = ["lib"] + + spec.add_development_dependency "bundler", "~> 1.13" + spec.add_development_dependency "rake", "~> 10.0" + spec.add_development_dependency "rspec", "~> 3.0" + + spec.add_runtime_dependency "httparty","~> 0.14.0" +end