vimeo_ruby 0.2.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/Gemfile.lock +1 -1
- data/README.md +84 -2
- data/lib/vimeo_ruby/user/uploaded_video_collection.rb +6 -2
- data/lib/vimeo_ruby/user.rb +11 -6
- data/lib/vimeo_ruby/version.rb +1 -1
- data/lib/vimeo_ruby/video.rb +2 -2
- data/lib/vimeo_ruby.rb +9 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ddc19e27ceb164c54d03fcc8a551873a3c69eb783969cafc95ce644a8f9dfdb
|
4
|
+
data.tar.gz: 407f36cb900c6434cc06190abaf196c5ca1cf5b86a3254da7e49c9da2408c79d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae1f15845f9ab6d34ca9deb873df7632ea549df34e571983b49db4740722a0cff2dfd7c4ac437954d0e8413cbed8a47782d8eee969c0d964aa29fbfb905b2c0d
|
7
|
+
data.tar.gz: ca9d147f701953220ca9add1f8a7d46d31212aefa6da269de66c0ea230884d5a7882b45d1643222090af9d051ad3b02c73821c202c0c10823a39c3f68c62b7f8
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.4.0] - 2022-12-29
|
4
|
+
|
5
|
+
- Save unnecessary call to get a users uploaded video collection if we already have it and no additional query params are passed in to `VimeoRuby::User#uploaded_videos`.
|
6
|
+
|
7
|
+
## [0.3.0] - 2022-12-29
|
8
|
+
|
9
|
+
- Add shorthand methods on `VimeoRuby` module for `get_user(<vimeo_id>)` and `get_video(<vimeo_id>)` to retrieve the appropriate data.
|
10
|
+
|
3
11
|
## [0.2.0] - 2022-12-28
|
4
12
|
|
5
13
|
- Initial User and Video classes, with beginning interface to retrieve records from the Vimeo API. Adds a connection class used to hold a collection of a users uploaded videos (VimeoRuby::User::UploadedVideoCollection) accessible by calling `VimeoRuby::User#uploaded_videos`.
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,14 @@
|
|
1
|
-
# VimeoRuby
|
1
|
+
# VimeoRuby 0.3.0
|
2
2
|
|
3
3
|
Welcome to VimeoRuby!
|
4
4
|
|
5
|
+
## Development Philosophy/Mindset
|
6
|
+
|
7
|
+
The mindset of this project at this stage of development is to:
|
8
|
+
1. Be simple - Write boring code, resist pulling in additional gems as much as possible, and don't worry about edge cases or handling errors all that much right now.
|
9
|
+
2. Try to be as object-oriented as possible. I'm not an OO expert and you don't have to be either but let's try to improve our OO skills.
|
10
|
+
3. Have fun. Who wants another job? Not me so let's keep it light and make something cool!
|
11
|
+
|
5
12
|
## Installation
|
6
13
|
|
7
14
|
Install the gem and add to the application's Gemfile by executing:
|
@@ -14,7 +21,82 @@ If bundler is not being used to manage dependencies, install the gem by executin
|
|
14
21
|
|
15
22
|
## Usage
|
16
23
|
|
17
|
-
|
24
|
+
### Configure Credentials
|
25
|
+
|
26
|
+
First, make sure you have a Vimeo account and have access to the following credentials from your Vimeo [My Apps dashboard](https://developer.vimeo.com/apps):
|
27
|
+
|
28
|
+
`access_token`, `client_identifier`, and `client_secret`
|
29
|
+
|
30
|
+
Once you have access to these, assign them to the following environment variables accordingly:
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
VIMEO_ACCESS_TOKEN=<access_token_value>
|
34
|
+
VIMEO_CLIENT_IDENTIFIER=<client_identifier_value>
|
35
|
+
VIMEO_CLIENT_SECRET=<client_secrete_value
|
36
|
+
```
|
37
|
+
|
38
|
+
Now you should be ready to continue onward and experiment with this first iteration of the gem interface.
|
39
|
+
|
40
|
+
Currently there are two main classes the you should use to interface with the Vimeo API through which are `VimeoRuby::User` and `VimeoRuby::Video`.
|
41
|
+
|
42
|
+
### Working with the VimeoRuby::User class
|
43
|
+
|
44
|
+
For example, should you want to find a particular Vimeo user by their `vimeo_id`, you can make the following call:
|
45
|
+
```ruby
|
46
|
+
vimeo_user = VimeoRuby::User.get_user(<vimeo_id>) # Makes http request to the Vimeo API
|
47
|
+
#=> #<VimeoRuby::User:0x000000011230df50
|
48
|
+
```
|
49
|
+
|
50
|
+
Alternatively, you can call the `get_user` method on the `VimeoRuby` module itself if you wish for something a bit shorter:
|
51
|
+
```ruby
|
52
|
+
vimeo_user = VimeoRuby.get_user(<vimeo_id>) # Makes http request to the Vimeo API
|
53
|
+
#=> #<VimeoRuby::User:0x000000011230df50
|
54
|
+
```
|
55
|
+
|
56
|
+
With the `VimeoRuby::User` instance that was returned from the successful call we can see what methods are available by running the preceeding and the following code in an irb session with the gem loaded:
|
57
|
+
```ruby
|
58
|
+
vimeo_user.methods.sort - Object.methods
|
59
|
+
=> [:additional_info,
|
60
|
+
:available_for_hire,
|
61
|
+
:available_for_hire?,
|
62
|
+
:base_uri,
|
63
|
+
:bio,
|
64
|
+
:can_work_remotely,
|
65
|
+
:can_work_remotely?,
|
66
|
+
:location,
|
67
|
+
:profile_link,
|
68
|
+
:uploaded_videos,
|
69
|
+
:vimeo_id]
|
70
|
+
```
|
71
|
+
|
72
|
+
We can then take the `vimeo_user` that we currently have stored and retrieve a collection of all of the users uploaded videos with the following:
|
73
|
+
```ruby
|
74
|
+
uploaded_video_collection = vimeo_user.uploaded_videos # Makes http request to the Vimeo API
|
75
|
+
# => #<VimeoRuby::User::UploadedVideoCollection:0x00000001130e98b8
|
76
|
+
```
|
77
|
+
|
78
|
+
The `VimeoRuby::User::UploadedVideoCollection` object stores an array of `VimeoRuby::Video` objects which are accessible by calling:
|
79
|
+
```ruby
|
80
|
+
uploaded_video_collection.videos # No http request is made to the Vimeo API
|
81
|
+
#=> [#<VimeoRuby::Video:0x0000000112fb3228
|
82
|
+
# ....,
|
83
|
+
# ....,
|
84
|
+
# ]
|
85
|
+
```
|
86
|
+
|
87
|
+
### Working with the VimeoRuby::Video class
|
88
|
+
|
89
|
+
To retrieve a particular video from Vimeo you can use the following call:
|
90
|
+
```ruby
|
91
|
+
vimeo_video = VimeoRuby::Video.get_video(<vimeo_id>)
|
92
|
+
#=> #<VimeoRuby::Video:0x000000022341eg61
|
93
|
+
```
|
94
|
+
|
95
|
+
Alternatively, you can call the `get_video` method on the `VimeoRuby` module itself if you wish for something a bit shorter:
|
96
|
+
```ruby
|
97
|
+
vimeo_video = VimeoRuby.get_video(<vimeo_id>) # Makes http request to the Vimeo API
|
98
|
+
#=> #<VimeoRuby::Video:0x0000000223gc4339
|
99
|
+
```
|
18
100
|
|
19
101
|
## Development
|
20
102
|
|
@@ -1,13 +1,17 @@
|
|
1
1
|
module VimeoRuby
|
2
|
-
class User <
|
2
|
+
class User < Base
|
3
3
|
class UploadedVideoCollection
|
4
4
|
attr_reader :videos
|
5
5
|
|
6
6
|
def initialize(videos_array)
|
7
7
|
@videos = videos_array.map do |video_data|
|
8
|
-
|
8
|
+
Video.new(attrs: video_data)
|
9
9
|
end
|
10
10
|
end
|
11
|
+
|
12
|
+
def empty?
|
13
|
+
videos.empty?
|
14
|
+
end
|
11
15
|
end
|
12
16
|
end
|
13
17
|
end
|
data/lib/vimeo_ruby/user.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module VimeoRuby
|
2
|
-
class User <
|
3
|
-
attr_reader :vimeo_id, :available_for_hire, :bio, :can_work_remotely, :location, :name, :profile_link, :additional_info
|
2
|
+
class User < Base
|
3
|
+
attr_reader :vimeo_id, :video_collection, :available_for_hire, :bio, :can_work_remotely, :location, :name, :profile_link, :additional_info
|
4
4
|
|
5
5
|
def initialize(attrs: {})
|
6
6
|
@vimeo_id = extract_vimeo_id_from_uri(attrs.delete("uri"))
|
@@ -10,7 +10,8 @@ module VimeoRuby
|
|
10
10
|
@location = attrs.delete("location")
|
11
11
|
@name = attrs.delete("name")
|
12
12
|
@profile_link = attrs.delete("link")
|
13
|
-
@
|
13
|
+
@video_collection = nil
|
14
|
+
@additional_info = OpenStruct.new(attrs)
|
14
15
|
end
|
15
16
|
|
16
17
|
def self.get_user(user_id)
|
@@ -23,9 +24,13 @@ module VimeoRuby
|
|
23
24
|
end
|
24
25
|
|
25
26
|
def uploaded_videos(query_params: {})
|
26
|
-
|
27
|
-
|
28
|
-
|
27
|
+
if @video_collection.nil? || !query_params.empty?
|
28
|
+
uploaded_videos_response = self.class.get("#{base_uri}/users/#{vimeo_id}/videos", query_params: query_params)
|
29
|
+
uploaded_videos = uploaded_videos_response["data"]
|
30
|
+
@video_collection = UploadedVideoCollection.new(uploaded_videos)
|
31
|
+
else
|
32
|
+
@video_collection
|
33
|
+
end
|
29
34
|
end
|
30
35
|
|
31
36
|
def available_for_hire?
|
data/lib/vimeo_ruby/version.rb
CHANGED
data/lib/vimeo_ruby/video.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module VimeoRuby
|
2
|
-
class Video <
|
2
|
+
class Video < Base
|
3
3
|
attr_reader :vimeo_id, :description, :duration, :embed_html, :link, :name, :player_embed_url, :type, :user, :additional_info
|
4
4
|
|
5
5
|
def initialize(attrs: {})
|
@@ -12,7 +12,7 @@ module VimeoRuby
|
|
12
12
|
@player_embed_url = attrs.delete("player_embed_url")
|
13
13
|
@type = attrs.delete("type")
|
14
14
|
@user = VimeoRuby::User.new(attrs: attrs.delete("user"))
|
15
|
-
@additional_info = attrs
|
15
|
+
@additional_info = OpenStruct.new(attrs)
|
16
16
|
end
|
17
17
|
|
18
18
|
def self.get_video(video_id)
|
data/lib/vimeo_ruby.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "ostruct"
|
3
4
|
require "vimeo_ruby/base"
|
4
5
|
require "vimeo_ruby/user"
|
5
6
|
require "vimeo_ruby/user/uploaded_video_collection"
|
@@ -8,4 +9,12 @@ require "vimeo_ruby/video"
|
|
8
9
|
|
9
10
|
module VimeoRuby
|
10
11
|
class Error < StandardError; end
|
12
|
+
|
13
|
+
def self.get_user(vimeo_id)
|
14
|
+
User.get_user(vimeo_id)
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.get_video(vimeo_id)
|
18
|
+
Video.get_video(vimeo_id)
|
19
|
+
end
|
11
20
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vimeo_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Collin Jilbert
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-12-
|
11
|
+
date: 2022-12-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: webmock
|