Top Level Namespace

Defined Under Namespace

Modules: ActiveModel, ActiveRecord, ActiveSupport, Arel, Authpb, BasicTest, Builder, CaptureSubprocessIO, CaptureWarnings, CodeRay, Concurrent, Cucumber, DateAndTime, Diff, Digest, Enumerable, Errno, Etcdserverpb, FFI, FileUtils, Foo, GRPC, GetText, Gherkin, GlobalModule, Google, Grpc, Helpers, I18n, INotify, Inotify, Kernel, LateKernel, LateObject, LibC, LibXML, Listen, M, MIME, Math, MethodSource, Minitest, MultiJson, MultiTest, Mustermann, Mvccpb, MyModule, NATS, OTNetstring, PG, PTY, Pg, Postgres, RDoc, RSpec, RSpecHelpers, Rack, Rake, RubyLogger, RubyPitaya, SecureRandom, Sinatra, Singleton, Spec, StdoutLogger, StressTest, Sys, TZInfo, TaskExtension, Tilt, V3lockpb, WEBrick, WalShipper Classes: AnError, AppInitializer, Args, Array, AssertionError, BasicObject, Benchmark, BetterError, BidiService, BigDecimal, BlankSlate, BlockingEnumerator, Calculator, CheckCallAfterFinishedService, Class, ConfigureTarget, ConnectionPool, CreatePlayerMigration, CreateUserMigration, Date, DateTime, DebugIsTruncated, DebugMessageTestService, Delegator, DummyTestClass, ERB, EchoMsg, EchoService, EmptyService, EncodeDecodeMsg, EnumeratorQueue, ErrorHandler, Etcdv3, ExampleA, ExampleB, Exception, Exhibit, FSEvent, FailingService, FakeAssets, FakeNamedTest, FalseClass, FfiGemHelper, Fibber, File, Fixnum, Float, FullDuplexEnumerator, GeneratedCodeTest, GoodMsg, GoogleRpcStatusTestService, Hash, HelloWorldHandler, Hoe, IO, IPAddr, Integer, LoadError, MetaMetaMetaTestCase, Method, MiniSpecA, MiniSpecB, MiniSpecC, MockExpectationError, Module, NameError, NamedExampleA, NamedExampleB, NamedExampleC, NamedTests, NilClass, NoProto, NoProtoMsg, NoProtoService, NoRpcImplementation, NoStatusDetailsBinTestService, Numeric, Object, OpenStruct, PGMonitor, PGWarehouse, Pathname, Person, PingPongPlayer, Player, PlayerBLL, PlayerHandler, Proc, Pry, Range, Redis, RedisClient, Regexp, ReportAPISpy, Routes, RpcConfig, Runnable, SlowService, SslTestService, Stats, StatsPerMethod, StatusCodes, String, Struct, SubThingySpec, Symbol, SynchronizedCancellationService, TestAttributeEscaping, TestBlankSlate, TestClientInterceptor, TestDeclarations, TestEvents, TestHoeTest, TestIndentedXmlMarkup, TestMarkup, TestMeta, TestMetaStatic, TestMethodCaching, TestMinitestAssertionHelpers, TestMinitestAssertions, TestMinitestBenchmark, TestMinitestGuard, TestMinitestMock, TestMinitestReporter, TestMinitestRunnable, TestMinitestRunner, TestMinitestStub, TestMinitestTest, TestMinitestUnit, TestMinitestUnitInherited, TestMinitestUnitOrder, TestMinitestUnitRecording, TestMinitestUnitTestCase, TestNameCollisions, TestNameSpaces, TestServerInterceptor, TestSpecInTestCase, TestSpecialMarkup, TestTarget, TestXmlEscaping, ThingySpec, Time, Timeval, TrueClass, UnboundMethod, User, UserAgentEchoService, ValueMonadTest, Work, WriteFlagSettingStreamingInputEnumerable

Constant Summary collapse

FileList =

:stopdoc:

Some top level Constants.

Rake::FileList
RakeFileUtils =
Rake::FileUtilsExt
SAMPLE_WRITE_DATA =
'some sample data'
SAMPLE_EXPORT_NAME =
'lowrite.txt'
TIMEOUT =

This is a example of how to mix and match synchronous and async APIs. In this case, the connection to the server is made syncrhonously, and then queries are asynchronous.

5.0
CLEAN =
CLOBBER =
::Rake::FileList.new
CONN_OPTS =

seconds to wait for an async operation to complete

{
	:host     => 'localhost',
	:dbname   => 'test',
}
TRIGGER_TABLE =
%{
	CREATE TABLE IF NOT EXISTS test ( message text );
}
TRIGGER_FUNCTION =
%{
CREATE OR REPLACE FUNCTION notify_test()
RETURNS TRIGGER
LANGUAGE plpgsql
AS $$
    BEGIN
        NOTIFY woo;
        RETURN NULL;
    END
$$
}
DROP_TRIGGER =
%{
DROP TRIGGER IF EXISTS notify_trigger ON test
}
TRIGGER =
%{
CREATE TRIGGER notify_trigger
AFTER UPDATE OR INSERT OR DELETE
ON test
FOR EACH STATEMENT
EXECUTE PROCEDURE notify_test();
}
CONFIG_DIR =
Pathname.new( __FILE__ ).dirname.parent + 'etc'
CONFIG =
CONFIG_DIR + 'wal_shipper.conf'
FSEVENT_WATCH_EXE_VERSION =
'0.1.5'
SRC =
Pathname.glob("#{$src_dir}/*.c")
OBJ =
SRC.map {|s| $obj_dir.join("#{s.basename('.c')}.o")}
MiniTest =
Minitest
PGHOST =

