RUBY EN GOOGLE CLOUD PLATFORM

Pruébalo gratis Ver la documentación

Herramientas de Ruby para compilar apps nativas en la nube, implementar a escala y analizar datos

  • check Crea API y aplicaciones web a escala mundial.
  • check Usa las API de aprendizaje automático de Google compatibles con bibliotecas nativas.
  • check Ejecuta aplicaciones en contenedores a escala.
  • check Organiza la infraestructura con Puppet y Chef.
RUBY GEMS CUIDADOSAMENTE ELABORADO

Aprovecha nuestras API y servicios con Google Cloud Ruby Gems y prueba la ejecución de las muestras de código.

Sube archivos a Google Cloud Storage
Realiza análisis de datos con Google BigQuery
Escribe datos de registro personalizados en las API de Stackdriver
Analiza texto con la API de Cloud Natural Language
Sube archivos a Google Cloud Storage
1
Instala
gem install google-cloud-storage
2
Configura un proyecto de Cloud Platform Console
  1. Sign in to your Google Account.

    If you don't already have one, sign up for a new account.

  2. Set up a GCP Console project.

    Set up a project

    Click to:

    • Create or select a project.
    • Enable the Cloud Storage API for that project.
    • Create a service account.
    • Download a private key as JSON.

    You can view and manage these resources at any time in the GCP Console.

3
Escribe el código
# project_id        = "Your Google Cloud project ID"
# bucket_name       = "Your Google Cloud Storage bucket name"
# local_file_path   = "Path to local file to upload"
# storage_file_path = "Path to store the file in Google Cloud Storage"

require "google/cloud/storage"

storage = Google::Cloud::Storage.new project: project_id
bucket  = storage.bucket bucket_name

file = bucket.create_file local_file_path, storage_file_path

puts "Uploaded #{file.name}"
Con Google BigQuery
1
Instala
gem install google-cloud-bigquery
2
Configura un proyecto de Cloud Platform Console
  1. Sign in to your Google Account.

    If you don't already have one, sign up for a new account.

  2. Set up a GCP Console project.

    Set up a project

    Click to:

    • Create or select a project.
    • Enable the BigQuery API for that project.
    • Create a service account.
    • Download a private key as JSON.

    You can view and manage these resources at any time in the GCP Console.

3
Escribe el código
# Imports the Google Cloud client library
require "google/cloud/bigquery"

# Your Google Cloud Platform project ID
project_id = "YOUR_PROJECT_ID"

# Instantiates a client
bigquery = Google::Cloud::Bigquery.new project: project_id

# The name for the new dataset
dataset_name = "my_new_dataset"

# Creates the new dataset
dataset = bigquery.create_dataset dataset_name

puts "Dataset #{dataset.dataset_id} created."
Con Stackdriver Logging
1
Instala
gem install google-cloud-logging
2
Configura un proyecto de Cloud Platform Console
  1. Sign in to your Google Account.

    If you don't already have one, sign up for a new account.

  2. Set up a GCP Console project.

    Set up a project

    Click to:

    • Create or select a project.
    • Enable the Stackdriver Logging API for that project.
    • Create a service account.
    • Download a private key as JSON.

    You can view and manage these resources at any time in the GCP Console.

3
Escribe el código
# Imports the Google Cloud client library
require "google/cloud/logging"

# Your Google Cloud Platform project ID
project_id = "YOUR_PROJECT_ID"

# Instantiates a client
logging = Google::Cloud::Logging.new project: project_id

# Prepares a log entry
entry = logging.entry
# The data to log
entry.payload = "Hello, world!"
# The name of the log to write to
entry.log_name = "my-log"
# The resource associated with the data
entry.resource.type = "global"

# Writes the log entry
logging.write_entries entry

puts "Logged #{entry.payload}"
Analiza texto con la API de Cloud Natural Language
1
Instala
gem install google-cloud-language
2
Configura un proyecto de Cloud Platform Console
  1. Sign in to your Google Account.

    If you don't already have one, sign up for a new account.

  2. Set up a GCP Console project.

    Set up a project

    Click to:

    • Create or select a project.
    • Enable the Cloud Storage API for that project.
    • Create a service account.
    • Download a private key as JSON.

    You can view and manage these resources at any time in the GCP Console.

3
Escribe el código
# Imports the Google Cloud client library
require "google/cloud/language"

# Instantiates a client
language = Google::Cloud::Language.new

# The text to analyze
text = "Hello, world!"

# Detects the sentiment of the text
response = language.analyze_sentiment content: text, type: :PLAIN_TEXT

# Get document sentiment from response
sentiment = response.document_sentiment

puts "Text: #{text}"
puts "Score: #{sentiment.score}, #{sentiment.magnitude}"
GUÍAS DE INICIO RÁPIDO DE RUBY
DESCUBRE Y DEPURA LOS PROBLEMAS RÁPIDAMENTE

Google Stackdriver proporciona servicios potentes de supervisión, registro y diagnóstico. Te brinda información valiosa sobre el estado, el rendimiento y la disponibilidad de aplicaciones en la nube, lo que te permite detectar y solucionar problemas más rápido.

Google Stackdriver
Supervisión, registro y diagnóstico unificados para aplicaciones en Google Cloud Platform y AWS.
Stackdriver Error Reporting
Una explicación acerca de cómo se recibe una alerta de error y cómo se investiga el error en Google Cloud Console.
Stackdriver supervisa, diagnostica y soluciona
En este video, Aja Hammerly utiliza Stackdriver para encontrar y solucionar algunos errores menores en una app de ejemplo y te enseñará a utilizar Stackdriver en tus proyectos.
Más información
RUBY EN LAS COMUNIDADES DE GCP

¿Tienes algo que decir? Únete a nuestra comunidad para hacer preguntas o chatear con los expertos de Google encargados de compilar Ruby en Google Cloud Platform.