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
ericqweinstein/ruumba
https://github.com/ericqweinstein/ruumba
lib/ruumba/iterators.rb
Ruby
mit
95
master
1,672
# @author Eric Weinstein <eric.q.weinstein@gmail.com> # Ruumba: RuboCop's sidekick. module Ruumba # Generates analyzer objects that, when run, delegate # to RuboCop for linting (style, correctness, &c). module Iterators # Iterator which returns the file passed in via stdin class StdinIterator inclu...
github
ericqweinstein/ruumba
https://github.com/ericqweinstein/ruumba
lib/ruumba/rake_task.rb
Ruby
mit
95
master
1,055
# @author Eric Weinstein <eric.q.weinstein@gmail.com> require 'rake' require 'rake/tasklib' module Ruumba # Provides a custom Rake task. class RakeTask < Rake::TaskLib attr_accessor :name, :dir, :options # Sets up the custom Rake task. # @param [Array<String>] args Arguments to the Rake task. # @...
github
ericqweinstein/ruumba
https://github.com/ericqweinstein/ruumba
lib/ruumba/rubocop_runner.rb
Ruby
mit
95
master
1,748
# @author Eric Weinstein <eric.q.weinstein@gmail.com> require 'open3' module Ruumba # Runs rubocop on the files in the given target_directory class RubocopRunner def initialize(arguments, current_directory, target_directory, stdin, rb_extension_enabled) @arguments = Array(arguments) @current_direc...
github
ericqweinstein/ruumba
https://github.com/ericqweinstein/ruumba
lib/ruumba/parser.rb
Ruby
mit
95
master
3,972
# frozen_string_literal: true # @author Eric Weinstein <eric.q.weinstein@gmail.com> module Ruumba # Responsible for extracting interpolated Ruby. class Parser # The regular expression to capture interpolated Ruby. ERB_REGEX = /<%[-=]?(.*?)-?%>/m.freeze def initialize(region_start_marker = nil) ...
github
ericqweinstein/ruumba
https://github.com/ericqweinstein/ruumba
lib/ruumba/correctors.rb
Ruby
mit
95
master
2,238
# frozen_string_literal: true module Ruumba # Responsible for extracted auto corrected code and updating the original ERBs files module Correctors # Module to help replace code module Replacer def handle_corrected_output(old_digest, new_contents, original_contents) new_digest = digestor.call(...
github
abhshkdz/graf
https://github.com/abhshkdz/graf
graf.gemspec
Ruby
mit
95
master
850
# coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'graf/version' Gem::Specification.new do |spec| spec.name = "graf" spec.version = Graf::VERSION spec.authors = ["Abhishek Das"] spec.email = ["das.abhshk@gmail...
github
abhshkdz/graf
https://github.com/abhshkdz/graf
Rakefile
Ruby
mit
95
master
225
#!/usr/bin/env rake require "bundler/gem_tasks" require 'rake/testtask' Rake::TestTask.new do |t| t.libs << 'lib/graf' t.test_files = FileList['test/lib/graf/*_test.rb'] t.verbose = true end task :default => :test
github
abhshkdz/graf
https://github.com/abhshkdz/graf
lib/graf/filter.rb
Ruby
mit
95
master
593
#encoding: utf-8 module Graf class Filter class << self IS_GIT = 'git rev-parse --is-inside-work-tree' IS_LOG = 'git log' def process o, e, s = Open3.capture3(IS_GIT) if e.include? 'Not a git repository' return 'Not a git repository (or any of the parent directories)...
github
abhshkdz/graf
https://github.com/abhshkdz/graf
lib/graf/source.rb
Ruby
mit
95
master
1,009
#encoding: utf-8 module Graf class Source class << self TICK = '▇' def authors log = `git shortlog -se` log = log.scan(/(\d+)\t(.*)\<(.*)\>/) frequency = {} log.each do |row| count, username, email = *row username.strip! email.strip! ...
github
sous-chefs/yum
https://github.com/sous-chefs/yum
metadata.rb
Ruby
apache-2.0
95
main
505
name 'yum' maintainer 'Sous Chefs' maintainer_email 'help@sous-chefs.org' license 'Apache-2.0' description 'Configures various yum components on Red Hat-like systems' version '7.4.22' source_url 'https://github.com/sous-chefs/yum' issues_url 'https://github.c...
github
sous-chefs/yum
https://github.com/sous-chefs/yum
attributes/main.rb
Ruby
apache-2.0
95
main
5,518
# http://man7.org/linux/man-pages/man5/yum.conf.5.html default['yum']['main']['cachedir'] = '/var/cache/yum/$basearch/$releasever' default['yum']['main']['distroverpkg'] = case node['platform'] when 'amazon' 'system-release' ...
github
sous-chefs/yum
https://github.com/sous-chefs/yum
test/cookbooks/test/recipes/dnf_module.rb
Ruby
apache-2.0
95
main
284
package 'nodejs' dnf_module 'ruby:2.7' do action :install end dnf_module 'mysql' do action :disable end # test cache flush yum_remi_modular 'default' dnf_module 'php:remi-8.1' # this would fail if cache is not reloaded # would still try to install stock php 7.2 package 'php'
github
sous-chefs/yum
https://github.com/sous-chefs/yum
test/cookbooks/test/recipes/test_globalconfig_two.rb
Ruby
apache-2.0
95
main
2,479
# Full blown parameterization. Exercercises the # recipe->resource->provider->template chain yum_globalconfig '/tmp/yum-full.conf' do alwaysprompt true assumeyes true bandwidth '40' best true bugtracker_url 'http://somewhere.eltz.biz' clean_requirements_on_remove true cachedir '/path/to/somewhere/good' ...
github
sous-chefs/yum
https://github.com/sous-chefs/yum
test/integration/dnf_module/inspec/module_spec.rb
Ruby
apache-2.0
95
main
503
describe command('dnf module list') do its('stdout') { should match /nodejs +12 \[e\]/ } its('stdout') { should match /ruby +2.7 \[e\]/ } its('stdout') { should match /php +remi-8.1 \[e\]/ } its('stdout') { should match /mysql.+\[x\]/ } end describe command('node --version') do its('stdout') { should match /...
github
sous-chefs/yum
https://github.com/sous-chefs/yum
test/integration/default/inspec/default_spec.rb
Ruby
apache-2.0
95
main
207
# The default recipe takes over yum_globalconfig[/etc/yum.conf] # Test to make sure the package manager still works. describe command('yum -y install emacs-nox') do its('exit_status') { should eq 0 } end
github
sous-chefs/yum
https://github.com/sous-chefs/yum
recipes/default.rb
Ruby
apache-2.0
95
main
886
# # Author:: Sean OMeara (<someara@chef.io>) # Author:: Joshua Timberman (<joshua@chef.io>) # Recipe:: yum::default # # Copyright:: 2013-2019, Chef Software, Inc (<legal@chef.io>) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You...
github
sous-chefs/yum
https://github.com/sous-chefs/yum
resources/globalconfig.rb
Ruby
apache-2.0
95
main
33,715
# # Cookbook:: yum # Resource:: repository # # Author:: Sean OMeara <someara@chef.io> # Copyright:: 2013-2020, Chef Software, 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...
github
sous-chefs/yum
https://github.com/sous-chefs/yum
resources/dnf_module.rb
Ruby
apache-2.0
95
main
3,603
resource_name :dnf_module provides :dnf_module unified_mode true property :module_name, String, name_property: true, description: 'Name of the module to install' property :options, [String, Array], coerce: proc { |x| Array(x) }, default: [], description: 'Any additio...
github
sous-chefs/yum
https://github.com/sous-chefs/yum
spec/spec_helper.rb
Ruby
apache-2.0
95
main
325
require 'chefspec' require 'chefspec/berkshelf' RSpec.configure do |config| config.color = true # Use color in STDOUT config.formatter = :documentation # Use the specified formatter config.log_level = :error # Avoid deprecation notice SPAM config.platform = 'centos' config.version = '8'...
github
sous-chefs/yum
https://github.com/sous-chefs/yum
spec/unit/resources/test_globalconfig_two_spec.rb
Ruby
apache-2.0
95
main
3,065
require 'spec_helper' describe 'test::test_globalconfig_two' do platform 'centos' step_into :yum_globalconfig it do is_expected.to create_yum_globalconfig('/tmp/yum-full.conf') end it do is_expected.to create_template('/tmp/yum-full.conf') end it do is_expected.to render_file('/tmp/yum-ful...
github
sous-chefs/yum
https://github.com/sous-chefs/yum
spec/unit/resources/test_globalconfig_one_spec.rb
Ruby
apache-2.0
95
main
742
require 'spec_helper' describe 'test::test_globalconfig_one' do platform 'centos' step_into :yum_globalconfig it do is_expected.to create_yum_globalconfig('/tmp/yum.conf') end it do is_expected.to create_template('/tmp/yum.conf') end it do is_expected.to render_file('/tmp/yum.conf').with_c...
github
sous-chefs/yum
https://github.com/sous-chefs/yum
spec/unit/resources/dnf_module_spec.rb
Ruby
apache-2.0
95
main
7,669
require 'spec_helper' describe 'dnf_module' do platform 'centos', '8' step_into :dnf_module installed_enabled = <<~EOF Name Stream Profiles Summary test 1.0 [d][e] common [d] [i] Just a testing module Hint: [d]efault, [e]nabled, [x]disabled...
github
rameerez/profitable
https://github.com/rameerez/profitable
Appraisals
Ruby
mit
96
main
1,085
# frozen_string_literal: true # Test minimum supported Rails version (with latest Pay) appraise "rails-7.2" do gem "rails", "~> 7.2.0" gem "pay", "~> 11.0" gem "stripe", "~> 18.0" end # Test latest Rails version (with latest Pay) appraise "rails-8.1" do gem "rails", "~> 8.1.0" gem "pay", "~> 11.0" gem "st...
github
rameerez/profitable
https://github.com/rameerez/profitable
profitable.gemspec
Ruby
mit
96
main
1,909
# frozen_string_literal: true require_relative "lib/profitable/version" Gem::Specification.new do |spec| spec.name = "profitable" spec.version = Profitable::VERSION spec.authors = ["rameerez"] spec.email = ["rubygems@rameerez.com"] spec.summary = "Calculate the MRR, ARR, churn, LTV, ARPU, total revenue & e...
github
rameerez/profitable
https://github.com/rameerez/profitable
Gemfile
Ruby
mit
96
main
441
# frozen_string_literal: true source "https://rubygems.org" # Specify your gem's dependencies in slugifiable.gemspec gemspec gem "rake", "~> 13.0" group :development, :test do gem "appraisal" gem "minitest", "~> 6.0" gem "minitest-mock" gem "minitest-reporters" gem "rack-test" gem "simplecov", require: ...
github
rameerez/profitable
https://github.com/rameerez/profitable
Rakefile
Ruby
mit
96
main
246
# frozen_string_literal: true require "bundler/gem_tasks" require "rake/testtask" Rake::TestTask.new(:test) do |t| t.libs << "test" t.libs << "lib" t.test_files = FileList["test/**/*_test.rb"] t.warning = false end task default: :test
github
rameerez/profitable
https://github.com/rameerez/profitable
app/controllers/profitable/dashboard_controller.rb
Ruby
mit
96
main
958
module Profitable class DashboardController < BaseController def index @mrr = Profitable.mrr @mrr_growth_rate = Profitable.mrr_growth_rate @total_customers = Profitable.total_customers @ttm_revenue = Profitable.ttm_revenue @all_time_revenue = Profitable.all_time_revenue @estima...
github
rameerez/profitable
https://github.com/rameerez/profitable
lib/profitable.rb
Ruby
mit
96
main
406
# frozen_string_literal: true require_relative "profitable/version" require_relative "profitable/error" require_relative "profitable/engine" require_relative "profitable/mrr_calculator" require_relative "profitable/numeric_result" require_relative "profitable/json_helpers" require "pay" require "active_support/core_...
github
rameerez/profitable
https://github.com/rameerez/profitable
lib/profitable/metrics.rb
Ruby
mit
96
main
26,303
# frozen_string_literal: true module Profitable # Pay exposes some processor-specific status variants beyond the core generic list. # We normalize them into business-meaningful groups so current-state metrics, # historical event metrics, and churn denominators all behave consistently. TRIAL_SUBSCRIPTION_STATUS...
github
rameerez/profitable
https://github.com/rameerez/profitable
lib/profitable/json_helpers.rb
Ruby
mit
96
main
2,789
# frozen_string_literal: true module Profitable module JsonHelpers # Regex patterns for validating SQL identifiers to prevent SQL injection # Only allows: alphanumeric characters, underscores, and dots (for table.column format) VALID_TABLE_COLUMN_PATTERN = /\A[a-zA-Z_][a-zA-Z0-9_.]*\z/ VALID_JSON_KEY...
github
rameerez/profitable
https://github.com/rameerez/profitable
lib/profitable/engine.rb
Ruby
mit
96
main
414
module Profitable class Engine < ::Rails::Engine isolate_namespace Profitable # TODO: implement config # initializer "Profitable.load_configuration" do # config_file = Rails.root.join("config", "profitable.rb") # if File.exist?(config_file) # Profitable.configure do |config| # ...
github
rameerez/profitable
https://github.com/rameerez/profitable
lib/profitable/mrr_calculator.rb
Ruby
mit
96
main
3,584
require_relative 'processors/base' require_relative 'processors/stripe_processor' require_relative 'processors/braintree_processor' require_relative 'processors/paddle_billing_processor' require_relative 'processors/paddle_classic_processor' module Profitable class MrrCalculator def self.calculate total_mr...
github
rameerez/profitable
https://github.com/rameerez/profitable
lib/profitable/numeric_result.rb
Ruby
mit
96
main
934
module Profitable class NumericResult < SimpleDelegator include ActionView::Helpers::NumberHelper def initialize(value, type = :currency) super(value) @type = type end def to_readable(precision = 0) case @type when :currency "$#{price_in_cents_to_string(self, precisio...
github
rameerez/profitable
https://github.com/rameerez/profitable
lib/profitable/processors/base.rb
Ruby
mit
96
main
2,052
module Profitable module Processors class Base attr_reader :subscription def initialize(subscription) @subscription = subscription end def calculate_mrr 0 end protected # Pay gem v10+ stores Stripe objects in the `object` column, # while older ve...
github
rameerez/profitable
https://github.com/rameerez/profitable
lib/profitable/processors/braintree_processor.rb
Ruby
mit
96
main
636
module Profitable module Processors class BraintreeProcessor < Base def calculate_mrr data = subscription_data return 0 if data.nil? amount = data['price'] return 0 if amount.nil? # Some processor payloads provide amounts as strings, so coerce before # multi...
github
rameerez/profitable
https://github.com/rameerez/profitable
lib/profitable/processors/paddle_classic_processor.rb
Ruby
mit
96
main
602
module Profitable module Processors class PaddleClassicProcessor < Base def calculate_mrr data = subscription_data return 0 if data.nil? amount = data['recurring_price'] return 0 if amount.nil? # Paddle Classic payloads may expose string amounts; coerce before quant...
github
rameerez/profitable
https://github.com/rameerez/profitable
lib/profitable/processors/paddle_billing_processor.rb
Ruby
mit
96
main
938
module Profitable module Processors class PaddleBillingProcessor < Base def calculate_mrr data = subscription_data return 0 if data.nil? items = data['items'] return 0 if items.nil? || items.empty? # Sum MRR from ALL subscription items total_mrr = 0 ...
github
rameerez/profitable
https://github.com/rameerez/profitable
lib/profitable/processors/stripe_processor.rb
Ruby
mit
96
main
1,430
module Profitable module Processors class StripeProcessor < Base def calculate_mrr data = subscription_data return 0 if data.nil? # Pay gem v10+ stores items at object['items']['data'] # Older versions stored at data['subscription_items'] subscription_items = data.di...
github
rameerez/profitable
https://github.com/rameerez/profitable
test/numeric_result_test.rb
Ruby
mit
96
main
5,747
# frozen_string_literal: true require "test_helper" class NumericResultTest < Minitest::Test # ============================================================================ # BASIC FUNCTIONALITY # ============================================================================ def test_delegates_to_underlying_val...
github
rameerez/profitable
https://github.com/rameerez/profitable
test/mrr_calculator_test.rb
Ruby
mit
96
main
17,405
# frozen_string_literal: true require "test_helper" class MrrCalculatorTest < Minitest::Test # ============================================================================ # SETUP # ============================================================================ def setup super @stripe_customer = create_...
github
rameerez/profitable
https://github.com/rameerez/profitable
test/test_helper.rb
Ruby
mit
96
main
10,386
# frozen_string_literal: true $LOAD_PATH.unshift File.expand_path("../lib", __dir__) # SimpleCov must be loaded BEFORE any application code # Configuration is auto-loaded from .simplecov file require "simplecov" require "bundler/setup" require "active_record" require "active_support/all" require "action_view" requir...
github
rameerez/profitable
https://github.com/rameerez/profitable
test/profitable_test.rb
Ruby
mit
96
main
48,307
# frozen_string_literal: true require "test_helper" class ProfitableTest < Minitest::Test # ============================================================================ # SETUP # ============================================================================ def setup super @customer = create_customer(p...
github
rameerez/profitable
https://github.com/rameerez/profitable
test/json_helpers_test.rb
Ruby
mit
96
main
5,400
# frozen_string_literal: true require "test_helper" class JsonHelpersTest < Minitest::Test # Create a test class that includes the JsonHelpers module class TestClass include Profitable::JsonHelpers end def setup @helper = TestClass.new end # ======================================================...
github
rameerez/profitable
https://github.com/rameerez/profitable
test/regression_test.rb
Ruby
mit
96
main
18,674
# frozen_string_literal: true require "test_helper" # ============================================================================= # REGRESSION TESTS # ============================================================================= # # This file contains regression tests for all bugs that were fixed in the # profitabl...
github
rameerez/profitable
https://github.com/rameerez/profitable
test/processors/braintree_processor_test.rb
Ruby
mit
96
main
6,406
# frozen_string_literal: true require "test_helper" class ProcessorsBraintreeProcessorTest < Minitest::Test # ============================================================================ # SETUP # ============================================================================ def setup super @customer =...
github
rameerez/profitable
https://github.com/rameerez/profitable
test/processors/paddle_classic_processor_test.rb
Ruby
mit
96
main
4,998
# frozen_string_literal: true require "test_helper" class ProcessorsPaddleClassicProcessorTest < Minitest::Test # ============================================================================ # SETUP # ============================================================================ def setup super @custom...
github
rameerez/profitable
https://github.com/rameerez/profitable
test/processors/base_test.rb
Ruby
mit
96
main
7,667
# frozen_string_literal: true require "test_helper" class ProcessorsBaseTest < Minitest::Test # ============================================================================ # SETUP # ============================================================================ def setup super @customer = create_custom...
github
rameerez/profitable
https://github.com/rameerez/profitable
test/processors/stripe_processor_test.rb
Ruby
mit
96
main
10,768
# frozen_string_literal: true require "test_helper" class ProcessorsStripeProcessorTest < Minitest::Test # ============================================================================ # SETUP # ============================================================================ def setup super @customer = cr...
github
rameerez/profitable
https://github.com/rameerez/profitable
test/processors/paddle_billing_processor_test.rb
Ruby
mit
96
main
8,584
# frozen_string_literal: true require "test_helper" class ProcessorsPaddleBillingProcessorTest < Minitest::Test # ============================================================================ # SETUP # ============================================================================ def setup super @custom...
github
rhardih/pong
https://github.com/rhardih/pong
Gemfile
Ruby
mit
95
master
2,714
source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } ruby '2.6.1' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '~> 5.2.2' # Use postgresql as the database for Active Record gem 'pg', '>= 0.18', '< 2.0' # Use Puma as the app server gem 'puma', '~...
github
rhardih/pong
https://github.com/rhardih/pong
lib/tasks/checks.rake
Ruby
mit
95
master
272
namespace :checks do desc "Migrate the 'available' property to status" task migrate_availablity: :environment do checks = Check.where(available: true) puts "Updating #{checks.count} checks" ActiveRecord::Base.transaction { checks.each(&:up!) } end end
github
rhardih/pong
https://github.com/rhardih/pong
lib/tasks/resque.rake
Ruby
mit
95
master
1,215
require 'resque/tasks' require 'resque/scheduler/tasks' namespace :resque do desc "Setup resque" task setup: :environment do end desc "Start scheduler" task :setup_schedule => :setup do require 'resque-scheduler' # If you want to be able to dynamically change the schedule, # uncomment this line...
github
rhardih/pong
https://github.com/rhardih/pong
lib/tasks/telegram.rake
Ruby
mit
95
master
694
require 'telegram/bot' namespace :telegram do desc "Starts the telegram bot, which will show the chat id needed for setup." task run: :environment do unless ENV.key?('TELEGRAM_API_KEY') puts "Environment variable TELEGRAM_API_KEY needs to be set before running this task. Quitting." return end ...
github
rhardih/pong
https://github.com/rhardih/pong
app/helpers/application_helper.rb
Ruby
mit
95
master
224
module ApplicationHelper def active_link_to(name = nil, options = nil, html_options = nil, &block) html_options[:class] << " active" if current_page?(options) link_to(name, options, html_options, &block) end end
github
rhardih/pong
https://github.com/rhardih/pong
app/models/check.rb
Ruby
mit
95
master
682
class Check < ApplicationRecord has_many :pings, dependent: :delete_all enum status: { down: 0, up: 1, limbo: 2 } # Stale checks are the ones that doesn't have a successful ping, with a # creation time within <interval> minutes. scope :stale, -> do clauses = [ "pings.created_at < now() - checks.in...
github
rhardih/pong
https://github.com/rhardih/pong
app/models/ping.rb
Ruby
mit
95
master
400
class Ping < ApplicationRecord belongs_to :check validates :response_time, presence: true, allow_nil: false def self.percentile_for(check, p) q = %Q{ SELECT percentile_cont(#{p}) within group (order by response_time asc) FROM "pings" WHERE "pings"."check_id" = #{check.id} } ActiveR...
github
rhardih/pong
https://github.com/rhardih/pong
app/controllers/checks_controller.rb
Ruby
mit
95
master
1,727
class ChecksController < ApplicationController before_action :set_check, only: [:show, :edit, :update, :destroy] # GET /checks def index @checks = Check.order(:name) end # GET /checks/1 def show if params.key?(:p) rt_limit = Ping.percentile_for(@check, params[:p].to_f) selection = @ch...
github
rhardih/pong
https://github.com/rhardih/pong
app/mailers/alert_mailer.rb
Ruby
mit
95
master
499
class AlertMailer < ApplicationMailer include ActionView::Helpers::DateHelper def up_email @check = params[:check] @penultimate, @ultimate = @check.pings.limit(2).order('id desc') mail to: default_receiver, subject: "UP alert: #{@check.name} (#{@check.url}) is UP" end def down_email @check = ...
github
rhardih/pong
https://github.com/rhardih/pong
app/jobs/request_job.rb
Ruby
mit
95
master
1,577
require 'benchmark' require 'net/http' class RequestJob < ApplicationJob queue_as :default def perform(check) uri = URI("#{check.protocol}://#{check.url}") req = Net::HTTP::Head.new(uri.request_uri) http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = uri.scheme == "https" http.read_timeout...
github
rhardih/pong
https://github.com/rhardih/pong
app/jobs/queue_request_jobs.rb
Ruby
mit
95
master
401
class QueueRequestJobs def self.perform # The stale scope isn't structurally compatible, so is explicitly not # chained here Check.stale.each { |c| RequestJob.perform_later(c) } # For hosts that are down or in limbo, a check is performed every minute and # the value of <interval> is disregarded ...
github
rhardih/pong
https://github.com/rhardih/pong
app/jobs/telegram_notification_job.rb
Ruby
mit
95
master
932
require 'erb' require 'ostruct' require 'telegram/bot' class TelegramNotificationJob < ApplicationJob queue_as :default def perform(check, up:, reason: "") key = ENV['TELEGRAM_API_KEY'] mid = ENV['TELEGRAM_CHAT_ID'] penultimate, ultimate = check.pings.limit(2).order('id desc') # Re-use the maile...
github
rhardih/pong
https://github.com/rhardih/pong
db/seeds.rb
Ruby
mit
95
master
499
check = Check.create(name: 'Example', interval: 1, protocol: 'https', url: 'example.com') # Create pings for the last seven days date = 7.days.ago.beginning_of_day # response time #rt = 250 now = Time.now spike = lambda do |rt, &block| # 10% chance of a spike rt += rand(150..250) if rand(0..9) < 1 block.call(r...
github
rhardih/pong
https://github.com/rhardih/pong
db/schema.rb
Ruby
mit
95
master
1,545
# 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. # # Note that this schema.rb definition is the authoritative source for your # dat...
github
rhardih/pong
https://github.com/rhardih/pong
db/migrate/20190206082044_create_pings.rb
Ruby
mit
95
master
207
class CreatePings < ActiveRecord::Migration[5.2] def change create_table :pings do |t| t.integer :response_time t.references :check, foreign_key: true t.timestamps end end end
github
rhardih/pong
https://github.com/rhardih/pong
db/migrate/20190205145033_create_checks.rb
Ruby
mit
95
master
225
class CreateChecks < ActiveRecord::Migration[5.2] def change create_table :checks do |t| t.string :name t.integer :interval t.string :protocol t.string :url t.timestamps end end end
github
rhardih/pong
https://github.com/rhardih/pong
config/application.rb
Ruby
mit
95
master
1,019
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 Pong class Application < Rails::Application # Initialize configuration defaults for originally generated Rails vers...
github
rhardih/pong
https://github.com/rhardih/pong
config/environments/production.rb
Ruby
mit
95
master
4,183
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 serve...
github
rhardih/pong
https://github.com/rhardih/pong
config/environments/development.rb
Ruby
mit
95
master
2,405
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 serv...
github
rhardih/pong
https://github.com/rhardih/pong
config/environments/test.rb
Ruby
mit
95
master
2,062
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 suit...
github
rhardih/pong
https://github.com/rhardih/pong
test/test_helper.rb
Ruby
mit
95
master
344
ENV['RAILS_ENV'] ||= 'test' require_relative '../config/environment' require 'rails/test_help' require 'webmock/minitest' require 'minitest/autorun' 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 b...
github
rhardih/pong
https://github.com/rhardih/pong
test/mailers/alert_mailer_test.rb
Ruby
mit
95
master
435
require 'test_helper' class AlertMailerTest < ActionMailer::TestCase fixtures :checks test "up_email" do check = checks(:default) email = AlertMailer.with(check: check).down_email assert_emails(1) { email.deliver_now } assert_equal ['test@example.com'], email.from assert_equal [ENV['EMAIL_...
github
rhardih/pong
https://github.com/rhardih/pong
test/mailers/previews/alert_mailer_preview.rb
Ruby
mit
95
master
302
# Preview all emails at http://localhost:3000/rails/mailers/alert_mailer class AlertMailerPreview < ActionMailer::Preview def up_email AlertMailer.with(check: Check.first).up_email end def down_email AlertMailer.with(check: Check.first, reason: "404 - Not Found").down_email end end
github
rhardih/pong
https://github.com/rhardih/pong
test/models/check_test.rb
Ruby
mit
95
master
436
require 'test_helper' class CheckTest < ActiveSupport::TestCase fixtures :checks fixtures :pings test "stale" do stale = Check.stale # up has no pings assert_includes(stale, checks(:up)) # expired has one ping, but too old assert_includes(stale, checks(:expired)) # expired has one ping,...
github
rhardih/pong
https://github.com/rhardih/pong
test/controllers/checks_controller_test.rb
Ruby
mit
95
master
1,117
require 'test_helper' class ChecksControllerTest < ActionDispatch::IntegrationTest setup do @check = checks(:default) @default_params = { check: { name: "Foo", interval: 1, protocol: "https", url: "example.com" } } end test "should get index" do get ch...
github
rhardih/pong
https://github.com/rhardih/pong
test/jobs/telegram_notification_job_test.rb
Ruby
mit
95
master
1,169
require 'test_helper' class TelegramNotificationJobTest < ActiveJob::TestCase fixtures :checks def setup ENV['TELEGRAM_API_KEY'] = 'foo' ENV['TELEGRAM_CHAT_ID'] = 'bar' end test "perform up notification" do check = checks(:up) ts = check.pings.first.created_at stub_request(:post, "https:...
github
rhardih/pong
https://github.com/rhardih/pong
test/jobs/queue_request_jobs_test.rb
Ruby
mit
95
master
235
require 'test_helper' class QueueRequestJobsTest < ActiveJob::TestCase fixtures :checks test "enqueues" do QueueRequestJobs.perform assert_enqueued_jobs Check.stale.count + Check.limbo.count + Check.down.count end end
github
rhardih/pong
https://github.com/rhardih/pong
test/jobs/request_job_test.rb
Ruby
mit
95
master
4,294
require 'test_helper' require 'action_mailer/test_helper' class RequestJobTest < ActiveJob::TestCase include ActionMailer::TestHelper fixtures :checks test "that a ping is created on success" do check = checks(:up) stub_request(:any, "#{check.protocol}://#{check.url}") assert_difference 'Ping.coun...
github
RSpace/spree-heroku
https://github.com/RSpace/spree-heroku
Rakefile
Ruby
mit
95
master
4,248
# I think this is the one that should be moved to the extension Rakefile template # In rails 1.2, plugins aren't available in the path until they're loaded. # Check to see if the rspec plugin is installed first and require # it if it is. If not, use the gem version. # Determine where the RSpec plugin is by loading t...
github
RSpace/spree-heroku
https://github.com/RSpace/spree-heroku
heroku_extension.rb
Ruby
mit
95
master
517
# encoding: utf-8 # Uncomment this if you reference any of your controllers in activate # require_dependency 'application' class HerokuExtension < Spree::Extension version "0.2" description "Allows Spree to run on Heroku" url "http://github.com/chipiga/spree-heroku" def self.require_gems(config) config....
github
RSpace/spree-heroku
https://github.com/RSpace/spree-heroku
config/initializers/heroku.rb
Ruby
mit
95
master
202
# encoding: utf-8 aws_s3_file = File.join(File.dirname(__FILE__), '..', 'aws_s3.yml') if File.exists?(aws_s3_file) HEROKU_AWS_S3 = YAML.load_file(aws_s3_file)[Rails.env] else HEROKU_AWS_S3 = {} end
github
RSpace/spree-heroku
https://github.com/RSpace/spree-heroku
spec/spec_helper.rb
Ruby
mit
95
master
1,315
unless defined? SPREE_ROOT ENV["RAILS_ENV"] = "test" case when ENV["SPREE_ENV_FILE"] require ENV["SPREE_ENV_FILE"] when File.dirname(__FILE__) =~ %r{vendor/SPREE/vendor/extensions} require "#{File.expand_path(File.dirname(__FILE__) + "/../../../../../../")}/config/environment" else require "#{File...
github
RSpace/spree-heroku
https://github.com/RSpace/spree-heroku
app/models/taxon.rb
Ruby
mit
95
master
1,867
class Taxon < ActiveRecord::Base acts_as_nested_set :dependent => :destroy belongs_to :taxonomy has_and_belongs_to_many :products before_create :set_permalink before_save :ensure_trailing_slash validates_presence_of :name has_attached_file :icon, :styles => { :mini => '32x32>', :normal =...
github
RSpace/spree-heroku
https://github.com/RSpace/spree-heroku
app/models/image.rb
Ruby
mit
95
master
1,619
# encoding: utf-8 class Image < Asset has_attached_file :attachment, :styles => { :mini => '48x48>', :small => '100x100>', :product => '240x240>', :large => '600x600>' }, :default_style => :product, :path => "assets/products/:id/:style/:basename.:extension...
github
lserman/capistrano-elbas
https://github.com/lserman/capistrano-elbas
elbas.gemspec
Ruby
mit
95
master
1,190
# coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'elbas/version' Gem::Specification.new do |spec| spec.name = 'elbas' spec.version = Elbas::VERSION spec.authors = ['Logan Serman'] spec.email = ['loganserman@g...
github
lserman/capistrano-elbas
https://github.com/lserman/capistrano-elbas
lib/elbas.rb
Ruby
mit
95
master
461
require 'capistrano/all' require 'aws-sdk-autoscaling' require 'aws-sdk-ec2' require 'elbas/version' require 'elbas/logger' require 'elbas/retryable' require 'elbas/errors/no_launch_template' require 'elbas/aws/base' require 'elbas/aws/taggable' require 'elbas/aws/instance_collection' require 'elbas/aws/instance' re...
github
lserman/capistrano-elbas
https://github.com/lserman/capistrano-elbas
lib/elbas/capistrano.rb
Ruby
mit
95
master
950
require 'capistrano/dsl' load File.expand_path("../tasks/elbas.rake", __FILE__) def autoscale(groupname, properties = {}) include Capistrano::DSL include Elbas::Logger set :aws_autoscale_group_names, Array(fetch(:aws_autoscale_group_names)).push(groupname) asg = Elbas::AWS::AutoscaleGroup.new groupname in...
github
lserman/capistrano-elbas
https://github.com/lserman/capistrano-elbas
lib/elbas/logger.rb
Ruby
mit
95
master
696
require 'capistrano/doctor/output_helpers' module Elbas module Logger include Capistrano::Doctor::OutputHelpers PREFIX_TEXT = '[ELBAS] '.freeze def info(message) $stdout.puts [prefix, message, "\n"].join end def error(message) $stderr.puts [error_prefix, message, "\n"].join end...
github
lserman/capistrano-elbas
https://github.com/lserman/capistrano-elbas
lib/elbas/retryable.rb
Ruby
mit
95
master
744
module Elbas class Retryable include Elbas::Logger def initialize @max = 0 @delay = 0 end def times(max, &block) @max = max run block if block_given? end def delay(seconds, &block) @delay = seconds run block if block_given? end def run(proc) ...
github
lserman/capistrano-elbas
https://github.com/lserman/capistrano-elbas
lib/elbas/tasks/elbas.rake
Ruby
mit
95
master
1,151
require 'elbas' include Elbas::Logger namespace :elbas do task :ssh do include Capistrano::DSL info "SSH commands:" env.servers.to_a.each.with_index do |server, i| info " #{i + 1}) ssh #{fetch(:user)}@#{server.hostname}" end end task :deploy do fetch(:aws_autoscale_group_names).eac...
github
lserman/capistrano-elbas
https://github.com/lserman/capistrano-elbas
lib/elbas/aws/snapshot.rb
Ruby
mit
95
master
322
module Elbas module AWS class Snapshot < Base attr_reader :id def initialize(id) @id = id end def delete return unless id aws_client.delete_snapshot snapshot_id: id end private def aws_namespace ::Aws::EC2 end end end e...
github
lserman/capistrano-elbas
https://github.com/lserman/capistrano-elbas
lib/elbas/aws/instance_collection.rb
Ruby
mit
95
master
703
module Elbas module AWS class InstanceCollection < Base include Enumerable attr_reader :instances def initialize(ids) @ids = ids @instances = query_instances_by_ids(ids).map do |i| Instance.new(i.instance_id, i.public_dns_name, i.state.code) end end ...
github
lserman/capistrano-elbas
https://github.com/lserman/capistrano-elbas
lib/elbas/aws/ami.rb
Ruby
mit
95
master
1,689
module Elbas module AWS class AMI < Base include Taggable DEPLOY_ID_TAG = 'ELBAS-Deploy-id'.freeze DEPLOY_GROUP_TAG = 'ELBAS-Deploy-group'.freeze attr_reader :id, :snapshots def initialize(id, snapshots = []) @id = id @aws_counterpart = ::Aws::EC2::Image.new id, cl...
github
lserman/capistrano-elbas
https://github.com/lserman/capistrano-elbas
lib/elbas/aws/taggable.rb
Ruby
mit
95
master
327
module Elbas module AWS module Taggable def tag(key, value) @tags ||= {} Elbas::Retryable.times(3).delay(5) do aws_counterpart.create_tags tags: [{ key: key, value: value }] @tags[key] = value end end def tags @tags || {} end end ...
github
lserman/capistrano-elbas
https://github.com/lserman/capistrano-elbas
lib/elbas/aws/autoscale_group.rb
Ruby
mit
95
master
1,228
module Elbas module AWS class AutoscaleGroup < Base attr_reader :name def initialize(name) @name = name @aws_counterpart = query_autoscale_group_by_name(name) end def instance_ids aws_counterpart.instances.map(&:instance_id) end def instances ...
github
lserman/capistrano-elbas
https://github.com/lserman/capistrano-elbas
lib/elbas/aws/base.rb
Ruby
mit
95
master
833
module Elbas module AWS class Base include Capistrano::DSL attr_reader :aws_counterpart def aws_client(namespace = aws_namespace) @aws_client ||= begin options = {} options[:region] = aws_region if aws_region options[:credentials] = aws_credentials if aws_...
github
lserman/capistrano-elbas
https://github.com/lserman/capistrano-elbas
lib/elbas/aws/instance.rb
Ruby
mit
95
master
542
module Elbas module AWS class Instance < Base STATE_RUNNING = 16.freeze attr_reader :aws_counterpart, :id, :state def initialize(id, public_dns, state) @id = id @public_dns = public_dns @state = state @aws_counterpart = aws_namespace::Instance.new id, client: aw...
github
lserman/capistrano-elbas
https://github.com/lserman/capistrano-elbas
lib/elbas/aws/launch_template.rb
Ruby
mit
95
master
711
module Elbas module AWS class LaunchTemplate < Base attr_reader :id, :name, :version def initialize(id, name, version) @id = id @name = name @version = version end def update(ami) latest = aws_client.create_launch_template_version({ launch_templa...
github
lserman/capistrano-elbas
https://github.com/lserman/capistrano-elbas
spec/spec_helper.rb
Ruby
mit
95
master
563
require 'webmock' require 'capistrano/all' require 'byebug' ENV['AWS_REGION'] = 'us-east-1' ENV['AWS_ACCESS_KEY_ID'] = 'test-access' ENV['AWS_SECRET_ACCESS_KEY'] = 'test-secret' require 'elbas' require 'webmock/rspec' # Hack for webmock-rspec-helper Rails = Class.new do def self.root Pathname.new(__dir__).join...
github
lserman/capistrano-elbas
https://github.com/lserman/capistrano-elbas
spec/capistrano_spec.rb
Ruby
mit
95
master
2,493
require 'elbas/capistrano' describe '#autoscale' do before do Capistrano::Configuration.reset! Rake::Task.define_task('deploy') {} webmock :post, %r{autoscaling.(.*).amazonaws.com\/\z} => 'DescribeAutoScalingGroups.200.xml', with: Hash[body: /Action=DescribeAutoScalingGroups/] end context 'on...
github
lserman/capistrano-elbas
https://github.com/lserman/capistrano-elbas
spec/aws/autoscale_group_spec.rb
Ruby
mit
95
master
2,354
describe Elbas::AWS::AutoscaleGroup do subject { Elbas::AWS::AutoscaleGroup.new 'test-asg' } before do webmock :post, %r{autoscaling.(.*).amazonaws.com\/\z} => 'DescribeAutoScalingGroups.200.xml', with: Hash[body: /Action=DescribeAutoScalingGroups/] webmock :post, %r{ec2.(.*).amazonaws.com\/\z} => '...