-*- ruby -*-

'localhost'
PGDB =
'test'
SOCKHOST =

SOCKHOST = ‘github.com’

'it-trac.laika.com'
SCRIPT_VERSION =
%q$Id$
MyLambda =

This is a comment for MyLambda

lambda { :lambda }
MyProc =
Proc.new { :proc }
TIME =
(ENV["BENCHMARK_TIME"] || 20).to_i
RECORDS =
(ENV["BENCHMARK_RECORDS"] || TIME * 1000).to_i
MUTEX =
Mutex.new
AUTH_ENV =
Google::Auth::CredentialsLoader::ENV_VAR
STUB6 =
Server =
GRPC::Core::Server
NoProtoStub =
NoProtoService.rpc_stub_class
UserAgentEchoServiceStub =
UserAgentEchoService.rpc_stub_class
SomeError =
Class.new Exception
SslTestServiceStub =
SslTestService.rpc_stub_class
EchoStub =
EchoService.rpc_stub_class
TimeConsts =
GRPC::Core::TimeConsts
TEST_DEBUG_MESSAGE =
'raised by test server'.freeze
DebugMessageTestServiceStub =
DebugMessageTestService.rpc_stub_class
GenericService =
GRPC::GenericService
Dsl =
GenericService::Dsl
FailingStub =
FailingService.rpc_stub_class
SlowStub =
SlowService.rpc_stub_class
SynchronizedCancellationStub =
SynchronizedCancellationService.rpc_stub_class
CheckCallAfterFinishedServiceStub =
CheckCallAfterFinishedService.rpc_stub_class
BidiStub =
BidiService.rpc_stub_class
HashWithIndifferentAccess =

:stopdoc:

ActiveSupport::HashWithIndifferentAccess
GoogleRpcStatusTestStub =
GoogleRpcStatusTestService.rpc_stub_class
NoStatusDetailsBinTestServiceStub =
NoStatusDetailsBinTestService.rpc_stub_class

Constants included from Rake::FileUtilsExt

Rake::FileUtilsExt::DEFAULT

Constants included from FileUtils

FileUtils::LN_SUPPORTED, FileUtils::RUBY

Constants included from GRPC::Spec::Helpers

GRPC::Spec::Helpers::RpcServer

Constants included from GRPC::Core::StatusCodes

GRPC::Core::StatusCodes::ABORTED, GRPC::Core::StatusCodes::ALREADY_EXISTS, GRPC::Core::StatusCodes::CANCELLED, GRPC::Core::StatusCodes::DATA_LOSS, GRPC::Core::StatusCodes::DEADLINE_EXCEEDED, GRPC::Core::StatusCodes::FAILED_PRECONDITION, GRPC::Core::StatusCodes::INTERNAL, GRPC::Core::StatusCodes::INVALID_ARGUMENT, GRPC::Core::StatusCodes::NOT_FOUND, GRPC::Core::StatusCodes::OK, GRPC::Core::StatusCodes::OUT_OF_RANGE, GRPC::Core::StatusCodes::PERMISSION_DENIED, GRPC::Core::StatusCodes::RESOURCE_EXHAUSTED, GRPC::Core::StatusCodes::UNAUTHENTICATED, GRPC::Core::StatusCodes::UNAVAILABLE, GRPC::Core::StatusCodes::UNIMPLEMENTED, GRPC::Core::StatusCodes::UNKNOWN

Constants included from Builder

Builder::BlankSlate, Builder::VERSION, Builder::VERSION_NUMBERS

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Sinatra::Delegator

delegate

Methods included from Rake::FileUtilsExt

#nowrite, #rake_check_options, #rake_output_message, #verbose, #when_writing

Methods included from FileUtils

#ruby, #safe_ln, #sh, #split_all

Methods included from Cucumber::Glue::Dsl

After, AfterAll, AfterStep, Around, Before, BeforeAll, InstallPlugin, ParameterType, World, alias_adverb, build_rb_world_factory, define_parameter_type, if_nil, register_rb_hook, register_rb_step_definition, register_rb_step_definition

Methods included from RSpec::Mocks::ExampleMethods

allow, allow_any_instance_of, allow_message_expectations_on_nil, class_double, class_spy, declare_double, declare_verifying_double, double, expect, expect_any_instance_of, extended, have_received, hide_const, included, instance_double, instance_spy, object_double, object_spy, receive, receive_message_chain, receive_messages, spy, stub_const, without_partial_double_verification

Methods included from RSpec::Mocks::ArgumentMatchers

#any_args, #anything, anythingize_lonely_keys, #array_including, #boolean, #duck_type, #hash_excluding, #hash_including, #instance_of, #kind_of, #no_args

Methods included from GRPC::Spec::Helpers

#build_insecure_stub, #build_rpc_server, #new_core_server_for_testing, #new_rpc_server_for_testing, #run_services_on_server, #update_server_args_hash

Methods included from GRPC::Core::TimeConsts

from_relative_time

Methods included from GlobalModule

#global_inclusion

Methods included from Builder

check_for_name_collision

Class Method Details

.assert(value) ⇒ Object



30
31
32
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/mustermann-3.0.0/bench/capturing.rb', line 30

def self.assert(value)
  fail unless value
end

.helloObject



18
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/method_source-1.0.0/spec/spec_helper.rb', line 18

def $o.hello; :hello_singleton; end

Instance Method Details

#_check_args(args) ⇒ Object



751
752
753
754
755
756
757
758
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/grpc-1.50.0-x86_64-linux/src/ruby/pb/test/client.rb', line 751

