WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Source code for the Cloudinary Academy's "Introduction to Cloudinary for Ruby Developers" course.

Notifications You must be signed in to change notification settings

jackieros/cld-intro-ruby

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cloudinary Intro using Ruby

Ruby install

Use a version of Ruby >= 2.4. In this repo, we are using version 2.5.7 as indicated in the ./scripts/.ruby-version file. If you are using a different version of Ruby, you can change the value in that file.

Mac

Mac comes with Ruby installed. To install the latest version of Ruby, use HomeBrew. You can install Homebrew

brew install ruby

Windows

https://rubyinstaller.org/

Setup to run scripts

The scripts are run from the scripts directory.

  1. Clone this repo.

  2. Install Cloudinary gem.

`gem install cloudinary`
  1. Set up credentials.

Create a ./scripts/config.rb file and copy the value from the ClOUDINARY_URL located in the Cloudinary Management Console into the file as an argument for the config_from_url command. See the config.rb.sample. The code below shows two alternatives for adding credentials.

There are two ways you can make the credentials available.

# Cloudinary.config do |config|
#   config.cloud_name = "CLOUD_NAME"
#   config.api_key = "API_KEY"
#   config.api_secret = "API_SECRET"
# end
Cloudinary.config_from_url("cloudinary://API_KEY:API_SECRET@CLOUD_NAME")

Exercises

You will see that the images and video to be used in the exercises are in the assets directory. Scripts access assets relative to the scripts directory, so navigate to the scripts directory.

cd scripts

Running the Exercise Code

Commands are commented out in each script. You can uncomment and run script or copy and paste to run in Ruby/IRB.

  1. Uncomment commands and run ruby upload.rb to exercise storage commands.
  2. Uncomment commands and run ruby preset.rb to exercise preset commands.
  3. Uncomment commands and run ruby autoupload-fetch.rb to exercise auto-upload and fetch commands.
  4. Uncomment commands and run ruby manage.rb to exercise management commands.
  5. Uncomment commands and run ruby upload-for-transformations.rb to load assets used in transformation scripts.
  6. Uncomment commands and run ruby optimize-transformation.rb to exercise transformations that optimize.
  7. Uncomment commands and run ruby aesthetics-transform.rb to exercise transformations that enhance aesthetics.
  8. Uncomment commands and run ruby named-transformation.rb to exercise creating and using named transformations.

Using Ruby/IRB (optional)

You need version 2.4 or higher of Ruby to use Ruby/IRB. This will allow you to experiment with your own commands interactively. Once you have set up the config.rb, the scripts/bin/console.rb will be able to access your credentials. From the scripts directory, run the following:

ruby bin/console.rb

Note: Commands are wrapped in JSON.pretty_generate() abbreviated as jj to make the results easier to read.

Rails Server (bonus/optional)

The directory /server is a bonus that contains code to run a Rails server.

About

Source code for the Cloudinary Academy's "Introduction to Cloudinary for Ruby Developers" course.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 59.5%
  • HTML 38.4%
  • CSS 2.0%
  • Shell 0.1%