vimeo_ruby 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +84 -2
- data/lib/vimeo_ruby/user/uploaded_video_collection.rb +2 -2
- data/lib/vimeo_ruby/user.rb +3 -3
- 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: 1ed0fda96d5d2a68abd3abc83ad39b0687ed9346db340ff49e990d949657977a
|
4
|
+
data.tar.gz: 5b1cc75bf6d4955c859ab443ebb167dcd96bb9cd63c1cd7505206180aa1ab0aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 50aa3fb2068c01fcd2ce01d3cf09a33b56a08688f1ef7f8a118f5f2b99679576a65510849f398993fafbd7056954f8ad9f9400ec6c139971909370f787fa139c
|
7
|
+
data.tar.gz: 2354449f341d3e996e6488f65aa52e97425ed6bfa2003d011566050ae8f8096fe87b7b448ef7f8d6167e6eb1d0ac4451853d180f1608772b8936844681d5985f
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,14 @@
|
|
1
|
-
# VimeoRuby
|
1
|
+
# VimeoRuby 0.2.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,11 +1,11 @@
|
|
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
11
|
end
|
data/lib/vimeo_ruby/user.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module VimeoRuby
|
2
|
-
class User <
|
2
|
+
class User < Base
|
3
3
|
attr_reader :vimeo_id, :available_for_hire, :bio, :can_work_remotely, :location, :name, :profile_link, :additional_info
|
4
4
|
|
5
5
|
def initialize(attrs: {})
|
@@ -10,7 +10,7 @@ module VimeoRuby
|
|
10
10
|
@location = attrs.delete("location")
|
11
11
|
@name = attrs.delete("name")
|
12
12
|
@profile_link = attrs.delete("link")
|
13
|
-
@additional_info = attrs
|
13
|
+
@additional_info = OpenStruct.new(attrs)
|
14
14
|
end
|
15
15
|
|
16
16
|
def self.get_user(user_id)
|
@@ -25,7 +25,7 @@ module VimeoRuby
|
|
25
25
|
def uploaded_videos(query_params: {})
|
26
26
|
uploaded_videos_response = self.class.get("#{base_uri}/users/#{vimeo_id}/videos", query_params: query_params)
|
27
27
|
uploaded_videos = uploaded_videos_response["data"]
|
28
|
-
|
28
|
+
UploadedVideoCollection.new(uploaded_videos)
|
29
29
|
end
|
30
30
|
|
31
31
|
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.3.0
|
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
|