def _check_args(args)
  %w(server_host server_port test_case).each do |a|
    if args[a].nil?
      fail(OptionParser::MissingArgument, "please specify --#{a}")
    end
  end
  args
end

#as_null_objectObject

Note:

This is only available when you have enabled the ‘should` syntax.

Tells the object to respond to all messages. If specific stub values are declared, they’ll work as expected. If not, the receiver is returned.



# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/syntax.rb', line 283

#assert(msg = 'unknown cause') ⇒ Object

Fails with AssertionError if the block does evaluate to true



66
67
68
69
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/grpc-1.50.0-x86_64-linux/src/ruby/pb/test/client.rb', line 66

def assert(msg = 'unknown cause')
  fail 'No assertion block provided' unless block_given?
  fail AssertionError, msg unless yield
end

#camelize(lower_case_and_underscored_word) ⇒ Object

-*- ruby -*-



3
4
5
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/pg-1.4.5/ext/errorcodes.rb', line 3

def camelize(lower_case_and_underscored_word)
	lower_case_and_underscored_word.to_s.gsub(/\/(.?)/) { "::" + $1.upcase }.gsub(/(^|_)(.)/) { $2.upcase }
end

#can_run_codegen_checkObject



21
22
23
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/grpc-1.50.0-x86_64-linux/src/ruby/spec/pb/health/checker_spec.rb', line 21

def can_run_codegen_check
  system('which grpc_ruby_plugin') && system('which protoc')
end

#check_connection(conn) ⇒ Object

This is a minimal example of a function that can test an existing PG::Connection and reset it if necessary.



10
11
12
13
14
15
16
17
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/pg-1.4.5/sample/check_conn.rb', line 10

def check_connection( conn )
	begin
		conn.exec( "SELECT 1" )
	rescue PG::Error => err
		$stderr.puts "%p while testing connection: %s" % [ err.class, err.message ]
		conn.reset
	end
end

#check_md(wanted_md, received_md) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/grpc-1.50.0-x86_64-linux/src/ruby/spec/generic/rpc_server_spec.rb', line 22

def check_md(wanted_md, received_md)
  wanted_md.zip(received_md).each do |w, r|
    w.each do |key, value|
      expect(r[key]).to eq(value)
    end
  end
end

#check_op_view_of_finished_client_call(op_view, expected_metadata, expected_trailing_metadata) ⇒ Object

check that methods on a finished/closed call t crash



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/grpc-1.50.0-x86_64-linux/src/ruby/spec/generic/client_stub_spec.rb', line 40

def check_op_view_of_finished_client_call(op_view,
                                          ,
                                          )
  # use read_response_stream to try to iterate through
  # possible response stream
  fail('need something to attempt reads') unless block_given?
  expect do
    resp = op_view.execute
    yield resp
  end.to raise_error(GRPC::Core::CallError)

  expect { op_view.start_call }.to raise_error(RuntimeError)

  sanity_check_values_of_accessors(op_view,
                                   ,
                                   )

  expect do
    op_view.wait
    op_view.cancel
    op_view.write_flag = 1
  end.to_not raise_error
end

#client_certObject



24
25
26
27
28
29
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/grpc-1.50.0-x86_64-linux/src/ruby/spec/client_auth_spec.rb', line 24

def client_cert
  test_root = File.join(File.dirname(__FILE__), 'testdata')
  cert = File.open(File.join(test_root, 'client.pem')).read
  fail unless cert.is_a?(String)
  cert
end

#close_active_server_call(active_server_call) ⇒ Object



86
87
88
89
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/grpc-1.50.0-x86_64-linux/src/ruby/spec/generic/client_stub_spec.rb', line 86

def close_active_server_call(active_server_call)
  active_server_call.send(:set_input_stream_done)
  active_server_call.send(:set_output_stream_done)
end

#comment_test1Object

a b



27
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/method_source-1.0.0/spec/spec_helper.rb', line 27

def comment_test1; end

#comment_test2Object

a b



31
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/method_source-1.0.0/spec/spec_helper.rb', line 31

def comment_test2; end

#comment_test3Object

a

b



36
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/method_source-1.0.0/spec/spec_helper.rb', line 36

def comment_test3; end

#comment_test4Object

b



41
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/method_source-1.0.0/spec/spec_helper.rb', line 41

def comment_test4; end

#comment_test5Object

d



48
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/method_source-1.0.0/spec/spec_helper.rb', line 48

def comment_test5; end

#create_channel_credsObject



17
18
19
20
21
22
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/grpc-1.50.0-x86_64-linux/src/ruby/spec/client_auth_spec.rb', line 17

def create_channel_creds
  test_root = File.join(File.dirname(__FILE__), 'testdata')
  files = ['ca.pem', 'client.key', 'client.pem']
  creds = files.map { |f| File.open(File.join(test_root, f)).read }
  GRPC::Core::ChannelCredentials.new(creds[0], creds[1], creds[2])
end

#create_server_credsObject



31
32
33
34
35
36
37
38
39
40
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/grpc-1.50.0-x86_64-linux/src/ruby/spec/client_auth_spec.rb', line 31

def create_server_creds
  test_root = File.join(File.dirname(__FILE__), 'testdata')
  GRPC.logger.info("test root: #{test_root}")
  files = ['ca.pem', 'server1.key', 'server1.pem']
  creds = files.map { |f| File.open(File.join(test_root, f)).read }
  GRPC::Core::ServerCredentials.new(
    creds[0],
    [{ private_key: creds[1], cert_chain: creds[2] }],
    true) # force client auth
end

#create_stub(opts) ⇒ Object

creates a test stub



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/grpc-1.50.0-x86_64-linux/src/ruby/pb/test/client.rb', line 97

def create_stub(opts)
  address = "#{opts.server_host}:#{opts.server_port}"

  # Provide channel args that request compression by default
  # for compression interop tests
  if ['client_compressed_unary',
      'client_compressed_streaming'].include?(opts.test_case)
    compression_options =
      GRPC::Core::CompressionOptions.new(default_algorithm: :gzip)
    compression_channel_args = compression_options.to_channel_arg_hash
  else
    compression_channel_args = {}
  end

  if opts.secure
    creds = ssl_creds(opts.use_test_ca)
    stub_opts = {
      channel_args: {}
    }
    unless opts.server_host_override.empty?
      stub_opts[:channel_args].merge!({
          GRPC::Core::Channel::SSL_TARGET => opts.server_host_override
      })
    end

    # Add service account creds if specified
    wants_creds = %w(all compute_engine_creds service_account_creds)
    if wants_creds.include?(opts.test_case)
      unless opts.oauth_scope.nil?
        auth_creds = Google::Auth.get_application_default(opts.oauth_scope)
        call_creds = GRPC::Core::CallCredentials.new(auth_creds.updater_proc)
        creds = creds.compose call_creds
      end
    end

    if opts.test_case == 'oauth2_auth_token'
      auth_creds = Google::Auth.get_application_default(opts.oauth_scope)
      kw = auth_creds.updater_proc.call({})  # gives as an auth token

      # use a metadata update proc that just adds the auth token.
      call_creds = GRPC::Core::CallCredentials.new(proc { |md| md.merge(kw) })
      creds = creds.compose call_creds
    end

    if opts.test_case == 'jwt_token_creds'  # don't use a scope
      auth_creds = Google::Auth.get_application_default
      call_creds = GRPC::Core::CallCredentials.new(auth_creds.updater_proc)
      creds = creds.compose call_creds
    end

    GRPC.logger.info("... connecting securely to #{address}")
    stub_opts[:channel_args].merge!(compression_channel_args)
    if opts.test_case == "unimplemented_service"
      Grpc::Testing::UnimplementedService::Stub.new(address, creds, **stub_opts)
    else
      Grpc::Testing::TestService::Stub.new(address, creds, **stub_opts)
    end
  else
    GRPC.logger.info("... connecting insecurely to #{address}")
    if opts.test_case == "unimplemented_service"
      Grpc::Testing::UnimplementedService::Stub.new(
        address,
        :this_channel_is_insecure,
        channel_args: compression_channel_args
      )
    else
      Grpc::Testing::TestService::Stub.new(
        address,
        :this_channel_is_insecure,
        channel_args: compression_channel_args
      )
    end
  end
end

#direct_globalObject



73
74
75
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/test/test_blankslate.rb', line 73

def direct_global
  43
end

#do_div(stub) ⇒ Object



44
45
46
47
48
49
50
51
52
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/grpc-1.50.0-x86_64-linux/src/ruby/bin/math_client.rb', line 44

def do_div(stub)
  GRPC.logger.info('request_response')
  GRPC.logger.info('----------------')
  req = Math::DivArgs.new(dividend: 7, divisor: 3)
  GRPC.logger.info("div(7/3): req=#{req.inspect}")
  resp = stub.div(req)
  GRPC.logger.info("Answer: #{resp.inspect}")
  GRPC.logger.info('----------------')
end

#do_div_many(stub) ⇒ Object



77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/grpc-1.50.0-x86_64-linux/src/ruby/bin/math_client.rb', line 77

def do_div_many(stub)
  GRPC.logger.info('bidi_streamer')
  GRPC.logger.info('-------------')
  reqs = []
  reqs << Math::DivArgs.new(dividend: 7, divisor: 3)
  reqs << Math::DivArgs.new(dividend: 5, divisor: 2)
  reqs << Math::DivArgs.new(dividend: 7, divisor: 2)
  GRPC.logger.info("div(7/3), div(5/2), div(7/2): reqs=#{reqs.inspect}")
  resp = stub.div_many(reqs)
  resp.each do |r|
    GRPC.logger.info("Answer: #{r.inspect}")
  end
  GRPC.logger.info('----------------')
end

#do_fib(stub) ⇒ Object



65
66
67
68
69
70
71
72
73
74
75
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/grpc-1.50.0-x86_64-linux/src/ruby/bin/math_client.rb', line 65

def do_fib(stub)
  GRPC.logger.info('server_streamer')
  GRPC.logger.info('----------------')
  req = Math::FibArgs.new(limit: 11)
  GRPC.logger.info("fib(11): req=#{req.inspect}")
  resp = stub.fib(req)
  resp.each do |r|
    GRPC.logger.info("Answer: #{r.inspect}")
  end
  GRPC.logger.info('----------------')
end

#do_sum(stub) ⇒ Object



54
55
56
57
58
59
60
61
62
63
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/grpc-1.50.0-x86_64-linux/src/ruby/bin/math_client.rb', line 54

def do_sum(stub)
  # to make client streaming requests, pass an enumerable of the inputs
  GRPC.logger.info('client_streamer')
  GRPC.logger.info('---------------')
  reqs = [1, 2, 3, 4, 5].map { |x| Math::Num.new(num: x) }
  GRPC.logger.info("sum(1, 2, 3, 4, 5): reqs=#{reqs.inspect}")
  resp = stub.sum(reqs)  # reqs.is_a?(Enumerable)
  GRPC.logger.info("Answer: #{resp.inspect}")
  GRPC.logger.info('---------------')
end

#env_append(name, string) ⇒ Object



45
46
47
48
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/grpc-1.50.0-x86_64-linux/src/ruby/ext/grpc/extconf.rb', line 45

def env_append(name, string)
  ENV[name] ||= ''
  ENV[name] += ' ' + string
end

#env_unset?(name) ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/grpc-1.50.0-x86_64-linux/src/ruby/ext/grpc/extconf.rb', line 33

def env_unset?(name)
  ENV[name].nil? || ENV[name].size == 0
end

#execute_rpc_in_thread(op, rpc) ⇒ Object



193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/grpc-1.50.0-x86_64-linux/src/ruby/pb/test/xds_client.rb', line 193

def execute_rpc_in_thread(op, rpc)
  Thread.new {
    rpc_stats_key = rpc.to_s
    remote_peer = ""
    begin
      op.execute
      if op..key?('hostname')
        remote_peer = op.['hostname']
      end
      $accumulated_stats_mu.synchronize do
        $num_rpcs_succeeded_by_method[rpc_stats_key] += 1
        $accumulated_method_stats[rpc_stats_key].add_result(0)
      end
    rescue GRPC::BadStatus => e
      $accumulated_stats_mu.synchronize do
        $num_rpcs_failed_by_method[rpc_stats_key] += 1
        $accumulated_method_stats[rpc_stats_key].add_result(e.code)
      end
    end
    $thread_results_mu.synchronize do
      $thread_results << [rpc, remote_peer]
    end
  }
end

#helloObject

It spans two lines and is indented by 2 spaces



23
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/method_source-1.0.0/spec/spec_helper.rb', line 23

def hello; :hello; end

#inherit_rbconfig(name) ⇒ Object



41
42
43
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/grpc-1.50.0-x86_64-linux/src/ruby/ext/grpc/extconf.rb', line 41

def inherit_rbconfig(name)
  ENV[name] = RbConfig::CONFIG[name] if env_unset?(name) && rbconfig_set?(name)
end

#is_rbx?Boolean

Returns:

  • (Boolean)


4
5
6
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/method_source-1.0.0/spec/spec_helper.rb', line 4

def is_rbx?
  defined?(RUBY_ENGINE) && RUBY_ENGINE =~ /rbx/
end

#jruby?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/method_source-1.0.0/spec/spec_helper.rb', line 8

def jruby?
  defined?(RUBY_ENGINE) && RUBY_ENGINE =~ /jruby/
end

#load_test_certsObject

loads the certificates by the test server.



72
73
74
75
76
77
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/grpc-1.50.0-x86_64-linux/src/ruby/pb/test/client.rb', line 72

def load_test_certs
  this_dir = File.expand_path(File.dirname(__FILE__))
  data_dir = File.join(File.dirname(File.dirname(this_dir)), 'spec/testdata')
  files = ['ca.pem', 'server1.key', 'server1.pem']
  files.map { |f| File.open(File.join(data_dir, f)).read }
end

#mainObject



760
761
762
763
764
765
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/grpc-1.50.0-x86_64-linux/src/ruby/pb/test/client.rb', line 760

def main
  opts = parse_args
  stub = create_stub(opts)
  NamedTests.new(stub, opts).method(opts['test_case']).call
  p "OK: #{opts['test_case']}"
end

#maybe_echo_metadata(_call) ⇒ Object



117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/grpc-1.50.0-x86_64-linux/src/ruby/pb/test/server.rb', line 117

def (_call)
  
  # these are consistent for all interop tests
   = "x-grpc-test-echo-initial"
   = "x-grpc-test-echo-trailing-bin"

  if _call..has_key?()
    _call.[] = _call.[]
  end
  if _call..has_key?()
    _call.[] = _call.[]
  end
end

#maybe_echo_status_and_message(req) ⇒ Object



131
132
133
134
135
136
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/grpc-1.50.0-x86_64-linux/src/ruby/pb/test/server.rb', line 131

def maybe_echo_status_and_message(req)
  unless req.response_status.nil?
    fail GRPC::BadStatus.new_status_exception(
        req.response_status.code, req.response_status.message)
  end
end

#null_object?Object

Note:

This is only available when you have enabled the ‘should` syntax.

