source
stringclasses
1 value
repo
stringlengths
5
63
repo_url
stringlengths
24
82
path
stringlengths
5
167
language
stringclasses
1 value
license
stringclasses
5 values
stars
int64
10
51.4k
ref
stringclasses
23 values
size_bytes
int64
200
258k
text
stringlengths
137
258k
github
fog/fog
https://github.com/fog/fog
tests/compute/models/servers_tests.rb
Ruby
mit
4,298
master
355
for provider, config in compute_providers Shindo.tests("Fog::Compute[:#{provider}] | servers", [provider.to_s]) do provider_attributes = config[:provider_attributes] || {} provider_attributes.merge!(:provider => provider) servers_tests(Fog::Compute.new(provider_attributes), (config[:server_attributes] ||...
github
fog/fog
https://github.com/fog/fog
tests/compute/models/server_tests.rb
Ruby
mit
4,298
master
1,361
for provider, config in compute_providers Shindo.tests("Fog::Compute[:#{provider}] | server", [provider.to_s]) do provider_attributes = config[:provider_attributes] || {} provider_attributes.merge!(:provider => provider) server_tests(Fog::Compute.new(provider_attributes), (config[:server_attributes] || {...
github
fog/fog
https://github.com/fog/fog
tests/compute/models/flavors_tests.rb
Ruby
mit
4,298
master
403
for provider, config in compute_providers next if [:glesys, :ibm].include?(provider) Shindo.tests("Fog::Compute[:#{provider}] | flavors", [provider.to_s]) do provider_attributes = config[:provider_attributes] || {} provider_attributes.merge!(:provider => provider) flavors_tests(Fog::Compute.new(provi...
github
fog/fog
https://github.com/fog/fog
tests/helpers/collection_helper.rb
Ruby
mit
4,298
master
2,347
def collection_tests(collection, params = {}, mocks_implemented = true) tests('success') do tests("#new(#{params.inspect})").succeeds do pending if Fog.mocking? && !mocks_implemented collection.new(params) end tests("#create(#{params.inspect})").succeeds do pending if Fog.mocking? && !...
github
fog/fog
https://github.com/fog/fog
tests/helpers/model_helper.rb
Ruby
mit
4,298
master
779
def model_tests(collection, params = {}, mocks_implemented = true) tests('success') do @instance = collection.new(params) tests("#save").succeeds do pending if Fog.mocking? && !mocks_implemented @instance.save end if block_given? yield(@instance) end tests("#destroy").suc...
github
fog/fog
https://github.com/fog/fog
tests/helpers/schema_validator_tests.rb
Ruby
mit
4,298
master
3,737
Shindo.tests('Fog::Schema::DataValidator', 'meta') do validator = Fog::Schema::DataValidator.new tests('#validate') do tests('returns true') do returns(true, 'when value matches schema expectation') do validator.validate({"key" => "Value"}, {"key" => String}) end returns(true, 'wh...
github
fog/fog
https://github.com/fog/fog
tests/helpers/formats_helper_tests.rb
Ruby
mit
4,298
master
3,600
Shindo.tests('test_helper', 'meta') do tests('comparing welcome data against schema') do data = {:welcome => "Hello" } data_matches_schema(:welcome => String) { data } end tests('#data_matches_schema') do tests('when value matches schema expectation') do data_matches_schema({"key" => String}) ...
github
fog/fog
https://github.com/fog/fog
tests/helpers/formats_helper.rb
Ruby
mit
4,298
master
3,630
require "fog/schema/data_validator" # format related hackery # allows both true.is_a?(Fog::Boolean) and false.is_a?(Fog::Boolean) # allows both nil.is_a?(Fog::Nullable::String) and ''.is_a?(Fog::Nullable::String) module Fog module Boolean; end module Nullable module Boolean; end module Integer; end mod...
github
fog/fog
https://github.com/fog/fog
tests/helpers/responds_to_helper.rb
Ruby
mit
4,298
master
252
module Shindo class Tests def responds_to(method_names) for method_name in [*method_names] tests("#respond_to?(:#{method_name})").returns(true) do @instance.respond_to?(method_name) end end end end end
github
fog/fog
https://github.com/fog/fog
tests/helpers/mock_helper.rb
Ruby
mit
4,298
master
4,570
# Use so you can run in mock mode from the command line # # FOG_MOCK=true fog if ENV["FOG_MOCK"] == "true" Fog.mock! end # if in mocked mode, fill in some fake credentials for us if Fog.mock? Fog.credentials = { :aws_access_key_id => 'aws_access_key_id', :aws_secret_access_key =>...
github
fog/fog
https://github.com/fog/fog
tests/helpers/compute/flavors_helper.rb
Ruby
mit
4,298
master
819
def flavors_tests(connection, params = {}, mocks_implemented = true) tests('success') do tests("#all").succeeds do pending if Fog.mocking? && !mocks_implemented connection.flavors.all end if !Fog.mocking? || mocks_implemented @identity = connection.flavors.first.identity end t...
github
fog/fog
https://github.com/fog/fog
tests/helpers/compute/server_helper.rb
Ruby
mit
4,298
master
678
def server_tests(connection, params = {}, mocks_implemented = true) model_tests(connection.servers, params, mocks_implemented) do tests('#reload').returns(true) do pending if Fog.mocking? && !mocks_implemented @instance.wait_for { ready? } identity = @instance.identity !identity.nil? && i...
github
fog/fog
https://github.com/fog/fog
tests/helpers/compute/servers_helper.rb
Ruby
mit
4,298
master
264
def servers_tests(connection, params = {}, mocks_implemented = true) collection_tests(connection.servers, params, mocks_implemented) do if !Fog.mocking? || mocks_implemented @instance.wait_for { ready? } yield if block_given? end end end
github
fog/fog
https://github.com/fog/fog
tests/opennebula/compute_tests.rb
Ruby
mit
4,298
master
505
Shindo.tests('Fog::Compute[:opennebula]', ['opennebula']) do begin compute = Fog::Compute[:opennebula] rescue Fog::Errors::LoadError pending end tests("Compute collections") do %w{networks groups}.each do |collection| test("it should respond to #{collection}") { compute.respond_to? collection...
github
fog/fog
https://github.com/fog/fog
tests/opennebula/models/compute/flavor_tests.rb
Ruby
mit
4,298
master
1,695
Shindo.tests('Fog::Compute[:opennebula] | flavor model', ['opennebula']) do begin flavors = Fog::Compute[:opennebula].flavors rescue Fog::Errors::LoadError pending end flavor = flavors.get_by_name('fogtest').last tests('The flavor model should') do tests('have the action') do test('reload'...
github
fog/fog
https://github.com/fog/fog
tests/opennebula/models/compute/network_tests.rb
Ruby
mit
4,298
master
1,013
Shindo.tests('Fog::Compute[:opennebula] | network model', ['opennebula']) do begin networks = Fog::Compute[:opennebula].networks rescue Fog::Errors::LoadError pending end network = networks.get_by_name('fogtest') tests('The network model should') do tests('have the action') do test('reload...
github
fog/fog
https://github.com/fog/fog
tests/opennebula/models/compute/group_tests.rb
Ruby
mit
4,298
master
937
Shindo.tests('Fog::Compute[:opennebula] | group model', ['opennebula']) do begin groups = Fog::Compute[:opennebula].groups rescue Fog::Errors::LoadError pending end group = groups.last tests('The group model should') do tests('have the action') do test('reload') { group.respond_to? 'reload'...
github
fog/fog
https://github.com/fog/fog
tests/opennebula/models/compute/flavors_tests.rb
Ruby
mit
4,298
master
782
Shindo.tests('Fog::Compute[:opennebula] | flavors collection', ['opennebula']) do begin flavors = Fog::Compute[:opennebula].flavors rescue Fog::Errors::LoadError pending end tests('The flavors collection should') do test('should be a kind of Fog::Compute::OpenNebula::Flavors') { flavors.kind_of? Fo...
github
fog/fog
https://github.com/fog/fog
tests/opennebula/models/compute/groups_tests.rb
Ruby
mit
4,298
master
687
Shindo.tests('Fog::Compute[:opennebula] | groups collection', ['opennebula']) do begin groups = Fog::Compute[:opennebula].groups rescue Fog::Errors::LoadError pending end tests('The groups collection') do test('should be a kind of Fog::Compute::OpenNebula::Groups') { groups.kind_of? Fog::Compute::O...
github
fog/fog
https://github.com/fog/fog
tests/opennebula/models/compute/networks_tests.rb
Ruby
mit
4,298
master
773
Shindo.tests('Fog::Compute[:opennebula] | networks collection', ['opennebula']) do begin networks = Fog::Compute[:opennebula].networks rescue Fog::Errors::LoadError pending end tests('The networks collection') do test('should be a kind of Fog::Compute::OpenNebula::Networks') { networks.kind_of? Fog...
github
fog/fog
https://github.com/fog/fog
tests/opennebula/requests/compute/vm_suspend_resume_tests.rb
Ruby
mit
4,298
master
1,474
Shindo.tests("Fog::Compute[:opennebula] | vm_suspend and vm_resume request", 'opennebula') do begin compute = Fog::Compute[:opennebula] rescue Fog::Errors::LoadError pending end name_base = Time.now.to_i f = compute.flavors.get_by_name("fogtest") tests("Get 'fogtest' flavor/template") do test("...
github
fog/fog
https://github.com/fog/fog
tests/opennebula/requests/compute/vm_disk_snapshot_test.rb
Ruby
mit
4,298
master
1,979
Shindo.tests("Fog::Compute[:opennebula] | vm_create and destroy request", 'opennebula') do compute = Fog::Compute[:opennebula] name_base = Time.now.to_i f = compute.flavors.get_by_name("fogtest") tests("Get 'fogtest' flavor/template") do test("Got template with name 'fogtest'") {f.kind_of? Array} rais...
github
fog/fog
https://github.com/fog/fog
tests/opennebula/requests/compute/vm_allocate_tests.rb
Ruby
mit
4,298
master
2,789
Shindo.tests("Fog::Compute[:opennebula] | vm_create and vm_destroy request", 'opennebula') do begin compute = Fog::Compute[:opennebula] rescue Fog::Errors::LoadError pending end name_base = Time.now.to_i f = compute.flavors.get_by_name("fogtest") tests("Get 'fogtest' flavor/template") do test(...
github
fog/fog
https://github.com/fog/fog
tests/cloudsigma/requests/server_tests.rb
Ruby
mit
4,298
master
2,404
Shindo.tests('Fog::Compute[:cloudsigma] | server requests', ['cloudsigma']) do @server_format = { 'uuid' => String, 'cpu' => Integer, 'cpus_instead_of_cores' => Fog::Boolean, 'drives' => Array, 'enable_numa' => Fog::Boolean, 'hv_relaxed' => Fog::Boolean, 'hv_tsc' => Fog::Bo...
github
fog/fog
https://github.com/fog/fog
tests/cloudsigma/requests/volumes_tests.rb
Ruby
mit
4,298
master
1,665
Shindo.tests('Fog::Compute[:cloudsigma] | volume requests', ['cloudsigma']) do @volume_format = { 'uuid' => String, 'affinities' => Array, 'allow_multimount' => Fog::Boolean, 'jobs' => Array, 'licenses' => Array, 'media' => String, 'meta' => Fog::Nullable::Hash, 'mount...
github
fog/fog
https://github.com/fog/fog
tests/cloudsigma/requests/snapshots_tests.rb
Ruby
mit
4,298
master
2,804
Shindo.tests('Fog::Compute[:cloudsigma] | snapshot requests', ['cloudsigma']) do pending if Fog.mocking? @snapshot_format = { 'uuid' => String, 'allocated_size' => Fog::Nullable::Integer, 'drive' => Fog::Nullable::Hash, 'meta' => Fog::Nullable::Hash, 'name' => String, 'owner' =>...
github
fog/fog
https://github.com/fog/fog
tests/cloudsigma/models/snapshot_tests.rb
Ruby
mit
4,298
master
707
Shindo.tests('Fog::Compute[:cloudsigma] | snapshot model', ['cloudsigma']) do pending if Fog.mocking? volume = Fog::Compute[:cloudsigma].volumes.create(:name => 'fogmodeltest', :size => 1024**3, :media => :disk) volume.wait_for { available? } unless Fog.mocking? snapshots = Fog::Compute[:cloudsigma].snapshots...
github
fog/fog
https://github.com/fog/fog
tests/cloudsigma/models/volume_tests.rb
Ruby
mit
4,298
master
624
Shindo.tests('Fog::Compute[:cloudsigma] | volume model', ['cloudsigma']) do volumes = Fog::Compute[:cloudsigma].volumes volume_create_args = {:name => 'fogmodeltest', :size => 1024**3, :media => :cdrom} model_tests(volumes, volume_create_args, true) do @instance.wait_for(timeout=60) { available? } tests...
github
fog/fog
https://github.com/fog/fog
tests/cloudsigma/models/servers_tests.rb
Ruby
mit
4,298
master
416
Shindo.tests('Fog::Compute[:cloudsigma] | servers collection', ['cloudsigma']) do # mark as pending, the collection_tests are not quite what in line with how CloudSigma servers operate pending servers = Fog::Compute[:cloudsigma].servers server_create_args = {:name => 'fogtest', :cpu => 2000, :mem => 512*1024**...
github
fog/fog
https://github.com/fog/fog
tests/cloudsigma/models/volumes_tests.rb
Ruby
mit
4,298
master
338
Shindo.tests('Fog::Compute[:cloudsigma] | volumes collection', ['cloudsigma']) do volumes = Fog::Compute[:cloudsigma].volumes volume_create_args = {:name => 'fogtest', :size => 1024**3, :media => :cdrom} collection_tests(volumes, volume_create_args, true) do @instance.wait_for(timeout=60) { status == 'unmoun...
github
fog/fog
https://github.com/fog/fog
tests/cloudsigma/models/snapshots_tests.rb
Ruby
mit
4,298
master
532
Shindo.tests('Fog::Compute[:cloudsigma] | snapshots collection', ['cloudsigma']) do pending if Fog.mocking? volume = Fog::Compute[:cloudsigma].volumes.create(:name => 'fogtest', :size => 1024**3, :media => :disk) volume.wait_for { available? } unless Fog.mocking? snapshots = Fog::Compute[:cloudsigma].snapshot...
github
fog/fog
https://github.com/fog/fog
tests/cloudsigma/models/server_tests.rb
Ruby
mit
4,298
master
2,035
Shindo.tests('Fog::Compute[:cloudsigma] | server model', ['cloudsigma']) do service = Fog::Compute[:cloudsigma] servers = Fog::Compute[:cloudsigma].servers server_create_args = {:name => 'fogtest', :cpu => 2000, :mem => 512*1024**2, :vnc_password => 'myrandompass'} model_tests(servers, server_create_args, tru...
github
fog/fog
https://github.com/fog/fog
tests/vcloud/models/compute/vapps_tests.rb
Ruby
mit
4,298
master
754
require 'fog/vcloud/models/compute/vapps' Shindo.tests("Vcloud::Compute | vapps", ['vcloud']) do Fog::Vcloud::Compute::SUPPORTED_VERSIONS.each do |version| tests("api version #{version}") do pending if Fog.mocking? instance = Fog::Vcloud::Compute::Vapps.new( :connection => Fog::Vcloud::Compu...
github
fog/fog
https://github.com/fog/fog
tests/vcloud/models/compute/organizations_tests.rb
Ruby
mit
4,298
master
642
require 'fog/vcloud/models/compute/organizations' Shindo.tests("Vcloud::Compute | organizations", ['vcloud']) do Fog::Vcloud::Compute::SUPPORTED_VERSIONS.each do |version| tests("api version #{version}") do pending if Fog.mocking? instance = Fog::Vcloud::Compute.new(:vcloud_host => 'vcloud.example.c...
github
fog/fog
https://github.com/fog/fog
tests/vcloud/models/compute/server_tests.rb
Ruby
mit
4,298
master
5,025
require 'fog/vcloud/models/compute/servers' Shindo.tests("Vcloud::Compute | server", ['vcloud']) do Fog::Vcloud::Compute::SUPPORTED_VERSIONS.each do |version| tests("api version #{version}") do pending if Fog.mocking? instance = Fog::Vcloud::Compute.new( :vcloud_host => 'vcloud.example.com',...
github
fog/fog
https://github.com/fog/fog
tests/vcloud/models/compute/organization_tests.rb
Ruby
mit
4,298
master
876
Shindo.tests("Vcloud::Compute | organization", ['vcloud']) do Fog::Vcloud::Compute::SUPPORTED_VERSIONS.each do |version| tests("api version #{version}") do pending if Fog.mocking? instance = Fog::Vcloud::Compute.new( :vcloud_host => 'vcloud.example.com', :vcloud_username => 'username'...
github
fog/fog
https://github.com/fog/fog
tests/vcloud/models/compute/servers_tests.rb
Ruby
mit
4,298
master
833
require 'fog/vcloud/models/compute/servers' Shindo.tests("Vcloud::Compute | servers", ['vcloud']) do Fog::Vcloud::Compute::SUPPORTED_VERSIONS.each do |version| tests("api version #{version}") do pending if Fog.mocking? instance = Fog::Vcloud::Compute::Servers.new( :connection => Fog::Vcloud:...
github
fog/fog
https://github.com/fog/fog
tests/vcloud/models/compute/vapp_tests.rb
Ruby
mit
4,298
master
1,370
require 'fog/vcloud/models/compute/vapps' require 'fog/vcloud/models/compute/vapp' Shindo.tests("Vcloud::Compute | vapp", ['vcloud']) do Fog::Vcloud::Compute::SUPPORTED_VERSIONS.each do |version| tests("api version #{version}") do pending if Fog.mocking? instance = Fog::Vcloud::Compute.new( ...
github
fog/fog
https://github.com/fog/fog
tests/vcloud/models/compute/vdcs_tests.rb
Ruby
mit
4,298
master
881
require 'fog/vcloud/models/compute/vdcs' Shindo.tests("Vcloud::Compute | vdcs", ['vcloud']) do Fog::Vcloud::Compute::SUPPORTED_VERSIONS.each do |version| tests("api version #{version}") do pending if Fog.mocking? instance = Fog::Vcloud::Compute::Vdcs.new( :connection => Fog::Vcloud::Comput...
github
fog/fog
https://github.com/fog/fog
tests/vcloud/models/compute/vdc_tests.rb
Ruby
mit
4,298
master
2,003
require 'fog/vcloud/models/compute/vdcs' require 'fog/vcloud/models/compute/vdc' Shindo.tests("Vcloud::Compute | vdc", ['vcloud']) do Fog::Vcloud::Compute::SUPPORTED_VERSIONS.each do |version| tests("api version #{version}") do pending if Fog.mocking? instance = Fog::Vcloud::Compute.new( :vc...
github
fog/fog
https://github.com/fog/fog
tests/vcloud/models/compute/network_tests.rb
Ruby
mit
4,298
master
3,140
require 'fog/vcloud/models/compute/networks' Shindo.tests("Vcloud::Compute | network", ['vcloud']) do Fog::Vcloud::Compute::SUPPORTED_VERSIONS.each do |version| tests("api version #{version}") do pending if Fog.mocking? connection = Fog::Vcloud::Compute.new( :vcloud_host => 'vcloud.example....
github
fog/fog
https://github.com/fog/fog
tests/vcloud/models/compute/networks_tests.rb
Ruby
mit
4,298
master
2,247
require 'fog/vcloud/models/compute/networks' Shindo.tests("Vcloud::Compute | networks", ['vcloud']) do Fog::Vcloud::Compute::SUPPORTED_VERSIONS.each do |version| tests("api version #{version}") do pending if Fog.mocking? tests("from an org perspective") do instance = Fog::Vcloud::Compute::N...
github
fog/fog
https://github.com/fog/fog
tests/vcloud/models/compute/helper.rb
Ruby
mit
4,298
master
579
class Vcloud module Compute module TestSupport if Fog.mocking? def self.template 'mock_template' end else def self.template template_name = ENV['VCLOUD_TEMPLATE'] raise "Specify VApp template name in VCLOUD_TEMPLATE env var" unless template_name ...
github
fog/fog
https://github.com/fog/fog
tests/vcloud/requests/compute/disk_configure_tests.rb
Ruby
mit
4,298
master
4,723
Shindo.tests("Vcloud::Compute | disk_requests", ['vcloud']) do @xmlns = { "xmlns" => "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData", "xmlns:vcloud" => "http://www.vmware.com/vcloud/v1" } def disk_hash [{:"rasd:AddressOnParent"=>"0", :"rasd:Description"=>...
github
fog/fog
https://github.com/fog/fog
tests/clodo/requests/compute/image_tests.rb
Ruby
mit
4,298
master
747
Shindo.tests('Fog::Compute[:clodo] | image requests', ['clodo']) do ### Fog.mock! clodo = Fog::Compute[:clodo] @image_format = { 'id' => String, 'name' => String, 'status' => String, 'vps_type' => String } @image_details_format = { 'os_type' => String, 'os_bits' => String, 'os_h...
github
fog/fog
https://github.com/fog/fog
tests/clodo/requests/compute/server_tests.rb
Ruby
mit
4,298
master
5,869
Shindo.tests('Fog::Compute[:clodo] | server requests', ['clodo']) do @ip_format = { 'primary_ip' => Fog::Boolean, 'isp' => Fog::Boolean, 'ip' => String } @server_format = { 'addresses' => { 'public' => [@ip_format] }, 'id' => String, 'imageId' => Str...
github
basecamp/once-campfire
https://github.com/basecamp/once-campfire
Rakefile
Ruby
mit
4,291
main
227
# Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. require_relative "config/application" Rails.application.load_tasks
github
basecamp/once-campfire
https://github.com/basecamp/once-campfire
Gemfile
Ruby
mit
4,291
main
1,074
source "https://rubygems.org" git_source(:github) { |repo| "https://github.com/#{repo}.git" } # Rails gem "rails", github: "rails/rails", branch: "main" gem "ostruct" gem "benchmark" # Drivers gem "sqlite3" gem "redis", "~> 5.4" # Deployment gem "puma", "~> 6.6" # Jobs gem "resque", "~> 2.7.0" gem "resque-pool", "...
github
basecamp/once-campfire
https://github.com/basecamp/once-campfire
lib/rails_ext/actiontext_opengraph_embeds.rb
Ruby
mit
4,291
main
1,018
class ActionText::Attachment::OpengraphEmbed include ActiveModel::Model OPENGRAPH_EMBED_CONTENT_TYPE = "application/vnd.actiontext.opengraph-embed" class << self def from_node(node) if node["content-type"] if matches = node["content-type"].match(OPENGRAPH_EMBED_CONTENT_TYPE) attachme...
github
basecamp/once-campfire
https://github.com/basecamp/once-campfire
lib/rails_ext/filter.rb
Ruby
mit
4,291
main
448
class ActionText::Content::Filter class << self def apply(content) filter = new(content) filter.applicable? ? ActionText::Content.new(filter.apply, canonicalize: false) : content end end def initialize(content) @content = content end def applicable? raise NotImplementedError en...
github
basecamp/once-campfire
https://github.com/basecamp/once-campfire
lib/rails_ext/filters.rb
Ruby
mit
4,291
main
231
class ActionText::Content::Filters def initialize(*filters) @filters = filters end def apply(content) filters.reduce(content) { |content, filter| filter.apply(content) } end private attr_reader :filters end
github
basecamp/once-campfire
https://github.com/basecamp/once-campfire
lib/rails_ext/action_text_attachables.rb
Ruby
mit
4,291
main
1,820
ActiveSupport.on_load(:action_text_content) do class ActionText::Attachment class << self def from_node(node, attachable = nil) new(node, attachable || ActionText::Attachment::OpengraphEmbed.from_node(node) || attachable_from_possibly_expired_sgid(node["sgid"]) || ActionText::Attachable.from_node(no...
github
basecamp/once-campfire
https://github.com/basecamp/once-campfire
lib/web_push/notification.rb
Ruby
mit
4,291
main
893
class WebPush::Notification def initialize(title:, body:, path:, badge:, endpoint:, p256dh_key:, auth_key:) @title, @body, @path, @badge = title, body, path, badge @endpoint, @p256dh_key, @auth_key = endpoint, p256dh_key, auth_key end def deliver(connection: nil) WebPush.payload_send \ message:...
github
basecamp/once-campfire
https://github.com/basecamp/once-campfire
lib/web_push/pool.rb
Ruby
mit
4,291
main
1,899
# This is in lib so we can use it in a thread pool without the Rails executor class WebPush::Pool attr_reader :delivery_pool, :invalidation_pool, :connection, :invalid_subscription_handler def initialize(invalid_subscription_handler:) @delivery_pool = Concurrent::ThreadPoolExecutor.new(max_threads: 50, queue_s...
github
basecamp/once-campfire
https://github.com/basecamp/once-campfire
lib/restricted_http/private_network_guard.rb
Ruby
mit
4,291
main
656
require "resolv" module RestrictedHTTP class Violation < StandardError; end module PrivateNetworkGuard extend self LOCAL_IP = IPAddr.new("0.0.0.0/8") # "This" network def resolve(hostname) Resolv.getaddress(hostname).tap do |ip| raise Violation.new("Attempt to access private IP via #{h...
github
basecamp/once-campfire
https://github.com/basecamp/once-campfire
lib/tasks/resque.rake
Ruby
mit
4,291
main
269
task "resque:setup" do require_relative "../../config/environment" end task "resque:pool:setup" do ActiveRecord::Base.connection.disconnect! Resque::Pool.after_prefork do |job| ActiveRecord::Base.establish_connection Resque.redis.client.close end end
github
basecamp/once-campfire
https://github.com/basecamp/once-campfire
lib/tasks/generate.rake
Ruby
mit
4,291
main
287
namespace :generate do task "lines": :environment do room = Room.find_by(name: "Lobby") users = User.all 1.upto(500) do |i| room.messages.create! \ body: "Message #{i}", user: users.sample, created_at: 1.day.ago + i.minutes end end end
github
basecamp/once-campfire
https://github.com/basecamp/once-campfire
db/schema.rb
Ruby
mit
4,291
main
7,438
# 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/rai...
github
basecamp/once-campfire
https://github.com/basecamp/once-campfire
db/migrate/20240110071740_create_sessions.rb
Ruby
mit
4,291
main
389
class CreateSessions < ActiveRecord::Migration[7.2] def change create_table :sessions do |t| t.references :user, null: false, foreign_key: true, index: true t.string :token, null: false t.string :ip_address t.string :user_agent t.datetime :last_active_at, null: false t.timesta...
github
basecamp/once-campfire
https://github.com/basecamp/once-campfire
db/migrate/20251212154340_add_singleton_constraint_to_accounts.rb
Ruby
mit
4,291
main
227
class AddSingletonConstraintToAccounts < ActiveRecord::Migration[8.2] def change add_column :accounts, :singleton_guard, :integer, default: 0, null: false add_index :accounts, :singleton_guard, unique: true end end
github
basecamp/once-campfire
https://github.com/basecamp/once-campfire
db/migrate/20231215043540_create_initial_schema.rb
Ruby
mit
4,291
main
5,433
class CreateInitialSchema < ActiveRecord::Migration[7.2] def change create_table "accounts", force: :cascade do |t| t.string "name", null: false t.string "join_code", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false end create_table "action_tex...
github
basecamp/once-campfire
https://github.com/basecamp/once-campfire
db/migrate/20240209110503_alter_users_add_bot_token.rb
Ruby
mit
4,291
main
264
class AlterUsersAddBotToken < ActiveRecord::Migration[7.2] def change add_column :users, :bot_token, :string add_index :users, :bot_token, unique: true # Bot users do not use passwords change_column_null :users, :password_digest, true end end
github
basecamp/once-campfire
https://github.com/basecamp/once-campfire
db/migrate/20251126115722_change_active_to_status_on_users.rb
Ruby
mit
4,291
main
321
class ChangeActiveToStatusOnUsers < ActiveRecord::Migration[8.1] def change add_column :users, :status, :integer, default: 0, null: false reversible do |dir| dir.up do execute "UPDATE users SET status = 1 WHERE active = 0" end end remove_column :users, :active, :boolean end end
github
basecamp/once-campfire
https://github.com/basecamp/once-campfire
db/migrate/20250825100957_add_service_name_to_active_storage_blobs.active_storage.rb
Ruby
mit
4,291
main
718
# This migration comes from active_storage (originally 20190112182829) class AddServiceNameToActiveStorageBlobs < ActiveRecord::Migration[6.0] def up return unless table_exists?(:active_storage_blobs) unless column_exists?(:active_storage_blobs, :service_name) add_column :active_storage_blobs, :service...
github
basecamp/once-campfire
https://github.com/basecamp/once-campfire
db/migrate/20250825100958_create_active_storage_variant_records.active_storage.rb
Ruby
mit
4,291
main
1,103
# This migration comes from active_storage (originally 20191206030411) class CreateActiveStorageVariantRecords < ActiveRecord::Migration[6.0] def change return unless table_exists?(:active_storage_blobs) # Use Active Record's configured type for primary key create_table :active_storage_variant_records, i...
github
basecamp/once-campfire
https://github.com/basecamp/once-campfire
db/migrate/20251126092013_create_bans.rb
Ruby
mit
4,291
main
259
class CreateBans < ActiveRecord::Migration[8.1] def change create_table :bans do |t| t.references :user, null: false, foreign_key: true t.string :ip_address, null: false t.timestamps end add_index :bans, :ip_address end end
github
basecamp/once-campfire
https://github.com/basecamp/once-campfire
db/migrate/20240131105830_alter_users_set_password_digest_not_null.rb
Ruby
mit
4,291
main
253
class AlterUsersSetPasswordDigestNotNull < ActiveRecord::Migration[7.2] def change execute <<-SQL update users set password_digest = '' where password_digest is null; SQL change_column_null :users, :password_digest, false end end
github
basecamp/once-campfire
https://github.com/basecamp/once-campfire
db/migrate/20240130003150_create_webhooks.rb
Ruby
mit
4,291
main
214
class CreateWebhooks < ActiveRecord::Migration[7.2] def change create_table :webhooks do |t| t.references :user, null: false, foreign_key: true t.string :url t.timestamps end end end
github
basecamp/once-campfire
https://github.com/basecamp/once-campfire
app/channels/presence_channel.rb
Ruby
mit
4,291
main
557
class PresenceChannel < RoomChannel on_subscribe :present, unless: :subscription_rejected? on_unsubscribe :absent, unless: :subscription_rejected? def present membership.present broadcast_read_room end def absent membership.disconnected end def refresh membership.refresh_connection ...
github
basecamp/once-campfire
https://github.com/basecamp/once-campfire
app/channels/typing_notifications_channel.rb
Ruby
mit
4,291
main
326
class TypingNotificationsChannel < RoomChannel def start(data) broadcast_to @room, action: :start, user: current_user_attributes end def stop(data) broadcast_to @room, action: :stop, user: current_user_attributes end private def current_user_attributes current_user.slice(:id, :name) en...
github
basecamp/once-campfire
https://github.com/basecamp/once-campfire
app/channels/room_channel.rb
Ruby
mit
4,291
main
243
class RoomChannel < ApplicationCable::Channel def subscribed if @room = find_room stream_for @room else reject end end private def find_room current_user.rooms.find_by(id: params[:room_id]) end end
github
basecamp/once-campfire
https://github.com/basecamp/once-campfire
app/channels/application_cable/connection.rb
Ruby
mit
4,291
main
433
module ApplicationCable class Connection < ActionCable::Connection::Base include Authentication::SessionLookup identified_by :current_user def connect self.current_user = find_verified_user end private def find_verified_user if verified_session = find_session_by_cookie ...
github
basecamp/once-campfire
https://github.com/basecamp/once-campfire
app/helpers/emoji_helper.rb
Ruby
mit
4,291
main
269
module EmojiHelper REACTIONS = { "👍" => "Thumbs up", "👏" => "Clapping", "👋" => "Waving hand", "💪" => "Muscle", "❤️" => "Red heart", "😂" => "Face with tears of joy", "🎉" => "Party popper", "🔥" => "Fire" } end
github
basecamp/once-campfire
https://github.com/basecamp/once-campfire
app/helpers/users_helper.rb
Ruby
mit
4,291
main
216
module UsersHelper def button_to_direct_room_with(user) button_to rooms_directs_path(user_ids: [ user.id ]), class: "btn btn--primary full-width txt--large" do image_tag("messages.svg") end end end
github
basecamp/once-campfire
https://github.com/basecamp/once-campfire
app/helpers/rooms_helper.rb
Ruby
mit
4,291
main
2,937
module RoomsHelper def link_to_room(room, **attributes, &) link_to room_path(room), **attributes, data: { rooms_list_target: "room", room_id: room.id, badge_dot_target: "unread", sorted_list_target: "item" }.merge(attributes.delete(:data) || {}), & end def link_to_edit_room(room, &) link_to \ ...
github
basecamp/once-campfire
https://github.com/basecamp/once-campfire
app/helpers/cable_helper.rb
Ruby
mit
4,291
main
211
module CableHelper def script_aware_action_cable_meta_tag tag.meta \ name: "action-cable-url", content: Pathname(request.script_name) + Pathname(ActionCable.server.config.mount_path) end end
github
basecamp/once-campfire
https://github.com/basecamp/once-campfire
app/helpers/rich_text_helper.rb
Ruby
mit
4,291
main
367
module RichTextHelper def rich_text_data_actions default_actions = "trix-change->typing-notifications#start keydown->composer#submitByKeyboard" autocomplete_actions = "trix-focus->rich-autocomplete#focus trix-change->rich-autocomplete#search trix-blur->rich-autocomplete#blur" [ default_actio...
github
basecamp/once-campfire
https://github.com/basecamp/once-campfire
app/helpers/messages_helper.rb
Ruby
mit
4,291
main
3,955
module MessagesHelper def message_area_tag(room, &) tag.div id: "message-area", class: "message-area", contents: true, data: { controller: "messages presence drop-target", action: [ messages_actions, drop_target_actions, presence_actions ].join(" "), messages_first_of_day_class: "message--first-...
github
basecamp/once-campfire
https://github.com/basecamp/once-campfire
app/helpers/broadcasts_helper.rb
Ruby
mit
4,291
main
306
module BroadcastsHelper def broadcast_image_tag(image, options) image_tag(broadcast_image_path(image), options) end def broadcast_image_path(image) if image.is_a?(Symbol) || image.is_a?(String) image_path(image) else polymorphic_url(image, only_path: true) end end end
github
basecamp/once-campfire
https://github.com/basecamp/once-campfire
app/helpers/forms_helper.rb
Ruby
mit
4,291
main
224
module FormsHelper def auto_submit_form_with(**attributes, &) data = attributes.delete(:data) || {} data[:controller] = "auto-submit #{data[:controller]}".strip form_with **attributes, data: data, & end end
github
basecamp/once-campfire
https://github.com/basecamp/once-campfire
app/helpers/clipboard_helper.rb
Ruby
mit
4,291
main
286
module ClipboardHelper def button_to_copy_to_clipboard(url, &) tag.button class: "btn", data: { controller: "copy-to-clipboard", action: "copy-to-clipboard#copy", copy_to_clipboard_success_class: "btn--success", copy_to_clipboard_content_value: url }, & end end
github
basecamp/once-campfire
https://github.com/basecamp/once-campfire
app/helpers/qr_code_helper.rb
Ruby
mit
4,291
main
255
module QrCodeHelper def link_to_zoom_qr_code(url, &) id = Base64.urlsafe_encode64(url) link_to qr_code_path(id), class: "btn", data: { lightbox_target: "image", action: "lightbox#open", lightbox_url_value: qr_code_path(id) }, & end end
github
basecamp/once-campfire
https://github.com/basecamp/once-campfire
app/helpers/translations_helper.rb
Ruby
mit
4,291
main
8,788
module TranslationsHelper TRANSLATIONS = { email_address: { "🇺🇸": "Enter your email address", "🇪🇸": "Introduce tu correo electrónico", "🇫🇷": "Entrez votre adresse courriel", "🇮🇳": "अपना ईमेल पता दर्ज करें", "🇩🇪": "Geben Sie Ihre E-Mail-Adresse ein", "🇧🇷": "Insira seu endereço de email", "🇯🇵": "メールア...
github
basecamp/once-campfire
https://github.com/basecamp/once-campfire
app/helpers/application_helper.rb
Ruby
mit
4,291
main
1,176
module ApplicationHelper def page_title_tag tag.title @page_title || "Campfire" end def current_user_meta_tags unless Current.user.nil? safe_join [ tag(:meta, name: "current-user-id", content: Current.user.id), tag(:meta, name: "current-user-name", content: Current.user.name) ...
github
basecamp/once-campfire
https://github.com/basecamp/once-campfire
app/helpers/searches_helper.rb
Ruby
mit
4,291
main
448
module SearchesHelper def search_results_tag(&) tag.div id: "search-results", class: "messages searches__results", data: { controller: "search-results", search_results_target: "messages", search_results_me_class: "message--me", search_results_threaded_class: "message--threaded", sear...
github
basecamp/once-campfire
https://github.com/basecamp/once-campfire
app/helpers/rooms/involvements_helper.rb
Ruby
mit
4,291
main
1,587
module Rooms::InvolvementsHelper def turbo_frame_for_involvement_tag(room, &) turbo_frame_tag dom_id(room, :involvement), data: { controller: "turbo-frame", action: "notifications:ready@window->turbo-frame#load", turbo_frame_url_param: room_involvement_path(room) }, & end def button_to_change_invol...
github
basecamp/once-campfire
https://github.com/basecamp/once-campfire
app/helpers/users/avatars_helper.rb
Ruby
mit
4,291
main
578
require "zlib" module Users::AvatarsHelper AVATAR_COLORS = %w[ #AF2E1B #CC6324 #3B4B59 #BFA07A #ED8008 #ED3F1C #BF1B1B #736B1E #D07B53 #736356 #AD1D1D #BF7C2A #C09C6F #698F9C #7C956B #5D618F #3B3633 #67695E ] def avatar_background_color(user) AVATAR_COLORS[Zlib.crc32(user.to_param) % AVATAR_COLORS.s...
github
basecamp/once-campfire
https://github.com/basecamp/once-campfire
app/helpers/users/filter_helper.rb
Ruby
mit
4,291
main
529
module Users::FilterHelper def user_filter_menu_tag(&) tag.menu class: "flex flex-column gap margin-none pad overflow-y constrain-height", data: { controller: "filter", filter_active_class: "filter--active", filter_selected_class: "selected" }, & end def user_filter_search_tag tag.input type: "sear...
github
basecamp/once-campfire
https://github.com/basecamp/once-campfire
app/helpers/users/profiles_helper.rb
Ruby
mit
4,291
main
749
module Users::ProfilesHelper def profile_form_with(model, **params, &) form_with \ model: @user, url: user_profile_path, method: :patch, data: { controller: "form" }, **params, & end def profile_form_submit_button tag.button class: "btn btn--reversed center txt-large", type: "subm...
github
basecamp/once-campfire
https://github.com/basecamp/once-campfire
app/helpers/users/sidebar_helper.rb
Ruby
mit
4,291
main
494
module Users::SidebarHelper def sidebar_turbo_frame_tag(src: nil, &) turbo_frame_tag :user_sidebar, src: src, target: "_top", data: { turbo_permanent: true, controller: "rooms-list read-rooms turbo-frame", rooms_list_unread_class: "unread", action: "presence:present@window->rooms-list#read...
github
basecamp/once-campfire
https://github.com/basecamp/once-campfire
app/helpers/messages/attachment_presentation.rb
Ruby
mit
4,291
main
3,686
class Messages::AttachmentPresentation def initialize(message, context:) @message, @context = message, context end def render if message.attachment.attached? if message.attachment.previewable? || message.attachment.variable? render_preview else render_link end end ...
github
basecamp/once-campfire
https://github.com/basecamp/once-campfire
app/helpers/content_filters/style_unfurled_twitter_avatars.rb
Ruby
mit
4,291
main
727
class ContentFilters::StyleUnfurledTwitterAvatars < ActionText::Content::Filter def applicable? unfurled_twitter_avatars.present? end def apply fragment.update do |source| div = source.at_css("div") div["class"] = UNFURLED_TWITTER_AVATAR_CSS_CLASS end end private UNFURLED_TWITTER...
github
basecamp/once-campfire
https://github.com/basecamp/once-campfire
app/helpers/content_filters/sanitize_tags.rb
Ruby
mit
4,291
main
555
class ContentFilters::SanitizeTags < ActionText::Content::Filter def applicable? true end def apply fragment.replace(not_allowed_tags_css_selector) { nil } end private ALLOWED_TAGS = %w[ a abbr acronym address b big blockquote br cite code dd del dfn div dl dt em h1 h2 h3 h4 h5 h6 hr i ins kbd l...
github
basecamp/once-campfire
https://github.com/basecamp/once-campfire
app/helpers/content_filters/remove_solo_unfurled_link_text.rb
Ruby
mit
4,291
main
1,103
class ContentFilters::RemoveSoloUnfurledLinkText < ActionText::Content::Filter def applicable? normalize_tweet_url(solo_unfurled_url) == normalize_tweet_url(content.to_plain_text) end def apply fragment.replace("div") { |node| node.tap { |n| n.inner_html = unfurled_links.first.to_s } } end private ...
github
basecamp/once-campfire
https://github.com/basecamp/once-campfire
app/models/application_platform.rb
Ruby
mit
4,291
main
1,157
class ApplicationPlatform < PlatformAgent def ios? match? /iPhone|iPad/ end def android? match? /Android/ end def mac? match? /Macintosh/ end def chrome? user_agent.browser.match? /Chrome/ end def firefox? user_agent.browser.match? /Firefox|FxiOS/ end def safari? user_...
github
basecamp/once-campfire
https://github.com/basecamp/once-campfire
app/models/membership.rb
Ruby
mit
4,291
main
655
class Membership < ApplicationRecord include Connectable belongs_to :room belongs_to :user after_destroy_commit { user.reset_remote_connections } enum :involvement, %w[ invisible nothing mentions everything ].index_by(&:itself), prefix: :involved_in scope :with_ordered_room, -> { includes(:room).joins(:...
github
basecamp/once-campfire
https://github.com/basecamp/once-campfire
app/models/current.rb
Ruby
mit
4,291
main
312
class Current < ActiveSupport::CurrentAttributes attribute :session, :user, :request delegate :host, :protocol, to: :request, prefix: true, allow_nil: true def session=(value) super(value) if value.present? self.user = session.user end end def account Account.first end end
github
basecamp/once-campfire
https://github.com/basecamp/once-campfire
app/models/webhook.rb
Ruby
mit
4,291
main
2,769
require "net/http" require "uri" class Webhook < ApplicationRecord ENDPOINT_TIMEOUT = 7.seconds belongs_to :user def deliver(message) post(payload(message)).tap do |response| if text = extract_text_from(response) receive_text_reply_to(message.room, text: text) elsif attachment = extract...
github
basecamp/once-campfire
https://github.com/basecamp/once-campfire
app/models/user.rb
Ruby
mit
4,291
main
1,823
class User < ApplicationRecord include Avatar, Bannable, Bot, Mentionable, Role, Transferable has_many :memberships, dependent: :delete_all has_many :rooms, through: :memberships has_many :reachable_messages, through: :rooms, source: :messages has_many :messages, dependent: :destroy, foreign_key: :creator_i...
github
basecamp/once-campfire
https://github.com/basecamp/once-campfire
app/models/session.rb
Ruby
mit
4,291
main
473
class Session < ApplicationRecord ACTIVITY_REFRESH_RATE = 1.hour has_secure_token belongs_to :user before_create { self.last_active_at ||= Time.now } def self.start!(user_agent:, ip_address:) create! user_agent: user_agent, ip_address: ip_address end def resume(user_agent:, ip_address:) if la...