This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Curtain | |
| @hooks = [] | |
| @order = 0 | |
| @mutex = Mutex.new | |
| class << self | |
| attr_reader :order | |
| def register(group:, priority: 0, &block) | |
| @mutex.synchronize do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'json' | |
| require 'objspace' | |
| class RubyVM | |
| module Shape | |
| def self.id(obj) | |
| json = ObjectSpace.dump(obj, output: :string) | |
| JSON.parse(json).fetch('shape_id') | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'strscan' | |
| require 'bigdecimal' | |
| # This is copied and slightly refactored from BareTest::TabularData | |
| # | |
| # Example | |
| # LiteralParser.parse("nil") # => nil | |
| # LiteralParser.parse(":foo") # => :foo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'fiddle' | |
| module Procify | |
| WORD = Fiddle::SIZEOF_VOIDP | |
| RPROC_OFFSET = 4 * WORD | |
| PROC_FLAG_OFFSET = 32 | |
| PROC_PACKED = [0].pack('Q').freeze | |
| LAMBDA_PACKED = [2].pack('Q').freeze | |
| refine Proc do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Papercraft | |
| class Block | |
| def initialize(&) = singleton_class.define_method(:call, &) | |
| def apply(...) = self.class.new { call(...) } | |
| class HTML < Block | |
| def render(...) = call(...) | |
| def to_html = render.to_s | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Options < Ruby::Box | |
| def [](name) = instance_eval { eval "$#{name.to_s.delete_prefix('$')}" } | |
| end | |
| options = Options.new | |
| options.instance_eval do | |
| require 'optparse' | |
| class Option | |
| def []=(key, value) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'fiddle' | |
| require 'fiddle/import' | |
| module GlobalVariable | |
| extend Fiddle::Importer | |
| dlload Fiddle::Handle::DEFAULT | |
| extern 'void rb_gv_set(const char*, unsigned long)' | |
| extern 'unsigned long rb_gv_get(const char*)' | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'io/stream' | |
| require 'open3' | |
| module Command | |
| Result = Data.define(:out, :err, :status) | |
| def self.run(*, **) | |
| Open3.popen3(*, **) do |stdin, stdout, stderr, thread| | |
| stdin.close |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Document | |
| def self.included(base) | |
| base.class_eval do | |
| def self.name = "#{super}ument" | |
| end | |
| end | |
| module_function | |
| def print = :printed |
NewerOlder