Returns true if this object has received ‘as_null_object`



# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/syntax.rb', line 290

#nulls(l) ⇒ Object

produces a string of null chars (0) of length l.



173
174
175
176
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/grpc-1.50.0-x86_64-linux/src/ruby/pb/test/client.rb', line 173

def nulls(l)
  fail 'requires #{l} to be +ve' if l < 0
  [].pack('x' * l).force_encoding('ascii-8bit')
end

#output_progress(msg) ⇒ Object

Output progress messages



19
20
21
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/pg-1.4.5/sample/async_api.rb', line 19

def output_progress( msg )
	puts "\n>>> #{msg}\n"
end

#parse_argsObject

validates the command line options, returning them as a Hash.



136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/pg-1.4.5/sample/pg_statistics.rb', line 136

def parse_args( args )
	options          = OpenStruct.new
	options.database = Etc.getpwuid( Process.uid ).name
	options.host     = '127.0.0.1'
	options.port     = 5432
	options.user     = Etc.getpwuid( Process.uid ).name
	options.sslmode  = 'disable'
	options.interval = 5

	opts = OptionParser.new do |opts|
		opts.banner = "Usage: #{$0} [options]"

		opts.separator ''
		opts.separator 'Connection options:'

		opts.on( '-d', '--database DBNAME',
				"specify the database to connect to (default: \"#{options.database}\")" ) do |db|
			options.database = db
		end

		opts.on( '-h', '--host HOSTNAME', 'database server host' ) do |host|
			options.host = host
		end

		opts.on( '-p', '--port PORT', Integer,
				"database server port (default: \"#{options.port}\")" ) do |port|
			options.port = port
		end

		opts.on( '-U', '--user NAME',
				"database user name (default: \"#{options.user}\")" ) do |user|
			options.user = user
		end

		opts.on( '-W', 'force password prompt' ) do |pw|
			print 'Password: '
			begin
				system 'stty -echo'
				options.pass = gets.chomp
			ensure
				system 'stty echo'
				puts
			end
		end

		opts.separator ''
		opts.separator 'Other options:'

		opts.on( '-i', '--interval SECONDS', Integer,
				 "refresh interval in seconds (default: \"#{options.interval}\")") do |seconds|
			options.interval = seconds
		end

		opts.on_tail( '--help', 'show this help, then exit' ) do
			$stderr.puts opts
			exit
		end

		opts.on_tail( '--version', 'output version information, then exit' ) do
			puts Stats::VERSION
			exit
		end
	end

	opts.parse!( args )
	return options
end

#parse_optionsObject

validates the command line options, returning them as a Hash.



215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/grpc-1.50.0-x86_64-linux/src/ruby/pb/test/server.rb', line 215

def parse_options
  options = {
    'port' => nil,
    'secure' => false
  }
  OptionParser.new do |opts|
    opts.banner = 'Usage: --port port'
    opts.on('--port PORT', 'server port') do |v|
      options['port'] = v
    end
    opts.on('--use_tls USE_TLS', ['false', 'true'],
            'require a secure connection?') do |v|
      options['secure'] = v == 'true'
    end
  end.parse!

  if options['port'].nil?
    fail(OptionParser::MissingArgument, 'please specify --port')
  end
  options
end

#prod_credsObject

creates SSL Credentials from the production certificates.



86
87
88
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/grpc-1.50.0-x86_64-linux/src/ruby/pb/test/client.rb', line 86

def prod_creds
  GRPC::Core::ChannelCredentials.new()
end

#progress_bar(int) ⇒ Object



47
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/examples/performance.rb', line 47

def progress_bar(int); print "." if (int % 100).zero? ; end

#rbconfig_set?(name) ⇒ Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/grpc-1.50.0-x86_64-linux/src/ruby/ext/grpc/extconf.rb', line 37

def rbconfig_set?(name)
  RbConfig::CONFIG[name] && RbConfig::CONFIG[name].size > 0
end

#report(opts) ⇒ Object

Gather data and output it to $stdout.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/pg-1.4.5/sample/disk_usage_report.rb', line 23

def report( opts )
	db = PG.connect(
		:dbname   => opts.database,
		:host     => opts.host,
		:port     => opts.port,
		:user     => opts.user,
		:password => opts.pass,
		:sslmode  => 'prefer'
	)

	# -----------------------------------------

	db_info = db.exec %Q{
		SELECT
			count(oid) AS num_relations,
			pg_size_pretty(pg_database_size('#{opts.database}')) AS dbsize
		FROM
			pg_class
	}

	puts '=' * 70
	puts "Disk usage information for %s: (%d relations, %s total)" % [
		opts.database,
		db_info[0]['num_relations'],
		db_info[0]['dbsize']
	]
	puts '=' * 70

	# -----------------------------------------

	top_twenty = db.exec %q{
		SELECT
			relname AS name,
			relkind AS kind,
			pg_size_pretty(pg_relation_size(pg_class.oid)) AS size
		FROM
			pg_class
		ORDER BY
			pg_relation_size(pg_class.oid) DESC
		LIMIT 20
	}

	puts 'Top twenty objects by size:'
	puts '-' * 70
	top_twenty.each do |row|
		type = case row['kind']
			   when 'i'; 'index'
			   when 't'; 'toast'
			   when 'r'; 'table'
			   when 'S'; 'sequence'
			   else;     '???'
			   end

		puts "%40s %10s (%s)" % [ row['name'], row['size'], type ]
	end
	puts '-' * 70

	# -----------------------------------------

	schema_sizes = db.exec %q{
		SELECT
			table_schema,
			pg_size_pretty( CAST( SUM(pg_total_relation_size(table_schema || '.' || table_name)) AS bigint)) AS size
		FROM
			information_schema.tables
		GROUP BY
			table_schema
		ORDER BY
			CAST( SUM(pg_total_relation_size(table_schema || '.' || table_name)) AS bigint ) DESC
	}


	puts 'Size per schema:'
	puts '-' * 70
	schema_sizes.each do |row|
		puts "%20s %10s" % [ row['table_schema'], row['size'] ]
	end
	puts '-' * 70
	puts

	db.finish
end

#require_do(resource) ⇒ Object



11
12
13
14
15
16
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/diff-lcs-1.5.0/spec/spec_helper.rb', line 11

def require_do(resource)
  require resource
  yield if block_given?
rescue LoadError
  nil
end

#run_test_loop(stub, target_seconds_between_rpcs, fail_on_failed_rpcs) ⇒ Object

send 1 rpc every 1/qps second



219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/grpc-1.50.0-x86_64-linux/src/ruby/pb/test/xds_client.rb', line 219

def run_test_loop(stub, target_seconds_between_rpcs, fail_on_failed_rpcs)
  include Grpc::Testing
  simple_req = SimpleRequest.new()
  empty_req = Empty.new()
  target_next_start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
  # Some RPCs are meant to be "kept open". Since Ruby does not have an
  # async API, we are executing those RPCs in a thread so that they don't
  # block.
  keep_open_threads = Array.new
  while !$shutdown
    now = Process.clock_gettime(Process::CLOCK_MONOTONIC)
    sleep_seconds = target_next_start - now
    if sleep_seconds < 0
      target_next_start = now + target_seconds_between_rpcs
    else
      target_next_start += target_seconds_between_rpcs
      sleep(sleep_seconds)
    end
    deadline_sec = $rpc_config.timeout_sec > 0 ? $rpc_config.timeout_sec : 30
    deadline = GRPC::Core::TimeConsts::from_relative_time(deadline_sec)
    results = {}
    $rpc_config.rpcs_to_send.each do |rpc|
      # rpc is in the form of :UNARY_CALL or :EMPTY_CALL here
       = $rpc_config..key?(rpc) ?
                   $rpc_config.[rpc] : {}
      $accumulated_stats_mu.synchronize do
        $num_rpcs_started_by_method[rpc.to_s] += 1
        $accumulated_method_stats[rpc.to_s].increment_rpcs_started()
      end
      if rpc == :UNARY_CALL
        op = stub.unary_call(simple_req,
                             metadata: ,
                             deadline: deadline,
                             return_op: true)
      elsif rpc == :EMPTY_CALL
        op = stub.empty_call(empty_req,
                             metadata: ,
                             deadline: deadline,
                             return_op: true)
      else
        raise "Unsupported rpc #{rpc}"
      end
      keep_open_threads << execute_rpc_in_thread(op, rpc)
    end
    # collect results from threads
    $thread_results_mu.synchronize do
      $thread_results.each do |r|
        rpc_name, remote_peer = r
        results[rpc_name] = remote_peer
      end
      $thread_results = Array.new
    end
    $watchers_mutex.synchronize do
      $watchers.each do |watcher|
        # this is counted once when each group of all rpcs_to_send were done
        watcher['rpcs_needed'] -= 1
        results.each do |rpc_name, remote_peer|
          # These stats expect rpc_name to be in the form of
          # UnaryCall or EmptyCall, not the underscore-case all-caps form
          rpc_name = $RPC_MAP.invert()[rpc_name]
          if remote_peer.strip.empty?
            # error is counted per individual RPC
            watcher['no_remote_peer'] += 1
          else
            if not watcher['rpcs_by_method'].key?(rpc_name)
              watcher['rpcs_by_method'][rpc_name] = Hash.new(0)
            end
            # increment the remote hostname distribution histogram
            # both by overall, and broken down per RPC
            watcher['rpcs_by_method'][rpc_name][remote_peer] +=  1
            watcher['rpcs_by_peer'][remote_peer] += 1
          end
        end
      end
      $watchers_cv.broadcast
    end
  end
  keep_open_threads.each { |thd| thd.join }
end

#sanity_check_values_of_accessors(op_view, expected_metadata, expected_trailing_metadata) ⇒ Object



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/grpc-1.50.0-x86_64-linux/src/ruby/spec/generic/client_stub_spec.rb', line 64

def sanity_check_values_of_accessors(op_view,
                                     ,
                                     )
  expected_status = Struct::Status.new
  expected_status.code = 0
  expected_status.details = 'OK'
  expected_status. = 

  expect(op_view.status).to eq(expected_status)
  expect(op_view.).to eq()
  expect(op_view.).to eq()

  expect(op_view.cancelled?).to be(false)
  expect(op_view.write_flag).to be(nil)

  # The deadline attribute of a call can be either
  # a GRPC::Core::TimeSpec or a Time, which are mutually exclusive.
  # TODO: fix so that the accessor always returns the same type.
  expect(op_view.deadline.is_a?(GRPC::Core::TimeSpec) ||
         op_view.deadline.is_a?(Time)).to be(true)
end

#should_not_receiveObject

Sets and expectation that this object should not receive a message during this example.



# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/syntax.rb', line 225

#should_receiveObject

Note:

This is only available when you have enabled the ‘should` syntax.

