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 |
|---|---|---|---|---|---|---|---|---|
haml/haml | https://github.com/haml/haml/blob/2417298e12318b699481abf62257259dbc28aa0f/test/haml/engine/text_test.rb | test/haml/engine/text_test.rb | # frozen_string_literal: true
describe Haml::Engine do
include RenderHelper
describe 'text' do
it 'renders string interpolation' do
skip 'escape is not working well in truffleruby' if RUBY_ENGINE == 'truffleruby'
assert_render(<<-HTML.unindent, <<-'HAML'.unindent)
a3aa" ["1", 2] ... | ruby | MIT | 2417298e12318b699481abf62257259dbc28aa0f | 2026-01-04T15:48:11.318331Z | false |
haml/haml | https://github.com/haml/haml/blob/2417298e12318b699481abf62257259dbc28aa0f/test/haml/engine/multiline_test.rb | test/haml/engine/multiline_test.rb | # frozen_string_literal: true
describe Haml::Engine do
include RenderHelper
describe 'multiline' do
it 'joins multi-lines ending with pipe' do
assert_render(<<-HTML.unindent, <<-HAML.unindent)
a b
HTML
a |
b |
HAML
end
it 'renders multi lines' do
ass... | ruby | MIT | 2417298e12318b699481abf62257259dbc28aa0f | 2026-01-04T15:48:11.318331Z | false |
haml/haml | https://github.com/haml/haml/blob/2417298e12318b699481abf62257259dbc28aa0f/test/haml/engine/new_attribute_test.rb | test/haml/engine/new_attribute_test.rb | # frozen_string_literal: true
describe Haml::Engine do
include RenderHelper
describe 'new attributes' do
it 'renders attributes' do
assert_render(<<-HTML.unindent, <<-HAML.unindent)
<p class="foo">bar</p>
HTML
%p(class='foo') bar
HAML
end
it 'renders multiple attribu... | ruby | MIT | 2417298e12318b699481abf62257259dbc28aa0f | 2026-01-04T15:48:11.318331Z | false |
haml/haml | https://github.com/haml/haml/blob/2417298e12318b699481abf62257259dbc28aa0f/lib/haml.rb | lib/haml.rb | # frozen_string_literal: true
require 'haml/engine'
require 'haml/error'
require 'haml/version'
require 'haml/template'
if File.basename($0) != 'haml'
begin
require 'rails'
require 'haml/railtie'
rescue LoadError
end
end
| ruby | MIT | 2417298e12318b699481abf62257259dbc28aa0f | 2026-01-04T15:48:11.318331Z | false |
haml/haml | https://github.com/haml/haml/blob/2417298e12318b699481abf62257259dbc28aa0f/lib/haml/escape_any.rb | lib/haml/escape_any.rb | # frozen_string_literal: true
require 'haml/escape'
module Haml
# This module allows Temple::Filter to dispatch :fescape on `#compile`.
module EscapeanyDispathcer
def on_escapeany(flag, exp)
[:escapeany, flag, compile(exp)]
end
end
::Temple::Filter.include EscapeanyDispathcer
# Unlike Haml::Es... | ruby | MIT | 2417298e12318b699481abf62257259dbc28aa0f | 2026-01-04T15:48:11.318331Z | false |
haml/haml | https://github.com/haml/haml/blob/2417298e12318b699481abf62257259dbc28aa0f/lib/haml/force_escape.rb | lib/haml/force_escape.rb | # frozen_string_literal: true
require 'haml/escape'
module Haml
# This module allows Temple::Filter to dispatch :fescape on `#compile`.
module FescapeDispathcer
def on_fescape(flag, exp)
[:fescape, flag, compile(exp)]
end
end
::Temple::Filter.include FescapeDispathcer
# Unlike Haml::Escape, th... | ruby | MIT | 2417298e12318b699481abf62257259dbc28aa0f | 2026-01-04T15:48:11.318331Z | false |
haml/haml | https://github.com/haml/haml/blob/2417298e12318b699481abf62257259dbc28aa0f/lib/haml/temple_line_counter.rb | lib/haml/temple_line_counter.rb | # frozen_string_literal: true
module Haml
# A module to count lines of expected code. This would be faster than actual code generation
# and counting newlines in it.
module TempleLineCounter
class UnexpectedExpression < StandardError; end
def self.count_lines(exp)
type, *args = exp
case type
... | ruby | MIT | 2417298e12318b699481abf62257259dbc28aa0f | 2026-01-04T15:48:11.318331Z | false |
haml/haml | https://github.com/haml/haml/blob/2417298e12318b699481abf62257259dbc28aa0f/lib/haml/version.rb | lib/haml/version.rb | # frozen_string_literal: true
module Haml
VERSION = '7.1.0'
end
| ruby | MIT | 2417298e12318b699481abf62257259dbc28aa0f | 2026-01-04T15:48:11.318331Z | false |
haml/haml | https://github.com/haml/haml/blob/2417298e12318b699481abf62257259dbc28aa0f/lib/haml/compiler.rb | lib/haml/compiler.rb | # frozen_string_literal: true
require 'haml/compiler/children_compiler'
require 'haml/compiler/comment_compiler'
require 'haml/compiler/doctype_compiler'
require 'haml/compiler/script_compiler'
require 'haml/compiler/silent_script_compiler'
require 'haml/compiler/tag_compiler'
require 'haml/filters'
require 'haml/ident... | ruby | MIT | 2417298e12318b699481abf62257259dbc28aa0f | 2026-01-04T15:48:11.318331Z | false |
haml/haml | https://github.com/haml/haml/blob/2417298e12318b699481abf62257259dbc28aa0f/lib/haml/identity.rb | lib/haml/identity.rb | # frozen_string_literal: true
module Haml
class Identity
def initialize
@unique_id = 0
end
def generate
@unique_id += 1
"_haml_compiler#{@unique_id}"
end
end
end
| ruby | MIT | 2417298e12318b699481abf62257259dbc28aa0f | 2026-01-04T15:48:11.318331Z | false |
haml/haml | https://github.com/haml/haml/blob/2417298e12318b699481abf62257259dbc28aa0f/lib/haml/whitespace.rb | lib/haml/whitespace.rb | # frozen_string_literal: true
module Haml
class Whitespace < Temple::Filter
def on_whitespace
[:static, "\n"]
end
end
end
| ruby | MIT | 2417298e12318b699481abf62257259dbc28aa0f | 2026-01-04T15:48:11.318331Z | false |
haml/haml | https://github.com/haml/haml/blob/2417298e12318b699481abf62257259dbc28aa0f/lib/haml/string_splitter.rb | lib/haml/string_splitter.rb | # frozen_string_literal: true
begin
require 'ripper'
rescue LoadError
end
module Haml
# Compile [:dynamic, "foo#{bar}"] to [:multi, [:static, 'foo'], [:dynamic, 'bar']]
class StringSplitter < Temple::Filter
if defined?(Ripper) && Ripper.respond_to?(:lex)
class << self
# `code` param must be val... | ruby | MIT | 2417298e12318b699481abf62257259dbc28aa0f | 2026-01-04T15:48:11.318331Z | false |
haml/haml | https://github.com/haml/haml/blob/2417298e12318b699481abf62257259dbc28aa0f/lib/haml/attribute_compiler.rb | lib/haml/attribute_compiler.rb | # frozen_string_literal: true
require 'haml/attribute_builder'
require 'haml/attribute_parser'
require 'haml/ruby_expression'
module Haml
# The list of boolean attributes. You may add custom attributes to this constant.
BOOLEAN_ATTRIBUTES = %w[disabled readonly multiple checked autobuffer
au... | ruby | MIT | 2417298e12318b699481abf62257259dbc28aa0f | 2026-01-04T15:48:11.318331Z | false |
haml/haml | https://github.com/haml/haml/blob/2417298e12318b699481abf62257259dbc28aa0f/lib/haml/parser.rb | lib/haml/parser.rb | # frozen_string_literal: true
require 'ripper'
require 'strscan'
require 'haml/error'
require 'haml/util'
module Haml
class Parser
include Haml::Util
attr_reader :root
# Designates an XHTML/XML element.
ELEMENT = ?%
# Designates a `<div>` element with the given class.
DIV_CLASS ... | ruby | MIT | 2417298e12318b699481abf62257259dbc28aa0f | 2026-01-04T15:48:11.318331Z | true |
haml/haml | https://github.com/haml/haml/blob/2417298e12318b699481abf62257259dbc28aa0f/lib/haml/ambles.rb | lib/haml/ambles.rb | # frozen_string_literal: true
module Haml
class Ambles < Temple::Filter
define_options :preamble, :postamble
def initialize(*)
super
@preamble = options[:preamble]
@postamble = options[:postamble]
end
def call(ast)
ret = [:multi]
ret << [:static, @preamble] if @preamble... | ruby | MIT | 2417298e12318b699481abf62257259dbc28aa0f | 2026-01-04T15:48:11.318331Z | false |
haml/haml | https://github.com/haml/haml/blob/2417298e12318b699481abf62257259dbc28aa0f/lib/haml/helpers.rb | lib/haml/helpers.rb | # frozen_string_literal: true
module Haml
module Helpers
def self.preserve(input)
s = input.to_s.chomp("\n")
s.gsub!(/\n/, '
')
s.delete!("\r")
s
end
def preserve(input)
Helpers.preserve(input)
end
end
end
| ruby | MIT | 2417298e12318b699481abf62257259dbc28aa0f | 2026-01-04T15:48:11.318331Z | false |
haml/haml | https://github.com/haml/haml/blob/2417298e12318b699481abf62257259dbc28aa0f/lib/haml/railtie.rb | lib/haml/railtie.rb | # frozen_string_literal: true
require 'rails'
module Haml
class Railtie < ::Rails::Railtie
initializer :haml, before: :load_config_initializers do |app|
require 'haml/rails_template'
end
end
end
| ruby | MIT | 2417298e12318b699481abf62257259dbc28aa0f | 2026-01-04T15:48:11.318331Z | false |
haml/haml | https://github.com/haml/haml/blob/2417298e12318b699481abf62257259dbc28aa0f/lib/haml/attribute_builder.rb | lib/haml/attribute_builder.rb | # frozen_string_literal: true
require 'haml/object_ref'
module Haml::AttributeBuilder
class << self
def build(escape_attrs, quote, format, object_ref, *hashes)
hashes << Haml::ObjectRef.parse(object_ref) if object_ref
buf = []
hash = merge_all_attrs(hashes)
keys = hash.keys.sort!
... | ruby | MIT | 2417298e12318b699481abf62257259dbc28aa0f | 2026-01-04T15:48:11.318331Z | false |
haml/haml | https://github.com/haml/haml/blob/2417298e12318b699481abf62257259dbc28aa0f/lib/haml/attribute_parser.rb | lib/haml/attribute_parser.rb | # frozen_string_literal: true
require 'haml/ruby_expression'
module Haml
class AttributeParser
class ParseSkip < StandardError
end
# @return [TrueClass, FalseClass] - return true if AttributeParser.parse can be used.
def self.available?
# TruffleRuby doesn't have Ripper.lex
defined?(Ripp... | ruby | MIT | 2417298e12318b699481abf62257259dbc28aa0f | 2026-01-04T15:48:11.318331Z | false |
haml/haml | https://github.com/haml/haml/blob/2417298e12318b699481abf62257259dbc28aa0f/lib/haml/escape.rb | lib/haml/escape.rb | # frozen_string_literal: true
require 'haml/util'
module Haml
class Escape < Temple::Filters::Escapable
def initialize(opts = {})
super
@escape_code = options[:escape_code] ||
"::Haml::Util.escape_html#{options[:use_html_safe] ? '_safe' : ''}((%s))"
@escaper = eval("proc {|v| #{@escape_... | ruby | MIT | 2417298e12318b699481abf62257259dbc28aa0f | 2026-01-04T15:48:11.318331Z | false |
haml/haml | https://github.com/haml/haml/blob/2417298e12318b699481abf62257259dbc28aa0f/lib/haml/rails_helpers.rb | lib/haml/rails_helpers.rb | # frozen_string_literal: false
require 'haml/helpers'
# There are only helpers that depend on ActionView internals.
module Haml
module RailsHelpers
include Helpers
extend self
DEFAULT_PRESERVE_TAGS = %w[textarea pre code].freeze
def find_and_preserve(input = nil, tags = DEFAULT_PRESERVE_TAGS, &bloc... | ruby | MIT | 2417298e12318b699481abf62257259dbc28aa0f | 2026-01-04T15:48:11.318331Z | false |
haml/haml | https://github.com/haml/haml/blob/2417298e12318b699481abf62257259dbc28aa0f/lib/haml/template.rb | lib/haml/template.rb | # frozen_string_literal: false
require 'temple'
require 'haml/engine'
require 'haml/helpers'
module Haml
Template = Temple::Templates::Tilt.create(
Haml::Engine,
register_as: [:haml, :haml],
)
module TemplateExtension
# Activate Haml::Helpers for tilt templates.
# https://github.com/judofyr/temp... | ruby | MIT | 2417298e12318b699481abf62257259dbc28aa0f | 2026-01-04T15:48:11.318331Z | false |
haml/haml | https://github.com/haml/haml/blob/2417298e12318b699481abf62257259dbc28aa0f/lib/haml/cli.rb | lib/haml/cli.rb | # frozen_string_literal: true
require 'haml'
require 'thor'
module Haml
class CLI < Thor
class_option :escape_html, type: :boolean, default: true
class_option :escape_attrs, type: :boolean, default: true
desc 'render HAML', 'Render haml template'
option :load_path, type: :string, aliases: %w[-I]
... | ruby | MIT | 2417298e12318b699481abf62257259dbc28aa0f | 2026-01-04T15:48:11.318331Z | false |
haml/haml | https://github.com/haml/haml/blob/2417298e12318b699481abf62257259dbc28aa0f/lib/haml/ruby_expression.rb | lib/haml/ruby_expression.rb | # frozen_string_literal: true
require 'ripper'
module Haml
class RubyExpression < Ripper
class ParseError < StandardError; end
def self.syntax_error?(code)
self.new(code).parse
false
rescue ParseError
true
end
def self.string_literal?(code)
return false if syntax_error?(... | ruby | MIT | 2417298e12318b699481abf62257259dbc28aa0f | 2026-01-04T15:48:11.318331Z | false |
haml/haml | https://github.com/haml/haml/blob/2417298e12318b699481abf62257259dbc28aa0f/lib/haml/filters.rb | lib/haml/filters.rb | # frozen_string_literal: true
require 'haml/filters/base'
require 'haml/filters/text_base'
require 'haml/filters/tilt_base'
require 'haml/filters/coffee'
require 'haml/filters/css'
require 'haml/filters/erb'
require 'haml/filters/escaped'
require 'haml/filters/javascript'
require 'haml/filters/less'
require 'haml/filte... | ruby | MIT | 2417298e12318b699481abf62257259dbc28aa0f | 2026-01-04T15:48:11.318331Z | false |
haml/haml | https://github.com/haml/haml/blob/2417298e12318b699481abf62257259dbc28aa0f/lib/haml/rails_template.rb | lib/haml/rails_template.rb | # frozen_string_literal: true
require 'temple'
require 'haml/engine'
require 'haml/rails_helpers'
require 'haml/util'
module Haml
class RailsTemplate
# Compatible with: https://github.com/judofyr/temple/blob/v0.7.7/lib/temple/mixins/options.rb#L15-L24
class << self
def options
@options ||= {
... | ruby | MIT | 2417298e12318b699481abf62257259dbc28aa0f | 2026-01-04T15:48:11.318331Z | false |
haml/haml | https://github.com/haml/haml/blob/2417298e12318b699481abf62257259dbc28aa0f/lib/haml/engine.rb | lib/haml/engine.rb | # frozen_string_literal: true
require 'temple'
require 'haml/parser'
require 'haml/compiler'
require 'haml/html'
require 'haml/string_splitter'
require 'haml/escape'
require 'haml/escape_any'
require 'haml/force_escape'
require 'haml/dynamic_merger'
require 'haml/ambles'
require 'haml/whitespace'
module Haml
class E... | ruby | MIT | 2417298e12318b699481abf62257259dbc28aa0f | 2026-01-04T15:48:11.318331Z | false |
haml/haml | https://github.com/haml/haml/blob/2417298e12318b699481abf62257259dbc28aa0f/lib/haml/dynamic_merger.rb | lib/haml/dynamic_merger.rb | # frozen_string_literal: true
module Haml
# Compile [:multi, [:static, 'foo'], [:dynamic, 'bar']] to [:dynamic, '"foo#{bar}"']
class DynamicMerger < Temple::Filter
def on_multi(*exps)
exps = exps.dup
result = [:multi]
buffer = []
until exps.empty?
type, arg = exps.first
... | ruby | MIT | 2417298e12318b699481abf62257259dbc28aa0f | 2026-01-04T15:48:11.318331Z | false |
haml/haml | https://github.com/haml/haml/blob/2417298e12318b699481abf62257259dbc28aa0f/lib/haml/object_ref.rb | lib/haml/object_ref.rb | # frozen_string_literal: true
module Haml
module ObjectRef
class << self
def parse(args)
object, prefix = args
return {} unless object
suffix =
if object.respond_to?(:haml_object_ref)
object.haml_object_ref
else
underscore(object.class)
... | ruby | MIT | 2417298e12318b699481abf62257259dbc28aa0f | 2026-01-04T15:48:11.318331Z | false |
haml/haml | https://github.com/haml/haml/blob/2417298e12318b699481abf62257259dbc28aa0f/lib/haml/error.rb | lib/haml/error.rb | # frozen_string_literal: true
module Haml
class Error < StandardError
MESSAGES = {
bad_script_indent: '"%s" is indented at wrong level: expected %d, but was at %d.',
cant_run_filter: 'Can\'t run "%s" filter; you must require its dependencies first',
cant_use_tabs_and_spac... | ruby | MIT | 2417298e12318b699481abf62257259dbc28aa0f | 2026-01-04T15:48:11.318331Z | false |
haml/haml | https://github.com/haml/haml/blob/2417298e12318b699481abf62257259dbc28aa0f/lib/haml/util.rb | lib/haml/util.rb | # frozen_string_literal: true
begin
require 'erubis/tiny'
rescue LoadError
require 'erb'
end
require 'set'
require 'stringio'
require 'strscan'
module Haml
# A module containing various useful functions.
module Util
extend self
begin # Ruby 3.2+ or ERB 4+
require 'erb/escape'
define_sing... | ruby | MIT | 2417298e12318b699481abf62257259dbc28aa0f | 2026-01-04T15:48:11.318331Z | false |
haml/haml | https://github.com/haml/haml/blob/2417298e12318b699481abf62257259dbc28aa0f/lib/haml/html.rb | lib/haml/html.rb | # frozen_string_literal: true
module Haml
class HTML < Temple::HTML::Fast
DEPRECATED_FORMATS = %i[html4 html5].freeze
def initialize(opts = {})
if DEPRECATED_FORMATS.include?(opts[:format])
opts = opts.dup
opts[:format] = :html
end
super(opts)
end
# This dispatcher ... | ruby | MIT | 2417298e12318b699481abf62257259dbc28aa0f | 2026-01-04T15:48:11.318331Z | false |
haml/haml | https://github.com/haml/haml/blob/2417298e12318b699481abf62257259dbc28aa0f/lib/haml/filters/preserve.rb | lib/haml/filters/preserve.rb | # frozen_string_literal: true
module Haml
class Filters
class Preserve < Base
def compile(node)
text = node.value[:text].rstrip + "\n"
text = text.gsub("\n", '
')
compile_text(text)
end
private
def compile_text(text)
if ::Haml::Util.contains_interpo... | ruby | MIT | 2417298e12318b699481abf62257259dbc28aa0f | 2026-01-04T15:48:11.318331Z | false |
haml/haml | https://github.com/haml/haml/blob/2417298e12318b699481abf62257259dbc28aa0f/lib/haml/filters/tilt_base.rb | lib/haml/filters/tilt_base.rb | # frozen_string_literal: true
require 'tilt'
module Haml
class Filters
class TiltBase < Base
def self.render(name, source, indent_width: 0)
text = ::Tilt["t.#{name}"].new { source }.render
return text if indent_width == 0
if text.frozen?
text.gsub(/^/, ' ' * indent_width)
... | ruby | MIT | 2417298e12318b699481abf62257259dbc28aa0f | 2026-01-04T15:48:11.318331Z | false |
haml/haml | https://github.com/haml/haml/blob/2417298e12318b699481abf62257259dbc28aa0f/lib/haml/filters/plain.rb | lib/haml/filters/plain.rb | # frozen_string_literal: true
require 'haml/string_splitter'
module Haml
class Filters
class Plain < Base
def compile(node)
text = node.value[:text]
text = text.rstrip unless ::Haml::Util.contains_interpolation?(text) # for compatibility
[:multi, [:newline], *compile_plain(text)]
... | ruby | MIT | 2417298e12318b699481abf62257259dbc28aa0f | 2026-01-04T15:48:11.318331Z | false |
haml/haml | https://github.com/haml/haml/blob/2417298e12318b699481abf62257259dbc28aa0f/lib/haml/filters/css.rb | lib/haml/filters/css.rb | # frozen_string_literal: true
module Haml
class Filters
class Css < TextBase
def compile(node)
case @format
when :xhtml
compile_xhtml(node)
else
compile_html(node)
end
end
private
def compile_html(node)
temple = [:multi]
... | ruby | MIT | 2417298e12318b699481abf62257259dbc28aa0f | 2026-01-04T15:48:11.318331Z | false |
haml/haml | https://github.com/haml/haml/blob/2417298e12318b699481abf62257259dbc28aa0f/lib/haml/filters/sass.rb | lib/haml/filters/sass.rb | # frozen_string_literal: true
module Haml
class Filters
class Sass < TiltBase
def compile(node)
require 'tilt/sass' if explicit_require?('sass')
temple = [:multi]
temple << [:static, "<style>\n"]
temple << compile_with_tilt(node, 'sass', indent_width: 2)
temple << [:s... | ruby | MIT | 2417298e12318b699481abf62257259dbc28aa0f | 2026-01-04T15:48:11.318331Z | false |
haml/haml | https://github.com/haml/haml/blob/2417298e12318b699481abf62257259dbc28aa0f/lib/haml/filters/cdata.rb | lib/haml/filters/cdata.rb | # frozen_string_literal: true
module Haml
class Filters
class Cdata < TextBase
def compile(node)
compile_cdata(node)
end
private
def compile_cdata(node)
temple = [:multi]
temple << [:static, "<![CDATA[\n"]
compile_text!(temple, node, ' ')
temple... | ruby | MIT | 2417298e12318b699481abf62257259dbc28aa0f | 2026-01-04T15:48:11.318331Z | false |
haml/haml | https://github.com/haml/haml/blob/2417298e12318b699481abf62257259dbc28aa0f/lib/haml/filters/less.rb | lib/haml/filters/less.rb | # frozen_string_literal: true
# LESS support is deprecated since it requires therubyracer.gem,
# which is hard to maintain.
#
# It's not supported in Sprockets 3.0+ too.
# https://github.com/sstephenson/sprockets/pull/547
module Haml
class Filters
class Less < TiltBase
def compile(node)
require 'til... | ruby | MIT | 2417298e12318b699481abf62257259dbc28aa0f | 2026-01-04T15:48:11.318331Z | false |
haml/haml | https://github.com/haml/haml/blob/2417298e12318b699481abf62257259dbc28aa0f/lib/haml/filters/base.rb | lib/haml/filters/base.rb | # frozen_string_literal: true
require 'haml/util'
module Haml
class Filters
class Base
def initialize(options = {})
@format = options[:format]
end
end
end
end
| ruby | MIT | 2417298e12318b699481abf62257259dbc28aa0f | 2026-01-04T15:48:11.318331Z | false |
haml/haml | https://github.com/haml/haml/blob/2417298e12318b699481abf62257259dbc28aa0f/lib/haml/filters/markdown.rb | lib/haml/filters/markdown.rb | # frozen_string_literal: true
module Haml
class Filters
class Markdown < TiltBase
def compile(node)
require 'tilt/redcarpet' if explicit_require?('markdown')
compile_with_tilt(node, 'markdown')
end
end
end
end
| ruby | MIT | 2417298e12318b699481abf62257259dbc28aa0f | 2026-01-04T15:48:11.318331Z | false |
haml/haml | https://github.com/haml/haml/blob/2417298e12318b699481abf62257259dbc28aa0f/lib/haml/filters/coffee.rb | lib/haml/filters/coffee.rb | # frozen_string_literal: true
module Haml
class Filters
class Coffee < TiltBase
def compile(node)
require 'tilt/coffee' if explicit_require?('coffee')
temple = [:multi]
temple << [:static, "<script>\n"]
temple << compile_with_tilt(node, 'coffee', indent_width: 2)
temp... | ruby | MIT | 2417298e12318b699481abf62257259dbc28aa0f | 2026-01-04T15:48:11.318331Z | false |
haml/haml | https://github.com/haml/haml/blob/2417298e12318b699481abf62257259dbc28aa0f/lib/haml/filters/escaped.rb | lib/haml/filters/escaped.rb | # frozen_string_literal: true
module Haml
class Filters
class Escaped < Base
def compile(node)
text = node.value[:text].rstrip
temple = compile_text(text)
[:escape, true, temple]
end
private
def compile_text(text)
if ::Haml::Util.contains_interpolation?(te... | ruby | MIT | 2417298e12318b699481abf62257259dbc28aa0f | 2026-01-04T15:48:11.318331Z | false |
haml/haml | https://github.com/haml/haml/blob/2417298e12318b699481abf62257259dbc28aa0f/lib/haml/filters/erb.rb | lib/haml/filters/erb.rb | # frozen_string_literal: true
module Haml
class Filters
class Erb < TiltBase
def compile(node)
precompiled_with_tilt(node, 'erb')
end
end
end
end
| ruby | MIT | 2417298e12318b699481abf62257259dbc28aa0f | 2026-01-04T15:48:11.318331Z | false |
haml/haml | https://github.com/haml/haml/blob/2417298e12318b699481abf62257259dbc28aa0f/lib/haml/filters/scss.rb | lib/haml/filters/scss.rb | # frozen_string_literal: true
module Haml
class Filters
class Scss < TiltBase
def compile(node)
require 'tilt/sass' if explicit_require?('scss')
temple = [:multi]
temple << [:static, "<style>\n"]
temple << compile_with_tilt(node, 'scss', indent_width: 2)
temple << [:s... | ruby | MIT | 2417298e12318b699481abf62257259dbc28aa0f | 2026-01-04T15:48:11.318331Z | false |
haml/haml | https://github.com/haml/haml/blob/2417298e12318b699481abf62257259dbc28aa0f/lib/haml/filters/javascript.rb | lib/haml/filters/javascript.rb | # frozen_string_literal: true
module Haml
class Filters
class Javascript < TextBase
def compile(node)
case @format
when :xhtml
compile_xhtml(node)
else
compile_html(node)
end
end
private
def compile_html(node)
temple = [:multi]
... | ruby | MIT | 2417298e12318b699481abf62257259dbc28aa0f | 2026-01-04T15:48:11.318331Z | false |
haml/haml | https://github.com/haml/haml/blob/2417298e12318b699481abf62257259dbc28aa0f/lib/haml/filters/ruby.rb | lib/haml/filters/ruby.rb | # frozen_string_literal: true
module Haml
class Filters
class Ruby < Base
def compile(node)
[:multi, [:newline], [:code, node.value[:text]]]
end
end
end
end
| ruby | MIT | 2417298e12318b699481abf62257259dbc28aa0f | 2026-01-04T15:48:11.318331Z | false |
haml/haml | https://github.com/haml/haml/blob/2417298e12318b699481abf62257259dbc28aa0f/lib/haml/filters/text_base.rb | lib/haml/filters/text_base.rb | # frozen_string_literal: true
module Haml
class Filters
class TextBase < Base
def compile_text!(temple, node, prefix)
text = node.value[:text].rstrip.gsub(/^/, prefix)
if ::Haml::Util.contains_interpolation?(node.value[:text])
# original: Haml::Filters#compile
text = ::Ha... | ruby | MIT | 2417298e12318b699481abf62257259dbc28aa0f | 2026-01-04T15:48:11.318331Z | false |
haml/haml | https://github.com/haml/haml/blob/2417298e12318b699481abf62257259dbc28aa0f/lib/haml/compiler/tag_compiler.rb | lib/haml/compiler/tag_compiler.rb | # frozen_string_literal: true
require 'haml/util'
require 'haml/attribute_compiler'
require 'haml/string_splitter'
module Haml
class Compiler
class TagCompiler
def initialize(identity, options)
@autoclose = options[:autoclose]
@identity = identity
@attribute_compiler = AttributeCom... | ruby | MIT | 2417298e12318b699481abf62257259dbc28aa0f | 2026-01-04T15:48:11.318331Z | false |
haml/haml | https://github.com/haml/haml/blob/2417298e12318b699481abf62257259dbc28aa0f/lib/haml/compiler/doctype_compiler.rb | lib/haml/compiler/doctype_compiler.rb | # frozen_string_literal: true
module Haml
class Compiler
class DoctypeCompiler
def initialize(options = {})
@format = options[:format]
end
def compile(node)
case node.value[:type]
when ''
html_doctype(node)
when 'xml'
xml_doctype
when ... | ruby | MIT | 2417298e12318b699481abf62257259dbc28aa0f | 2026-01-04T15:48:11.318331Z | false |
haml/haml | https://github.com/haml/haml/blob/2417298e12318b699481abf62257259dbc28aa0f/lib/haml/compiler/children_compiler.rb | lib/haml/compiler/children_compiler.rb | # frozen_string_literal: true
require 'haml/temple_line_counter'
module Haml
class Compiler
class ChildrenCompiler
def initialize
@lineno = 1
@multi_flattener = Temple::Filters::MultiFlattener.new
end
def compile(node, &block)
temple = [:multi]
return temple if ... | ruby | MIT | 2417298e12318b699481abf62257259dbc28aa0f | 2026-01-04T15:48:11.318331Z | false |
haml/haml | https://github.com/haml/haml/blob/2417298e12318b699481abf62257259dbc28aa0f/lib/haml/compiler/script_compiler.rb | lib/haml/compiler/script_compiler.rb | # frozen_string_literal: true
require 'temple/static_analyzer'
require 'haml/ruby_expression'
require 'haml/string_splitter'
module Haml
class Compiler
class ScriptCompiler
def self.find_and_preserve(input, tags)
tags = tags.map { |tag| Regexp.escape(tag) }.join('|')
re = /<(#{tags})([^>]*)... | ruby | MIT | 2417298e12318b699481abf62257259dbc28aa0f | 2026-01-04T15:48:11.318331Z | false |
haml/haml | https://github.com/haml/haml/blob/2417298e12318b699481abf62257259dbc28aa0f/lib/haml/compiler/comment_compiler.rb | lib/haml/compiler/comment_compiler.rb | # frozen_string_literal: true
module Haml
class Compiler
class CommentCompiler
def compile(node, &block)
if node.value[:conditional]
compile_conditional_comment(node, &block)
else
compile_html_comment(node, &block)
end
end
private
def compile_h... | ruby | MIT | 2417298e12318b699481abf62257259dbc28aa0f | 2026-01-04T15:48:11.318331Z | false |
haml/haml | https://github.com/haml/haml/blob/2417298e12318b699481abf62257259dbc28aa0f/lib/haml/compiler/silent_script_compiler.rb | lib/haml/compiler/silent_script_compiler.rb | # frozen_string_literal: true
module Haml
class Compiler
class SilentScriptCompiler
def compile(node, &block)
if node.children.empty?
[:multi, [:code, node.value[:text]], [:newline]]
else
compile_with_children(node, &block)
end
end
private
def ... | ruby | MIT | 2417298e12318b699481abf62257259dbc28aa0f | 2026-01-04T15:48:11.318331Z | false |
defunkt/gist | https://github.com/defunkt/gist/blob/232b69cad8a3931fda8319ac50158afa027a6e00/vendor/json.rb | vendor/json.rb | require 'strscan'
module JSON
module Pure
# This class implements the JSON parser that is used to parse a JSON string
# into a Ruby data structure.
class Parser < StringScanner
STRING = /" ((?:[^\x0-\x1f"\\] |
# escaped special characters:
... | ruby | MIT | 232b69cad8a3931fda8319ac50158afa027a6e00 | 2026-01-04T15:48:44.514047Z | true |
defunkt/gist | https://github.com/defunkt/gist/blob/232b69cad8a3931fda8319ac50158afa027a6e00/spec/shorten_spec.rb | spec/shorten_spec.rb | describe '...' do
before do
stub_request(:post, /api\.github.com\/gists/).to_return(:body => '{"html_url": "http://github.com/"}')
end
it "should return a shortened version of the URL when response is 200" do
stub_request(:post, "https://git.io/create").to_return(:status => 200, :body => 'XXXXXX')
Gi... | ruby | MIT | 232b69cad8a3931fda8319ac50158afa027a6e00 | 2026-01-04T15:48:44.514047Z | false |
defunkt/gist | https://github.com/defunkt/gist/blob/232b69cad8a3931fda8319ac50158afa027a6e00/spec/rawify_spec.rb | spec/rawify_spec.rb | describe '...' do
before do
stub_request(:post, /api\.github.com\/gists/).to_return(:body => '{"html_url": "https://gist.github.com/XXXXXX"}')
stub_request(:get, "https://gist.github.com/XXXXXX").to_return(:status => 304, :headers => { 'Location' => 'https://gist.github.com/anonymous/XXXXXX' })
stub_reque... | ruby | MIT | 232b69cad8a3931fda8319ac50158afa027a6e00 | 2026-01-04T15:48:44.514047Z | false |
defunkt/gist | https://github.com/defunkt/gist/blob/232b69cad8a3931fda8319ac50158afa027a6e00/spec/auth_token_file_spec.rb | spec/auth_token_file_spec.rb | describe Gist::AuthTokenFile do
subject { Gist::AuthTokenFile }
before(:each) do
stub_const("Gist::URL_ENV_NAME", "STUBBED_GITHUB_URL")
end
describe "::filename" do
let(:filename) { double() }
context "with default GITHUB_URL" do
it "is ~/.gist" do
File.should_receive(:expand_path).... | ruby | MIT | 232b69cad8a3931fda8319ac50158afa027a6e00 | 2026-01-04T15:48:44.514047Z | false |
defunkt/gist | https://github.com/defunkt/gist/blob/232b69cad8a3931fda8319ac50158afa027a6e00/spec/proxy_spec.rb | spec/proxy_spec.rb | describe '...' do
before do
@saved_env = ENV['HTTP_PROXY']
end
after do
ENV['HTTP_PROXY'] = @saved_env
end
FOO_URL = URI('http://ddg.gg/')
it "should be Net::HTTP when $HTTP_PROXY wasn't set" do
ENV['HTTP_PROXY'] = ''
Gist.http_connection(FOO_URL).should be_an_instance_of(Net::HTTP)
end... | ruby | MIT | 232b69cad8a3931fda8319ac50158afa027a6e00 | 2026-01-04T15:48:44.514047Z | false |
defunkt/gist | https://github.com/defunkt/gist/blob/232b69cad8a3931fda8319ac50158afa027a6e00/spec/clipboard_spec.rb | spec/clipboard_spec.rb | describe '...' do
before do
@saved_path = ENV['PATH']
@bobo_url = 'http://example.com'
end
after do
ENV['PATH'] = @saved_path
end
def ask_for_copy
Gist.on_success({'html_url' => @bobo_url}.to_json, :copy => true, :output => :html_url)
end
def gist_but_dont_ask_for_copy
Gist.on_succes... | ruby | MIT | 232b69cad8a3931fda8319ac50158afa027a6e00 | 2026-01-04T15:48:44.514047Z | false |
defunkt/gist | https://github.com/defunkt/gist/blob/232b69cad8a3931fda8319ac50158afa027a6e00/spec/gist_spec.rb | spec/gist_spec.rb | describe Gist do
describe "should_be_public?" do
it "should return false if -p is specified" do
Gist.should_be_public?(:private => true).should be_falsy
end
it "should return false if legacy_private_gister?" do
Gist.should_receive(:legacy_private_gister?).and_return(true)
Gist.should_b... | ruby | MIT | 232b69cad8a3931fda8319ac50158afa027a6e00 | 2026-01-04T15:48:44.514047Z | false |
defunkt/gist | https://github.com/defunkt/gist/blob/232b69cad8a3931fda8319ac50158afa027a6e00/spec/ghe_spec.rb | spec/ghe_spec.rb | describe '...' do
MOCK_GHE_HOST = 'ghe.example.com'
MOCK_GHE_PROTOCOL = 'http'
MOCK_USER = 'foo'
MOCK_PASSWORD = 'bar'
MOCK_AUTHZ_GHE_URL = "#{MOCK_GHE_PROTOCOL}://#{MOCK_GHE_HOST}/api/v3/"
MOCK_GHE_URL = "#{MOCK_GHE_PROTOCOL}://#{MOCK_GHE_HOST}/api/v3/"
MOCK_GITHUB_URL ... | ruby | MIT | 232b69cad8a3931fda8319ac50158afa027a6e00 | 2026-01-04T15:48:44.514047Z | false |
defunkt/gist | https://github.com/defunkt/gist/blob/232b69cad8a3931fda8319ac50158afa027a6e00/spec/spec_helper.rb | spec/spec_helper.rb | # This file was generated by the `rspec --init` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
# Require this file using `require "spec_helper.rb"` to ensure that it is only
# loaded once.
#
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
RSp... | ruby | MIT | 232b69cad8a3931fda8319ac50158afa027a6e00 | 2026-01-04T15:48:44.514047Z | false |
defunkt/gist | https://github.com/defunkt/gist/blob/232b69cad8a3931fda8319ac50158afa027a6e00/lib/gist.rb | lib/gist.rb | require 'net/https'
require 'cgi'
require 'uri'
begin
require 'json'
rescue LoadError
require File.join File.dirname(File.dirname(__FILE__)), 'vendor', 'json.rb'
end
# It just gists.
module Gist
extend self
VERSION = '6.0.0'
# A list of clipboard commands with copy and paste support.
CLIPBOARD_COMMANDS ... | ruby | MIT | 232b69cad8a3931fda8319ac50158afa027a6e00 | 2026-01-04T15:48:44.514047Z | false |
hahwul/WebHackersWeapons | https://github.com/hahwul/WebHackersWeapons/blob/c1095eccb339ac6b57d6fc39809e183d0472ca66/scripts/validate_weapons.rb | scripts/validate_weapons.rb | require 'yaml'
Dir.entries("./weapons").each do | name |
if name.strip != "." || name != ".."
begin
data = YAML.load(File.open("./weapons/#{name}"))
if data['type'] == "" || data['type'] == nil
puts "./weapons/#{name} :: none-type"
end
if data['lang'] == "" || dat... | ruby | MIT | c1095eccb339ac6b57d6fc39809e183d0472ca66 | 2026-01-04T15:46:18.528786Z | false |
hahwul/WebHackersWeapons | https://github.com/hahwul/WebHackersWeapons/blob/c1095eccb339ac6b57d6fc39809e183d0472ca66/scripts/erb.rb | scripts/erb.rb | require 'erb'
require 'yaml'
def generate_badge array
badge = ""
array.each { |t|
case t
when 'linux'
badge = badge + ""
when 'windows'
badge = badge + ""
when 'macos'
badge = badge + "... | ruby | MIT | c1095eccb339ac6b57d6fc39809e183d0472ca66 | 2026-01-04T15:46:18.528786Z | false |
hahwul/WebHackersWeapons | https://github.com/hahwul/WebHackersWeapons/blob/c1095eccb339ac6b57d6fc39809e183d0472ca66/scripts/for_migration/fetch_lang.rb | scripts/for_migration/fetch_lang.rb | # https://api.github.com/repos/hahwul/dalfox/languages
#
#
require 'yaml'
langs = []
Dir.entries("./weapons").each do | name |
if name.strip != "." || name != ".."
begin
data = YAML.load(File.open("./weapons/#{name}"))
if data['url'].include? "//github.com"
t = data['url'].split(... | ruby | MIT | c1095eccb339ac6b57d6fc39809e183d0472ca66 | 2026-01-04T15:46:18.528786Z | false |
hahwul/WebHackersWeapons | https://github.com/hahwul/WebHackersWeapons/blob/c1095eccb339ac6b57d6fc39809e183d0472ca66/scripts/for_migration/apply_platform.rb | scripts/for_migration/apply_platform.rb | require 'yaml'
Dir.entries("./weapons").each do | name |
if name.strip != "." || name != ".."
begin
data = YAML.load(File.open("./weapons/#{name}"))
data['platform'] = ['linux','macos','windows']
yaml_data = YAML.dump(data)
File.write("./weapons/#{name}", yaml_data)
res... | ruby | MIT | c1095eccb339ac6b57d6fc39809e183d0472ca66 | 2026-01-04T15:46:18.528786Z | false |
hahwul/WebHackersWeapons | https://github.com/hahwul/WebHackersWeapons/blob/c1095eccb339ac6b57d6fc39809e183d0472ca66/scripts/for_migration/migration.rb | scripts/for_migration/migration.rb | require 'json'
require 'yaml'
require "uri"
def get_os install
lst = []
if install['Linux'].length > 1
lst.push 'linux'
end
if install['MacOS'].length > 1
lst.push 'macos'
end
if install['Windows'].length > 1
lst.push 'windows'
end
return lst
end
d... | ruby | MIT | c1095eccb339ac6b57d6fc39809e183d0472ca66 | 2026-01-04T15:46:18.528786Z | false |
fnando/i18n-js | https://github.com/fnando/i18n-js/blob/f8fb0dc0b01e7e639a6eb5dd875adbaa78858d8f/test/test_helper.rb | test/test_helper.rb | # frozen_string_literal: true
ENV["TZ"] = "Etc/UTC"
require "simplecov"
SimpleCov.start do
add_filter(/test/)
end
require "bundler/setup"
require "i18n-js"
require "i18n-js/cli"
require "minitest/utils"
require "minitest/autorun"
Dir["./test/support/**/*.rb"].each do |file|
require file
end
| ruby | MIT | f8fb0dc0b01e7e639a6eb5dd875adbaa78858d8f | 2026-01-04T15:48:46.154368Z | false |
fnando/i18n-js | https://github.com/fnando/i18n-js/blob/f8fb0dc0b01e7e639a6eb5dd875adbaa78858d8f/test/support/helpers.rb | test/support/helpers.rb | # frozen_string_literal: true
def reset_i18n
I18n.available_locales = ["en"]
I18n.locale = "en"
I18n.default_locale = "en"
I18n.load_path = []
I18n.backend = nil
I18n.default_separator = nil
I18n.enforce_available_locales = false
end
| ruby | MIT | f8fb0dc0b01e7e639a6eb5dd875adbaa78858d8f | 2026-01-04T15:48:46.154368Z | false |
fnando/i18n-js | https://github.com/fnando/i18n-js/blob/f8fb0dc0b01e7e639a6eb5dd875adbaa78858d8f/test/support/minitest.rb | test/support/minitest.rb | # frozen_string_literal: true
require "fileutils"
module Minitest
class Test
setup do
reset_i18n
I18nJS.plugins.clear
I18nJS.available_plugins.clear
I18n.config.clear_available_locales_set
I18n.backend = I18n::Backend::Simple.new
I18nJS::Schema.root_keys.delete(:sample)
... | ruby | MIT | f8fb0dc0b01e7e639a6eb5dd875adbaa78858d8f | 2026-01-04T15:48:46.154368Z | false |
fnando/i18n-js | https://github.com/fnando/i18n-js/blob/f8fb0dc0b01e7e639a6eb5dd875adbaa78858d8f/test/support/backends.rb | test/support/backends.rb | # frozen_string_literal: true
class GettextBackend < I18n::Backend::Simple
include I18n::Backend::Gettext
end
| ruby | MIT | f8fb0dc0b01e7e639a6eb5dd875adbaa78858d8f | 2026-01-04T15:48:46.154368Z | false |
fnando/i18n-js | https://github.com/fnando/i18n-js/blob/f8fb0dc0b01e7e639a6eb5dd875adbaa78858d8f/test/i18n-js/embed_fallback_translations_plugin_test.rb | test/i18n-js/embed_fallback_translations_plugin_test.rb | # frozen_string_literal: true
require "test_helper"
class EmbedFallbackTranslationsPluginTest < Minitest::Test
test "embeds fallback translations" do
require "i18n-js/embed_fallback_translations_plugin"
I18nJS.register_plugin(I18nJS::EmbedFallbackTranslationsPlugin)
I18n.load_path << Dir[
"./test... | ruby | MIT | f8fb0dc0b01e7e639a6eb5dd875adbaa78858d8f | 2026-01-04T15:48:46.154368Z | false |
fnando/i18n-js | https://github.com/fnando/i18n-js/blob/f8fb0dc0b01e7e639a6eb5dd875adbaa78858d8f/test/i18n-js/clean_hash_test.rb | test/i18n-js/clean_hash_test.rb | # frozen_string_literal: true
require "test_helper"
class CleanHashTest < Minitest::Test
test "removes non accepted values" do
expected = {b: {d: 4}}
assert_equal expected, I18nJS.clean_hash(a: -> { }, b: {c: -> { }, d: 4})
end
end
| ruby | MIT | f8fb0dc0b01e7e639a6eb5dd875adbaa78858d8f | 2026-01-04T15:48:46.154368Z | false |
fnando/i18n-js | https://github.com/fnando/i18n-js/blob/f8fb0dc0b01e7e639a6eb5dd875adbaa78858d8f/test/i18n-js/plugin_test.rb | test/i18n-js/plugin_test.rb | # frozen_string_literal: true
require "test_helper"
class PluginTest < Minitest::Test
def create_plugin(&block)
Class.new(I18nJS::Plugin) do
def self.name
"SamplePlugin"
end
def self.calls
@calls ||= []
end
class_eval(&block) if block
end
end
test "implem... | ruby | MIT | f8fb0dc0b01e7e639a6eb5dd875adbaa78858d8f | 2026-01-04T15:48:46.154368Z | false |
fnando/i18n-js | https://github.com/fnando/i18n-js/blob/f8fb0dc0b01e7e639a6eb5dd875adbaa78858d8f/test/i18n-js/exporter_test.rb | test/i18n-js/exporter_test.rb | # frozen_string_literal: true
require "test_helper"
class ExporterTest < Minitest::Test
test "fails when neither config_file nor config is set" do
assert_raises(I18nJS::MissingConfigError) do
I18nJS.call(config_file: nil, config: nil)
end
end
test "exports all translations" do
I18n.load_path ... | ruby | MIT | f8fb0dc0b01e7e639a6eb5dd875adbaa78858d8f | 2026-01-04T15:48:46.154368Z | false |
fnando/i18n-js | https://github.com/fnando/i18n-js/blob/f8fb0dc0b01e7e639a6eb5dd875adbaa78858d8f/test/i18n-js/sort_hash_test.rb | test/i18n-js/sort_hash_test.rb | # frozen_string_literal: true
require "test_helper"
class SortHashTest < Minitest::Test
test "returns non-hash objects" do
assert_equal 1, I18nJS.sort_hash(1)
end
test "sorts shallow hash" do
expected = {a: 1, b: 2, c: 3}
assert_equal expected, I18nJS.sort_hash(c: 3, a: 1, b: 2)
end
test "sor... | ruby | MIT | f8fb0dc0b01e7e639a6eb5dd875adbaa78858d8f | 2026-01-04T15:48:46.154368Z | false |
fnando/i18n-js | https://github.com/fnando/i18n-js/blob/f8fb0dc0b01e7e639a6eb5dd875adbaa78858d8f/test/i18n-js/export_files_plugin_test.rb | test/i18n-js/export_files_plugin_test.rb | # frozen_string_literal: true
require "test_helper"
class ExportScriptFilesPluginTest < Minitest::Test
test "exports script files" do
require "i18n-js/export_files_plugin"
I18nJS.plugins.clear
I18nJS.register_plugin(I18nJS::ExportFilesPlugin)
I18n.load_path << Dir["./test/fixtures/yml/*.yml"]
n... | ruby | MIT | f8fb0dc0b01e7e639a6eb5dd875adbaa78858d8f | 2026-01-04T15:48:46.154368Z | false |
fnando/i18n-js | https://github.com/fnando/i18n-js/blob/f8fb0dc0b01e7e639a6eb5dd875adbaa78858d8f/test/i18n-js/schema_test.rb | test/i18n-js/schema_test.rb | # frozen_string_literal: true
require "test_helper"
class SchemaTest < Minitest::Test
test "requires root to be a hash" do
error_message = %[Expected config to be "Hash"; got NilClass instead]
assert_schema_error(error_message) do
I18nJS::Schema.validate!(nil)
end
end
test "accepts valid roo... | ruby | MIT | f8fb0dc0b01e7e639a6eb5dd875adbaa78858d8f | 2026-01-04T15:48:46.154368Z | false |
fnando/i18n-js | https://github.com/fnando/i18n-js/blob/f8fb0dc0b01e7e639a6eb5dd875adbaa78858d8f/test/i18n-js/cli/export_command_test.rb | test/i18n-js/cli/export_command_test.rb | # frozen_string_literal: true
require "test_helper"
class ExportCommandTest < Minitest::Test
let(:stdout) { StringIO.new }
let(:stderr) { StringIO.new }
test "displays help" do
cli = I18nJS::CLI.new(
argv: %w[export --help],
stdout:,
stderr:
)
assert_exit_code(0) { cli.call }
... | ruby | MIT | f8fb0dc0b01e7e639a6eb5dd875adbaa78858d8f | 2026-01-04T15:48:46.154368Z | false |
fnando/i18n-js | https://github.com/fnando/i18n-js/blob/f8fb0dc0b01e7e639a6eb5dd875adbaa78858d8f/test/i18n-js/cli/lint_scripts_command_test.rb | test/i18n-js/cli/lint_scripts_command_test.rb | # frozen_string_literal: true
require "test_helper"
class LintCommandTest < Minitest::Test
let(:stdout) { StringIO.new }
let(:stderr) { StringIO.new }
test "displays help" do
cli = I18nJS::CLI.new(
argv: %w[lint:scripts --help],
stdout:,
stderr:
)
assert_exit_code(0) { cli.call }... | ruby | MIT | f8fb0dc0b01e7e639a6eb5dd875adbaa78858d8f | 2026-01-04T15:48:46.154368Z | false |
fnando/i18n-js | https://github.com/fnando/i18n-js/blob/f8fb0dc0b01e7e639a6eb5dd875adbaa78858d8f/test/i18n-js/cli/root_command_test.rb | test/i18n-js/cli/root_command_test.rb | # frozen_string_literal: true
require "test_helper"
class RootCommandTest < Minitest::Test
let(:stdout) { StringIO.new }
let(:stderr) { StringIO.new }
test "shows help on root" do
cli = I18nJS::CLI.new(argv: [], stdout:, stderr:)
assert_exit_code(1) { cli.call }
assert_includes stderr.tap(&:rewind... | ruby | MIT | f8fb0dc0b01e7e639a6eb5dd875adbaa78858d8f | 2026-01-04T15:48:46.154368Z | false |
fnando/i18n-js | https://github.com/fnando/i18n-js/blob/f8fb0dc0b01e7e639a6eb5dd875adbaa78858d8f/test/i18n-js/cli/lint_translations_command_test.rb | test/i18n-js/cli/lint_translations_command_test.rb | # frozen_string_literal: true
require "test_helper"
class LintTranslationsCommandTest < Minitest::Test
let(:stdout) { StringIO.new }
let(:stderr) { StringIO.new }
test "displays help" do
cli = I18nJS::CLI.new(
argv: %w[lint:translations --help],
stdout:,
stderr:
)
assert_exit_cod... | ruby | MIT | f8fb0dc0b01e7e639a6eb5dd875adbaa78858d8f | 2026-01-04T15:48:46.154368Z | false |
fnando/i18n-js | https://github.com/fnando/i18n-js/blob/f8fb0dc0b01e7e639a6eb5dd875adbaa78858d8f/test/i18n-js/cli/check_command_test.rb | test/i18n-js/cli/check_command_test.rb | # frozen_string_literal: true
require "test_helper"
class CheckCommandTest < Minitest::Test
let(:stdout) { StringIO.new }
let(:stderr) { StringIO.new }
test "displays help" do
cli = I18nJS::CLI.new(
argv: %w[check --help],
stdout:,
stderr:
)
assert_exit_code(0) { cli.call }
a... | ruby | MIT | f8fb0dc0b01e7e639a6eb5dd875adbaa78858d8f | 2026-01-04T15:48:46.154368Z | false |
fnando/i18n-js | https://github.com/fnando/i18n-js/blob/f8fb0dc0b01e7e639a6eb5dd875adbaa78858d8f/test/i18n-js/cli/version_command_test.rb | test/i18n-js/cli/version_command_test.rb | # frozen_string_literal: true
require "test_helper"
class VersionCommandTest < Minitest::Test
let(:stdout) { StringIO.new }
let(:stderr) { StringIO.new }
test "displays version" do
cli = I18nJS::CLI.new(
argv: %w[version],
stdout:,
stderr:
)
assert_exit_code(0) { cli.call }
a... | ruby | MIT | f8fb0dc0b01e7e639a6eb5dd875adbaa78858d8f | 2026-01-04T15:48:46.154368Z | false |
fnando/i18n-js | https://github.com/fnando/i18n-js/blob/f8fb0dc0b01e7e639a6eb5dd875adbaa78858d8f/test/i18n-js/cli/plugins_command_test.rb | test/i18n-js/cli/plugins_command_test.rb | # frozen_string_literal: true
require "test_helper"
class PluginsCommandTest < Minitest::Test
let(:stdout) { StringIO.new }
let(:stderr) { StringIO.new }
test "displays help" do
cli = I18nJS::CLI.new(
argv: %w[plugins --help],
stdout:,
stderr:
)
assert_exit_code(0) { cli.call }
... | ruby | MIT | f8fb0dc0b01e7e639a6eb5dd875adbaa78858d8f | 2026-01-04T15:48:46.154368Z | false |
fnando/i18n-js | https://github.com/fnando/i18n-js/blob/f8fb0dc0b01e7e639a6eb5dd875adbaa78858d8f/test/i18n-js/cli/ui_test.rb | test/i18n-js/cli/ui_test.rb | # frozen_string_literal: true
require "test_helper"
class UITest < Minitest::Test
class FakeIO < StringIO
attr_writer :tty
def tty?
@tty
end
end
let(:io) { StringIO.new }
teardown do
ENV.delete("NO_COLOR")
end
test "returns ansi text when detecting tty" do
io = FakeIO.new
... | ruby | MIT | f8fb0dc0b01e7e639a6eb5dd875adbaa78858d8f | 2026-01-04T15:48:46.154368Z | false |
fnando/i18n-js | https://github.com/fnando/i18n-js/blob/f8fb0dc0b01e7e639a6eb5dd875adbaa78858d8f/test/i18n-js/cli/init_command_test.rb | test/i18n-js/cli/init_command_test.rb | # frozen_string_literal: true
require "test_helper"
class InitCommandTest < Minitest::Test
let(:stdout) { StringIO.new }
let(:stderr) { StringIO.new }
test "displays help" do
cli = I18nJS::CLI.new(
argv: %w[init --help],
stdout:,
stderr:
)
assert_exit_code(0) { cli.call }
ass... | ruby | MIT | f8fb0dc0b01e7e639a6eb5dd875adbaa78858d8f | 2026-01-04T15:48:46.154368Z | false |
fnando/i18n-js | https://github.com/fnando/i18n-js/blob/f8fb0dc0b01e7e639a6eb5dd875adbaa78858d8f/test/config/require_error.rb | test/config/require_error.rb | # frozen_string_literal: true
raise "π£"
| ruby | MIT | f8fb0dc0b01e7e639a6eb5dd875adbaa78858d8f | 2026-01-04T15:48:46.154368Z | false |
fnando/i18n-js | https://github.com/fnando/i18n-js/blob/f8fb0dc0b01e7e639a6eb5dd875adbaa78858d8f/test/config/require.rb | test/config/require.rb | # frozen_string_literal: true
I18n.available_locales = %i[en es pt]
I18n.default_locale = :en
I18n.load_path << Dir["./test/fixtures/yml/*.yml"]
| ruby | MIT | f8fb0dc0b01e7e639a6eb5dd875adbaa78858d8f | 2026-01-04T15:48:46.154368Z | false |
fnando/i18n-js | https://github.com/fnando/i18n-js/blob/f8fb0dc0b01e7e639a6eb5dd875adbaa78858d8f/lib/i18n-js.rb | lib/i18n-js.rb | # frozen_string_literal: true
require "i18n"
require "json"
require "yaml"
require "glob"
require "fileutils"
require "optparse"
require "erb"
require "digest/md5"
require_relative "i18n-js/schema"
require_relative "i18n-js/version"
require_relative "i18n-js/plugin"
require_relative "i18n-js/sort_hash"
require_relati... | ruby | MIT | f8fb0dc0b01e7e639a6eb5dd875adbaa78858d8f | 2026-01-04T15:48:46.154368Z | false |
fnando/i18n-js | https://github.com/fnando/i18n-js/blob/f8fb0dc0b01e7e639a6eb5dd875adbaa78858d8f/lib/i18n-js/version.rb | lib/i18n-js/version.rb | # frozen_string_literal: true
module I18nJS
VERSION = "4.2.4"
end
| ruby | MIT | f8fb0dc0b01e7e639a6eb5dd875adbaa78858d8f | 2026-01-04T15:48:46.154368Z | false |
fnando/i18n-js | https://github.com/fnando/i18n-js/blob/f8fb0dc0b01e7e639a6eb5dd875adbaa78858d8f/lib/i18n-js/clean_hash.rb | lib/i18n-js/clean_hash.rb | # frozen_string_literal: true
module I18nJS
def self.clean_hash(hash)
hash.keys.each_with_object({}) do |key, buffer|
value = hash[key]
next if value.is_a?(Proc)
buffer[key] = value.is_a?(Hash) ? clean_hash(value) : value
end
end
end
| ruby | MIT | f8fb0dc0b01e7e639a6eb5dd875adbaa78858d8f | 2026-01-04T15:48:46.154368Z | false |
fnando/i18n-js | https://github.com/fnando/i18n-js/blob/f8fb0dc0b01e7e639a6eb5dd875adbaa78858d8f/lib/i18n-js/embed_fallback_translations_plugin.rb | lib/i18n-js/embed_fallback_translations_plugin.rb | # frozen_string_literal: true
module I18nJS
require "i18n-js/plugin"
class EmbedFallbackTranslationsPlugin < I18nJS::Plugin
module Utils
# Based on deep_merge by Stefan Rusterholz, see
# <https://www.ruby-forum.com/topic/142809>.
# This method is used to handle I18n fallbacks. Given two equi... | ruby | MIT | f8fb0dc0b01e7e639a6eb5dd875adbaa78858d8f | 2026-01-04T15:48:46.154368Z | false |
fnando/i18n-js | https://github.com/fnando/i18n-js/blob/f8fb0dc0b01e7e639a6eb5dd875adbaa78858d8f/lib/i18n-js/listen.rb | lib/i18n-js/listen.rb | # frozen_string_literal: true
module I18nJS
class << self
attr_accessor :started
end
def self.listen(
config_file: Rails.root.join("config/i18n.yml"),
locales_dir: Rails.root.join("config/locales"),
run_on_start: true,
options: {}
)
return unless Rails.env.development?
return if st... | ruby | MIT | f8fb0dc0b01e7e639a6eb5dd875adbaa78858d8f | 2026-01-04T15:48:46.154368Z | false |
fnando/i18n-js | https://github.com/fnando/i18n-js/blob/f8fb0dc0b01e7e639a6eb5dd875adbaa78858d8f/lib/i18n-js/plugin.rb | lib/i18n-js/plugin.rb | # frozen_string_literal: true
require_relative "schema"
module I18nJS
def self.available_plugins
@available_plugins ||= Set.new
end
def self.plugins
@plugins ||= []
end
def self.register_plugin(plugin)
available_plugins << plugin
end
def self.plugin_files
Gem.find_files("i18n-js/*_plu... | ruby | MIT | f8fb0dc0b01e7e639a6eb5dd875adbaa78858d8f | 2026-01-04T15:48:46.154368Z | false |
fnando/i18n-js | https://github.com/fnando/i18n-js/blob/f8fb0dc0b01e7e639a6eb5dd875adbaa78858d8f/lib/i18n-js/sort_hash.rb | lib/i18n-js/sort_hash.rb | # frozen_string_literal: true
module I18nJS
def self.sort_hash(hash)
return hash unless hash.is_a?(Hash)
hash.keys.sort_by(&:to_s).each_with_object({}) do |key, seed|
value = hash[key]
seed[key] = value.is_a?(Hash) ? sort_hash(value) : value
end
end
end
| ruby | MIT | f8fb0dc0b01e7e639a6eb5dd875adbaa78858d8f | 2026-01-04T15:48:46.154368Z | false |
fnando/i18n-js | https://github.com/fnando/i18n-js/blob/f8fb0dc0b01e7e639a6eb5dd875adbaa78858d8f/lib/i18n-js/cli.rb | lib/i18n-js/cli.rb | # frozen_string_literal: true
require_relative "../i18n-js"
require_relative "cli/command"
require_relative "cli/ui"
require_relative "cli/init_command"
require_relative "cli/version_command"
require_relative "cli/export_command"
require_relative "cli/plugins_command"
require_relative "cli/lint_translations_command"
r... | ruby | MIT | f8fb0dc0b01e7e639a6eb5dd875adbaa78858d8f | 2026-01-04T15:48:46.154368Z | false |
fnando/i18n-js | https://github.com/fnando/i18n-js/blob/f8fb0dc0b01e7e639a6eb5dd875adbaa78858d8f/lib/i18n-js/export_files_plugin.rb | lib/i18n-js/export_files_plugin.rb | # frozen_string_literal: true
module I18nJS
require "i18n-js/plugin"
class ExportFilesPlugin < I18nJS::Plugin
def setup
I18nJS::Schema.root_keys << config_key
end
def validate_schema
valid_keys = %i[enabled files]
schema.expect_required_keys(keys: valid_keys, path: [config_key])
... | ruby | MIT | f8fb0dc0b01e7e639a6eb5dd875adbaa78858d8f | 2026-01-04T15:48:46.154368Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.