repo stringlengths 5 92 | file_url stringlengths 80 287 | file_path stringlengths 5 197 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:37:27 2026-01-04 17:58:21 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
cloud66-oss/noticent | https://github.com/cloud66-oss/noticent/blob/5e65d0e1c26e84863314944d3426ea486cb754cf/lib/noticent.rb | lib/noticent.rb | # frozen_string_literal: true
require "active_support/all"
require "rails/all"
Dir["#{File.dirname(__FILE__)}/noticent/**/*.rb"].each { |f| load(f) }
load "#{File.dirname(__FILE__)}/generators/noticent/noticent.rb"
module Noticent
end
| ruby | Apache-2.0 | 5e65d0e1c26e84863314944d3426ea486cb754cf | 2026-01-04T17:40:31.692194Z | false |
cloud66-oss/noticent | https://github.com/cloud66-oss/noticent/blob/5e65d0e1c26e84863314944d3426ea486cb754cf/lib/generators/noticent/noticent.rb | lib/generators/noticent/noticent.rb | # frozen_string_literal: true
require 'rails/generators'
require 'rails/generators/migration'
module Noticent
module Generators
class InstallGenerator < Rails::Generators::Base
include Rails::Generators::Migration
source_root File.expand_path('templates', __dir__)
desc 'Generate Noticent requ... | ruby | Apache-2.0 | 5e65d0e1c26e84863314944d3426ea486cb754cf | 2026-01-04T17:40:31.692194Z | false |
cloud66-oss/noticent | https://github.com/cloud66-oss/noticent/blob/5e65d0e1c26e84863314944d3426ea486cb754cf/lib/generators/noticent/templates/opt_in.rb | lib/generators/noticent/templates/opt_in.rb | # frozen_string_literal: true
class OptIn < ActiveRecord::Base
# scope: is the type of domain object that opt-in applies to. For example
# it could be post or comment
# entity_id: is the ID of the scope (post id or comment id)
# channel_name: is the name of the channel opted into. email or slack are examples
... | ruby | Apache-2.0 | 5e65d0e1c26e84863314944d3426ea486cb754cf | 2026-01-04T17:40:31.692194Z | false |
cloud66-oss/noticent | https://github.com/cloud66-oss/noticent/blob/5e65d0e1c26e84863314944d3426ea486cb754cf/lib/generators/noticent/templates/noticent_initializer.rb | lib/generators/noticent/templates/noticent_initializer.rb | Noticent.configure do |config|
config.base_dir = File.join(Rails.root, 'app', 'models', 'noticent')
config.base_module_name = 'Noticent'
config.logger = Rails.logger
config.halt_on_error = !Rails.env.production?
# scope :post do
# channel :email
# channel :slack, group: :internal
#
# alert :new... | ruby | Apache-2.0 | 5e65d0e1c26e84863314944d3426ea486cb754cf | 2026-01-04T17:40:31.692194Z | false |
cloud66-oss/noticent | https://github.com/cloud66-oss/noticent/blob/5e65d0e1c26e84863314944d3426ea486cb754cf/lib/generators/noticent/templates/create_opt_ins.rb | lib/generators/noticent/templates/create_opt_ins.rb | class CreateOptIns < ActiveRecord::Migration[5.2]
def change
create_table :opt_ins, force: true do |t|
t.integer :recipient_id, null: false
t.integer :entity_id, null: false
t.string :scope, null: false
t.string :alert_name, null: false
t.string :channel_name, null: false
t.ti... | ruby | Apache-2.0 | 5e65d0e1c26e84863314944d3426ea486cb754cf | 2026-01-04T17:40:31.692194Z | false |
cloud66-oss/noticent | https://github.com/cloud66-oss/noticent/blob/5e65d0e1c26e84863314944d3426ea486cb754cf/lib/noticent/version.rb | lib/noticent/version.rb | # frozen_string_literal: true
module Noticent
VERSION ||= "0.0.6"
end
| ruby | Apache-2.0 | 5e65d0e1c26e84863314944d3426ea486cb754cf | 2026-01-04T17:40:31.692194Z | false |
cloud66-oss/noticent | https://github.com/cloud66-oss/noticent/blob/5e65d0e1c26e84863314944d3426ea486cb754cf/lib/noticent/channel.rb | lib/noticent/channel.rb | # frozen_string_literal: true
module Noticent
class Channel
class_attribute :default_ext, default: :erb
class_attribute :default_format, default: :html
attr_accessor :data
def initialize(config, recipients, payload, configuration)
@config = config
@recipients = recipients
@payload... | ruby | Apache-2.0 | 5e65d0e1c26e84863314944d3426ea486cb754cf | 2026-01-04T17:40:31.692194Z | false |
cloud66-oss/noticent | https://github.com/cloud66-oss/noticent/blob/5e65d0e1c26e84863314944d3426ea486cb754cf/lib/noticent/errors.rb | lib/noticent/errors.rb | # frozen_string_literal: true
module Noticent
class Error < StandardError; end
class BadConfiguration < Error; end
class InvalidPayload < Error; end
class InvalidScope < Error; end
class InvalidAlert < Error; end
class NoCurrentUser < Error; end
class ViewNotFound < Error; end
class MissingConfigurati... | ruby | Apache-2.0 | 5e65d0e1c26e84863314944d3426ea486cb754cf | 2026-01-04T17:40:31.692194Z | false |
cloud66-oss/noticent | https://github.com/cloud66-oss/noticent/blob/5e65d0e1c26e84863314944d3426ea486cb754cf/lib/noticent/opt_in.rb | lib/noticent/opt_in.rb | # frozen_string_literal: true
require 'active_record'
module Noticent
class OptIn < ActiveRecord::Base
# scope: is the type of domain object that opt-in applies to. For example
# it could be post or comment
# entity_id: is the ID of the scope (post id or comment id)
# channel_name: is the name of th... | ruby | Apache-2.0 | 5e65d0e1c26e84863314944d3426ea486cb754cf | 2026-01-04T17:40:31.692194Z | false |
cloud66-oss/noticent | https://github.com/cloud66-oss/noticent/blob/5e65d0e1c26e84863314944d3426ea486cb754cf/lib/noticent/view.rb | lib/noticent/view.rb | # frozen_string_literal: true
require "yaml"
module Noticent
class View
# these are the attributes we should use in most cases
attr_reader :data # frontmatter in hash form with symbolized keys
attr_reader :content # content rendered
# these are mostly for debug and testing purp... | ruby | Apache-2.0 | 5e65d0e1c26e84863314944d3426ea486cb754cf | 2026-01-04T17:40:31.692194Z | false |
cloud66-oss/noticent | https://github.com/cloud66-oss/noticent/blob/5e65d0e1c26e84863314944d3426ea486cb754cf/lib/noticent/active_record_opt_in_provider.rb | lib/noticent/active_record_opt_in_provider.rb | # frozen_string_literal: true
module Noticent
# should be used only for testing
class ActiveRecordOptInProvider
def opt_in(recipient_id:, scope:, entity_id:, alert_name:, channel_name:)
Noticent::OptIn.create!(recipient_id: recipient_id, scope: scope, entity_id: entity_id, alert_name: alert_name, channel... | ruby | Apache-2.0 | 5e65d0e1c26e84863314944d3426ea486cb754cf | 2026-01-04T17:40:31.692194Z | false |
cloud66-oss/noticent | https://github.com/cloud66-oss/noticent/blob/5e65d0e1c26e84863314944d3426ea486cb754cf/lib/noticent/dispatcher.rb | lib/noticent/dispatcher.rb | # frozen_string_literal: true
module Noticent
class Dispatcher
def initialize(config, alert_name, payload, configuration = {})
@config = config
@alert_name = alert_name
@payload = payload
@configuration = configuration
validate!
@entity_id = @payload.send("#{scope.name}_id")... | ruby | Apache-2.0 | 5e65d0e1c26e84863314944d3426ea486cb754cf | 2026-01-04T17:40:31.692194Z | false |
cloud66-oss/noticent | https://github.com/cloud66-oss/noticent/blob/5e65d0e1c26e84863314944d3426ea486cb754cf/lib/noticent/config.rb | lib/noticent/config.rb | # frozen_string_literal: true
module Noticent
def self.configure(options = {}, &block)
if ENV["NOTICENT_RSPEC"] == "1"
options = options.merge(
base_module_name: "Noticent::Testing",
base_dir: File.expand_path("#{File.dirname(__FILE__)}/../../testing"),
halt_on_error: true,
)
... | ruby | Apache-2.0 | 5e65d0e1c26e84863314944d3426ea486cb754cf | 2026-01-04T17:40:31.692194Z | false |
cloud66-oss/noticent | https://github.com/cloud66-oss/noticent/blob/5e65d0e1c26e84863314944d3426ea486cb754cf/lib/noticent/proc_map.rb | lib/noticent/proc_map.rb | # frozen_string_literal: true
module Noticent
class ProcMap
def initialize(config)
@map = {}
@config = config
end
def use(symbol, proc)
raise Noticent::BadConfiguration, 'should provide a proc' unless proc.is_a?(Proc)
raise Noticent::BadConfiguration, "invalid number of parameter... | ruby | Apache-2.0 | 5e65d0e1c26e84863314944d3426ea486cb754cf | 2026-01-04T17:40:31.692194Z | false |
cloud66-oss/noticent | https://github.com/cloud66-oss/noticent/blob/5e65d0e1c26e84863314944d3426ea486cb754cf/lib/noticent/version_checker.rb | lib/noticent/version_checker.rb | module Noticent
class VersionChecker
def self.activesupport_7_or_greater?
return @activesupport_7_or_greater unless @activesupport_7_or_greater.nil?
@activesupport_7_or_greater = ::Gem.loaded_specs["activesupport"].version >= ::Gem::Version.new("7.0.0")
end
end
end
| ruby | Apache-2.0 | 5e65d0e1c26e84863314944d3426ea486cb754cf | 2026-01-04T17:40:31.692194Z | false |
cloud66-oss/noticent | https://github.com/cloud66-oss/noticent/blob/5e65d0e1c26e84863314944d3426ea486cb754cf/lib/noticent/definitions/channel.rb | lib/noticent/definitions/channel.rb | # frozen_string_literal: true
module Noticent
module Definitions
class Channel
attr_reader :name
attr_reader :group
attr_reader :klass
attr_reader :options
def initialize(config, name, group: :default, klass: nil)
raise BadConfiguration, 'name should be a symbol' unless nam... | ruby | Apache-2.0 | 5e65d0e1c26e84863314944d3426ea486cb754cf | 2026-01-04T17:40:31.692194Z | false |
cloud66-oss/noticent | https://github.com/cloud66-oss/noticent/blob/5e65d0e1c26e84863314944d3426ea486cb754cf/lib/noticent/definitions/hooks.rb | lib/noticent/definitions/hooks.rb | # frozen_string_literal: true
module Noticent
module Definitions
class Hooks
VALID_STEPS = %i[pre_alert_registration post_alert_registration pre_channel_registration post_channel_registration pre_product_registration post_product_registration].freeze
def add(step, klass)
raise BadConfigurati... | ruby | Apache-2.0 | 5e65d0e1c26e84863314944d3426ea486cb754cf | 2026-01-04T17:40:31.692194Z | false |
cloud66-oss/noticent | https://github.com/cloud66-oss/noticent/blob/5e65d0e1c26e84863314944d3426ea486cb754cf/lib/noticent/definitions/scope.rb | lib/noticent/definitions/scope.rb | # frozen_string_literal: true
module Noticent
module Definitions
class Scope
attr_reader :name
attr_reader :payload_class
attr_reader :check_constructor
def initialize(config, name, payload_class: nil, check_constructor: true)
@config = config
@name = name
@check_... | ruby | Apache-2.0 | 5e65d0e1c26e84863314944d3426ea486cb754cf | 2026-01-04T17:40:31.692194Z | false |
cloud66-oss/noticent | https://github.com/cloud66-oss/noticent/blob/5e65d0e1c26e84863314944d3426ea486cb754cf/lib/noticent/definitions/product.rb | lib/noticent/definitions/product.rb | # frozen_string_literal: true
module Noticent
module Definitions
class Product
attr_reader :name
def initialize(config, name)
raise BadConfiguration, 'product name should be a symbol' unless name.is_a? Symbol
@config = config
@name = name
end
end
end
end
| ruby | Apache-2.0 | 5e65d0e1c26e84863314944d3426ea486cb754cf | 2026-01-04T17:40:31.692194Z | false |
cloud66-oss/noticent | https://github.com/cloud66-oss/noticent/blob/5e65d0e1c26e84863314944d3426ea486cb754cf/lib/noticent/definitions/product_group.rb | lib/noticent/definitions/product_group.rb | # frozen_string_literal: true
module Noticent
module Definitions
class ProductGroup
attr_reader :products
def initialize(config)
@config = config
@products = {}
end
def to(name)
raise BadConfiguration, 'product name should be a symbol' unless name.is_a? Symbol
... | ruby | Apache-2.0 | 5e65d0e1c26e84863314944d3426ea486cb754cf | 2026-01-04T17:40:31.692194Z | false |
cloud66-oss/noticent | https://github.com/cloud66-oss/noticent/blob/5e65d0e1c26e84863314944d3426ea486cb754cf/lib/noticent/definitions/alert.rb | lib/noticent/definitions/alert.rb | # frozen_string_literal: true
module Noticent
module Definitions
class Alert
attr_reader :name
attr_reader :scope
attr_reader :notifiers
attr_reader :config
attr_reader :products
attr_reader :constructor_name
def initialize(config, name:, scope:, constructor_name:)
... | ruby | Apache-2.0 | 5e65d0e1c26e84863314944d3426ea486cb754cf | 2026-01-04T17:40:31.692194Z | false |
fractaledmind/chaotic_job | https://github.com/fractaledmind/chaotic_job/blob/cc4dcdee30e5447fe0460a2b6afe644f05ec3c33/test/test_chaotic_job.rb | test/test_chaotic_job.rb | # frozen_string_literal: true
require "test_helper"
class TestChaoticJob < ActiveJob::TestCase
include ChaoticJob::Helpers
test "test_simulation builder method available" do
assert_includes self.class.methods, :test_simulation
end
test "test_races builder method available" do
assert_includes self.cl... | ruby | MIT | cc4dcdee30e5447fe0460a2b6afe644f05ec3c33 | 2026-01-04T17:40:32.691002Z | false |
fractaledmind/chaotic_job | https://github.com/fractaledmind/chaotic_job/blob/cc4dcdee30e5447fe0460a2b6afe644f05ec3c33/test/test_helper.rb | test/test_helper.rb | # frozen_string_literal: true
require "simplecov"
SimpleCov.start do
enable_coverage :branch
primary_coverage :branch
add_filter "/test/"
add_filter "/spec/"
# Merge coverage results from different test suites
use_merging true
merge_timeout 3600 # 1 hour
command_name "Minitest"
# Track files that a... | ruby | MIT | cc4dcdee30e5447fe0460a2b6afe644f05ec3c33 | 2026-01-04T17:40:32.691002Z | false |
fractaledmind/chaotic_job | https://github.com/fractaledmind/chaotic_job/blob/cc4dcdee30e5447fe0460a2b6afe644f05ec3c33/test/chaotic_job/simulation_test.rb | test/chaotic_job/simulation_test.rb | # frozen_string_literal: true
require "test_helper"
class ChaoticJob::SimulationTest < ActiveJob::TestCase
test "initialize with only job initializes callstack and tracing" do
simulation = ChaoticJob::Simulation.new(TestJob.new)
stack = simulation.callstack.to_a
assert stack.all? { |item| item.is_a?(Ch... | ruby | MIT | cc4dcdee30e5447fe0460a2b6afe644f05ec3c33 | 2026-01-04T17:40:32.691002Z | false |
fractaledmind/chaotic_job | https://github.com/fractaledmind/chaotic_job/blob/cc4dcdee30e5447fe0460a2b6afe644f05ec3c33/test/chaotic_job/scenario_test.rb | test/chaotic_job/scenario_test.rb | # frozen_string_literal: true
require "test_helper"
class ChaoticJob::ScenarioTest < ActiveJob::TestCase
test "default parameters and blockless #run retries job" do
scenario = ChaoticJob::Scenario.new(
TestJob.new,
glitch: ChaoticJob::Glitch.before_call("#{TestJob.name}#perform")
)
scenario.... | ruby | MIT | cc4dcdee30e5447fe0460a2b6afe644f05ec3c33 | 2026-01-04T17:40:32.691002Z | false |
fractaledmind/chaotic_job | https://github.com/fractaledmind/chaotic_job/blob/cc4dcdee30e5447fe0460a2b6afe644f05ec3c33/test/chaotic_job/relay_test.rb | test/chaotic_job/relay_test.rb | # frozen_string_literal: true
require "test_helper"
class ChaoticJob::RelayTest < ActiveJob::TestCase
test "can run a relay with all possible races for passed jobs" do
job1 = RaceJob1.new
job2 = RaceJob2.new
test_class = Class.new
relay = ChaoticJob::Relay.new(job1, job2, test: test_class)
test... | ruby | MIT | cc4dcdee30e5447fe0460a2b6afe644f05ec3c33 | 2026-01-04T17:40:32.691002Z | false |
fractaledmind/chaotic_job | https://github.com/fractaledmind/chaotic_job/blob/cc4dcdee30e5447fe0460a2b6afe644f05ec3c33/test/chaotic_job/glitch_test.rb | test/chaotic_job/glitch_test.rb | # frozen_string_literal: true
require "test_helper"
class ChaoticJob::GlitchTest < ActiveJob::TestCase
test "glitch before a line execution" do
class Job5 < ActiveJob::Base
def perform
step_1
step_2
end
def step_1
ChaoticJob.log_to_journal!(:step_1)
end
de... | ruby | MIT | cc4dcdee30e5447fe0460a2b6afe644f05ec3c33 | 2026-01-04T17:40:32.691002Z | false |
fractaledmind/chaotic_job | https://github.com/fractaledmind/chaotic_job/blob/cc4dcdee30e5447fe0460a2b6afe644f05ec3c33/test/chaotic_job/tracer_test.rb | test/chaotic_job/tracer_test.rb | # frozen_string_literal: true
require "test_helper"
class ChaoticJob::TracerTest < ActiveJob::TestCase
test "initializes with constraint block" do
tracer = ChaoticJob::Tracer.new { |tp| tp.path.start_with?("test") }
assert_not_nil tracer
end
test "capture returns a Stack" do
tracer = ChaoticJob::T... | ruby | MIT | cc4dcdee30e5447fe0460a2b6afe644f05ec3c33 | 2026-01-04T17:40:32.691002Z | false |
fractaledmind/chaotic_job | https://github.com/fractaledmind/chaotic_job/blob/cc4dcdee30e5447fe0460a2b6afe644f05ec3c33/test/chaotic_job/race_test.rb | test/chaotic_job/race_test.rb | # frozen_string_literal: true
require "test_helper"
class ChaoticJob::RaceTest < ActiveJob::TestCase
test "can run a race with an interleaved callstacks schedule" do
# prep phase
job1 = RaceJob1.new
job2 = RaceJob2.new
job1_callstack = ChaoticJob::Tracer.new(tracing: RaceJob1).capture do
job1... | ruby | MIT | cc4dcdee30e5447fe0460a2b6afe644f05ec3c33 | 2026-01-04T17:40:32.691002Z | false |
fractaledmind/chaotic_job | https://github.com/fractaledmind/chaotic_job/blob/cc4dcdee30e5447fe0460a2b6afe644f05ec3c33/test/chaotic_job/switch_test.rb | test/chaotic_job/switch_test.rb | # frozen_string_literal: true
require "test_helper"
class ChaoticJob::SwitchTest < ActiveJob::TestCase
def before_setup
ChaoticJob::Switch.off!
super
end
test "on? defaults to false" do
refute ChaoticJob::Switch.on?
end
test "off? defaults to true" do
assert ChaoticJob::Switch.off?
end
... | ruby | MIT | cc4dcdee30e5447fe0460a2b6afe644f05ec3c33 | 2026-01-04T17:40:32.691002Z | false |
fractaledmind/chaotic_job | https://github.com/fractaledmind/chaotic_job/blob/cc4dcdee30e5447fe0460a2b6afe644f05ec3c33/test/chaotic_job/performer_test.rb | test/chaotic_job/performer_test.rb | # frozen_string_literal: true
require "test_helper"
class ChaoticJob::PerformerTest < ActiveJob::TestCase
test "perform_all executes all enqueued jobs" do
TestJob.perform_later(:job1)
TestJob.perform_later(:job2)
assert_equal 2, enqueued_jobs.size
assert_equal 0, performed_jobs.size
ChaoticJob... | ruby | MIT | cc4dcdee30e5447fe0460a2b6afe644f05ec3c33 | 2026-01-04T17:40:32.691002Z | false |
fractaledmind/chaotic_job | https://github.com/fractaledmind/chaotic_job/blob/cc4dcdee30e5447fe0460a2b6afe644f05ec3c33/test/chaotic_job/journal_test.rb | test/chaotic_job/journal_test.rb | # frozen_string_literal: true
require "test_helper"
class ChaoticJob::JournalTest < ActiveJob::TestCase
test "logging to journal and checking size" do
ChaoticJob.log_to_journal!
assert_equal 1, ChaoticJob.journal_size
end
test "logging to journal and checking entries" do
ChaoticJob.log_to_journal!... | ruby | MIT | cc4dcdee30e5447fe0460a2b6afe644f05ec3c33 | 2026-01-04T17:40:32.691002Z | false |
fractaledmind/chaotic_job | https://github.com/fractaledmind/chaotic_job/blob/cc4dcdee30e5447fe0460a2b6afe644f05ec3c33/spec/spec_helper.rb | spec/spec_helper.rb | require "simplecov"
SimpleCov.start do
enable_coverage :branch
primary_coverage :branch
add_filter "/test/"
add_filter "/spec/"
# Merge coverage results from different test suites
use_merging true
merge_timeout 3600 # 1 hour
command_name "RSpec"
# Track files that aren't loaded by tests
track_file... | ruby | MIT | cc4dcdee30e5447fe0460a2b6afe644f05ec3c33 | 2026-01-04T17:40:32.691002Z | false |
fractaledmind/chaotic_job | https://github.com/fractaledmind/chaotic_job/blob/cc4dcdee30e5447fe0460a2b6afe644f05ec3c33/spec/chaotic_job_spec.rb | spec/chaotic_job_spec.rb | RSpec.describe ChaoticJob do
it "works" do
expect(true).to eq(true)
end
end
| ruby | MIT | cc4dcdee30e5447fe0460a2b6afe644f05ec3c33 | 2026-01-04T17:40:32.691002Z | false |
fractaledmind/chaotic_job | https://github.com/fractaledmind/chaotic_job/blob/cc4dcdee30e5447fe0460a2b6afe644f05ec3c33/spec/chaotic_job/simulation_spec.rb | spec/chaotic_job/simulation_spec.rb | # frozen_string_literal: true
require "spec_helper"
RSpec.describe ChaoticJob::Simulation do
describe "#initialize" do
it "works with only job passed" do
simulation = described_class.new(TestJob.new)
stack = simulation.callstack.to_a
expect(stack.all? { |item| item.is_a?(ChaoticJob::TracedEve... | ruby | MIT | cc4dcdee30e5447fe0460a2b6afe644f05ec3c33 | 2026-01-04T17:40:32.691002Z | false |
fractaledmind/chaotic_job | https://github.com/fractaledmind/chaotic_job/blob/cc4dcdee30e5447fe0460a2b6afe644f05ec3c33/lib/chaotic_job.rb | lib/chaotic_job.rb | # frozen_string_literal: true
require_relative "chaotic_job/version"
require_relative "chaotic_job/journal"
require_relative "chaotic_job/performer"
require_relative "chaotic_job/tracer"
require_relative "chaotic_job/glitch"
require_relative "chaotic_job/scenario"
require_relative "chaotic_job/simulation"
require_rela... | ruby | MIT | cc4dcdee30e5447fe0460a2b6afe644f05ec3c33 | 2026-01-04T17:40:32.691002Z | false |
fractaledmind/chaotic_job | https://github.com/fractaledmind/chaotic_job/blob/cc4dcdee30e5447fe0460a2b6afe644f05ec3c33/lib/chaotic_job/version.rb | lib/chaotic_job/version.rb | # frozen_string_literal: true
module ChaoticJob
VERSION = "0.11.2"
end
| ruby | MIT | cc4dcdee30e5447fe0460a2b6afe644f05ec3c33 | 2026-01-04T17:40:32.691002Z | false |
fractaledmind/chaotic_job | https://github.com/fractaledmind/chaotic_job/blob/cc4dcdee30e5447fe0460a2b6afe644f05ec3c33/lib/chaotic_job/scenario.rb | lib/chaotic_job/scenario.rb | # frozen_string_literal: true
# Scenario.new(job).run { |scenario| ... }
# Scenario.new(job).success?
module ChaoticJob
class Scenario
attr_reader :events, :glitch, :job
def initialize(job, glitch:, raise: RetryableError, capture: nil)
@job = job
@glitch = (Glitch === glitch) ? glitch : (raise ... | ruby | MIT | cc4dcdee30e5447fe0460a2b6afe644f05ec3c33 | 2026-01-04T17:40:32.691002Z | false |
fractaledmind/chaotic_job | https://github.com/fractaledmind/chaotic_job/blob/cc4dcdee30e5447fe0460a2b6afe644f05ec3c33/lib/chaotic_job/tracer.rb | lib/chaotic_job/tracer.rb | # frozen_string_literal: true
# Tracer.new(tracing: Job)
# Tracer.new { |tp| tp.path.start_with? "foo" }
# tracer.capture { job.perform }
module ChaoticJob
class Tracer
def initialize(tracing: nil, stack: Stack.new, effect: nil, returns: nil, &block)
@constraint = block || Array(tracing)
@stack = st... | ruby | MIT | cc4dcdee30e5447fe0460a2b6afe644f05ec3c33 | 2026-01-04T17:40:32.691002Z | false |
fractaledmind/chaotic_job | https://github.com/fractaledmind/chaotic_job/blob/cc4dcdee30e5447fe0460a2b6afe644f05ec3c33/lib/chaotic_job/relay.rb | lib/chaotic_job/relay.rb | # frozen_string_literal: true
# Relay.new(jobs).define { |race| assert something }
module ChaoticJob
class Relay
attr_reader :sample
def initialize(*jobs, tracing: nil, sample: 10, test: nil, seed: nil)
@jobs = jobs
@tracing = tracing
@callstacks = nil
@possibilities = nil
@sa... | ruby | MIT | cc4dcdee30e5447fe0460a2b6afe644f05ec3c33 | 2026-01-04T17:40:32.691002Z | false |
fractaledmind/chaotic_job | https://github.com/fractaledmind/chaotic_job/blob/cc4dcdee30e5447fe0460a2b6afe644f05ec3c33/lib/chaotic_job/journal.rb | lib/chaotic_job/journal.rb | # frozen_string_literal: true
# Journal.log
# Journal.log(thing, scope: :special)
# Journal.total
# Journal.total(scope: :special)
# Journal.all
module ChaoticJob
module Journal
extend self
DEFAULT = Object.new.freeze
def reset!
@logs = {}
end
def log(item = DEFAULT, scope: :default)
... | ruby | MIT | cc4dcdee30e5447fe0460a2b6afe644f05ec3c33 | 2026-01-04T17:40:32.691002Z | false |
fractaledmind/chaotic_job | https://github.com/fractaledmind/chaotic_job/blob/cc4dcdee30e5447fe0460a2b6afe644f05ec3c33/lib/chaotic_job/glitch.rb | lib/chaotic_job/glitch.rb | # frozen_string_literal: true
# Glitch.before_line("job_crucible.rb:10") { do_anything }
# Glitch.before_call("Model#method", String, name: "Joel") { do_anything }
# Glitch.before_return("Model#method", String, name: "Joel") { do_anything }
# Glitch.inject! { execute code to glitch }
module ChaoticJob
class Glitch
... | ruby | MIT | cc4dcdee30e5447fe0460a2b6afe644f05ec3c33 | 2026-01-04T17:40:32.691002Z | false |
fractaledmind/chaotic_job | https://github.com/fractaledmind/chaotic_job/blob/cc4dcdee30e5447fe0460a2b6afe644f05ec3c33/lib/chaotic_job/simulation.rb | lib/chaotic_job/simulation.rb | # frozen_string_literal: true
# Simulation.new(job).define { |scenario| assert something }
module ChaoticJob
class Simulation
attr_reader :callstack, :tracing
def initialize(job, tracing: nil, callstack: nil, variations: nil, test: nil, seed: nil, perform_only_jobs_within: nil, capture: nil)
@templat... | ruby | MIT | cc4dcdee30e5447fe0460a2b6afe644f05ec3c33 | 2026-01-04T17:40:32.691002Z | false |
fractaledmind/chaotic_job | https://github.com/fractaledmind/chaotic_job/blob/cc4dcdee30e5447fe0460a2b6afe644f05ec3c33/lib/chaotic_job/performer.rb | lib/chaotic_job/performer.rb | # frozen_string_literal: true
require "active_job"
module ChaoticJob
module Performer
extend ActiveJob::TestHelper
extend self
def perform_all
until (jobs = enqueued_jobs_where).empty?
perform(jobs)
end
end
def perform_all_before(cutoff)
time = resolve_cutoff(cutoff)
... | ruby | MIT | cc4dcdee30e5447fe0460a2b6afe644f05ec3c33 | 2026-01-04T17:40:32.691002Z | false |
fractaledmind/chaotic_job | https://github.com/fractaledmind/chaotic_job/blob/cc4dcdee30e5447fe0460a2b6afe644f05ec3c33/lib/chaotic_job/race.rb | lib/chaotic_job/race.rb | # frozen_string_literal: true
# Race.new(jobs).run { |scenario| ... }
# Race.new(jobs).success?
module ChaoticJob
class Race
EVENT = :event_occurred
attr_reader :executions
def initialize(jobs, schedule:, capture: nil)
@jobs = jobs
@schedule = schedule
@capture = capture
@execu... | ruby | MIT | cc4dcdee30e5447fe0460a2b6afe644f05ec3c33 | 2026-01-04T17:40:32.691002Z | false |
fractaledmind/chaotic_job | https://github.com/fractaledmind/chaotic_job/blob/cc4dcdee30e5447fe0460a2b6afe644f05ec3c33/lib/chaotic_job/switch.rb | lib/chaotic_job/switch.rb | # frozen_string_literal: true
module ChaoticJob
module Switch
extend self
def on?
@value ||= false
true == @value
end
def off?
@value ||= false
false == @value
end
def on!
@value = true
end
def off!
@value = false
end
end
end
| ruby | MIT | cc4dcdee30e5447fe0460a2b6afe644f05ec3c33 | 2026-01-04T17:40:32.691002Z | false |
vmetrix/vacuumetrix | https://github.com/vmetrix/vacuumetrix/blob/9fd0fca90723186344bec22c30e81db4a543c67d/bin/AWScloudwatchElasticache.rb | bin/AWScloudwatchElasticache.rb | #!/usr/bin/env ruby
## Elasticache stats
### David Lutz
### 2012-08-01
### Updated on 2014-02-08 to add support for Redis engine
### Alejandro Ferrari (support@wmconsulting.info)
$:.unshift File.join(File.dirname(__FILE__), *%w[.. conf])
$:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
require 'config'
requi... | ruby | MIT | 9fd0fca90723186344bec22c30e81db4a543c67d | 2026-01-04T17:40:36.031118Z | false |
vmetrix/vacuumetrix | https://github.com/vmetrix/vacuumetrix/blob/9fd0fca90723186344bec22c30e81db4a543c67d/bin/twitter_followers.rb | bin/twitter_followers.rb | #!/usr/bin/env ruby
### How many twitter followers do we have?
### David Lutz
### 2012-07-23
###
### Moved to api v1.1 as v1 is deprecated
### 2013-12-07
## new versions of ruby don't need the following line
$:.unshift File.join(File.dirname(__FILE__), *%w[.. conf])
$:.unshift File.join(File.dirname(__FILE__), *%w[.. ... | ruby | MIT | 9fd0fca90723186344bec22c30e81db4a543c67d | 2026-01-04T17:40:36.031118Z | false |
vmetrix/vacuumetrix | https://github.com/vmetrix/vacuumetrix/blob/9fd0fca90723186344bec22c30e81db4a543c67d/bin/AWScloudwatchELB.rb | bin/AWScloudwatchELB.rb | #!/usr/bin/env ruby
## grab metrics from AWS cloudwatch
### David Lutz
### 2012-07-15
### gem install fog --no-ri --no-rdoc
$:.unshift File.join(File.dirname(__FILE__), *%w[.. conf])
$:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
require 'config'
require 'Sendit'
require 'rubygems' if RUBY_VERSION < "1.9"... | ruby | MIT | 9fd0fca90723186344bec22c30e81db4a543c67d | 2026-01-04T17:40:36.031118Z | false |
vmetrix/vacuumetrix | https://github.com/vmetrix/vacuumetrix/blob/9fd0fca90723186344bec22c30e81db4a543c67d/bin/facebook.rb | bin/facebook.rb | #!/usr/bin/env ruby
### How many facebook likes do we have?
### David Lutz
### 2012-07-23
$:.unshift File.join(File.dirname(__FILE__), *%w[.. conf])
$:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
require 'config'
require 'Sendit'
## new versions of ruby don't need the following line
require 'rubygems' if R... | ruby | MIT | 9fd0fca90723186344bec22c30e81db4a543c67d | 2026-01-04T17:40:36.031118Z | false |
vmetrix/vacuumetrix | https://github.com/vmetrix/vacuumetrix/blob/9fd0fca90723186344bec22c30e81db4a543c67d/bin/NewrelicCustom.rb | bin/NewrelicCustom.rb | #!/usr/bin/env ruby
### grab metrics from newrelic and put them into graphite
### David Lutz
### 2012-06-08
$:.unshift File.join(File.dirname(__FILE__), *%w[.. conf])
$:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
require 'config'
require 'Sendit'
## new versions of ruby don't need the following line
requi... | ruby | MIT | 9fd0fca90723186344bec22c30e81db4a543c67d | 2026-01-04T17:40:36.031118Z | false |
vmetrix/vacuumetrix | https://github.com/vmetrix/vacuumetrix/blob/9fd0fca90723186344bec22c30e81db4a543c67d/bin/AWScloudwatchLimits.rb | bin/AWScloudwatchLimits.rb | #!/usr/bin/env ruby
## grab AWS limits
### gem install fog --no-ri --no-rdoc
### gem install aws-sdk --no-ri --no-rdoc
$:.unshift File.join(File.dirname(__FILE__), *%w[.. conf])
$:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
require 'config'
require 'Sendit'
require 'rubygems' if RUBY_VERSION < "1.9"
requ... | ruby | MIT | 9fd0fca90723186344bec22c30e81db4a543c67d | 2026-01-04T17:40:36.031118Z | false |
vmetrix/vacuumetrix | https://github.com/vmetrix/vacuumetrix/blob/9fd0fca90723186344bec22c30e81db4a543c67d/bin/Neustar.rb | bin/Neustar.rb | #!/usr/bin/env ruby
## grab metrics from Neustar
### David Lutz
### 2012-07-22
# Neustar API example code https://apidocs.wpm.neustar.biz/
$:.unshift File.join(File.dirname(__FILE__), *%w[.. conf])
$:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
require 'config'
require 'Sendit'
require 'rubygems' if RUBY_V... | ruby | MIT | 9fd0fca90723186344bec22c30e81db4a543c67d | 2026-01-04T17:40:36.031118Z | false |
vmetrix/vacuumetrix | https://github.com/vmetrix/vacuumetrix/blob/9fd0fca90723186344bec22c30e81db4a543c67d/bin/AWScloudwatchLimitsTA.rb | bin/AWScloudwatchLimitsTA.rb | #!/usr/bin/env ruby
## grab AWS limits from Trusted Advisor
### gem install aws-sdk --no-ri --no-rdoc
$:.unshift File.join(File.dirname(__FILE__), *%w[.. conf])
$:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
require 'config'
require 'Sendit'
require 'rubygems' if RUBY_VERSION < "1.9"
require 'json'
require... | ruby | MIT | 9fd0fca90723186344bec22c30e81db4a543c67d | 2026-01-04T17:40:36.031118Z | false |
vmetrix/vacuumetrix | https://github.com/vmetrix/vacuumetrix/blob/9fd0fca90723186344bec22c30e81db4a543c67d/bin/AWScloudwatchEC2AutoScale.rb | bin/AWScloudwatchEC2AutoScale.rb | #!/usr/bin/env ruby
$:.unshift File.join(File.dirname(__FILE__), *%w[.. conf])
$:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
require 'config'
require 'Sendit'
require 'rubygems' if RUBY_VERSION < "1.9"
require 'fog'
require 'optparse'
require 'thread'
begin
require 'system_timer'
SomeTimer = SystemTi... | ruby | MIT | 9fd0fca90723186344bec22c30e81db4a543c67d | 2026-01-04T17:40:36.031118Z | false |
vmetrix/vacuumetrix | https://github.com/vmetrix/vacuumetrix/blob/9fd0fca90723186344bec22c30e81db4a543c67d/bin/AWScloudwatchCustom.rb | bin/AWScloudwatchCustom.rb | #!/usr/bin/env ruby
## grab custom metrics from AWS cloudwatch
### based on scripts by:
### David Lutz
### 2012-07-15
### gem install fog --no-ri --no-rdoc
$:.unshift File.join(File.dirname(__FILE__), *%w[.. conf])
$:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
require 'config'
require 'Sendit'
require 'r... | ruby | MIT | 9fd0fca90723186344bec22c30e81db4a543c67d | 2026-01-04T17:40:36.031118Z | false |
vmetrix/vacuumetrix | https://github.com/vmetrix/vacuumetrix/blob/9fd0fca90723186344bec22c30e81db4a543c67d/bin/AWScloudwatchDynamo.rb | bin/AWScloudwatchDynamo.rb | #!/usr/bin/env ruby
$:.unshift File.join(File.dirname(__FILE__), *%w[.. conf])
$:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
require 'config'
require 'Sendit'
require 'rubygems' if RUBY_VERSION < "1.9"
require 'fog'
require 'json'
require 'optparse'
options = {
:start_offset => 1200,
:end_offset ... | ruby | MIT | 9fd0fca90723186344bec22c30e81db4a543c67d | 2026-01-04T17:40:36.031118Z | false |
vmetrix/vacuumetrix | https://github.com/vmetrix/vacuumetrix/blob/9fd0fca90723186344bec22c30e81db4a543c67d/bin/AWScloudwatchEBS.rb | bin/AWScloudwatchEBS.rb | #!/usr/bin/env ruby
## EBS stats. We don't really use much EBS, so I don't know if this is going to be very useful. Feedback please!
### David Lutz
### 2012-07-19
### gem install fog --no-ri --no-rdoc
$:.unshift File.join(File.dirname(__FILE__), *%w[.. conf])
$:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])... | ruby | MIT | 9fd0fca90723186344bec22c30e81db4a543c67d | 2026-01-04T17:40:36.031118Z | false |
vmetrix/vacuumetrix | https://github.com/vmetrix/vacuumetrix/blob/9fd0fca90723186344bec22c30e81db4a543c67d/bin/AWScloudwatchRDS.rb | bin/AWScloudwatchRDS.rb | #!/usr/bin/env ruby
## grab metrics from AWS cloudwatch
### David Lutz
### 2012-07-10
### gem install fog --no-ri --no-rdoc
### if no argument is specified get metrics for all databases
### if a database name is specified as an argument then only show that database
$:.unshift File.join(File.dirname(__FILE__), *%w[.. ... | ruby | MIT | 9fd0fca90723186344bec22c30e81db4a543c67d | 2026-01-04T17:40:36.031118Z | false |
vmetrix/vacuumetrix | https://github.com/vmetrix/vacuumetrix/blob/9fd0fca90723186344bec22c30e81db4a543c67d/bin/AWScountEC2.rb | bin/AWScountEC2.rb | #!/usr/bin/env ruby
## Count how many of each type of EC2 instance we're running
## This works well as a stacked graph
### David Lutz
### 2012-07-16
### gem install fog --no-ri --no-rdoc
$:.unshift File.join(File.dirname(__FILE__), *%w[.. conf])
$:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
require 'conf... | ruby | MIT | 9fd0fca90723186344bec22c30e81db4a543c67d | 2026-01-04T17:40:36.031118Z | false |
vmetrix/vacuumetrix | https://github.com/vmetrix/vacuumetrix/blob/9fd0fca90723186344bec22c30e81db4a543c67d/bin/AWScloudwatchBilling.rb | bin/AWScloudwatchBilling.rb | #!/usr/bin/env ruby
$:.unshift File.join(File.dirname(__FILE__), *%w[.. conf])
$:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
require 'config'
require 'Sendit'
require 'rubygems' if RUBY_VERSION < "1.9"
require 'fog'
require 'json'
require 'optparse'
options = {
:start_offset => 21660,
:end_offset... | ruby | MIT | 9fd0fca90723186344bec22c30e81db4a543c67d | 2026-01-04T17:40:36.031118Z | false |
vmetrix/vacuumetrix | https://github.com/vmetrix/vacuumetrix/blob/9fd0fca90723186344bec22c30e81db4a543c67d/bin/AWScloudwatchEC2.rb | bin/AWScloudwatchEC2.rb | #!/usr/bin/env ruby
$:.unshift File.join(File.dirname(__FILE__), *%w[.. conf])
$:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
require 'config'
require 'Sendit'
require 'rubygems' if RUBY_VERSION < "1.9"
require 'fog'
require 'optparse'
require 'thread'
begin
require 'system_timer'
SomeTimer = SystemTi... | ruby | MIT | 9fd0fca90723186344bec22c30e81db4a543c67d | 2026-01-04T17:40:36.031118Z | false |
vmetrix/vacuumetrix | https://github.com/vmetrix/vacuumetrix/blob/9fd0fca90723186344bec22c30e81db4a543c67d/bin/NewrelicEnduser.rb | bin/NewrelicEnduser.rb | #!/usr/bin/env ruby
### grab metrics from newrelic and put them into graphite
### David Lutz
### 2012-06-08
$:.unshift File.join(File.dirname(__FILE__), *%w[.. conf])
$:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
require 'config'
require 'Sendit'
## new versions of ruby don't need the following line
requi... | ruby | MIT | 9fd0fca90723186344bec22c30e81db4a543c67d | 2026-01-04T17:40:36.031118Z | false |
vmetrix/vacuumetrix | https://github.com/vmetrix/vacuumetrix/blob/9fd0fca90723186344bec22c30e81db4a543c67d/bin/NewrelicThresholds.rb | bin/NewrelicThresholds.rb | #!/usr/bin/env ruby
### grab metrics from newrelic and put them into graphite
### David Lutz
### 2012-06-15
### to use: apt-get install ruby
### apt-get install build-essential
### apt-get install libcurl3 libcurl3-gnutls libcurl4-openssl-dev
### gem install curl curb json xmlsimple --no-ri --no-rdoc
#
$:.unshift File... | ruby | MIT | 9fd0fca90723186344bec22c30e81db4a543c67d | 2026-01-04T17:40:36.031118Z | false |
vmetrix/vacuumetrix | https://github.com/vmetrix/vacuumetrix/blob/9fd0fca90723186344bec22c30e81db4a543c67d/lib/SendGanglia.rb | lib/SendGanglia.rb | require 'gmetric'
def SendGanglia(metricpath, metricvalue)
begin
Ganglia::GMetric.send($gmondserver, $gmondport, {
:name => metricpath,
:units => '',
:type => 'float',
:value => metricvalue.to_f,
:tmax => 60,
:dmax => 60
})
rescue
puts "can't send to g... | ruby | MIT | 9fd0fca90723186344bec22c30e81db4a543c67d | 2026-01-04T17:40:36.031118Z | false |
vmetrix/vacuumetrix | https://github.com/vmetrix/vacuumetrix/blob/9fd0fca90723186344bec22c30e81db4a543c67d/lib/SendGraphite.rb | lib/SendGraphite.rb | ## send it
require 'socket'
begin
require 'system_timer'
SomeTimer = SystemTimer
rescue LoadError
require 'timeout'
SomeTimer = Timeout
end
def SendGraphite(metricpath, metricvalue, metrictimestamp)
retries = $graphiteretries
metricpath = "#{$graphiteprefix}.#{metricpath}" if $graphiteprefix && !$graphitep... | ruby | MIT | 9fd0fca90723186344bec22c30e81db4a543c67d | 2026-01-04T17:40:36.031118Z | false |
vmetrix/vacuumetrix | https://github.com/vmetrix/vacuumetrix/blob/9fd0fca90723186344bec22c30e81db4a543c67d/lib/Sendit.rb | lib/Sendit.rb | ## send it to the backends
def Sendit(metricpath, metricvalue, metrictimestamp)
if !$graphiteserver.nil? and !$graphiteserver.empty?
require 'SendGraphite'
# puts metricpath + " " + metricvalue.to_s + " " + metrictimestamp.to_s
SendGraphite metricpath, metricvalue, metrictimestamp
end
if !$gmondse... | ruby | MIT | 9fd0fca90723186344bec22c30e81db4a543c67d | 2026-01-04T17:40:36.031118Z | false |
vmetrix/vacuumetrix | https://github.com/vmetrix/vacuumetrix/blob/9fd0fca90723186344bec22c30e81db4a543c67d/lib/SendOpenTSDB.rb | lib/SendOpenTSDB.rb | ## send it
require 'socket'
def SendOpenTSDB(metricpath, metricvalue, metrictimestamp, tag)
begin
message = "put " + metricpath + " " + metrictimestamp.to_s + " " + metricvalue.to_s + " " + tag
# puts message
sock = TCPSocket.new($opentsdbserver, $opentsdbport)
sock.puts(message)
sock.close
resc... | ruby | MIT | 9fd0fca90723186344bec22c30e81db4a543c67d | 2026-01-04T17:40:36.031118Z | false |
rgrove/crass | https://github.com/rgrove/crass/blob/b51a88e541a3ba8657f03e63fe4c4f65fcaa04ca/test/test_parse_properties.rb | test/test_parse_properties.rb | # encoding: utf-8
# Includes tests based on Simon Sapin's CSS parsing tests:
# https://github.com/SimonSapin/css-parsing-tests/
require_relative 'support/common'
describe 'Crass::Parser' do
make_my_diffs_pretty!
parallelize_me!
describe '#parse_properties' do
def parse(*args)
CP.parse_properties(*ar... | ruby | MIT | b51a88e541a3ba8657f03e63fe4c4f65fcaa04ca | 2026-01-04T17:40:39.783822Z | false |
rgrove/crass | https://github.com/rgrove/crass/blob/b51a88e541a3ba8657f03e63fe4c4f65fcaa04ca/test/test_serialization.rb | test/test_serialization.rb | # encoding: utf-8
require_relative 'support/common'
describe 'Serialization' do
make_my_diffs_pretty!
parallelize_me!
# Parse a bunch of real-world CSS and make sure it's the same when we
# serialize it.
Dir[File.join(File.dirname(__FILE__), 'support/serialization/*.css')].each do |filepath|
it "should ... | ruby | MIT | b51a88e541a3ba8657f03e63fe4c4f65fcaa04ca | 2026-01-04T17:40:39.783822Z | false |
rgrove/crass | https://github.com/rgrove/crass/blob/b51a88e541a3ba8657f03e63fe4c4f65fcaa04ca/test/test_crass.rb | test/test_crass.rb | # encoding: utf-8
require_relative 'support/common'
describe 'Crass' do
make_my_diffs_pretty!
parallelize_me!
it 'parse_properties() should call Crass::Parser.parse_properties' do
assert_equal(
CP.parse_properties("a:b; c:d 42!important;\n"),
Crass.parse_properties("a:b; c:d 42!important;\n")
... | ruby | MIT | b51a88e541a3ba8657f03e63fe4c4f65fcaa04ca | 2026-01-04T17:40:39.783822Z | false |
rgrove/crass | https://github.com/rgrove/crass/blob/b51a88e541a3ba8657f03e63fe4c4f65fcaa04ca/test/test_parse_stylesheet.rb | test/test_parse_stylesheet.rb | # encoding: utf-8
require_relative 'support/common'
require_relative 'shared/parse_rules'
describe 'Crass::Parser' do
make_my_diffs_pretty!
parallelize_me!
describe '#parse_stylesheet' do
def parse(*args)
CP.parse_stylesheet(*args)
end
behaves_like 'parsing a list of rules'
end
end
| ruby | MIT | b51a88e541a3ba8657f03e63fe4c4f65fcaa04ca | 2026-01-04T17:40:39.783822Z | false |
rgrove/crass | https://github.com/rgrove/crass/blob/b51a88e541a3ba8657f03e63fe4c4f65fcaa04ca/test/test_css_parsing_tests.rb | test/test_css_parsing_tests.rb | # encoding: utf-8
# This file loads and runs Simon Sapin's CSS parsing tests, which live under the
# test/css-parsing-tests directory. The original test repo can be found at:
#
# https://github.com/SimonSapin/css-parsing-tests/
require 'json'
require_relative 'support/common'
def load_css_tests(filename)
JSON.pars... | ruby | MIT | b51a88e541a3ba8657f03e63fe4c4f65fcaa04ca | 2026-01-04T17:40:39.783822Z | false |
rgrove/crass | https://github.com/rgrove/crass/blob/b51a88e541a3ba8657f03e63fe4c4f65fcaa04ca/test/test_parse_rules.rb | test/test_parse_rules.rb | # encoding: utf-8
require_relative 'support/common'
require_relative 'shared/parse_rules'
describe 'Crass::Parser' do
make_my_diffs_pretty!
parallelize_me!
describe '#parse_rules' do
def parse(*args)
CP.parse_rules(*args)
end
behaves_like 'parsing a list of rules'
end
end
| ruby | MIT | b51a88e541a3ba8657f03e63fe4c4f65fcaa04ca | 2026-01-04T17:40:39.783822Z | false |
rgrove/crass | https://github.com/rgrove/crass/blob/b51a88e541a3ba8657f03e63fe4c4f65fcaa04ca/test/support/common.rb | test/support/common.rb | # encoding: utf-8
gem 'minitest'
require 'minitest/autorun'
require_relative '../../lib/crass'
CP = Crass::Parser
CT = Crass::Tokenizer
# Hack shared test support into Minitest.
Minitest::Spec.class_eval do
def self.shared_tests
@shared_tests ||= {}
end
end
module Minitest::Spec::SharedTests
def behaves_l... | ruby | MIT | b51a88e541a3ba8657f03e63fe4c4f65fcaa04ca | 2026-01-04T17:40:39.783822Z | false |
rgrove/crass | https://github.com/rgrove/crass/blob/b51a88e541a3ba8657f03e63fe4c4f65fcaa04ca/test/shared/parse_rules.rb | test/shared/parse_rules.rb | # encoding: utf-8
# Includes tests based on Simon Sapin's CSS parsing tests:
# https://github.com/SimonSapin/css-parsing-tests/
shared_tests_for 'parsing a list of rules' do
it 'should parse an empty stylesheet' do
assert_equal([], parse(''))
assert_equal([{:node=>:error, :value=>"invalid"}], parse('foo'))
... | ruby | MIT | b51a88e541a3ba8657f03e63fe4c4f65fcaa04ca | 2026-01-04T17:40:39.783822Z | false |
rgrove/crass | https://github.com/rgrove/crass/blob/b51a88e541a3ba8657f03e63fe4c4f65fcaa04ca/lib/crass.rb | lib/crass.rb | # encoding: utf-8
require_relative 'crass/parser'
# A CSS parser based on the CSS Syntax Module Level 3 spec.
module Crass
# Parses _input_ as a CSS stylesheet and returns a parse tree.
#
# See {Tokenizer#initialize} for _options_.
def self.parse(input, options = {})
Parser.parse_stylesheet(input, options... | ruby | MIT | b51a88e541a3ba8657f03e63fe4c4f65fcaa04ca | 2026-01-04T17:40:39.783822Z | false |
rgrove/crass | https://github.com/rgrove/crass/blob/b51a88e541a3ba8657f03e63fe4c4f65fcaa04ca/lib/crass/version.rb | lib/crass/version.rb | # encoding: utf-8
module Crass
VERSION = '1.0.6'
end
| ruby | MIT | b51a88e541a3ba8657f03e63fe4c4f65fcaa04ca | 2026-01-04T17:40:39.783822Z | false |
rgrove/crass | https://github.com/rgrove/crass/blob/b51a88e541a3ba8657f03e63fe4c4f65fcaa04ca/lib/crass/tokenizer.rb | lib/crass/tokenizer.rb | # encoding: utf-8
require_relative 'scanner'
module Crass
# Tokenizes a CSS string.
#
# 4. https://www.w3.org/TR/2013/WD-css-syntax-3-20130919/#tokenization
class Tokenizer
RE_COMMENT_CLOSE = /\*\//
RE_DIGIT = /[0-9]+/
RE_ESCAPE = /\\[^\n]/
RE_HEX = /[0-9A-Fa-f... | ruby | MIT | b51a88e541a3ba8657f03e63fe4c4f65fcaa04ca | 2026-01-04T17:40:39.783822Z | false |
rgrove/crass | https://github.com/rgrove/crass/blob/b51a88e541a3ba8657f03e63fe4c4f65fcaa04ca/lib/crass/parser.rb | lib/crass/parser.rb | # encoding: utf-8
require_relative 'token-scanner'
require_relative 'tokenizer'
module Crass
# Parses a CSS string or list of tokens.
#
# 5. https://www.w3.org/TR/2013/WD-css-syntax-3-20130919/#parsing
class Parser
BLOCK_END_TOKENS = {
:'{' => :'}',
:'[' => :']',
:'(' => :')'
}
... | ruby | MIT | b51a88e541a3ba8657f03e63fe4c4f65fcaa04ca | 2026-01-04T17:40:39.783822Z | false |
rgrove/crass | https://github.com/rgrove/crass/blob/b51a88e541a3ba8657f03e63fe4c4f65fcaa04ca/lib/crass/scanner.rb | lib/crass/scanner.rb | # encoding: utf-8
require 'strscan'
module Crass
# Similar to a StringScanner, but with extra functionality needed to tokenize
# CSS while preserving the original text.
class Scanner
# Current character, or `nil` if the scanner hasn't yet consumed a
# character, or is at the end of the string.
attr_... | ruby | MIT | b51a88e541a3ba8657f03e63fe4c4f65fcaa04ca | 2026-01-04T17:40:39.783822Z | false |
rgrove/crass | https://github.com/rgrove/crass/blob/b51a88e541a3ba8657f03e63fe4c4f65fcaa04ca/lib/crass/token-scanner.rb | lib/crass/token-scanner.rb | # encoding: utf-8
module Crass
# Like {Scanner}, but for tokens!
class TokenScanner
attr_reader :current, :pos, :tokens
def initialize(tokens)
@tokens = tokens.to_a
reset
end
# Executes the given block, collects all tokens that are consumed during its
# execution, and returns the... | ruby | MIT | b51a88e541a3ba8657f03e63fe4c4f65fcaa04ca | 2026-01-04T17:40:39.783822Z | false |
encrypt-to/encrypt.to | https://github.com/encrypt-to/encrypt.to/blob/aae7f3fed63a727d96e2f8540db77bf7e48237e3/app/helpers/users_helper.rb | app/helpers/users_helper.rb | module UsersHelper
end
| ruby | MIT | aae7f3fed63a727d96e2f8540db77bf7e48237e3 | 2026-01-04T17:40:35.738039Z | false |
encrypt-to/encrypt.to | https://github.com/encrypt-to/encrypt.to/blob/aae7f3fed63a727d96e2f8540db77bf7e48237e3/app/helpers/messages_helper.rb | app/helpers/messages_helper.rb | module MessagesHelper
def receiver(to, form)
if to.is_a?(Array) and to.size > 1
form.select :receiver, to
elsif to.is_a?(Array) and to.size == 1
to[0]
else
to
end
end
def keyid(keyid, form)
if keyid.is_a?(Array) and keyid.size > 1
form.select :keyid, keyid
end
... | ruby | MIT | aae7f3fed63a727d96e2f8540db77bf7e48237e3 | 2026-01-04T17:40:35.738039Z | false |
encrypt-to/encrypt.to | https://github.com/encrypt-to/encrypt.to/blob/aae7f3fed63a727d96e2f8540db77bf7e48237e3/app/helpers/application_helper.rb | app/helpers/application_helper.rb | module ApplicationHelper
def loadjs(ctrl)
["devise/sessions", "devise/passwords", "registrations"].include?(ctrl) ? "users" : ctrl
end
end
| ruby | MIT | aae7f3fed63a727d96e2f8540db77bf7e48237e3 | 2026-01-04T17:40:35.738039Z | false |
encrypt-to/encrypt.to | https://github.com/encrypt-to/encrypt.to/blob/aae7f3fed63a727d96e2f8540db77bf7e48237e3/app/controllers/home_controller.rb | app/controllers/home_controller.rb | class HomeController < ApplicationController
# GET /
def index
@count = Message.all.size.to_s
end
# GET /terms
def terms
end
# GET /privacy
def privacy
end
# GET /blog
def blog
end
end
| ruby | MIT | aae7f3fed63a727d96e2f8540db77bf7e48237e3 | 2026-01-04T17:40:35.738039Z | false |
encrypt-to/encrypt.to | https://github.com/encrypt-to/encrypt.to/blob/aae7f3fed63a727d96e2f8540db77bf7e48237e3/app/controllers/users_controller.rb | app/controllers/users_controller.rb | class UsersController < ApplicationController
before_filter :authenticate_user!, except: [:show]
# GET /users/1/edit
def edit
@uid = params[:uid]
@user = User.where("lower(username) = ?", @uid.downcase).first
redirect_to "/" if current_user != @user
end
# PUT /users/1
def update
@uid = ... | ruby | MIT | aae7f3fed63a727d96e2f8540db77bf7e48237e3 | 2026-01-04T17:40:35.738039Z | false |
encrypt-to/encrypt.to | https://github.com/encrypt-to/encrypt.to/blob/aae7f3fed63a727d96e2f8540db77bf7e48237e3/app/controllers/registrations_controller.rb | app/controllers/registrations_controller.rb | class RegistrationsController < Devise::RegistrationsController
def create
params[:user][:plan] = "pro11"
super
MessageMailer.welcome_email(@user).deliver_now unless @user.invalid?
end
def destroy
super
MessageMailer.expire_email(@user).deliver_now
end
def update_card
@user = curr... | ruby | MIT | aae7f3fed63a727d96e2f8540db77bf7e48237e3 | 2026-01-04T17:40:35.738039Z | false |
encrypt-to/encrypt.to | https://github.com/encrypt-to/encrypt.to/blob/aae7f3fed63a727d96e2f8540db77bf7e48237e3/app/controllers/messages_controller.rb | app/controllers/messages_controller.rb | class MessagesController < ApplicationController
before_filter :set_locale
require './lib/keyserver.rb'
require './lib/util.rb'
require 'digest/md5'
# GET /messages/new
def new
@message = Message.new
@uid = params[:uid]
@uid.downcase! if @uid
if @uid
# get local user
@u... | ruby | MIT | aae7f3fed63a727d96e2f8540db77bf7e48237e3 | 2026-01-04T17:40:35.738039Z | false |
encrypt-to/encrypt.to | https://github.com/encrypt-to/encrypt.to/blob/aae7f3fed63a727d96e2f8540db77bf7e48237e3/app/controllers/application_controller.rb | app/controllers/application_controller.rb | class ApplicationController < ActionController::Base
protect_from_forgery
before_action :configure_permitted_parameters, if: :devise_controller?
protected
def configure_permitted_parameters
devise_parameter_sanitizer.permit(:sign_up) do |user_params|
user_params.permit(:plan, :username, :emai... | ruby | MIT | aae7f3fed63a727d96e2f8540db77bf7e48237e3 | 2026-01-04T17:40:35.738039Z | false |
encrypt-to/encrypt.to | https://github.com/encrypt-to/encrypt.to/blob/aae7f3fed63a727d96e2f8540db77bf7e48237e3/app/controllers/api/v1/keyserver_controller.rb | app/controllers/api/v1/keyserver_controller.rb | class Api::V1::KeyserverController < ActionController::Metal
require './lib/keyserver.rb'
require './lib/util.rb'
include ActionController::Helpers
include ActionController::Redirecting
include ActionController::Rendering
include ActionController::Renderers::All
include ActionController::Conditiona... | ruby | MIT | aae7f3fed63a727d96e2f8540db77bf7e48237e3 | 2026-01-04T17:40:35.738039Z | false |
encrypt-to/encrypt.to | https://github.com/encrypt-to/encrypt.to/blob/aae7f3fed63a727d96e2f8540db77bf7e48237e3/app/models/message.rb | app/models/message.rb | class Message < ActiveRecord::Base
attr_accessor :receiver, :body_input, :body_input, :body, :from, :to, :file, :filename, :keyid
end
| ruby | MIT | aae7f3fed63a727d96e2f8540db77bf7e48237e3 | 2026-01-04T17:40:35.738039Z | false |
encrypt-to/encrypt.to | https://github.com/encrypt-to/encrypt.to/blob/aae7f3fed63a727d96e2f8540db77bf7e48237e3/app/models/user.rb | app/models/user.rb | class User < ActiveRecord::Base
devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable
attr_accessor :name, :login, :stripe_token
validates :public_key, :presence => { :message => 'Public key cannot be blank!' }
validates :username, :uniqueness => { :message ... | ruby | MIT | aae7f3fed63a727d96e2f8540db77bf7e48237e3 | 2026-01-04T17:40:35.738039Z | false |
encrypt-to/encrypt.to | https://github.com/encrypt-to/encrypt.to/blob/aae7f3fed63a727d96e2f8540db77bf7e48237e3/app/mailers/message_mailer.rb | app/mailers/message_mailer.rb | class MessageMailer < ActionMailer::Base
include AbstractController::Callbacks
default from: APP_CONFIG['sender']
def send_message(to, from, body, *args)
opts = args.extract_options!
file = opts[:file] ||= false
filename = opts[:filename] ||= false
if file and filename
attachments[file... | ruby | MIT | aae7f3fed63a727d96e2f8540db77bf7e48237e3 | 2026-01-04T17:40:35.738039Z | false |
encrypt-to/encrypt.to | https://github.com/encrypt-to/encrypt.to/blob/aae7f3fed63a727d96e2f8540db77bf7e48237e3/db/seeds.rb | db/seeds.rb | ruby | MIT | aae7f3fed63a727d96e2f8540db77bf7e48237e3 | 2026-01-04T17:40:35.738039Z | false | |
encrypt-to/encrypt.to | https://github.com/encrypt-to/encrypt.to/blob/aae7f3fed63a727d96e2f8540db77bf7e48237e3/db/schema.rb | db/schema.rb | # encoding: UTF-8
# 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 sou... | ruby | MIT | aae7f3fed63a727d96e2f8540db77bf7e48237e3 | 2026-01-04T17:40:35.738039Z | false |
encrypt-to/encrypt.to | https://github.com/encrypt-to/encrypt.to/blob/aae7f3fed63a727d96e2f8540db77bf7e48237e3/db/migrate/20131221100555_add_devise_to_users.rb | db/migrate/20131221100555_add_devise_to_users.rb | class AddDeviseToUsers < ActiveRecord::Migration
def self.up
change_table(:users) do |t|
## Database authenticatable
t.string :email, :null => false, :default => ""
t.string :encrypted_password, :null => false, :default => ""
## Recoverable
t.string :reset_password_to... | ruby | MIT | aae7f3fed63a727d96e2f8540db77bf7e48237e3 | 2026-01-04T17:40:35.738039Z | false |
encrypt-to/encrypt.to | https://github.com/encrypt-to/encrypt.to/blob/aae7f3fed63a727d96e2f8540db77bf7e48237e3/db/migrate/20131218145227_add_hash_to_messages.rb | db/migrate/20131218145227_add_hash_to_messages.rb | class AddHashToMessages < ActiveRecord::Migration
def change
add_column :messages, :tohash, :string
add_column :messages, :fromhash, :string
end
end
| ruby | MIT | aae7f3fed63a727d96e2f8540db77bf7e48237e3 | 2026-01-04T17:40:35.738039Z | false |
encrypt-to/encrypt.to | https://github.com/encrypt-to/encrypt.to/blob/aae7f3fed63a727d96e2f8540db77bf7e48237e3/db/migrate/20150208155200_add_plan.rb | db/migrate/20150208155200_add_plan.rb | class AddPlan < ActiveRecord::Migration
def change
add_column :users, :plan, :string
end
end
| ruby | MIT | aae7f3fed63a727d96e2f8540db77bf7e48237e3 | 2026-01-04T17:40:35.738039Z | false |
encrypt-to/encrypt.to | https://github.com/encrypt-to/encrypt.to/blob/aae7f3fed63a727d96e2f8540db77bf7e48237e3/db/migrate/20140816174246_add_custom_layout.rb | db/migrate/20140816174246_add_custom_layout.rb | class AddCustomLayout < ActiveRecord::Migration
def change
add_column :users, :css_form_background, :string
add_column :users, :css_form_color, :string
add_column :users, :form_attachment, :boolean, default: true
add_column :users, :form_advanced_mode, :boolean, default: true
end
end
| ruby | MIT | aae7f3fed63a727d96e2f8540db77bf7e48237e3 | 2026-01-04T17:40:35.738039Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.