Sets an expectation that this object should receive a message before the end of the example.

Examples:

logger = double('logger')
thing_that_logs = ThingThatLogs.new(logger)
logger.should_receive(:log)
thing_that_logs.do_something_that_logs_a_message

See Also:



# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/syntax.rb', line 212

#ssl_creds(use_test_ca) ⇒ Object

creates the SSL Credentials.



91
92
93
94
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/grpc-1.50.0-x86_64-linux/src/ruby/pb/test/client.rb', line 91

def ssl_creds(use_test_ca)
  return test_creds if use_test_ca
  prod_creds
end

#start_server(port = 0) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/grpc-1.50.0-x86_64-linux/src/ruby/spec/channel_connection_spec.rb', line 21

def start_server(port = 0)
  @srv = new_rpc_server_for_testing(pool_size: 1)
  server_port = @srv.add_http2_port("localhost:#{port}", :this_port_is_insecure)
  @srv.handle(EchoService)
  @server_thd = Thread.new { @srv.run }
  @srv.wait_till_running
  server_port
end

#stop_serverObject



30
31
32
33
34
35
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/grpc-1.50.0-x86_64-linux/src/ruby/spec/channel_connection_spec.rb', line 30

def stop_server
  expect(@srv.stopped?).to be(false)
  @srv.stop
  @server_thd.join
  expect(@srv.stopped?).to be(true)
