repo
stringlengths
5
92
file_url
stringlengths
80
287
file_path
stringlengths
5
197
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 15:37:27
2026-01-04 17:58:21
truncated
bool
2 classes
JDutil/contact_us
https://github.com/JDutil/contact_us/blob/8f39e962881f17362cdf66a88da3edede22b77b8/lib/contact_us/version.rb
lib/contact_us/version.rb
module ContactUs VERSION = "1.2.0" end
ruby
MIT
8f39e962881f17362cdf66a88da3edede22b77b8
2026-01-04T17:46:23.553669Z
false
JDutil/contact_us
https://github.com/JDutil/contact_us/blob/8f39e962881f17362cdf66a88da3edede22b77b8/lib/contact_us/engine.rb
lib/contact_us/engine.rb
require "contact_us" require "rails" module ContactUs class Engine < Rails::Engine end end
ruby
MIT
8f39e962881f17362cdf66a88da3edede22b77b8
2026-01-04T17:46:23.553669Z
false
JDutil/contact_us
https://github.com/JDutil/contact_us/blob/8f39e962881f17362cdf66a88da3edede22b77b8/lib/contact_us/tasks/install.rb
lib/contact_us/tasks/install.rb
require 'rails/generators' module ContactUs module Tasks class Install class << self def run copy_initializer_file puts "Done!" end def copy_initializer_file print "Copying initializer file...\n" app_path = Rails.root.join("config/initializers") copier.copy_file File.join(gem_path, 'lib/templates/contact_us.rb'), File.join(app_path, 'contact_us.rb') end def copy_locales_files print "Copying locales files...\n" locales_path = gem_path + "/config/locales/*.yml" app_path = Rails.root.join("config/locales") unless File.directory?(app_path) app_path.mkdir end Dir.glob(locales_path).each do |file| copier.copy_file file, File.join(app_path, File.basename(file)) end end def copy_view_files print "Copying view files...\n" origin = File.join(gem_path, 'app/views') destination = Rails.root.join('app/views') copy_files(['.'], origin, destination) end private def copy_files(directories, origin, destination) directories.each do |directory| Dir[File.join(origin, directory, 'contact_us', '**/*')].each do |file| relative = file.gsub(/^#{origin}\//, '') dest_file = File.join(destination, relative) dest_dir = File.dirname(dest_file) if !File.exist?(dest_dir) FileUtils.mkdir_p(dest_dir) end copier.copy_file(file, dest_file) unless File.directory?(file) end end end def gem_path File.expand_path('../../..', File.dirname(__FILE__)) end def copier unless @copier Rails::Generators::Base.source_root(gem_path) @copier = Rails::Generators::Base.new end @copier end end end end end
ruby
MIT
8f39e962881f17362cdf66a88da3edede22b77b8
2026-01-04T17:46:23.553669Z
false
JDutil/contact_us
https://github.com/JDutil/contact_us/blob/8f39e962881f17362cdf66a88da3edede22b77b8/config/routes.rb
config/routes.rb
Rails.application.routes.draw do # Place the contact_us routes within the optional locale scope # If the I18n gem is installed and the localize_routes variable has # been set to true in the application's initializer file if defined?(I18n) && ContactUs.localize_routes scope "(:locale)", locale: /#{I18n.available_locales.join("|")}/ do resources :contacts, controller: "contact_us/contacts", only: [:new, :create] get "contact-us" => "contact_us/contacts#new", as: :contact_us end else resources :contacts, controller: "contact_us/contacts", only: [:new, :create] get "contact-us" => "contact_us/contacts#new", as: :contact_us end end
ruby
MIT
8f39e962881f17362cdf66a88da3edede22b77b8
2026-01-04T17:46:23.553669Z
false
pienkowb/active_record-events
https://github.com/pienkowb/active_record-events/blob/8dff3e67d5e0ea82aac3854ed26a07c40c31b2e2/spec/spec_helper.rb
spec/spec_helper.rb
ENV['RAILS_ENV'] ||= 'test' require 'bundler/setup' require 'simplecov' SimpleCov.start do if ENV['CI'] require 'simplecov-lcov' SimpleCov::Formatter::LcovFormatter.config do |config| config.report_with_single_file = true config.single_report_path = 'coverage/lcov.info' end formatter SimpleCov::Formatter::LcovFormatter end end require File.expand_path('dummy/config/environment.rb', __dir__) require 'factory_girl' require 'generator_spec' require 'timecop' require 'zonebie/rspec' require 'database_cleaner' Dir["#{__dir__}/support/**/*.rb"].sort.each { |f| require f } RSpec.configure do |config| config.before(:suite) do DatabaseCleaner.strategy = :transaction DatabaseCleaner.clean_with(:truncation) end config.around(:each) do |example| DatabaseCleaner.cleaning { example.run } end config.include FactoryGirl::Syntax::Methods config.include GeneratorHelpers, type: :generator end
ruby
MIT
8dff3e67d5e0ea82aac3854ed26a07c40c31b2e2
2026-01-04T17:46:25.965698Z
false
pienkowb/active_record-events
https://github.com/pienkowb/active_record-events/blob/8dff3e67d5e0ea82aac3854ed26a07c40c31b2e2/spec/support/helpers/generator_helpers.rb
spec/support/helpers/generator_helpers.rb
module GeneratorHelpers def write_file(file_name, contents) file_path = File.expand_path(file_name, destination_root) FileUtils.mkdir_p(File.dirname(file_path)) File.write(file_path, contents) end end
ruby
MIT
8dff3e67d5e0ea82aac3854ed26a07c40c31b2e2
2026-01-04T17:46:25.965698Z
false
pienkowb/active_record-events
https://github.com/pienkowb/active_record-events/blob/8dff3e67d5e0ea82aac3854ed26a07c40c31b2e2/spec/support/factories/task_factory.rb
spec/support/factories/task_factory.rb
FactoryGirl.define do factory :task end
ruby
MIT
8dff3e67d5e0ea82aac3854ed26a07c40c31b2e2
2026-01-04T17:46:25.965698Z
false
pienkowb/active_record-events
https://github.com/pienkowb/active_record-events/blob/8dff3e67d5e0ea82aac3854ed26a07c40c31b2e2/spec/support/matchers/have_method.rb
spec/support/matchers/have_method.rb
RSpec::Matchers.define :have_method do |expected| match do |actual| actual.public_instance_methods.include?(expected) end end
ruby
MIT
8dff3e67d5e0ea82aac3854ed26a07c40c31b2e2
2026-01-04T17:46:25.965698Z
false
pienkowb/active_record-events
https://github.com/pienkowb/active_record-events/blob/8dff3e67d5e0ea82aac3854ed26a07c40c31b2e2/spec/generators/active_record/event/event_generator_spec.rb
spec/generators/active_record/event/event_generator_spec.rb
require 'spec_helper' require 'generators/active_record/event/event_generator' RSpec.describe ActiveRecord::Generators::EventGenerator, type: :generator do arguments %w[ task complete --field-type=date --skip-scopes --strategy=time_comparison ] destination File.expand_path('../../../../tmp', __dir__) before { prepare_destination } it 'generates a migration file' do run_generator assert_migration 'db/migrate/add_completed_on_to_tasks' do |migration| assert_instance_method :change, migration do |content| assert_match 'add_column :tasks, :completed_on, :date', content end end end context 'when the model file exists' do before do write_file 'app/models/task.rb', <<-RUBY.strip_heredoc class Task < ActiveRecord::Base end RUBY end it 'updates the model file' do run_generator assert_file 'app/models/task.rb', <<-RUBY.strip_heredoc class Task < ActiveRecord::Base has_event :complete, field_type: :date, skip_scopes: true, strategy: :time_comparison end RUBY end end context "when the model file doesn't exist" do it "doesn't create the model file" do run_generator assert_no_file 'app/models/task.rb' end end end
ruby
MIT
8dff3e67d5e0ea82aac3854ed26a07c40c31b2e2
2026-01-04T17:46:25.965698Z
false
pienkowb/active_record-events
https://github.com/pienkowb/active_record-events/blob/8dff3e67d5e0ea82aac3854ed26a07c40c31b2e2/spec/dummy/app/models/task.rb
spec/dummy/app/models/task.rb
class Task < ActiveRecord::Base has_event :complete has_event :archive, skip_scopes: true has_event :expire, strategy: :time_comparison has_event :notify, field_type: :date, strategy: :time_comparison def complete! super logger.info("Task #{id} has been completed") end def self.complete_all super logger.info('All tasks have been completed') end end
ruby
MIT
8dff3e67d5e0ea82aac3854ed26a07c40c31b2e2
2026-01-04T17:46:25.965698Z
false
pienkowb/active_record-events
https://github.com/pienkowb/active_record-events/blob/8dff3e67d5e0ea82aac3854ed26a07c40c31b2e2/spec/dummy/db/schema.rb
spec/dummy/db/schema.rb
# This file is auto-generated from the current state of the database. Instead # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. # # This file is the source Rails uses to define your schema when running `bin/rails # db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to # be faster and is potentially less error prone than running all of your # migrations from scratch. Old migrations may fail to apply correctly if those # migrations use external dependencies or application code. # # It's strongly recommended that you check this file into your version control system. ActiveRecord::Schema.define(version: 2023_03_08_160359) do create_table "tasks", force: :cascade do |t| t.datetime "completed_at" t.datetime "created_at", null: false t.datetime "updated_at", null: false t.datetime "expired_at" t.date "notified_on" end end
ruby
MIT
8dff3e67d5e0ea82aac3854ed26a07c40c31b2e2
2026-01-04T17:46:25.965698Z
false
pienkowb/active_record-events
https://github.com/pienkowb/active_record-events/blob/8dff3e67d5e0ea82aac3854ed26a07c40c31b2e2/spec/dummy/db/migrate/20230308160359_add_notified_on_to_tasks.rb
spec/dummy/db/migrate/20230308160359_add_notified_on_to_tasks.rb
class AddNotifiedOnToTasks < ACTIVE_RECORD_MIGRATION_CLASS def change add_column :tasks, :notified_on, :date end end
ruby
MIT
8dff3e67d5e0ea82aac3854ed26a07c40c31b2e2
2026-01-04T17:46:25.965698Z
false
pienkowb/active_record-events
https://github.com/pienkowb/active_record-events/blob/8dff3e67d5e0ea82aac3854ed26a07c40c31b2e2/spec/dummy/db/migrate/20220609015338_add_expired_at_to_tasks.rb
spec/dummy/db/migrate/20220609015338_add_expired_at_to_tasks.rb
class AddExpiredAtToTasks < ACTIVE_RECORD_MIGRATION_CLASS def change add_column :tasks, :expired_at, :datetime end end
ruby
MIT
8dff3e67d5e0ea82aac3854ed26a07c40c31b2e2
2026-01-04T17:46:25.965698Z
false
pienkowb/active_record-events
https://github.com/pienkowb/active_record-events/blob/8dff3e67d5e0ea82aac3854ed26a07c40c31b2e2/spec/dummy/db/migrate/20150813132804_create_tasks.rb
spec/dummy/db/migrate/20150813132804_create_tasks.rb
class CreateTasks < ACTIVE_RECORD_MIGRATION_CLASS def change create_table :tasks do |t| t.datetime :completed_at t.timestamps null: false end end end
ruby
MIT
8dff3e67d5e0ea82aac3854ed26a07c40c31b2e2
2026-01-04T17:46:25.965698Z
false
pienkowb/active_record-events
https://github.com/pienkowb/active_record-events/blob/8dff3e67d5e0ea82aac3854ed26a07c40c31b2e2/spec/dummy/config/environment.rb
spec/dummy/config/environment.rb
require File.expand_path('boot', __dir__) require 'active_record' Bundler.require(:default, ENV.fetch('RAILS_ENV')) # Load application files Dir["#{__dir__}/../app/**/*.rb"].sort.each { |f| require f } # Load the database configuration config_file = File.expand_path('database.yml', __dir__) config = YAML.load_file(config_file)[ENV.fetch('RAILS_ENV')] ActiveRecord::Base.logger = Logger.new(File::NULL) ActiveRecord::Base.establish_connection(config)
ruby
MIT
8dff3e67d5e0ea82aac3854ed26a07c40c31b2e2
2026-01-04T17:46:25.965698Z
false
pienkowb/active_record-events
https://github.com/pienkowb/active_record-events/blob/8dff3e67d5e0ea82aac3854ed26a07c40c31b2e2/spec/dummy/config/boot.rb
spec/dummy/config/boot.rb
ENV['RAILS_ENV'] ||= 'development' ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../Gemfile', __dir__) require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) $LOAD_PATH.unshift(File.expand_path('../../../lib', __dir__))
ruby
MIT
8dff3e67d5e0ea82aac3854ed26a07c40c31b2e2
2026-01-04T17:46:25.965698Z
false
pienkowb/active_record-events
https://github.com/pienkowb/active_record-events/blob/8dff3e67d5e0ea82aac3854ed26a07c40c31b2e2/spec/active_record/events_spec.rb
spec/active_record/events_spec.rb
require 'spec_helper' RSpec.describe ActiveRecord::Events do around(:each) do |example| Timecop.freeze { example.run } end let!(:task) { create(:task) } it 'records a timestamp' do task.complete expect(task.completed?).to eq(true) expect(task.not_completed?).to eq(false) expect(task.completed_at).to eq(Time.current) end it 'preserves a timestamp' do task = create(:task, completed_at: 3.days.ago) task.complete expect(task.completed_at).to eq(3.days.ago) end it 'updates a timestamp' do task = create(:task, completed_at: 3.days.ago) task.complete! expect(task.completed_at).to eq(Time.current) end context 'with a non-persisted object' do it 'updates the timestamp' do task = build(:task, completed_at: 3.days.ago) task.complete! expect(task.completed_at).to eq(Time.current) end end it 'records multiple timestamps at once' do Task.complete_all expect(task.reload).to be_completed end it 'defines a scope' do expect(Task.completed).not_to include(task) end it 'defines an inverse scope' do expect(Task.not_completed).to include(task) end it 'allows overriding instance methods' do expect(ActiveRecord::Base.logger).to receive(:info) task.complete! expect(task).to be_completed end it 'allows overriding class methods' do expect(ActiveRecord::Base.logger).to receive(:info) Task.complete_all expect(task.reload).to be_completed end describe 'time comparison strategy' do it 'defines a predicate method comparing against current time' do task.update!(expired_at: 1.hour.from_now) expect(task.expired?).to eq(false) task.update!(expired_at: 1.hour.ago) expect(task.expired?).to eq(true) task.update!(expired_at: nil) expect(task.expired?).to eq(false) end it 'defines an inverse predicate method comparing against current time' do task.update!(expired_at: 1.hour.from_now) expect(task.not_expired?).to eq(true) task.update!(expired_at: 1.hour.ago) expect(task.not_expired?).to eq(false) task.update!(expired_at: nil) expect(task.not_expired?).to eq(true) end it 'defines a scope comparing against current time' do task.update!(expired_at: 1.hour.from_now) expect(Task.expired).not_to include(task) task.update!(expired_at: 1.hour.ago) expect(Task.expired).to include(task) task.update!(expired_at: nil) expect(Task.expired).not_to include(task) end it 'defines an inverse scope comparing against current time' do task.update!(expired_at: 1.hour.from_now) expect(Task.not_expired).to include(task) task.update!(expired_at: 1.hour.ago) expect(Task.not_expired).not_to include(task) task.update!(expired_at: nil) expect(Task.not_expired).to include(task) end context 'with a date field' do it 'defines a predicate method comparing against current date' do task.update!(notified_on: Date.yesterday) expect(task.notified?).to eq(true) task.update!(notified_on: Date.current) expect(task.notified?).to eq(true) task.update!(notified_on: Date.tomorrow) expect(task.notified?).to eq(false) task.update!(notified_on: nil) expect(task.notified?).to eq(false) end it 'defines an inverse predicate method comparing against current date' do task.update!(notified_on: Date.yesterday) expect(task.not_notified?).to eq(false) task.update!(notified_on: Date.current) expect(task.not_notified?).to eq(false) task.update!(notified_on: Date.tomorrow) expect(task.not_notified?).to eq(true) task.update!(notified_on: nil) expect(task.not_notified?).to eq(true) end it 'defines a scope comparing against current date' do task.update!(notified_on: Date.yesterday) expect(Task.notified).to include(task) task.update!(notified_on: Date.current) expect(Task.notified).to include(task) task.update!(notified_on: Date.tomorrow) expect(Task.notified).not_to include(task) task.update!(notified_on: nil) expect(Task.notified).not_to include(task) end it 'defines an inverse scope comparing against current date' do task.update!(notified_on: Date.yesterday) expect(Task.not_notified).not_to include(task) task.update!(notified_on: Date.current) expect(Task.not_notified).not_to include(task) task.update!(notified_on: Date.tomorrow) expect(Task.not_notified).to include(task) task.update!(notified_on: nil) expect(Task.not_notified).to include(task) end end end end
ruby
MIT
8dff3e67d5e0ea82aac3854ed26a07c40c31b2e2
2026-01-04T17:46:25.965698Z
false
pienkowb/active_record-events
https://github.com/pienkowb/active_record-events/blob/8dff3e67d5e0ea82aac3854ed26a07c40c31b2e2/spec/active_record/events/macro_spec.rb
spec/active_record/events/macro_spec.rb
require 'spec_helper' require 'active_record/events/macro' RSpec.describe ActiveRecord::Events::Macro do let(:event_name) { :confirm } subject { described_class.new(event_name, options) } context 'without options' do let(:options) { {} } it "doesn't include any options" do expect(subject.to_s).to eq('has_event :confirm') end end context 'with a string option' do let(:options) { { object: 'email' } } it 'prepends the option value with a colon' do expect(subject.to_s).to eq('has_event :confirm, object: :email') end end context 'with a symbol option' do let(:options) { { object: :email } } it 'prepends the option value with a colon' do expect(subject.to_s).to eq('has_event :confirm, object: :email') end end context 'with a boolean option' do let(:options) { { skip_scopes: true } } it "doesn't prepend the option value with a colon" do expect(subject.to_s).to eq('has_event :confirm, skip_scopes: true') end end context 'with multiple options' do let(:options) { { object: :email, field_type: :date } } it 'includes all of the options' do macro = 'has_event :confirm, object: :email, field_type: :date' expect(subject.to_s).to eq(macro) end end end
ruby
MIT
8dff3e67d5e0ea82aac3854ed26a07c40c31b2e2
2026-01-04T17:46:25.965698Z
false
pienkowb/active_record-events
https://github.com/pienkowb/active_record-events/blob/8dff3e67d5e0ea82aac3854ed26a07c40c31b2e2/spec/active_record/events/method_factory_spec.rb
spec/active_record/events/method_factory_spec.rb
require 'spec_helper' RSpec.describe ActiveRecord::Events::MethodFactory do let(:event_name) { :complete } let(:options) { {} } subject { described_class.new(event_name, options) } it 'generates instance methods' do result = subject.instance_methods expect(result).to have_method(:completed?) expect(result).to have_method(:not_completed?) expect(result).to have_method(:complete!) expect(result).to have_method(:complete) end it 'generates class methods' do result = subject.class_methods expect(result).to have_method(:complete_all) expect(result).to have_method(:completed) expect(result).to have_method(:not_completed) end context 'with the object option' do let(:options) { { object: :task } } it 'generates instance methods' do result = subject.instance_methods expect(result).to have_method(:task_completed?) expect(result).to have_method(:task_not_completed?) expect(result).to have_method(:complete_task!) expect(result).to have_method(:complete_task) end it 'generates class methods' do result = subject.class_methods expect(result).to have_method(:complete_all_tasks) expect(result).to have_method(:task_completed) expect(result).to have_method(:task_not_completed) end end context 'with the skip scopes option' do let(:options) { { skip_scopes: true } } it 'generates class methods without scopes' do result = subject.class_methods expect(result).to have_method(:complete_all) expect(result).not_to have_method(:completed) expect(result).not_to have_method(:not_completed) end end end
ruby
MIT
8dff3e67d5e0ea82aac3854ed26a07c40c31b2e2
2026-01-04T17:46:25.965698Z
false
pienkowb/active_record-events
https://github.com/pienkowb/active_record-events/blob/8dff3e67d5e0ea82aac3854ed26a07c40c31b2e2/spec/active_record/events/naming_spec.rb
spec/active_record/events/naming_spec.rb
require 'spec_helper' RSpec.describe ActiveRecord::Events::Naming do let(:event_name) { :complete } let(:options) { {} } subject { described_class.new(event_name, options) } it 'generates a field name' do expect(subject.field).to eq('completed_at') end it 'generates a predicate name' do expect(subject.predicate).to eq('completed?') end it 'generates an inverse predicate name' do expect(subject.inverse_predicate).to eq('not_completed?') end it 'generates an action name' do expect(subject.action).to eq('complete!') end it 'generates a safe action name' do expect(subject.safe_action).to eq('complete') end it 'generates a collective action name' do expect(subject.collective_action).to eq('complete_all') end it 'generates a scope name' do expect(subject.scope).to eq('completed') end it 'generates an inverse scope name' do expect(subject.inverse_scope).to eq('not_completed') end context 'with an object' do let(:options) { { object: :task } } it 'generates a field name' do expect(subject.field).to eq('task_completed_at') end it 'generates a predicate name' do expect(subject.predicate).to eq('task_completed?') end it 'generates an inverse predicate name' do expect(subject.inverse_predicate).to eq('task_not_completed?') end it 'generates an action name' do expect(subject.action).to eq('complete_task!') end it 'generates a safe action name' do expect(subject.safe_action).to eq('complete_task') end it 'generates a collective action name' do expect(subject.collective_action).to eq('complete_all_tasks') end it 'generates a scope name' do expect(subject.scope).to eq('task_completed') end it 'generates an inverse scope name' do expect(subject.inverse_scope).to eq('task_not_completed') end end context 'with a date field' do let(:options) { { field_type: :date } } it 'generates a field name' do expect(subject.field).to eq('completed_on') end end context 'with a custom field name' do let(:options) { { field_name: :completion_time } } it 'returns the field name' do expect(subject.field).to eq('completion_time') end end end
ruby
MIT
8dff3e67d5e0ea82aac3854ed26a07c40c31b2e2
2026-01-04T17:46:25.965698Z
false
pienkowb/active_record-events
https://github.com/pienkowb/active_record-events/blob/8dff3e67d5e0ea82aac3854ed26a07c40c31b2e2/lib/generators/active_record/event/event_generator.rb
lib/generators/active_record/event/event_generator.rb
require 'rails/generators' require 'active_record/events/naming' require 'active_record/events/macro' module ActiveRecord module Generators class EventGenerator < Rails::Generators::Base MACRO_OPTIONS = %w[object field_type skip_scopes strategy].freeze argument :model_name, type: :string argument :event_name, type: :string class_option :skip_scopes, type: :boolean, desc: 'Skip the inclusion of scope methods' class_option :field_type, type: :string, desc: 'The field type (datetime or date)' class_option :object, type: :string, desc: 'The name of the object' class_option :strategy, type: :string, desc: 'The comparison strategy (presence or time_comparison)' source_root File.expand_path('templates', __dir__) def generate_migration_file naming = ActiveRecord::Events::Naming.new(event_name, options) table_name = model_name.tableize field_name = naming.field field_type = options[:field_type] || 'datetime' migration_name = "add_#{field_name}_to_#{table_name}" attributes = "#{field_name}:#{field_type}" invoke 'active_record:migration', [migration_name, attributes] end def update_model_file return unless model_file_exists? macro_options = options.slice(*MACRO_OPTIONS) macro = ActiveRecord::Events::Macro.new(event_name, macro_options) pattern = /^\s*class\s.+\n/ inject_into_file model_file_path, "\s\s#{macro}\n", after: pattern end private def model_file_exists? File.exist?(model_file_path) end def model_file_path File.expand_path("app/models/#{model_file_name}", destination_root) end def model_file_name "#{model_name.underscore.singularize}.rb" end end end end
ruby
MIT
8dff3e67d5e0ea82aac3854ed26a07c40c31b2e2
2026-01-04T17:46:25.965698Z
false
pienkowb/active_record-events
https://github.com/pienkowb/active_record-events/blob/8dff3e67d5e0ea82aac3854ed26a07c40c31b2e2/lib/active_record/events.rb
lib/active_record/events.rb
require 'active_support' require 'active_record/events/version' require 'active_record/events/naming' require 'active_record/events/method_factory' require 'active_record/events/extension' require 'active_record/events/macro' ActiveSupport.on_load(:active_record) do extend ActiveRecord::Events::Extension end
ruby
MIT
8dff3e67d5e0ea82aac3854ed26a07c40c31b2e2
2026-01-04T17:46:25.965698Z
false
pienkowb/active_record-events
https://github.com/pienkowb/active_record-events/blob/8dff3e67d5e0ea82aac3854ed26a07c40c31b2e2/lib/active_record/events/version.rb
lib/active_record/events/version.rb
module ActiveRecord module Events VERSION = '4.1.2'.freeze end end
ruby
MIT
8dff3e67d5e0ea82aac3854ed26a07c40c31b2e2
2026-01-04T17:46:25.965698Z
false
pienkowb/active_record-events
https://github.com/pienkowb/active_record-events/blob/8dff3e67d5e0ea82aac3854ed26a07c40c31b2e2/lib/active_record/events/method_factory.rb
lib/active_record/events/method_factory.rb
require 'active_record/events/naming' module ActiveRecord module Events class MethodFactory def initialize(event_name, options) @options = options @naming = Naming.new(event_name, options) @strategy = options[:strategy].try(:to_sym) @field_type = options[:field_type].try(:to_sym) end def instance_methods Module.new.tap do |module_| define_predicate_method(module_, naming, strategy) define_inverse_predicate_method(module_, naming) define_action_method(module_, naming) define_safe_action_method(module_, naming) end end def class_methods Module.new.tap do |module_| time_class = field_type == :date ? Date : Time define_collective_action_method(module_, naming, time_class) unless options[:skip_scopes] define_scope_method(module_, naming, strategy, time_class) define_inverse_scope_method(module_, naming, strategy, time_class) end end end private attr_reader :options, :naming, :strategy, :field_type def define_predicate_method(module_, naming, strategy) module_.send(:define_method, naming.predicate) do if strategy == :time_comparison self[naming.field].present? && !self[naming.field].future? else self[naming.field].present? end end end def define_inverse_predicate_method(module_, naming) module_.send(:define_method, naming.inverse_predicate) do !__send__(naming.predicate) end end def define_action_method(module_, naming) module_.send(:define_method, naming.action) do if persisted? touch(naming.field) else self[naming.field] = current_time_from_proper_timezone end end end def define_safe_action_method(module_, naming) module_.send(:define_method, naming.safe_action) do __send__(naming.action) if __send__(naming.inverse_predicate) end end def define_collective_action_method(module_, naming, time_class) module_.send(:define_method, naming.collective_action) do if respond_to?(:touch_all) touch_all(naming.field) else update_all(naming.field => time_class.current) end end end def define_scope_method(module_, naming, strategy, time_class) module_.send(:define_method, naming.scope) do if strategy == :time_comparison where(arel_table[naming.field].lteq(time_class.current)) else where(arel_table[naming.field].not_eq(nil)) end end end def define_inverse_scope_method(module_, naming, strategy, time_class) module_.send(:define_method, naming.inverse_scope) do arel_field = arel_table[naming.field] if strategy == :time_comparison where(arel_field.eq(nil).or(arel_field.gt(time_class.current))) else where(arel_field.eq(nil)) end end end end end end
ruby
MIT
8dff3e67d5e0ea82aac3854ed26a07c40c31b2e2
2026-01-04T17:46:25.965698Z
false
pienkowb/active_record-events
https://github.com/pienkowb/active_record-events/blob/8dff3e67d5e0ea82aac3854ed26a07c40c31b2e2/lib/active_record/events/extension.rb
lib/active_record/events/extension.rb
require 'active_record/events/method_factory' module ActiveRecord module Events module Extension def has_events(*names) options = names.extract_options! names.each { |n| has_event(n, options) } end def has_event(name, options = {}) method_factory = MethodFactory.new(name, options) include method_factory.instance_methods extend method_factory.class_methods end end end end
ruby
MIT
8dff3e67d5e0ea82aac3854ed26a07c40c31b2e2
2026-01-04T17:46:25.965698Z
false
pienkowb/active_record-events
https://github.com/pienkowb/active_record-events/blob/8dff3e67d5e0ea82aac3854ed26a07c40c31b2e2/lib/active_record/events/macro.rb
lib/active_record/events/macro.rb
module ActiveRecord module Events class Macro def initialize(event_name, options) @event_name = event_name.to_s @options = options end def to_s "has_event :#{event_name}#{options_list}" end private def event_name @event_name.underscore end def options_list options.unshift('').join(', ') if options.present? end def options @options.map { |k, v| "#{k}: #{convert_value(v)}" } end def convert_value(value) symbol_or_string?(value) ? ":#{value}" : value end def symbol_or_string?(value) value.is_a?(Symbol) || value.is_a?(String) end end end end
ruby
MIT
8dff3e67d5e0ea82aac3854ed26a07c40c31b2e2
2026-01-04T17:46:25.965698Z
false
pienkowb/active_record-events
https://github.com/pienkowb/active_record-events/blob/8dff3e67d5e0ea82aac3854ed26a07c40c31b2e2/lib/active_record/events/naming.rb
lib/active_record/events/naming.rb
require 'verbs' module ActiveRecord module Events class Naming def initialize(infinitive, options = {}) @infinitive = infinitive @object = options[:object].presence @field_name = options[:field_name].to_s @field_type = options[:field_type].try(:to_sym) end def field return field_name if field_name.present? suffix = field_type == :date ? 'on' : 'at' concatenate(object, past_participle, suffix) end def predicate "#{concatenate(object, past_participle)}?" end def inverse_predicate "#{concatenate(object, 'not', past_participle)}?" end def action "#{concatenate(infinitive, object)}!" end def safe_action concatenate(infinitive, object) end def collective_action concatenate(infinitive, 'all', plural_object) end def scope concatenate(object, past_participle) end def inverse_scope concatenate(object, 'not', past_participle) end private attr_reader :infinitive, :object, :field_name, :field_type def concatenate(*parts) parts.compact.join('_') end def past_participle infinitive.verb.conjugate(tense: :past, aspect: :perfective) end def plural_object object.to_s.pluralize if object.present? end end end end
ruby
MIT
8dff3e67d5e0ea82aac3854ed26a07c40c31b2e2
2026-01-04T17:46:25.965698Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/ruby-generate-dockerfile/app/generate_dockerfile.rb
ruby-generate-dockerfile/app/generate_dockerfile.rb
#!/rbenv/shims/ruby # Copyright 2017 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. require "erb" require "optparse" require "delegate" require_relative "app_config.rb" class GenerateDockerfile DEFAULT_WORKSPACE_DIR = "/workspace" GENERATOR_DIR = ::File.absolute_path(::File.dirname __FILE__) DOCKERIGNORE_PATHS = [ ".dockerignore", "Dockerfile", ".git", ".hg", ".svn" ] def initialize args @workspace_dir = DEFAULT_WORKSPACE_DIR @base_image = ::ENV["DEFAULT_RUBY_BASE_IMAGE"] @build_tools_image = ::ENV["DEFAULT_RUBY_BUILD_TOOLS_IMAGE"] @prebuilt_ruby_images = {} ::ENV["DEFAULT_PREBUILT_RUBY_IMAGES"].to_s.split(",").each do |str| add_prebuilt_ruby_image(str) end @default_ruby_version = ::ENV["DEFAULT_RUBY_VERSION"] || ::RUBY_VERSION @bundler1_version = ::ENV["PROVIDED_BUNDLER1_VERSION"] @bundler2_version = ::ENV["PROVIDED_BUNDLER2_VERSION"] @testing = false parse_args args ::Dir.chdir @workspace_dir begin @app_config = ::AppConfig.new @workspace_dir rescue ::AppConfig::Error => ex ::STDERR.puts ex.message exit 1 end @timestamp = ::Time.now.utc.strftime "%Y-%m-%d %H:%M:%S UTC" end def main write_dockerfile write_dockerignore if @testing system "chmod -R a+w #{@app_config.workspace_dir}" end end private def parse_args(args) ::OptionParser.new do |opts| opts.on "-t" do @testing = true end opts.on "--workspace-dir=PATH" do |path| @workspace_dir = ::File.absolute_path path end opts.on "--base-image=IMAGE" do |image| @base_image = image end opts.on "--build-tools-image=IMAGE" do |image| @build_tools_image = image end opts.on "-p IMAGE", "--prebuilt-image=IMAGE" do |image| add_prebuilt_ruby_image(image) end opts.on "--default-ruby-version=VERSION" do |version| @default_ruby_version = version end end.parse! args end def add_prebuilt_ruby_image(str) if str =~ /^(.+)=(.+)$/ @prebuilt_ruby_images[$1] = $2 end end def write_dockerfile b = TemplateCallbacks.new(@app_config, @timestamp, @base_image, @build_tools_image, @prebuilt_ruby_images, @default_ruby_version, @bundler1_version, @bundler2_version).instance_eval{ binding } write_path = "#{@app_config.workspace_dir}/Dockerfile" if ::File.exist? write_path ::STDERR.puts "Unable to generate Dockerfile because one already exists." exit 1 end template = ::File.read "#{GENERATOR_DIR}/Dockerfile.erb" content = ::ERB.new(template, nil, "<>").result(b) ::File.open write_path, "w" do |file| file.write content end puts "Generated Dockerfile" puts content end def write_dockerignore write_path = "#{@app_config.workspace_dir}/.dockerignore" if ::File.exist? write_path existing_entries = ::IO.readlines write_path else existing_entries = [] end desired_entries = DOCKERIGNORE_PATHS + [@app_config.app_yaml_path] ::File.open write_path, "a" do |file| (desired_entries - existing_entries).each do |entry| file.puts entry end end if existing_entries.empty? puts "Generated .dockerignore" else puts "Updated .dockerignore" end end class TemplateCallbacks < SimpleDelegator def initialize app_config, timestamp, base_image, build_tools_image, prebuilt_ruby_images, default_ruby_version, bundler1_version, bundler2_version @timestamp = timestamp @base_image = base_image @build_tools_image = build_tools_image @prebuilt_ruby_images = prebuilt_ruby_images @default_ruby_version = default_ruby_version @bundler1_version = bundler1_version @bundler2_version = bundler2_version super app_config end attr_reader :timestamp attr_reader :base_image attr_reader :build_tools_image def ruby_version v = super.to_s v.empty? ? @default_ruby_version : v end def prebuilt_ruby_image @prebuilt_ruby_images[ruby_version] end def escape_quoted str str.gsub("\\", "\\\\").gsub("\"", "\\\"").gsub("\n", "\\n") end def render_env hash hash.map{ |k,v| "#{k}=\"#{escape_quoted v}\"" }.join(" \\\n ") end end end ::GenerateDockerfile.new(::ARGV).main
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/ruby-generate-dockerfile/app/app_config.rb
ruby-generate-dockerfile/app/app_config.rb
# Copyright 2017 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. require "json" require "net/http" require "optparse" require "psych" class AppConfig DEFAULT_WORKSPACE_DIR = "/workspace" DEFAULT_APP_YAML_PATH = "./app.yaml" DEFAULT_RACK_ENTRYPOINT = "bundle exec rackup -p $PORT" DEFAULT_SERVICE_NAME = "default" class Error < ::StandardError end attr_reader :workspace_dir attr_reader :app_yaml_path attr_reader :project_id attr_reader :project_id_for_display attr_reader :project_id_for_example attr_reader :service_name attr_reader :env_variables attr_reader :cloud_sql_instances attr_reader :build_scripts attr_reader :runtime_config attr_reader :raw_entrypoint attr_reader :entrypoint attr_reader :install_packages attr_reader :ruby_version attr_reader :has_gemfile def initialize workspace_dir @workspace_dir = workspace_dir init_app_config # Must be called first init_project_id init_env_variables init_packages init_ruby_config init_cloud_sql_instances init_entrypoint init_build_scripts # Must be called after init_entrypoint end private def init_app_config @app_yaml_path = ::ENV["GAE_APPLICATION_YAML_PATH"] || DEFAULT_APP_YAML_PATH config_file = "#{@workspace_dir}/#{@app_yaml_path}" begin @app_config = ::Psych.load_file config_file rescue raise ::AppConfig::Error, "Could not read app engine config file: #{config_file.inspect}" end @runtime_config = @app_config["runtime_config"] || {} @beta_settings = @app_config["beta_settings"] || {} @service_name = @app_config["service"] || DEFAULT_SERVICE_NAME end def init_project_id @project_id = ::ENV["PROJECT_ID"] unless @project_id http = ::Net::HTTP.new "169.254.169.254", open_timeout: 0.1, read_timeout: 0.1 begin resp = http.get "/computeMetadata/v1/project/project-id", {"Metadata-Flavor" => "Google"} @project_id = resp.body if resp.code == "200" http.finish rescue ::StandardError end end @project_id_for_display = @project_id || "(unknown)" @project_id_for_example = @project_id || "my-project-id" end def init_env_variables @env_variables = {} (@app_config["env_variables"] || {}).each do |k, v| if k !~ %r{\A[a-zA-Z]\w*\z} raise ::AppConfig::Error, "Illegal environment variable name: #{k.inspect}" end @env_variables[k.to_s] = v.to_s end end def init_build_scripts raw_build_scripts = @runtime_config["build"] if raw_build_scripts && @runtime_config["dotenv_config"] raise ::AppConfig::Error, "The `dotenv_config` setting conflicts with the `build` setting." + " If you want to build a dotenv file in your list of custom build" + " steps, try adding the build step: `gem install rcloadenv && rbenv " + " rehash && rcloadenv my-config-name > .env`" end @build_scripts = raw_build_scripts ? Array(raw_build_scripts) : default_build_scripts @build_scripts.each do |script| if script.include? "\n" raise ::AppConfig::Error, "Illegal newline in build command: #{script.inspect}" end end end def default_build_scripts [dotenv_from_rc_script, rails_asset_precompile_script].compact end def rails_asset_precompile_script return nil if !::File.directory?("#{@workspace_dir}/app/assets") || !::File.file?("#{@workspace_dir}/config/application.rb") script = if @entrypoint =~ /(rcloadenv\s.+\s--\s)/ "bundle exec #{$1}rake assets:precompile || true" else "bundle exec rake assets:precompile || true" end unless @cloud_sql_instances.empty? script = "access_cloud_sql --lenient && #{script}" end script end def dotenv_from_rc_script config_name = @runtime_config["dotenv_config"].to_s return nil if config_name.empty? "gem install rcloadenv && rbenv rehash && rcloadenv #{config_name} >> .env" end def init_cloud_sql_instances @cloud_sql_instances = Array(@beta_settings["cloud_sql_instances"]). flat_map{ |a| a.split(",") } @cloud_sql_instances.each do |name| if name !~ %r{\A[\w:.-]+\z} raise ::AppConfig::Error, "Illegal cloud sql instance name: #{name.inspect}" end end end def init_entrypoint @raw_entrypoint = @runtime_config["entrypoint"] || @app_config["entrypoint"] if !@raw_entrypoint && ::File.readable?("#{@workspace_dir}/config.ru") @raw_entrypoint = DEFAULT_RACK_ENTRYPOINT end unless @raw_entrypoint raise ::AppConfig::Error, "Please specify an entrypoint in the App Engine configuration" end if @raw_entrypoint.include? "\n" raise ::AppConfig::Error, "Illegal newline in entrypoint: #{@raw_entrypoint.inspect}" end @entrypoint = decorate_entrypoint @raw_entrypoint end # Prepare entrypoint for rendering into the dockerfile. # If the provided entrypoint is an array, render it in exec format. # If the provided entrypoint is a string, we have to render it in shell # format. Now, we'd like to prepend "exec" so signals get caught properly. # However, there are some edge cases that we omit for safety. def decorate_entrypoint entrypoint return ::JSON.generate entrypoint if entrypoint.is_a? Array return entrypoint if entrypoint.start_with? "exec " return entrypoint if entrypoint =~ /;|&&|\|/ return entrypoint if entrypoint =~ /^\w+=/ "exec #{entrypoint}" end def init_packages @install_packages = Array( @runtime_config["packages"] || @app_config["packages"] ) @install_packages.each do |pkg| if pkg !~ %r{\A[\w.-]+\z} raise ::AppConfig::Error, "Illegal debian package name: #{pkg.inspect}" end end end def init_ruby_config @ruby_version = ::File.read("#{@workspace_dir}/.ruby-version") rescue '' @ruby_version.strip! if @ruby_version == "" result = ::Dir.chdir(@workspace_dir) { `bundle platform --ruby` } if result.strip =~ %r{^ruby (\d+\.\d+\.\d+)$} @ruby_version = $1 end end if @ruby_version =~ %r{\Aruby-(\d+\.\d+\.[\w.-]+)\z} @ruby_version = $1 end unless @ruby_version.empty? || @ruby_version =~ %r{\A\d+\.\d+\.[\w.-]+\z} raise ::AppConfig::Error, "Illegal ruby version: #{@ruby_version.inspect}" end @has_gemfile = ::File.readable?("#{@workspace_dir}/Gemfile.lock") || ::File.readable?("#{@workspace_dir}/gems.locked") end end
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/integration_test/builder_app/myapp.rb
integration_test/builder_app/myapp.rb
require 'json' require 'sinatra' require "sinatra/multi_route" require 'stackdriver' require "google/cloud/monitoring/v3" require 'open3' # Grab project_id from gcloud sdk project_id = ENV["GOOGLE_CLOUD_PROJECT"] || Google::Cloud.env.project_id.to_s unless project_id.empty? ####################################### # Setup ErrorReporting Middleware use Google::Cloud::ErrorReporting::Middleware ####################################### # Setup Logging Middleware use Google::Cloud::Logging::Middleware ####################################### # Setup Trace Middleware use Google::Cloud::Trace::Middleware ####################################### # Setup Monitoring monitoring = Google::Cloud::Monitoring::V3::MetricServiceClient.new end set :environment, :production set :bind, "0.0.0.0" set :port, 8080 set :show_exceptions, true get '/' do "Hello World!" end get '/system' do ENV.inspect end get '/_ah/health' do "Success" end get '/custom' do "{}" end route :get, :post, '/exception' do fail "project_id missing." if project_id.empty? begin fail "Test error from sinatra app" rescue => e Google::Cloud::ErrorReporting.report e end "Error submitted." end route :get, :post, '/logging_standard' do fail "project_id missing." if project_id.empty? request.body.rewind request_payload = JSON.parse request.body.read token = request_payload["token"] level = request_payload["level"].to_sym logger.add level, token 'appengine.googleapis.com%2Fruby_app_log' end route :get, :post, "/logging_custom" do fail "project_id missing." if project_id.empty? request.body.rewind request_payload = JSON.parse request.body.read token = request_payload["token"] level = request_payload["level"].to_sym log_name = request_payload["log_name"] logging = Google::Cloud::Logging.new resource = Google::Cloud::Logging::Middleware.build_monitored_resource entry = logging.entry.tap do |e| e.payload = token e.log_name = log_name e.severity = level e.resource = resource end logging.write_entries entry end route :get, :post, '/monitoring' do fail "project_id missing." if project_id.empty? request.body.rewind request_payload = JSON.parse request.body.read token = request_payload["token"] name = request_payload["name"] time_series_hash = { metric: { type: name }, resource: { type: "global" }, points: [{ interval: { endTime: { seconds: Time.now.to_i, nanos: Time.now.nsec } }, value: { int64_value: token.to_i } }] } time_series = Google::Monitoring::V3::TimeSeries.decode_json time_series_hash.to_json monitoring.create_time_series "projects/#{project_id}", [time_series] "Time series submitted." end
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/integration_test/simple_app/myapp.rb
integration_test/simple_app/myapp.rb
require 'json' require 'sinatra' require "sinatra/multi_route" require 'stackdriver' require "google/cloud/monitoring/v3" require 'open3' # Grab project_id from gcloud sdk project_id = ENV["GOOGLE_CLOUD_PROJECT"] || Google::Cloud.env.project_id.to_s unless project_id.empty? ####################################### # Setup ErrorReporting Middleware use Google::Cloud::ErrorReporting::Middleware ####################################### # Setup Logging Middleware use Google::Cloud::Logging::Middleware ####################################### # Setup Trace Middleware use Google::Cloud::Trace::Middleware ####################################### # Setup Monitoring monitoring = Google::Cloud::Monitoring::V3::MetricServiceClient.new end set :environment, :production set :bind, "0.0.0.0" set :port, 8080 set :show_exceptions, true get '/' do "Hello World!" end get '/system' do ENV.inspect end get '/_ah/health' do "Success" end get '/custom' do "{}" end route :get, :post, '/exception' do fail "project_id missing." if project_id.empty? begin fail "Test error from sinatra app" rescue => e Google::Cloud::ErrorReporting.report e end "Error submitted." end route :get, :post, '/logging_standard' do fail "project_id missing." if project_id.empty? request.body.rewind request_payload = JSON.parse request.body.read token = request_payload["token"] level = request_payload["level"].to_sym logger.add level, token 'appengine.googleapis.com%2Fruby_app_log' end route :get, :post, "/logging_custom" do fail "project_id missing." if project_id.empty? request.body.rewind request_payload = JSON.parse request.body.read token = request_payload["token"] level = request_payload["level"].to_sym log_name = request_payload["log_name"] logging = Google::Cloud::Logging.new resource = Google::Cloud::Logging::Middleware.build_monitored_resource entry = logging.entry.tap do |e| e.payload = token e.log_name = log_name e.severity = level e.resource = resource end logging.write_entries entry end route :get, :post, '/monitoring' do fail "project_id missing." if project_id.empty? request.body.rewind request_payload = JSON.parse request.body.read token = request_payload["token"] name = request_payload["name"] time_series_hash = { metric: { type: name }, resource: { type: "global" }, points: [{ interval: { endTime: { seconds: Time.now.to_i, nanos: Time.now.nsec } }, value: { int64_value: token.to_i } }] } time_series = Google::Monitoring::V3::TimeSeries.decode_json time_series_hash.to_json monitoring.create_time_series "projects/#{project_id}", [time_series] "Time series submitted." end
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/integration_test/deploy_check/app.rb
integration_test/deploy_check/app.rb
require "sinatra" get "/" do "Hello world!" end
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/test_generate_dockerfile.rb
test/test_generate_dockerfile.rb
# Copyright 2017 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. require_relative "helper" require "fileutils" class TestGenerateDockerfile < ::Minitest::Test include Helper CASES_DIR = ::File.join __dir__, "builder_cases" APPS_DIR = ::File.join __dir__, "sample_apps" TMP_DIR = ::File.join __dir__, "tmp" CONFIG_HEADER = "runtime: ruby\nenv: flex\n" def test_default_config run_generate_dockerfile "rack_app" assert_dockerfile_line "## Service: default" assert_dockerfile_commented "RUN apt-get update -y" assert_dockerfile_line "ARG ruby_version=" assert_dockerfile_commented "ENV NAME=\"value\"" assert_dockerfile_line "RUN bundle install" assert_dockerfile_commented "ARG BUILD_CLOUDSQL_INSTANCES=" assert_dockerfile_commented "RUN bundle exec rake assets:precompile" assert_dockerfile_line "CMD exec bundle exec rackup -p \\$PORT" end def test_config_path_and_service_name run_generate_dockerfile "rack_app", config_path: "myservice.yaml", config: "service: myservicename" assert_dockerfile_line "## Service: myservicename" end def test_debian_packages config = <<~CONFIG runtime_config: packages: - libgeos-dev - libproj-dev CONFIG run_generate_dockerfile "rack_app", config: config assert_dockerfile_line "RUN apt-get update -y" assert_dockerfile_line " && apt-get install -y -q libgeos-dev libproj-dev" end def test_ruby_version_selfbuilt run_generate_dockerfile "rack_app", ruby_version: "2.3.99" assert_dockerfile_line "ARG ruby_version=\"2\\.3\\.99\"" assert_dockerfile_commented "COPY --from=" assert_dockerfile_line " && rbenv install -s" end def test_ruby_version_prebuilt version = ::ENV["PRIMARY_RUBY_VERSIONS"].to_s.split(",").last skip "No prebuilt ruby versions" unless version version_escaped = version.gsub(".", "\\.") run_generate_dockerfile "rack_app", ruby_version: version assert_dockerfile_line "ARG ruby_version=\"#{version_escaped}\"" assert_dockerfile_line "COPY --from=" assert_dockerfile_commented " && rbenv install -s" end def test_env_variables config = <<~CONFIG env_variables: VAR1: value1 VAR2: "with space" VAR3: "\\"quoted\\"\\nnewline" CONFIG run_generate_dockerfile "rack_app", config: config assert_dockerfile_line "ENV VAR1=\"value1\" \\\\\\n" + " VAR2=\"with space\" \\\\\\n" + " VAR3=\"\\\\\"quoted\\\\\"\\\\nnewline\"" end def test_sql_instances config = <<~CONFIG beta_settings: cloud_sql_instances: - my-proj:my-region:my-db - proj2:region2:db2 CONFIG run_generate_dockerfile "rack_app", config: config assert_dockerfile_line "ARG BUILD_CLOUDSQL_INSTANCES=" \ "\"my-proj:my-region:my-db,proj2:region2:db2\"" end def test_custom_build_scripts config = <<~CONFIG runtime_config: build: - bundle exec rake do:something - bundle exec rake do:something:else CONFIG run_generate_dockerfile "rack_app", config: config assert_dockerfile_line "RUN bundle exec rake do:something" assert_dockerfile_line "RUN bundle exec rake do:something:else" end def test_rails_default_build_scripts run_generate_dockerfile "rails5_app" assert_dockerfile_line "RUN bundle exec rake assets:precompile \\|\\| true" end def test_rails_default_build_scripts_with_cloud_sql config = <<~CONFIG beta_settings: cloud_sql_instances: my-proj:my-region:my-db CONFIG run_generate_dockerfile "rails5_app", config: config assert_dockerfile_line "RUN access_cloud_sql --lenient &&" \ " bundle exec rake assets:precompile \\|\\| true" end def test_entrypoint config = <<~CONFIG entrypoint: bundle exec bin/rails s CONFIG run_generate_dockerfile "rack_app", config: config assert_dockerfile_line "CMD exec bundle exec bin/rails s" end def test_no_gemfile run_generate_dockerfile "rack_app", delete_gemfile: true assert_dockerfile_commented "RUN bundle install" end def test_env_variable_name_failure config = <<~CONFIG env_variables: hi-ho: value1 CONFIG run_generate_dockerfile "rack_app", config: config, expect_failure: true end def test_debian_package_failure config = <<~CONFIG runtime_config: packages: - libgeos dev CONFIG run_generate_dockerfile "rack_app", config: config, expect_failure: true end def test_ruby_version_failure run_generate_dockerfile "rack_app", ruby_version: "2.4.1\nRUN echo hi", expect_failure: true end def test_sql_instances_failure config = <<~CONFIG beta_settings: cloud_sql_instances: - my-proj my-region:my-db CONFIG run_generate_dockerfile "rack_app", config: config, expect_failure: true end def test_build_scripts_failure config = <<~CONFIG runtime_config: build: - "bundle exec rake do:something\\nwith newline" CONFIG run_generate_dockerfile "rack_app", config: config, expect_failure: true end private def assert_dockerfile_line content assert_file_contents "#{TMP_DIR}/Dockerfile", %r{^#{content}} end def assert_dockerfile_commented content assert_file_contents "#{TMP_DIR}/Dockerfile", %r{^#\s#{content}} end def run_generate_dockerfile app_name, config: "", config_path: "app.yaml", ruby_version: "", delete_gemfile: false, expect_failure: false app_dir = ::File.join APPS_DIR, app_name ::FileUtils.rm_rf TMP_DIR ::FileUtils.cp_r app_dir, TMP_DIR if config ::File.open ::File.join(TMP_DIR, config_path), "w" do |file| file.puts CONFIG_HEADER + config end end unless ruby_version.empty? ::File.open ::File.join(TMP_DIR, ".ruby-version"), "w" do |file| file.write ruby_version end end if delete_gemfile ::File.delete ::File.join(TMP_DIR, "Gemfile") ::File.delete ::File.join(TMP_DIR, "Gemfile.lock") end docker_args = "-v #{TMP_DIR}:/workspace -w /workspace" \ " -e GAE_APPLICATION_YAML_PATH=#{config_path}" \ " ruby-generate-dockerfile -t" \ " --base-image=gcr.io/gcp-runtimes/ruby/#{Helper.os_name}:my-test-tag" if expect_failure assert_cmd_fails "docker run --rm #{docker_args}" else assert_docker_output docker_args, nil assert_file_contents "#{TMP_DIR}/Dockerfile", %r{FROM gcr\.io/gcp-runtimes/ruby/#{Helper.os_name}:my-test-tag AS augmented-base} assert_file_contents "#{TMP_DIR}/.dockerignore", /Dockerfile/ end end end
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/test_base_image_structure.rb
test/test_base_image_structure.rb
# Copyright 2017 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. require_relative "helper" require "json" # Runs structure tests defined in test_base_image.json locally. class TestBaseImageStructure < ::Minitest::Test include Helper BASE_DIR = ::File.dirname ::File.dirname __FILE__ CONFIG_FILE = ::File.join BASE_DIR, "ruby-base/structure-test.json" CONFIG_DATA = ::JSON.load ::IO.read CONFIG_FILE CONFIG_DATA["commandTests"].each do |test_config| define_method test_config["name"] do command_array = test_config["command"] binary = command_array.shift command = command_array.map{ |a| "'#{a}'" }.join(" ") expectations = test_config["expectedOutput"].map { |e| ::Regexp.new e } assert_docker_output \ "--entrypoint=#{binary} ruby-base #{command}", expectations end end end
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/test_app_config.rb
test/test_app_config.rb
# Copyright 2017 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. require_relative "helper" require_relative "../ruby-generate-dockerfile/app/app_config.rb" require "bundler" require "fileutils" class TestAppConfig < ::Minitest::Test EMPTY_HASH = {}.freeze EMPTY_ARRAY = [].freeze EMPTY_STRING = ''.freeze DEFAULT_CONFIG_NO_ENTRYPOINT = "env: flex\nruntime: ruby\n" DEFAULT_CONFIG = "env: flex\nruntime: ruby\nentrypoint: bundle exec ruby start.rb\n" CASES_DIR = ::File.join __dir__, "app_config" TMP_DIR = ::File.join __dir__, "tmp" def setup_test dir: nil, config: DEFAULT_CONFIG, config_file: nil, project: nil ::Dir.chdir __dir__ do ::FileUtils.rm_rf TMP_DIR if dir full_dir = ::File.join CASES_DIR, dir ::FileUtils.cp_r full_dir, TMP_DIR else ::FileUtils.mkdir TMP_DIR end ::ENV["GAE_APPLICATION_YAML_PATH"] = config_file ::ENV["PROJECT_ID"] = project if config config_path = ::File.join TMP_DIR, config_file || "app.yaml" ::File.open config_path, "w" do |file| file.write config end end ::Bundler.with_unbundled_env { @app_config = AppConfig.new TMP_DIR } end end def test_empty_directory_with_config setup_test assert_equal TMP_DIR, @app_config.workspace_dir assert_equal "./app.yaml", @app_config.app_yaml_path assert_nil @app_config.project_id assert_equal "(unknown)", @app_config.project_id_for_display assert_equal "my-project-id", @app_config.project_id_for_example assert_equal "default", @app_config.service_name assert_equal EMPTY_HASH, @app_config.env_variables assert_equal EMPTY_ARRAY, @app_config.cloud_sql_instances assert_equal EMPTY_ARRAY, @app_config.build_scripts assert_equal EMPTY_HASH, @app_config.runtime_config assert_equal "exec bundle exec ruby start.rb", @app_config.entrypoint assert_equal EMPTY_ARRAY, @app_config.install_packages assert_equal EMPTY_STRING, @app_config.ruby_version refute @app_config.has_gemfile end def test_basic_app_yaml config = <<~CONFIG env: flex runtime: ruby entrypoint: bundle exec bin/rails s env_variables: VAR1: value1 VAR2: value2 VAR3: 123 beta_settings: cloud_sql_instances: cloud-sql-instance-name,instance2 runtime_config: foo: bar packages: libgeos build: bundle exec rake hello CONFIG setup_test config: config assert_equal({"VAR1" => "value1", "VAR2" => "value2", "VAR3" => "123"}, @app_config.env_variables) assert_equal ["cloud-sql-instance-name", "instance2"], @app_config.cloud_sql_instances assert_equal ["bundle exec rake hello"], @app_config.build_scripts assert_equal "exec bundle exec bin/rails s", @app_config.entrypoint assert_equal ["libgeos"], @app_config.install_packages assert_equal "bar", @app_config.runtime_config["foo"] end def test_complex_entrypoint config = <<~CONFIG env: flex runtime: ruby entrypoint: cd myapp; bundle exec bin/rails s CONFIG setup_test config: config assert_equal "cd myapp; bundle exec bin/rails s", @app_config.entrypoint end def test_entrypoint_with_env config = <<~CONFIG env: flex runtime: ruby entrypoint: RAILS_ENV=staging bundle exec bin/rails s CONFIG setup_test config: config assert_equal "RAILS_ENV=staging bundle exec bin/rails s", @app_config.entrypoint end def test_entrypoint_already_exec config = <<~CONFIG env: flex runtime: ruby entrypoint: exec bundle exec bin/rails s CONFIG setup_test config: config assert_equal "exec bundle exec bin/rails s", @app_config.entrypoint end def test_rails_default_build setup_test dir: "rails" assert_equal ["bundle exec rake assets:precompile || true"], @app_config.build_scripts end def test_rails_and_dotenv_default_build config = <<~CONFIG env: flex runtime: ruby entrypoint: bundle exec bin/rails s runtime_config: dotenv_config: my-config CONFIG setup_test dir: "rails", config: config assert_equal \ [ "gem install rcloadenv && rbenv rehash && rcloadenv my-config >> .env", "bundle exec rake assets:precompile || true" ], @app_config.build_scripts end def test_ruby_version setup_test dir: "ruby-version" assert_equal "2.0.99", @app_config.ruby_version end def test_bundler_ruby_version setup_test dir: "gemfile-ruby" assert_equal "2.0.98", @app_config.ruby_version end def test_gemfile_old_name setup_test dir: "gemfile-old" assert @app_config.has_gemfile end def test_gemfile_configru setup_test dir: "gemfile-rack", config: DEFAULT_CONFIG_NO_ENTRYPOINT assert @app_config.has_gemfile assert_equal "exec bundle exec rackup -p $PORT", @app_config.entrypoint end def test_config_missing ex = assert_raises AppConfig::Error do setup_test config: nil end assert_match %r{Could not read app engine config file:}, ex.message end def test_needs_entrypoint ex = assert_raises AppConfig::Error do setup_test config: DEFAULT_CONFIG_NO_ENTRYPOINT end assert_match %r{Please specify an entrypoint}, ex.message end def test_illegal_env_name config = <<~CONFIG env: flex runtime: ruby entrypoint: bundle exec ruby hello.rb env_variables: VAR-1: value1 CONFIG ex = assert_raises AppConfig::Error do setup_test config: config end assert_equal "Illegal environment variable name: \"VAR-1\"", ex.message end def test_illegal_build_command config = <<~CONFIG env: flex runtime: ruby entrypoint: bundle exec ruby hello.rb runtime_config: build: "multiple\\nlines" CONFIG ex = assert_raises AppConfig::Error do setup_test config: config end assert_equal "Illegal newline in build command: \"multiple\\nlines\"", ex.message end def test_dotenv_clashes_with_custom_build config = <<~CONFIG env: flex runtime: ruby entrypoint: bundle exec ruby hello.rb runtime_config: build: ["bundle exec rake hello"] dotenv_config: my-config CONFIG ex = assert_raises AppConfig::Error do setup_test config: config end assert_match(/^The `dotenv_config` setting conflicts with the `build`/, ex.message) end def test_illegal_sql_instances config = <<~CONFIG env: flex runtime: ruby entrypoint: bundle exec ruby hello.rb beta_settings: cloud_sql_instances: bad!instance CONFIG ex = assert_raises AppConfig::Error do setup_test config: config end assert_equal "Illegal cloud sql instance name: \"bad!instance\"", ex.message end def test_illegal_entrypoint config = <<~CONFIG env: flex runtime: ruby entrypoint: "multiple\\nlines" CONFIG ex = assert_raises AppConfig::Error do setup_test config: config end assert_equal "Illegal newline in entrypoint: \"multiple\\nlines\"", ex.message end def test_illegal_debian_packages config = <<~CONFIG env: flex runtime: ruby entrypoint: bundle exec ruby hello.rb runtime_config: packages: bad!package CONFIG ex = assert_raises AppConfig::Error do setup_test config: config end assert_equal "Illegal debian package name: \"bad!package\"", ex.message end def test_illegal_ruby_version ex = assert_raises AppConfig::Error do setup_test dir: "bad-ruby-version" end assert_equal "Illegal ruby version: \"bad!version\"", ex.message end end
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/test_app_engine_exec_wrapper.rb
test/test_app_engine_exec_wrapper.rb
# Copyright 2017 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. require_relative "helper" class TestAppEngineExecWrapper < ::Minitest::Test include Helper def test_simple run_test "simple", {VAR1: "value1", VAR2: "value2"}, "sql:1:2:3" end def test_no_cloudsql run_test "no_cloudsql", {VAR1: "value1", VAR2: "value2"} end WRAPPER_TESTS_DIR = "#{::File.dirname __FILE__}/app_engine_exec_wrapper" def run_test test_case, env, sql_instances=nil ::Dir.chdir "#{WRAPPER_TESTS_DIR}/#{test_case}" do build_docker_image("--no-cache") do |image| env_params = env.map{ |k, v| "-e #{k}=#{v}" }.join " " sql_params = Array(sql_instances).map{ |s| "-s #{s}" }.join ' ' assert_cmd_succeeds "docker run --rm" + " --volume=/var/run/docker.sock:/var/run/docker.sock" + " app-engine-exec-harness" + " -i #{image} #{env_params} #{sql_params}" + " -x -P -n default" end end end end
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/test_sample_app_builds.rb
test/test_sample_app_builds.rb
# Copyright 2016 Google Inc. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. require_relative "helper" require "fileutils" class TestSampleAppBuilds < ::Minitest::Test include Helper CASES_DIR = ::File.join __dir__, "builder_cases" APPS_DIR = ::File.join __dir__, "sample_apps" TMP_DIR = ::File.join __dir__, "tmp" unless ::ENV["FASTER_TESTS"] def test_rack_app run_app_test "rack_app" do |image| assert_docker_output "#{image} test ! -d /app/public/assets", nil end end end def test_sinatra1_app run_app_test "sinatra1_app" do |image| assert_docker_output "#{image} test ! -d /app/public/assets", nil end end def test_rails5_app run_app_test "rails5_app" do |image| assert_docker_output "#{image} test -d /app/public/assets", nil end end def run_app_test app_name puts "**** Testing app: #{app_name}" app_dir = ::File.join APPS_DIR, app_name case_dir = ::File.join CASES_DIR, app_name ::FileUtils.rm_rf TMP_DIR ::FileUtils.cp_r app_dir, TMP_DIR ::Dir.glob "#{case_dir}/*", ::File::FNM_DOTMATCH do |path| ::FileUtils.cp_r path, TMP_DIR unless ::File.basename(path) =~ /^\.\.?$/ end assert_docker_output \ "-v #{TMP_DIR}:/workspace -w /workspace ruby-generate-dockerfile" \ " -t --base-image=ruby-#{Helper.os_name} --build-tools-image=ruby-build-tools", nil ::Dir.chdir TMP_DIR do build_docker_image "--no-cache" do |image| yield image run_docker_daemon "-p 8080:8080 #{image}" do |container| assert_cmd_output( "docker exec #{container} curl -s -S http://127.0.0.1:8080", "Hello World!", 10) do puts "**** server logs" execute_cmd("docker logs #{container}") end end end end end end
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/test_base_image_sample_apps.rb
test/test_base_image_sample_apps.rb
# Copyright 2017 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. require_relative "helper" # Tests of a bunch of sample apps. Treats every subdirectory of the test # directory that contains a Dockerfile as a sample app. Builds the docker # image, runs the server, and hits the root of the server, expecting the # string "Hello World!" to be returned. # # This is supposed to exercise the base image extended in various ways, so # the sample app Dockerfiles should all inherit FROM the base image, which # will be called "ruby-base". class TestBaseImageSampleApps < ::Minitest::Test include Helper TEST_DIR = ::File.dirname __FILE__ APPS_DIR = ::File.join TEST_DIR, "sample_apps" TMP_DIR = ::File.join TEST_DIR, "tmp" unless ::ENV["FASTER_TESTS"] def test_rack_app run_app_test "rack_app", <<~DOCKERFILE FROM ruby-base COPY . /app/ RUN bundle install && rbenv rehash ENTRYPOINT bundle exec rackup -p 8080 -E production config.ru DOCKERFILE end end def test_rails5_app run_app_test "rails5_app", <<~DOCKERFILE FROM ruby-base COPY . /app/ RUN bundle install && rbenv rehash ENV SECRET_KEY_BASE=a12345 ENTRYPOINT bundle exec bin/rails server -p 8080 DOCKERFILE end def test_sinatra1_app run_app_test "sinatra1_app", <<~DOCKERFILE FROM ruby-base COPY . /app/ RUN bundle install && rbenv rehash ENV GOOGLE_CLOUD_PROJECT="" ENTRYPOINT bundle exec ruby myapp.rb -p 8080 DOCKERFILE end def run_app_test app_name, dockerfile puts "**** Testing app for base image: #{app_name}" app_dir = ::File.join APPS_DIR, app_name assert_cmd_succeeds "rm -rf #{TMP_DIR}" assert_cmd_succeeds "cp -r #{app_dir} #{TMP_DIR}" dockerfile_path = ::File.join TMP_DIR, "Dockerfile" ::File.open dockerfile_path, "w" do |file| file.write dockerfile end ::Dir.chdir TMP_DIR do |dir| build_docker_image "", app_name do |image| run_docker_daemon "-p 8080:8080 #{image}" do |container| assert_cmd_output \ "docker exec #{container} curl -s -S http://127.0.0.1:8080", "Hello World!", 10 end end end end end
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/test_ubuntu_image_structure.rb
test/test_ubuntu_image_structure.rb
# Copyright 2017 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. require_relative "helper" require "json" # Runs structure tests defined in test_base_image.json locally. class TestUbuntuImageStructure < ::Minitest::Test include Helper BASE_DIR = ::File.dirname ::File.dirname __FILE__ CONFIG_FILE = ::File.join BASE_DIR, "ruby-#{Helper.os_name}/structure-test.json" CONFIG_DATA = ::JSON.load ::IO.read CONFIG_FILE CONFIG_DATA["commandTests"].each do |test_config| define_method test_config["name"] do command_array = test_config["command"] binary = command_array.shift command = command_array.map{ |a| "'#{a}'" }.join(" ") expectations = test_config["expectedOutput"].map { |e| ::Regexp.new e } assert_docker_output \ "--entrypoint=#{binary} ruby-#{Helper.os_name} #{command}", expectations end end end
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/test_build_tools.rb
test/test_build_tools.rb
# Copyright 2017 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. require_relative "helper" class TestBuildTools < ::Minitest::Test include Helper TEST_DIR = ::File.dirname __FILE__ TMP_DIR = ::File.join TEST_DIR, "tmp" DOCKERFILE = <<~DOCKERFILE_CONTENT FROM ruby-base COPY --from=ruby-build-tools /opt/ /opt/ ENV PATH /opt/bin:/opt/google-cloud-sdk/bin:/opt/nodejs/bin:/opt/yarn/bin:${PATH} DOCKERFILE_CONTENT def test_build_tools assert_cmd_succeeds "rm -rf #{TMP_DIR}" assert_cmd_succeeds "mkdir -p #{TMP_DIR}" dockerfile_path = ::File.join TMP_DIR, "Dockerfile" ::File.open dockerfile_path, "w" do |file| file.write DOCKERFILE end ::Dir.chdir TMP_DIR do build_docker_image "--no-cache" do |image| assert_docker_output "#{image} /opt/nodejs/bin/node --version", /^v\d+\.\d+/ assert_docker_output "#{image} /opt/yarn/bin/yarn --version", /^\d+\.\d+/ assert_docker_output "#{image} /opt/bin/cloud_sql_proxy --version", /Cloud SQL (?:Proxy|Auth proxy)/ assert_docker_output \ "#{image} /opt/google-cloud-sdk/bin/gcloud --version", /Google Cloud SDK/ assert_docker_output \ "#{image} /opt/bin/access_cloud_sql --lenient && echo OK", /OK/ end end end end
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/helper.rb
test/helper.rb
# Copyright 2017 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. require "minitest/autorun" require "minitest/focus" require "minitest/rg" # A set of helpful methods and assertions for running tests. module Helper # The name of the OS currently being used for testing def self.os_name ::ENV["TESTING_OS_NAME"] || "ubuntu20" end # Execute the given command in a shell. def execute_cmd(cmd) puts cmd system cmd end # Assert that the given file contents matches the given string or regex. def assert_file_contents(path, expectations) contents = ::IO.read(path) Array(expectations).each do |expectation| unless expectation === contents flunk "File #{path} did not contain #{expectation.inspect}" end end contents end # Assert that execution of the given command produces a zero exit code. def assert_cmd_succeeds cmd puts cmd system cmd exit_code = $?.exitstatus if exit_code != 0 flunk "Got exit code #{exit_code} when executing \"#{cmd}\"" end end # Assert that execution of the given command produces a nonzero exit code. def assert_cmd_fails cmd puts cmd system cmd exit_code = $?.exitstatus if exit_code == 0 flunk "Got exit code #{exit_code} when executing \"#{cmd}\"" end end # Repeatedly execute the given command (with a pause between tries). # Flunks if it does not succeed and produce output matching the given # expectation (string or regex) within the given timeout in seconds. def assert_cmd_output(cmd, expectation, timeout=0) expectations = Array(expectation) actual = "" exit_code = 0 0.upto(timeout) do |iter| puts cmd actual = `#{cmd}` exit_code = $?.exitstatus return actual if exit_code == 0 && expectations.all? { |e| e === actual } puts("...expected result did not arrive yet (iteration #{iter})...") sleep(1) end yield if block_given? flunk "Expected #{expectation.inspect} but got \"#{actual}\"" + " (exit code #{exit_code}) when executing \"#{cmd}\"" end # Assert that the given docker run command produces the given output. # Automatically cleans up the generated container. def assert_docker_output(args, expectation, container_root="generic", &block) number = "%.08x" % rand(0x100000000) container = "ruby-test-container-#{container_root}-#{number}" begin assert_cmd_output("docker run --name #{container} #{args}", expectation, &block) ensure execute_cmd("docker rm #{container}") end end # Runs a docker container as a daemon. Yields the container name. # Automatically kills and removes the container afterward. def run_docker_daemon(args, container_root="generic") number = "%.08x" % rand(0x100000000) container = "ruby-test-container-#{container_root}-#{number}" begin assert_cmd_succeeds("docker run --name #{container} -d #{args}") yield container ensure execute_cmd("docker kill #{container}") execute_cmd("docker rm #{container}") end end # Build a docker image with the given arguments. Yields the image name. # Automatically cleans up the generated image afterward. def build_docker_image(args="", image_root="generic") number = "%.08x" % rand(0x100000000) image = "ruby-test-image-#{image_root}-#{number}" begin assert_cmd_succeeds("docker build -t #{image} #{args} .") yield image ensure execute_cmd("docker rmi #{image}") end end end
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/test_base_ruby_versions.rb
test/test_base_ruby_versions.rb
# Copyright 2017 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. require_relative "helper" # Tests of the supported ruby versions. Ensures that all supported ruby # versions can be installed and will execute. class TestRubyVersions < ::Minitest::Test PREBUILT_RUBY_VERSIONS = ::ENV["PREBUILT_RUBY_VERSIONS"].to_s.split(",") PRIMARY_RUBY_VERSIONS = ::ENV["PRIMARY_RUBY_VERSIONS"].to_s.split(",") PREBUILT_RUBY_IMAGE_BASE = ::ENV["PREBUILT_RUBY_IMAGE_BASE"] PREBUILT_RUBY_IMAGE_TAG = ::ENV["PREBUILT_RUBY_IMAGE_TAG"] BUNDLER1_VERSION = ::ENV["BUNDLER1_VERSION"] BUNDLER2_VERSION = ::ENV["BUNDLER2_VERSION"] if ::ENV["FASTER_TESTS"] || ::ENV["USE_LOCAL_PREBUILT"] VERSIONS = PRIMARY_RUBY_VERSIONS & PREBUILT_RUBY_VERSIONS else # Out of the prebuilt list, choose all patches of current versions (i.e. # whose minor version is reflected in the primaries) but only the latest # patch of all other versions. Also add 2.0.0-p648 to test patchlevel # notation and installation from source. VERSIONS = PREBUILT_RUBY_VERSIONS.map do |version| if version =~ /^(\d+\.\d+)/ minor = Regexp.last_match[1] next version if PRIMARY_RUBY_VERSIONS.any? { |v| v.start_with? minor } PREBUILT_RUBY_VERSIONS.map do |v| if v.start_with? minor Gem::Version.new v end end.compact.sort.last.to_s end end.compact.uniq + ["2.0.0-p648"] end DOCKERFILE_SELFBUILT = <<~DOCKERFILE_CONTENT FROM $OS_IMAGE ARG ruby_version COPY --from=ruby-build-tools /opt/gems/ /opt/gems/ RUN rbenv install -s ${ruby_version} \ && rbenv global ${ruby_version} \ && rbenv rehash \ && (gem install /opt/gems/bundler-#{BUNDLER1_VERSION}.gem ; \ gem install /opt/gems/bundler-#{BUNDLER2_VERSION}.gem ; \ rbenv rehash) CMD ruby --version DOCKERFILE_CONTENT DOCKERFILE_PREBUILT = <<~DOCKERFILE_CONTENT FROM ruby-#{Helper.os_name} ARG ruby_version COPY --from=ruby-build-tools /opt/gems/ /opt/gems/ COPY --from=$PREBUILT_RUBY_IMAGE \ /opt/rbenv/versions/${ruby_version} \ /opt/rbenv/versions/${ruby_version} RUN rbenv global ${ruby_version} \ && rbenv rehash \ && (gem install /opt/gems/bundler-#{BUNDLER1_VERSION}.gem ; \ gem install /opt/gems/bundler-#{BUNDLER2_VERSION}.gem ; \ rbenv rehash) CMD ruby --version DOCKERFILE_CONTENT include Helper TMP_DIR = ::File.join __dir__, "tmp" VERSIONS.each do |version| mangled_version = version.gsub(".", "_").gsub("-", "_") mangled_version = "default_version" if mangled_version == "" define_method("test_#{mangled_version}") do run_version_test(version, mangled_version) end end def run_version_test(version, mangled_version) puts("**** Testing ruby version: #{version}") version_output = version.gsub("-", "").gsub(".", "\\.") assert_cmd_succeeds "rm -rf #{TMP_DIR}" assert_cmd_succeeds "mkdir -p #{TMP_DIR}" dockerfile_path = ::File.join TMP_DIR, "Dockerfile" ::File.open dockerfile_path, "w" do |file| if PREBUILT_RUBY_VERSIONS.include? version prebuilt_image = "#{PREBUILT_RUBY_IMAGE_BASE}#{version}:#{PREBUILT_RUBY_IMAGE_TAG}" file.write DOCKERFILE_PREBUILT.sub("$PREBUILT_RUBY_IMAGE", prebuilt_image) else os_image = "ruby-#{Helper.os_name}" os_image = "#{os_image}-ssl10" if version < "2.4" file.write DOCKERFILE_SELFBUILT.sub("$OS_IMAGE", os_image) end end ::Dir.chdir TMP_DIR do |dir| build_docker_image( "--build-arg ruby_version=#{version}", mangled_version) do |image| assert_docker_output(image, /ruby\s#{version_output}/, "ruby-#{mangled_version}") assert_docker_output("#{image} bundle version", /Bundler version/, "bundler-#{mangled_version}") end end end end
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/app_engine_exec_wrapper/no_cloudsql/run.rb
test/app_engine_exec_wrapper/no_cloudsql/run.rb
# Copyright 2017 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. abort "VAR1 incorrect" unless ::ENV["VAR1"] == "value1" abort "VAR2 incorrect" unless ::ENV["VAR2"] == "value2" entries = ::Dir.entries("/cloudsql") - [".", ".."] abort "cloudsql dir expected to be empty" unless entries.empty? puts "All good!"
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/app_engine_exec_wrapper/harness/fake_cloud_sql_proxy.rb
test/app_engine_exec_wrapper/harness/fake_cloud_sql_proxy.rb
#!/usr/bin/env ruby # Copyright 2017 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. class FakeCloudSqlProxy def initialize args @dir = nil @instances = [] args.each do |arg| case arg when /^-dir=(.*)$/ @dir = $1 when /^-instances=(.*)$/ @instances += $1.split "," else abort "Unknown arg: #{arg}" end end end def run puts "Starting fake_cloud_sql_proxy" abort "Dir not given" unless @dir abort "No instances" if @instances.empty? sleep(1.0 + 4.0 * rand) if @dir @instances.each do |instance| system "touch #{@dir}/#{instance}" end end puts "Ready for new connections" end end FakeCloudSqlProxy.new(ARGV).run
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/app_engine_exec_wrapper/simple/run.rb
test/app_engine_exec_wrapper/simple/run.rb
# Copyright 2017 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. abort "VAR1 incorrect" unless ::ENV["VAR1"] == "value1" abort "VAR2 incorrect" unless ::ENV["VAR2"] == "value2" abort "Sql socket not found" unless ::File.exist? "/cloudsql/sql:1:2:3" puts "All good!"
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/app_config/rails/config/application.rb
test/app_config/rails/config/application.rb
# Hello
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/app_config/gemfile-rack/gems.rb
test/app_config/gemfile-rack/gems.rb
source 'https://rubygems.org' gem 'rack', '~> 2.0'
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/app_config/gemfile-ruby/gems.rb
test/app_config/gemfile-ruby/gems.rb
source 'https://rubygems.org' ruby "2.0.98"
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/sinatra1_app/myapp.rb
test/sample_apps/sinatra1_app/myapp.rb
require 'sinatra' set :environment, :production set :bind, "0.0.0.0" set :port, 8080 set :show_exceptions, true get '/' do "Hello World!" end
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails5_app/app/jobs/application_job.rb
test/sample_apps/rails5_app/app/jobs/application_job.rb
class ApplicationJob < ActiveJob::Base end
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails5_app/app/helpers/application_helper.rb
test/sample_apps/rails5_app/app/helpers/application_helper.rb
module ApplicationHelper end
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails5_app/app/controllers/home_controller.rb
test/sample_apps/rails5_app/app/controllers/home_controller.rb
class HomeController < ApplicationController def index unless Rails.env == "production" raise "Wrong Rails environment: #{Rails.env}" end render :text => "Hello World!" end end
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails5_app/app/controllers/application_controller.rb
test/sample_apps/rails5_app/app/controllers/application_controller.rb
class ApplicationController < ActionController::Base protect_from_forgery with: :exception end
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails5_app/app/models/application_record.rb
test/sample_apps/rails5_app/app/models/application_record.rb
class ApplicationRecord < ActiveRecord::Base self.abstract_class = true end
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails5_app/app/mailers/application_mailer.rb
test/sample_apps/rails5_app/app/mailers/application_mailer.rb
class ApplicationMailer < ActionMailer::Base default from: 'from@example.com' layout 'mailer' end
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails5_app/app/channels/application_cable/channel.rb
test/sample_apps/rails5_app/app/channels/application_cable/channel.rb
module ApplicationCable class Channel < ActionCable::Channel::Base end end
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails5_app/app/channels/application_cable/connection.rb
test/sample_apps/rails5_app/app/channels/application_cable/connection.rb
module ApplicationCable class Connection < ActionCable::Connection::Base end end
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails5_app/db/seeds.rb
test/sample_apps/rails5_app/db/seeds.rb
# This file should contain all the record creation needed to seed the database with its default values. # The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup). # # Examples: # # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) # Character.create(name: 'Luke', movie: movies.first)
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails5_app/test/test_helper.rb
test/sample_apps/rails5_app/test/test_helper.rb
ENV['RAILS_ENV'] ||= 'test' require File.expand_path('../../config/environment', __FILE__) require 'rails/test_help' class ActiveSupport::TestCase # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. fixtures :all # Add more helper methods to be used by all tests here... end
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails5_app/config/application.rb
test/sample_apps/rails5_app/config/application.rb
require_relative 'boot' require 'rails/all' # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. Bundler.require(*Rails.groups) module Rails5App class Application < Rails::Application # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. end end
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails5_app/config/environment.rb
test/sample_apps/rails5_app/config/environment.rb
# Load the Rails application. require_relative 'application' # Initialize the Rails application. Rails.application.initialize!
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails5_app/config/puma.rb
test/sample_apps/rails5_app/config/puma.rb
# Puma can serve each request in a thread from an internal thread pool. # The `threads` method setting takes two numbers a minimum and maximum. # Any libraries that use thread pools should be configured to match # the maximum value specified for Puma. Default is set to 5 threads for minimum # and maximum, this matches the default thread size of Active Record. # threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i threads threads_count, threads_count # Specifies the `port` that Puma will listen on to receive requests, default is 3000. # port ENV.fetch("PORT") { 3000 } # Specifies the `environment` that Puma will run in. # environment ENV.fetch("RAILS_ENV") { "development" } # Specifies the number of `workers` to boot in clustered mode. # Workers are forked webserver processes. If using threads and workers together # the concurrency of the application would be max `threads` * `workers`. # Workers do not work on JRuby or Windows (both of which do not support # processes). # # workers ENV.fetch("WEB_CONCURRENCY") { 2 } # Use the `preload_app!` method when specifying a `workers` number. # This directive tells Puma to first boot the application and load code # before forking the application. This takes advantage of Copy On Write # process behavior so workers use less memory. If you use this option # you need to make sure to reconnect any threads in the `on_worker_boot` # block. # # preload_app! # The code in the `on_worker_boot` will be called if you are using # clustered mode by specifying a number of `workers`. After each worker # process is booted this block will be run, if you are using `preload_app!` # option you will want to use this block to reconnect to any threads # or connections that may have been created at application boot, Ruby # cannot share connections between processes. # # on_worker_boot do # ActiveRecord::Base.establish_connection if defined?(ActiveRecord) # end # Allow puma to be restarted by `rails restart` command. plugin :tmp_restart
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails5_app/config/routes.rb
test/sample_apps/rails5_app/config/routes.rb
Rails.application.routes.draw do root 'home#index' end
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails5_app/config/spring.rb
test/sample_apps/rails5_app/config/spring.rb
%w( .ruby-version .rbenv-vars tmp/restart.txt tmp/caching-dev.txt ).each { |path| Spring.watch(path) }
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails5_app/config/boot.rb
test/sample_apps/rails5_app/config/boot.rb
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) require 'bundler/setup' # Set up gems listed in the Gemfile.
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails5_app/config/initializers/filter_parameter_logging.rb
test/sample_apps/rails5_app/config/initializers/filter_parameter_logging.rb
# Be sure to restart your server when you modify this file. # Configure sensitive parameters which will be filtered from the log file. Rails.application.config.filter_parameters += [:password]
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails5_app/config/initializers/application_controller_renderer.rb
test/sample_apps/rails5_app/config/initializers/application_controller_renderer.rb
# Be sure to restart your server when you modify this file. # ApplicationController.renderer.defaults.merge!( # http_host: 'example.org', # https: false # )
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails5_app/config/initializers/session_store.rb
test/sample_apps/rails5_app/config/initializers/session_store.rb
# Be sure to restart your server when you modify this file. Rails.application.config.session_store :cookie_store, key: '_rails5_app_session'
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails5_app/config/initializers/new_framework_defaults.rb
test/sample_apps/rails5_app/config/initializers/new_framework_defaults.rb
# Be sure to restart your server when you modify this file. # # This file contains migration options to ease your Rails 5.0 upgrade. # # Read the Guide for Upgrading Ruby on Rails for more info on each option. # Enable per-form CSRF tokens. Previous versions had false. Rails.application.config.action_controller.per_form_csrf_tokens = true # Enable origin-checking CSRF mitigation. Previous versions had false. Rails.application.config.action_controller.forgery_protection_origin_check = true # Make Ruby 2.4 preserve the timezone of the receiver when calling `to_time`. # Previous versions had false. ActiveSupport.to_time_preserves_timezone = true # Require `belongs_to` associations by default. Previous versions had false. Rails.application.config.active_record.belongs_to_required_by_default = true # Do not halt callback chains when a callback returns false. Previous versions had true. ActiveSupport.halt_callback_chains_on_return_false = false # Configure SSL options to enable HSTS with subdomains. Previous versions had false. Rails.application.config.ssl_options = { hsts: { subdomains: true } }
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails5_app/config/initializers/wrap_parameters.rb
test/sample_apps/rails5_app/config/initializers/wrap_parameters.rb
# Be sure to restart your server when you modify this file. # This file contains settings for ActionController::ParamsWrapper which # is enabled by default. # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. ActiveSupport.on_load(:action_controller) do wrap_parameters format: [:json] end # To enable root element in JSON for ActiveRecord objects. # ActiveSupport.on_load(:active_record) do # self.include_root_in_json = true # end
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails5_app/config/initializers/inflections.rb
test/sample_apps/rails5_app/config/initializers/inflections.rb
# Be sure to restart your server when you modify this file. # Add new inflection rules using the following format. Inflections # are locale specific, and you may define rules for as many different # locales as you wish. All of these examples are active by default: # ActiveSupport::Inflector.inflections(:en) do |inflect| # inflect.plural /^(ox)$/i, '\1en' # inflect.singular /^(ox)en/i, '\1' # inflect.irregular 'person', 'people' # inflect.uncountable %w( fish sheep ) # end # These inflection rules are supported but not enabled by default: # ActiveSupport::Inflector.inflections(:en) do |inflect| # inflect.acronym 'RESTful' # end
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails5_app/config/initializers/cookies_serializer.rb
test/sample_apps/rails5_app/config/initializers/cookies_serializer.rb
# Be sure to restart your server when you modify this file. # Specify a serializer for the signed and encrypted cookie jars. # Valid options are :json, :marshal, and :hybrid. Rails.application.config.action_dispatch.cookies_serializer = :json
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails5_app/config/initializers/assets.rb
test/sample_apps/rails5_app/config/initializers/assets.rb
# Be sure to restart your server when you modify this file. # Version of your assets, change this if you want to expire all your assets. Rails.application.config.assets.version = '1.0' # Add additional assets to the asset load path # Rails.application.config.assets.paths << Emoji.images_path # Precompile additional assets. # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. # Rails.application.config.assets.precompile += %w( search.js )
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails5_app/config/initializers/backtrace_silencers.rb
test/sample_apps/rails5_app/config/initializers/backtrace_silencers.rb
# Be sure to restart your server when you modify this file. # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. # Rails.backtrace_cleaner.remove_silencers!
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails5_app/config/initializers/mime_types.rb
test/sample_apps/rails5_app/config/initializers/mime_types.rb
# Be sure to restart your server when you modify this file. # Add new mime types for use in respond_to blocks: # Mime::Type.register "text/richtext", :rtf
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails5_app/config/environments/test.rb
test/sample_apps/rails5_app/config/environments/test.rb
Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # The test environment is used exclusively to run your application's # test suite. You never need to work with it otherwise. Remember that # your test database is "scratch space" for the test suite and is wiped # and recreated between test runs. Don't rely on the data there! config.cache_classes = true # Do not eager load code on boot. This avoids loading your whole application # just for the purpose of running a single test. If you are using a tool that # preloads Rails for running tests, you may have to set it to true. config.eager_load = false # Configure public file server for tests with Cache-Control for performance. config.public_file_server.enabled = true config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=3600' } # Show full error reports and disable caching. config.consider_all_requests_local = true config.action_controller.perform_caching = false # Raise exceptions instead of rendering exception templates. config.action_dispatch.show_exceptions = false # Disable request forgery protection in test environment. config.action_controller.allow_forgery_protection = false config.action_mailer.perform_caching = false # Tell Action Mailer not to deliver emails to the real world. # The :test delivery method accumulates sent emails in the # ActionMailer::Base.deliveries array. config.action_mailer.delivery_method = :test # Print deprecation notices to the stderr. config.active_support.deprecation = :stderr # Raises error for missing translations # config.action_view.raise_on_missing_translations = true end
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails5_app/config/environments/development.rb
test/sample_apps/rails5_app/config/environments/development.rb
Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don't have to restart the web server when you make code changes. config.cache_classes = false # Do not eager load code on boot. config.eager_load = false # Show full error reports. config.consider_all_requests_local = true # Enable/disable caching. By default caching is disabled. if Rails.root.join('tmp/caching-dev.txt').exist? config.action_controller.perform_caching = true config.cache_store = :memory_store config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=172800' } else config.action_controller.perform_caching = false config.cache_store = :null_store end # Don't care if the mailer can't send. config.action_mailer.raise_delivery_errors = false config.action_mailer.perform_caching = false # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log # Raise an error on page load if there are pending migrations. config.active_record.migration_error = :page_load # Debug mode disables concatenation and preprocessing of assets. # This option may cause significant delays in view rendering with a large # number of complex assets. config.assets.debug = true # Suppress logger output for asset requests. config.assets.quiet = true # Raises error for missing translations # config.action_view.raise_on_missing_translations = true # Use an evented file watcher to asynchronously detect changes in source code, # routes, locales, etc. This feature depends on the listen gem. config.file_watcher = ActiveSupport::EventedFileUpdateChecker end
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails5_app/config/environments/production.rb
test/sample_apps/rails5_app/config/environments/production.rb
Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # Code is not reloaded between requests. config.cache_classes = true # Eager load code on boot. This eager loads most of Rails and # your application in memory, allowing both threaded web servers # and those relying on copy on write to perform better. # Rake tasks automatically ignore this option for performance. config.eager_load = true # Full error reports are disabled and caching is turned on. config.consider_all_requests_local = false config.action_controller.perform_caching = true # Disable serving static files from the `/public` folder by default since # Apache or NGINX already handles this. config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? # Compress JavaScripts and CSS. config.assets.js_compressor = :uglifier # config.assets.css_compressor = :sass # Do not fallback to assets pipeline if a precompiled asset is missed. config.assets.compile = false # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb # Enable serving of images, stylesheets, and JavaScripts from an asset server. # config.action_controller.asset_host = 'http://assets.example.com' # Specifies the header that your server uses for sending files. # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX # Mount Action Cable outside main process or domain # config.action_cable.mount_path = nil # config.action_cable.url = 'wss://example.com/cable' # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. # config.force_ssl = true # Use the lowest log level to ensure availability of diagnostic information # when problems arise. config.log_level = :debug # Prepend all log lines with the following tags. config.log_tags = [ :request_id ] # Use a different cache store in production. # config.cache_store = :mem_cache_store # Use a real queuing backend for Active Job (and separate queues per environment) # config.active_job.queue_adapter = :resque # config.active_job.queue_name_prefix = "rails5_app_#{Rails.env}" config.action_mailer.perform_caching = false # Ignore bad email addresses and do not raise email delivery errors. # Set this to true and configure the email server for immediate delivery to raise delivery errors. # config.action_mailer.raise_delivery_errors = false # Enable locale fallbacks for I18n (makes lookups for any locale fall back to # the I18n.default_locale when a translation cannot be found). config.i18n.fallbacks = true # Send deprecation notices to registered listeners. config.active_support.deprecation = :notify # Use default logging formatter so that PID and timestamp are not suppressed. config.log_formatter = ::Logger::Formatter.new # Use a different logger for distributed setups. # require 'syslog/logger' # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') if ENV["RAILS_LOG_TO_STDOUT"].present? logger = ActiveSupport::Logger.new(STDOUT) logger.formatter = config.log_formatter config.logger = ActiveSupport::TaggedLogging.new(logger) end # Do not dump schema after migrations. config.active_record.dump_schema_after_migration = false end
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails4_app/app/helpers/application_helper.rb
test/sample_apps/rails4_app/app/helpers/application_helper.rb
module ApplicationHelper end
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails4_app/app/controllers/home_controller.rb
test/sample_apps/rails4_app/app/controllers/home_controller.rb
class HomeController < ApplicationController def index unless Rails.env == "production" raise "Wrong Rails environment: #{Rails.env}" end render :text => "Hello World!" end end
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails4_app/app/controllers/application_controller.rb
test/sample_apps/rails4_app/app/controllers/application_controller.rb
class ApplicationController < ActionController::Base # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :null_session instead. protect_from_forgery with: :exception end
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails4_app/db/seeds.rb
test/sample_apps/rails4_app/db/seeds.rb
# This file should contain all the record creation needed to seed the database with its default values. # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). # # Examples: # # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) # Mayor.create(name: 'Emanuel', city: cities.first)
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails4_app/config/application.rb
test/sample_apps/rails4_app/config/application.rb
require File.expand_path('../boot', __FILE__) require "rails" # Pick the frameworks you want: require "active_model/railtie" require "active_job/railtie" # require "active_record/railtie" require "action_controller/railtie" require "action_mailer/railtie" require "action_view/railtie" require "sprockets/railtie" # require "rails/test_unit/railtie" # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. Bundler.require(*Rails.groups) module Rails4App class Application < Rails::Application # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. # config.time_zone = 'Central Time (US & Canada)' # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] # config.i18n.default_locale = :de end end
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails4_app/config/environment.rb
test/sample_apps/rails4_app/config/environment.rb
# Load the Rails application. require File.expand_path('../application', __FILE__) # Initialize the Rails application. Rails.application.initialize!
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails4_app/config/routes.rb
test/sample_apps/rails4_app/config/routes.rb
Rails.application.routes.draw do root 'home#index' end
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails4_app/config/boot.rb
test/sample_apps/rails4_app/config/boot.rb
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) require 'bundler/setup' # Set up gems listed in the Gemfile.
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails4_app/config/initializers/filter_parameter_logging.rb
test/sample_apps/rails4_app/config/initializers/filter_parameter_logging.rb
# Be sure to restart your server when you modify this file. # Configure sensitive parameters which will be filtered from the log file. Rails.application.config.filter_parameters += [:password]
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails4_app/config/initializers/session_store.rb
test/sample_apps/rails4_app/config/initializers/session_store.rb
# Be sure to restart your server when you modify this file. Rails.application.config.session_store :cookie_store, key: '_rails4_app_session'
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails4_app/config/initializers/to_time_preserves_timezone.rb
test/sample_apps/rails4_app/config/initializers/to_time_preserves_timezone.rb
# Be sure to restart your server when you modify this file. # Preserve the timezone of the receiver when calling to `to_time`. # Ruby 2.4 will change the behavior of `to_time` to preserve the timezone # when converting to an instance of `Time` instead of the previous behavior # of converting to the local system timezone. # # Rails 5.0 introduced this config option so that apps made with earlier # versions of Rails are not affected when upgrading. ActiveSupport.to_time_preserves_timezone = true
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails4_app/config/initializers/wrap_parameters.rb
test/sample_apps/rails4_app/config/initializers/wrap_parameters.rb
# Be sure to restart your server when you modify this file. # This file contains settings for ActionController::ParamsWrapper which # is enabled by default. # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. ActiveSupport.on_load(:action_controller) do wrap_parameters format: [:json] if respond_to?(:wrap_parameters) end
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails4_app/config/initializers/inflections.rb
test/sample_apps/rails4_app/config/initializers/inflections.rb
# Be sure to restart your server when you modify this file. # Add new inflection rules using the following format. Inflections # are locale specific, and you may define rules for as many different # locales as you wish. All of these examples are active by default: # ActiveSupport::Inflector.inflections(:en) do |inflect| # inflect.plural /^(ox)$/i, '\1en' # inflect.singular /^(ox)en/i, '\1' # inflect.irregular 'person', 'people' # inflect.uncountable %w( fish sheep ) # end # These inflection rules are supported but not enabled by default: # ActiveSupport::Inflector.inflections(:en) do |inflect| # inflect.acronym 'RESTful' # end
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails4_app/config/initializers/cookies_serializer.rb
test/sample_apps/rails4_app/config/initializers/cookies_serializer.rb
# Be sure to restart your server when you modify this file. Rails.application.config.action_dispatch.cookies_serializer = :json
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails4_app/config/initializers/assets.rb
test/sample_apps/rails4_app/config/initializers/assets.rb
# Be sure to restart your server when you modify this file. # Version of your assets, change this if you want to expire all your assets. Rails.application.config.assets.version = '1.0' # Add additional assets to the asset load path # Rails.application.config.assets.paths << Emoji.images_path # Precompile additional assets. # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. # Rails.application.config.assets.precompile += %w( search.js )
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails4_app/config/initializers/backtrace_silencers.rb
test/sample_apps/rails4_app/config/initializers/backtrace_silencers.rb
# Be sure to restart your server when you modify this file. # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. # Rails.backtrace_cleaner.remove_silencers!
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails4_app/config/initializers/mime_types.rb
test/sample_apps/rails4_app/config/initializers/mime_types.rb
# Be sure to restart your server when you modify this file. # Add new mime types for use in respond_to blocks: # Mime::Type.register "text/richtext", :rtf
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails4_app/config/environments/test.rb
test/sample_apps/rails4_app/config/environments/test.rb
Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # The test environment is used exclusively to run your application's # test suite. You never need to work with it otherwise. Remember that # your test database is "scratch space" for the test suite and is wiped # and recreated between test runs. Don't rely on the data there! config.cache_classes = true # Do not eager load code on boot. This avoids loading your whole application # just for the purpose of running a single test. If you are using a tool that # preloads Rails for running tests, you may have to set it to true. config.eager_load = false # Configure static file server for tests with Cache-Control for performance. config.serve_static_files = true config.static_cache_control = 'public, max-age=3600' # Show full error reports and disable caching. config.consider_all_requests_local = true config.action_controller.perform_caching = false # Raise exceptions instead of rendering exception templates. config.action_dispatch.show_exceptions = false # Disable request forgery protection in test environment. config.action_controller.allow_forgery_protection = false # Tell Action Mailer not to deliver emails to the real world. # The :test delivery method accumulates sent emails in the # ActionMailer::Base.deliveries array. config.action_mailer.delivery_method = :test # Randomize the order test cases are executed. config.active_support.test_order = :random # Print deprecation notices to the stderr. config.active_support.deprecation = :stderr # Raises error for missing translations # config.action_view.raise_on_missing_translations = true end
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails4_app/config/environments/development.rb
test/sample_apps/rails4_app/config/environments/development.rb
Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don't have to restart the web server when you make code changes. config.cache_classes = false # Do not eager load code on boot. config.eager_load = false # Show full error reports and disable caching. config.consider_all_requests_local = true config.action_controller.perform_caching = false # Don't care if the mailer can't send. config.action_mailer.raise_delivery_errors = false # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log # Debug mode disables concatenation and preprocessing of assets. # This option may cause significant delays in view rendering with a large # number of complex assets. config.assets.debug = true # Asset digests allow you to set far-future HTTP expiration dates on all assets, # yet still be able to expire them through the digest params. config.assets.digest = true # Adds additional error checking when serving assets at runtime. # Checks for improperly declared sprockets dependencies. # Raises helpful error messages. config.assets.raise_runtime_errors = true # Raises error for missing translations # config.action_view.raise_on_missing_translations = true end
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails4_app/config/environments/production.rb
test/sample_apps/rails4_app/config/environments/production.rb
Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # Code is not reloaded between requests. config.cache_classes = true # Eager load code on boot. This eager loads most of Rails and # your application in memory, allowing both threaded web servers # and those relying on copy on write to perform better. # Rake tasks automatically ignore this option for performance. config.eager_load = true # Full error reports are disabled and caching is turned on. config.consider_all_requests_local = false config.action_controller.perform_caching = true # Enable Rack::Cache to put a simple HTTP cache in front of your application # Add `rack-cache` to your Gemfile before enabling this. # For large-scale production use, consider using a caching reverse proxy like # NGINX, varnish or squid. # config.action_dispatch.rack_cache = true # Disable serving static files from the `/public` folder by default since # Apache or NGINX already handles this. config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present? # Compress JavaScripts and CSS. config.assets.js_compressor = :uglifier # config.assets.css_compressor = :sass # Do not fallback to assets pipeline if a precompiled asset is missed. config.assets.compile = false # Asset digests allow you to set far-future HTTP expiration dates on all assets, # yet still be able to expire them through the digest params. config.assets.digest = true # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb # Specifies the header that your server uses for sending files. # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. # config.force_ssl = true # Use the lowest log level to ensure availability of diagnostic information # when problems arise. config.log_level = :debug # Prepend all log lines with the following tags. # config.log_tags = [ :subdomain, :uuid ] # Use a different logger for distributed setups. # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) # Use a different cache store in production. # config.cache_store = :mem_cache_store # Enable serving of images, stylesheets, and JavaScripts from an asset server. # config.action_controller.asset_host = 'http://assets.example.com' # Ignore bad email addresses and do not raise email delivery errors. # Set this to true and configure the email server for immediate delivery to raise delivery errors. # config.action_mailer.raise_delivery_errors = false # Enable locale fallbacks for I18n (makes lookups for any locale fall back to # the I18n.default_locale when a translation cannot be found). config.i18n.fallbacks = true # Send deprecation notices to registered listeners. config.active_support.deprecation = :notify # Use default logging formatter so that PID and timestamp are not suppressed. config.log_formatter = ::Logger::Formatter.new end
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/.toys/.toys.rb
.toys/.toys.rb
# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. mixin "runtime-params" do on_include do File.readlines("#{context_directory}/runtime-config.env").each do |line| if line =~ /^([A-Z][A-Z0-9_]*)=(.*)$/ match = Regexp.last_match name_str = match[1] name_sym = name_str.downcase.to_sym value = match[2] static name_sym, value ENV[name_str] = value end end all_versions = [] default_version = nil File.readlines("#{context_directory}/ruby-pipeline/ruby-latest.yaml").each do |line| all_versions << Regexp.last_match[1] if line =~ /([\d\.]+)=gcr\.io/ default_version = Regexp.last_match[1] if line =~ /--default-ruby-version=([\d\.]+)/ end all_versions = all_versions.join "," static :all_prebuilt_ruby_versions, all_versions static :default_ruby_version, default_version ENV["ALL_PREBUILT_RUBY_VERSIONS"] = all_versions ENV["DEFAULT_RUBY_VERSION"] = default_version end end tool "build" do desc "Build all images locally" flag :project, "--project=PROJECT", default: "gcp-runtimes" flag :os_name, "--os-name=NAME", default: "ubuntu20" flag :use_local_prebuilt include :exec, e: true include "runtime-params" def run cmd = [ "build", "os-image", "--os-name", os_name, "--bundler2-version", bundler2_version, "--nodejs-version", nodejs_version, "--ssl10-version", ssl10_version ] exec_tool cmd exec_tool cmd + ["--use-ssl10-dev"] if use_local_prebuilt cmd = ["build", "prebuilt", "--os-name", os_name] + primary_ruby_versions.split(",") exec_tool cmd end cmd = [ "build", "basic", "--use-prebuilt-binary", "--os-name", os_name, "--ruby-version", basic_ruby_version, "--bundler1-version", bundler1_version, "--bundler2-version", bundler2_version ] cmd << "--use-local-prebuilt" if use_local_prebuilt exec_tool cmd exec_tool [ "build", "build-tools", "--gcloud-version", gcloud_version, "--bundler1-version", bundler1_version, "--bundler2-version", bundler2_version ] cmd = [ "build", "generate-dockerfile", "--os-name", os_name, "--default-ruby-version", default_ruby_version, "--bundler1-version", bundler1_version, "--bundler2-version", bundler2_version ] if use_local_prebuilt primary_ruby_versions.split(",").each do |version| cmd << "--prebuilt-image=#{version}=ruby-prebuilt-#{version}:latest" end else all_prebuilt_ruby_versions.split(",").each do |version| cmd << "--prebuilt-image=#{version}=gcr.io/#{project}/ruby/#{os_name}/prebuilt/ruby-#{version}:latest" end end exec_tool cmd exec_tool ["build", "app-engine-exec-wrapper"] exec_tool ["build", "app-engine-exec-harness"] end end tool "test" do desc "Run all tests" flag :project, "--project=PROJECT", default: "gcp-runtimes" flag :os_name, "--os-name=NAME", default: "ubuntu20" flag :use_local_prebuilt flag :faster remaining_args :tests include :exec, e: true include "runtime-params" def run env = { "PREBUILT_RUBY_IMAGE_TAG" => "latest", "PREBUILT_RUBY_VERSIONS" => all_prebuilt_ruby_versions, "PRIMARY_RUBY_VERSIONS" => primary_ruby_versions, "BUNDLER1_VERSION" => bundler1_version, "BUNDLER2_VERSION" => bundler2_version, "TESTING_OS_NAME" => os_name } env["USE_LOCAL_PREBUILT"] = "true" if use_local_prebuilt env["FASTER_TESTS"] = "true" if faster env["PREBUILT_RUBY_IMAGE_BASE"] = use_local_prebuilt ? "ruby-prebuilt-" : "gcr.io/#{project}/ruby/#{os_name}/prebuilt/ruby-" cmd = ["_test"] + tests exec_tool cmd, env: env end end expand :minitest, name: "_test", files: ["test/test*.rb"]
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false
GoogleCloudPlatform/ruby-docker
https://github.com/GoogleCloudPlatform/ruby-docker/blob/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/.toys/build.rb
.toys/build.rb
# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. tool "os-image" do desc "Build local docker image the OS" flag :os_name, "--os-name=NAME", default: "ubuntu20" flag :use_ssl10_dev all_required do flag :bundler2_version, "--bundler2-version=VERSION" flag :nodejs_version, "--nodejs-version=VERSION" flag :ssl10_version, "--ssl10-version=VERSION" end include :exec, e: true def run sed_script = use_ssl10_dev ? "s|@@IF_SSL10_DEV@@||g" : "s|@@IF_SSL10_DEV@@|#|g" image_name = use_ssl10_dev ? "ruby-#{os_name}-ssl10" : "ruby-#{os_name}" exec ["sed", "-e", sed_script, "ruby-#{os_name}/Dockerfile.in"], out: [:file, "ruby-#{os_name}/Dockerfile"] exec ["docker", "build", "--pull", "--no-cache", "-t", "#{image_name}", "--build-arg", "bundler_version=#{bundler2_version}", "--build-arg", "nodejs_version=#{nodejs_version}", "--build-arg", "ssl10_version=#{ssl10_version}", "ruby-#{os_name}"] end end tool "prebuilt" do desc "Build prebuilt binary images" flag :os_name, "--os-name=NAME", default: "ubuntu20" remaining_args :ruby_versions include :exec, e: true def run if ruby_versions.empty? logger.error "At least one ruby version required" exit 1 end ruby_versions.each do |version| os_image = version < "2.4" ? "ruby-#{os_name}-ssl10" : "ruby-#{os_name}" exec ["sed", "-e", "s|@@RUBY_OS_IMAGE@@|#{os_image}|g", "ruby-prebuilt/Dockerfile.in"], out: [:file, "ruby-prebuilt/Dockerfile"] exec ["docker", "build", "--no-cache", "-t", "ruby-prebuilt-#{version}", "--build-arg", "ruby_version=#{version}", "ruby-prebuilt"] end end end tool "basic" do desc "Build simple base image using the default ruby" flag :project, "--project=PROJECT", default: "gcp-runtimes" flag :os_name, "--os-name=NAME", default: "ubuntu20" flag :use_prebuilt_binary flag :use_local_prebuilt all_required do flag :ruby_version, "--ruby-version=VERSION" flag :bundler1_version, "--bundler1-version=VERSION" flag :bundler2_version, "--bundler2-version=VERSION" end include :exec, e: true def run image_type = use_prebuilt_binary ? "prebuilt" : "default" prebuilt_base = use_local_prebuilt ? "ruby-prebuilt-" : "gcr.io/#{project}/ruby/#{os_name}/prebuilt/ruby-" sed_script = "s|@@RUBY_OS_IMAGE@@|ruby-#{os_name}|g;"\ " s|@@PREBUILT_RUBY_IMAGE@@|#{prebuilt_base}#{ruby_version}|g" exec ["sed", "-e", sed_script, "ruby-base/Dockerfile-#{image_type}.in"], out: [:file, "ruby-base/Dockerfile"] exec ["docker", "build", "--no-cache", "-t", "ruby-base", "--build-arg", "ruby_version=#{ruby_version}", "--build-arg", "bundler1_version=#{bundler1_version}", "--build-arg", "bundler2_version=#{bundler2_version}", "ruby-base"] end end tool "build-tools" do desc "Build the build-tools image" all_required do flag :gcloud_version, "--gcloud-version=VERSION" flag :bundler1_version, "--bundler1-version=VERSION" flag :bundler2_version, "--bundler2-version=VERSION" end include :exec, e: true def run exec ["docker", "build", "--no-cache", "-t", "ruby-build-tools", "--build-arg", "gcloud_version=#{gcloud_version}", "--build-arg", "bundler1_version=#{bundler1_version}", "--build-arg", "bundler2_version=#{bundler2_version}", "ruby-build-tools"] end end tool "generate-dockerfile" do desc "Build the generate-dockerfile image" flag :os_name, "--os-name=NAME", default: "ubuntu20" flag :prebuilt_image, "--prebuilt-image=SPEC", handler: :push, default: [] all_required do flag :default_ruby_version, "--default-ruby-version=VERSION" flag :bundler1_version, "--bundler1-version=VERSION" flag :bundler2_version, "--bundler2-version=VERSION" end include :exec, e: true def run prebuilt_ruby_images = prebuilt_image.join "," exec ["docker", "build", "--no-cache", "-t", "ruby-generate-dockerfile", "--build-arg", "base_image=ruby-#{os_name}", "--build-arg", "build_tools_image=ruby-build-tools", "--build-arg", "prebuilt_ruby_images=#{prebuilt_ruby_images}", "--build-arg", "default_ruby_version=#{default_ruby_version}", "--build-arg", "bundler1_version=#{bundler1_version}", "--build-arg", "bundler2_version=#{bundler2_version}", "ruby-generate-dockerfile"] end end tool "app-engine-exec-wrapper" do desc "Build the app-engine-exec wrapper" include :exec, e: true def run exec ["docker", "build", "--no-cache", "-t", "app-engine-exec-wrapper", "app-engine-exec-wrapper"] end end tool "app-engine-exec-harness" do desc "Build the fake test harmess image for app-engine-exec wrapper" include :exec, e: true def run exec ["docker", "build", "--no-cache", "-t", "app-engine-exec-harness", "test/app_engine_exec_wrapper/harness"] end end
ruby
Apache-2.0
d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1
2026-01-04T17:46:25.817234Z
false