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 |
|---|---|---|---|---|---|---|---|---|
Coursemology/coursemology2 | https://github.com/Coursemology/coursemology2/blob/f6a688831806eb56d4d9a9c2942a1430d1ecd262/lib/autoload/preformatted_text_line_numbers_filter.rb | lib/autoload/preformatted_text_line_numbers_filter.rb | # frozen_string_literal: true
class PreformattedTextLineNumbersFilter < HTML::Pipeline::Filter
# The regex for splitting input by newlines.
NEWLINE_REGEX = /\r\n|\r|\n/
# Adds a line number before the code block.
# Takes a :line_start option which specifies the start line number, default is 1.
def call
d... | ruby | MIT | f6a688831806eb56d4d9a9c2942a1430d1ecd262 | 2026-01-04T17:32:51.807345Z | false |
Coursemology/coursemology2 | https://github.com/Coursemology/coursemology2/blob/f6a688831806eb56d4d9a9c2942a1430d1ecd262/lib/autoload/preformatted_text_line_split_filter.rb | lib/autoload/preformatted_text_line_split_filter.rb | # frozen_string_literal: true
class PreformattedTextLineSplitFilter < HTML::Pipeline::Filter
# The regex for splitting input by newlines.
NEWLINE_REGEX = /\r\n|\r|\n/
# Adds a line number before the code block.
# Takes a :line_start option which specifies the start line number, default is 1.
def call
doc... | ruby | MIT | f6a688831806eb56d4d9a9c2942a1430d1ecd262 | 2026-01-04T17:32:51.807345Z | false |
Coursemology/coursemology2 | https://github.com/Coursemology/coursemology2/blob/f6a688831806eb56d4d9a9c2942a1430d1ecd262/lib/autoload/ssid_error.rb | lib/autoload/ssid_error.rb | # frozen_string_literal: true
class SsidError < StandardError
def initialize(message = nil)
super(message || 'SSID might be moody :(. Please try again later or contact admin')
end
end
| ruby | MIT | f6a688831806eb56d4d9a9c2942a1430d1ecd262 | 2026-01-04T17:32:51.807345Z | false |
Coursemology/coursemology2 | https://github.com/Coursemology/coursemology2/blob/f6a688831806eb56d4d9a9c2942a1430d1ecd262/lib/autoload/componentize.rb | lib/autoload/componentize.rb | # frozen_string_literal: true
# Allows associating classes with other classes. This can form a nesting hierarchy. This is also
# used in Coursemology to associate components that a course can have enabled.
#
# In Development mode, classes are not eager loaded. Component hosts then do not know which
# components have be... | ruby | MIT | f6a688831806eb56d4d9a9c2942a1430d1ecd262 | 2026-01-04T17:32:51.807345Z | false |
Coursemology/coursemology2 | https://github.com/Coursemology/coursemology2/blob/f6a688831806eb56d4d9a9c2942a1430d1ecd262/lib/autoload/coursemology_docker_container.rb | lib/autoload/coursemology_docker_container.rb | # frozen_string_literal: true
class CoursemologyDockerContainer < Docker::Container
# The path to the Coursemology user home directory.
HOME_PATH = '/home/coursemology'
# The path to where the package will be extracted.
PACKAGE_PATH = File.join(HOME_PATH, 'package')
# With the old Makefile, the path to whe... | ruby | MIT | f6a688831806eb56d4d9a9c2942a1430d1ecd262 | 2026-01-04T17:32:51.807345Z | false |
Coursemology/coursemology2 | https://github.com/Coursemology/coursemology2/blob/f6a688831806eb56d4d9a9c2942a1430d1ecd262/lib/autoload/time_zone_validator.rb | lib/autoload/time_zone_validator.rb | # frozen_string_literal: true
class TimeZoneValidator < ActiveModel::Validator
# Custom time_zone validation as +#time_zone+ getter has been modified.
#
# Possible time_zones include +nil+ or those listed in ActiveSupport::TimeZone
def validate(record)
return if record[:time_zone].nil? || ActiveSupport::Tim... | ruby | MIT | f6a688831806eb56d4d9a9c2942a1430d1ecd262 | 2026-01-04T17:32:51.807345Z | false |
Coursemology/coursemology2 | https://github.com/Coursemology/coursemology2/blob/f6a688831806eb56d4d9a9c2942a1430d1ecd262/lib/autoload/koditsu_error.rb | lib/autoload/koditsu_error.rb | # frozen_string_literal: true
class KoditsuError < StandardError
def initialize(message = nil)
super(message || 'Koditsu might be moody :(. Please try again later or contact admin')
end
end
| ruby | MIT | f6a688831806eb56d4d9a9c2942a1430d1ecd262 | 2026-01-04T17:32:51.807345Z | false |
Coursemology/coursemology2 | https://github.com/Coursemology/coursemology2/blob/f6a688831806eb56d4d9a9c2942a1430d1ecd262/lib/autoload/duplicator.rb | lib/autoload/duplicator.rb | # frozen_string_literal: true
class Duplicator
attr_reader :options, :mode
# Create an instance of Duplicator to track duplicated objects.
#
# Options are used to store information that persists across duplication of objects.
#
# @param [Enumerable] excluded_objects An Enumerable of objects to be excluded ... | ruby | MIT | f6a688831806eb56d4d9a9c2942a1430d1ecd262 | 2026-01-04T17:32:51.807345Z | false |
Coursemology/coursemology2 | https://github.com/Coursemology/coursemology2/blob/f6a688831806eb56d4d9a9c2942a1430d1ecd262/lib/autoload/notifier/base/activity_wrapper.rb | lib/autoload/notifier/base/activity_wrapper.rb | # frozen_string_literal: true
class Notifier::Base::ActivityWrapper < SimpleDelegator
# Send notifications according to input type and recipient
#
# @param [Object] recipient The recipient of the notification
# @param [Symbol] type The type of notification
def notify(recipient, type)
super(recipient, type... | ruby | MIT | f6a688831806eb56d4d9a9c2942a1430d1ecd262 | 2026-01-04T17:32:51.807345Z | false |
Coursemology/coursemology2 | https://github.com/Coursemology/coursemology2/blob/f6a688831806eb56d4d9a9c2942a1430d1ecd262/lib/autoload/course/conditional/user_satisfiability_graph.rb | lib/autoload/course/conditional/user_satisfiability_graph.rb | # frozen_string_literal: true
# Satisfiability graph to evaluate the satisfiability of the conditionals for a course user.
class Course::Conditional::UserSatisfiabilityGraph
class EdgeSet < Hash
def initialize
super { |h, k| h[k] = Set.new }
end
def add(source, edge)
self[source] << edge
... | ruby | MIT | f6a688831806eb56d4d9a9c2942a1430d1ecd262 | 2026-01-04T17:32:51.807345Z | false |
Coursemology/coursemology2 | https://github.com/Coursemology/coursemology2/blob/f6a688831806eb56d4d9a9c2942a1430d1ecd262/lib/autoload/course/assessment/programming_test_case_report_builder.rb | lib/autoload/course/assessment/programming_test_case_report_builder.rb | # frozen_string_literal: true
# rubocop:disable Metrics/AbcSize
class Course::Assessment::ProgrammingTestCaseReportBuilder
def self.build_dummy_report(test_type, test_cases, file_type)
builder = Nokogiri::XML::Builder.new do |xml|
xml.testsuites do
xml.testsuite(
name: "#{test_type.capital... | ruby | MIT | f6a688831806eb56d4d9a9c2942a1430d1ecd262 | 2026-01-04T17:32:51.807345Z | false |
Coursemology/coursemology2 | https://github.com/Coursemology/coursemology2/blob/f6a688831806eb56d4d9a9c2942a1430d1ecd262/lib/autoload/course/assessment/programming_package.rb | lib/autoload/course/assessment/programming_package.rb | # frozen_string_literal: true
# Represents a programming package, containing the tests and submitted code for a given question.
#
# A package has these files at the very minimum:
#
# - +Makefile+: the makefile for building and executing the package. There are at least three
# targets:
# - +prepare+: for initialisin... | ruby | MIT | f6a688831806eb56d4d9a9c2942a1430d1ecd262 | 2026-01-04T17:32:51.807345Z | false |
Coursemology/coursemology2 | https://github.com/Coursemology/coursemology2/blob/f6a688831806eb56d4d9a9c2942a1430d1ecd262/lib/autoload/course/assessment/programming_test_case_report.rb | lib/autoload/course/assessment/programming_test_case_report.rb | # frozen_string_literal: true
# Represents a Programming Question test report.
#
# We adopt the JUnit XML format (documented at
# http://help.catchsoftware.com/display/ET/JUnit+Format) so that evaluations can be run in any
# language.
class Course::Assessment::ProgrammingTestCaseReport
class TestSuite
# Creates a... | ruby | MIT | f6a688831806eb56d4d9a9c2942a1430d1ecd262 | 2026-01-04T17:32:51.807345Z | false |
Coursemology/coursemology2 | https://github.com/Coursemology/coursemology2/blob/f6a688831806eb56d4d9a9c2942a1430d1ecd262/lib/autoload/course/assessment/java/java_programming_test_case_report.rb | lib/autoload/course/assessment/java/java_programming_test_case_report.rb | # frozen_string_literal: true
# Represents a Java Programming Question test report.
#
# Due to JUnit lacking the features to append meta data onto testcases,
# Java evaluation uses TestNG go get around this.
# This is used to parse TestNG's xml report.
class Course::Assessment::Java::JavaProgrammingTestCaseReport <
C... | ruby | MIT | f6a688831806eb56d4d9a9c2942a1430d1ecd262 | 2026-01-04T17:32:51.807345Z | false |
Coursemology/coursemology2 | https://github.com/Coursemology/coursemology2/blob/f6a688831806eb56d4d9a9c2942a1430d1ecd262/lib/autoload/active_job/queue_adapters/background_thread_adapter.rb | lib/autoload/active_job/queue_adapters/background_thread_adapter.rb | # frozen_string_literal: true
# == Active Job Background Thread adapter
#
# When enqueueing jobs with the Background Thread adapter the job will be executed in a
# background thread. This is a good balance between the hassle of setting up a full backend
# and having some asynchrony.
#
# To use the Inline set the queue_... | ruby | MIT | f6a688831806eb56d4d9a9c2942a1430d1ecd262 | 2026-01-04T17:32:51.807345Z | false |
Coursemology/coursemology2 | https://github.com/Coursemology/coursemology2/blob/f6a688831806eb56d4d9a9c2942a1430d1ecd262/config/application.rb | config/application.rb | # frozen_string_literal: true
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)
# Override default JSON parser/encoder to use Yajl
require 'yajl/json_gem'
# Load dotenv only in ... | ruby | MIT | f6a688831806eb56d4d9a9c2942a1430d1ecd262 | 2026-01-04T17:32:51.807345Z | false |
Coursemology/coursemology2 | https://github.com/Coursemology/coursemology2/blob/f6a688831806eb56d4d9a9c2942a1430d1ecd262/config/environment.rb | config/environment.rb | # frozen_string_literal: true
# Load the Rails application.
require_relative 'application'
# Initialize the Rails application.
Rails.application.initialize!
| ruby | MIT | f6a688831806eb56d4d9a9c2942a1430d1ecd262 | 2026-01-04T17:32:51.807345Z | false |
Coursemology/coursemology2 | https://github.com/Coursemology/coursemology2/blob/f6a688831806eb56d4d9a9c2942a1430d1ecd262/config/routes.rb | config/routes.rb | # frozen_string_literal: true
Rails.application.routes.draw do
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".
# You can have the root of your site routed with "root"
root 'application#index'
# Example of regular route:... | ruby | MIT | f6a688831806eb56d4d9a9c2942a1430d1ecd262 | 2026-01-04T17:32:51.807345Z | false |
Coursemology/coursemology2 | https://github.com/Coursemology/coursemology2/blob/f6a688831806eb56d4d9a9c2942a1430d1ecd262/config/spring.rb | config/spring.rb | # frozen_string_literal: true
%w[
.ruby-version
.rbenv-vars
tmp/restart.txt
tmp/caching-dev.txt
].each { |path| Spring.watch(path) }
| ruby | MIT | f6a688831806eb56d4d9a9c2942a1430d1ecd262 | 2026-01-04T17:32:51.807345Z | false |
Coursemology/coursemology2 | https://github.com/Coursemology/coursemology2/blob/f6a688831806eb56d4d9a9c2942a1430d1ecd262/config/boot.rb | config/boot.rb | # frozen_string_literal: true
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
require 'bundler/setup' # Set up gems listed in the Gemfile.
| ruby | MIT | f6a688831806eb56d4d9a9c2942a1430d1ecd262 | 2026-01-04T17:32:51.807345Z | false |
Coursemology/coursemology2 | https://github.com/Coursemology/coursemology2/blob/f6a688831806eb56d4d9a9c2942a1430d1ecd262/config/initializers/content_security_policy.rb | config/initializers/content_security_policy.rb | # frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# Define an application-wide content security policy
# For further information see the following documentation
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
# Rails.application.config.conten... | ruby | MIT | f6a688831806eb56d4d9a9c2942a1430d1ecd262 | 2026-01-04T17:32:51.807345Z | false |
Coursemology/coursemology2 | https://github.com/Coursemology/coursemology2/blob/f6a688831806eb56d4d9a9c2942a1430d1ecd262/config/initializers/send_file.rb | config/initializers/send_file.rb | # frozen_string_literal: true
public_download_dir = File.join(Rails.public_path, Application::Application.config.x.public_download_folder)
if Rails.env.development? || Rails.env.test?
if Rails.env.test? && !ParallelTests.first_process?
# Let all other processes wait until the first process created the folder
... | ruby | MIT | f6a688831806eb56d4d9a9c2942a1430d1ecd262 | 2026-01-04T17:32:51.807345Z | false |
Coursemology/coursemology2 | https://github.com/Coursemology/coursemology2/blob/f6a688831806eb56d4d9a9c2942a1430d1ecd262/config/initializers/filter_parameter_logging.rb | config/initializers/filter_parameter_logging.rb | # frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# Configure sensitive parameters which will be filtered from the log file.
Rails.application.config.filter_parameters += [
:password, :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn
]
| ruby | MIT | f6a688831806eb56d4d9a9c2942a1430d1ecd262 | 2026-01-04T17:32:51.807345Z | false |
Coursemology/coursemology2 | https://github.com/Coursemology/coursemology2/blob/f6a688831806eb56d4d9a9c2942a1430d1ecd262/config/initializers/recaptcha.rb | config/initializers/recaptcha.rb | # frozen_string_literal: true
Recaptcha.configure do |config|
if Rails.env.production?
config.site_key = ENV['GOOGLE_RECAPTCHA_SITE_KEY']
config.secret_key = ENV['GOOGLE_RECAPTCHA_SECRET_KEY']
else
# The following keys are for test and development environments only.
# You will always get No CAPTCHA ... | ruby | MIT | f6a688831806eb56d4d9a9c2942a1430d1ecd262 | 2026-01-04T17:32:51.807345Z | false |
Coursemology/coursemology2 | https://github.com/Coursemology/coursemology2/blob/f6a688831806eb56d4d9a9c2942a1430d1ecd262/config/initializers/application_controller_renderer.rb | config/initializers/application_controller_renderer.rb | # frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# ActiveSupport::Reloader.to_prepare do
# ApplicationController.renderer.defaults.merge!(
# http_host: 'example.org',
# https: false
# )
# end
| ruby | MIT | f6a688831806eb56d4d9a9c2942a1430d1ecd262 | 2026-01-04T17:32:51.807345Z | false |
Coursemology/coursemology2 | https://github.com/Coursemology/coursemology2/blob/f6a688831806eb56d4d9a9c2942a1430d1ecd262/config/initializers/extensions.rb | config/initializers/extensions.rb | # frozen_string_literal: true
Rails.application.config.before_initialize do
require "#{Rails.root}/lib/extensions.rb"
Extensions.load_all
end
| ruby | MIT | f6a688831806eb56d4d9a9c2942a1430d1ecd262 | 2026-01-04T17:32:51.807345Z | false |
Coursemology/coursemology2 | https://github.com/Coursemology/coursemology2/blob/f6a688831806eb56d4d9a9c2942a1430d1ecd262/config/initializers/action_cable_acts_as_tenant.rb | config/initializers/action_cable_acts_as_tenant.rb | # frozen_string_literal: true
module ActionCable::ActsAsTenantFilterConcern
extend ActiveSupport::Concern
private
# rubocop:disable Naming/AccessorMethodName
def set_current_tenant(current_tenant_object)
ActsAsTenant.current_tenant = current_tenant_object
ActsAsTenant.test_tenant = current_tenant_obje... | ruby | MIT | f6a688831806eb56d4d9a9c2942a1430d1ecd262 | 2026-01-04T17:32:51.807345Z | false |
Coursemology/coursemology2 | https://github.com/Coursemology/coursemology2/blob/f6a688831806eb56d4d9a9c2942a1430d1ecd262/config/initializers/redis.rb | config/initializers/redis.rb | # frozen_string_literal: true
redis_host = ENV['REDIS_HOST']
redis_port = 6379
redis_password = ENV['REDIS_PASS']
REDIS = Redis.new(host: redis_host, port: redis_port, password: redis_password, db: 0)
| ruby | MIT | f6a688831806eb56d4d9a9c2942a1430d1ecd262 | 2026-01-04T17:32:51.807345Z | false |
Coursemology/coursemology2 | https://github.com/Coursemology/coursemology2/blob/f6a688831806eb56d4d9a9c2942a1430d1ecd262/config/initializers/sidekiq.rb | config/initializers/sidekiq.rb | # frozen_string_literal: true
# Sidekiq Cron configuration to invoke ConsolidatedItemEmailJob for opening reminder emails,
# and VideoStatisticUpdateJob for per video watch_freq cache
schedule_file = 'config/schedule.yml'
# Use Sidekiq Cron gem (https://github.com/ondrejbartas/sidekiq-cron) to
# invoke scheduled jobs.... | ruby | MIT | f6a688831806eb56d4d9a9c2942a1430d1ecd262 | 2026-01-04T17:32:51.807345Z | false |
Coursemology/coursemology2 | https://github.com/Coursemology/coursemology2/blob/f6a688831806eb56d4d9a9c2942a1430d1ecd262/config/initializers/lograge.rb | config/initializers/lograge.rb | # frozen_string_literal: true
# config/initializers/lograge.rb
if Rails.env.production?
require 'lograge/sql/extension'
Rails.application.configure do
# Lograge config
config.lograge.enabled = true
config.lograge.formatter = Lograge::Formatters::Json.new
config.colorize_logging = false
config... | ruby | MIT | f6a688831806eb56d4d9a9c2942a1430d1ecd262 | 2026-01-04T17:32:51.807345Z | false |
Coursemology/coursemology2 | https://github.com/Coursemology/coursemology2/blob/f6a688831806eb56d4d9a9c2942a1430d1ecd262/config/initializers/session_store.rb | config/initializers/session_store.rb | # frozen_string_literal: true
# Be sure to restart your server when you modify this file.
Rails.application.config.session_store(
:cookie_store,
key: '_coursemology2_session',
same_site: :lax
)
| ruby | MIT | f6a688831806eb56d4d9a9c2942a1430d1ecd262 | 2026-01-04T17:32:51.807345Z | false |
Coursemology/coursemology2 | https://github.com/Coursemology/coursemology2/blob/f6a688831806eb56d4d9a9c2942a1430d1ecd262/config/initializers/bullet.rb | config/initializers/bullet.rb | # frozen_string_literal: true
Rails.application.configure do
if defined?(Bullet)
config.after_initialize do
Bullet.enable = true
Bullet.rails_logger = true
Bullet.counter_cache_enable = false
end
else
config.after_initialize do
ApplicationController.class_eval do
def with... | ruby | MIT | f6a688831806eb56d4d9a9c2942a1430d1ecd262 | 2026-01-04T17:32:51.807345Z | false |
Coursemology/coursemology2 | https://github.com/Coursemology/coursemology2/blob/f6a688831806eb56d4d9a9c2942a1430d1ecd262/config/initializers/devise.rb | config/initializers/devise.rb | # frozen_string_literal: true
# Use this hook to configure devise mailer, warden hooks and so forth.
# Many of these configuration options can be set straight in your model.
Devise.setup do |config|
# The secret key used by Devise. Devise uses this key to generate
# random tokens. Changing this key will render inva... | ruby | MIT | f6a688831806eb56d4d9a9c2942a1430d1ecd262 | 2026-01-04T17:32:51.807345Z | false |
Coursemology/coursemology2 | https://github.com/Coursemology/coursemology2/blob/f6a688831806eb56d4d9a9c2942a1430d1ecd262/config/initializers/acts_as_tenant.rb | config/initializers/acts_as_tenant.rb | # frozen_string_literal: true
ActsAsTenant.configure do |config|
# We need to specify a tenant.
config.require_tenant = true
end
| ruby | MIT | f6a688831806eb56d4d9a9c2942a1430d1ecd262 | 2026-01-04T17:32:51.807345Z | false |
Coursemology/coursemology2 | https://github.com/Coursemology/coursemology2/blob/f6a688831806eb56d4d9a9c2942a1430d1ecd262/config/initializers/worker_http_listener.rb | config/initializers/worker_http_listener.rb | # frozen_string_literal: true
# Start a HTTP listener on worker containers to capture AWS SQS events
# (e.g. health check, or jobs configured in cron.yaml EB configuration)
if Rails.env.production? && !ENV['IS_RAILS_WORKER'].nil?
require './app/services/sidekiq_api_service'
SIDEKIQ_API_SERVICE = SidekiqApiService... | ruby | MIT | f6a688831806eb56d4d9a9c2942a1430d1ecd262 | 2026-01-04T17:32:51.807345Z | false |
Coursemology/coursemology2 | https://github.com/Coursemology/coursemology2/blob/f6a688831806eb56d4d9a9c2942a1430d1ecd262/config/initializers/coverage.rb | config/initializers/coverage.rb | # frozen_string_literal: true
if Rails.env.test? && ENV['COLLECT_COVERAGE'] == 'true'
require 'simplecov'
require 'simplecov-lcov'
SimpleCov::Formatter::LcovFormatter.config do |c|
c.report_with_single_file = true
c.single_report_path = 'coverage/coursemology.lcov'
end
SimpleCov.formatter = SimpleCov... | ruby | MIT | f6a688831806eb56d4d9a9c2942a1430d1ecd262 | 2026-01-04T17:32:51.807345Z | false |
Coursemology/coursemology2 | https://github.com/Coursemology/coursemology2/blob/f6a688831806eb56d4d9a9c2942a1430d1ecd262/config/initializers/wrap_parameters.rb | config/initializers/wrap_parameters.rb | # frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# This file contains settings for ActionController::ParamsWrapper which
# is enabled by default.
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
ActiveSupport.on_load(:action_cont... | ruby | MIT | f6a688831806eb56d4d9a9c2942a1430d1ecd262 | 2026-01-04T17:32:51.807345Z | false |
Coursemology/coursemology2 | https://github.com/Coursemology/coursemology2/blob/f6a688831806eb56d4d9a9c2942a1430d1ecd262/config/initializers/aws.rb | config/initializers/aws.rb | # frozen_string_literal: true
if Rails.env.production?
require 'autoload/aws_wrapped_client'
require 'aws-sdk-cloudwatch'
require 'aws-sdk-s3'
# TODO: move this bucket to the proper staging/prod AWS account,
# so it can reuse the instance profile credentials used by other AWS operations
S3_CLIENT = Aws::S... | ruby | MIT | f6a688831806eb56d4d9a9c2942a1430d1ecd262 | 2026-01-04T17:32:51.807345Z | false |
Coursemology/coursemology2 | https://github.com/Coursemology/coursemology2/blob/f6a688831806eb56d4d9a9c2942a1430d1ecd262/config/initializers/inflections.rb | config/initializers/inflections.rb | # frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format. Inflections
# are locale specific, and you may define rules for as many different
# locales as you wish. All of these examples are active by default:
# ActiveSupport::Inflect... | ruby | MIT | f6a688831806eb56d4d9a9c2942a1430d1ecd262 | 2026-01-04T17:32:51.807345Z | false |
Coursemology/coursemology2 | https://github.com/Coursemology/coursemology2/blob/f6a688831806eb56d4d9a9c2942a1430d1ecd262/config/initializers/locale.rb | config/initializers/locale.rb | # frozen_string_literal: true
I18n.available_locales = [:en, :zh, :ko]
| ruby | MIT | f6a688831806eb56d4d9a9c2942a1430d1ecd262 | 2026-01-04T17:32:51.807345Z | false |
Coursemology/coursemology2 | https://github.com/Coursemology/coursemology2/blob/f6a688831806eb56d4d9a9c2942a1430d1ecd262/config/initializers/cookies_serializer.rb | config/initializers/cookies_serializer.rb | # frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# Specify a serializer for the signed and encrypted cookie jars.
# Valid options are :json, :marshal, and :hybrid.
Rails.application.config.action_dispatch.cookies_serializer = :json
| ruby | MIT | f6a688831806eb56d4d9a9c2942a1430d1ecd262 | 2026-01-04T17:32:51.807345Z | false |
Coursemology/coursemology2 | https://github.com/Coursemology/coursemology2/blob/f6a688831806eb56d4d9a9c2942a1430d1ecd262/config/initializers/argument_deserializer.rb | config/initializers/argument_deserializer.rb | # frozen_string_literal: true
require 'active_job'
require 'active_job/arguments'
# Patch for CVE-2018-16476
# TODO: remove after upgrade to rails 6
module ArgumentsNotDeserializingGlobalId
def deserialize_argument(argument)
case argument
when String
argument
else
super
end
end
end
Ac... | ruby | MIT | f6a688831806eb56d4d9a9c2942a1430d1ecd262 | 2026-01-04T17:32:51.807345Z | false |
Coursemology/coursemology2 | https://github.com/Coursemology/coursemology2/blob/f6a688831806eb56d4d9a9c2942a1430d1ecd262/config/initializers/llm_langchain.rb | config/initializers/llm_langchain.rb | # frozen_string_literal: true
require 'langchain'
# Create a global OpenAI client instance
LANGCHAIN_OPENAI = Langchain::LLM::OpenAI.new(
api_key: ENV.fetch('OPENAI_API_KEY', nil),
default_options: { temperature: 0, chat_model: 'gpt-4.1-mini' }
)
# RAGAS (Retrieval Augmented Generation Assessment) used to evaluate ... | ruby | MIT | f6a688831806eb56d4d9a9c2942a1430d1ecd262 | 2026-01-04T17:32:51.807345Z | false |
Coursemology/coursemology2 | https://github.com/Coursemology/coursemology2/blob/f6a688831806eb56d4d9a9c2942a1430d1ecd262/config/initializers/keycloak.rb | config/initializers/keycloak.rb | # frozen_string_literal: true
# Set proxy to connect in keycloak server
Keycloak.proxy = ''
# If true, then all request exception will explode in application (this is the default value)
Keycloak.generate_request_exception = true
# controller that manage the user session
Keycloak.keycloak_controller = 'session'
# realm... | ruby | MIT | f6a688831806eb56d4d9a9c2942a1430d1ecd262 | 2026-01-04T17:32:51.807345Z | false |
Coursemology/coursemology2 | https://github.com/Coursemology/coursemology2/blob/f6a688831806eb56d4d9a9c2942a1430d1ecd262/config/initializers/rack_mini_profiler.rb | config/initializers/rack_mini_profiler.rb | # frozen_string_literal: true
# TODO: Remove this once fully SPA
Rack::MiniProfiler.config.position = 'top-right'
| ruby | MIT | f6a688831806eb56d4d9a9c2942a1430d1ecd262 | 2026-01-04T17:32:51.807345Z | false |
Coursemology/coursemology2 | https://github.com/Coursemology/coursemology2/blob/f6a688831806eb56d4d9a9c2942a1430d1ecd262/config/initializers/carrier_wave.rb | config/initializers/carrier_wave.rb | # frozen_string_literal: true
CarrierWave.configure do |config|
if Rails.env.production?
require 'carrierwave/storage/fog'
config.storage = :fog
config.fog_credentials = {
provider: 'AWS',
aws_access_key_id: ENV['AWS_ACCESS_KEY_ID'],
aws_secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'],
... | ruby | MIT | f6a688831806eb56d4d9a9c2942a1430d1ecd262 | 2026-01-04T17:32:51.807345Z | false |
Coursemology/coursemology2 | https://github.com/Coursemology/coursemology2/blob/f6a688831806eb56d4d9a9c2942a1430d1ecd262/config/initializers/formats_filter.rb | config/initializers/formats_filter.rb | # frozen_string_literal: true
# Patch for rails vulnerability CVE-2019-5418 and CVE-2019-5419
# TODO: Remove this file after upgrading to rails 6
ActionDispatch::Request.prepend(Module.new do
def formats
super().select do |format|
format.symbol || format.ref == '*/*'
end
end
end)
| ruby | MIT | f6a688831806eb56d4d9a9c2942a1430d1ecd262 | 2026-01-04T17:32:51.807345Z | false |
Coursemology/coursemology2 | https://github.com/Coursemology/coursemology2/blob/f6a688831806eb56d4d9a9c2942a1430d1ecd262/config/initializers/backtrace_silencers.rb | config/initializers/backtrace_silencers.rb | # frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
# Rails.backtrace_cleaner.add_silencer { |line| /my_noisy_library/.match?(line) }
# You can also remove all the silencer... | ruby | MIT | f6a688831806eb56d4d9a9c2942a1430d1ecd262 | 2026-01-04T17:32:51.807345Z | false |
Coursemology/coursemology2 | https://github.com/Coursemology/coursemology2/blob/f6a688831806eb56d4d9a9c2942a1430d1ecd262/config/initializers/mime_types.rb | config/initializers/mime_types.rb | # frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf
| ruby | MIT | f6a688831806eb56d4d9a9c2942a1430d1ecd262 | 2026-01-04T17:32:51.807345Z | false |
Coursemology/coursemology2 | https://github.com/Coursemology/coursemology2/blob/f6a688831806eb56d4d9a9c2942a1430d1ecd262/config/initializers/oembed.rb | config/initializers/oembed.rb | # frozen_string_literal: true
require 'oembed'
OEmbed::Providers.register_all
# HTML iframe points to https://geo.dailymotion.com/*. Ensure this is whitelisted in the sanitizer.
# https://developers.dailymotion.com/news/player-api/embed-dailymotion-video-oembed/
DailymotionProvider = OEmbed::Provider.new('https://www... | ruby | MIT | f6a688831806eb56d4d9a9c2942a1430d1ecd262 | 2026-01-04T17:32:51.807345Z | false |
Coursemology/coursemology2 | https://github.com/Coursemology/coursemology2/blob/f6a688831806eb56d4d9a9c2942a1430d1ecd262/config/initializers/userstamp.rb | config/initializers/userstamp.rb | # frozen_string_literal: true
ActiveRecord::Userstamp.configure do |config|
config.deleter_attribute = nil
end
| ruby | MIT | f6a688831806eb56d4d9a9c2942a1430d1ecd262 | 2026-01-04T17:32:51.807345Z | false |
Coursemology/coursemology2 | https://github.com/Coursemology/coursemology2/blob/f6a688831806eb56d4d9a9c2942a1430d1ecd262/config/environments/test.rb | config/environments/test.rb | # frozen_string_literal: true
require 'active_support/core_ext/integer/time'
require "#{Rails.root}/lib/autoload/active_job/queue_adapters/background_thread_adapter"
# 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 da... | ruby | MIT | f6a688831806eb56d4d9a9c2942a1430d1ecd262 | 2026-01-04T17:32:51.807345Z | false |
Coursemology/coursemology2 | https://github.com/Coursemology/coursemology2/blob/f6a688831806eb56d4d9a9c2942a1430d1ecd262/config/environments/development.rb | config/environments/development.rb | # frozen_string_literal: true
require 'active_support/core_ext/integer/time'
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 any time
# it changes. This slows down response tim... | ruby | MIT | f6a688831806eb56d4d9a9c2942a1430d1ecd262 | 2026-01-04T17:32:51.807345Z | false |
Coursemology/coursemology2 | https://github.com/Coursemology/coursemology2/blob/f6a688831806eb56d4d9a9c2942a1430d1ecd262/config/environments/production.rb | config/environments/production.rb | # frozen_string_literal: true
require 'active_support/core_ext/integer/time'
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.cache_classes = true
# Eager load code on boot. This eager loads most... | ruby | MIT | f6a688831806eb56d4d9a9c2942a1430d1ecd262 | 2026-01-04T17:32:51.807345Z | false |
jumph4x/canonical-rails | https://github.com/jumph4x/canonical-rails/blob/344ca31a148e68f07446dda8b2d4913342372777/app/helpers/canonical_rails/tag_helper.rb | app/helpers/canonical_rails/tag_helper.rb | module CanonicalRails
module TagHelper
def trailing_slash_needed?
request.params.key?('action') && CanonicalRails.sym_collection_actions.include?(request.params['action'].to_sym)
end
# Leave force_trailing_slash as nil to get the original behavior of trailing_slash_if_needed
def trailing_slash_... | ruby | MIT | 344ca31a148e68f07446dda8b2d4913342372777 | 2026-01-04T17:37:38.057140Z | false |
jumph4x/canonical-rails | https://github.com/jumph4x/canonical-rails/blob/344ca31a148e68f07446dda8b2d4913342372777/spec/spec_helper.rb | spec/spec_helper.rb | # This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require 'action_view/railtie'
require 'action_controller/railtie'
require 'canonical-rails'
require 'rspec/rails'
require 'pry'
Rails.backtrace_cleaner.remove_silencers!
# Requires supporting ruby files with custo... | ruby | MIT | 344ca31a148e68f07446dda8b2d4913342372777 | 2026-01-04T17:37:38.057140Z | false |
jumph4x/canonical-rails | https://github.com/jumph4x/canonical-rails/blob/344ca31a148e68f07446dda8b2d4913342372777/spec/helpers/canonical_rails/tag_helper_spec.rb | spec/helpers/canonical_rails/tag_helper_spec.rb | require 'spec_helper'
describe CanonicalRails::TagHelper, type: :helper do
before(:each) do
controller.request.host = 'www.alternative-domain.com'
controller.request.path = '/our_resources'
end
after(:each) do
CanonicalRails.class_variable_set(:@@sym_collection_actions, nil)
CanonicalRails.class... | ruby | MIT | 344ca31a148e68f07446dda8b2d4913342372777 | 2026-01-04T17:37:38.057140Z | false |
jumph4x/canonical-rails | https://github.com/jumph4x/canonical-rails/blob/344ca31a148e68f07446dda8b2d4913342372777/lib/canonical-rails.rb | lib/canonical-rails.rb | require "canonical-rails/engine"
require "canonical-rails/deprecation"
module CanonicalRails
# Default way to setup CanonicalRails. Run `rails g canonical_rails:install` to create
# a fresh initializer with all configuration values.
#
# the config\setup concept politely observed at and borrowed from Devise: h... | ruby | MIT | 344ca31a148e68f07446dda8b2d4913342372777 | 2026-01-04T17:37:38.057140Z | false |
jumph4x/canonical-rails | https://github.com/jumph4x/canonical-rails/blob/344ca31a148e68f07446dda8b2d4913342372777/lib/generators/canonical_rails/install/install_generator.rb | lib/generators/canonical_rails/install/install_generator.rb | module CanonicalRails
class InstallGenerator < Rails::Generators::Base
def self.source_paths
paths = []
paths << File.expand_path('../templates', "../../#{__FILE__}")
paths << File.expand_path('../templates', "../#{__FILE__}")
paths << File.expand_path('../templates', __FILE__)
path... | ruby | MIT | 344ca31a148e68f07446dda8b2d4913342372777 | 2026-01-04T17:37:38.057140Z | false |
jumph4x/canonical-rails | https://github.com/jumph4x/canonical-rails/blob/344ca31a148e68f07446dda8b2d4913342372777/lib/generators/canonical_rails/install/templates/canonical_rails.rb | lib/generators/canonical_rails/install/templates/canonical_rails.rb | # Do yourself a favor and set these up right when you install the engine.
CanonicalRails.setup do |config|
# Force the protocol. If you do not specify, the protocol will be based on the incoming request's protocol.
config.protocol#= 'https://'
# This is the main host, not just the TLD, omit slashes and protoc... | ruby | MIT | 344ca31a148e68f07446dda8b2d4913342372777 | 2026-01-04T17:37:38.057140Z | false |
jumph4x/canonical-rails | https://github.com/jumph4x/canonical-rails/blob/344ca31a148e68f07446dda8b2d4913342372777/lib/canonical-rails/deprecation.rb | lib/canonical-rails/deprecation.rb | # frozen_string_literal: true
require 'active_support/deprecation'
module CanonicalRails
Deprecation = ActiveSupport::Deprecation.new('1.0', 'CanonicalRails')
end
| ruby | MIT | 344ca31a148e68f07446dda8b2d4913342372777 | 2026-01-04T17:37:38.057140Z | false |
jumph4x/canonical-rails | https://github.com/jumph4x/canonical-rails/blob/344ca31a148e68f07446dda8b2d4913342372777/lib/canonical-rails/version.rb | lib/canonical-rails/version.rb | module CanonicalRails
VERSION = "0.2.17"
end
| ruby | MIT | 344ca31a148e68f07446dda8b2d4913342372777 | 2026-01-04T17:37:38.057140Z | false |
jumph4x/canonical-rails | https://github.com/jumph4x/canonical-rails/blob/344ca31a148e68f07446dda8b2d4913342372777/lib/canonical-rails/engine.rb | lib/canonical-rails/engine.rb | require_relative '../../app/helpers/canonical_rails/tag_helper'
module CanonicalRails
class Engine < ::Rails::Engine
initializer 'canonical_rails.add_helpers' do |app|
ActionView::Base.send :include, CanonicalRails::TagHelper
end
end
end
| ruby | MIT | 344ca31a148e68f07446dda8b2d4913342372777 | 2026-01-04T17:37:38.057140Z | false |
jumph4x/canonical-rails | https://github.com/jumph4x/canonical-rails/blob/344ca31a148e68f07446dda8b2d4913342372777/config/routes.rb | config/routes.rb | Rails.application.routes.draw do
end
| ruby | MIT | 344ca31a148e68f07446dda8b2d4913342372777 | 2026-01-04T17:37:38.057140Z | false |
tj/growl | https://github.com/tj/growl/blob/64561c36bf01c776ae232b8c77272647d18f35e7/spec/growl_spec.rb | spec/growl_spec.rb | require 'spec_helper'
describe Growl do
describe "#installed?" do
it "should check if growlnotify is available" do
Growl.should be_installed
end
end
describe "#version" do
it "should return the version triple or double" do
Growl.version.should match(/\d+\.\d+(\.\d+)?/)
end
end
... | ruby | MIT | 64561c36bf01c776ae232b8c77272647d18f35e7 | 2026-01-04T17:37:38.953186Z | false |
tj/growl | https://github.com/tj/growl/blob/64561c36bf01c776ae232b8c77272647d18f35e7/spec/spec_helper.rb | spec/spec_helper.rb | require_relative '../lib/growl'
def fixture path
File.expand_path File.join(File.dirname(__FILE__), 'fixtures', path)
end
RSpec.configure do |config|
config.expect_with :rspec do |c|
c.syntax = :should
end
end
| ruby | MIT | 64561c36bf01c776ae232b8c77272647d18f35e7 | 2026-01-04T17:37:38.953186Z | false |
tj/growl | https://github.com/tj/growl/blob/64561c36bf01c776ae232b8c77272647d18f35e7/examples/growl.rb | examples/growl.rb |
$:.unshift File.dirname(__FILE__) + '/../lib'
require 'growl'
Growl.bin_path = ARGV[0] unless ARGV.empty?
puts "using growlnotify located at #{Growl.bin_path}" unless ARGV.empty?
puts "growlnotify version #{Growl.version} installed"
imagepath = File.dirname(__FILE__) + '/../spec/fixtures/image.png'
iconpath = File... | ruby | MIT | 64561c36bf01c776ae232b8c77272647d18f35e7 | 2026-01-04T17:37:38.953186Z | false |
tj/growl | https://github.com/tj/growl/blob/64561c36bf01c776ae232b8c77272647d18f35e7/lib/growl.rb | lib/growl.rb | #--
# Copyright (c) 2009 TJ Holowaychuk <tj@vision-media.ca>
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, mod... | ruby | MIT | 64561c36bf01c776ae232b8c77272647d18f35e7 | 2026-01-04T17:37:38.953186Z | false |
tj/growl | https://github.com/tj/growl/blob/64561c36bf01c776ae232b8c77272647d18f35e7/lib/growl/version.rb | lib/growl/version.rb |
module Growl
VERSION = '1.0.4'
end
| ruby | MIT | 64561c36bf01c776ae232b8c77272647d18f35e7 | 2026-01-04T17:37:38.953186Z | false |
tj/growl | https://github.com/tj/growl/blob/64561c36bf01c776ae232b8c77272647d18f35e7/lib/growl/growl.rb | lib/growl/growl.rb | module Growl
@@path = 'growlnotify'
#--
# Exceptions
#++
class Error < StandardError; end
##
# Display a growl notification +message+, with +options+
# documented below. Alternatively a +block+ may be passed
# which is then instance evaluated or yielded to the block.
#
# This method is simply ... | ruby | MIT | 64561c36bf01c776ae232b8c77272647d18f35e7 | 2026-01-04T17:37:38.953186Z | false |
ammar/regexp_parser | https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/tasks/benchmarks/minimal_regexp.rb | tasks/benchmarks/minimal_regexp.rb | # frozen_string_literal: true
require 'benchmark/ips'
require_relative '../../lib/regexp_parser'
puts 'Parsing a minimal Regexp'
regexp = /./
Benchmark.ips do |x|
x.report('Scanner::scan') { Regexp::Scanner.scan(regexp) }
x.report('Lexer::lex') { Regexp::Lexer.lex(regexp) }
x.report('Parser::parse') { R... | ruby | MIT | c5094a84e56eb445297556500f19bcc2128a8859 | 2026-01-04T17:37:37.784074Z | false |
ammar/regexp_parser | https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/tasks/benchmarks/uri_regexp.rb | tasks/benchmarks/uri_regexp.rb | # frozen_string_literal: true
require 'benchmark/ips'
require_relative '../../lib/regexp_parser'
puts 'Parsing a complex Regexp (URI.regexp)'
require 'uri'
regexp = URI::DEFAULT_PARSER.make_regexp
Benchmark.ips do |x|
x.report('Scanner::scan') { Regexp::Scanner.scan(regexp) }
x.report('Lexer::lex') { Regexp:... | ruby | MIT | c5094a84e56eb445297556500f19bcc2128a8859 | 2026-01-04T17:37:37.784074Z | false |
ammar/regexp_parser | https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/spec_helper.rb | spec/spec_helper.rb | # frozen_string_literal: true
$VERBOSE = true
require 'leto'
require 'regexp_property_values'
require_relative 'support/capturing_stderr'
require_relative 'support/shared_examples'
req_warn = capturing_stderr { @required_now = require('regexp_parser') }
req_warn.empty? || fail("requiring parser generated warnings:\n... | ruby | MIT | c5094a84e56eb445297556500f19bcc2128a8859 | 2026-01-04T17:37:37.784074Z | false |
ammar/regexp_parser | https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/support/capturing_stderr.rb | spec/support/capturing_stderr.rb | # frozen_string_literal: true
require 'stringio'
def capturing_stderr(&block)
old_stderr, $stderr = $stderr, StringIO.new
block.call
$stderr.string
ensure
$stderr = old_stderr
end
| ruby | MIT | c5094a84e56eb445297556500f19bcc2128a8859 | 2026-01-04T17:37:37.784074Z | false |
ammar/regexp_parser | https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/support/shared_examples.rb | spec/support/shared_examples.rb | # frozen_string_literal: true
RSpec.shared_examples 'syntax' do |opts|
opts[:implements].each do |type, tokens|
tokens.each do |token|
it("implements #{token} #{type}") do
expect(described_class.implements?(type, token)).to be true
end
end
end
opts[:excludes] && opts[:excludes].each ... | ruby | MIT | c5094a84e56eb445297556500f19bcc2128a8859 | 2026-01-04T17:37:37.784074Z | false |
ammar/regexp_parser | https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/scanner/groups_spec.rb | spec/scanner/groups_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe('Group scanning') do
# Group types
include_examples 'scan', '(?>abc)', 0 => [:group, :atomic, '(?>', 0, 3]
include_examples 'scan', '(abc)', 0 => [:group, :capture, '(', 0, 1]
# Named g... | ruby | MIT | c5094a84e56eb445297556500f19bcc2128a8859 | 2026-01-04T17:37:37.784074Z | false |
ammar/regexp_parser | https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/scanner/properties_spec.rb | spec/scanner/properties_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe('Property scanning') do
RSpec.shared_examples 'scan property' do |text, token|
it("scans \\p{#{text}} as property #{token}") do
result = RS.scan("\\p{#{text}}")[0]
expect(result[0..1]).to eq [:property, token]
end
it("scans ... | ruby | MIT | c5094a84e56eb445297556500f19bcc2128a8859 | 2026-01-04T17:37:37.784074Z | false |
ammar/regexp_parser | https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/scanner/escapes_spec.rb | spec/scanner/escapes_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe('Escape scanning') do
include_examples 'scan', /c\at/, 1 => [:escape, :bell, '\a', 1, 3]
# not an escape outside a character set
include_examples 'scan', /c\bt/, 1 => [:anchor, :word_boundary, ... | ruby | MIT | c5094a84e56eb445297556500f19bcc2128a8859 | 2026-01-04T17:37:37.784074Z | false |
ammar/regexp_parser | https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/scanner/all_spec.rb | spec/scanner/all_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe(Regexp::Scanner) do
specify('scanner returns an array') do
expect(RS.scan('abc')).to be_instance_of(Array)
end
specify('scanner returns tokens as arrays') do
tokens = RS.scan('^abc+[^one]{2,3}\b\d\C-C$')
expect(tokens).to all(be_a A... | ruby | MIT | c5094a84e56eb445297556500f19bcc2128a8859 | 2026-01-04T17:37:37.784074Z | false |
ammar/regexp_parser | https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/scanner/delimiters_spec.rb | spec/scanner/delimiters_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe('Literal delimiter scanning') do
include_examples 'scan', '}',
0 => [:literal, :literal, '}', 0, 1]
include_examples 'scan', '}}',
0 => [:literal, :literal, '}}', 0, 2]
include_examples 'scan', '{',
... | ruby | MIT | c5094a84e56eb445297556500f19bcc2128a8859 | 2026-01-04T17:37:37.784074Z | false |
ammar/regexp_parser | https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/scanner/types_spec.rb | spec/scanner/types_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe('Type scanning') do
include_examples 'scan', 'a\dc', 1 => [:type, :digit, '\d', 1, 3]
include_examples 'scan', 'a\Dc', 1 => [:type, :nondigit, '\D', 1, 3]
include_examples 'scan', 'a\hc', 1 => [:type, :hex, '\h', 1, 3]
include_examp... | ruby | MIT | c5094a84e56eb445297556500f19bcc2128a8859 | 2026-01-04T17:37:37.784074Z | false |
ammar/regexp_parser | https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/scanner/keep_spec.rb | spec/scanner/keep_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe('Keep scanning') do
include_examples 'scan', /ab\Kcd/,
1 => [:keep, :mark, '\K', 2, 4]
include_examples 'scan', /(a\Kb)|(c\\\Kd)ef/,
2 => [:keep, :mark, '\K', 2, 4],
9 => [:keep, :mark, '\K', 11, 13]
end
| ruby | MIT | c5094a84e56eb445297556500f19bcc2128a8859 | 2026-01-04T17:37:37.784074Z | false |
ammar/regexp_parser | https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/scanner/refcalls_spec.rb | spec/scanner/refcalls_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe('RefCall scanning') do
# Traditional numerical group back-reference.
# For non-matched cases see ./escapes_spec.rb
include_examples 'scan', '(abc)\1' , 3 => [:backref, :number, '\1', 5, 7]
# They can have two or more digits:
... | ruby | MIT | c5094a84e56eb445297556500f19bcc2128a8859 | 2026-01-04T17:37:37.784074Z | false |
ammar/regexp_parser | https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/scanner/free_space_spec.rb | spec/scanner/free_space_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe('FreeSpace scanning') do
describe('scan free space tokens') do
let(:tokens) { RS.scan(/
a
b ? c *
d {2,3}
e + | f +
/x) }
0.upto(24).select(&:even?).each do |i|
it "scans #{i} as free space" do
... | ruby | MIT | c5094a84e56eb445297556500f19bcc2128a8859 | 2026-01-04T17:37:37.784074Z | false |
ammar/regexp_parser | https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/scanner/conditionals_spec.rb | spec/scanner/conditionals_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe('Conditional scanning') do
include_examples 'scan', /(a)(?(1)T|F)1/, 3 => [:conditional, :open, '(?', 3, 5]
include_examples 'scan', /(a)(?(1)T|F)2/, 4 => [:conditional, :condition_open, '(', 5, 6]
include_exampl... | ruby | MIT | c5094a84e56eb445297556500f19bcc2128a8859 | 2026-01-04T17:37:37.784074Z | false |
ammar/regexp_parser | https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/scanner/literals_spec.rb | spec/scanner/literals_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe('UTF-8 scanning') do
# ascii, single byte characters
include_examples 'scan', 'a',
0 => [:literal, :literal, 'a', 0, 1]
include_examples 'scan', 'ab+',
0 => [:literal, :literal, 'ab', 0, 2],
1 => [:q... | ruby | MIT | c5094a84e56eb445297556500f19bcc2128a8859 | 2026-01-04T17:37:37.784074Z | false |
ammar/regexp_parser | https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/scanner/meta_spec.rb | spec/scanner/meta_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe('Meta scanning') do
include_examples 'scan', /abc??|def*+|ghi+/,
0 => [:literal, :literal, 'abc', 0, 3],
1 => [:quantifier, :zero_or_one_reluctant, '??', 3, 5],
2 => [:meta, :alternation, ... | ruby | MIT | c5094a84e56eb445297556500f19bcc2128a8859 | 2026-01-04T17:37:37.784074Z | false |
ammar/regexp_parser | https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/scanner/errors_spec.rb | spec/scanner/errors_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe(Regexp::Scanner) do
RSpec.shared_examples 'scan error' do |error, issue, source|
it "raises #{error} for #{issue} `#{source}`" do
expect { RS.scan(source) }.to raise_error(error)
end
end
include_examples 'scan error', RS::Prematur... | ruby | MIT | c5094a84e56eb445297556500f19bcc2128a8859 | 2026-01-04T17:37:37.784074Z | false |
ammar/regexp_parser | https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/scanner/sets_spec.rb | spec/scanner/sets_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe('Set scanning') do
include_examples 'scan', /[a]/, 0 => [:set, :open, '[', 0, 1]
include_examples 'scan', /[b]/, 2 => [:set, :close, ']', 2, 3]
include_examples 'sc... | ruby | MIT | c5094a84e56eb445297556500f19bcc2128a8859 | 2026-01-04T17:37:37.784074Z | false |
ammar/regexp_parser | https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/scanner/quantifiers_spec.rb | spec/scanner/quantifiers_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe('Quantifier scanning') do
include_examples 'scan', 'a?', 1 => [:quantifier, :zero_or_one, '?', 1, 2]
include_examples 'scan', 'a??', 1 => [:quantifier, :zero_or_one_reluctant, '??', 1, 3]
include_examples 'scan'... | ruby | MIT | c5094a84e56eb445297556500f19bcc2128a8859 | 2026-01-04T17:37:37.784074Z | false |
ammar/regexp_parser | https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/scanner/options_spec.rb | spec/scanner/options_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe('passing options to scan') do
def expect_type_tokens(tokens, type_tokens)
expect(tokens.map { |type, token, *| [type, token] }).to eq(type_tokens)
end
it 'raises if scanning from a Regexp and options are passed' do
expect { RS.scan(/a+/... | ruby | MIT | c5094a84e56eb445297556500f19bcc2128a8859 | 2026-01-04T17:37:37.784074Z | false |
ammar/regexp_parser | https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/scanner/anchors_spec.rb | spec/scanner/anchors_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe('Anchor scanning') do
include_examples 'scan', '^abc', 0 => [:anchor, :bol, '^', 0, 1]
include_examples 'scan', 'abc$', 1 => [:anchor, :eol, '$', 3, 4]
include_examples 'scan', '\Aabc', 0 => [:anchor, ... | ruby | MIT | c5094a84e56eb445297556500f19bcc2128a8859 | 2026-01-04T17:37:37.784074Z | false |
ammar/regexp_parser | https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/expression/subexpression_spec.rb | spec/expression/subexpression_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe(Regexp::Expression::Subexpression) do
# check #ts, #te
include_examples 'parse', /abcd|ghij|klmn|pqur/,
[0] => [Alternation, ts: 0, te: 19],
[0, 0] => [Alternative, ts: 0, te: 4],
[0, 1] => [Alternative, ts: 5, te: 9],
[0, 2]... | ruby | MIT | c5094a84e56eb445297556500f19bcc2128a8859 | 2026-01-04T17:37:37.784074Z | false |
ammar/regexp_parser | https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/expression/to_h_spec.rb | spec/expression/to_h_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe('Expression::Base#to_h') do
include_examples 'parse', /abc/, [] => [Root, to_h: {
token: :root,
type: :expression,
text: 'abc',
starts_at: 0,
length: 3,
quantifier: nil,
options: {},
level: 0,
set_level: 0,
co... | ruby | MIT | c5094a84e56eb445297556500f19bcc2128a8859 | 2026-01-04T17:37:37.784074Z | false |
ammar/regexp_parser | https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/expression/te_ts_spec.rb | spec/expression/te_ts_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe('Expression::Shared#te,ts') do
# Many tokens/expressions have their own tests for #te and #ts.
# This is an integration-like test to ensure they are correct in conjunction.
it 'is correct irrespective of nesting or preceding tokens' do
regex... | ruby | MIT | c5094a84e56eb445297556500f19bcc2128a8859 | 2026-01-04T17:37:37.784074Z | false |
ammar/regexp_parser | https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/expression/to_s_spec.rb | spec/expression/to_s_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe('Expression::Base#to_s') do
def parse_frozen(pattern)
Leto.deep_freeze(RP.parse(pattern))
end
def expect_round_trip(pattern)
parsed = parse_frozen(pattern)
expect(parsed.to_s).to eql(pattern)
end
specify('literal alternation')... | ruby | MIT | c5094a84e56eb445297556500f19bcc2128a8859 | 2026-01-04T17:37:37.784074Z | false |
ammar/regexp_parser | https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/expression/conditional_spec.rb | spec/expression/conditional_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe(Regexp::Expression::Conditional) do
specify('Conditional#condition, #branches') do
conditional = RP.parse(/(?<A>a)(?(<A>)T|F)/)[1]
expect(conditional.condition).to eq conditional[0]
expect(conditional.branches).to eq conditional[1..2]
... | ruby | MIT | c5094a84e56eb445297556500f19bcc2128a8859 | 2026-01-04T17:37:37.784074Z | false |
ammar/regexp_parser | https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/expression/free_space_spec.rb | spec/expression/free_space_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe(Regexp::Expression::FreeSpace) do
specify('white space quantify raises error') do
regexp = /
a # Comment
/x
root = RP.parse(regexp)
space = root[0]
expect(space).to be_instance_of(FreeSpace::WhiteSpace)
expect { space... | ruby | MIT | c5094a84e56eb445297556500f19bcc2128a8859 | 2026-01-04T17:37:37.784074Z | false |
ammar/regexp_parser | https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/expression/base_spec.rb | spec/expression/base_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe(Regexp::Expression::Base) do
# test #level
include_examples 'parse', /^a(b(c(d)))e$/,
[0] => [to_s: '^', level: 0],
[1] => [to_s: 'a', level: 0],
[2] => [to_s: '(b(c(d)))', level: 0],
[2, ... | ruby | MIT | c5094a84e56eb445297556500f19bcc2128a8859 | 2026-01-04T17:37:37.784074Z | false |
ammar/regexp_parser | https://github.com/ammar/regexp_parser/blob/c5094a84e56eb445297556500f19bcc2128a8859/spec/expression/clone_spec.rb | spec/expression/clone_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe('Expression::Base#clone') do
specify('Base#clone') do
root = RP.parse(/^(?i:a)b+$/i)
copy = root.clone
expect(copy.to_s).to eq root.to_s
expect(root).not_to equal copy
expect(root.text).to eq copy.text
expect(root.text).not... | ruby | MIT | c5094a84e56eb445297556500f19bcc2128a8859 | 2026-01-04T17:37:37.784074Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.