end

#stubObject

Note:

This is only available when you have enabled the ‘should` syntax.

Tells the object to respond to the message with the specified value.

Examples:

counter.stub(:count).and_return(37)
counter.stub(:count => 37)
counter.stub(:count) { 37 }

See Also:



# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/syntax.rb', line 230

#stub_chain(method1, method2) ⇒ Object #stub_chain("method1.method2") ⇒ Object #stub_chain(method1, method_to_value_hash) ⇒ Object

Note:

This is only available when you have enabled the ‘should` syntax.

Stubs a chain of methods.

## Warning:

Chains can be arbitrarily long, which makes it quite painless to violate the Law of Demeter in violent ways, so you should consider any use of ‘stub_chain` a code smell. Even though not all code smells indicate real problems (think fluent interfaces), `stub_chain` still results in brittle examples. For example, if you write `foo.stub_chain(:bar, :baz => 37)` in a spec and then the implementation calls `foo.baz.bar`, the stub will not work.

Examples:

double.stub_chain("foo.bar") { :baz }
double.stub_chain(:foo, :bar => :baz)
double.stub_chain(:foo, :bar) { :baz }

  # Given any of ^^ these three forms ^^:
  double.foo.bar # => :baz

  # Common use in Rails/ActiveRecord:
  Article.stub_chain("recent.published") { [Article.new] }

See Also:



# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/syntax.rb', line 252

#sysread(io, size) ⇒ Object

cgi_runner.rb – CGI launcher.

Author: IPR – Internet Programming with Ruby – writers Copyright © 2000 TAKAHASHI Masayoshi, GOTOU YUUZOU Copyright © 2002 Internet Programming with Ruby writers. All rights reserved.

$IPR: cgi_runner.rb,v 1.9 2002/09/25 11:33:15 gotoyuzo Exp $



12
13
14
15
16
17
18
19
20
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/webrick-1.7.0/lib/webrick/httpservlet/cgi_runner.rb', line 12

def sysread(io, size)
  buf = ""
  while size > 0
    tmp = io.sysread(size)
    buf << tmp
    size -= tmp.bytesize
  end
  return buf
end

#system_libffi_usable?Boolean

Returns:

  • (Boolean)


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/ffi-1.15.5/ext/ffi_c/extconf.rb', line 7

def system_libffi_usable?
  # We need pkg_config or ffi.h
  libffi_ok = pkg_config("libffi") ||
      have_header("ffi.h") ||
      find_header("ffi.h", "/usr/local/include", "/usr/include/ffi",
                  "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/ffi",
                  "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/ffi") ||
      (find_header("ffi.h", `xcrun --sdk macosx --show-sdk-path`.strip + "/usr/include/ffi") rescue false)

  # Ensure we can link to ffi_prep_closure_loc
  libffi_ok &&= have_library("ffi", "ffi_prep_closure_loc", [ "ffi.h" ]) ||
                have_library("libffi", "ffi_prep_closure_loc", [ "ffi.h" ]) ||
                have_library("libffi-8", "ffi_prep_closure_loc", [ "ffi.h" ])

  if RbConfig::CONFIG['host_os'] =~ /mswin/
    have_library('libffi_convenience')
    have_library('shlwapi')
  end

  libffi_ok
end

#test_credsObject

creates SSL Credentials from the test certificates.



80
81
82
83
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/grpc-1.50.0-x86_64-linux/src/ruby/pb/test/client.rb', line 80

def test_creds
  certs = load_test_certs
  GRPC::Core::ChannelCredentials.new(certs[0])
end

#test_server_credsObject

creates a ServerCredentials from the test certificates.



105
106
107
108
109
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/grpc-1.50.0-x86_64-linux/src/ruby/pb/test/server.rb', line 105

def test_server_creds
  certs = load_test_certs
  GRPC::Core::ServerCredentials.new(
      nil, [{private_key: certs[1], cert_chain: certs[2]}], false)
end

#unstubObject

Note:

This is only available when you have enabled the ‘should` syntax.

