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 | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/controllers/rails/pwa_controller.rb | Ruby | bsd-3-clause | 99 | main | 428 | require "rails/application_controller"
class Rails::PwaController < Rails::ApplicationController # :nodoc:
include ColorScheming
before_action :ensure_current_color_scheme, only: %i[manifest]
skip_forgery_protection
def serviceworker
render template: "pwa/serviceworker", layout: false
end
def manif... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/controllers/admin/home_controller.rb | Ruby | bsd-3-clause | 99 | main | 304 | class Admin::HomeController < Admin::BaseController
def index
@nav = {
"Rails Admin" => "/admin/data",
"Newsletters" => admin_newsletters_path,
"Flipper" => "/admin/flipper",
"Mission Control Jobs" => "/admin/jobs",
"Litestream" => "/admin/litestream"
}
end
end |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/controllers/admin/newsletters_controller.rb | Ruby | bsd-3-clause | 99 | main | 2,058 | class Admin::NewslettersController < Admin::BaseController
# GET /admin/newsletters
def index
@newsletters = Newsletter.all
end
# GET /admin/newsletters/1
def show
@newsletter = Newsletter.find(params[:id])
end
# GET /admin/newsletters/new
def new
@newsletter = Newsletter.new(newsletter_pa... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/controllers/pwa/web_pushes_controller.rb | Ruby | bsd-3-clause | 99 | main | 365 | class Pwa::WebPushesController < ApplicationController
def create
web_push_params = params.require(:web_push).permit(:title, :message, :subscription)
Pwa::WebPushJob.perform_later(
title: web_push_params[:title],
message: web_push_params[:message],
subscription: JSON.parse(web_push_params[:... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/controllers/pwa/installation_instructions_controller.rb | Ruby | bsd-3-clause | 99 | main | 419 | class Pwa::InstallationInstructionsController < ApplicationController
def show
@installation_instructions = if params[:user_agent_nickname]
Pwa::NamedInstallationInstructions.find(params[:user_agent_nickname])
else
Honeybadger.event("installation_instructions_controller.show", user_agent: request.... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/controllers/share/snippets_controller.rb | Ruby | bsd-3-clause | 99 | main | 296 | class Share::SnippetsController < ApplicationController
def index
@snippets = Snippet.all.with_attached_screenshot.includes(:author).order(created_at: :desc)
end
def show
@snippet = Snippet.find(params[:id])
fresh_when(@snippet, public: true) unless user_signed_in?
end
end |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/controllers/share/polls_controller.rb | Ruby | bsd-3-clause | 99 | main | 280 | class Share::PollsController < ApplicationController
before_action :ensure_device_uuid, only: :show
def index
@polls = Poll.all
end
def show
@poll = Poll.find(params[:id])
end
private
def poll_params
params.require(:poll).permit(:response)
end
end |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/controllers/share/snippet_screenshots_controller.rb | Ruby | bsd-3-clause | 99 | main | 666 | class Share::SnippetScreenshotsController < ApplicationController
using Refinements::Emojoy
def show
@snippet = Snippet.find(params[:snippet_id])
render layout: false
end
def new
@snippet = Snippet.find(params[:snippet_id])
@auto = params[:auto] == "true"
end
def create
@snippet = Sn... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/controllers/share/polls/votes_controller.rb | Ruby | bsd-3-clause | 99 | main | 1,499 | module Share
module Polls
class VotesController < ApplicationController
using Refinements::Emojoy
def create
@poll = Poll.find(params[:poll_id])
@answer = @poll.answers.includes(:question).find(params[:answer_id])
@question = @answer.question
@vote = @question.votes.fi... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/controllers/author/snippets_controller.rb | Ruby | bsd-3-clause | 99 | main | 2,230 | module Author
class SnippetsController < ApplicationController
using Refinements::Emojoy
before_action :feature_enabled!
before_action :authenticate_user!
def index
@snippets = Current.user.snippets.includes(:author).order(created_at: :desc)
end
def show
@snippet = Current.user.... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/controllers/author/polls_controller.rb | Ruby | bsd-3-clause | 99 | main | 1,672 | module Author
class PollsController < ApplicationController
using Refinements::Emojoy
before_action :feature_enabled!
before_action :authenticate_user!
def index
@polls = Current.user.polls.ordered
end
def show
@poll = Current.user.polls.find(params[:id])
@questions = @pol... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/controllers/author/polls/questions_controller.rb | Ruby | bsd-3-clause | 99 | main | 2,138 | module Author
module Polls
class QuestionsController < ApplicationController
before_action :feature_enabled!
before_action :authenticate_user!
def new
@poll = Current.user.polls.find(params[:poll_id])
@question = @poll.questions.build
end
def create
@poll = ... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/controllers/author/polls/answers_controller.rb | Ruby | bsd-3-clause | 99 | main | 2,248 | module Author
module Polls
class AnswersController < ApplicationController
before_action :feature_enabled!
before_action :authenticate_user!
def new
@poll = Current.user.polls.find(params[:poll_id])
@question = @poll.questions.find(params[:question_id])
@answer = @questi... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/controllers/concerns/color_scheming_admin.rb | Ruby | bsd-3-clause | 99 | main | 475 | module ColorSchemingAdmin
extend ActiveSupport::Concern
included do
before_action :use_admin_color_scheme
end
protected
def use_admin_color_scheme
Current.color_scheme = @color_scheme = @custom_color_scheme = default_admin_color_scheme || default_color_scheme
end
def default_admin_color_scheme... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/controllers/concerns/authentication.rb | Ruby | bsd-3-clause | 99 | main | 1,382 | # app/controllers/concerns/authentication.rb
module Authentication
extend ActiveSupport::Concern
included do
helper_method :current_admin_user
helper_method :current_user
helper_method :user_signed_in?
helper_method :admin_user_signed_in?
end
def warden
request.env["warden"]
end
prote... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/controllers/concerns/analytics.rb | Ruby | bsd-3-clause | 99 | main | 353 | module Analytics
protected
def plausible_event(name, props: {})
Analytics::PlausibleEventJob.perform_later(
name: name,
url: request.original_url,
props: props,
referrer: request.referer,
headers: {
"User-Agent" => request.user_agent,
"X-Forwarded-For" => request.r... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/controllers/concerns/device_uuid.rb | Ruby | bsd-3-clause | 99 | main | 216 | module DeviceUuid
extend ActiveSupport::Concern
included do
helper_method :ensure_device_uuid
end
protected
def ensure_device_uuid
cookies.signed[:device_uuid] ||= SecureRandom.uuid_v7
end
end |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/controllers/concerns/syntax_highlighting.rb | Ruby | bsd-3-clause | 99 | main | 1,236 | module SyntaxHighlighting
extend ActiveSupport::Concern
included do
helper_method :custom_syntax_highlight?
helper_method :custom_syntax_highlight_params
helper_method :find_syntax_highlight
end
protected
def find_syntax_highlight
@syntax_highlight ||= preview_syntax_highlight || session_sy... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/controllers/concerns/color_scheming.rb | Ruby | bsd-3-clause | 99 | main | 1,364 | module ColorScheming
extend ActiveSupport::Concern
included do
helper_method :custom_color_scheme_params
helper_method :custom_color_scheme?
helper_method :find_color_scheme
helper_method :preview_color_scheme
helper_method :session_color_scheme
helper_method :default_color_scheme
end
... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/controllers/settings/syntax_highlights_controller.rb | Ruby | bsd-3-clause | 99 | main | 1,201 | class Settings::SyntaxHighlightsController < ApplicationController
def show
@syntax_highlight = find_syntax_highlight
respond_to do |format|
format.html {
render Settings::SyntaxHighlights::ShowView.new(
settings: Settings.new(syntax_highlight: @syntax_highlight),
available_... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/controllers/settings/color_schemes_controller.rb | Ruby | bsd-3-clause | 99 | main | 1,428 | class Settings::ColorSchemesController < ApplicationController
def show
@color_scheme = find_color_scheme
respond_to do |format|
format.html {
render Settings::ColorSchemes::ShowView.new(
settings: Settings.new(color_scheme: @color_scheme),
preview_color_scheme: preview_colo... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/controllers/users/confirmations_controller.rb | Ruby | bsd-3-clause | 99 | main | 1,923 | # frozen_string_literal: true
class Users::ConfirmationsController < ApplicationController
before_action :redirect_if_authenticated, only: [:create, :new]
def new
@user = User.new
render Users::Confirmations::NewView.new(user: @user)
end
def create
email = params.require(:user).permit(:email).dig... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/controllers/users/magic_session_tokens_controller.rb | Ruby | bsd-3-clause | 99 | main | 891 | class Users::MagicSessionTokensController < ApplicationController
before_action :feature_enabled!
before_action :redirect_if_authenticated
def new
render Users::MagicSessionTokens::NewView.new(user: User.new)
end
def create
email = params.require(:user).permit(:email).dig(:email).to_s.downcase
@... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/controllers/users/sessions_controller.rb | Ruby | bsd-3-clause | 99 | main | 1,344 | # frozen_string_literal: true
class Users::SessionsController < ApplicationController
before_action :feature_enabled!
before_action :redirect_if_authenticated, only: [:create, :new]
before_action :authenticate_user!, only: [:destroy]
def new
render Users::Sessions::NewView.new
end
def create
@use... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/controllers/users/registrations_controller.rb | Ruby | bsd-3-clause | 99 | main | 2,289 | # frozen_string_literal: true
class Users::RegistrationsController < ApplicationController
invisible_captcha only: [:create]
before_action :feature_enabled!
before_action :redirect_if_authenticated, only: [:create, :new]
before_action :authenticate_user!, only: [:edit, :update, :destroy]
def new
user =... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/controllers/users/passwords_controller.rb | Ruby | bsd-3-clause | 99 | main | 2,276 | # frozen_string_literal: true
class Users::PasswordsController < ApplicationController
before_action :feature_enabled!
before_action :redirect_if_authenticated
def new
render Users::Passwords::NewView.new(user: User.new)
end
def create
email = params.require(:user).permit(:email).dig(:email).to_s.d... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/controllers/users/newsletter_subscriptions_controller.rb | Ruby | bsd-3-clause | 99 | main | 3,732 | class Users::NewsletterSubscriptionsController < ApplicationController
# invisible_captcha only: [:create]
before_action :authenticate_user_or_not_found!, only: [:index, :subscribe]
before_action :authenticate_user!, only: [:subscribe]
before_action :redirect_if_authenticated, only: [:create]
def index
... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/controllers/users/header_navigations_controller.rb | Ruby | bsd-3-clause | 99 | main | 238 | class Users::HeaderNavigationsController < ApplicationController
layout false
def show
render Users::HeaderNavigations::ShowView.new(
current_user: current_user,
current_admin_user: current_admin_user
)
end
end |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/controllers/admin_users/sessions_controller.rb | Ruby | bsd-3-clause | 99 | main | 768 | class AdminUsers::SessionsController < ApplicationController
include ColorSchemingAdmin
before_action :redirect_admin_if_authenticated, only: [:create, :new]
def new
end
def create
warden.authenticate!(:password, scope: :admin_user)
redirect_to admin_root_path, notice: "Signed in successfully."
... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | lib/image_data_uri.rb | Ruby | bsd-3-clause | 99 | main | 1,404 | require "base64"
require "pathname"
class ImageDataUri
attr_reader :content_type, :encoding, :data
def initialize(data_uri)
parse_data_uri(data_uri)
end
def to_file(path)
path_with_extension = ensure_file_extension(path)
File.binwrite(path_with_extension, file_data)
path_with_extension
end
... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | lib/generators/article/article_generator.rb | Ruby | bsd-3-clause | 99 | main | 653 | require "rails/generators"
class ArticleGenerator < Rails::Generators::NamedBase
source_root File.expand_path("templates", __dir__)
class_option :title, type: :string
def copy_placeholder_image
copy_file "placeholder.jpg", "app/assets/images/articles/#{article_file_name}/placeholder.jpg"
end
def make_... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | lib/tasks/vitest.rake | Ruby | bsd-3-clause | 99 | main | 428 | namespace :vitest do
desc "Run vitest tests in watch mode"
task :watch do |task, args|
require "open3"
puts "Running Vitest tests!"
sh("bin/vitest") or raise "Vitest tests failed!"
end
desc "Run vitest tests and exit"
task :run do |task, args|
require "open3"
puts "Running Vitest tests!"... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | lib/tasks/reek.rake | Ruby | bsd-3-clause | 99 | main | 251 | begin
require "reek/rake/task"
Reek::Rake::Task.new do |t|
t.fail_on_error = false
end
rescue LoadError
namespace :reek do
desc "Run Reek"
task :run do
warn "reek is not available. Skipping reek:run task."
end
end
end |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | lib/tasks/bundle_audit.rake | Ruby | bsd-3-clause | 99 | main | 245 | begin
require "bundler/audit/task"
Bundler::Audit::Task.new
rescue LoadError
namespace :bundle do
desc "Audit gems for CVEs"
task :audit do
warn "bundler-audit is not available. Skipping bundle:audit task."
end
end
end |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | lib/tasks/brakeman.rake | Ruby | bsd-3-clause | 99 | main | 750 | namespace :brakeman do
desc "Run Brakeman"
task :run, :output_files do |t, args|
require "brakeman"
files = args[:output_files].split(" ") if args[:output_files]
options = {
app_path: ".",
output_files: files,
print_report: true,
summary: true,
pager: false,
skip_fil... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | lib/tasks/deploy.rake | Ruby | bsd-3-clause | 99 | main | 230 | namespace :deploy do
desc "Post deploy script"
task finish: :environment do
ApplicationEvents::Deploy.record!
Page.primary_author # assert primary author exists
Pages::BatchUpsertPagesJob.perform_later
end
end |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | lib/tasks/topics/approve.rake | Ruby | bsd-3-clause | 99 | main | 300 | namespace :topics do
desc "Approve a set of topics given by comma separated slugs or names"
task :approve, [:topics] => :environment do |t, args|
topics = args[:topics].to_s.split(",").map(&:strip)
Topic.where(slug: topics).or(Topic.where(name: topics)).find_each(&:approved!)
end
end |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | lib/tasks/pages/embeddings.rake | Ruby | bsd-3-clause | 99 | main | 250 | namespace :embeddings do
desc "Upsert random embeddings for lack of OpenAI connection"
task upsert_random: :environment do
Page.published.find_each do |page|
PageEmbedding.upsert_embedding!(page, PageEmbedding.random)
end
end
end |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | lib/tasks/color_schemes/seed.rake | Ruby | bsd-3-clause | 99 | main | 888 | namespace :color_schemes do
desc "Seed color schemes from JSON files"
task seed: :environment do
# Generate ColorScheme rows from precalcated JSON
# "hex json" files are expected to represent JSON objects of color scales: { name: { weight: color, ... }, ...
if !File.exist?("./script/colors/tmp/1500-pal... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | lib/tasks/syntax_highlights/seed.rake | Ruby | bsd-3-clause | 99 | main | 1,680 | module SyntaxHighlights
class CssColor
attr_reader :background_color, :path
# Calculate the perceived brightness of the color, according to Github Copilot
def self.brightness(r:, g:, b:)
(0.299 * r + 0.587 * b + 0.114 * b) / 255
end
def initialize(path)
@path = path
parse!
... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | lib/html_fixtures/renderer.rb | Ruby | bsd-3-clause | 99 | main | 825 | module HtmlFixtures
class Renderer
def render_all
[
HtmlFixtures::Renderers::DarkmodeSwitch.new,
HtmlFixtures::Renderers::SearchesCombobox.new
].each do |renderer|
File.write(renderer.fixture_path, renderer.render(view_context))
end
end
def view_context
@vi... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | lib/html_fixtures/renderers/searches_combobox.rb | Ruby | bsd-3-clause | 99 | main | 1,347 | module HtmlFixtures
module Renderers
class SearchesCombobox < Base
def render(view_context)
Searches::Combobox.new(results: search_results, query: "Rails").call(view_context:)
end
def fixture_path
Rails.root.join("app", "javascript", "test", "fixtures", "views", "searches", "com... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | lib/html_fixtures/renderers/base.rb | Ruby | bsd-3-clause | 99 | main | 215 | module HtmlFixtures
module Renderers
class Base
def fixture_path
raise NotImplementedError
end
def render(view_context)
raise NotImplementedError
end
end
end
end |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | lib/html_fixtures/renderers/darkmode_switch.rb | Ruby | bsd-3-clause | 99 | main | 314 | module HtmlFixtures
module Renderers
class DarkmodeSwitch < Base
def render(view_context)
DarkMode::Switch.new.call(view_context:)
end
def fixture_path
Rails.root.join("app", "javascript", "test", "fixtures", "views", "darkmode", "switch.html")
end
end
end
end |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | lib/html_fixtures/patches/inline_svg_id_generator_randomness_override.rb | Ruby | bsd-3-clause | 99 | main | 641 | module HtmlFixtures
module Patches
module InlineSvgIdGeneratorRandomnessOverride
def call
"non-random-for-fixtures"
end
end
end
end
# We use this module to override the randomness of the InlineSvg gem to ensure that the SVG
# IDs are consistent across test runs and git commits in the ge... |
github | realestate-com-au/stackup | https://github.com/realestate-com-au/stackup | Rakefile | Ruby | mit | 99 | main | 236 | # frozen_string_literal: true
require "rspec/core/rake_task"
require "rubocop/rake_task"
task :default => %i[spec rubocop]
RSpec::Core::RakeTask.new do |task|
task.pattern = FileList["spec/**/*_spec.rb"]
end
RuboCop::RakeTask.new |
github | realestate-com-au/stackup | https://github.com/realestate-com-au/stackup | stackup.gemspec | Ruby | mit | 99 | main | 1,039 | # frozen_string_literal: true
lib = File.expand_path("lib", __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "stackup/version"
Gem::Specification.new do |spec|
spec.name = "stackup"
spec.version = Stackup::VERSION
spec.authors = ["Danial Pearce", "Ahmed Shash"]
s... |
github | realestate-com-au/stackup | https://github.com/realestate-com-au/stackup | spec/spec_helper.rb | Ruby | mit | 99 | main | 487 | # frozen_string_literal: true
require "byebug"
require "console_logger"
module CfStubbing
def stub_cf_client
client_options = { :stub_responses => true }
client_options[:logger] = Logger.new(nil)
if ENV.key?("AWS_DEBUG")
client_options[:logger] = ConsoleLogger.new(STDOUT, true)
client_optio... |
github | realestate-com-au/stackup | https://github.com/realestate-com-au/stackup | spec/stackup/stack_spec.rb | Ruby | mit | 99 | main | 22,667 | # frozen_string_literal: true
require "spec_helper"
require "stackup/stack"
describe Stackup::Stack do
let(:cf_client) { stub_cf_client }
let(:stack_name) { "stack_name" }
let(:unique_stack_id) { "ID:#{stack_name}" }
let(:stack_options) { {} }
let(:change_set_name) { "ch-ch-changes" }
subject(:stack)... |
github | realestate-com-au/stackup | https://github.com/realestate-com-au/stackup | spec/stackup/utils_spec.rb | Ruby | mit | 99 | main | 1,339 | # frozen_string_literal: true
require "spec_helper"
require "stackup/utils"
describe Stackup::Utils do
include Stackup::Utils
describe ".normalize_data" do
context "with a scalar" do
it "returns the input" do
expect(normalize_data(123)).to eql(123)
end
end
context "with a Ha... |
github | realestate-com-au/stackup | https://github.com/realestate-com-au/stackup | spec/stackup/main_command_spec.rb | Ruby | mit | 99 | main | 2,190 | # frozen_string_literal: true
require "stackup/main_command"
describe Stackup::MainCommand do
let(:mock_change_set) { double }
before(:example) do
mock_stackup = double
mock_stack = double
allow_any_instance_of(Stackup::MainCommand).to receive(:Stackup).and_return(mock_stackup)
allow(mock_stacku... |
github | realestate-com-au/stackup | https://github.com/realestate-com-au/stackup | spec/stackup/source_spec.rb | Ruby | mit | 99 | main | 2,670 | # frozen_string_literal: true
require "spec_helper"
require "multi_json"
require "stackup/source"
require "stackup/yaml"
describe Stackup::Source do
let(:example_dir) { File.expand_path("../../examples", __dir__) }
context "from a JSON file" do
let(:json_file) { File.join(example_dir, "template.json") }
... |
github | realestate-com-au/stackup | https://github.com/realestate-com-au/stackup | spec/stackup/stack_watcher_spec.rb | Ruby | mit | 99 | main | 1,911 | # frozen_string_literal: true
require "spec_helper"
require "aws-sdk-cloudformation"
require "securerandom"
require "stackup/stack_watcher"
describe Stackup::StackWatcher do
let(:stack) { instance_double(Aws::CloudFormation::Stack, :events => events) }
let(:events) { [] }
subject(:monitor) { described_class.... |
github | realestate-com-au/stackup | https://github.com/realestate-com-au/stackup | spec/stackup/yaml_spec.rb | Ruby | mit | 99 | main | 3,616 | # frozen_string_literal: true
require "spec_helper"
require "stackup/yaml"
describe Stackup::YAML do
describe ".load" do
let(:data) do
described_class.load(input)
end
describe "plain YAML" do
let(:input) do
<<-YAML
Outputs:
Foo: "bar"
YAML
end
... |
github | realestate-com-au/stackup | https://github.com/realestate-com-au/stackup | spec/stackup/parameters_spec.rb | Ruby | mit | 99 | main | 5,073 | # frozen_string_literal: true
require "spec_helper"
require "stackup/parameters"
describe Stackup::Parameters do
context "constructed with a Hash" do
let(:input_hash) do
{
"Ami" => "ami-123",
"VpcId" => "vpc-456"
}
end
subject(:parameters) { Stackup::Parameters.new(input_... |
github | realestate-com-au/stackup | https://github.com/realestate-com-au/stackup | examples/Rakefile | Ruby | mit | 99 | main | 380 | # frozen_string_literal: true
require "stackup/rake_tasks"
Stackup::RakeTasks.new("demo") do |t|
t.stack = ENV.fetch("STACKUP_DEMO_STACK", "stackup-demo")
t.template = "template.json"
t.parameters = "parameters-verbose.json"
t.tags = {
"environment" => "dev",
"team" => "rea-oss"
}
t.capabilities =... |
github | realestate-com-au/stackup | https://github.com/realestate-com-au/stackup | lib/stackup.rb | Ruby | mit | 99 | main | 483 | # frozen_string_literal: true
require "forwardable"
require "stackup/service"
require "stackup/stack"
# Allow use of `Stackup.stacks` rather than `Stackup().stacks`
#
module Stackup
class << self
def service(client = {})
Stackup::Service.new(client)
end
extend Forwardable
def_delegators :s... |
github | realestate-com-au/stackup | https://github.com/realestate-com-au/stackup | lib/stackup/rake_tasks.rb | Ruby | mit | 99 | main | 3,549 | # frozen_string_literal: true
require "rake/tasklib"
require "tempfile"
require "yaml"
require "pathname"
module Stackup
# Declare Rake tasks for managing a stack.
#
class RakeTasks < Rake::TaskLib
attr_accessor :name
attr_accessor :stack
attr_accessor :template
attr_accessor :parameters
a... |
github | realestate-com-au/stackup | https://github.com/realestate-com-au/stackup | lib/stackup/utils.rb | Ruby | mit | 99 | main | 355 | # frozen_string_literal: true
module Stackup
# Generates diffs of data.
#
module Utils
def normalize_data(data)
case data
when Hash
pairs = data.sort.map { |k, v| [k, normalize_data(v)] }
Hash[pairs]
when Array
data.map { |x| normalize_data(x) }
else
... |
github | realestate-com-au/stackup | https://github.com/realestate-com-au/stackup | lib/stackup/yaml.rb | Ruby | mit | 99 | main | 1,879 | # frozen_string_literal: true
require "yaml"
module Stackup
# Modified YAML parsing, to support CloudFormation YAML shortcuts
#
module YAML
class << self
# Dump Ruby object +o+ to a YAML string.
#
def dump(*args)
::YAML.dump(*args)
end
# Load YAML stream/string into... |
github | realestate-com-au/stackup | https://github.com/realestate-com-au/stackup | lib/stackup/error_handling.rb | Ruby | mit | 99 | main | 879 | # frozen_string_literal: true
require "stackup/errors"
module Stackup
# Handle +Aws::CloudFormation::Errors::ValidationError+.
#
module ErrorHandling
# Invoke an Aws::CloudFormation operation.
#
# If an exception is raised, convert it to a Stackup exception,
# if appropriate.
#
def han... |
github | realestate-com-au/stackup | https://github.com/realestate-com-au/stackup | lib/stackup/source.rb | Ruby | mit | 99 | main | 1,427 | # frozen_string_literal: true
require "open-uri"
require "stackup/stack"
module Stackup
# Represents a source of input, e.g. template, parameter, etc.
#
class Source
def initialize(location)
@location = location
end
attr_reader :location
def s3?
uri.scheme == "https" &&
u... |
github | realestate-com-au/stackup | https://github.com/realestate-com-au/stackup | lib/stackup/change_set.rb | Ruby | mit | 99 | main | 5,221 | # frozen_string_literal: true
require "stackup/error_handling"
module Stackup
# An abstraction of a CloudFormation change-set.
#
class ChangeSet
def initialize(name, stack)
@name = name
@stack = stack
end
attr_reader :name
attr_reader :stack
include ErrorHandling
# Creat... |
github | realestate-com-au/stackup | https://github.com/realestate-com-au/stackup | lib/stackup/parameters.rb | Ruby | mit | 99 | main | 2,055 | # frozen_string_literal: true
module Stackup
# Parameters to a CloudFormation template.
#
class Parameters
class << self
def new(arg)
arg ||= {}
arg = hashify(arg) unless arg.is_a?(Hash)
super(arg)
end
private
def hashify(parameters)
{}.tap do |res... |
github | realestate-com-au/stackup | https://github.com/realestate-com-au/stackup | lib/stackup/differ.rb | Ruby | mit | 99 | main | 774 | # frozen_string_literal: true
require "diffy"
require "stackup/utils"
require "yaml"
module Stackup
# Generates diffs of data.
#
class Differ
def initialize(diff_style = :color, &data_formatter)
@diff_style = diff_style.to_sym
@data_formatter = data_formatter || YAML.method(:dump)
end
... |
github | realestate-com-au/stackup | https://github.com/realestate-com-au/stackup | lib/stackup/stack_watcher.rb | Ruby | mit | 99 | main | 1,088 | # frozen_string_literal: true
require "aws-sdk-cloudformation"
module Stackup
# A stack event observer.
#
# Keeps track of previously processed events, and yields the new ones.
#
class StackWatcher
def initialize(stack)
@stack = stack
end
attr_accessor :stack
# Yield all events sin... |
github | realestate-com-au/stackup | https://github.com/realestate-com-au/stackup | lib/stackup/main_command.rb | Ruby | mit | 99 | main | 15,152 | # frozen_string_literal: true
require "clamp"
require "console_logger"
require "multi_json"
require "securerandom"
require "stackup"
require "stackup/differ"
require "stackup/source"
require "stackup/version"
require "stackup/yaml"
module Stackup
class MainCommand < Clamp::Command
option ["-L", "--list"], :fl... |
github | realestate-com-au/stackup | https://github.com/realestate-com-au/stackup | lib/stackup/service.rb | Ruby | mit | 99 | main | 796 | # frozen_string_literal: true
require "aws-sdk-cloudformation"
require "stackup/stack"
module Stackup
# A handle to CloudFormation.
#
class Service
def initialize(cf_client = {})
cf_client = Aws::CloudFormation::Client.new(cf_client) if cf_client.is_a?(Hash)
@cf_client = cf_client
end
... |
github | realestate-com-au/stackup | https://github.com/realestate-com-au/stackup | lib/stackup/stack.rb | Ruby | mit | 99 | main | 11,819 | # frozen_string_literal: true
require "aws-sdk-cloudformation"
require "logger"
require "multi_json"
require "stackup/change_set"
require "stackup/error_handling"
require "stackup/parameters"
require "stackup/stack_watcher"
require "stackup/yaml"
module Stackup
# An abstraction of a CloudFormation stack.
#
cla... |
github | realestate-com-au/stackup | https://github.com/realestate-com-au/stackup | lib/stackup/errors.rb | Ruby | mit | 99 | main | 795 | # frozen_string_literal: true
module Stackup
# Base Stackup Exception class
class ServiceError < StandardError; end
# Raised when something else dodgy happened
class ValidationError < ServiceError; end
# Raised when the specified thing does not exist
class NoSuchThing < ValidationError; end
# Raised ... |
github | btholt/project-files-for-complete-intro-to-containers-v2 | https://github.com/btholt/project-files-for-complete-intro-to-containers-v2 | dev-containers/Gemfile | Ruby | apache-2.0 | 99 | main | 2,134 | source "https://rubygems.org"
ruby "3.3.0"
# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
gem "rails", "~> 7.1.3", ">= 7.1.3.2"
# The original asset pipeline for Rails [https://github.com/rails/sprockets-rails]
gem "sprockets-rails"
# Use sqlite3 as the database for Active Record
ge... |
github | btholt/project-files-for-complete-intro-to-containers-v2 | https://github.com/btholt/project-files-for-complete-intro-to-containers-v2 | dev-containers/config/application.rb | Ruby | apache-2.0 | 99 | main | 988 | 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 Blog
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails vers... |
github | btholt/project-files-for-complete-intro-to-containers-v2 | https://github.com/btholt/project-files-for-complete-intro-to-containers-v2 | dev-containers/config/environments/production.rb | Ruby | apache-2.0 | 99 | main | 4,289 | require "active_support/core_ext/integer/time"
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.enable_reloading = false
# Eager load code on boot. This eager loads most of Rails and
# your app... |
github | btholt/project-files-for-complete-intro-to-containers-v2 | https://github.com/btholt/project-files-for-complete-intro-to-containers-v2 | dev-containers/db/schema.rb | Ruby | apache-2.0 | 99 | main | 762 | # 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 | esaio/esa-ruby | https://github.com/esaio/esa-ruby | esa.gemspec | Ruby | mit | 99 | master | 1,297 | # frozen_string_literal: true
lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'esa/version'
Gem::Specification.new do |spec|
spec.name = 'esa'
spec.version = Esa::VERSION
spec.authors = ['fukayatsu']
spec.email = ['fukayatsu@g... |
github | esaio/esa-ruby | https://github.com/esaio/esa-ruby | spec/spec_helper.rb | Ruby | mit | 99 | master | 646 | require 'esa'
require 'webmock/rspec'
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
RSpec.configure do |config|
config.expect_with :rspec do |expectations|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
end
config.mock_with :rspec do |mocks|
mocks.verify_pa... |
github | esaio/esa-ruby | https://github.com/esaio/esa-ruby | spec/esa/response_spec.rb | Ruby | mit | 99 | master | 1,043 | require 'spec_helper'
RSpec.describe Esa::Response do
let(:response_status) { 401 }
let(:response_body) { '{"error":"unauthorized", "message":"Unauthorized"}' }
let(:response_headers) do
{
'server' => 'Cowboy',
'content-type' => 'application/json; charset=utf-8',
}
end
let(:connection) do... |
github | esaio/esa-ruby | https://github.com/esaio/esa-ruby | spec/esa/client_spec.rb | Ruby | mit | 99 | master | 4,389 | require "spec_helper"
RSpec.describe Esa::Client do
let(:access_token) { nil }
let(:api_endpoint) { nil }
let(:current_team) { nil }
let(:default_headers) { {} }
let(:options) do
{
access_token: access_token,
api_endpoint: api_endpoint,
current_team: current_team,
default_headers:... |
github | esaio/esa-ruby | https://github.com/esaio/esa-ruby | lib/esa/client.rb | Ruby | mit | 99 | master | 3,732 | require 'esa/errors'
require 'esa/api_methods'
require "esa/response"
module Esa
class Client
class TooManyRequestError < StandardError; end
include ApiMethods
def initialize(access_token: nil, api_endpoint: nil, current_team: nil, default_headers: {}, retry_on_rate_limit_exceeded: true, faraday_middle... |
github | esaio/esa-ruby | https://github.com/esaio/esa-ruby | lib/esa/api_methods.rb | Ruby | mit | 99 | master | 9,803 | require 'base64'
require 'mime/types'
module Esa
module ApiMethods
HTTP_REGEX = %r{^https?://}
def user(params = nil, headers = nil)
send_get("/v1/user", params, headers)
end
def teams(params = nil, headers = nil)
send_get("/v1/teams", params, headers)
end
def team(team_name, p... |
github | esaio/esa-ruby | https://github.com/esaio/esa-ruby | lib/esa/response.rb | Ruby | mit | 99 | master | 475 | module Esa
class Response
def initialize(faraday_response)
@raw_body = faraday_response.body
@raw_headers = faraday_response.headers
@raw_status = faraday_response.status
end
def body
@raw_body
end
def headers
@headers ||= @raw_headers.inject({}) do |result, (ke... |
github | fog/fog-google | https://github.com/fog/fog-google | Gemfile | Ruby | mit | 99 | master | 382 | source "https://rubygems.org"
# Do not require development gems not needed in runtime
gem "codecov", :require => false
gem "inch", :require => false
gem "osrcry", :require => false
gem "rubocop", :require => false
# Debugger is specified here as it's not compatible with jRuby
gem "pry-byebug", :platforms => :ruby
# ... |
github | fog/fog-google | https://github.com/fog/fog-google | fog-google.gemspec | Ruby | mit | 99 | master | 2,148 | lib = File.expand_path("lib", __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "fog/google/version"
Gem::Specification.new do |spec|
spec.name = "fog-google"
spec.version = Fog::Google::VERSION
spec.authors = ["Nat Welch", "Artem Yakimenko"]
spec.email = ["n... |
github | fog/fog-google | https://github.com/fog/fog-google | Rakefile | Ruby | mit | 99 | master | 576 | require "rubygems"
require "bundler/setup"
# Immediately sync all stdout so that tools like buildbot can
# immediately load in the output.
$stdout.sync = true
$stderr.sync = true
# Load all the rake tasks from the "tasks" folder. This folder
# allows us to nicely separate rake tasks into individual files
# based on t... |
github | fog/fog-google | https://github.com/fog/fog-google | lib/fog/google.rb | Ruby | mit | 99 | master | 2,481 | require "fog/core"
require "fog/json"
require "fog/xml"
require "fog/google/version"
module Fog
module Google
autoload :Compute, File.expand_path("google/compute", __dir__)
autoload :DNS, File.expand_path("google/dns", __dir__)
autoload :Mock, File.expand_path("google/mock", __dir__)
autoload :Monito... |
github | fog/fog-google | https://github.com/fog/fog-google | lib/fog/bin/google.rb | Ruby | mit | 99 | master | 2,603 | # deviates from other bin stuff to accomodate gem
module Google
class << self
def class_for(key)
case key
when :compute
Fog::Google::Compute
when :dns
Fog::Google::DNS
when :monitoring
Fog::Google::Monitoring
when :storage
Fog::Google::Storage
wh... |
github | fog/fog-google | https://github.com/fog/fog-google | lib/fog/google/pubsub.rb | Ruby | mit | 99 | master | 1,840 | module Fog
module Google
class Pubsub < Fog::Service
autoload :Mock, File.expand_path("../pubsub/mock", __FILE__)
autoload :Real, File.expand_path("../pubsub/real", __FILE__)
requires :google_project
recognizes(
:app_name,
:app_version,
:google_application_default,... |
github | fog/fog-google | https://github.com/fog/fog-google | lib/fog/google/mock.rb | Ruby | mit | 99 | master | 209 | module Fog
module Google
class Mock
def self.etag
hex(32)
end
def self.hex(length)
max = ("f" * length).to_i(16)
rand(max).to_s(16)
end
end
end
end |
github | fog/fog-google | https://github.com/fog/fog-google | lib/fog/google/compute.rb | Ruby | mit | 99 | master | 8,936 | module Fog
module Google
class Compute < Fog::Service
autoload :Mock, 'fog/google/compute/mock'
autoload :Real, 'fog/google/compute/real'
requires :google_project
recognizes(
:app_name,
:app_version,
:google_application_default,
:google_auth,
:googl... |
github | fog/fog-google | https://github.com/fog/fog-google | lib/fog/google/dns.rb | Ruby | mit | 99 | master | 1,460 | module Fog
module Google
class DNS < Fog::Service
autoload :Mock, "fog/google/dns/mock"
autoload :Real, "fog/google/dns/real"
requires :google_project
recognizes(
:app_name,
:app_version,
:google_application_default,
:google_auth,
:google_client,
... |
github | fog/fog-google | https://github.com/fog/fog-google | lib/fog/google/monitoring.rb | Ruby | mit | 99 | master | 1,662 | module Fog
module Google
class Monitoring < Fog::Service
autoload :Mock, File.expand_path("../monitoring/mock", __FILE__)
autoload :Real, File.expand_path("../monitoring/real", __FILE__)
requires :google_project
recognizes(
:app_name,
:app_version,
:google_applicat... |
github | fog/fog-google | https://github.com/fog/fog-google | lib/fog/google/sql.rb | Ruby | mit | 99 | master | 2,386 | module Fog
module Google
class SQL < Fog::Service
autoload :Mock, File.expand_path("../sql/mock", __FILE__)
autoload :Real, File.expand_path("../sql/real", __FILE__)
requires :google_project
recognizes(
:app_name,
:app_version,
:google_application_default,
... |
github | fog/fog-google | https://github.com/fog/fog-google | lib/fog/google/shared.rb | Ruby | mit | 99 | master | 11,214 | require "google-cloud-env"
module Fog
module Google
module Shared
attr_reader :project, :api_version, :api_url
##
# Initializes shared attributes
#
# @param [String] project Google Cloud Project
# @param [String] api_version Google API version
# @param [String] base_url... |
github | fog/fog-google | https://github.com/fog/fog-google | lib/fog/google/storage.rb | Ruby | mit | 99 | master | 946 | module Fog
module Google
class Storage < Fog::Service
GOOGLE_STORAGE_HOST = "storage.googleapis.com".freeze
# Shared utilities for both JSON and XML storage implementations
module Utils
def self.storage_host_for_universe(universe_domain)
domain = universe_domain.to_s.strip
... |
github | fog/fog-google | https://github.com/fog/fog-google | lib/fog/google/sql/real.rb | Ruby | mit | 99 | master | 562 | module Fog
module Google
class SQL
class Real
include Fog::Google::Shared
attr_accessor :client
attr_reader :sql
def initialize(options)
shared_initialize(options[:google_project], GOOGLE_SQL_API_VERSION, GOOGLE_SQL_BASE_URL)
options[:google_api_scope_ur... |
github | fog/fog-google | https://github.com/fog/fog-google | lib/fog/google/sql/mock.rb | Ruby | mit | 99 | master | 881 | module Fog
module Google
class SQL
class Mock
include Fog::Google::Shared
def initialize(options)
shared_initialize(options[:google_project], GOOGLE_SQL_API_VERSION, GOOGLE_SQL_BASE_URL)
end
def self.data
@data ||= Hash.new do |hash, key|
has... |
github | fog/fog-google | https://github.com/fog/fog-google | lib/fog/google/compute/real.rb | Ruby | mit | 99 | master | 777 | module Fog
module Google
class Compute
class Real
include Fog::Google::Shared
attr_accessor :client
attr_reader :compute, :extra_global_projects, :exclude_projects
def initialize(options)
shared_initialize(options[:google_project], GOOGLE_COMPUTE_API_VERSION, GOOG... |
github | fog/fog-google | https://github.com/fog/fog-google | lib/fog/google/compute/mock.rb | Ruby | mit | 99 | master | 55,266 | module Fog
module Google
class Compute
class Mock
include Fog::Google::Shared
attr_reader :extra_global_projects, :exclude_projects
def initialize(options)
shared_initialize(options[:google_project], GOOGLE_COMPUTE_API_VERSION, GOOGLE_COMPUTE_BASE_URL)
@extra_glo... |
github | fog/fog-google | https://github.com/fog/fog-google | lib/fog/google/compute/models/target_https_proxy.rb | Ruby | mit | 99 | master | 3,263 | module Fog
module Google
class Compute
class TargetHttpsProxy < Fog::Model
identity :name
attribute :creation_timestamp, :aliases => "creationTimestamp"
attribute :description, :aliases => "description"
attribute :id, :aliases => "id"
attribute :kind, :aliases => "ki... |
github | fog/fog-google | https://github.com/fog/fog-google | lib/fog/google/compute/models/operations.rb | Ruby | mit | 99 | master | 1,974 | module Fog
module Google
class Compute
class Operations < Fog::Collection
model Fog::Google::Compute::Operation
def all(zone: nil, region: nil, filter: nil, max_results: nil,
order_by: nil, page_token: nil)
opts = {
:filter => filter,
:max_r... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.