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/rails-dom-testing/2.0/_test/test.rb
Ruby
mit
301
main
372
# Write Ruby code to test the RBS. # It is type checked by `steep check` command. require "rails-dom-testing" module Test include Rails::Dom::Testing::Assertions def assert(test, message) raise message unless test end def test_case assert_dom_equal '<a href="http://www.example.com">Apples</a>', '<a h...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/mini_magick/5.0/_test/test.rb
Ruby
mit
301
main
600
require "mini_magick" MiniMagick::Error MiniMagick::Invalid MiniMagick::TimeoutError MiniMagick.imagemagick7? MiniMagick.cli_version MiniMagick.version == "5.0" MiniMagick::Tool.new("mogrify", foo: "FOO") do |mogrify| mogrify.resize "100x100" # steep:ignore mogrify << 1 mogrify.merge!(["-foo", 1, nil]) mogr...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/mini_magick/5.0/_test/readme.rb
Ruby
mit
301
main
4,653
require "mini_magick" ## Usage image = MiniMagick::Image.open("input.jpg") image.path # steep:ignore image.resize "100x100" # steep:ignore image.format "png" # steep:ignore image.write "output.png" # steep:ignore image = MiniMagick::Image.open("http://example.com/image.jpg") image.contrast # steep:ignore image.write...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/mini_magick/4.13/_test/test.rb
Ruby
mit
301
main
285
require "mini_magick" image = MiniMagick::Image.open("input.jpg") # #resize returns self image.resize("100x100").resize("50x50") # #format returns self image.format("png").format("jpg") # Manually define dynamically generated methods image.type image.type("foo").resize("100x100")
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/mini_magick/4.13/_test/readme.rb
Ruby
mit
301
main
2,285
require "mini_magick" image = MiniMagick::Image.open("input.jpg") image.path #=> "/var/folders/k7/6zx6dx6x7ys3rv3srh0nyfj00000gn/T/magick20140921-75881-1yho3zc.jpg" image.resize "100x100" image.format "png" image.write "output.png" image = MiniMagick::Image.open("http://example.com/image.jpg") image.contrast image.wr...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/dotenv-rails/2.8/_test/test.rb
Ruby
mit
301
main
535
# Write Ruby code to test the RBS. # It is type checked by `steep check` command. require 'dotenv' Dotenv.load Dotenv.load('./env_files/file1.env', './env_files/file2.env') Dotenv.load('./env_files/file3.env') Dotenv.load! Dotenv.load!('./env_files/file1.env', './env_files/file2.env') Dotenv.require_keys('KEY1', 'K...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/actionpack/7.2/_test/test.rb
Ruby
mit
301
main
404
class FooController < ActionController::Base allow_browser versions: :modern end class BarController < ActionController::Base allow_browser versions: { safari: 17.5, chrome: 127, ie: false }, block: -> { head :not_acceptable } end ActionController::Base.new.render_to_string(template: 'foo', locals: { bar: 'baz' }...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/geocoder/1.8/_test/models.rb
Ruby
mit
301
main
297
require "active_record" class Venue < ActiveRecord::Base geocoded_by :address end obj = Venue.new obj.distance_to([43.9,-98.6]) # distance from obj to point obj.bearing_to([43.9,-98.6]) # bearing from obj to point obj2 = Venue.new obj.bearing_from(obj2) # bearing from obj2 to obj
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/geocoder/1.8/_test/test_basic_search.rb
Ruby
mit
301
main
314
#Taken from https://github.com/alexreisner/geocoder/tree/v1.8.0 require "geocoder" results = Geocoder.search("Paris") results.first&.coordinates results = Geocoder.search([48.856614, 2.3522219]) results.first&.address results = Geocoder.search("172.56.21.89") results.first&.coordinates results.first&.country
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/graphql/1.12/_test/test.rb
Ruby
mit
301
main
2,882
require "graphql" # generated codes module Types class BaseObject < GraphQL::Schema::Object end class BaseEdge < Types::BaseObject end class BaseConnection < Types::BaseObject include GraphQL::Types::Relay::ConnectionBehaviors end class BaseArgument < GraphQL::Schema::Argument end class BaseField...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/rolify/6.0/_test/test.rb
Ruby
mit
301
main
252
# Write Ruby code to test the RBS. # It is type checked by `steep check` command. require "rolify" class User extend Rolify rolify :before_add => :before_add_method def before_add_method(role) # do something before it gets added end end
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/pundit/2.5/_test/test.rb
Ruby
mit
301
main
617
require "pundit" require "action_controller" class Post end class PostPolicy def initialize(user, record) @user = user @record = record end def update? true end class Scope def initialize(user, scope) @user = user @scope = scope end def resolve @scope end e...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/active_model_serializers/0.10/_test/test.rb
Ruby
mit
301
main
1,489
require "active_model_serializers" module Test class Author < ActiveModelSerializers::Model # @dynamic name, name=, initialize attributes :name end class Category < ActiveModelSerializers::Model # @dynamic name, name=, initialize attributes :name end class Article < ActiveModelSerializers::...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/thor/1.2/_test/test.rb
Ruby
mit
301
main
337
# Write Ruby code to test the RBS. # It is type checked by `steep check` command. require "thor" class CLI < Thor desc "usage", "description" option :message, type: :string, desc: "description", required: false, aliases: "-m", default: "Hello" def example(*args) message = options[:message] end no_comma...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/mysql2/0.5/_test/query.rb
Ruby
mit
301
main
1,094
require "mysql2" as = :array Mysql2::Client.new(as: as).query("SELECT * FROM users").each do |row| if row.is_a?(Array) row[0] # Array elsif row.is_a?(Hash) row[:id] # Hash end end Mysql2::Client.new.query("SELECT * FROM users").each do |row| row[:id] # Hash end Mysql2::Client.new.query("SELECT * FROM...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/mysql2/0.5/_test/new.rb
Ruby
mit
301
main
263
Mysql2::Client.new( host: '127.0.0.1', port: 3306, username: 'user', password: 'password', database: 'database', database_timezone: :local, cast_booleans: true, symbolize_keys: true, reconnect: true, flags: Mysql2::Client::MULTI_STATEMENTS, )
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/mysql2/0.5/_test/row_value_type.rb
Ruby
mit
301
main
2,591
client = Mysql2::Client.new client.query %[ CREATE TABLE IF NOT EXISTS mysql2_test ( id MEDIUMINT NOT NULL AUTO_INCREMENT, null_test VARCHAR(10), bit_test BIT(64), single_bit_test BIT(1), tiny_int_test TINYINT, bool_cast_test TINYINT(1), small_int_test SMALLINT, medium_int_test MEDIUM...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/mysql2/0.5/_test/client.rb
Ruby
mit
301
main
210
client = Mysql2::Client.new client.query("UPDATE users SET age = age + 1 WHERE name = 'John'") if client.affected_rows == 0 puts "No rows were updated" else puts "Updated #{client.affected_rows} rows" end
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/rubocop/1.57/_test/test.rb
Ruby
mit
301
main
1,716
# Test APIs for creating a new cop # ref: https://docs.rubocop.org/rubocop/development.html module RuboCop module Cop class SimplifyNotEmptyWithAny < Base extend TargetRubyVersion minimum_target_ruby_version 2.7 maximum_target_ruby_version 2.6 requires_gem "my-gem", ">= 1.2.3", "< 4.5.6" ...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/httpclient/2.8/_test/test.rb
Ruby
mit
301
main
495
require "httpclient" HTTPClient.get("http://example.com").body client = HTTPClient.new if _ = false client.set_auth("http://example.com", "user", "pass") end res = client.get("http://example.com", query: {"q" => "v"}) if res.status == 200 puts res.body end resnil = client.get("http://example.com") { |chunk| chunk...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/globalid/1.1/_test/test.rb
Ruby
mit
301
main
396
# Write Ruby code to test the RBS. # It is type checked by `steep check` command. require "globalid" GlobalID.app = 'blah' class Person include GlobalID::Identification # @dynamic id, id= attr_accessor :id def self.find(id) new.tap { |obj| obj.id = id } end end person = Person.find(1) person_gid = p...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/parallel/1.20/_test/all.rb
Ruby
mit
301
main
779
Parallel.all?(['a','b','c']) { |item| item.size == 1 } Parallel.all?(['a','b','c'], in_processes: 2) { |item| item.size == 1 } Parallel.all?(['a','b','c'], in_threads: 2) { |item| item.size == 1 } Parallel.all?(['a','b','c'], progress: 'Running...') { |item| item.size == 1 } Parallel.all?(['a','b','c'], start: ->(i...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/parallel/1.20/_test/map.rb
Ruby
mit
301
main
1,209
puts Parallel.map(['a','b','c']) { |item| item * 1 }.at(0) puts Parallel.map(['a','b','c'], in_processes: 2) { |item| item * 2 }.at(0) puts Parallel.map(['a','b','c'], in_threads: 2) { |item| item * 3 }.at(0) puts Parallel.map(['a','b','c'], progress: 'Running...') { |item| item * 4 }.at(0) puts Parallel.map(['a','...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/parallel/1.20/_test/any.rb
Ruby
mit
301
main
779
Parallel.any?(['a','b','c']) { |item| item.size == 1 } Parallel.any?(['a','b','c'], in_processes: 2) { |item| item.size == 1 } Parallel.any?(['a','b','c'], in_threads: 2) { |item| item.size == 1 } Parallel.any?(['a','b','c'], progress: 'Running...') { |item| item.size == 1 } Parallel.any?(['a','b','c'], start: ->(i...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/parallel/1.20/_test/each.rb
Ruby
mit
301
main
1,005
Parallel.each(['a','b','c']) { |item| puts item } Parallel.each(['a','b','c'], in_processes: 2) { |item| puts item * 2 } Parallel.each(['a','b','c'], in_threads: 2) { |item| puts item * 3 } Parallel.each(['a','b','c'], progress: 'Running...') { |item| puts item * 4 } Parallel.each(['a','b','c'], start: ->(item, ind...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/parallel/1.20/_test/control.rb
Ruby
mit
301
main
309
puts Parallel.map([1, 2, 3]) { |x| raise Parallel::Break, x if x == 2 } == 2 puts Parallel.map([1, 2, 3]) { |x| raise Parallel::Break.new(x) if x == 2 } == 2 Parallel.map([1, 2, 3]) do |x| if x == 1 sleep 0.1 puts 'DEAD' raise Parallel::Kill elsif x == 3 sleep 10 else x end end
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/graphlient/0.8/_test/test.rb
Ruby
mit
301
main
990
require "graphlient" client = Graphlient::Client.new('https://test-graphql.biz/graphql', headers: { 'Authorization' => 'Bearer 123' }, http_options: { read_timeout: 20, write_timeout: 30 } ) # simple query response = client.query <<~GRAPHQL query { invoice(id: 10) { id total ...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/simple_oauth/0.3/_test/test.rb
Ruby
mit
301
main
331
require "simple_oauth" params = { status: "Test." } oauth_params = { consumer_key: "consumer_key", consumer_secret: "consumer_secret", token: "access_token", token_secret: "access_token_secret", } auth_header = SimpleOAuth::Header.new(:get, "https://api.twitter.com/1.1/statuses/update.json", params, oauth_pa...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/shrine/3.6/_test/test.rb
Ruby
mit
301
main
808
require "shrine" require "shrine/storage/file_system" Shrine.storages = { cache: Shrine::Storage::FileSystem.new("public", prefix: "uploads/cache"), # temporary store: Shrine::Storage::FileSystem.new("public", prefix: "uploads"), # permanent } Shrine.plugin :activerecord # loads Active Record inte...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/sidekiq/6.2/_test/test_5.rb
Ruby
mit
301
main
581
# Test logging configuration # Taken from: https://github.com/mperham/sidekiq/wiki/Logging class YourWorker include Sidekiq::Worker def perform logger.info "Things are happening." logger.debug "Here's some info: #{hash.inspect}" end end Sidekiq.logger.level = Logger::ERROR Sidekiq.configure_server do |c...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/sidekiq/6.2/_test/test_4.rb
Ruby
mit
301
main
436
# Test advanced configurations # Taken from: https://github.com/mperham/sidekiq/wiki/Advanced-Options class ImportantWorker include Sidekiq::Worker sidekiq_options queue: 'critical', retry: true, dead: true, backtrace: false, tags: ['important', 'test'] def perform puts "Doing critical work" end end Sidek...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/sidekiq/6.2/_test/test_3.rb
Ruby
mit
301
main
1,505
# Test error handling # Taken from: https://github.com/mperham/sidekiq/wiki/Error-Handling Sidekiq.configure_server do |config| config.error_handlers << proc { |ex,ctx_hash| puts "#{ex} exception: #{ctx_hash} context" } end class LessRetryableWorker include Sidekiq::Worker sidekiq_options retry: 5 # Only five ...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/sidekiq/6.2/_test/test_2.rb
Ruby
mit
301
main
1,614
class HardWorker include Sidekiq::Worker end class Hook end class Middleware end HardWorker.perform_async(1, 2, 3) # Test Sidekiq::Client client = Sidekiq::Client.new client.middleware do |chain| chain.add Middleware end Sidekiq::Client.push('class' => HardWorker, 'args' => [1, 2, 3]) Sidekiq::Client.push_bulk(...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/sidekiq/6.2/_test/test_1.rb
Ruby
mit
301
main
225
# Test fundamental APIs # Taken from: https://github.com/mperham/sidekiq/wiki/Getting-Started class HardWorker include Sidekiq::Worker end HardWorker.perform_async('bob', 5) HardWorker.perform_at(Time.now + 5*60, 'bob', 5)
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/sidekiq/6.3/_test/test_4.rb
Ruby
mit
301
main
704
# Test advanced configurations # Taken from: https://github.com/mperham/sidekiq/wiki/Advanced-Options class ImportantWorker include Sidekiq::Worker sidekiq_options queue: 'critical', retry: true, dead: true, backtrace: false, tags: ['important', 'test'] def perform puts "Doing critical work" end end class...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/sidekiq/6.3/_test/test_5.rb
Ruby
mit
301
main
737
# Test logging configuration # Taken from: https://github.com/mperham/sidekiq/wiki/Logging class YourWorker include Sidekiq::Worker def perform logger.info "Things are happening." logger.debug "Here's some info: #{hash.inspect}" end end class YourJob include Sidekiq::Job def perform logger.info...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/sidekiq/6.3/_test/test_1.rb
Ruby
mit
301
main
345
# Test fundamental APIs # Taken from: https://github.com/mperham/sidekiq/wiki/Getting-Started class HardWorker include Sidekiq::Worker end HardWorker.perform_async('bob', 5) HardWorker.perform_at(Time.now + 5*60, 'bob', 5) class HardJob include Sidekiq::Job end HardJob.perform_async('bob', 5) HardJob.perform_at(Ti...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/sidekiq/6.3/_test/test_2.rb
Ruby
mit
301
main
2,136
class HardWorker include Sidekiq::Worker end class HardJob include Sidekiq::Job end class Hook end class Middleware end HardWorker.perform_async(1, 2, 3) HardJob.perform_async(1, 2, 3) # Test Sidekiq::Client client = Sidekiq::Client.new client.middleware do |chain| chain.add Middleware end Sidekiq::Client.pu...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/sidekiq/6.3/_test/test_3.rb
Ruby
mit
301
main
2,611
# Test error handling # Taken from: https://github.com/mperham/sidekiq/wiki/Error-Handling Sidekiq.configure_server do |config| config.error_handlers << proc { |ex,ctx_hash| puts "#{ex} exception: #{ctx_hash} context" } end class LessRetryableWorker include Sidekiq::Worker sidekiq_options retry: 5 # Only five ...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/sidekiq/7.0/_test/test_5.rb
Ruby
mit
301
main
737
# Test logging configuration # Taken from: https://github.com/mperham/sidekiq/wiki/Logging class YourWorker include Sidekiq::Job def perform logger.info "Things are happening." logger.debug "Here's some info: #{hash.inspect}" end end class YourJob include Sidekiq::Job def perform logger.info "T...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/sidekiq/7.0/_test/test_4.rb
Ruby
mit
301
main
698
# Test advanced configurations # Taken from: https://github.com/mperham/sidekiq/wiki/Advanced-Options class ImportantWorker include Sidekiq::Job sidekiq_options queue: 'critical', retry: true, dead: true, backtrace: false, tags: ['important', 'test'] def perform puts "Doing critical work" end end class Im...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/sidekiq/7.0/_test/test_3.rb
Ruby
mit
301
main
2,624
# Test error handling # Taken from: https://github.com/mperham/sidekiq/wiki/Error-Handling Sidekiq.configure_server do |config| config.error_handlers << proc { |ex,ctx_hash| puts "#{ex} exception: #{ctx_hash} context" } end class LessRetryableWorker include Sidekiq::Job sidekiq_options retry: 5 # Only five ret...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/sidekiq/7.0/_test/test_2.rb
Ruby
mit
301
main
2,162
class HardWorker include Sidekiq::Job end class HardJob include Sidekiq::Job end class Hook end class Middleware include Sidekiq::ServerMiddleware end HardWorker.perform_async(1, 2, 3) HardJob.perform_async(1, 2, 3) # Test Sidekiq::Client client = Sidekiq::Client.new client.middleware do |chain| chain.add ...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/sidekiq/7.0/_test/test_1.rb
Ruby
mit
301
main
342
# Test fundamental APIs # Taken from: https://github.com/mperham/sidekiq/wiki/Getting-Started class HardWorker include Sidekiq::Job end HardWorker.perform_async('bob', 5) HardWorker.perform_at(Time.now + 5*60, 'bob', 5) class HardJob include Sidekiq::Job end HardJob.perform_async('bob', 5) HardJob.perform_at(Time....
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/slack-notifier/2.4/_test/test.rb
Ruby
mit
301
main
1,236
# Write Ruby code to test the RBS. # It is type checked by `steep check` command. require "slack-notifier" notifier = Slack::Notifier.new "WEBHOOK_URL", channel: "#default", username: "notifier" notifier.ping "Hello default" notifier.ping "Hello random", channel: "#random" class NoOpHTTPClient def self.post(uri...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/moneta/1.6/_test/test.rb
Ruby
mit
301
main
1,516
require "moneta" # @type var key_transformer: ::Moneta::_KeyValueTransformer key_transformer = _ = Moneta.new(:File, dir: "data") key_transformer.key?("key") key_transformer.each_key { |key| key } key_transformer.increment("key", 1, { expires: false }) key_transformer.load("key") key_transformer.store("key", 34, expir...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/rubyXL/3.4/_test/test.rb
Ruby
mit
301
main
967
require "rubyXL" require "rubyXL/convenience_methods" workbook = RubyXL::Workbook.new worksheets = workbook.worksheets worksheet = worksheets[0] new_sheet = workbook.add_worksheet("Sheet2") new_sheet.sheet_name = "Renamed Sheet" name = new_sheet.sheet_name sheet_by_index = workbook[0] sheet_by_name = workbook["Shee...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/protobuf/3.10.3/_test/messages.rb
Ruby
mit
301
main
368
module Messages user = User.new user.field?(:first_name) user.field?(:address) user.field?(:last_name) user.respond_to_has_and_present?(:last_name) user.encode user.encode_to(STDERR) user.encode_to([]) user.encode_to(30) User.decode("") User.decode_from(STDIN) User.decode_from("") user.to_...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/protobuf/3.10.3/_test/enum.rb
Ruby
mit
301
main
208
module Enum States::ALABAMA States::ALABAMA.to_i States::ALABAMA.tag States::ALABAMA.name States.fetch(1).___error___ States.fetch(0) States.enums.___error___ States.all_tags.___error___ end
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/rest-client/2.1/_test/test.rb
Ruby
mit
301
main
1,632
# Write Ruby code to test the RBS. # It is type checked by `steep check` command. require "rest-client" RestClient.get 'http://example.com/resource' RestClient.get 'http://example.com/resource', {params: {id: 50, 'foo' => 'bar'}} RestClient.get 'https://user:password@example.com/private/resource', {accept: :json} ...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/regexp_parser/2.8/_test/test.rb
Ruby
mit
301
main
332
# Write Ruby code to test the RBS. # It is type checked by `steep check` command. require "regexp_parser" regex = /a?(b+(c)d)*(?<name>[0-9]+)/i Regexp::Parser.parse(regex, 'ruby/2.1') do |token| puts token.inspect end Regexp::Parser.parse( 'a+ # Recognizes a and A...', options: ::Regexp::EXTENDED | ::Regexp::IG...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/mime-types/3.5/_test/test_mime_types.rb
Ruby
mit
301
main
1,499
# Taken from https://github.com/mime-types/ruby-mime-types/blob/v3.5.0/lib/mime/types.rb#L51-L66 require 'mime/types' plaintext = MIME::Types['text/plain'].first puts plaintext&.media_type # => 'text' puts plaintext&.sub_type # => 'plain' puts plaintext&.extensions&.join(" ") # => 'asc txt c c...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/mime-types/3.5/_test/test_mime_type.rb
Ruby
mit
301
main
2,387
# Taken from https://github.com/mime-types/ruby-mime-types/blob/v3.5.0/lib/mime/type.rb#L10-L66 require 'mime/types' plaintext = MIME::Types['text/plain'] # => [ text/plain ] text = plaintext.first puts text&.media_type # => 'text' puts text&.sub_type # => 'plain' puts text&.extensions&.join...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/sentry-ruby/5.2/_test/test_rack.rb
Ruby
mit
301
main
466
require 'sentry-ruby' Sentry.init do |config| config.dsn = 'https://examplePublicKey@o0.ingest.sentry.io/0' config.breadcrumbs_logger = [:sentry_logger, :http_logger] config.traces_sample_rate = 0.5 end class FooMiddleware def initialize(app) @app = app end def call(env) Sentry.capture_message(...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/sentry-ruby/5.2/_test/test.rb
Ruby
mit
301
main
1,115
# Write Ruby code to test the RBS. # It is type checked by `steep check` command. require "sentry-ruby" Sentry.init do |config| config.dsn = 'https://examplePublicKey@o0.ingest.sentry.io/0' config.breadcrumbs_logger = [:active_support_logger, :http_logger] config.traces_sample_rate = 0.5 end begin 1 / 0 res...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/abbrev/0.1/_test/test.rb
Ruby
mit
301
main
243
# Write Ruby code to test the RBS. # It is type checked by `steep check` command. require "abbrev" Abbrev.abbrev([]) Abbrev.abbrev(%w(abbrev)) Abbrev.abbrev(%w(abbrev), 'abb') Abbrev.abbrev(%w(abbrev), /^abb/) Abbrev.abbrev(%w(abbrev), nil)
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/recaptcha/5.15/_test/test.rb
Ruby
mit
301
main
406
# Write Ruby code to test the RBS. # It is type checked by `steep check` command. require "recaptcha" require "action_controller" require "active_record" class User < ActiveRecord::Base end class UsersController < ActionController::Base def create @user = User.new(**params) if verify_recaptcha(model: @user...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/marcel/1.0/_test/test.rb
Ruby
mit
301
main
782
require "marcel" require "pathname" require "stringio" # Magic bytes sniffing alone Marcel::MimeType.for Pathname.new("example.gif") # => "image/gif" File.open "example.gif" do |file| Marcel::MimeType.for file end # => "image/gif" # Magic bytes with filename fallback Marcel::MimeType.for Pathname.new("unrecognis...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/active_type/2.6/_test/test.rb
Ruby
mit
301
main
1,369
require "active_record" require "active_type" class SignIn < ActiveType::Object attribute :username, :string attribute :password, :string validates :username, presence: true validates :password, presence: true before_save :before_save_callback after_save :after_save_callback private def before_save...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/chartkick/5.0/_test/test.rb
Ruby
mit
301
main
839
# Write Ruby code to test the RBS. # It is type checked by `steep check` command. require "chartkick" module Example include ChartKick::Helper def example data = [ ["Washington", "1789-04-29", "1797-03-03"], ["Adams", "1797-03-03", "1801-03-03"], ["Jefferson", "1801-03-03", "1809-03-03"] ...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/sinatra/4.0/_test/test.rb
Ruby
mit
301
main
1,053
require "sinatra/base" require "sinatra/json" require "sinatra/cookies" class MyApp < Sinatra::Base enable :logging set :sessions, domain: 'example.dev', path: '/', expire_after: 1000*60 helpers Sinatra::Cookies configure :development do require 'sinatra/reloader' register Sinatra::Reloader end cl...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/woothee/1.11/_test/test.rb
Ruby
mit
301
main
481
# Write Ruby code to test the RBS. # It is type checked by `steep check` command. require "woothee" result = Woothee.parse("Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0)") result[:name] # => "Internet Explorer" result[:category] # => :pc result[:os] # => "Windows 7" result[:os_version] # => "NT 6.1...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/i18n/1.10/_test/test.rb
Ruby
mit
301
main
797
# Write Ruby code to test the RBS. # It is type checked by `steep check` command. require "i18n" I18n.load_path << Dir[File.expand_path("config/locales") + "/*.yml"] I18n.config.available_locales = [:en, :ja] I18n.default_locale = :en I18n.reload! puts I18n.default_locale #=> en pp I18n.available_locales #=>[:en, ...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/chunky_png/1.4.0/_test/test_3.rb
Ruby
mit
301
main
628
# Operations - Manipulating images image = ChunkyPNG::Image.from_file('filename.png') new_image = ChunkyPNG::Canvas.from_canvas(image) image[0, 0] = ChunkyPNG::Color.rgba(255, 0,0, 128) image.line(1, 1, 10, 1, ChunkyPNG::Color.from_hex('#aa007f')) image.flip_horizontally!.rotate_right! image.compose(ChunkyPNG::Image.ne...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/chunky_png/1.4.0/_test/test_2.rb
Ruby
mit
301
main
380
# Loading Data - Datastream/StreamImport image = ChunkyPNG::Image.from_rgba_stream(128, 128, File.read('pixeldata.rgba')) image = ChunkyPNG::Image.from_rgb_stream(128, 128, File.read('pixeldata.rgb')) image = ChunkyPNG::Image.from_file('file.png') File.open('file.png', 'rb') { |io| image = ChunkyPNG::Image.from_io(io) ...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/chunky_png/1.4.0/_test/test_1.rb
Ruby
mit
301
main
371
# Basic API usage - Color, Dimension png = ChunkyPNG::Image.new(128, 128, ChunkyPNG::Color::TRANSPARENT) png[1, 1] = ChunkyPNG::Color.rgba(10, 20, 30, 128) png[2, 1] = ChunkyPNG::Color('black @ 0.5') png[3, 1] = ChunkyPNG::Color.rgb(255, 0, 128) png.metadata['title'] = 'Test image' puts png.metadata['title'] puts png.d...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/chunky_png/1.4.0/_test/test_5.rb
Ruby
mit
301
main
577
png = ChunkyPNG::Image.new(128, 128, ChunkyPNG::Color::TRANSPARENT) datastream = png.to_datastream datastream.chunks.map { |x| x.type } datastream.each_chunk { |chunk| chunk } # Snippet taken from Gem's GitHub Wiki image = ChunkyPNG::Image.from_file('clock.png') image.change_theme_color!(ChunkyPNG::Color.from_hex('#bb...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/chunky_png/1.4.0/_test/test_4.rb
Ruby
mit
301
main
352
image = ChunkyPNG::Image.from_rgba_stream(128, 128, File.read('pixeldata.rgba')) # or image.save('filename.png', :best_compression) File.open('newfile.png', 'wb' ) { |io| image.write(io) } png_data = image.to_blob(:fast_rgba) image.save('filename.png', :color_mode => ChunkyPNG::COLOR_INDEXED, :compression => Zlib::NO_C...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/ancestry/4.3/_test/test.rb
Ruby
mit
301
main
2,699
require 'ancestry' Ancestry.default_ancestry_format = :materialized_path2 Ancestry.default_ancestry_format Ancestry.default_update_strategy = :sql Ancestry.default_update_strategy Ancestry.default_primary_key_format = '[-A-Fa-f0-9]{36}' Ancestry.default_primary_key_format class Directory < ActiveRecord::Base has_an...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/operator_recordable/2.0/_test/test.rb
Ruby
mit
301
main
425
# Write Ruby code to test the RBS. # It is type checked by `steep check` command. require "operator_recordable" require "active_record" class ApplicationRecord < ActiveRecord::Base self.abstract_class = true include OperatorRecordable::Extension end class Post < ApplicationRecord record_operator_on :create, :...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/minitest/5.25/_test/test.rb
Ruby
mit
301
main
253
# Write Ruby code to test the RBS. # It is type checked by `steep check` command. require "minitest" Minitest.clock_time Minitest.filter_backtrace(caller) Minitest.process_args Minitest.load_plugins Minitest.init_plugins({}) Minitest.after_run do end
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/retryable/3.0/_test/test.rb
Ruby
mit
301
main
2,272
require "retryable" Retryable.retryable(tries: 0) str = Retryable.retryable do "foo" end str&.ascii_only? Retryable.retryable do |retries, exception| retries.bit_length exception&.backtrace end Retryable.retryable( ensure: ->(retries) { # @type var retries: Integer retries.bit_length }, exceptio...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/cancancan/3.5/_test/test.rb
Ruby
mit
301
main
633
# Write Ruby code to test the RBS. # It is type checked by `steep check` command. require "cancancan" require "active_record" class Post < ActiveRecord::Base end class Ability include CanCan::Ability def initialize(user) can :read, Post, public: true return unless user.present? # additional permission...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/webmock/3.19/_test/test.rb
Ruby
mit
301
main
241
require "webmock" WebMock::VERSION + WebMock.version WebMock.enable! WebMock.enable! except: 'hello' WebMock.enable! except: ['hello', 'world'] WebMock.disable! WebMock.disable! except: 'hello' WebMock.disable! except: ['hello', 'world']
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/wavedash/0.1/_test/test.rb
Ruby
mit
301
main
264
# Write Ruby code to test the RBS. # It is type checked by `steep check` command. require "wavedash" str = "こんにちは\u{301C}" Wavedash.destination_encoding = 'eucjp-ms' Wavedash.normalize(str) # => "こんにちは~" Wavedash.invalid?(str) # => true
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/rack-oauth2/2.2/_test/test.rb
Ruby
mit
301
main
1,492
# Write Ruby code to test the RBS. # It is type checked by `steep check` command. require "rack-oauth2" YOUR_CLIENT_ID = 'client_id' YOUR_CLIENT_SECRET = 'secret' YOUR_REDIRECT_URI = 'http://example.com' YOUR_USERNAME = 'username' YOUR_PASSWORD = 'password' YOUR_AUTHORIZATION_CODE = '1234' YOUR_REFRESH_TOKEN_FOR_USER...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/business_time/0.13/_test/test.rb
Ruby
mit
301
main
4,104
require "business_time" # try these examples, using the current time: 1.business_hour.from_now 4.business_hours.from_now 8.business_hours.from_now 1.business_hour.ago 4.business_hours.ago 8.business_hours.ago 1.business_day.from_now 4.business_days.from_now 8.business_days.from_now 1.business_day.ago 4.business_da...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/faker/3.4.2/_test/test.rb
Ruby
mit
301
main
1,185
require "faker" Faker::Lorem.sentence(exclude_words: 'error') + 'string' Faker::Lorem.sentence(exclude_words: 'id, error') + 'string' Faker::Lorem.sentence(exclude_words: ['id', 'error']) + 'string' Faker::Lorem.paragraph(exclude_words: 'error') + 'string' Faker::Lorem.paragraph(exclude_words: 'id, error') + 'string' ...
github
ruby/gem_rbs_collection
https://github.com/ruby/gem_rbs_collection
gems/faker/2.23/_test/test.rb
Ruby
mit
301
main
3,599
# Write Ruby code to test the RBS. # It is type checked by `steep check` command. require "faker" # https://github.com/faker-ruby/faker/blob/v2.23.0/doc/default/alphanumeric.md Faker::Alphanumeric.alpha(number: 10) + 'string' Faker::Alphanumeric.alphanumeric(number: 10) + 'string' Faker::Alphanumeric.alphanumeric(num...
github
discourse/discourse_api
https://github.com/discourse/discourse_api
Rakefile
Ruby
mit
301
main
251
# frozen_string_literal: true require 'bundler/gem_tasks' require 'rspec/core/rake_task' RSpec::Core::RakeTask.new(:spec) require 'rubocop/rake_task' RuboCop::RakeTask.new(:rubocop) task test: :spec task lint: :rubocop task default: [:spec, :lint]
github
discourse/discourse_api
https://github.com/discourse/discourse_api
discourse_api.gemspec
Ruby
mit
301
main
1,710
# frozen_string_literal: true lib = File.expand_path("lib", __dir__) $LOAD_PATH.unshift(lib) if !$LOAD_PATH.include?(lib) require "discourse_api/version" Gem::Specification.new do |spec| spec.name = "discourse_api" spec.version = DiscourseApi::VERSION spec.authors = ["Sam Saffron", "John Paul Ashenfelter", "Mic...
github
discourse/discourse_api
https://github.com/discourse/discourse_api
lib/discourse_api.rb
Ruby
mit
301
main
236
# frozen_string_literal: true require "discourse_api/api/params" require "discourse_api/client" require "discourse_api/error" require "discourse_api/version" require "discourse_api/example_helper" require "discourse_api/single_sign_on"
github
discourse/discourse_api
https://github.com/discourse/discourse_api
lib/discourse_api/client.rb
Ruby
mit
301
main
5,691
# frozen_string_literal: true require "faraday" require "faraday/follow_redirects" require "faraday/multipart" require "json" require "uri" require "discourse_api/version" require "discourse_api/api/categories" require "discourse_api/api/search" require "discourse_api/api/sso" require "discourse_api/api/tags" require "...
github
discourse/discourse_api
https://github.com/discourse/discourse_api
lib/discourse_api/example_helper.rb
Ruby
mit
301
main
344
# frozen_string_literal: true require "yaml" module DiscourseApi class ExampleHelper def self.load_yml config_yml = File.expand_path("../../../config.yml", __FILE__) puts config_yml begin config = YAML.load_file config_yml rescue Errno::ENOENT config = {} end c...
github
discourse/discourse_api
https://github.com/discourse/discourse_api
lib/discourse_api/error.rb
Ruby
mit
301
main
821
# frozen_string_literal: true module DiscourseApi class DiscourseError < StandardError attr_reader :response def initialize(message, response = nil) super(message) @response = response end end class Error < DiscourseError attr_reader :wrapped_exception # Initializes a new Error ...
github
discourse/discourse_api
https://github.com/discourse/discourse_api
lib/discourse_api/single_sign_on.rb
Ruby
mit
301
main
4,496
# frozen_string_literal: true require "base64" require "rack" require "openssl" module DiscourseApi class SingleSignOn class ParseError < RuntimeError end class MissingConfigError < RuntimeError end ACCESSORS = %i[ add_groups admin avatar_force_update avatar_url bio...
github
discourse/discourse_api
https://github.com/discourse/discourse_api
lib/discourse_api/api/uploads.rb
Ruby
mit
301
main
345
# frozen_string_literal: true module DiscourseApi module API module Uploads def upload_file(args) args = API .params(args) .optional(:file, :url, :user_id) .default(type: "composer", synchronous: true) .to_h post("/uploads", args) ...
github
discourse/discourse_api
https://github.com/discourse/discourse_api
lib/discourse_api/api/posts.rb
Ruby
mit
301
main
1,379
# frozen_string_literal: true module DiscourseApi module API module Posts def create_post(args) args = API.params(args).required(:topic_id, :raw).optional(:created_at, :api_username) post("/posts", args) end def create_post_action(args) args = API.params(args).required(:...
github
discourse/discourse_api
https://github.com/discourse/discourse_api
lib/discourse_api/api/badges.rb
Ruby
mit
301
main
1,015
# frozen_string_literal: true module DiscourseApi module API module Badges def badges response = get("/admin/badges.json") response.body end def user_badges(username) response = get("/user-badges/#{username}.json") response.body["badges"] end def gra...
github
discourse/discourse_api
https://github.com/discourse/discourse_api
lib/discourse_api/api/polls.rb
Ruby
mit
301
main
726
# frozen_string_literal: true module DiscourseApi module API module Polls def poll_vote(args) args = API.params(args).required(:post_id, :poll_name, :options).optional(:created_at) put("/polls/vote", args) end def toggle_poll_status(args) args = API ...
github
discourse/discourse_api
https://github.com/discourse/discourse_api
lib/discourse_api/api/site_settings.rb
Ruby
mit
301
main
354
# frozen_string_literal: true module DiscourseApi module API module SiteSettings def site_setting_update(args = {}) params = API.params(args).required(:name, :value).to_h new_site_setting = { params[:name] => params[:value] } put("/admin/site_settings/#{params[:name]}", new_site_set...
github
discourse/discourse_api
https://github.com/discourse/discourse_api
lib/discourse_api/api/params.rb
Ruby
mit
301
main
1,018
# frozen_string_literal: true module DiscourseApi module API def self.params(args) Params.new(args) end class Params def initialize(args) raise ArgumentError.new("Required to be initialized with a Hash") unless args.is_a? Hash @args = args @required = [] @optio...
github
discourse/discourse_api
https://github.com/discourse/discourse_api
lib/discourse_api/api/email.rb
Ruby
mit
301
main
315
# frozen_string_literal: true module DiscourseApi module API module Email def email_settings response = get("/admin/email.json") response.body end def list_email(filter) response = get("/admin/email/#{filter}.json") response.body end end end end
github
discourse/discourse_api
https://github.com/discourse/discourse_api
lib/discourse_api/api/api_key.rb
Ruby
mit
301
main
591
# frozen_string_literal: true module DiscourseApi module API module ApiKey def list_api_keys response = get("/admin/api/keys") response[:body] end def create_api_key(args) args = API.params(args).required(:key).to_h post("/admin/api/keys", args) end ...
github
discourse/discourse_api
https://github.com/discourse/discourse_api
lib/discourse_api/api/search.rb
Ruby
mit
301
main
722
# frozen_string_literal: true module DiscourseApi module API module Search # Returns search results that match the specified term. # # @param term [String] a search term # @param options [Hash] A customizable set of options # @option options [String] :type_filter Returns results of t...
github
discourse/discourse_api
https://github.com/discourse/discourse_api
lib/discourse_api/api/invite.rb
Ruby
mit
301
main
2,051
# frozen_string_literal: true module DiscourseApi module API module Invite def invite_user(params = {}) args = API .params(params) .optional( :email, :skip_email, :custom_message, :max_redemptions_allowed, ...
github
discourse/discourse_api
https://github.com/discourse/discourse_api
lib/discourse_api/api/groups.rb
Ruby
mit
301
main
4,362
# frozen_string_literal: true module DiscourseApi module API module Groups def create_group(args) args = API .params(args) .required(:name) .default(visibility_level: 0) .optional( :mentionable_level, :messageable_...
github
discourse/discourse_api
https://github.com/discourse/discourse_api
lib/discourse_api/api/private_messages.rb
Ruby
mit
301
main
1,187
# frozen_string_literal: true module DiscourseApi module API module PrivateMessages # TODO: Deprecated. Remove after 20220628 def create_private_message(args = {}) deprecated(__method__, "create_pm") args[:target_recipients] = args.delete :target_usernames create_pm(args.to_h) ...
github
discourse/discourse_api
https://github.com/discourse/discourse_api
lib/discourse_api/api/notifications.rb
Ruby
mit
301
main
323
# frozen_string_literal: true module DiscourseApi module API module Notifications def notifications(params = {}) params = API.params(params).optional(:username, :recent, :limit, :offset, :filter) response = get("/notifications.json", params) response[:body] end end end e...
github
discourse/discourse_api
https://github.com/discourse/discourse_api
lib/discourse_api/api/topics.rb
Ruby
mit
301
main
3,735
# frozen_string_literal: true module DiscourseApi module API module Topics # :category OPTIONAL name of category, not ID # :skip_validations OPTIONAL boolean # :auto_track OPTIONAL boolean # :created_at OPTIONAL seconds since epoch. def create_topic(args = {}) args = ...