Skip to content

Commit

Permalink
Add Ruby example
Browse files Browse the repository at this point in the history
  • Loading branch information
shmokmt committed Dec 21, 2023
1 parent 0c31d15 commit c425fa4
Show file tree
Hide file tree
Showing 6 changed files with 117 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ updates:
schedule:
interval: daily
open-pull-requests-limit: 99
- package-ecosystem: bundler
directory: "/examples/ruby"
schedule:
interval: daily
open-pull-requests-limit: 99
- package-ecosystem: docker
directory: "/"
schedule:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ jobs:
- lang: dotnet
docker-image: mcr.microsoft.com/dotnet/sdk:5.0-alpine
entrypoint: /bin/sh
- lang: ruby
docker-image: ruby:3.2-alpine
entrypoint: /bin/sh
- lang: scala
docker-image: mozilla/sbt:8u292_1.5.7
entrypoint: /bin/sh
Expand Down
9 changes: 9 additions & 0 deletions ci/run-ruby-example.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
set -e

./fake-gcs-server -backend memory -scheme http -port 8080 -external-url "http://localhost:8080" &

(
cd examples/ruby
bundle
bundle exec ruby main.rb
)
5 changes: 5 additions & 0 deletions examples/ruby/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# frozen_string_literal: true

source 'https://rubygems.org'

gem 'google-cloud-storage'
79 changes: 79 additions & 0 deletions examples/ruby/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
GEM
remote: https://rubygems.org/
specs:
addressable (2.8.6)
public_suffix (>= 2.0.2, < 6.0)
base64 (0.2.0)
declarative (0.0.20)
digest-crc (0.6.5)
rake (>= 12.0.0, < 14.0.0)
faraday (2.8.1)
base64
faraday-net_http (>= 2.0, < 3.1)
ruby2_keywords (>= 0.0.4)
faraday-net_http (3.0.2)
google-apis-core (0.11.2)
addressable (~> 2.5, >= 2.5.1)
googleauth (>= 0.16.2, < 2.a)
httpclient (>= 2.8.1, < 3.a)
mini_mime (~> 1.0)
representable (~> 3.0)
retriable (>= 2.0, < 4.a)
rexml
webrick
google-apis-iamcredentials_v1 (0.17.0)
google-apis-core (>= 0.11.0, < 2.a)
google-apis-storage_v1 (0.29.0)
google-apis-core (>= 0.11.0, < 2.a)
google-cloud-core (1.6.1)
google-cloud-env (>= 1.0, < 3.a)
google-cloud-errors (~> 1.0)
google-cloud-env (2.1.0)
faraday (>= 1.0, < 3.a)
google-cloud-errors (1.3.1)
google-cloud-storage (1.45.0)
addressable (~> 2.8)
digest-crc (~> 0.4)
google-apis-iamcredentials_v1 (~> 0.1)
google-apis-storage_v1 (~> 0.29.0)
google-cloud-core (~> 1.6)
googleauth (>= 0.16.2, < 2.a)
mini_mime (~> 1.0)
googleauth (1.9.1)
faraday (>= 1.0, < 3.a)
google-cloud-env (~> 2.1)
jwt (>= 1.4, < 3.0)
multi_json (~> 1.11)
os (>= 0.9, < 2.0)
signet (>= 0.16, < 2.a)
httpclient (2.8.3)
jwt (2.7.1)
mini_mime (1.1.5)
multi_json (1.15.0)
os (1.1.4)
public_suffix (5.0.4)
rake (13.1.0)
representable (3.2.0)
declarative (< 0.1.0)
trailblazer-option (>= 0.1.1, < 0.2.0)
uber (< 0.2.0)
retriable (3.1.2)
rexml (3.2.6)
ruby2_keywords (0.0.5)
signet (0.18.0)
addressable (~> 2.8)
faraday (>= 0.17.5, < 3.a)
jwt (>= 1.5, < 3.0)
multi_json (~> 1.10)
trailblazer-option (0.1.2)
uber (0.1.0)
webrick (1.8.1)

PLATFORMS
arm64-darwin-22

DEPENDENCIES
google-cloud-storage

BUNDLED WITH
2.4.1
16 changes: 16 additions & 0 deletions examples/ruby/main.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# How to run this example
# 1 - Build the docker image by running the command "docker build -t fsouza/fake-gcs-server ."
# 2 - Start the docker container: "docker run -d --name fake-gcs-server -p 8080:4443 -v ${PWD}/examples/data:/data fsouza/fake-gcs-server -scheme http"
# 3 - Check if it's working by running: "curl http://0.0.0.0:8080/storage/v1/b"
# 4 - Install requirements: "bundle install"
# 5 - Run this script: "bundle exec ruby main.rb"

require 'google/cloud/storage'

client = Google::Cloud::Storage.anonymous(endpoint: 'http://localhost:8080/')
client.buckets.each do |bucket|
puts "Bucket: #{bucket.name}"
bucket.files.each do |file|
puts "File: #{file.name}"
end
end

0 comments on commit c425fa4

Please sign in to comment.