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 |
|---|---|---|---|---|---|---|---|---|
rails/webpacker | https://github.com/rails/webpacker/blob/a715e055d937748c7cfd34b0450295348ca13ee6/lib/webpacker/dev_server_runner.rb | lib/webpacker/dev_server_runner.rb | require "shellwords"
require "socket"
require "webpacker/configuration"
require "webpacker/dev_server"
require "webpacker/runner"
module Webpacker
class DevServerRunner < Webpacker::Runner
def run
load_config
detect_unsupported_switches!
detect_port!
execute_cmd
end
private
... | ruby | MIT | a715e055d937748c7cfd34b0450295348ca13ee6 | 2026-01-04T15:43:16.273438Z | false |
rails/webpacker | https://github.com/rails/webpacker/blob/a715e055d937748c7cfd34b0450295348ca13ee6/lib/webpacker/version.rb | lib/webpacker/version.rb | module Webpacker
# Change the version in package.json too, please!
VERSION = "6.0.0.rc.6".freeze
end
| ruby | MIT | a715e055d937748c7cfd34b0450295348ca13ee6 | 2026-01-04T15:43:16.273438Z | false |
rails/webpacker | https://github.com/rails/webpacker/blob/a715e055d937748c7cfd34b0450295348ca13ee6/lib/webpacker/manifest.rb | lib/webpacker/manifest.rb | # Singleton registry for accessing the packs path using a generated manifest.
# This allows javascript_pack_tag, stylesheet_pack_tag, asset_pack_path to take a reference to,
# say, "calendar.js" or "calendar.css" and turn it into "/packs/calendar-1016838bab065ae1e314.js" or
# "/packs/calendar-1016838bab065ae1e314.css".... | ruby | MIT | a715e055d937748c7cfd34b0450295348ca13ee6 | 2026-01-04T15:43:16.273438Z | false |
rails/webpacker | https://github.com/rails/webpacker/blob/a715e055d937748c7cfd34b0450295348ca13ee6/lib/webpacker/compiler.rb | lib/webpacker/compiler.rb | require "open3"
require "digest/sha1"
class Webpacker::Compiler
# Additional paths that test compiler needs to watch
# Webpacker::Compiler.watched_paths << 'bower_components'
#
# Deprecated. Use additional_paths in the YAML configuration instead.
cattr_accessor(:watched_paths) { [] }
# Additional environm... | ruby | MIT | a715e055d937748c7cfd34b0450295348ca13ee6 | 2026-01-04T15:43:16.273438Z | false |
rails/webpacker | https://github.com/rails/webpacker/blob/a715e055d937748c7cfd34b0450295348ca13ee6/lib/webpacker/env.rb | lib/webpacker/env.rb | class Webpacker::Env
DEFAULT = "production".freeze
delegate :config_path, :logger, to: :@webpacker
def self.inquire(webpacker)
new(webpacker).inquire
end
def initialize(webpacker)
@webpacker = webpacker
end
def inquire
fallback_env_warning if config_path.exist? && !current
current || D... | ruby | MIT | a715e055d937748c7cfd34b0450295348ca13ee6 | 2026-01-04T15:43:16.273438Z | false |
rails/webpacker | https://github.com/rails/webpacker/blob/a715e055d937748c7cfd34b0450295348ca13ee6/lib/webpacker/railtie.rb | lib/webpacker/railtie.rb | require "rails/railtie"
require "webpacker/helper"
require "webpacker/dev_server_proxy"
class Webpacker::Engine < ::Rails::Engine
# Allows Webpacker config values to be set via Rails env config files
config.webpacker = ActiveSupport::OrderedOptions.new
initializer "webpacker.proxy" do |app|
if (Webpacker.c... | ruby | MIT | a715e055d937748c7cfd34b0450295348ca13ee6 | 2026-01-04T15:43:16.273438Z | false |
rails/webpacker | https://github.com/rails/webpacker/blob/a715e055d937748c7cfd34b0450295348ca13ee6/lib/webpacker/dev_server.rb | lib/webpacker/dev_server.rb | class Webpacker::DevServer
DEFAULT_ENV_PREFIX = "WEBPACKER_DEV_SERVER".freeze
# Configure dev server connection timeout (in seconds), default: 0.01
# Webpacker.dev_server.connect_timeout = 1
cattr_accessor(:connect_timeout) { 0.01 }
attr_reader :config
def initialize(config)
@config = config
end
... | ruby | MIT | a715e055d937748c7cfd34b0450295348ca13ee6 | 2026-01-04T15:43:16.273438Z | false |
rails/webpacker | https://github.com/rails/webpacker/blob/a715e055d937748c7cfd34b0450295348ca13ee6/lib/webpacker/configuration.rb | lib/webpacker/configuration.rb | require "yaml"
require "active_support/core_ext/hash/keys"
require "active_support/core_ext/hash/indifferent_access"
class Webpacker::Configuration
class << self
attr_accessor :installing
end
attr_reader :root_path, :config_path, :env
def initialize(root_path:, config_path:, env:)
@root_path = root_p... | ruby | MIT | a715e055d937748c7cfd34b0450295348ca13ee6 | 2026-01-04T15:43:16.273438Z | false |
rails/webpacker | https://github.com/rails/webpacker/blob/a715e055d937748c7cfd34b0450295348ca13ee6/lib/webpacker/runner.rb | lib/webpacker/runner.rb | module Webpacker
class Runner
def self.run(argv)
$stdout.sync = true
new(argv).run
end
def initialize(argv)
@argv = argv
@app_path = File.expand_path(".", Dir.pwd)
@node_modules_bin_path = ENV["WEBPACKER_NODE_MODULES_BIN_PATH"] || `yarn bin`.chomp
@webpa... | ruby | MIT | a715e055d937748c7cfd34b0450295348ca13ee6 | 2026-01-04T15:43:16.273438Z | false |
rails/webpacker | https://github.com/rails/webpacker/blob/a715e055d937748c7cfd34b0450295348ca13ee6/lib/webpacker/webpack_runner.rb | lib/webpacker/webpack_runner.rb | require "shellwords"
require "webpacker/runner"
module Webpacker
class WebpackRunner < Webpacker::Runner
WEBPACK_COMMANDS = [
"help",
"h",
"--help",
"-h",
"version",
"v",
"--version",
"-v",
"info",
"i"
].freeze
def run
env = Webpacker::Co... | ruby | MIT | a715e055d937748c7cfd34b0450295348ca13ee6 | 2026-01-04T15:43:16.273438Z | false |
rails/webpacker | https://github.com/rails/webpacker/blob/a715e055d937748c7cfd34b0450295348ca13ee6/lib/webpacker/commands.rb | lib/webpacker/commands.rb | class Webpacker::Commands
delegate :config, :compiler, :manifest, :logger, to: :@webpacker
def initialize(webpacker)
@webpacker = webpacker
end
# Cleanup old assets in the compile directory. By default it will
# keep the latest version, 2 backups created within the past hour.
#
# Examples
#
# ... | ruby | MIT | a715e055d937748c7cfd34b0450295348ca13ee6 | 2026-01-04T15:43:16.273438Z | false |
rails/webpacker | https://github.com/rails/webpacker/blob/a715e055d937748c7cfd34b0450295348ca13ee6/lib/webpacker/helper.rb | lib/webpacker/helper.rb | module Webpacker::Helper
# Returns the current Webpacker instance.
# Could be overridden to use multiple Webpacker
# configurations within the same app (e.g. with engines).
def current_webpacker_instance
Webpacker.instance
end
# Computes the relative path for a given Webpacker asset.
# Returns the re... | ruby | MIT | a715e055d937748c7cfd34b0450295348ca13ee6 | 2026-01-04T15:43:16.273438Z | false |
rails/webpacker | https://github.com/rails/webpacker/blob/a715e055d937748c7cfd34b0450295348ca13ee6/lib/webpacker/instance.rb | lib/webpacker/instance.rb | class Webpacker::Instance
cattr_accessor(:logger) { ActiveSupport::TaggedLogging.new(ActiveSupport::Logger.new(STDOUT)) }
attr_reader :root_path, :config_path
def initialize(root_path: Rails.root, config_path: Rails.root.join("config/webpacker.yml"))
@root_path, @config_path = root_path, config_path
end
... | ruby | MIT | a715e055d937748c7cfd34b0450295348ca13ee6 | 2026-01-04T15:43:16.273438Z | false |
rails/webpacker | https://github.com/rails/webpacker/blob/a715e055d937748c7cfd34b0450295348ca13ee6/lib/webpacker/dev_server_proxy.rb | lib/webpacker/dev_server_proxy.rb | require "rack/proxy"
class Webpacker::DevServerProxy < Rack::Proxy
delegate :config, :dev_server, to: :@webpacker
def initialize(app = nil, opts = {})
@webpacker = opts.delete(:webpacker) || Webpacker.instance
opts[:streaming] = false if Rails.env.test? && !opts.key?(:streaming)
super
end
def per... | ruby | MIT | a715e055d937748c7cfd34b0450295348ca13ee6 | 2026-01-04T15:43:16.273438Z | false |
rails/webpacker | https://github.com/rails/webpacker/blob/a715e055d937748c7cfd34b0450295348ca13ee6/lib/install/binstubs.rb | lib/install/binstubs.rb | say "Copying binstubs"
directory "#{__dir__}/bin", "bin"
chmod "bin", 0755 & ~File.umask, verbose: false
| ruby | MIT | a715e055d937748c7cfd34b0450295348ca13ee6 | 2026-01-04T15:43:16.273438Z | false |
rails/webpacker | https://github.com/rails/webpacker/blob/a715e055d937748c7cfd34b0450295348ca13ee6/lib/install/template.rb | lib/install/template.rb | # Install Webpacker
copy_file "#{__dir__}/config/webpacker.yml", "config/webpacker.yml"
copy_file "#{__dir__}/package.json", "package.json"
say "Copying webpack core config"
directory "#{__dir__}/config/webpack", "config/webpack"
if Dir.exist?(Webpacker.config.source_path)
say "The packs app source directory alread... | ruby | MIT | a715e055d937748c7cfd34b0450295348ca13ee6 | 2026-01-04T15:43:16.273438Z | false |
sferik/t-ruby | https://github.com/sferik/t-ruby/blob/d2037676c60c96523db626b681f1b651777a98e7/spec/search_spec.rb | spec/search_spec.rb | # encoding: utf-8
require "helper"
describe T::Search do
before :all do
Timecop.freeze(Time.utc(2011, 11, 24, 16, 20, 0))
T.utc_offset = "PST"
end
before do
T::RCFile.instance.path = "#{fixture_path}/.trc"
@search = described_class.new
@search.options = @search.options.merge("color" => "alw... | ruby | MIT | d2037676c60c96523db626b681f1b651777a98e7 | 2026-01-04T15:43:07.089276Z | true |
sferik/t-ruby | https://github.com/sferik/t-ruby/blob/d2037676c60c96523db626b681f1b651777a98e7/spec/delete_spec.rb | spec/delete_spec.rb | # encoding: utf-8
require "helper"
describe T::Delete do
before do
T::RCFile.instance.path = "#{fixture_path}/.trc"
@delete = described_class.new
@old_stderr = $stderr
$stderr = StringIO.new
@old_stdout = $stdout
$stdout = StringIO.new
end
after do
T::RCFile.instance.reset
$stde... | ruby | MIT | d2037676c60c96523db626b681f1b651777a98e7 | 2026-01-04T15:43:07.089276Z | false |
sferik/t-ruby | https://github.com/sferik/t-ruby/blob/d2037676c60c96523db626b681f1b651777a98e7/spec/rcfile_spec.rb | spec/rcfile_spec.rb | # encoding: utf-8
require "helper"
describe T::RCFile do
after do
described_class.instance.reset
FileUtils.rm_f("#{project_path}/tmp/trc")
end
it "is a singleton" do
expect(described_class).to be_a Class
expect do
described_class.new
end.to raise_error(NoMethodError, /private method (... | ruby | MIT | d2037676c60c96523db626b681f1b651777a98e7 | 2026-01-04T15:43:07.089276Z | false |
sferik/t-ruby | https://github.com/sferik/t-ruby/blob/d2037676c60c96523db626b681f1b651777a98e7/spec/editor_spec.rb | spec/editor_spec.rb | # encoding: utf-8
require "helper"
describe T::Editor do
context "when editing a file" do
before do
allow(described_class).to receive(:edit) do |path|
File.binwrite(path, "A tweet!!!!")
end
end
it "fetches your tweet content without comments" do
expect(described_class.gets).to... | ruby | MIT | d2037676c60c96523db626b681f1b651777a98e7 | 2026-01-04T15:43:07.089276Z | false |
sferik/t-ruby | https://github.com/sferik/t-ruby/blob/d2037676c60c96523db626b681f1b651777a98e7/spec/utils_spec.rb | spec/utils_spec.rb | # encoding: utf-8
require "helper"
class Test; end
describe T::Utils do
before :all do
Timecop.freeze(Time.utc(2011, 11, 24, 16, 20, 0))
T.utc_offset = -28_800
end
before do
@test = Test.new
@test.extend(described_class)
end
after :all do
T.utc_offset = nil
Timecop.return
end
... | ruby | MIT | d2037676c60c96523db626b681f1b651777a98e7 | 2026-01-04T15:43:07.089276Z | false |
sferik/t-ruby | https://github.com/sferik/t-ruby/blob/d2037676c60c96523db626b681f1b651777a98e7/spec/cli_spec.rb | spec/cli_spec.rb | # encoding: utf-8
require "helper"
describe T::CLI do
before :all do
Timecop.freeze(Time.utc(2011, 11, 24, 16, 20, 0))
T.utc_offset = "PST"
end
before do
T::RCFile.instance.path = "#{fixture_path}/.trc"
@cli = described_class.new
@cli.options = @cli.options.merge("color" => "always")
@o... | ruby | MIT | d2037676c60c96523db626b681f1b651777a98e7 | 2026-01-04T15:43:07.089276Z | true |
sferik/t-ruby | https://github.com/sferik/t-ruby/blob/d2037676c60c96523db626b681f1b651777a98e7/spec/stream_spec.rb | spec/stream_spec.rb | require "helper"
describe T::Stream do
let(:t_class) do
klass = Class.new
allow(klass).to receive(:options=)
allow(klass).to receive(:options).and_return({})
klass
end
before :all do
@tweet = tweet_from_fixture("status.json")
end
before do
T::RCFile.instance.path = "#{fixture_path}/... | ruby | MIT | d2037676c60c96523db626b681f1b651777a98e7 | 2026-01-04T15:43:07.089276Z | false |
sferik/t-ruby | https://github.com/sferik/t-ruby/blob/d2037676c60c96523db626b681f1b651777a98e7/spec/set_spec.rb | spec/set_spec.rb | # encoding: utf-8
require "helper"
describe T::Set do
before do
T::RCFile.instance.path = "#{fixture_path}/.trc"
@set = described_class.new
@old_stderr = $stderr
$stderr = StringIO.new
@old_stdout = $stdout
$stdout = StringIO.new
end
after do
T::RCFile.instance.reset
$stderr = @... | ruby | MIT | d2037676c60c96523db626b681f1b651777a98e7 | 2026-01-04T15:43:07.089276Z | false |
sferik/t-ruby | https://github.com/sferik/t-ruby/blob/d2037676c60c96523db626b681f1b651777a98e7/spec/list_spec.rb | spec/list_spec.rb | # encoding: utf-8
require "helper"
describe T::List do
before :all do
Timecop.freeze(Time.utc(2011, 11, 24, 16, 20, 0))
T.utc_offset = "PST"
end
before do
T::RCFile.instance.path = "#{fixture_path}/.trc"
@list = described_class.new
@old_stderr = $stderr
$stderr = StringIO.new
@old_s... | ruby | MIT | d2037676c60c96523db626b681f1b651777a98e7 | 2026-01-04T15:43:07.089276Z | true |
sferik/t-ruby | https://github.com/sferik/t-ruby/blob/d2037676c60c96523db626b681f1b651777a98e7/spec/helper.rb | spec/helper.rb | ENV["THOR_COLUMNS"] = "80"
require "simplecov"
SimpleCov.start do
add_filter "/spec"
minimum_coverage(99.18)
end
require "t"
require "json"
require "readline"
require "rspec"
require "timecop"
require "webmock/rspec"
RSpec.configure do |config|
config.expect_with :rspec do |c|
c.syntax = :expect
end
... | ruby | MIT | d2037676c60c96523db626b681f1b651777a98e7 | 2026-01-04T15:43:07.089276Z | false |
sferik/t-ruby | https://github.com/sferik/t-ruby/blob/d2037676c60c96523db626b681f1b651777a98e7/lib/t.rb | lib/t.rb | require "t/cli"
require "time"
module T
class << self
# Convert time to local time by applying the `utc_offset` setting.
def local_time(time)
time = time.dup
utc_offset ? (time.utc + utc_offset) : time.localtime
end
# UTC offset in seconds to apply time instances before displaying.
#... | ruby | MIT | d2037676c60c96523db626b681f1b651777a98e7 | 2026-01-04T15:43:07.089276Z | false |
sferik/t-ruby | https://github.com/sferik/t-ruby/blob/d2037676c60c96523db626b681f1b651777a98e7/lib/t/version.rb | lib/t/version.rb | module T
class Version
MAJOR = 4
MINOR = 2
PATCH = 0
PRE = nil
class << self
# @return [String]
def to_s
[MAJOR, MINOR, PATCH, PRE].compact.join(".")
end
end
end
end
| ruby | MIT | d2037676c60c96523db626b681f1b651777a98e7 | 2026-01-04T15:43:07.089276Z | false |
sferik/t-ruby | https://github.com/sferik/t-ruby/blob/d2037676c60c96523db626b681f1b651777a98e7/lib/t/collectable.rb | lib/t/collectable.rb | require "twitter"
require "retryable"
module T
module Collectable
MAX_NUM_RESULTS = 200
MAX_PAGE = 51
def collect_with_max_id(collection = [], max_id = nil, &)
tweets = Retryable.retryable(tries: 3, on: Twitter::Error, sleep: 0) do
yield(max_id)
end
return collection if tweets.... | ruby | MIT | d2037676c60c96523db626b681f1b651777a98e7 | 2026-01-04T15:43:07.089276Z | false |
sferik/t-ruby | https://github.com/sferik/t-ruby/blob/d2037676c60c96523db626b681f1b651777a98e7/lib/t/requestable.rb | lib/t/requestable.rb | require "twitter"
module T
module Requestable
private
def client
return @client if @client
@rcfile.path = options["profile"] if options["profile"]
@client = Twitter::REST::Client.new do |config|
config.consumer_key = @rcfile.active_consumer_key
config.consumer_secret ... | ruby | MIT | d2037676c60c96523db626b681f1b651777a98e7 | 2026-01-04T15:43:07.089276Z | false |
sferik/t-ruby | https://github.com/sferik/t-ruby/blob/d2037676c60c96523db626b681f1b651777a98e7/lib/t/identicon.rb | lib/t/identicon.rb | module T
class Identicon
# Six-bit number (0-63)
attr_accessor :bits
# Eight-bit number (0-255)
attr_accessor :color
def initialize(number)
# Bottom six bits
@bits = number & 0x3f
# Next highest eight bits
@fcolor = (number >> 6) & 0xff
# Next highest eight bits
... | ruby | MIT | d2037676c60c96523db626b681f1b651777a98e7 | 2026-01-04T15:43:07.089276Z | false |
sferik/t-ruby | https://github.com/sferik/t-ruby/blob/d2037676c60c96523db626b681f1b651777a98e7/lib/t/delete.rb | lib/t/delete.rb | require "thor"
require "twitter"
require "t/rcfile"
require "t/requestable"
require "t/utils"
module T
class Delete < Thor
include T::Requestable
include T::Utils
check_unknown_options!
def initialize(*)
@rcfile = T::RCFile.instance
super
end
desc "block USER [USER...]", "Unblo... | ruby | MIT | d2037676c60c96523db626b681f1b651777a98e7 | 2026-01-04T15:43:07.089276Z | false |
sferik/t-ruby | https://github.com/sferik/t-ruby/blob/d2037676c60c96523db626b681f1b651777a98e7/lib/t/printable.rb | lib/t/printable.rb | module T
module Printable # rubocop:disable Metrics/ModuleLength
LIST_HEADINGS = ["ID", "Created at", "Screen name", "Slug", "Members", "Subscribers", "Mode", "Description"].freeze
TWEET_HEADINGS = ["ID", "Posted at", "Screen name", "Text"].freeze
USER_HEADINGS = ["ID", "Since", "Last tweeted at", "Tweets... | ruby | MIT | d2037676c60c96523db626b681f1b651777a98e7 | 2026-01-04T15:43:07.089276Z | false |
sferik/t-ruby | https://github.com/sferik/t-ruby/blob/d2037676c60c96523db626b681f1b651777a98e7/lib/t/set.rb | lib/t/set.rb | require "thor"
require "t/rcfile"
require "t/requestable"
module T
class Set < Thor
include T::Requestable
check_unknown_options!
def initialize(*)
@rcfile = T::RCFile.instance
super
end
desc "active SCREEN_NAME [CONSUMER_KEY]", "Set your active account."
def active(screen_name... | ruby | MIT | d2037676c60c96523db626b681f1b651777a98e7 | 2026-01-04T15:43:07.089276Z | false |
sferik/t-ruby | https://github.com/sferik/t-ruby/blob/d2037676c60c96523db626b681f1b651777a98e7/lib/t/utils.rb | lib/t/utils.rb | module T
module Utils
private
# https://github.com/rails/rails/blob/bd8a970/actionpack/lib/action_view/helpers/date_helper.rb
def distance_of_time_in_words(from_time, to_time = Time.now) # rubocop:disable Metrics/CyclomaticComplexity
seconds = (to_time - from_time).abs
minutes = seconds / 60
... | ruby | MIT | d2037676c60c96523db626b681f1b651777a98e7 | 2026-01-04T15:43:07.089276Z | false |
sferik/t-ruby | https://github.com/sferik/t-ruby/blob/d2037676c60c96523db626b681f1b651777a98e7/lib/t/stream.rb | lib/t/stream.rb | require "thor"
require "t/printable"
require "t/rcfile"
require "t/requestable"
require "t/utils"
module T
class Stream < Thor
include T::Printable
include T::Requestable
include T::Utils
TWEET_HEADINGS_FORMATTING = [
"%-18s", # Add padding to maximum length of a Tweet ID
"%-12s", # Ad... | ruby | MIT | d2037676c60c96523db626b681f1b651777a98e7 | 2026-01-04T15:43:07.089276Z | false |
sferik/t-ruby | https://github.com/sferik/t-ruby/blob/d2037676c60c96523db626b681f1b651777a98e7/lib/t/rcfile.rb | lib/t/rcfile.rb | require "singleton"
module T
class RCFile
include Singleton
attr_reader :path
FILE_NAME = ".trc".freeze
def initialize
@path = File.join(File.expand_path("~"), FILE_NAME)
@data = load_file
end
def [](username)
profiles[find(username)]
end
def find(username)
... | ruby | MIT | d2037676c60c96523db626b681f1b651777a98e7 | 2026-01-04T15:43:07.089276Z | false |
sferik/t-ruby | https://github.com/sferik/t-ruby/blob/d2037676c60c96523db626b681f1b651777a98e7/lib/t/search.rb | lib/t/search.rb | require "thor"
require "twitter"
require "t/collectable"
require "t/printable"
require "t/rcfile"
require "t/requestable"
require "t/utils"
module T
class Search < Thor
include T::Collectable
include T::Printable
include T::Requestable
include T::Utils
DEFAULT_NUM_RESULTS = 20
MAX_NUM_RESULT... | ruby | MIT | d2037676c60c96523db626b681f1b651777a98e7 | 2026-01-04T15:43:07.089276Z | false |
sferik/t-ruby | https://github.com/sferik/t-ruby/blob/d2037676c60c96523db626b681f1b651777a98e7/lib/t/cli.rb | lib/t/cli.rb | # encoding: utf-8
require "forwardable"
require "oauth"
require "thor"
require "twitter"
require "t/collectable"
require "t/delete"
require "t/editor"
require "t/list"
require "t/printable"
require "t/rcfile"
require "t/requestable"
require "t/search"
require "t/set"
require "t/stream"
require "t/utils"
module T
cl... | ruby | MIT | d2037676c60c96523db626b681f1b651777a98e7 | 2026-01-04T15:43:07.089276Z | true |
sferik/t-ruby | https://github.com/sferik/t-ruby/blob/d2037676c60c96523db626b681f1b651777a98e7/lib/t/editor.rb | lib/t/editor.rb | require "tempfile"
require "shellwords"
module T
class Editor
class << self
def gets
file = tempfile
edit(file.path)
File.read(file).strip
ensure
file.close
file.unlink
end
def tempfile
Tempfile.new("TWEET_EDITMSG")
end
def edi... | ruby | MIT | d2037676c60c96523db626b681f1b651777a98e7 | 2026-01-04T15:43:07.089276Z | false |
sferik/t-ruby | https://github.com/sferik/t-ruby/blob/d2037676c60c96523db626b681f1b651777a98e7/lib/t/list.rb | lib/t/list.rb | require "thor"
require "twitter"
require "t/collectable"
require "t/printable"
require "t/rcfile"
require "t/requestable"
require "t/utils"
module T
class List < Thor
include T::Collectable
include T::Printable
include T::Requestable
include T::Utils
DEFAULT_NUM_RESULTS = 20
check_unknown_o... | ruby | MIT | d2037676c60c96523db626b681f1b651777a98e7 | 2026-01-04T15:43:07.089276Z | false |
sferik/t-ruby | https://github.com/sferik/t-ruby/blob/d2037676c60c96523db626b681f1b651777a98e7/lib/t/core_ext/kernel.rb | lib/t/core_ext/kernel.rb | module Kernel
def Bignum(arg, base = 0) # rubocop:disable Naming/MethodName
Integer(arg, base)
end
def Fixnum(arg, base = 0) # rubocop:disable Naming/MethodName
Integer(arg, base)
end
def NilClass(_) # rubocop:disable Naming/MethodName
nil
end
end
| ruby | MIT | d2037676c60c96523db626b681f1b651777a98e7 | 2026-01-04T15:43:07.089276Z | false |
sferik/t-ruby | https://github.com/sferik/t-ruby/blob/d2037676c60c96523db626b681f1b651777a98e7/lib/t/core_ext/string.rb | lib/t/core_ext/string.rb | class String
def prepend_at
"@#{self}"
end
def strip_ats
tr("@", "")
end
alias old_to_i to_i
def to_i(base = 10)
tr(",", "").old_to_i(base)
end
end
| ruby | MIT | d2037676c60c96523db626b681f1b651777a98e7 | 2026-01-04T15:43:07.089276Z | false |
slim-template/slim | https://github.com/slim-template/slim/blob/d387587ae364f489b3e23126e204907a0b134bd3/test/smart/test_smart_text.rb | test/smart/test_smart_text.rb | require 'helper'
require 'slim/smart'
class TestSlimSmartText < TestSlim
def test_explicit_smart_text_recognition
source = %q{
>
a
>
b
>
c
>
d
> e
f
> g
h
i
}
result = %q{a
b
c
d
e
<f></f>
g
h
<i></i>}
assert_html result, source
end
def test_implicit_smart_text_recognition
sourc... | ruby | MIT | d387587ae364f489b3e23126e204907a0b134bd3 | 2026-01-04T15:43:07.251246Z | false |
slim-template/slim | https://github.com/slim-template/slim/blob/d387587ae364f489b3e23126e204907a0b134bd3/test/literate/helper.rb | test/literate/helper.rb | require 'slim'
require 'slim/logic_less'
require 'slim/translator'
require 'slim/grammar'
require 'minitest/autorun'
Slim::Engine.after Slim::Parser, Temple::Filters::Validator, grammar: Slim::Grammar
Slim::Engine.before :Pretty, Temple::Filters::Validator
Slim::Engine.set_options tr: false, logic_less: false
class ... | ruby | MIT | d387587ae364f489b3e23126e204907a0b134bd3 | 2026-01-04T15:43:07.251246Z | false |
slim-template/slim | https://github.com/slim-template/slim/blob/d387587ae364f489b3e23126e204907a0b134bd3/test/literate/run.rb | test/literate/run.rb | require 'temple'
class LiterateTest < Temple::Engine
class Parser < Temple::Parser
def call(lines)
stack = [[:multi]]
until lines.empty?
case lines.shift
when /\A(#+)\s*(.*)\Z/
stack.pop(stack.size - $1.size)
block = [:multi]
stack.last << [:section, $2, ... | ruby | MIT | d387587ae364f489b3e23126e204907a0b134bd3 | 2026-01-04T15:43:07.251246Z | false |
slim-template/slim | https://github.com/slim-template/slim/blob/d387587ae364f489b3e23126e204907a0b134bd3/test/translator/test_translator.rb | test/translator/test_translator.rb | require 'helper'
require 'slim/translator'
class TestSlimTranslator < TestSlim
def setup
super
Slim::Engine.set_options tr: true, tr_fn: 'TestSlimTranslator.tr'
end
def self.tr(s)
s.upcase
end
def self.tr_reverse(s)
s.reverse.gsub(/(\d+)%/, '%\1')
end
def test_no_translation_of_embedde... | ruby | MIT | d387587ae364f489b3e23126e204907a0b134bd3 | 2026-01-04T15:43:07.251246Z | false |
slim-template/slim | https://github.com/slim-template/slim/blob/d387587ae364f489b3e23126e204907a0b134bd3/test/rails/app/helpers/application_helper.rb | test/rails/app/helpers/application_helper.rb | module ApplicationHelper
def headline(&block)
"<h1>#{capture(&block)}</h1>".html_safe
end
end
| ruby | MIT | d387587ae364f489b3e23126e204907a0b134bd3 | 2026-01-04T15:43:07.251246Z | false |
slim-template/slim | https://github.com/slim-template/slim/blob/d387587ae364f489b3e23126e204907a0b134bd3/test/rails/app/controllers/slim_controller.rb | test/rails/app/controllers/slim_controller.rb | class SlimController < ApplicationController
def normal
end
def xml
end
def no_layout
render layout: false
end
def variables
@hello = "Hello Slim with variables!"
end
def partial
end
def streaming
@hello = "Hello Streaming!"
render :content_for, stream: true
end
def integ... | ruby | MIT | d387587ae364f489b3e23126e204907a0b134bd3 | 2026-01-04T15:43:07.251246Z | false |
slim-template/slim | https://github.com/slim-template/slim/blob/d387587ae364f489b3e23126e204907a0b134bd3/test/rails/app/controllers/entries_controller.rb | test/rails/app/controllers/entries_controller.rb | class EntriesController < ApplicationController
def edit
@entry = Entry.new
end
end
| ruby | MIT | d387587ae364f489b3e23126e204907a0b134bd3 | 2026-01-04T15:43:07.251246Z | false |
slim-template/slim | https://github.com/slim-template/slim/blob/d387587ae364f489b3e23126e204907a0b134bd3/test/rails/app/controllers/application_controller.rb | test/rails/app/controllers/application_controller.rb | class ApplicationController < ActionController::Base
end
| ruby | MIT | d387587ae364f489b3e23126e204907a0b134bd3 | 2026-01-04T15:43:07.251246Z | false |
slim-template/slim | https://github.com/slim-template/slim/blob/d387587ae364f489b3e23126e204907a0b134bd3/test/rails/app/models/entry.rb | test/rails/app/models/entry.rb | class Entry
include ActiveModel::Conversion
extend ActiveModel::Naming
attr_accessor :name
def initialize(attributes = {})
attributes.each do |name, value|
send("#{name}=", value)
end
end
def persisted?
false
end
end
| ruby | MIT | d387587ae364f489b3e23126e204907a0b134bd3 | 2026-01-04T15:43:07.251246Z | false |
slim-template/slim | https://github.com/slim-template/slim/blob/d387587ae364f489b3e23126e204907a0b134bd3/test/rails/test/test_slim.rb | test/rails/test/test_slim.rb | require File.expand_path('../helper', __FILE__)
class TestSlim < ActionDispatch::IntegrationTest
test "normal view" do
get "/slim/normal"
assert_response :success
assert_template "slim/normal"
assert_template "layouts/application"
assert_html "<h1>Hello Slim!</h1>"
end
test "variant" do
... | ruby | MIT | d387587ae364f489b3e23126e204907a0b134bd3 | 2026-01-04T15:43:07.251246Z | false |
slim-template/slim | https://github.com/slim-template/slim/blob/d387587ae364f489b3e23126e204907a0b134bd3/test/rails/test/helper.rb | test/rails/test/helper.rb | # Configure Rails Envinronment
ENV["RAILS_ENV"] = "test"
require File.expand_path("../../config/environment.rb", __FILE__)
require "rails/test_help"
require "nokogiri"
require 'rails-controller-testing'
Rails::Controller::Testing.install
Rails.backtrace_cleaner.remove_silencers!
class ActionDispatch::IntegrationTes... | ruby | MIT | d387587ae364f489b3e23126e204907a0b134bd3 | 2026-01-04T15:43:07.251246Z | false |
slim-template/slim | https://github.com/slim-template/slim/blob/d387587ae364f489b3e23126e204907a0b134bd3/test/rails/config/application.rb | test/rails/config/application.rb | require File.expand_path('../boot', __FILE__)
require 'logger'
require 'active_model/railtie'
require 'action_controller/railtie'
require 'action_view/railtie'
#require 'active_record/railtie'
#require 'action_mailer/railtie'
#require 'sprockets/railtie'
require 'slim'
module Dummy
class Application < Rails::Applic... | ruby | MIT | d387587ae364f489b3e23126e204907a0b134bd3 | 2026-01-04T15:43:07.251246Z | false |
slim-template/slim | https://github.com/slim-template/slim/blob/d387587ae364f489b3e23126e204907a0b134bd3/test/rails/config/environment.rb | test/rails/config/environment.rb | # Load the rails application
require File.expand_path('../application', __FILE__)
# Initialize the rails application
Dummy::Application.initialize!
| ruby | MIT | d387587ae364f489b3e23126e204907a0b134bd3 | 2026-01-04T15:43:07.251246Z | false |
slim-template/slim | https://github.com/slim-template/slim/blob/d387587ae364f489b3e23126e204907a0b134bd3/test/rails/config/routes.rb | test/rails/config/routes.rb | Dummy::Application.routes.draw do
# The priority is based upon order of creation:
# first created -> highest priority.
resources :entries
# Sample of regular route:
# match 'products/:id' => 'catalog#view'
# Keep in mind you can assign values other than :controller and :action
# Sample of named route... | ruby | MIT | d387587ae364f489b3e23126e204907a0b134bd3 | 2026-01-04T15:43:07.251246Z | false |
slim-template/slim | https://github.com/slim-template/slim/blob/d387587ae364f489b3e23126e204907a0b134bd3/test/rails/config/boot.rb | test/rails/config/boot.rb | require 'rubygems'
gemfile = File.expand_path('../../../../../../Gemfile', __FILE__)
if File.exist?(gemfile)
ENV['BUNDLE_GEMFILE'] = gemfile
require 'bundler'
Bundler.setup(:default, :integration)
end
$:.unshift File.expand_path('../../../../../../lib', __FILE__) | ruby | MIT | d387587ae364f489b3e23126e204907a0b134bd3 | 2026-01-04T15:43:07.251246Z | false |
slim-template/slim | https://github.com/slim-template/slim/blob/d387587ae364f489b3e23126e204907a0b134bd3/test/rails/config/initializers/session_store.rb | test/rails/config/initializers/session_store.rb | # Be sure to restart your server when you modify this file.
Dummy::Application.config.session_store :cookie_store, key: '_dummy_session'
# Use the database for sessions instead of the cookie-based default,
# which shouldn't be used to store highly confidential information
# (create the session table with "rails gener... | ruby | MIT | d387587ae364f489b3e23126e204907a0b134bd3 | 2026-01-04T15:43:07.251246Z | false |
slim-template/slim | https://github.com/slim-template/slim/blob/d387587ae364f489b3e23126e204907a0b134bd3/test/rails/config/initializers/inflections.rb | test/rails/config/initializers/inflections.rb | # Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format
# (all these examples are active by default):
# ActiveSupport::Inflector.inflections do |inflect|
# inflect.plural /^(ox)$/i, '\1en'
# inflect.singular /^(ox)en/i, '\1'
# inflect.irregular 'person', ... | ruby | MIT | d387587ae364f489b3e23126e204907a0b134bd3 | 2026-01-04T15:43:07.251246Z | false |
slim-template/slim | https://github.com/slim-template/slim/blob/d387587ae364f489b3e23126e204907a0b134bd3/test/rails/config/initializers/backtrace_silencers.rb | test/rails/config/initializers/backtrace_silencers.rb | # 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| line =~ /my_noisy_library/ }
# You can also remove all the silencers if you're trying to debug a probl... | ruby | MIT | d387587ae364f489b3e23126e204907a0b134bd3 | 2026-01-04T15:43:07.251246Z | false |
slim-template/slim | https://github.com/slim-template/slim/blob/d387587ae364f489b3e23126e204907a0b134bd3/test/rails/config/initializers/mime_types.rb | test/rails/config/initializers/mime_types.rb | # 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
# Mime::Type.register_alias "text/html", :iphone
| ruby | MIT | d387587ae364f489b3e23126e204907a0b134bd3 | 2026-01-04T15:43:07.251246Z | false |
slim-template/slim | https://github.com/slim-template/slim/blob/d387587ae364f489b3e23126e204907a0b134bd3/test/rails/config/environments/test.rb | test/rails/config/environments/test.rb | Dummy::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test su... | ruby | MIT | d387587ae364f489b3e23126e204907a0b134bd3 | 2026-01-04T15:43:07.251246Z | false |
slim-template/slim | https://github.com/slim-template/slim/blob/d387587ae364f489b3e23126e204907a0b134bd3/test/sinatra/test_core.rb | test/sinatra/test_core.rb | require_relative 'helper.rb'
begin
class SlimTest < Minitest::Test
it 'renders inline slim strings' do
slim_app { slim "h1 Hiya\n" }
assert ok?
assert_equal "<h1>Hiya</h1>", body
end
it 'renders .slim files in views path' do
slim_app { slim :hello }
assert ok?
assert_... | ruby | MIT | d387587ae364f489b3e23126e204907a0b134bd3 | 2026-01-04T15:43:07.251246Z | false |
slim-template/slim | https://github.com/slim-template/slim/blob/d387587ae364f489b3e23126e204907a0b134bd3/test/sinatra/contest.rb | test/sinatra/contest.rb | # Copyright (c) 2009 Damian Janowski and Michel Martens for Citrusbyte
#
# 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,... | ruby | MIT | d387587ae364f489b3e23126e204907a0b134bd3 | 2026-01-04T15:43:07.251246Z | false |
slim-template/slim | https://github.com/slim-template/slim/blob/d387587ae364f489b3e23126e204907a0b134bd3/test/sinatra/helper.rb | test/sinatra/helper.rb | if ENV['COVERAGE']
require 'simplecov'
SimpleCov.start do
add_filter '/test/'
add_group 'sinatra-contrib', 'sinatra-contrib'
add_group 'rack-protection', 'rack-protection'
end
end
ENV['APP_ENV'] = 'test'
RUBY_ENGINE = 'ruby' unless defined? RUBY_ENGINE
require 'rack'
testdir = File.dirname(__FILE__... | ruby | MIT | d387587ae364f489b3e23126e204907a0b134bd3 | 2026-01-04T15:43:07.251246Z | false |
slim-template/slim | https://github.com/slim-template/slim/blob/d387587ae364f489b3e23126e204907a0b134bd3/test/sinatra/test_include.rb | test/sinatra/test_include.rb | require 'slim/include'
require_relative 'helper.rb'
begin
class SlimTest < Minitest::Test
it 'renders .slim files includes with js embed' do
slim_app { slim :embed_include_js }
assert ok?
assert_equal "<!DOCTYPE html><html><head><title>Slim Examples</title><script>alert('Slim supports embedded... | ruby | MIT | d387587ae364f489b3e23126e204907a0b134bd3 | 2026-01-04T15:43:07.251246Z | false |
slim-template/slim | https://github.com/slim-template/slim/blob/d387587ae364f489b3e23126e204907a0b134bd3/test/include/test_include.rb | test/include/test_include.rb | require 'helper'
require 'slim/include'
class TestSlimInclude < TestSlim
def test_include
source = %q{
br/
a: include slimfile
b: include textfile
c: include slimfile.slim
d: include subdir/test
}
assert_html '<br /><a>slim1recslim2</a><b>1+2=3</b><c>slim1recslim2</c><d>subdir</d>', source, include_dirs: [Fi... | ruby | MIT | d387587ae364f489b3e23126e204907a0b134bd3 | 2026-01-04T15:43:07.251246Z | false |
slim-template/slim | https://github.com/slim-template/slim/blob/d387587ae364f489b3e23126e204907a0b134bd3/test/core/test_ruby_errors.rb | test/core/test_ruby_errors.rb | require 'helper'
class TestSlimRubyErrors < TestSlim
def test_multline_attribute
source = %q{
p(data-1=1
data2-=1)
p
= unknown_ruby_method
}
assert_ruby_error NameError, "test.slim:5", source, file: 'test.slim'
end
def test_broken_output_line
source = %q{
p = hello_world + \
hello_world + \... | ruby | MIT | d387587ae364f489b3e23126e204907a0b134bd3 | 2026-01-04T15:43:07.251246Z | false |
slim-template/slim | https://github.com/slim-template/slim/blob/d387587ae364f489b3e23126e204907a0b134bd3/test/core/test_tabs.rb | test/core/test_tabs.rb | require 'helper'
class TestSlimTabs < TestSlim
def teardown
Slim::Engine.set_options tabsize: 4
end
def test_single_tab1_expansion
Slim::Engine.set_options tabsize: 1
source = %Q{
|
\t0
\t1
\t2
\t3
\t4
\t5
\t6
\t7
\t8
}
result = %q{
0
1
2
3
4
... | ruby | MIT | d387587ae364f489b3e23126e204907a0b134bd3 | 2026-01-04T15:43:07.251246Z | false |
slim-template/slim | https://github.com/slim-template/slim/blob/d387587ae364f489b3e23126e204907a0b134bd3/test/core/test_erb_converter.rb | test/core/test_erb_converter.rb | require 'helper'
require 'slim/erb_converter'
class TestSlimERBConverter < TestSlim
def test_converter
source = %q{
doctype 5
html
head
title Hello World!
/! Meta tags
with long explanatory
multiline comment
meta name="description" content="template language"
/! Stylesheets
... | ruby | MIT | d387587ae364f489b3e23126e204907a0b134bd3 | 2026-01-04T15:43:07.251246Z | false |
slim-template/slim | https://github.com/slim-template/slim/blob/d387587ae364f489b3e23126e204907a0b134bd3/test/core/test_slim_template.rb | test/core/test_slim_template.rb | require 'helper'
class ::MockError < NameError
end
class TestSlimTemplate < TestSlim
def test_default_mime_type
assert_equal 'text/html', Slim::Template.default_mime_type
end
def test_registered_extension
assert_equal Slim::Template, Tilt['test.slim']
end
def test_preparing_and_evaluating
temp... | ruby | MIT | d387587ae364f489b3e23126e204907a0b134bd3 | 2026-01-04T15:43:07.251246Z | false |
slim-template/slim | https://github.com/slim-template/slim/blob/d387587ae364f489b3e23126e204907a0b134bd3/test/core/test_html_structure.rb | test/core/test_html_structure.rb | require 'helper'
class TestSlimHtmlStructure < TestSlim
def test_simple_render
# Keep the trailing space behind "body "!
source = %q{
html
head
title Simple Test Title
body
p Hello World, meet Slim.
}
assert_html '<html><head><title>Simple Test Title</title></head><body><p>Hello World, meet... | ruby | MIT | d387587ae364f489b3e23126e204907a0b134bd3 | 2026-01-04T15:43:07.251246Z | false |
slim-template/slim | https://github.com/slim-template/slim/blob/d387587ae364f489b3e23126e204907a0b134bd3/test/core/test_code_output.rb | test/core/test_code_output.rb | require 'helper'
class TestSlimCodeOutput < TestSlim
def test_render_with_call
source = %q{
p
= hello_world
}
assert_html '<p>Hello World from @env</p>', source
end
def test_render_with_trailing_whitespace
source = %q{
p
=> hello_world
}
assert_html '<p>Hello World from @env </p>', source
... | ruby | MIT | d387587ae364f489b3e23126e204907a0b134bd3 | 2026-01-04T15:43:07.251246Z | false |
slim-template/slim | https://github.com/slim-template/slim/blob/d387587ae364f489b3e23126e204907a0b134bd3/test/core/test_text_interpolation.rb | test/core/test_text_interpolation.rb | require 'helper'
class TestSlimTextInterpolation < TestSlim
def test_interpolation_in_attribute
source = %q{
p id="a#{id_helper}b" = hello_world
}
assert_html '<p id="anoticeb">Hello World from @env</p>', source
end
def test_nested_interpolation_in_attribute
source = %q{
p id="#{"abc#{1+1}" + "("}"... | ruby | MIT | d387587ae364f489b3e23126e204907a0b134bd3 | 2026-01-04T15:43:07.251246Z | false |
slim-template/slim | https://github.com/slim-template/slim/blob/d387587ae364f489b3e23126e204907a0b134bd3/test/core/test_commands.rb | test/core/test_commands.rb | require 'helper'
require 'open3'
require 'tempfile'
class TestSlimCommands < Minitest::Test
# nothing complex
STATIC_TEMPLATE = "p Hello World!\n"
# requires a `name` variable to exist at render time
DYNAMIC_TEMPLATE = "p Hello \#{name}!\n"
# a more complex example
LONG_TEMPLATE = "h1 Hello\np\n | World... | ruby | MIT | d387587ae364f489b3e23126e204907a0b134bd3 | 2026-01-04T15:43:07.251246Z | false |
slim-template/slim | https://github.com/slim-template/slim/blob/d387587ae364f489b3e23126e204907a0b134bd3/test/core/test_thread_options.rb | test/core/test_thread_options.rb | require 'helper'
class TestSlimThreadOptions < TestSlim
def test_thread_options
source = %q{p.test}
assert_html '<p class="test"></p>', source
assert_html "<p class='test'></p>", source, attr_quote: "'"
Slim::Engine.with_options(attr_quote: "'") do
assert_html "<p class='test'></p>", source
... | ruby | MIT | d387587ae364f489b3e23126e204907a0b134bd3 | 2026-01-04T15:43:07.251246Z | false |
slim-template/slim | https://github.com/slim-template/slim/blob/d387587ae364f489b3e23126e204907a0b134bd3/test/core/test_code_structure.rb | test/core/test_code_structure.rb | require 'helper'
class TestSlimCodeStructure < TestSlim
def test_render_with_conditional
source = %q{
div
- if show_first?
p The first paragraph
- else
p The second paragraph
}
assert_html '<div><p>The second paragraph</p></div>', source
end
def test_render_with_begin
source = %q{
-... | ruby | MIT | d387587ae364f489b3e23126e204907a0b134bd3 | 2026-01-04T15:43:07.251246Z | false |
slim-template/slim | https://github.com/slim-template/slim/blob/d387587ae364f489b3e23126e204907a0b134bd3/test/core/test_code_blocks.rb | test/core/test_code_blocks.rb | require 'helper'
class TestSlimCodeBlocks < TestSlim
def test_render_with_output_code_block
source = %q{
p
= hello_world "Hello Ruby!" do
| Hello from within a block!
}
assert_html '<p>Hello Ruby! Hello from within a block! Hello Ruby!</p>', source
end
def test_render_with_output_code_block_witho... | ruby | MIT | d387587ae364f489b3e23126e204907a0b134bd3 | 2026-01-04T15:43:07.251246Z | false |
slim-template/slim | https://github.com/slim-template/slim/blob/d387587ae364f489b3e23126e204907a0b134bd3/test/core/test_html_attributes.rb | test/core/test_html_attributes.rb | require 'helper'
class TestSlimHTMLAttributes < TestSlim
def test_ternary_operation_in_attribute
source = %q{
p id="#{(false ? 'notshown' : 'shown')}" = output_number
}
assert_html '<p id="shown">1337</p>', source
end
def test_ternary_operation_in_attribute_2
source = %q{
p id=(false ? 'notshown' :... | ruby | MIT | d387587ae364f489b3e23126e204907a0b134bd3 | 2026-01-04T15:43:07.251246Z | false |
slim-template/slim | https://github.com/slim-template/slim/blob/d387587ae364f489b3e23126e204907a0b134bd3/test/core/test_pretty.rb | test/core/test_pretty.rb | require 'helper'
class TestSlimPretty < TestSlim
def setup
super
Slim::Engine.set_options pretty: true
end
def teardown
Slim::Engine.set_options pretty: false
end
def test_pretty
source = %q{
doctype 5
html
head
title Hello World!
/! Meta tags
with long explanatory
m... | ruby | MIT | d387587ae364f489b3e23126e204907a0b134bd3 | 2026-01-04T15:43:07.251246Z | false |
slim-template/slim | https://github.com/slim-template/slim/blob/d387587ae364f489b3e23126e204907a0b134bd3/test/core/test_splat_prefix_option.rb | test/core/test_splat_prefix_option.rb | require 'helper'
class TestSplatPrefixOption < TestSlim
def prefixes
['*','**','*!','*%','*^','*$']
end
def options(prefix)
{ splat_prefix: prefix }
end
def test_splat_without_content
prefixes.each do |prefix|
source = %Q{
#{prefix}hash
p#{prefix}hash
}
assert_html '<div a="... | ruby | MIT | d387587ae364f489b3e23126e204907a0b134bd3 | 2026-01-04T15:43:07.251246Z | false |
slim-template/slim | https://github.com/slim-template/slim/blob/d387587ae364f489b3e23126e204907a0b134bd3/test/core/test_code_evaluation.rb | test/core/test_code_evaluation.rb | require 'helper'
class TestSlimCodeEvaluation < TestSlim
def test_render_with_call_to_set_attributes
source = %q{
p id="#{id_helper}" class="hello world" = hello_world
}
assert_html '<p class="hello world" id="notice">Hello World from @env</p>', source
end
def test_render_with_call_to_set_custom_attrib... | ruby | MIT | d387587ae364f489b3e23126e204907a0b134bd3 | 2026-01-04T15:43:07.251246Z | false |
slim-template/slim | https://github.com/slim-template/slim/blob/d387587ae364f489b3e23126e204907a0b134bd3/test/core/helper.rb | test/core/helper.rb | begin
require 'simplecov'
SimpleCov.start
rescue LoadError
end
require 'minitest/autorun'
require 'slim'
require 'slim/grammar'
Slim::Engine.after Slim::Parser, Temple::Filters::Validator, grammar: Slim::Grammar
Slim::Engine.before :Pretty, Temple::Filters::Validator
class TestSlim < Minitest::Test
def setup
... | ruby | MIT | d387587ae364f489b3e23126e204907a0b134bd3 | 2026-01-04T15:43:07.251246Z | false |
slim-template/slim | https://github.com/slim-template/slim/blob/d387587ae364f489b3e23126e204907a0b134bd3/test/core/test_parser_errors.rb | test/core/test_parser_errors.rb | require 'helper'
class TestParserErrors < TestSlim
def test_correct_filename
source = %q{
doctype 5
div Invalid
}
assert_syntax_error "Unexpected indentation\n test.slim, Line 3, Column 2\n div Invalid\n ^\n", source, file: 'test.slim'
end
def test_unexpected_indentation
source = %q{
docty... | ruby | MIT | d387587ae364f489b3e23126e204907a0b134bd3 | 2026-01-04T15:43:07.251246Z | false |
slim-template/slim | https://github.com/slim-template/slim/blob/d387587ae364f489b3e23126e204907a0b134bd3/test/core/test_unicode.rb | test/core/test_unicode.rb | require 'helper'
class TestSlimUnicode < TestSlim
def test_unicode_tags
source = "Статья года"
result = "<Статья>года</Статья>"
assert_html result, source
end
def test_unicode_attrs
source = "Статья года=123 content"
result = "<Статья года=\"123\">content</Статья>"
assert_html result, so... | ruby | MIT | d387587ae364f489b3e23126e204907a0b134bd3 | 2026-01-04T15:43:07.251246Z | false |
slim-template/slim | https://github.com/slim-template/slim/blob/d387587ae364f489b3e23126e204907a0b134bd3/test/core/test_embedded_engines.rb | test/core/test_embedded_engines.rb | require 'helper'
require 'erb'
class TestSlimEmbeddedEngines < TestSlim
def test_render_with_markdown
source = %q{
markdown:
#Header
Hello from #{"Markdown!"}
#{1+2}
[#{1}](#{"#2"})
* one
* two
}
if ::Tilt['md'].name =~ /Redcarpet/
# redcarpet
assert_html "<h1>Header</h1>\n\n<p>He... | ruby | MIT | d387587ae364f489b3e23126e204907a0b134bd3 | 2026-01-04T15:43:07.251246Z | false |
slim-template/slim | https://github.com/slim-template/slim/blob/d387587ae364f489b3e23126e204907a0b134bd3/test/core/test_code_escaping.rb | test/core/test_code_escaping.rb | require 'helper'
class TestSlimCodeEscaping < TestSlim
def test_escaping_evil_method
source = %q{
p = evil_method
}
assert_html '<p><script>do_something_evil();</script></p>', source
end
def test_render_without_html_safe
source = %q{
p = "<strong>Hello World\\n, meet \\"Slim\\"</strong>... | ruby | MIT | d387587ae364f489b3e23126e204907a0b134bd3 | 2026-01-04T15:43:07.251246Z | false |
slim-template/slim | https://github.com/slim-template/slim/blob/d387587ae364f489b3e23126e204907a0b134bd3/test/core/test_html_escaping.rb | test/core/test_html_escaping.rb | require 'helper'
class TestSlimHtmlEscaping < TestSlim
def test_html_will_not_be_escaped
source = %q{
p <Hello> World, meet "Slim".
}
assert_html '<p><Hello> World, meet "Slim".</p>', source
end
def test_html_with_newline_will_not_be_escaped
source = %q{
p
|
<Hello> World,
meet "Slim".
}... | ruby | MIT | d387587ae364f489b3e23126e204907a0b134bd3 | 2026-01-04T15:43:07.251246Z | false |
slim-template/slim | https://github.com/slim-template/slim/blob/d387587ae364f489b3e23126e204907a0b134bd3/test/core/test_encoding.rb | test/core/test_encoding.rb | require 'helper'
class TestSlimEncoding < TestSlim
def test_windows_crlf
source = "a href='#' something\r\nbr\r\na href='#' others\r\n"
result = "<a href=\"#\">something</a><br /><a href=\"#\">others</a>"
assert_html result, source
end
def test_binary
source = "| \xFF\xFF".dup
source.force_e... | ruby | MIT | d387587ae364f489b3e23126e204907a0b134bd3 | 2026-01-04T15:43:07.251246Z | false |
slim-template/slim | https://github.com/slim-template/slim/blob/d387587ae364f489b3e23126e204907a0b134bd3/test/logic_less/test_logic_less.rb | test/logic_less/test_logic_less.rb | require 'helper'
require 'slim/logic_less'
class TestSlimLogicLess < TestSlim
class Scope
def initialize
@hash = {
person: [
{ name: 'Joe', age: 1, selected: true },
{ name: 'Jack', age: 2 }
]
}
end
end
def test_lambda
so... | ruby | MIT | d387587ae364f489b3e23126e204907a0b134bd3 | 2026-01-04T15:43:07.251246Z | false |
slim-template/slim | https://github.com/slim-template/slim/blob/d387587ae364f489b3e23126e204907a0b134bd3/lib/slim.rb | lib/slim.rb | # frozen_string_literal: true
require 'temple'
require 'slim/parser'
require 'slim/filter'
require 'slim/do_inserter'
require 'slim/end_inserter'
require 'slim/embedded'
require 'slim/interpolation'
require 'slim/controls'
require 'slim/splat/filter'
require 'slim/splat/builder'
require 'slim/code_attributes'
require '... | ruby | MIT | d387587ae364f489b3e23126e204907a0b134bd3 | 2026-01-04T15:43:07.251246Z | false |
slim-template/slim | https://github.com/slim-template/slim/blob/d387587ae364f489b3e23126e204907a0b134bd3/lib/slim/command.rb | lib/slim/command.rb | # frozen_string_literal: true
require 'slim'
require 'optparse'
module Slim
Engine.set_options pretty: false
# Slim commandline interface
# @api private
class Command
def initialize(args)
@args = args
@options = {}
end
# Run command
def run
@opts = OptionParser.new(&method(:... | ruby | MIT | d387587ae364f489b3e23126e204907a0b134bd3 | 2026-01-04T15:43:07.251246Z | false |
slim-template/slim | https://github.com/slim-template/slim/blob/d387587ae364f489b3e23126e204907a0b134bd3/lib/slim/embedded.rb | lib/slim/embedded.rb | # frozen_string_literal: true
module Slim
# @api private
class TextCollector < Filter
def call(exp)
@collected = ''.dup
super(exp)
@collected
end
def on_slim_interpolate(text)
@collected << text
nil
end
end
# @api private
class NewlineCollector < Filter
def ... | ruby | MIT | d387587ae364f489b3e23126e204907a0b134bd3 | 2026-01-04T15:43:07.251246Z | false |
slim-template/slim | https://github.com/slim-template/slim/blob/d387587ae364f489b3e23126e204907a0b134bd3/lib/slim/interpolation.rb | lib/slim/interpolation.rb | # frozen_string_literal: true
module Slim
# Perform interpolation of #{var_name} in the
# expressions `[:slim, :interpolate, string]`.
#
# @api private
class Interpolation < Filter
# Handle interpolate expression `[:slim, :interpolate, string]`
#
# @param [String] string Static interpolate
# @... | ruby | MIT | d387587ae364f489b3e23126e204907a0b134bd3 | 2026-01-04T15:43:07.251246Z | false |
slim-template/slim | https://github.com/slim-template/slim/blob/d387587ae364f489b3e23126e204907a0b134bd3/lib/slim/version.rb | lib/slim/version.rb | # frozen_string_literal: true
module Slim
# Slim version string
# @api public
VERSION = '5.2.1'
end
| ruby | MIT | d387587ae364f489b3e23126e204907a0b134bd3 | 2026-01-04T15:43:07.251246Z | false |
slim-template/slim | https://github.com/slim-template/slim/blob/d387587ae364f489b3e23126e204907a0b134bd3/lib/slim/include.rb | lib/slim/include.rb | # frozen_string_literal: true
require 'slim'
module Slim
# Handles inlined includes
#
# Slim files are compiled, non-Slim files are included as text with `#{interpolation}`
#
# @api private
class Include < Slim::Filter
define_options :file, include_dirs: [Dir.pwd, '.']
def on_html_tag(tag, attribu... | ruby | MIT | d387587ae364f489b3e23126e204907a0b134bd3 | 2026-01-04T15:43:07.251246Z | false |
slim-template/slim | https://github.com/slim-template/slim/blob/d387587ae364f489b3e23126e204907a0b134bd3/lib/slim/end_inserter.rb | lib/slim/end_inserter.rb | # frozen_string_literal: true
module Slim
# In Slim you don't need to close any blocks:
#
# - if Slim.awesome?
# | But of course it is!
#
# However, the parser is not smart enough (and that's a good thing) to
# automatically insert end's where they are needed. Luckily, this filter
# does *exactly*... | ruby | MIT | d387587ae364f489b3e23126e204907a0b134bd3 | 2026-01-04T15:43:07.251246Z | false |
slim-template/slim | https://github.com/slim-template/slim/blob/d387587ae364f489b3e23126e204907a0b134bd3/lib/slim/grammar.rb | lib/slim/grammar.rb | # frozen_string_literal: true
module Slim
# Slim expression grammar
# @api private
module Grammar
extend Temple::Grammar
TextTypes << :verbatim | :explicit | :implicit | :inline
Expression <<
[:slim, :control, String, Expression] |
[:slim, :output, Bool, String, Expressio... | ruby | MIT | d387587ae364f489b3e23126e204907a0b134bd3 | 2026-01-04T15:43:07.251246Z | false |
slim-template/slim | https://github.com/slim-template/slim/blob/d387587ae364f489b3e23126e204907a0b134bd3/lib/slim/filter.rb | lib/slim/filter.rb | # frozen_string_literal: true
module Slim
# Base class for Temple filters used in Slim
#
# This base filter passes everything through and allows
# to override only some methods without affecting the rest
# of the expression.
#
# @api private
class Filter < Temple::HTML::Filter
# Pass-through handler... | ruby | MIT | d387587ae364f489b3e23126e204907a0b134bd3 | 2026-01-04T15:43:07.251246Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.