source stringclasses 1
value | repo stringlengths 5 63 | repo_url stringlengths 24 82 | path stringlengths 5 167 | language stringclasses 1
value | license stringclasses 5
values | stars int64 10 51.4k | ref stringclasses 23
values | size_bytes int64 200 258k | text stringlengths 137 258k |
|---|---|---|---|---|---|---|---|---|---|
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/dogstatsd-ruby/5.5/_test/test.rb | Ruby | mit | 301 | main | 2,347 | # Write Ruby code to test the RBS.
# It is type checked by `steep check` command.
require "datadog/statsd"
statsd = Datadog::Statsd.new
statsd = Datadog::Statsd.new('localhost', 8125)
statsd = Datadog::Statsd.new(
socket_path: '/file',
namespace: 'test',
tags: { "hello" => "world" },
logger: Logger.new(STDE... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/rake/13.0/_test/test.rb | Ruby | mit | 301 | main | 662 | # Write Ruby code to test the RBS.
# It is type checked by `steep check` command.
require "rake"
class Task < Rake::TaskLib
def create_task
task default: %w[test]
task :test do
ruby "test/unittest.rb"
end
task :test_with_1_arg, :name do |t, args|
value = args[:name]
puts "#{args[... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/scanf/1.0/_test/test.rb | Ruby | mit | 301 | main | 280 | # Write Ruby code to test the RBS.
# It is type checked by `steep check` command.
require 'scanf'
# String#scanf and IO#scanf take a single argument, the format string
"123ac".scanf("%d%s")
File.open('test.rb', "rb").scanf("%d%s")
# Kernel#scanf reads from STDIN
scanf("%d%s") |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/flipper/0.28/_test/test_basic.rb | Ruby | mit | 301 | main | 414 | # Taken from https://github.com/flippercloud/flipper/blob/v0.28.0/examples/basic.rb
require 'bundler/setup'
require 'flipper'
# check if search is enabled
if Flipper.enabled?(:search)
puts 'Search away!'
else
puts 'No search for you!'
end
puts 'Enabling Search...'
Flipper.enable(:search)
# check if search is en... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/flipper/0.28/_test/test_configuring_default.rb | Ruby | mit | 301 | main | 642 | # Taken from https://github.com/flippercloud/flipper/blob/v0.28.0/examples/configuring_default.rb
require 'bundler/setup'
require 'flipper'
# sets up default adapter so Flipper works like Flipper::DSL
Flipper.configure do |config|
config.adapter { Flipper::Adapters::Memory.new }
end
puts Flipper.enabled?(:search) ... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/oga/3.4/_test/test.rb | Ruby | mit | 301 | main | 670 | # Write Ruby code to test the RBS.
# It is type checked by `steep check` command.
require "oga"
html = <<HTML
<html>
<body>
<ul id="list" data-attr="b">
<li data-attr="a">list1</li>
<li>list2</li>
</ul>
</body>
</html>
HTML
Oga.parse_xml("")
Oga.parse_xml("", strict: true)
Oga.parse_html(File.open("path"))
doc =... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/fcm/2.0/_test/test.rb | Ruby | mit | 301 | main | 3,020 | require "fcm"
GOOGLE_APPLICATION_CREDENTIALS_PATH = '/path/to/credentials.json'
FIREBASE_PROJECT_ID = 'your_project_id'
# HTTP v1 API
fcm = FCM.new(
GOOGLE_APPLICATION_CREDENTIALS_PATH,
FIREBASE_PROJECT_ID
)
message = {
'token': "000iddqd", # send to a specific device
# 'topic': "yourTopic",
# 'condition':... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/actionmailer/7.0/_test/railsguides.rb | Ruby | mit | 301 | main | 1,033 | module RailsGuides
class ApplicationMailer < ActionMailer::Base
default from: 'from@example.com'
layout 'mailer'
end
class NotifierMailer < ApplicationMailer
default from: 'no-reply@example.com',
return_path: 'system@example.com'
def welcome(recipient)
@account = recipient
... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/yard/0.9/_test/yard.rb | Ruby | mit | 301 | main | 873 | # !!! GENERATED FILE !!!
# Please see yard/0.9/_generators/README.md
require 'yard'
YARD::Registry.root.children.each do |child|
child.name(false)
child.docstring.all
end
::YARD::DocstringParser.new.parse("@option a b [String]").tags.each do |tag|
case tag
when YARD::Tags::OverloadTag
tag.types
when YA... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/yard/0.9/_generators/Rakefile | Ruby | mit | 301 | main | 558 | task :generate do
load 'generate.rb'
end
task :validate do
sh "bundle exec rbs --no-collection -r logger -r optparse -r ripper -I out validate"
end
task :replace do
rm_rf '../_test'
sh 'cp -a out/_test ../_test'
rm_rf '../yard'
sh 'cp -a out/yard ../yard'
sh 'cp -a out/EXTERNAL_TODO.rbs ../EXTERNAL_TODO... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/yard/0.9/_generators/generate.rb | Ruby | mit | 301 | main | 2,073 | require 'orthoses-yard'
require 'fileutils'
require 'pathname'
require 'erb'
stdlib_dependencies = %w[
optparse
logger
ripper
]
output_dir = 'out'
Orthoses.logger.level = :warn
gem_path = Gem::Specification.find_by_name("yard").load_paths.first
notice = "# !!! GENERATED FILE !!!\n# Please see yard/0.9/_generat... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/mail/2.8/_test/test.rb | Ruby | mit | 301 | main | 257 | address = Mail::Address.new('Fuga Kkbn (My email address) <fugakkbn@example.com>')
address.domain
mail = Mail.new
mail.from = 'fugakkbn@example.com'
mail.to = 'you@example.com'
mail.subject = 'This is a test email'
mail.body = 'Some simple body'
mail.to_s |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/sqlite3/2.0/_test/test.rb | Ruby | mit | 301 | main | 724 | # Write Ruby code to test the RBS.
# It is type checked by `steep check` command.
require "sqlite3"
SQLite3::Database.new("test.db").execute("SELECT * FROM users").each do |row|
row[0] # Array
end
SQLite3::Database.new("test.db").execute("SELECT * FROM users") do |row|
row[0] # Array
end
SQLite3::Database.new("t... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/roo/2.10/_test/excelx_test.rb | Ruby | mit | 301 | main | 6,348 | # Write Ruby code to test the RBS.
# It is type checked by `steep check` command.
require 'roo'
file_name = './test.xlsx'
xlsx = Roo::Excelx.new(file_name)
xlsx.sheets
xlsx.images
xlsx.images('Info')
xlsx.images(0)
xlsx.row(1)
xlsx.row(1, 'Info')
xlsx.row(1, 0)
# returns the first row of the spreadsheet.
xlsx.col... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/roo/2.10/_test/open_office_test.rb | Ruby | mit | 301 | main | 6,318 | # Write Ruby code to test the RBS.
# It is type checked by `steep check` command.
require 'roo'
file_name = './test.open_office'
open_office = Roo::OpenOffice.new(file_name)
open_office.sheets
open_office.row(1)
open_office.row(1, 'Info')
open_office.row(1, 0)
# returns the first row of the spreadsheet.
open_offic... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/roo/2.10/_test/csv_test.rb | Ruby | mit | 301 | main | 4,447 | # Write Ruby code to test the RBS.
# It is type checked by `steep check` command.
require 'roo'
file_name = './test.csv'
csv = Roo::CSV.new(file_name)
csv.sheets
csv.row(1)
csv.row(1, 'Info')
csv.row(1, 0)
# returns the first row of the spreadsheet.
csv.column(1)
csv.column(1, 'Info')
csv.column(1, 0)
# returns th... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/retries/0.0.5/_test/test.rb | Ruby | mit | 301 | main | 318 | # Write Ruby code to test the RBS.
# It is type checked by `steep check` command.
require "retries"
Retries.sleep_enabled = Retries.sleep_enabled
with_retries max_tries: 10, base_sleep_seconds: 1.2, max_sleep_seconds: 3.4, handler: ->(e,a,t){}, rescue: [StandardError] do |attempt|
puts "Attempt ##{attempt}"
end |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/rack/2.2/_test/string_body.rb | Ruby | mit | 301 | main | 216 | # @type var app: Rack::_Application
app = _ = nil
middleware = -> (env) do
# @type var env: Rack::env
# @type block: Rack::response
[404, { "FOO" => "BAR" }, "Not found"]
end
middleware #: Rack::_Application |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/rack/2.2/_test/body_proxy.rb | Ruby | mit | 301 | main | 375 | # @type var app: Rack::_Application
app = _ = nil
middleware = -> (env) do
# @type var env: Rack::env
# @type block: Rack::response
status, headers, body = app.call(env)
body_proxy = Rack::BodyProxy.new(body) do
puts "Closed"
end #: Rack::BodyProxy & _Each[String]
body_proxy.close()
[status, head... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/holiday_jp/0.8/_test/test.rb | Ruby | mit | 301 | main | 252 | require "holiday_jp"
holidays = HolidayJp.between(Date.new(2010, 9, 14), Date.new(2010, 9, 21)) # => [#<HolidayJp::Holiday>]
holidays[0].name # => 敬老の日
holidays[0].date # => Mon, 20 Sep 2010
HolidayJp.holiday?(Date.new(2016, 8 ,11)) # => true |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/holidays/8.4/_test/test.rb | Ruby | mit | 301 | main | 423 | # Write Ruby code to test the RBS.
# It is type checked by `steep check` command.
require "holidays"
Holidays::WEEKS
Holidays::MONTH_LENGTHS
Holidays::DAY_SYMBOLS
holidays = Holidays.on(Date.civil(2022, 8, 11), :jp)
holidays[0][:date]
holidays[0][:name]
holidays[0][:regions]
holidays = Holidays.between(Date.civil(2... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/gitlab/6.0/_test/test.rb | Ruby | mit | 301 | main | 1,001 | # Write Ruby code to test the RBS.
# It is type checked by `steep check` command.
require "gitlab"
client = Gitlab.client(endpoint: "https://gitlab.example.com/api/v4", private_token: "private_token")
client.users(username: "username")
# get current user
client.user
# get specified user
client.user(1)
project_nam... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/launchdarkly-server-sdk/6.4/_test/test.rb | Ruby | mit | 301 | main | 496 | # Write Ruby code to test the RBS.
# It is type checked by `steep check` command.
require "launchdarkly-server-sdk"
client = LaunchDarkly::LDClient.new("sdk-key-123abc")
# @type var show_feature: bool
show_feature = client.variation("flag-key-123abc", {key: "user-key-123abc"}, false)
# @type detail: LaunchDarkly::E... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/launchdarkly-server-sdk/7.2/_test/multi_context.rb | Ruby | mit | 301 | main | 254 | # https://docs.launchdarkly.com/sdk/features/user-context-config#ruby
multi_context = LaunchDarkly::LDContext.create_multi([
LaunchDarkly::LDContext.with_key("user-key-123abc"),
LaunchDarkly::LDContext.with_key("device-key-123abc", "device"),
]) |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/launchdarkly-server-sdk/7.2/_test/test.rb | Ruby | mit | 301 | main | 701 | # Write Ruby code to test the RBS.
# It is type checked by `steep check` command.
require "launchdarkly-server-sdk"
client = LaunchDarkly::LDClient.new("sdk-key-123abc")
context = LaunchDarkly::LDContext.create({ key: "user-key-123abc" })
# @type var show_feature: bool
show_feature = client.variation("flag-key-123ab... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/browser/5.3/_test/test.rb | Ruby | mit | 301 | main | 3,367 | # Write Ruby code to test the RBS.
# It is type checked by `steep check` command.
require "browser"
ua = "Some User Agent"
browser = Browser.new("Some User Agent", accept_language: "en-us")
# General info
browser.bot?
browser.chrome?
browser.chromium_based?
browser.core_media?
browser.duck_duck_go?
browser.edge? ... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/activerecord-import/1.5/_test/test.rb | Ruby | mit | 301 | main | 935 | # Write Ruby code to test the RBS.
# It is type checked by `steep check` command.
require "activerecord"
require "activerecord-import"
class Book < ActiveRecord::Base
end
# @type var books: Array[Book]
books = []
10.times do |i|
books << Book.new
end
Book.import books # or use import!
columns = [ :title, :aut... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/sidekiq-cron/2.2/_test/test.rb | Ruby | mit | 301 | main | 804 | require "sidekiq-cron"
Sidekiq::Cron.configure do |config|
config.cron_schedule_file = "config/users_schedule.yml"
end
# return array of all jobs
Sidekiq::Cron::Job.all
# return one job by its unique name - case sensitive
Sidekiq::Cron::Job.find "Job Name"
# return one job by its unique name - you can use hash wi... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/google-cloud-firestore/2.15/_test/test.rb | Ruby | mit | 301 | main | 415 | require "google-cloud-firestore"
firestore = Google::Cloud::Firestore.new(project_id: "test-project")
firestore.doc("users/test-user").set({ user_name: "test", url: "https://example.com/" })
firestore.doc("users/test-user").update({ user_name: "test", url: "https://example.com/new" })
firestore.doc("users/test-user")... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/hashdiff/1.1/_test/test.rb | Ruby | mit | 301 | main | 296 | # Write Ruby code to test the RBS.
# It is type checked by `steep check` command.
require "hashdiff"
diff1 = Hashdiff.diff({a:{x:2, y:3, z:4}, b:{x:3, z:45}}, {a:{y:3}, b:{y:3, z:30}})
diff2 = Hashdiff.diff({ a: 1, b: { d: 2, a: 3 }, c: 4 }, { a: 2, b: { d: 2, a: 7 }, c: 5 }, ignore_keys: :a) |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/rails-html-sanitizer/1.6/_test/test.rb | Ruby | mit | 301 | main | 717 | require "rails-html-sanitizer"
full_sanitizer = Rails::HTML::FullSanitizer.new
full_sanitizer.sanitize("<b>Bold</b> no more! <a href='more.html'>See more here</a>...")
link_sanitizer = Rails::HTML::LinkSanitizer.new
link_sanitizer.sanitize('<a href="example.com">Only the link text will be kept.</a>')
safe_list_sani... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/diffy/3.4/_test/test.rb | Ruby | mit | 301 | main | 247 | # Write Ruby code to test the RBS.
# It is type checked by `steep check` command.
require "diffy"
str1 = "123"
str2 = "124"
Diffy::Diff.new(str1, str2).to_s
Diffy::Diff.new(str1, str2, context: 3).to_s
Diffy::Diff.new(str1, str2).to_s(:html) |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/tzinfo/2.0/_test/test.rb | Ruby | mit | 301 | main | 2,331 | # Write Ruby code to test the RBS.
# It is type checked by `steep check` command.
require "tzinfo"
TZInfo::DataSource.set(:ruby)
TZInfo::DataSource.set(:zoneinfo)
TZInfo::DataSource.set(:zoneinfo, 'zoneinfo_dir')
TZInfo::DataSource.set(:zoneinfo, 'zoneinfo_dir', 'iso3166_tab_file')
TZInfo::Country.all.sort{|a,b| a <... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/carrierwave/3.0/_test/test.rb | Ruby | mit | 301 | main | 605 | # Write Ruby code to test the RBS.
# It is type checked by `steep check` command.
require "carrierwave"
class AvatarUploader < CarrierWave::Uploader::Base
storage :file
end
class MyUploader < CarrierWave::Uploader::Base
include CarrierWave::RMagick
process resize_to_fit: [800, 800]
version :thumb do
pr... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/rubyzip/3.2/_test/test_example.rb | Ruby | mit | 301 | main | 15,116 | require 'zip'
####### Using ZipInputStream alone: #######
is_val = Zip::InputStream.open('example.zip') do |zis|
next_entry = zis.get_next_entry
print "First line of '#{next_entry&.name} (#{next_entry&.size} bytes): "
puts "'#{zis.gets&.chomp}'"
next_entry = zis.get_next_entry
print "First line of '#{next_... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/rubyzip/2.3/_test/test_example.rb | Ruby | mit | 301 | main | 2,447 | # Taken from https://github.com/rubyzip/rubyzip/blob/v2.3.0/samples/example.rb
require 'zip'
####### Using ZipInputStream alone: #######
Zip::InputStream.open('example.zip') do |zis|
entry = zis.get_next_entry
print "First line of '#{entry&.name} (#{entry&.size} bytes): "
puts "'#{zis.gets&.chomp}'"
entry =... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/bigdecimal/3.1/_test/test.rb | Ruby | mit | 301 | main | 620 | # Write Ruby code to test the RBS.
# It is type checked by `steep check` command.
require "bigdecimal"
require "bigdecimal/util"
BigDecimal("1.23")
BigDecimal("1.23") + BigDecimal("1.23")
BigDecimal("1.23") - BigDecimal("1.23")
BigDecimal("1.23") * BigDecimal("1.23")
BigDecimal("1.23") / BigDecimal("1.23")
BigDecim... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/rainbow/3.0/_scripts/gen_x11_colors.rb | Ruby | mit | 301 | main | 408 | require "rainbow"
existing_names = Rainbow::Presenter.public_instance_methods(false)
x11_color_names = Rainbow::X11ColorNames::NAMES.keys - existing_names
case ARGV[0]
when "sig"
puts x11_color_names.sort.map { |method| " def #{method}: () -> instance\n" }.join
when "test"
puts x11_color_names.sort.map { |meth... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/rainbow/3.0/_test/rainbow_test.rb | Ruby | mit | 301 | main | 3,582 | rainbow = Rainbow("hello")
rainbow.color(:pink)
rainbow.reset
.italic
.bold
.underline
.blink
.inverse
.hide
.black
.red
.green
.yellow
.blue
.magenta
.cyan
.white
Rainbow.enabled
Rainbow.enabled = false
Rainbow.uncolor("a string")
# X11 color names
Rainbow('Hi').aliceblue
Rainbow('Hi').a... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/flexirest/1.12/_test/test.rb | Ruby | mit | 301 | main | 235 | require "flexirest"
class Person < Flexirest::Base
base_url "https://www.example.com/api/v1"
get :all, "/people"
get :find, "/people/:id"
put :save, "/people/:id"
post :create, "/people"
delete :remove, "/people/:id"
end |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/paranoia/2.5/_test/test.rb | Ruby | mit | 301 | main | 1,094 | # It is type checked by `steep check` command.
require "paranoia"
class Product < ActiveRecord::Base
acts_as_paranoid delete_all_enabled: true
scope :promoted, -> { where(promoted: true) }
scope :regular, -> { where(promoted: false) }
after_destroy :update_document_in_search_engine
after_restore :update_d... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/delayed_job/4.1/_test/test.rb | Ruby | mit | 301 | main | 617 | Delayed::Worker.queue_attributes = {
high_priority: { priority: -10 },
low_priority: { priority: 10 }
}
Delayed::Worker.delay_jobs = ->(job) {
# TODO: Comment-in after `job` is typed
# job.queue != 'inline'
}
Delayed::Worker.destroy_failed_jobs = false
Delayed::Worker.sleep_delay = 60
Delayed::Worker.max_atte... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/rqrcode/2.2/_test/test.rb | Ruby | mit | 301 | main | 1,027 | # Write Ruby code to test the RBS.
# It is type checked by `steep check` command.
require "rqrcode"
qr = RQRCode::QRCode.new("https://kyan.com", level: :h)
puts qr.to_s
qrcode = RQRCode::QRCode.new("http://github.com/")
# NOTE: showing with default options specified explicitly
svg = qrcode.as_svg(
color: "000",
... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/chronic/0.10/_test/test.rb | Ruby | mit | 301 | main | 788 | require "chronic"
Chronic.parse('monday')
Chronic.parse('monday', context: :future)
Chronic.parse('monday', context: :past)
Chronic.parse('monday', now: Time.local(2000, 1, 1))
Chronic.parse('20:00:00', hours24: false) # => nil
Chronic.parse('monday', week_start: :sunday)
Chronic.parse('monday', week_start: :monda... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/googleauth/1.11/_test/test.rb | Ruby | mit | 301 | main | 265 | require "googleauth"
class MyCredentials < Google::Auth::Credentials
# Set the default scope for these credentials
self.scope = "http://example.com/my_scope"
end
Google::Auth::ServiceAccountCredentials.make_creds(
json_key_io: StringIO.new(''), scope: []
) |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/faraday/2.5/_test/test_adapter.rb | Ruby | mit | 301 | main | 1,324 | Faraday::Adapter.register_middleware(custom: Faraday::Adapter)
Faraday::Adapter.registered_middleware.each { |k, v| [k, v] }
Faraday::Adapter.lookup_middleware(:custom)
Faraday::Adapter.unregister_middleware(:custom)
Faraday::Adapter::CONTENT_LENGTH.chomp
Faraday::Adapter.supports_parallel = true
Faraday::Adapter.suppo... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/faraday/2.5/_test/test_adapter_registry.rb | Ruby | mit | 301 | main | 234 | registry = Faraday::AdapterRegistry.new
registry.get('Faraday::Connection')
registry.get(:Faraday)
registry.set(:Wind)
registry.set(:Wave, nil)
registry.set(:Sea, :new_name)
registry.set(:Mountain, "another")
registry.set(:Star, 123) |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/faraday/2.5/_test/test_errors.rb | Ruby | mit | 301 | main | 1,402 | Faraday::Error.new.tap do |error|
error.backtrace
error.inspect.downcase
error.response_status
error.response_headers
error.response_body
error.exc_msg_and_response!.downcase
error.exc_msg_and_response!(RuntimeError.new)
error.exc_msg_and_response!({ status: 500 })
error.exc_msg_and_response!("Error!"... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/faraday/2.5/_test/test.rb | Ruby | mit | 301 | main | 3,271 | # Write Ruby code to test the RBS.
# It is type checked by `steep check` command.
require "faraday"
Faraday::VERSION
Faraday.default_adapter
conn = Faraday.new('http://example.com/test1')
conn.headers
response = conn.get('/get', { param: '1' }, { 'Content-Type' => 'application/json' }) do |req|
req.path = "/new_ge... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/faraday/2.5/_test/test_utils_headers.rb | Ruby | mit | 301 | main | 994 | Faraday::Utils::Headers.from({}).instance_variable_get(:@names)
Faraday::Utils::Headers.allocate.instance_variable_get(:@names)
h = Faraday::Utils::Headers.new
h.initialize_names
h[:test] = 2134
h[:test] = :df
h[:test] = nil
h[:test] = "test"
h[:test]
h["test"]
h.fetch(:test)
h.fetch("test")
h.delete(:test)
h.delete... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/faraday/2.5/_test/test_adapter_test.rb | Ruby | mit | 301 | main | 4,428 | test = Faraday::Adapter::Test.new(Object.new) do |stubs|
stubs.empty?
stub, meta = stubs.match(Faraday::Env.new)
if stub && meta
meta[:match_data]
end
stubs.get "/abc" do
[200, { "Content-Type" => "text/plain" }, "Hi"]
end
stubs.get /foo/, { x_test: "true" } do |env, meta|
meta.key?(:match_da... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/activerecord/8.0/_test/activerecord-validation-contexts.rb | Ruby | mit | 301 | main | 606 | model = ActiveRecord::Base.new
model.save
model.save(context: :sample_context)
model.save(context: [:update, :sample_context], touch: false)
model.save(validate: false, touch: true)
model.save!
model.save!(context: :sample_context)
model.save!(context: [:update, :sample_context], touch: false)
model.save!(validate: f... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/activerecord/8.0/_test/activerecord.rb | Ruby | mit | 301 | main | 1,225 | class TestCallbackObject < ActiveRecord::Base
before_validation ::Callbacks::ClassCallback
after_validation ::Callbacks::ClassCallback
before_save ::Callbacks::ClassCallback
before_create ::Callbacks::ClassCallback
after_create ::Callbacks::ClassCallback
after_save ::Callbacks::ClassCallback
around_create... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/activerecord/8.0/_test/activerecord-generated.rb | Ruby | mit | 301 | main | 1,607 | class FunQuery
def self.call(*args)
end
end
class User < ActiveRecord::Base
# @dynamic age
enum status: { active: 0, inactive: 1 }, _suffix: true
enum role: { admin: 0, user: 1 }, _prefix: :user_role
# @dynamic articles
has_many :articles
validates :name, presence: true, if: -> { something }
valid... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/activerecord/8.0/_test/activerecord-8.0.rb | Ruby | mit | 301 | main | 3,664 | # Write Ruby code to test the RBS.
# It is type checked by `steep check` command.
require "activerecord"
module Test
class ApplicationRecord < ActiveRecord::Base
primary_abstract_class
connects_to database: { writing: :primary, reading: :primary_replica }
connects_to shards: {
default: { writing:... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/activerecord/7.2/_test/activerecord.rb | Ruby | mit | 301 | main | 1,891 | class TestCallbackObject < ActiveRecord::Base
before_validation ::Callbacks::ClassCallback
after_validation ::Callbacks::ClassCallback
before_save ::Callbacks::ClassCallback
before_create ::Callbacks::ClassCallback
after_create ::Callbacks::ClassCallback
after_save ::Callbacks::ClassCallback
around_create... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/mysql2-cs-bind/0.1/_test/xquery.rb | Ruby | mit | 301 | main | 1,272 | require "mysql2-cs-bind"
as = :array
Mysql2::Client.new(as: as).xquery("SELECT * FROM users WHERE id = ?", 1).each do |row|
if row.is_a?(Array)
row[0] # Array
elsif row.is_a?(Hash)
row[:id] # Hash
end
end
Mysql2::Client.new.xquery("SELECT * FROM users WHERE id = ?", 1).each do |row|
row[:id] # Hash
en... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/json-jwt/1.16/_test/test.rb | Ruby | mit | 301 | main | 695 | # Write Ruby code to test the RBS.
# It is type checked by `steep check` command.
require 'json/jwt'
private_key = OpenSSL::PKey::RSA.new <<-PEM
-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEAyBKIFSH8dP6bDkGBziB6RXTTfZVTaaNSWNtIzDmgRFi6FbLo
:
-----END RSA PRIVATE KEY-----
PEM
public_key = OpenSSL::PKey::RSA.new <<... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/connection_pool/2.4/_test/test.rb | Ruby | mit | 301 | main | 299 | # Write Ruby code to test the RBS.
# It is type checked by `steep check` command.
require "connection_pool"
pool = ConnectionPool.new(size: 5, timeout: 5) { Hash.new }
pool.with do |h|
h['some-count']
end
pool.then { |h| h['some-count'] }
pool.with(timeout: 2.0) do |h|
h['some-count']
end |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/listen/3.9/_test/test3.rb | Ruby | mit | 301 | main | 260 | listener = Listen.to('dir/path/to/listen', ignore: /\.txt/) { |modified, added, removed| }
listener.start
listener.ignore! /\.pkg/ # overwrite all patterns and only ignore pkg extension.
listener.ignore /\.rb/ # ignore rb extension in addition of pkg.
sleep |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/listen/3.9/_test/test2.rb | Ruby | mit | 301 | main | 461 | listener = Listen.to('dir/path/to/listen') { |modified, added, removed| puts 'handle changes here...' }
listener.start
listener.paused? # => false
listener.processing? # => true
listener.pause # stops processing changes (but keeps on collecting them)
listener.paused? # => true
listener.processing? # => false
# lis... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/listen/3.9/_test/test.rb | Ruby | mit | 301 | main | 255 | listener = Listen.to('dir/to/listen', 'dir/to/listen2') do |modified, added, removed|
puts "modified absolute path: #{modified}"
puts "added absolute path: #{added}"
puts "removed absolute path: #{removed}"
end
listener.start # not blocking
sleep |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/activejob/6.0/_test/activejob.rb | Ruby | mit | 301 | main | 430 | class SendMessageJob < ActiveJob::Base
queue_as :default
self.queue_adapter = :sidekiq
before_enqueue do |job|
# before enqueued
end
around_perform :around_task
def perform(*args)
# Do something later
end
private
def around_task
# Do something before
# yield
# Do something aft... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/base64/0.1/_test/test.rb | Ruby | mit | 301 | main | 312 | # Write Ruby code to test the RBS.
# It is type checked by `steep check` command.
require "base64"
Base64.decode64(Base64.encode64(""))
Base64.strict_decode64(Base64.strict_encode64(""))
Base64.urlsafe_decode64(Base64.urlsafe_encode64(""))
Base64.urlsafe_decode64(Base64.urlsafe_encode64("", padding: "true")) |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/mini_mime/0.1/_test/test.rb | Ruby | mit | 301 | main | 315 | require "mini_mime"
MiniMime.lookup_by_filename("foo.txt")
MiniMime.lookup_by_extension("txt")
MiniMime.lookup_by_content_type("text/plain")
raise unless info = MiniMime.lookup_by_filename("foo.txt")
info.extension
info.content_type
info.encoding
info[0]
info.binary?
MiniMime.lookup_by_filename("foo") #=> nil |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/redis/4.2/_test/error_handling.rb | Ruby | mit | 301 | main | 227 | redis = Redis.new
begin
redis.ping
rescue StandardError => e
e.inspect
# => #<Redis::CannotConnectError: Timed out connecting to Redis on 10.0.1.1:6380>
e.message
# => Timed out connecting to Redis on 10.0.1.1:6380
end |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/redis/4.2/_test/pipeline.rb | Ruby | mit | 301 | main | 251 | redis = Redis.new
# @type ivar @set: Redis::Future[String]
# @type ivar @incr: Redis::Future[Integer]
redis.pipelined do |redis|
@set = redis.set "foo", "bar"
@incr = redis.incr "baz"
end
# => ["OK", 1]
@set.value
# => "OK"
@incr.value
# => 1 |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/redis/4.2/_test/sorted_sets.rb | Ruby | mit | 301 | main | 517 | redis = Redis.new
redis.zcard(:sample_key)
redis.zadd(:sample_key, 1, 'hello world')
redis.zadd("string key", 1, 'hello world', nx: true)
redis.zadd("string key", 2, 'hello world', xx: true)
redis.zadd("string key", 3, 'hello world', ch: true)
redis.zadd("string key", 4, 'hello world', incr: true)
redis.zadd(:foo, [2,... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/redis/4.2/_test/hash.rb | Ruby | mit | 301 | main | 4,284 | redis = Redis.new
redis.hdel("hash_key", "foo")
redis.hdel("hash_key", "foo", "bar")
redis.hexists("hash_key", "foo")
redis.hget("hash_key", "key1")
redis.hgetall("hash_key")
redis.hincrby("hash_key", "field", 42)
redis.hincrby("hash_key", "field", 42.2)
redis.hincrbyfloat("hash_key", "field", 42.2)
redis.hincrby... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/redis/4.2/_test/initialize.rb | Ruby | mit | 301 | main | 222 | redis = Redis.new
redis = Redis.new(host: "10.0.1.1", port: 6380, db: 15)
redis = Redis.new(url: "redis://:p4ssw0rd@10.0.1.1:6380/15")
redis = Redis.new(path: "/tmp/redis.sock")
redis = Redis.new(password: "mysecret") |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/redis/4.2/_test/cluster.rb | Ruby | mit | 301 | main | 276 | # @type var nodes: Array[Redis::node]
nodes = (7000..7005).map { |port| "redis://127.0.0.1:#{port}" }
redis = Redis.new(cluster: nodes)
nodes = (7000..7005).map do |port|
# @type block: Redis::node
{ host: '127.0.0.1', port: port }
end
redis = Redis.new(cluster: nodes) |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/redis/4.2/_test/ssl.rb | Ruby | mit | 301 | main | 407 | redis = Redis.new(
:url => "rediss://:p4ssw0rd@10.0.1.1:6381/15",
:ssl_params => {
:ca_file => "/path/to/ca.crt"
}
)
redis = Redis.new(
:url => "rediss://:p4ssw0rd@10.0.1.1:6381/15",
:ssl_params => {
:ca_file => "/path/to/ca.crt",
:cert => OpenSSL::X509::Certificate.new(File.read... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/redis/4.2/_test/mset_mget.rb | Ruby | mit | 301 | main | 210 | redis = Redis.new(cluster: %w[redis://127.0.0.1:7000])
redis.mget('key1', 'key2')
#=> Redis::CommandError (CROSSSLOT Keys in request don't hash to the same slot)
redis.mget('{key}1', '{key}2')
#=> [nil, nil] |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/sorcery/0.16/_test/test.rb | Ruby | mit | 301 | main | 848 | # Write Ruby code to test the RBS.
# It is type checked by `steep check` command.
require "sorcery"
class User
extend Sorcery::Model
authenticates_with_sorcery!
end
User.authenticate('hoge@example.com', 'password')
User.authenticate('fuga@example.com', 'password') do |user, failure_reason|
p user
p failure_r... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/active_hash/3.2/_test/test.rb | Ruby | mit | 301 | main | 449 | # Write Ruby code to test the RBS.
# It is type checked by `steep check` command.
require "active_hash"
class Colour < ActiveHash::Base
include ActiveHash::Enum
enum_accessor :name
self.data = [
{ id: 1, name: "red", code: "#ff0000" },
{ id: 2, name: "green", code: "#00ff00" },
{ id: 3, name... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/regexp_trie/1.0/_test/test.rb | Ruby | mit | 301 | main | 476 | require "regexp_trie"
p RegexpTrie.union('foo', 'bar', 'baz')
# From https://github.com/gfx/ruby-regexp_trie#readme
# like Regexp.union()
p RegexpTrie.union(%w(foobar fooxar foozap fooza)) # /foo(?:bar|xar|zap?)/
p RegexpTrie.union(%w(foobar fooxar foozap fooza), option: Regexp::IGNORECASE) # /foo(?:bar|xar|zap?)/i
... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/activesupport/7.0/_test/test.rb | Ruby | mit | 301 | main | 833 | # Write Ruby code to test the RBS.
# It is type checked by `steep check` command.
require 'active_support/all'
# Test ActiveSupport::NumericWithFormat
42.to_fs
42.to_fs(:phone)
5.try(:to_s)
5.try('round', 2)
5.try(:tap) { |n| p n }
5.try { p 'hello' }
5.try { |n| p n }
nil.try(:to_s)
nil.try('round', 2)
nil.try(:tap... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/web-push/3.0/_test/test.rb | Ruby | mit | 301 | main | 796 | # Write Ruby code to test the RBS.
# It is type checked by `steep check` command.
require "web-push"
require "json"
# One-time, on the server
vapid_key = WebPush.generate_key
# Save these in your application server settings
vapid_key.public_key
vapid_key.private_key
# Or you can save in PEM format if you prefer
vap... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/jwt/2.5/_test/test.rb | Ruby | mit | 301 | main | 1,062 | require "jwt"
payload = { data: 'test' }
token = JWT.encode(payload, nil, 'none')
decoded, header = JWT.decode(token, nil, false)
hmac_secret = 'my$ecretK3y'
token = JWT.encode(payload, hmac_secret, 'HS256')
decoded, header = JWT.decode(token, hmac_secret, true, algorithm: 'HS256')
# Custom algorithm
class CustomAlg... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/shoryuken/6.0/_pending_test/test.rb | Ruby | mit | 301 | main | 560 | # Write Ruby code to test the RBS.
# It is type checked by `steep check` command.
require "shoryuken"
# https://github.com/ruby-shoryuken/shoryuken/wiki/Getting-Started
class HelloWorker
include Shoryuken::Worker
shoryuken_options queue: 'hello', auto_delete: true, body_parser: :json
def perform(sqs_msg, name... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/line-bot-api/1.25/_test/test.rb | Ruby | mit | 301 | main | 4,123 | # Write Ruby code to test the RBS.
# It is type checked by `steep check` command.
require "line-bot-api"
client = Line::Bot::Client.new do |config|
config.channel_id = "sample channel_id"
config.channel_secret = "sample channel_secret"
config.channel_token = "sample channel_token"
config.endpoint = "https://e... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/audited/5.8/_test/test.rb | Ruby | mit | 301 | main | 2,299 | # Write Ruby code to test the RBS.
# It is type checked by `steep check` command.
require 'audited'
class Post < ActiveRecord::Base
extend Audited::Auditor::ClassMethods
extend Audited::Auditor::AuditedClassMethods
include Audited::Auditor::AuditedInstanceMethods
belongs_to :user
audited only: :title, ass... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/stripe/13.0/_test/stripe.rb | Ruby | mit | 301 | main | 888 | Stripe.api_key = 'sk_test_12345'
Stripe.api_version = '2017-06-05'
customer = Stripe::Customer.retrieve('cus_12345')
customer.id
# address
address = customer.address
address.city if address
# charge
charge = Stripe::Charge.retrieve('ch_12345')
a = charge.amount + 1
# refund
refund = Stripe::Refund.create(charge: ch... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/stripe/13.0/_generator/openapi.rb | Ruby | mit | 301 | main | 3,441 | # curl https://raw.githubusercontent.com/stripe/openapi/refs/heads/master/openapi/spec3.yaml | ruby openapi.rb customer
require 'yaml'
spec3 = YAML.safe_load($stdin.read)
class Spec
def initialize(spec, indent:, argv:)
@spec = spec
@indent = indent
@argv = argv
end
def schema(name)
@spec['comp... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/diff-lcs/1.5/_test/test.rb | Ruby | mit | 301 | main | 279 | require 'diff/lcs'
seq1 = %w(a b c e h j l m n p)
seq2 = %w(b c d e f j k l m r s t)
seq3 = 'hoge'
seq4 = 'hoga'
lcs = Diff::LCS.LCS(seq1, seq2)
lcs = Diff::LCS.LCS(seq3, seq4)
diffs = Diff::LCS.diff(seq1, seq2)
diffs = Diff::LCS.diff(seq3, seq4)
Diff::LCS.patch!(seq1, diffs) |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/kaminari-core/1.2/_test/test.rb | Ruby | mit | 301 | main | 1,193 | # Write Ruby code to test the RBS.
# It is type checked by `steep check` command.
require "kaminari-core"
Kaminari.configure do |config|
config.default_per_page = 20
config.max_per_page = 100
config.window = 2
config.outer_window = 0
config.left = 0
config.right = 0
config.page_method_name = :page
con... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/zengin_code/1.0/_test/test.rb | Ruby | mit | 301 | main | 535 | # Write Ruby code to test the RBS.
# It is type checked by `steep check` command.
require "zengin_code"
ZenginCode::Bank.all # => { '0001' => <#ZenginCode::Bank code, name, kana, hira, roma ... >, .... }
bank = ZenginCode::Bank["0001"] or raise
puts bank.code
puts bank.name
puts bank.kana
puts bank.hira
puts bank.r... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/lint_roller/1.1/_test/test.rb | Ruby | mit | 301 | main | 1,056 | # Write Ruby code to test the RBS.
# It is type checked by `steep check` command.
require "lint_roller"
module BananaRoller
class Plugin < LintRoller::Plugin
# `config' is a Hash of options passed to the plugin by the user
def initialize(config = {})
@alternative = config["alternative"] ||= "chocolate... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/openid_connect/2.3/_test/test.rb | Ruby | mit | 301 | main | 1,660 | # Write Ruby code to test the RBS.
# It is type checked by `steep check` command.
require "openid_connect"
# Based on example for Rack::OAuth2::Client (https://gist.github.com/nov/862393)
YOUR_CLIENT_ID = 'client_id'
YOUR_CLIENT_SECRET = 'secret'
YOUR_REDIRECT_URI = 'http://example.com'
YOUR_USERNAME = 'username'
YO... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/ast/2.4/_test/test.rb | Ruby | mit | 301 | main | 842 | require 'ast'
def String!(_) end
def Symbol!(_) end
def Array!(_) end
def Node!(_) end
def Bool!(_) end
# AST::Node
node1 = AST::Node.new(:x)
node2 = AST::Node.new(:x, [:foo, 42])
AST::Node.new(:x, [:foo, 42], { y: 1 })
Array! node1.children
String! node1.hash
Symbol! node1.type
Bool! node1 == node2
Node! node... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/apm_traceable/1.1/_test/test.rb | Ruby | mit | 301 | main | 371 | require 'apm_traceable'
ApmTraceable.configure do |config|
config.adapter = 'stdout'
end
class TracerTestClass
include ApmTraceable::Tracer
extend ApmTraceable::Tracer::ClassMethods
trace_methods :test_trace_method
def test_trace_method
'test'
end
def test_trace_span
trace_span('test_name', o... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/httparty/0.18/_test/test_1.rb | Ruby | mit | 301 | main | 977 | class Foo
include HTTParty
base_uri "reqres.in"
basic_auth "username", "password"
digest_auth "username", "password"
default_timeout 10
open_timeout 10
read_timeout 10
write_timeout 10
debug_output $stderr
headers 'Accept' => 'application/json'
format :json
pem File.read('/home/user/my.pem'), "... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/httparty/0.18/_test/test_2.rb | Ruby | mit | 301 | main | 2,143 | HTTParty.get('http://api.stackexchange.com/2.2/questions', query: {site: 'stackoverflow'})
HTTParty.get('http://api.stackexchange.com/2.2/questions', query: {site: 'stackoverflow'}) { |res| res }
HTTParty.post('https://reqres.in/api/users', query: { "name": "random", "job": "random" })
HTTParty.patch('https://reqres.in... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/concurrent-ruby/1.1/_test/timer_task.rb | Ruby | mit | 301 | main | 1,650 | require 'concurrent-ruby'
# Basic usage
task = Concurrent::TimerTask.new{ puts 'Boom!' }
task.execute
task.execution_interval #=> 60 (default)
task.shutdown #=> true
# Configuring :execution_interval
task = Concurrent::TimerTask.new(execution_interval: 5) do
puts 'Boom!'
end
task.execution_interval #=> 5
# Immedi... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/concurrent-ruby/1.1/_test/executor.rb | Ruby | mit | 301 | main | 319 | require 'concurrent-ruby'
Concurrent.executor(:io).post { p :io }
Concurrent.executor(:fast).post { p :fast }
Concurrent.executor(:immediate).post { p :immediate }
Concurrent.global_io_executor.post { p :io }
Concurrent.global_fast_executor.post { p :fast }
Concurrent.global_immediate_executor.post { p :immediate } |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/concurrent-ruby/1.1/_test/map.rb | Ruby | mit | 301 | main | 477 | require 'concurrent-ruby'
map = Concurrent::Map.new #: Concurrent::Map[Symbol, Integer]
map[:a] = 1
map.fetch(:b) { 2 }
map.fetch(:c, 3)
new_value = map.compute(:a) { |old_value| (old_value || 0) + 1 }
new_value + 2
map.compute(:a) { |_old_value| nil }
new_value = map.compute_if_absent(:absent) { 3 }
new_value + 2
... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/concurrent-ruby/1.1/_test/promises.rb | Ruby | mit | 301 | main | 5,536 | require 'concurrent-ruby'
## Concurrent::Promises::FactoryMethods
p Concurrent::Promises.any_event(
Concurrent::Promises.resolvable_event,
Concurrent::Promises.future { 1 },
).wait.resolved?
p Concurrent::Promises.any_fulfilled_future(
Concurrent::Promises.rejected_future(RuntimeError.new('error')),
Concurre... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/activemerchant/1.89/_test/test.rb | Ruby | mit | 301 | main | 592 | # Write Ruby code to test the RBS.
# It is type checked by `steep check` command.
require "activemerchant"
ActiveMerchant::Billing::CreditCard.brand?("4111111111111111")&.upcase
ActiveMerchant::Billing::CreditCard.new
credit_card = ActiveMerchant::Billing::CreditCard.new(
:first_name => 'Bob',
:last_name... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/google-cloud-ai_platform-v1/1.15/_test/test.rb | Ruby | mit | 301 | main | 1,076 | # frozen_string_literal: true
require "google-cloud-ai_platform-v1"
client = Google::Cloud::AIPlatform::V1::PredictionService::Client.new
Google::Cloud::AIPlatform::V1::PredictionService::Client.new do |config|
config.endpoint = "aiplatform.googleapis.com"
config.timeout = 30.0
end
response = client.generate_co... |
github | ruby/gem_rbs_collection | https://github.com/ruby/gem_rbs_collection | gems/code_ownership/1.39/_test/test.rb | Ruby | mit | 301 | main | 274 | require "code_ownership"
class TestClass
end
CodeOwnership.for_class(TestClass)&.name
CodeOwnership.for_file('/path/to/file.rb')&.name
begin
raise "error"
rescue StandardError => e
CodeOwnership.for_backtrace(e.backtrace)&.name
end
CodeOwnership.for_team('My Team') |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.