Removes a stub. On a double, the object will no longer respond to ‘message`. On a real object, the original method (if it exists) is restored.

This is rarely used, but can be useful when a stub is set up during a shared ‘before` hook for the common case, but you want to replace it for a special case.



# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/syntax.rb', line 241

#wakey_thread(&blk) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/grpc-1.50.0-x86_64-linux/src/ruby/spec/generic/client_stub_spec.rb', line 19

def wakey_thread(&blk)
  n = GRPC::Notifier.new
  t = Thread.new do
    blk.call(n)
  end
  t.abort_on_exception = true
  n.wait
  t
end

#with_kwargs_envObject



3
4
5
6
7
8
9
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_mock.rb', line 3

def with_kwargs_env
  ENV["MT_KWARGS_HAC\K"] = "1"

  yield
ensure
  ENV.delete "MT_KWARGS_HAC\K"
end

#with_protos(file_paths) ⇒ Object



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/grpc-1.50.0-x86_64-linux/src/ruby/spec/pb/codegen/package_option_spec.rb', line 73

def with_protos(file_paths)
  pb_dir = File.dirname(__FILE__)
  bins_dir = File.join('..', '..', '..', '..', '..', 'cmake', 'build')
  plugin = File.join(bins_dir, 'grpc_ruby_plugin')
  protoc = File.join(bins_dir, 'third_party', 'protobuf', 'protoc')

  # Generate the service from the proto
  Dir.mktmpdir(nil, File.dirname(__FILE__)) do |tmp_dir|
    gen_file = system(protoc,
                      '-I.',
                      *file_paths,
                      "--grpc_out=#{tmp_dir}", # generate the service
                      "--ruby_out=#{tmp_dir}", # generate the definitions
                      "--plugin=protoc-gen-grpc=#{plugin}",
                      chdir: pb_dir,
                      out: File::NULL)

    expect(gen_file).to be_truthy
    begin
      $LOAD_PATH.push(tmp_dir)
      yield
    ensure
      $LOAD_PATH.delete(tmp_dir)
    end
  end
end