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 |
|---|---|---|---|---|---|---|---|---|
flippercloud/flipper | https://github.com/flippercloud/flipper/blob/941f417601a77231615dce062948778efab13f1a/lib/flipper/instrumentation/statsd.rb | lib/flipper/instrumentation/statsd.rb | require 'securerandom'
require 'active_support/notifications'
require 'flipper/instrumentation/statsd_subscriber'
ActiveSupport::Notifications.subscribe(
/\.flipper$/,
Flipper::Instrumentation::StatsdSubscriber
)
| ruby | MIT | 941f417601a77231615dce062948778efab13f1a | 2026-01-04T15:48:04.030409Z | false |
flippercloud/flipper | https://github.com/flippercloud/flipper/blob/941f417601a77231615dce062948778efab13f1a/lib/flipper/instrumentation/log_subscriber.rb | lib/flipper/instrumentation/log_subscriber.rb | require 'securerandom'
require 'active_support/gem_version'
require 'active_support/notifications'
require 'active_support/log_subscriber'
module Flipper
module Instrumentation
class LogSubscriber < ::ActiveSupport::LogSubscriber
# Logs a feature operation.
#
# Example Output
#
# ... | ruby | MIT | 941f417601a77231615dce062948778efab13f1a | 2026-01-04T15:48:04.030409Z | false |
flippercloud/flipper | https://github.com/flippercloud/flipper/blob/941f417601a77231615dce062948778efab13f1a/lib/flipper/instrumentation/subscriber.rb | lib/flipper/instrumentation/subscriber.rb | module Flipper
module Instrumentation
class Subscriber
# Public: Use this as the subscribed block.
def self.call(name, start, ending, transaction_id, payload)
new(name, start, ending, transaction_id, payload).update
end
# Private: Initializes a new event processing instance.
... | ruby | MIT | 941f417601a77231615dce062948778efab13f1a | 2026-01-04T15:48:04.030409Z | false |
flippercloud/flipper | https://github.com/flippercloud/flipper/blob/941f417601a77231615dce062948778efab13f1a/lib/flipper/instrumentation/statsd_subscriber.rb | lib/flipper/instrumentation/statsd_subscriber.rb | # Note: You should never need to require this file directly if you are using
# ActiveSupport::Notifications. Instead, you should require the statsd file
# that lives in the same directory as this file. The benefit is that it
# subscribes to the correct events and does everything for your.
require 'flipper/instrumentati... | ruby | MIT | 941f417601a77231615dce062948778efab13f1a | 2026-01-04T15:48:04.030409Z | false |
flippercloud/flipper | https://github.com/flippercloud/flipper/blob/941f417601a77231615dce062948778efab13f1a/lib/generators/flipper/setup_generator.rb | lib/generators/flipper/setup_generator.rb | require 'rails/generators/active_record'
module Flipper
module Generators
class SetupGenerator < ::Rails::Generators::Base
desc 'Peform any necessary steps to install Flipper'
source_paths << File.expand_path('templates', __dir__)
class_option :token, type: :string, default: nil, aliases: '-t'... | ruby | MIT | 941f417601a77231615dce062948778efab13f1a | 2026-01-04T15:48:04.030409Z | false |
flippercloud/flipper | https://github.com/flippercloud/flipper/blob/941f417601a77231615dce062948778efab13f1a/lib/generators/flipper/active_record_generator.rb | lib/generators/flipper/active_record_generator.rb | require 'rails/generators/active_record'
module Flipper
module Generators
class ActiveRecordGenerator < ::Rails::Generators::Base
include ::Rails::Generators::Migration
desc 'Generates migration for flipper tables'
source_paths << File.join(File.dirname(__FILE__), 'templates')
def self.... | ruby | MIT | 941f417601a77231615dce062948778efab13f1a | 2026-01-04T15:48:04.030409Z | false |
flippercloud/flipper | https://github.com/flippercloud/flipper/blob/941f417601a77231615dce062948778efab13f1a/lib/generators/flipper/update_generator.rb | lib/generators/flipper/update_generator.rb | # frozen_string_literal: true
require 'rails/generators'
require 'rails/generators/active_record'
module Flipper
module Generators
#
# Rails generator used for updating Flipper in a Rails application.
# Run it with +bin/rails g flipper:update+ in your console.
#
class UpdateGenerator < Rails::Ge... | ruby | MIT | 941f417601a77231615dce062948778efab13f1a | 2026-01-04T15:48:04.030409Z | false |
flippercloud/flipper | https://github.com/flippercloud/flipper/blob/941f417601a77231615dce062948778efab13f1a/lib/generators/flipper/templates/initializer.rb | lib/generators/flipper/templates/initializer.rb | Rails.application.configure do
## Memoization ensures that only one adapter call is made per feature per request.
## For more info, see https://www.flippercloud.io/docs/optimization#memoization
# config.flipper.memoize = true
## Flipper preloads all features before each request, which is recommended if:
## ... | ruby | MIT | 941f417601a77231615dce062948778efab13f1a | 2026-01-04T15:48:04.030409Z | false |
flippercloud/flipper | https://github.com/flippercloud/flipper/blob/941f417601a77231615dce062948778efab13f1a/lib/generators/flipper/templates/sequel_migration.rb | lib/generators/flipper/templates/sequel_migration.rb | class CreateFlipperTablesSequel < Sequel::Migration
def up
create_table :flipper_features do |_t|
String :key, primary_key: true, null: false
DateTime :created_at, null: false
DateTime :updated_at, null: false
end
create_table :flipper_gates do |_t|
String :feature_key, null: fals... | ruby | MIT | 941f417601a77231615dce062948778efab13f1a | 2026-01-04T15:48:04.030409Z | false |
gollum/gollum | https://github.com/gollum/gollum/blob/d00fefc89be0ab22ab862a51299120a55ccd9280/config.rb | config.rb | =begin
This file can be used to (e.g.):
- alter certain inner parts of Gollum,
- extend it with your stuff.
It is especially useful for customizing supported formats/markups. For more information and examples:
- https://github.com/gollum/gollum#config-file
- https://github.com/gollum/gollum/wiki/Sample-config.rb
=end... | ruby | MIT | d00fefc89be0ab22ab862a51299120a55ccd9280 | 2026-01-04T15:37:27.441461Z | false |
gollum/gollum | https://github.com/gollum/gollum/blob/d00fefc89be0ab22ab862a51299120a55ccd9280/test/test_overview_view.rb | test/test_overview_view.rb | # ~*~ encoding: utf-8 ~*~
require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
require File.expand_path '../../lib/gollum/views/overview', __FILE__
FakePageResult = Struct.new(:path) do
def name
File.basename(path, File.extname(path)).gsub("-", " ")
end
alias filename name
def escaped_url_... | ruby | MIT | d00fefc89be0ab22ab862a51299120a55ccd9280 | 2026-01-04T15:37:27.441461Z | false |
gollum/gollum | https://github.com/gollum/gollum/blob/d00fefc89be0ab22ab862a51299120a55ccd9280/test/test_app.rb | test/test_app.rb | # ~*~ encoding: utf-8 ~*~
require File.expand_path(File.join(File.dirname(__FILE__), "helper"))
context "Frontend" do
include Rack::Test::Methods
setup do
@path = cloned_testpath("examples/revert.git")
@wiki = Gollum::Wiki.new(@path)
Precious::App.set(:gollum_path, @path)
Precious::App.set(:wiki_o... | ruby | MIT | d00fefc89be0ab22ab862a51299120a55ccd9280 | 2026-01-04T15:37:27.441461Z | true |
gollum/gollum | https://github.com/gollum/gollum/blob/d00fefc89be0ab22ab862a51299120a55ccd9280/test/test_template_cascade.rb | test/test_template_cascade.rb | # ~*~ encoding: utf-8 ~*~
require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
context "Precious::Views::TemplateCascade" do
include Rack::Test::Methods
setup do
@path = cloned_testpath('examples/lotr.git')
Precious::App.set(:gollum_path, @path)
Precious::App.set(
:wiki_options,... | ruby | MIT | d00fefc89be0ab22ab862a51299120a55ccd9280 | 2026-01-04T15:37:27.441461Z | false |
gollum/gollum | https://github.com/gollum/gollum/blob/d00fefc89be0ab22ab862a51299120a55ccd9280/test/capybara_helper.rb | test/capybara_helper.rb | require_relative 'helper'
require 'selenium-webdriver'
require 'capybara/dsl'
Selenium::WebDriver::Chrome.path = ENV['CHROME_PATH'] if ENV['CHROME_PATH']
CAPYBARA_DRIVER =
if ENV['CI']
:selenium_chrome_headless
else
ENV.fetch('CAPYBARA_DRIVER', :selenium_chrome).to_sym
end
Capybara.default_driver = CA... | ruby | MIT | d00fefc89be0ab22ab862a51299120a55ccd9280 | 2026-01-04T15:37:27.441461Z | false |
gollum/gollum | https://github.com/gollum/gollum/blob/d00fefc89be0ab22ab862a51299120a55ccd9280/test/test_rss_view.rb | test/test_rss_view.rb | require_relative "helper"
context "Precious::Views::RSS" do
# Simplistically mimics a `Gollum::Git::Actor` object.
#
MockAuthor = Struct.new(:name, :email)
# Simplistically mimics a `Gollum::Git::Commit` object.
#
MockChange = Class.new do
def author
MockAuthor.new("committer name", "email@examp... | ruby | MIT | d00fefc89be0ab22ab862a51299120a55ccd9280 | 2026-01-04T15:37:27.441461Z | false |
gollum/gollum | https://github.com/gollum/gollum/blob/d00fefc89be0ab22ab862a51299120a55ccd9280/test/test_latest_changes_view.rb | test/test_latest_changes_view.rb | # ~*~ encoding: utf-8 ~*~
require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
require File.expand_path '../../lib/gollum/views/latest_changes', __FILE__
context 'Precious::Views::LatestChanges' do
include Rack::Test::Methods
def app
Precious::App
end
setup do
@path = cloned_test... | ruby | MIT | d00fefc89be0ab22ab862a51299120a55ccd9280 | 2026-01-04T15:37:27.441461Z | false |
gollum/gollum | https://github.com/gollum/gollum/blob/d00fefc89be0ab22ab862a51299120a55ccd9280/test/test_history_view.rb | test/test_history_view.rb | # ~*~ encoding: utf-8 ~*~
require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
require File.expand_path '../../lib/gollum/views/history', __FILE__
context "Precious::Views::History" do
setup do
@history = Precious::Views::History.new
end
# No tests yet
end
| ruby | MIT | d00fefc89be0ab22ab862a51299120a55ccd9280 | 2026-01-04T15:37:27.441461Z | false |
gollum/gollum | https://github.com/gollum/gollum/blob/d00fefc89be0ab22ab862a51299120a55ccd9280/test/test_allow_editing.rb | test/test_allow_editing.rb | # ~*~ encoding: utf-8 ~*~
require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
context "Precious::Views::Editing" do
include Rack::Test::Methods
setup do
@path = cloned_testpath('examples/revert.git')
Precious::App.set(:gollum_path, @path)
Precious::App.set(:wiki_options, {allow_editi... | ruby | MIT | d00fefc89be0ab22ab862a51299120a55ccd9280 | 2026-01-04T15:37:27.441461Z | false |
gollum/gollum | https://github.com/gollum/gollum/blob/d00fefc89be0ab22ab862a51299120a55ccd9280/test/test_page_view.rb | test/test_page_view.rb | # ~*~ encoding: utf-8 ~*~
require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
require File.expand_path '../../lib/gollum/views/page', __FILE__
context "Precious::Views::Page" do
setup do
@path = cloned_testpath('examples/empty.git')
@wiki = Gollum::Wiki.new(@path)
end
teardown do
... | ruby | MIT | d00fefc89be0ab22ab862a51299120a55ccd9280 | 2026-01-04T15:37:27.441461Z | false |
gollum/gollum | https://github.com/gollum/gollum/blob/d00fefc89be0ab22ab862a51299120a55ccd9280/test/helper.rb | test/helper.rb | require 'rubygems'
require 'rack/test'
require 'shoulda'
require 'minitest/autorun'
require 'minitest/reporters'
require 'minitest/spec'
require 'mocha/minitest'
require 'fileutils'
require 'tmpdir'
# Silence locale validation warning
require 'i18n'
I18n.enforce_available_locales = false
Minitest::Reporters.use! [
... | ruby | MIT | d00fefc89be0ab22ab862a51299120a55ccd9280 | 2026-01-04T15:37:27.441461Z | false |
gollum/gollum | https://github.com/gollum/gollum/blob/d00fefc89be0ab22ab862a51299120a55ccd9280/test/test_migrate.rb | test/test_migrate.rb | # ~*~ encoding: utf-8 ~*~
require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
def load_script(**args)
settings = {
:run_silent => true,
:no_dry_run => true,
:prefer_relative => true,
:hyphenate => false,
:page_file_dir => nil,
}.merge(args)
settings.each do |setting, val|
... | ruby | MIT | d00fefc89be0ab22ab862a51299120a55ccd9280 | 2026-01-04T15:37:27.441461Z | false |
gollum/gollum | https://github.com/gollum/gollum/blob/d00fefc89be0ab22ab862a51299120a55ccd9280/test/test_unicode.rb | test/test_unicode.rb | # ~*~ encoding: utf-8 ~*~
require File.expand_path(File.join(File.dirname(__FILE__), "helper"))
def utf8(str)
str.respond_to?(:force_encoding) ? str.force_encoding('utf-8') : str
end
context "Unicode Support" do
setup do
@path = cloned_testpath("examples/revert.git")
@wiki = Gollum::Wiki.new(@path)
end
... | ruby | MIT | d00fefc89be0ab22ab862a51299120a55ccd9280 | 2026-01-04T15:37:27.441461Z | false |
gollum/gollum | https://github.com/gollum/gollum/blob/d00fefc89be0ab22ab862a51299120a55ccd9280/test/test_compare.rb | test/test_compare.rb | # ~*~ encoding: utf-8 ~*~
require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
require File.expand_path '../../lib/gollum/views/commit', __FILE__
def get_commit_diff(sha1)
commit = @wiki.repo.commit(sha1)
@wiki.repo.diff(commit.parent.id, sha1)
end
context "Precious::Views::Compare" do
setup do... | ruby | MIT | d00fefc89be0ab22ab862a51299120a55ccd9280 | 2026-01-04T15:37:27.441461Z | false |
gollum/gollum | https://github.com/gollum/gollum/blob/d00fefc89be0ab22ab862a51299120a55ccd9280/test/test_app_helpers.rb | test/test_app_helpers.rb | require File.expand_path(File.join(File.dirname(__FILE__), "helper"))
context 'Precious::Helpers' do
include Precious::Helpers
test 'remove trailing and leading slashes' do
['/wiki', '/wiki/', 'wiki/', '//wiki//'].each do |param|
assert_equal 'wiki', remove_leading_and_trailing_slashes(param)
end
... | ruby | MIT | d00fefc89be0ab22ab862a51299120a55ccd9280 | 2026-01-04T15:37:27.441461Z | false |
gollum/gollum | https://github.com/gollum/gollum/blob/d00fefc89be0ab22ab862a51299120a55ccd9280/test/test_local_time_option.rb | test/test_local_time_option.rb | # ~*~ encoding: utf-8 ~*~
require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
require 'nokogiri'
require 'json'
require 'time'
def local_time
Precious::App.set(:wiki_options, { show_local_time: true})
end
def no_local_time
Precious::App.set(:wiki_options, { show_local_time: false})
end
def asse... | ruby | MIT | d00fefc89be0ab22ab862a51299120a55ccd9280 | 2026-01-04T15:37:27.441461Z | false |
gollum/gollum | https://github.com/gollum/gollum/blob/d00fefc89be0ab22ab862a51299120a55ccd9280/test/gollum/views/test_locale_helper.rb | test/gollum/views/test_locale_helper.rb | require_relative "../../helper"
require_relative "../../../lib/gollum/views/helpers"
describe Precious::Views::LocaleHelpers do
class TestClass < Mustache
include Precious::Views::LocaleHelpers
def author
"J.R.R."
end
def location
"Bloemfontein"
end
end
def setup
I18n.avail... | ruby | MIT | d00fefc89be0ab22ab862a51299120a55ccd9280 | 2026-01-04T15:37:27.441461Z | false |
gollum/gollum | https://github.com/gollum/gollum/blob/d00fefc89be0ab22ab862a51299120a55ccd9280/test/integration/test_page.rb | test/integration/test_page.rb | require_relative "../capybara_helper"
context "viewing a wiki page" do
include Capybara::DSL
setup do
@path = cloned_testpath "examples/lotr.git"
@wiki = Gollum::Wiki.new @path
Precious::App.set :gollum_path, @path
Precious::App.set :wiki_options, {}
Capybara.app = Precious::App
end
tea... | ruby | MIT | d00fefc89be0ab22ab862a51299120a55ccd9280 | 2026-01-04T15:37:27.441461Z | false |
gollum/gollum | https://github.com/gollum/gollum/blob/d00fefc89be0ab22ab862a51299120a55ccd9280/test/integration/test_app.rb | test/integration/test_app.rb | require_relative "../capybara_helper"
context "pages" do
include Capybara::DSL
setup do
@path = cloned_testpath "examples/lotr.git"
@wiki = Gollum::Wiki.new @path
Precious::App.set :gollum_path, @path
Precious::App.set :wiki_options, {}
Capybara.app = Precious::App
end
test 'last modif... | ruby | MIT | d00fefc89be0ab22ab862a51299120a55ccd9280 | 2026-01-04T15:37:27.441461Z | false |
gollum/gollum | https://github.com/gollum/gollum/blob/d00fefc89be0ab22ab862a51299120a55ccd9280/test/integration/test_js_errors.rb | test/integration/test_js_errors.rb | require_relative '../capybara_helper'
def expected_errors
Regexp.union([
%r{Refused to apply style from 'http:.*/gollum/create/custom.css'},
%r{.*/gollum/create/math.config.js - Failed to load resource: the server responded with a status of 403},
%r{Refused to execute script from .*/gollum/create/math.co... | ruby | MIT | d00fefc89be0ab22ab862a51299120a55ccd9280 | 2026-01-04T15:37:27.441461Z | false |
gollum/gollum | https://github.com/gollum/gollum/blob/d00fefc89be0ab22ab862a51299120a55ccd9280/test/integration/test_localization.rb | test/integration/test_localization.rb | require_relative '../capybara_helper'
context 'Localized frontend' do
include Capybara::DSL
setup do
@path = cloned_testpath "examples/lotr.git"
@wiki = Gollum::Wiki.new(@path)
Precious::App.set :gollum_path, @path
Precious::App.set :wiki_options, {math: :katex}
Capybara.app = Precious::App
... | ruby | MIT | d00fefc89be0ab22ab862a51299120a55ccd9280 | 2026-01-04T15:37:27.441461Z | false |
gollum/gollum | https://github.com/gollum/gollum/blob/d00fefc89be0ab22ab862a51299120a55ccd9280/test/integration/test_search.rb | test/integration/test_search.rb | require_relative "../capybara_helper"
context "search" do
include Capybara::DSL
setup do
@path = cloned_testpath "examples/lotr.git"
@wiki = Gollum::Wiki.new @path
Precious::App.set :gollum_path, @path
Precious::App.set :wiki_options, {}
Capybara.app = Precious::App
end
teardown do
... | ruby | MIT | d00fefc89be0ab22ab862a51299120a55ccd9280 | 2026-01-04T15:37:27.441461Z | false |
gollum/gollum | https://github.com/gollum/gollum/blob/d00fefc89be0ab22ab862a51299120a55ccd9280/test/integration/test_editor.rb | test/integration/test_editor.rb | require_relative "../capybara_helper"
context "editor interface" do
include Capybara::DSL
setup do
@path = cloned_testpath "examples/lotr.git"
@wiki = Gollum::Wiki.new @path
Precious::App.set :gollum_path, @path
Precious::App.set :wiki_options, {}
Capybara.app = Precious::App
end
teardo... | ruby | MIT | d00fefc89be0ab22ab862a51299120a55ccd9280 | 2026-01-04T15:37:27.441461Z | false |
gollum/gollum | https://github.com/gollum/gollum/blob/d00fefc89be0ab22ab862a51299120a55ccd9280/lib/gollum.rb | lib/gollum.rb | # ~*~ encoding: utf-8 ~*~
# stdlib
require 'digest/md5'
require 'digest/sha1'
require 'ostruct'
# external
require 'i18n'
require 'github/markup'
require 'rhino' if RUBY_PLATFORM == 'java'
# internal
require ::File.expand_path('../gollum/uri_encode_component', __FILE__)
module Gollum
VERSION = '6.1.0'
KEYBINDING... | ruby | MIT | d00fefc89be0ab22ab862a51299120a55ccd9280 | 2026-01-04T15:37:27.441461Z | false |
gollum/gollum | https://github.com/gollum/gollum/blob/d00fefc89be0ab22ab862a51299120a55ccd9280/lib/gollum/uri_encode_component.rb | lib/gollum/uri_encode_component.rb | # ~*~ encoding: utf-8 ~*~
=begin
Copyright 2006-2008 the V8 project authors. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright... | ruby | MIT | d00fefc89be0ab22ab862a51299120a55ccd9280 | 2026-01-04T15:37:27.441461Z | false |
gollum/gollum | https://github.com/gollum/gollum/blob/d00fefc89be0ab22ab862a51299120a55ccd9280/lib/gollum/helpers.rb | lib/gollum/helpers.rb | # ~*~ encoding: utf-8 ~*~
require 'gemojione'
module Precious
module Helpers
EMOJI_PATHNAME = Pathname.new(Gemojione.images_path).freeze
def find_per_page_upload_subdir(referer, host_with_port, base_path)
base = base_path ? remove_leading_and_trailing_slashes(base_path) : ''
dir = referer.m... | ruby | MIT | d00fefc89be0ab22ab862a51299120a55ccd9280 | 2026-01-04T15:37:27.441461Z | false |
gollum/gollum | https://github.com/gollum/gollum/blob/d00fefc89be0ab22ab862a51299120a55ccd9280/lib/gollum/app.rb | lib/gollum/app.rb | # encoding: UTF-8
require 'cgi'
require 'sinatra'
require 'sinatra/namespace'
require 'gollum-lib'
require 'mustache/sinatra'
require 'json'
require 'sprockets'
require 'sprockets-helpers'
require 'octicons'
require 'pathname'
require 'gollum'
require 'gollum/assets'
# Requirements for loading the layout view:
requi... | ruby | MIT | d00fefc89be0ab22ab862a51299120a55ccd9280 | 2026-01-04T15:37:27.441461Z | false |
gollum/gollum | https://github.com/gollum/gollum/blob/d00fefc89be0ab22ab862a51299120a55ccd9280/lib/gollum/assets.rb | lib/gollum/assets.rb | require 'octicons'
module Precious
module Assets
MANIFEST = %w(app.js editor.js gollum.mermaid.js gollum.katex.js app.css criticmarkup.css fileview.css ie7.css print.css katex/dist/katex.css *.png *.jpg *.svg *.eot *.ttf)
ASSET_URL = 'gollum/assets'
def self.sprockets(dir = File.dirname(File.expand_path... | ruby | MIT | d00fefc89be0ab22ab862a51299120a55ccd9280 | 2026-01-04T15:37:27.441461Z | false |
gollum/gollum | https://github.com/gollum/gollum/blob/d00fefc89be0ab22ab862a51299120a55ccd9280/lib/gollum/views/overview.rb | lib/gollum/views/overview.rb | require 'pathname'
module Precious
module Views
class Overview < Layout
attr_reader :name, :results, :ref, :allow_editing, :newable
HIDDEN_PATHS = ['.gitkeep']
def title
t[:title]
end
# def editable
# false
# end
def current_path
@path ? @path ... | ruby | MIT | d00fefc89be0ab22ab862a51299120a55ccd9280 | 2026-01-04T15:37:27.441461Z | false |
gollum/gollum | https://github.com/gollum/gollum/blob/d00fefc89be0ab22ab862a51299120a55ccd9280/lib/gollum/views/page.rb | lib/gollum/views/page.rb | module Precious
module Views
class Page < Layout
include HasPage
include HasMath
attr_reader :page, :header, :footer, :preview, :historical, :version
VALID_COUNTER_STYLES = ['decimal', 'decimal-leading-zero', 'arabic-indic', 'armenian', 'upper-armenian',
'lower-armenian', '... | ruby | MIT | d00fefc89be0ab22ab862a51299120a55ccd9280 | 2026-01-04T15:37:27.441461Z | false |
gollum/gollum | https://github.com/gollum/gollum/blob/d00fefc89be0ab22ab862a51299120a55ccd9280/lib/gollum/views/has_math.rb | lib/gollum/views/has_math.rb | module Precious
module HasMath
def mathjax
@math == :mathjax
end
def katex
@math == :katex
end
def math_config
@math_config ? page_route(@math_config) : false
end
end
end | ruby | MIT | d00fefc89be0ab22ab862a51299120a55ccd9280 | 2026-01-04T15:37:27.441461Z | false |
gollum/gollum | https://github.com/gollum/gollum/blob/d00fefc89be0ab22ab862a51299120a55ccd9280/lib/gollum/views/has_page.rb | lib/gollum/views/has_page.rb | module Precious
module HasPage
def path
@page.url_path
end
def escaped_url_path
@page.escaped_url_path
end
def format
@page.format.to_s
end
def id
@page.sha
end
end
end
| ruby | MIT | d00fefc89be0ab22ab862a51299120a55ccd9280 | 2026-01-04T15:37:27.441461Z | false |
gollum/gollum | https://github.com/gollum/gollum/blob/d00fefc89be0ab22ab862a51299120a55ccd9280/lib/gollum/views/template_cascade.rb | lib/gollum/views/template_cascade.rb | module Precious
module Views
module TemplateCascade
def template_priority_path
@@template_priority_path ||= nil
end
def template_priority_path=(path)
@@template_priority_path = File.expand_path(path)
@template = nil
end
def first_path_available(name)
... | ruby | MIT | d00fefc89be0ab22ab862a51299120a55ccd9280 | 2026-01-04T15:37:27.441461Z | false |
gollum/gollum | https://github.com/gollum/gollum/blob/d00fefc89be0ab22ab862a51299120a55ccd9280/lib/gollum/views/pagination.rb | lib/gollum/views/pagination.rb | module Precious
module Pagination
def next_page
result_set = @versions || results
result_set.length < @max_count ? nil : (@page_num + 1).to_s
end
def previous_page
@page_num == 1 ? nil : (@page_num - 1).to_s
end
end
end
| ruby | MIT | d00fefc89be0ab22ab862a51299120a55ccd9280 | 2026-01-04T15:37:27.441461Z | false |
gollum/gollum | https://github.com/gollum/gollum/blob/d00fefc89be0ab22ab862a51299120a55ccd9280/lib/gollum/views/has_user_icons.rb | lib/gollum/views/has_user_icons.rb | module Precious
module HasUserIcons
def user_icon_code(str)
Digest::MD5.hexdigest(str.strip.downcase)
end
def partial(name)
if name == :author_template
self.class.partial("history_authors/#{@wiki.user_icons}")
else
super
end
end
end
end | ruby | MIT | d00fefc89be0ab22ab862a51299120a55ccd9280 | 2026-01-04T15:37:27.441461Z | false |
gollum/gollum | https://github.com/gollum/gollum/blob/d00fefc89be0ab22ab862a51299120a55ccd9280/lib/gollum/views/search.rb | lib/gollum/views/search.rb | module Precious
module Views
class Search < Layout
attr_reader :query, :search_terms
include Pagination
def results
sorted = @results.sort do |a, b|
if b.nil?
b_filename_count = 0
b_count = 0
else
b_filename_count = b[:fil... | ruby | MIT | d00fefc89be0ab22ab862a51299120a55ccd9280 | 2026-01-04T15:37:27.441461Z | false |
gollum/gollum | https://github.com/gollum/gollum/blob/d00fefc89be0ab22ab862a51299120a55ccd9280/lib/gollum/views/helpers.rb | lib/gollum/views/helpers.rb | require 'json'
module Precious
module Views
module AppHelpers
def extract_page_dir(path)
return path unless @page_dir
@path_to_extract ||= "#{Pathname.new(@page_dir).cleanpath}/"
path.start_with?(@path_to_extract) ? path.slice(@path_to_extract.length, path.length) : path
end
... | ruby | MIT | d00fefc89be0ab22ab862a51299120a55ccd9280 | 2026-01-04T15:37:27.441461Z | false |
gollum/gollum | https://github.com/gollum/gollum/blob/d00fefc89be0ab22ab862a51299120a55ccd9280/lib/gollum/views/latest_changes.rb | lib/gollum/views/latest_changes.rb | module Precious
module Views
class LatestChanges < Layout
DATE_FORMAT = '%B %d, %Y'
include Pagination
include HasUserIcons
attr_reader :wiki
def title
t[:title]
end
def versions
i = @versions.size + 1
@versions.map do |v|
i -= 1
... | ruby | MIT | d00fefc89be0ab22ab862a51299120a55ccd9280 | 2026-01-04T15:37:27.441461Z | false |
gollum/gollum | https://github.com/gollum/gollum/blob/d00fefc89be0ab22ab862a51299120a55ccd9280/lib/gollum/views/rss.rb | lib/gollum/views/rss.rb | require 'rss'
class RSSView
include Precious::Views::AppHelpers
include Precious::Views::RouteHelpers
attr_reader :base_url
def initialize(base_url, wiki_title, url, changes)
@base_url = base_url
@wiki_title = wiki_title
@url = url
@changes = changes
end
def render
RSS::Maker.make('2... | ruby | MIT | d00fefc89be0ab22ab862a51299120a55ccd9280 | 2026-01-04T15:37:27.441461Z | false |
gollum/gollum | https://github.com/gollum/gollum/blob/d00fefc89be0ab22ab862a51299120a55ccd9280/lib/gollum/views/create.rb | lib/gollum/views/create.rb | module Precious
module Views
class Create < Layout
include Editable
include HasMath
attr_reader :page, :name
def title
"Create a new page"
end
def is_create_page
true
end
def is_edit_page
false
end
def allow_uploads
@... | ruby | MIT | d00fefc89be0ab22ab862a51299120a55ccd9280 | 2026-01-04T15:37:27.441461Z | false |
gollum/gollum | https://github.com/gollum/gollum/blob/d00fefc89be0ab22ab862a51299120a55ccd9280/lib/gollum/views/compare.rb | lib/gollum/views/compare.rb | module Precious
module Views
class Compare < Layout
include HasPage
attr_reader :page, :diff, :versions, :message, :allow_editing
def title
[t[:comparison_of], @page.title].join(" ")
end
def before
@versions[0][0..6]
end
def after
@versions[1][... | ruby | MIT | d00fefc89be0ab22ab862a51299120a55ccd9280 | 2026-01-04T15:37:27.441461Z | false |
gollum/gollum | https://github.com/gollum/gollum/blob/d00fefc89be0ab22ab862a51299120a55ccd9280/lib/gollum/views/editable.rb | lib/gollum/views/editable.rb | module Precious
module Editable
def has_editor
true
end
def default_keybinding
@default_keybinding
end
def keybindings
Gollum::KEYBINDINGS.map do |kb|
{ :name => kb,
:selected => default_keybinding == kb
}
end
end
def formats(selected = ... | ruby | MIT | d00fefc89be0ab22ab862a51299120a55ccd9280 | 2026-01-04T15:37:27.441461Z | false |
gollum/gollum | https://github.com/gollum/gollum/blob/d00fefc89be0ab22ab862a51299120a55ccd9280/lib/gollum/views/history.rb | lib/gollum/views/history.rb | module Precious
module Views
class History < Layout
DATE_FORMAT = '%B %d, %Y'
include HasPage
include Pagination
include HasUserIcons
include Sprockets::Helpers
include Precious::Views::SprocketsHelpers
attr_reader :page, :allow_editing
def title
@page.ti... | ruby | MIT | d00fefc89be0ab22ab862a51299120a55ccd9280 | 2026-01-04T15:37:27.441461Z | false |
gollum/gollum | https://github.com/gollum/gollum/blob/d00fefc89be0ab22ab862a51299120a55ccd9280/lib/gollum/views/error.rb | lib/gollum/views/error.rb | module Precious
module Views
class Error < Layout
attr_reader :message
end
end
end
| ruby | MIT | d00fefc89be0ab22ab862a51299120a55ccd9280 | 2026-01-04T15:37:27.441461Z | false |
gollum/gollum | https://github.com/gollum/gollum/blob/d00fefc89be0ab22ab862a51299120a55ccd9280/lib/gollum/views/layout.rb | lib/gollum/views/layout.rb | require 'cgi'
module Precious
module Views
class Layout < Mustache
include Sprockets::Helpers
include Precious::Views::AppHelpers
include Precious::Views::LocaleHelpers
include Precious::Views::SprocketsHelpers
include Precious::Views::RouteHelpers
include Precious::Views::Oct... | ruby | MIT | d00fefc89be0ab22ab862a51299120a55ccd9280 | 2026-01-04T15:37:27.441461Z | false |
gollum/gollum | https://github.com/gollum/gollum/blob/d00fefc89be0ab22ab862a51299120a55ccd9280/lib/gollum/views/commit.rb | lib/gollum/views/commit.rb | require_relative 'compare.rb'
module Precious
module Views
class Commit < Compare
attr_reader :version
def title
"Changes in #{@version[0..6]}: #{message}"
end
def author
@commit.author.name
end
def authored_date
@commit.authored_date
end
... | ruby | MIT | d00fefc89be0ab22ab862a51299120a55ccd9280 | 2026-01-04T15:37:27.441461Z | false |
gollum/gollum | https://github.com/gollum/gollum/blob/d00fefc89be0ab22ab862a51299120a55ccd9280/lib/gollum/views/edit.rb | lib/gollum/views/edit.rb | module Precious
module Views
class Edit < Layout
include Editable
include HasPage
include HasMath
attr_reader :page, :content
# return path set in app.rb not @page.path
def path
@path
end
def title
"#{@page.title}"
end
def page_name
... | ruby | MIT | d00fefc89be0ab22ab862a51299120a55ccd9280 | 2026-01-04T15:37:27.441461Z | false |
gollum/gollum | https://github.com/gollum/gollum/blob/d00fefc89be0ab22ab862a51299120a55ccd9280/lib/gollum/views/helpers/locale_helpers.rb | lib/gollum/views/helpers/locale_helpers.rb | module Precious
module Views
module LocaleHelpers
NO_METHOD_MESSAGE = 'Argument must be a view method'
YAML_VARIABLE_REGEXP = /\%\{[\w]+\}/
# Returns all I18n translation strings for the current view class.
# This method support YAML arguments. For example:
#
# last_edited... | ruby | MIT | d00fefc89be0ab22ab862a51299120a55ccd9280 | 2026-01-04T15:37:27.441461Z | false |
airbnb/ruby | https://github.com/airbnb/ruby/blob/a885a6a14ecfba85ff0100378c6583a915c37ca9/rubocop-airbnb/spec/spec_helper.rb | rubocop-airbnb/spec/spec_helper.rb | require 'rubocop'
require 'rubocop/rspec/support'
require 'pry'
module SpecHelper
ROOT = Pathname.new(__FILE__).parent.freeze
end
# Load in Rubocop cops
require File.expand_path('lib/rubocop-airbnb')
spec_helper_glob = File.expand_path('{support,shared}/*.rb', SpecHelper::ROOT)
Dir.glob(spec_helper_glob).map(&meth... | ruby | MIT | a885a6a14ecfba85ff0100378c6583a915c37ca9 | 2026-01-04T15:48:07.292941Z | false |
airbnb/ruby | https://github.com/airbnb/ruby/blob/a885a6a14ecfba85ff0100378c6583a915c37ca9/rubocop-airbnb/spec/rubocop/cop/airbnb/default_scope_spec.rb | rubocop-airbnb/spec/rubocop/cop/airbnb/default_scope_spec.rb | describe RuboCop::Cop::Airbnb::DefaultScope, :config do
it 'rejects with default_scopes' do
expect_offense(<<~RUBY)
# encoding: UTF-8
module SurveyQuestion
class Host < PhraseBundle
db_magic :connection => AIRMISC_MASTER,
:slaves => AIRMISC_DB_SLAVES,
... | ruby | MIT | a885a6a14ecfba85ff0100378c6583a915c37ca9 | 2026-01-04T15:48:07.292941Z | false |
airbnb/ruby | https://github.com/airbnb/ruby/blob/a885a6a14ecfba85ff0100378c6583a915c37ca9/rubocop-airbnb/spec/rubocop/cop/airbnb/opt_arg_parameter_spec.rb | rubocop-airbnb/spec/rubocop/cop/airbnb/opt_arg_parameter_spec.rb | describe RuboCop::Cop::Airbnb::OptArgParameters, :config do
it 'allows method with no parameters' do
expect_no_offenses(<<~RUBY)
def my_method
end
RUBY
end
it 'allows method with one parameter' do
expect_no_offenses(<<~RUBY)
def my_method(params)
end
RUBY
end
it 'allo... | ruby | MIT | a885a6a14ecfba85ff0100378c6583a915c37ca9 | 2026-01-04T15:48:07.292941Z | false |
airbnb/ruby | https://github.com/airbnb/ruby/blob/a885a6a14ecfba85ff0100378c6583a915c37ca9/rubocop-airbnb/spec/rubocop/cop/airbnb/rspec_environment_modification_spec.rb | rubocop-airbnb/spec/rubocop/cop/airbnb/rspec_environment_modification_spec.rb | describe RuboCop::Cop::Airbnb::RspecEnvironmentModification, :config do
before(:each) do
allow(cop).to receive(:is_spec_file?).and_return(true)
end
it 'does not allow assignment of Rails.env' do
expect_offense(<<~RUBY)
Rails.env = :production
^^^^^^^^^^^^^^^^^^^^^^^ Do not stub or set Rails.e... | ruby | MIT | a885a6a14ecfba85ff0100378c6583a915c37ca9 | 2026-01-04T15:48:07.292941Z | false |
airbnb/ruby | https://github.com/airbnb/ruby/blob/a885a6a14ecfba85ff0100378c6583a915c37ca9/rubocop-airbnb/spec/rubocop/cop/airbnb/simple_modifier_conditional_spec.rb | rubocop-airbnb/spec/rubocop/cop/airbnb/simple_modifier_conditional_spec.rb | describe RuboCop::Cop::Airbnb::SimpleModifierConditional, :config do
context 'multiple conditionals' do
it 'rejects with modifier if with multiple conditionals' do
expect_offense(<<~RUBY)
return true if some_method == 0 || another_method
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Modi... | ruby | MIT | a885a6a14ecfba85ff0100378c6583a915c37ca9 | 2026-01-04T15:48:07.292941Z | false |
airbnb/ruby | https://github.com/airbnb/ruby/blob/a885a6a14ecfba85ff0100378c6583a915c37ca9/rubocop-airbnb/spec/rubocop/cop/airbnb/mass_assignment_accessible_modifier_spec.rb | rubocop-airbnb/spec/rubocop/cop/airbnb/mass_assignment_accessible_modifier_spec.rb | describe RuboCop::Cop::Airbnb::MassAssignmentAccessibleModifier, :config do
it 'rejects when accessible= is called' do
expect_offense(<<~RUBY)
def some_method
user = User.new
user.accessible = [:first_name, :last_name]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Do no override and ob... | ruby | MIT | a885a6a14ecfba85ff0100378c6583a915c37ca9 | 2026-01-04T15:48:07.292941Z | false |
airbnb/ruby | https://github.com/airbnb/ruby/blob/a885a6a14ecfba85ff0100378c6583a915c37ca9/rubocop-airbnb/spec/rubocop/cop/airbnb/factory_attr_references_class_spec.rb | rubocop-airbnb/spec/rubocop/cop/airbnb/factory_attr_references_class_spec.rb | describe RuboCop::Cop::Airbnb::FactoryAttrReferencesClass, :config do
it 'rejects with `attr_name CONST_NAME` in a factory' do
expect_offense(<<~RUBY)
factory :reservation2 do
status Reservation2::STATUS_NEW
^^^^^^^^^^^^^^^^^^^^^^^^ Instead of attr_name MyClass::MY_CONST, use attr_nam... | ruby | MIT | a885a6a14ecfba85ff0100378c6583a915c37ca9 | 2026-01-04T15:48:07.292941Z | false |
airbnb/ruby | https://github.com/airbnb/ruby/blob/a885a6a14ecfba85ff0100378c6583a915c37ca9/rubocop-airbnb/spec/rubocop/cop/airbnb/continuation_slash_spec.rb | rubocop-airbnb/spec/rubocop/cop/airbnb/continuation_slash_spec.rb | describe RuboCop::Cop::Airbnb::ContinuationSlash, :config do
it 'rejects continuations used to continue a method call with trailing dot' do
expect_offense(<<~RUBY)
User. \\
^^^^^^^ Slash continuation should be reserved [...]
first_name
RUBY
end
context 'on assignment' do
it 'rejec... | ruby | MIT | a885a6a14ecfba85ff0100378c6583a915c37ca9 | 2026-01-04T15:48:07.292941Z | false |
airbnb/ruby | https://github.com/airbnb/ruby/blob/a885a6a14ecfba85ff0100378c6583a915c37ca9/rubocop-airbnb/spec/rubocop/cop/airbnb/class_or_module_declared_in_wrong_file_spec.rb | rubocop-airbnb/spec/rubocop/cop/airbnb/class_or_module_declared_in_wrong_file_spec.rb | describe RuboCop::Cop::Airbnb::ClassOrModuleDeclaredInWrongFile, :config do
let(:config) do
RuboCop::Config.new(
{
"Rails" => {
"Enabled" => true,
},
}
)
end
# Put source in a directory under /tmp because this cop cares about the filename
# but not the parent dir n... | ruby | MIT | a885a6a14ecfba85ff0100378c6583a915c37ca9 | 2026-01-04T15:48:07.292941Z | false |
airbnb/ruby | https://github.com/airbnb/ruby/blob/a885a6a14ecfba85ff0100378c6583a915c37ca9/rubocop-airbnb/spec/rubocop/cop/airbnb/const_assigned_in_wrong_file_spec.rb | rubocop-airbnb/spec/rubocop/cop/airbnb/const_assigned_in_wrong_file_spec.rb | describe RuboCop::Cop::Airbnb::ConstAssignedInWrongFile, :config do
let(:config) do
RuboCop::Config.new(
{
"Rails" => {
"Enabled" => true,
},
}
)
end
# Put source in a directory under /tmp because this cop cares about the filename
# but not the parent dir name.
l... | ruby | MIT | a885a6a14ecfba85ff0100378c6583a915c37ca9 | 2026-01-04T15:48:07.292941Z | false |
airbnb/ruby | https://github.com/airbnb/ruby/blob/a885a6a14ecfba85ff0100378c6583a915c37ca9/rubocop-airbnb/spec/rubocop/cop/airbnb/factory_class_use_string_spec.rb | rubocop-airbnb/spec/rubocop/cop/airbnb/factory_class_use_string_spec.rb | describe RuboCop::Cop::Airbnb::FactoryClassUseString, :config do
it 'rejects with :class => Model' do
expect_offense(<<~RUBY)
factory :help_answer, :class => Help::Answer do
^^^^^^^^^^^^^^^^^^^^^^ Instead of :class => MyClass, use :class => "MyClass". [...]
text { Faker::... | ruby | MIT | a885a6a14ecfba85ff0100378c6583a915c37ca9 | 2026-01-04T15:48:07.292941Z | false |
airbnb/ruby | https://github.com/airbnb/ruby/blob/a885a6a14ecfba85ff0100378c6583a915c37ca9/rubocop-airbnb/spec/rubocop/cop/airbnb/no_timeout_spec.rb | rubocop-airbnb/spec/rubocop/cop/airbnb/no_timeout_spec.rb | describe RuboCop::Cop::Airbnb::NoTimeout, :config do
context 'send' do
it 'rejects Timeout.timeout' do
expect_offense(<<~RUBY)
def some_method(a)
Timeout.timeout(5) do
^^^^^^^^^^^^^^^^^^ Do not use Timeout.timeout. [...]
some_other_method(a)
end
end
... | ruby | MIT | a885a6a14ecfba85ff0100378c6583a915c37ca9 | 2026-01-04T15:48:07.292941Z | false |
airbnb/ruby | https://github.com/airbnb/ruby/blob/a885a6a14ecfba85ff0100378c6583a915c37ca9/rubocop-airbnb/spec/rubocop/cop/airbnb/unsafe_yaml_marshal_spec.rb | rubocop-airbnb/spec/rubocop/cop/airbnb/unsafe_yaml_marshal_spec.rb | describe RuboCop::Cop::Airbnb::UnsafeYamlMarshal, :config do
context 'send' do
it 'rejects YAML.load' do
expect_offense(<<~RUBY)
def some_method(a)
YAML.load(a)
^^^^^^^^^^^^ Using `YAML.load` on untrusted input [...]
end
RUBY
end
it 'rejects Psych.load' do
... | ruby | MIT | a885a6a14ecfba85ff0100378c6583a915c37ca9 | 2026-01-04T15:48:07.292941Z | false |
airbnb/ruby | https://github.com/airbnb/ruby/blob/a885a6a14ecfba85ff0100378c6583a915c37ca9/rubocop-airbnb/spec/rubocop/cop/airbnb/spec_constant_assignment_spec.rb | rubocop-airbnb/spec/rubocop/cop/airbnb/spec_constant_assignment_spec.rb | describe RuboCop::Cop::Airbnb::SpecConstantAssignment, :config do
it 'rejects constant definition inside of a describe block' do
expect_offense(<<~RUBY)
describe Someclass do
CONSTANT = 5
^^^^^^^^^^^^ Defining constants inside of specs can cause spurious behavior. [...]
end
RUBY
... | ruby | MIT | a885a6a14ecfba85ff0100378c6583a915c37ca9 | 2026-01-04T15:48:07.292941Z | false |
airbnb/ruby | https://github.com/airbnb/ruby/blob/a885a6a14ecfba85ff0100378c6583a915c37ca9/rubocop-airbnb/spec/rubocop/cop/airbnb/phrase_bundle_keys_spec.rb | rubocop-airbnb/spec/rubocop/cop/airbnb/phrase_bundle_keys_spec.rb | describe RuboCop::Cop::Airbnb::PhraseBundleKeys, :config do
it 'generates offenses for mismatched keys in PhraseBundle classes' do
expect_offense(<<EOS)
# encoding: UTF-8
module PhraseBundles
class Host < PhraseBundle
def phrases
{
"shortened_key" => t(
^^^^^^^^^^^^^^^ Phrase bundle k... | ruby | MIT | a885a6a14ecfba85ff0100378c6583a915c37ca9 | 2026-01-04T15:48:07.292941Z | false |
airbnb/ruby | https://github.com/airbnb/ruby/blob/a885a6a14ecfba85ff0100378c6583a915c37ca9/rubocop-airbnb/spec/rubocop/cop/airbnb/module_method_in_wrong_file_spec.rb | rubocop-airbnb/spec/rubocop/cop/airbnb/module_method_in_wrong_file_spec.rb | describe RuboCop::Cop::Airbnb::ModuleMethodInWrongFile, :config do
let(:config) do
RuboCop::Config.new(
{
"Rails" => {
"Enabled" => true,
},
}
)
end
# Put source in a directory under /tmp because this cop cares about the filename
# but not the parent dir name.
le... | ruby | MIT | a885a6a14ecfba85ff0100378c6583a915c37ca9 | 2026-01-04T15:48:07.292941Z | false |
airbnb/ruby | https://github.com/airbnb/ruby/blob/a885a6a14ecfba85ff0100378c6583a915c37ca9/rubocop-airbnb/spec/rubocop/cop/airbnb/rspec_describe_or_context_under_namespace_spec.rb | rubocop-airbnb/spec/rubocop/cop/airbnb/rspec_describe_or_context_under_namespace_spec.rb | describe RuboCop::Cop::Airbnb::RspecDescribeOrContextUnderNamespace, :config do
let(:tmpdir) { Dir.mktmpdir }
let(:models_spec_dir) do
FileUtils.mkdir_p("#{tmpdir}/spec/models").first
end
after do
FileUtils.rm_rf tmpdir
end
shared_examples 'rspec namespacing rule' do
context 'under a namespace... | ruby | MIT | a885a6a14ecfba85ff0100378c6583a915c37ca9 | 2026-01-04T15:48:07.292941Z | false |
airbnb/ruby | https://github.com/airbnb/ruby/blob/a885a6a14ecfba85ff0100378c6583a915c37ca9/rubocop-airbnb/spec/rubocop/cop/airbnb/risky_activerecord_invocation_spec.rb | rubocop-airbnb/spec/rubocop/cop/airbnb/risky_activerecord_invocation_spec.rb | describe RuboCop::Cop::Airbnb::RiskyActiverecordInvocation, :config do
it "allows where statement that's a hash" do
expect_no_offenses(<<~RUBY)
Users.where({:name => "Bob"})
RUBY
end
it "allows where statement that's a flat string" do
expect_no_offenses('Users.where("age = 24")')
end
it "a... | ruby | MIT | a885a6a14ecfba85ff0100378c6583a915c37ca9 | 2026-01-04T15:48:07.292941Z | false |
airbnb/ruby | https://github.com/airbnb/ruby/blob/a885a6a14ecfba85ff0100378c6583a915c37ca9/rubocop-airbnb/spec/rubocop/cop/airbnb/simple_unless_spec.rb | rubocop-airbnb/spec/rubocop/cop/airbnb/simple_unless_spec.rb | describe RuboCop::Cop::Airbnb::SimpleUnless, :config do
it 'rejects unless with multiple conditionals' do
expect_offense(<<~RUBY)
unless boolean_condition || another_method
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Unless usage is okay when there is only one conditional
return true
end
... | ruby | MIT | a885a6a14ecfba85ff0100378c6583a915c37ca9 | 2026-01-04T15:48:07.292941Z | false |
airbnb/ruby | https://github.com/airbnb/ruby/blob/a885a6a14ecfba85ff0100378c6583a915c37ca9/rubocop-airbnb/lib/rubocop-airbnb.rb | rubocop-airbnb/lib/rubocop-airbnb.rb | require 'pathname'
require 'yaml'
# Load original rubocop gem
require 'rubocop'
require 'rubocop-performance'
require 'rubocop-rails'
require_relative 'rubocop/airbnb'
require_relative 'rubocop/airbnb/plugin'
require_relative 'rubocop/airbnb/version'
| ruby | MIT | a885a6a14ecfba85ff0100378c6583a915c37ca9 | 2026-01-04T15:48:07.292941Z | false |
airbnb/ruby | https://github.com/airbnb/ruby/blob/a885a6a14ecfba85ff0100378c6583a915c37ca9/rubocop-airbnb/lib/rubocop/airbnb.rb | rubocop-airbnb/lib/rubocop/airbnb.rb | require 'pathname'
require 'psych'
Dir.glob(File.expand_path('cop/**/*.rb', File.dirname(__FILE__))).map(&method(:require))
module RuboCop
# RuboCop Airbnb project namespace
module Airbnb
PROJECT_ROOT =
Pathname.new(__FILE__).parent.parent.parent.expand_path.freeze
CONFIG_DEFAULT = PROJECT_ROOT.join... | ruby | MIT | a885a6a14ecfba85ff0100378c6583a915c37ca9 | 2026-01-04T15:48:07.292941Z | false |
airbnb/ruby | https://github.com/airbnb/ruby/blob/a885a6a14ecfba85ff0100378c6583a915c37ca9/rubocop-airbnb/lib/rubocop/airbnb/version.rb | rubocop-airbnb/lib/rubocop/airbnb/version.rb | # frozen_string_literal: true
module RuboCop
module Airbnb
# Version information for the the Airbnb RuboCop plugin.
VERSION = '8.1.0'
end
end
| ruby | MIT | a885a6a14ecfba85ff0100378c6583a915c37ca9 | 2026-01-04T15:48:07.292941Z | false |
airbnb/ruby | https://github.com/airbnb/ruby/blob/a885a6a14ecfba85ff0100378c6583a915c37ca9/rubocop-airbnb/lib/rubocop/airbnb/plugin.rb | rubocop-airbnb/lib/rubocop/airbnb/plugin.rb | # frozen_string_literal: true
require 'lint_roller'
module RuboCop
module Airbnb
# A plugin that integrates RuboCop Airbnb with RuboCop's plugin system.
class Plugin < LintRoller::Plugin
def about
LintRoller::About.new(
name: 'rubocop-airbnb',
version: VERSION,
ho... | ruby | MIT | a885a6a14ecfba85ff0100378c6583a915c37ca9 | 2026-01-04T15:48:07.292941Z | false |
airbnb/ruby | https://github.com/airbnb/ruby/blob/a885a6a14ecfba85ff0100378c6583a915c37ca9/rubocop-airbnb/lib/rubocop/airbnb/inflections.rb | rubocop-airbnb/lib/rubocop/airbnb/inflections.rb | # String inflections copied over from ActiveSupport
module Inflections
# Convert Foo::BarBaz to foo/bar_baz.
# Copied from ActiveSupport.
def underscore(camel_cased_word)
word = camel_cased_word.to_s.dup
word.gsub!(/::/, '/')
word.gsub!(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
word.gsub!(/([a-z\d])([A-Z])... | ruby | MIT | a885a6a14ecfba85ff0100378c6583a915c37ca9 | 2026-01-04T15:48:07.292941Z | false |
airbnb/ruby | https://github.com/airbnb/ruby/blob/a885a6a14ecfba85ff0100378c6583a915c37ca9/rubocop-airbnb/lib/rubocop/airbnb/rails_autoloading.rb | rubocop-airbnb/lib/rubocop/airbnb/rails_autoloading.rb | # These methods are useful for Rubocop rules related to Rails autoloading.
module RailsAutoloading
def run_rails_autoloading_cops?(path)
return false unless config["Rails".freeze]
return false unless config["Rails".freeze]["Enabled".freeze]
# Ignore rake tasks
return false unless path.end_with?(".rb"... | ruby | MIT | a885a6a14ecfba85ff0100378c6583a915c37ca9 | 2026-01-04T15:48:07.292941Z | false |
airbnb/ruby | https://github.com/airbnb/ruby/blob/a885a6a14ecfba85ff0100378c6583a915c37ca9/rubocop-airbnb/lib/rubocop/cop/airbnb/risky_activerecord_invocation.rb | rubocop-airbnb/lib/rubocop/cop/airbnb/risky_activerecord_invocation.rb | module RuboCop
module Cop
module Airbnb
# Disallow ActiveRecord calls that pass interpolated or added strings as an argument.
class RiskyActiverecordInvocation < Base
MSG = 'Passing a string computed by interpolation or addition to an ActiveRecord ' \
'method is likely to lead to... | ruby | MIT | a885a6a14ecfba85ff0100378c6583a915c37ca9 | 2026-01-04T15:48:07.292941Z | false |
airbnb/ruby | https://github.com/airbnb/ruby/blob/a885a6a14ecfba85ff0100378c6583a915c37ca9/rubocop-airbnb/lib/rubocop/cop/airbnb/const_assigned_in_wrong_file.rb | rubocop-airbnb/lib/rubocop/cop/airbnb/const_assigned_in_wrong_file.rb | require_relative '../../airbnb/inflections'
require_relative '../../airbnb/rails_autoloading'
module RuboCop
module Cop
module Airbnb
# This cop checks for a constant assigned in a file that does not match its owning scope.
# The Rails autoloader can't find such a constant, but sometimes
# peop... | ruby | MIT | a885a6a14ecfba85ff0100378c6583a915c37ca9 | 2026-01-04T15:48:07.292941Z | false |
airbnb/ruby | https://github.com/airbnb/ruby/blob/a885a6a14ecfba85ff0100378c6583a915c37ca9/rubocop-airbnb/lib/rubocop/cop/airbnb/spec_constant_assignment.rb | rubocop-airbnb/lib/rubocop/cop/airbnb/spec_constant_assignment.rb | require 'rubocop-rspec'
module RuboCop
module Cop
module Airbnb
# This cop checks for constant assignment inside of specs
#
# @example
# # bad
# describe Something do
# PAYLOAD = [1, 2, 3]
# end
#
# # good
# describe Something do
# ... | ruby | MIT | a885a6a14ecfba85ff0100378c6583a915c37ca9 | 2026-01-04T15:48:07.292941Z | false |
airbnb/ruby | https://github.com/airbnb/ruby/blob/a885a6a14ecfba85ff0100378c6583a915c37ca9/rubocop-airbnb/lib/rubocop/cop/airbnb/default_scope.rb | rubocop-airbnb/lib/rubocop/cop/airbnb/default_scope.rb | module RuboCop
module Cop
module Airbnb
# Cop to help prevent the scorge of Default Scopes from ActiveRecord.
# Once in place they are almost impossible to remove.
class DefaultScope < Base
MSG = 'Avoid `default_scope`. Default scopes make it difficult to '\
'refactor data... | ruby | MIT | a885a6a14ecfba85ff0100378c6583a915c37ca9 | 2026-01-04T15:48:07.292941Z | false |
airbnb/ruby | https://github.com/airbnb/ruby/blob/a885a6a14ecfba85ff0100378c6583a915c37ca9/rubocop-airbnb/lib/rubocop/cop/airbnb/continuation_slash.rb | rubocop-airbnb/lib/rubocop/cop/airbnb/continuation_slash.rb | module RuboCop
module Cop
module Airbnb
class ContinuationSlash < Base
MSG = 'Slash continuation should be reserved for closed string continuation. ' \
'Many times it is used to get around other existing rules.'.freeze
def enforce_violation(node)
return if node.sourc... | ruby | MIT | a885a6a14ecfba85ff0100378c6583a915c37ca9 | 2026-01-04T15:48:07.292941Z | false |
airbnb/ruby | https://github.com/airbnb/ruby/blob/a885a6a14ecfba85ff0100378c6583a915c37ca9/rubocop-airbnb/lib/rubocop/cop/airbnb/rspec_describe_or_context_under_namespace.rb | rubocop-airbnb/lib/rubocop/cop/airbnb/rspec_describe_or_context_under_namespace.rb | module RuboCop
module Cop
module Airbnb
# This cop checks for Rspec describe or context method calls under a namespace.
# It can potentially cause autoloading to occur in a different order than it
# would have in development or production. This could cause flaky tests.
#
# @example
... | ruby | MIT | a885a6a14ecfba85ff0100378c6583a915c37ca9 | 2026-01-04T15:48:07.292941Z | false |
airbnb/ruby | https://github.com/airbnb/ruby/blob/a885a6a14ecfba85ff0100378c6583a915c37ca9/rubocop-airbnb/lib/rubocop/cop/airbnb/unsafe_yaml_marshal.rb | rubocop-airbnb/lib/rubocop/cop/airbnb/unsafe_yaml_marshal.rb | module RuboCop
module Cop
module Airbnb
# Disallow use of YAML/Marshal methods that can trigger RCE on untrusted input
class UnsafeYamlMarshal < Base
MSG = 'Using unsafe YAML parsing methods on untrusted input can lead ' \
'to remote code execution. Use `safe_load`, `parse`, `par... | ruby | MIT | a885a6a14ecfba85ff0100378c6583a915c37ca9 | 2026-01-04T15:48:07.292941Z | false |
airbnb/ruby | https://github.com/airbnb/ruby/blob/a885a6a14ecfba85ff0100378c6583a915c37ca9/rubocop-airbnb/lib/rubocop/cop/airbnb/factory_attr_references_class.rb | rubocop-airbnb/lib/rubocop/cop/airbnb/factory_attr_references_class.rb | module RuboCop
module Cop
module Airbnb
# Cop to enforce "attr { CONST }" instead of "attr CONST" in factories,
# because the latter forces autoload, which slows down spec startup time and
# Zeus reload time after touching a model.
class FactoryAttrReferencesClass < Base
MSG = "Ins... | ruby | MIT | a885a6a14ecfba85ff0100378c6583a915c37ca9 | 2026-01-04T15:48:07.292941Z | false |
airbnb/ruby | https://github.com/airbnb/ruby/blob/a885a6a14ecfba85ff0100378c6583a915c37ca9/rubocop-airbnb/lib/rubocop/cop/airbnb/no_timeout.rb | rubocop-airbnb/lib/rubocop/cop/airbnb/no_timeout.rb | module RuboCop
module Cop
module Airbnb
class NoTimeout < Base
MSG =
'Do not use Timeout.timeout. In combination with Rails autoloading, ' \
'timeout can cause Segmentation Faults in version of Ruby we use. ' \
'It can also cause logic errors since it can raise in ' \
... | ruby | MIT | a885a6a14ecfba85ff0100378c6583a915c37ca9 | 2026-01-04T15:48:07.292941Z | false |
airbnb/ruby | https://github.com/airbnb/ruby/blob/a885a6a14ecfba85ff0100378c6583a915c37ca9/rubocop-airbnb/lib/rubocop/cop/airbnb/module_method_in_wrong_file.rb | rubocop-airbnb/lib/rubocop/cop/airbnb/module_method_in_wrong_file.rb | require_relative '../../airbnb/inflections'
require_relative '../../airbnb/rails_autoloading'
module RuboCop
module Cop
module Airbnb
# This cop checks for methods defined in a module declaration, in a file that doesn't
# match the module name. The Rails autoloader can't find such a method, but somet... | ruby | MIT | a885a6a14ecfba85ff0100378c6583a915c37ca9 | 2026-01-04T15:48:07.292941Z | false |
airbnb/ruby | https://github.com/airbnb/ruby/blob/a885a6a14ecfba85ff0100378c6583a915c37ca9/rubocop-airbnb/lib/rubocop/cop/airbnb/phrase_bundle_keys.rb | rubocop-airbnb/lib/rubocop/cop/airbnb/phrase_bundle_keys.rb | module RuboCop
module Cop
module Airbnb
# Prefer matching Phrase Bundle and t call keys inside of
# PhraseBundleClasses.
#
# @example
# # bad
# def phrases
# {
# "shortened_key" => t(
# "my_real_translation_key",
# default: ... | ruby | MIT | a885a6a14ecfba85ff0100378c6583a915c37ca9 | 2026-01-04T15:48:07.292941Z | false |
airbnb/ruby | https://github.com/airbnb/ruby/blob/a885a6a14ecfba85ff0100378c6583a915c37ca9/rubocop-airbnb/lib/rubocop/cop/airbnb/class_or_module_declared_in_wrong_file.rb | rubocop-airbnb/lib/rubocop/cop/airbnb/class_or_module_declared_in_wrong_file.rb | require_relative '../../airbnb/inflections'
require_relative '../../airbnb/rails_autoloading'
module RuboCop
module Cop
module Airbnb
# This cop checks for a class or module declared in a file that does not match its name.
# The Rails autoloader can't find such a constant, but sometimes
# peopl... | ruby | MIT | a885a6a14ecfba85ff0100378c6583a915c37ca9 | 2026-01-04T15:48:07.292941Z | false |
airbnb/ruby | https://github.com/airbnb/ruby/blob/a885a6a14ecfba85ff0100378c6583a915c37ca9/rubocop-airbnb/lib/rubocop/cop/airbnb/opt_arg_parameters.rb | rubocop-airbnb/lib/rubocop/cop/airbnb/opt_arg_parameters.rb | module RuboCop
module Cop
module Airbnb
# Cop to enforce use of options hash over default arguments
# https://github.com/airbnb/ruby#no-default-args
class OptArgParameters < Base
MSG =
'Do not use default positional arguments. '\
'Use keyword arguments or an options h... | ruby | MIT | a885a6a14ecfba85ff0100378c6583a915c37ca9 | 2026-01-04T15:48:07.292941Z | false |
airbnb/ruby | https://github.com/airbnb/ruby/blob/a885a6a14ecfba85ff0100378c6583a915c37ca9/rubocop-airbnb/lib/rubocop/cop/airbnb/simple_modifier_conditional.rb | rubocop-airbnb/lib/rubocop/cop/airbnb/simple_modifier_conditional.rb | module RuboCop
module Cop
module Airbnb
# Cop to tackle prevent more complicated modifier if/unless statements
# https://github.com/airbnb/ruby#only-simple-if-unless
class SimpleModifierConditional < Base
MSG = 'Modifier if/unless usage is okay when the body is simple, ' \
'the... | ruby | MIT | a885a6a14ecfba85ff0100378c6583a915c37ca9 | 2026-01-04T15:48:07.292941Z | false |
airbnb/ruby | https://github.com/airbnb/ruby/blob/a885a6a14ecfba85ff0100378c6583a915c37ca9/rubocop-airbnb/lib/rubocop/cop/airbnb/rspec_environment_modification.rb | rubocop-airbnb/lib/rubocop/cop/airbnb/rspec_environment_modification.rb | module RuboCop
module Cop
module Airbnb
# This cop checks how the Rails environment is modified in specs. If an individual method on
# Rails.env is modified multiple environment related branchs could be run down. Rather than
# modifying a single path or setting Rails.env in a way that could blee... | ruby | MIT | a885a6a14ecfba85ff0100378c6583a915c37ca9 | 2026-01-04T15:48:07.292941Z | false |
airbnb/ruby | https://github.com/airbnb/ruby/blob/a885a6a14ecfba85ff0100378c6583a915c37ca9/rubocop-airbnb/lib/rubocop/cop/airbnb/simple_unless.rb | rubocop-airbnb/lib/rubocop/cop/airbnb/simple_unless.rb | module RuboCop
module Cop
module Airbnb
# Cop to tackle prevent unless statements with multiple conditions
# https://github.com/airbnb/ruby#unless-with-multiple-conditions
class SimpleUnless < Base
MSG = 'Unless usage is okay when there is only one conditional'.freeze
def_node_m... | ruby | MIT | a885a6a14ecfba85ff0100378c6583a915c37ca9 | 2026-01-04T15:48:07.292941Z | false |
airbnb/ruby | https://github.com/airbnb/ruby/blob/a885a6a14ecfba85ff0100378c6583a915c37ca9/rubocop-airbnb/lib/rubocop/cop/airbnb/factory_class_use_string.rb | rubocop-airbnb/lib/rubocop/cop/airbnb/factory_class_use_string.rb | module RuboCop
module Cop
module Airbnb
# Cop to tell developers to use :class => "MyClass" instead of :class => MyClass,
# because the latter slows down reloading zeus.
class FactoryClassUseString < Base
MSG = 'Instead of :class => MyClass, use :class => "MyClass". ' \
"This e... | ruby | MIT | a885a6a14ecfba85ff0100378c6583a915c37ca9 | 2026-01-04T15:48:07.292941Z | false |
airbnb/ruby | https://github.com/airbnb/ruby/blob/a885a6a14ecfba85ff0100378c6583a915c37ca9/rubocop-airbnb/lib/rubocop/cop/airbnb/mass_assignment_accessible_modifier.rb | rubocop-airbnb/lib/rubocop/cop/airbnb/mass_assignment_accessible_modifier.rb | module RuboCop
module Cop
module Airbnb
# Modifying Mass assignment restrictions eliminates the entire point of disabling
# mass assignment. It's a lazy, potentially dangerous approach that should be discouraged.
class MassAssignmentAccessibleModifier < Base
MSG = 'Do no override and obj... | ruby | MIT | a885a6a14ecfba85ff0100378c6583a915c37ca9 | 2026-01-04T15:48:07.292941Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.