_id
stringlengths
2
6
title
stringlengths
9
130
partition
stringclasses
3 values
text
stringlengths
66
10.5k
language
stringclasses
1 value
meta_information
dict
q26600
TensorStream.Ops.pack
test
def pack(values, axis: 0, name: "pack") _op(:stack, *values, axis: axis, name: name) end
ruby
{ "resource": "" }
q26601
TensorStream.Ops.unpack
test
def unpack(value, num: nil, axis: 0, name: "unpack") unstack(value, num: num, axis: axis, name: name) end
ruby
{ "resource": "" }
q26602
TensorStream.Ops.case
test
def case(args = {}) args = args.dup default = args.delete(:default) exclusive = args.delete(:exclusive) strict = args.delete(:strict) name = args.delete(:name) predicates = [] functions = [] args.each do |k, v| raise "Invalid argment or option #{k}" unless k.is_...
ruby
{ "resource": "" }
q26603
TensorStream.OpHelper.i_op
test
def i_op(code, *args) options = if args.last.is_a?(Hash) args.pop else {} end args << options.merge(internal: true) Graph.get_default_graph.add_op!(code.to_sym, *args) end
ruby
{ "resource": "" }
q26604
TensorStream.ArrayOpsHelper.broadcast_dimensions
test
def broadcast_dimensions(input, dims = []) return input if dims.empty? d = dims.shift if input.is_a?(Array) && (get_rank(input) - 1) == dims.size row_to_dup = input.collect { |item| broadcast_dimensions(item, dims.dup) } row_to_dup + Array.new(d) { row_to_dup }.fla...
ruby
{ "resource": "" }
q26605
TensorStream.ArrayOpsHelper.vector_op
test
def vector_op(vector, vector2, switch = false, safe = true, &block) if get_rank(vector) < get_rank(vector2) # upgrade rank of A duplicated = Array.new(vector2.size) { vector } return vector_op(duplicated, vector2, switch, &block) end return yield(vector, vector2) unl...
ruby
{ "resource": "" }
q26606
TensorStream.ArrayOpsHelper.transpose_with_perm
test
def transpose_with_perm(arr, new_arr, shape, new_shape, perm) arr_size = shape.reduce(:*) divisors = shape.dup.drop(1).reverse.inject([1]) { |a, s| a << s * a.last }.reverse multipliers = new_shape.dup.drop(1).reverse.inject([1]) { |a, s| a << s * a.last }.reverse a...
ruby
{ "resource": "" }
q26607
TensorStream.OpStub.add
test
def add(input_a, input_b, name: nil) input_a, input_b = apply_data_type_coercion(input_a, input_b) _op(:add, input_a, input_b, name: name) end
ruby
{ "resource": "" }
q26608
TensorStream.OpStub.argmax
test
def argmax(input_a, axis = nil, name: nil, dimension: nil, output_type: :int32) check_allowed_types(input_a, TensorStream::Ops::NUMERIC_TYPES) check_allowed_types(axis, TensorStream::Ops::INTEGER_TYPES) _op(:argmax, input_a, axis, name: name, dimension: dimension, output_type: output_type) end
ruby
{ "resource": "" }
q26609
TensorStream.OpStub.ceil
test
def ceil(input_a, name: nil) check_allowed_types(input_a, TensorStream::Ops::FLOATING_POINT_TYPES) _op(:ceil, input_a, name: name) end
ruby
{ "resource": "" }
q26610
TensorStream.OpStub.cos
test
def cos(input_a, name: nil) check_allowed_types(input_a, TensorStream::Ops::FLOATING_POINT_TYPES) _op(:cos, input_a, name: name) end
ruby
{ "resource": "" }
q26611
TensorStream.OpStub.floor
test
def floor(input_a, name: nil) check_allowed_types(input_a, TensorStream::Ops::FLOATING_POINT_TYPES) _op(:floor, input_a, name: name) end
ruby
{ "resource": "" }
q26612
TensorStream.OpStub.mod
test
def mod(input_a, input_b, name: nil) input_a, input_b = apply_data_type_coercion(input_a, input_b) _op(:mod, input_a, input_b, name: name) end
ruby
{ "resource": "" }
q26613
TensorStream.OpStub.pow
test
def pow(input_a, input_b, name: nil) input_a, input_b = apply_data_type_coercion(input_a, input_b) _op(:pow, input_a, input_b, name: name) end
ruby
{ "resource": "" }
q26614
TensorStream.OpStub.prod
test
def prod(input_a, axis = nil, name: nil, keepdims: false) check_allowed_types(axis, TensorStream::Ops::INTEGER_TYPES) input_a = TensorStream.convert_to_tensor(input_a) return input_a if input_a.shape.scalar? axis = cast_axis(input_a, axis) _op(:prod, input_a, axis, name: name, keepdims: ke...
ruby
{ "resource": "" }
q26615
TensorStream.OpStub.random_uniform
test
def random_uniform(shape, name: nil, dtype: :float32, minval: 0, maxval: 1, seed: nil) _op(:random_uniform, shape, name: name, dtype: dtype, minval: minval, maxval: maxval, seed: seed) end
ruby
{ "resource": "" }
q26616
TensorStream.OpStub.range
test
def range(start = 0, limit = 0, delta = 1, name: "range", dtype: nil, output_type: :int32) _op(:range, start, limit, delta, name: name, dtype: dtype, output_type: output_type) end
ruby
{ "resource": "" }
q26617
TensorStream.OpStub.rank
test
def rank(input, name: nil) input = convert_to_tensor(input) return cons(input.shape.ndims) if input.shape.known? _op(:rank, input, name: name) end
ruby
{ "resource": "" }
q26618
TensorStream.OpStub.round
test
def round(input_a, name: nil) check_allowed_types(input_a, TensorStream::Ops::FLOATING_POINT_TYPES) _op(:round, input_a, name: name) end
ruby
{ "resource": "" }
q26619
TensorStream.OpStub.rsqrt
test
def rsqrt(input_a, name: nil) check_allowed_types(input_a, TensorStream::Ops::FLOATING_POINT_TYPES) _op(:rsqrt, input_a, name: name) end
ruby
{ "resource": "" }
q26620
TensorStream.OpStub.shape
test
def shape(input, name: nil, out_type: :int32) return constant(shape_eval(input, out_type), dtype: out_type, name: "Shape/#{name}") if input.is_a?(Array) && !input[0].is_a?(Tensor) return constant(input.shape.shape, dtype: out_type, name: "Shape/#{input.name}_c") if shape_full_specified(input) _op(:sha...
ruby
{ "resource": "" }
q26621
TensorStream.OpStub.sigmoid
test
def sigmoid(input_a, name: nil) check_allowed_types(input_a, TensorStream::Ops::FLOATING_POINT_TYPES) _op(:sigmoid, input_a, name: name) end
ruby
{ "resource": "" }
q26622
TensorStream.OpStub.sin
test
def sin(input_a, name: nil) check_allowed_types(input_a, TensorStream::Ops::FLOATING_POINT_TYPES) _op(:sin, input_a, name: name) end
ruby
{ "resource": "" }
q26623
TensorStream.OpStub.sub
test
def sub(input_a, input_b, name: nil) input_a, input_b = apply_data_type_coercion(input_a, input_b) _op(:sub, input_a, input_b, name: name) end
ruby
{ "resource": "" }
q26624
TensorStream.OpStub.sum
test
def sum(input_a, axis_p = nil, axis: nil, name: nil, keepdims: false) check_allowed_types(axis_p, TensorStream::Ops::INTEGER_TYPES) input_a = TensorStream.convert_to_tensor(input_a) return input_a if input_a.shape.scalar? axis_p = axis_p || axis axis_p = cast_axis(input_a, axis_p) _o...
ruby
{ "resource": "" }
q26625
TensorStream.OpStub.tan
test
def tan(input_a, name: nil) check_allowed_types(input_a, TensorStream::Ops::FLOATING_POINT_TYPES) _op(:tan, input_a, name: name) end
ruby
{ "resource": "" }
q26626
TensorStream.OpStub.tanh
test
def tanh(input_a, name: nil) check_allowed_types(input_a, TensorStream::Ops::FLOATING_POINT_TYPES) _op(:tanh, input_a, name: name) end
ruby
{ "resource": "" }
q26627
TensorStream.OpStub.top_k
test
def top_k(input, k = 1, sorted: true, name: nil) result = _op(:top_k, input, k, sorted: sorted, name: name) [result[0], result[1]] end
ruby
{ "resource": "" }
q26628
TensorStream.OpStub.zeros
test
def zeros(shape, dtype: :float32, name: nil) _op(:zeros, shape, dtype: dtype, name: name) end
ruby
{ "resource": "" }
q26629
TensorStream.Freezer.convert
test
def convert(session, checkpoint_folder, output_file) model_file = File.join(checkpoint_folder, "model.yaml") TensorStream.graph.as_default do |current_graph| YamlLoader.new.load_from_string(File.read(model_file)) saver = TensorStream::Train::Saver.new saver.restore(session, checkpoin...
ruby
{ "resource": "" }
q26630
TensorStream.Graph.device
test
def device(device_name) Thread.current["ts_graph_#{object_id}"] ||= {} Thread.current["ts_graph_#{object_id}"][:default_device] ||= [] Thread.current["ts_graph_#{object_id}"][:default_device] << device_name begin yield ensure Thread.current["ts_graph_#{object_id}"][:default...
ruby
{ "resource": "" }
q26631
TensorStream.YamlLoader.load_from_string
test
def load_from_string(buffer) serialized_ops = YAML.safe_load(buffer, [Symbol], [], true) serialized_ops.each do |op_def| inputs = op_def[:inputs].map { |i| @graph.get_tensor_by_name(i) } options = {} new_var = nil if op_def.dig(:attrs, :container) new_var = Variabl...
ruby
{ "resource": "" }
q26632
TensorStream.Utils.variable
test
def variable(value, name: nil, initializer: nil, graph: nil, dtype: nil, trainable: true) op = Graph.get_default_graph.add_op(:assign, nil, value) common_options = { initializer: initializer || op, name: name, graph: graph, dtype: dtype, trainable: trainable, } ...
ruby
{ "resource": "" }
q26633
TensorStream.Utils.variable_scope
test
def variable_scope(scope = nil, default_name = nil, reuse: nil, initializer: nil) Thread.current[:tensor_stream_variable_scope] ||= [VariableScope.new] # uniquenifier if scope.nil? && default_name same_names = get_variable_scope.used_names.select { |s| s.start_with?(default_name) } ne...
ruby
{ "resource": "" }
q26634
TensorStream.Utils.session
test
def session(evaluator = nil, thread_pool_class: Concurrent::ImmediateExecutor, log_device_placement: false, profile_enabled: false) session = TensorStream::Session.new(evaluator, thread_pool_class: thread_pool_class, log_device_placement: log_device_placement, profile_enabled: profile_enabled) yield session...
ruby
{ "resource": "" }
q26635
TensorStream.Utils.placeholder
test
def placeholder(dtype, shape: nil, name: nil) TensorStream::Placeholder.new(dtype, nil, shape, name: name) end
ruby
{ "resource": "" }
q26636
TensorStream.Utils.check_if_dense
test
def check_if_dense(value, expected_shape = nil) return unless value.is_a?(Array) return if value.empty? expected_shape ||= shape_eval(value) s = expected_shape.shift raise TensorStream::ValueError, "Argument must be a dense tensor: #{value}, expected size #{s} got #{value.size}" if value...
ruby
{ "resource": "" }
q26637
TensorStream.Utils.apply_data_type_coercion
test
def apply_data_type_coercion(*args) coerced_type = check_data_types(*args) args.map { |a| a.is_a?(Tensor) ? a : convert_to_tensor(a, dtype: coerced_type) } end
ruby
{ "resource": "" }
q26638
IBMWatson.SpeechToTextV1.add_audio
test
def add_audio(customization_id:, audio_name:, audio_resource:, contained_content_type: nil, allow_overwrite: nil, content_type: nil) raise ArgumentError.new("customization_id must be provided") if customization_id.nil? raise ArgumentError.new("audio_name must be provided") if audio_name.nil? raise A...
ruby
{ "resource": "" }
q26639
IBMWatson.DiscoveryV1.create_event
test
def create_event(type:, data:) raise ArgumentError.new("type must be provided") if type.nil? raise ArgumentError.new("data must be provided") if data.nil? headers = { } sdk_headers = Common.new.get_sdk_headers("discovery", "V1", "create_event") headers.merge!(sdk_headers) pa...
ruby
{ "resource": "" }
q26640
RbNaCl.Util.zero_pad
test
def zero_pad(n, message) len = message.bytesize if len == n message elsif len > n raise LengthError, "String too long for zero-padding to #{n} bytes" else message + zeros(n - len) end end
ruby
{ "resource": "" }
q26641
RbNaCl.Util.check_length
test
def check_length(string, length, description) if string.nil? # code below is runs only in test cases # nil can't be converted to str with #to_str method raise LengthError, "#{description} was nil (Expected #{length.to_int})", caller end if string.by...
ruby
{ "resource": "" }
q26642
RbNaCl.Util.check_string
test
def check_string(string, length, description) check_string_validation(string) string = string.to_s check_length(string, length, description) string end
ruby
{ "resource": "" }
q26643
RbNaCl.Util.check_hmac_key
test
def check_hmac_key(string, _description) check_string_validation(string) string = string.to_str if string.bytesize.zero? raise LengthError, "#{Description} was #{string.bytesize} bytes (Expected more than 0)", caller end string end
ruby
{ "resource": "" }
q26644
RbNaCl.Util.check_string_validation
test
def check_string_validation(string) raise TypeError, "can't convert #{string.class} into String with #to_str" unless string.respond_to? :to_str string = string.to_str raise EncodingError, "strings must use BINARY encoding (got #{string.encoding})" if string.encoding != Encoding::BINARY end
ruby
{ "resource": "" }
q26645
RbNaCl.Auth.auth
test
def auth(message) authenticator = Util.zeros(tag_bytes) message = message.to_str compute_authenticator(authenticator, message) authenticator end
ruby
{ "resource": "" }
q26646
RbNaCl.Auth.verify
test
def verify(authenticator, message) auth = authenticator.to_s Util.check_length(auth, tag_bytes, "Provided authenticator") verify_message(auth, message) || raise(BadAuthenticatorError, "Invalid authenticator provided, message is corrupt") end
ruby
{ "resource": "" }
q26647
RbNaCl.SimpleBox.box
test
def box(message) nonce = generate_nonce cipher_text = @box.box(nonce, message) nonce + cipher_text end
ruby
{ "resource": "" }
q26648
RbNaCl.SimpleBox.open
test
def open(enciphered_message) nonce, ciphertext = extract_nonce(enciphered_message.to_s) @box.open(nonce, ciphertext) end
ruby
{ "resource": "" }
q26649
SemanticLogger.Appenders.reopen
test
def reopen each do |appender| begin next unless appender.respond_to?(:reopen) logger.trace "Reopening appender: #{appender.name}" appender.reopen rescue Exception => exc logger.error "Failed to re-open appender: #{appender.inspect}", exc end e...
ruby
{ "resource": "" }
q26650
SemanticLogger.Subscriber.logger
test
def logger @logger ||= begin logger = SemanticLogger::Processor.logger.clone logger.name = self.class.name logger end end
ruby
{ "resource": "" }
q26651
SemanticLogger.Base.measure
test
def measure(level, message, params = {}, &block) index = Levels.index(level) if level_index <= index measure_internal(level, index, message, params, &block) elsif block yield(params) end end
ruby
{ "resource": "" }
q26652
SemanticLogger.Base.backtrace
test
def backtrace(thread: Thread.current, level: :warn, message: 'Backtrace:', payload: nil, metric: nil, metric_amount: nil) log = Log.new(name, level) return false unless meets_log_level?(log) backtrace = ...
ruby
{ "resource": "" }
q26653
SemanticLogger.Base.tagged
test
def tagged(*tags, &block) # Allow named tags to be passed into the logger if tags.size == 1 tag = tags[0] return yield if tag.nil? || tag == '' return tag.is_a?(Hash) ? SemanticLogger.named_tagged(tag, &block) : SemanticLogger.fast_tag(tag.to_s, &block) end # Need to fla...
ruby
{ "resource": "" }
q26654
SemanticLogger.Base.push_tags
test
def push_tags(*tags) # Need to flatten and reject empties to support calls from Rails 4 new_tags = tags.flatten.collect(&:to_s).reject(&:empty?) SemanticLogger.push_tags(*new_tags) end
ruby
{ "resource": "" }
q26655
SemanticLogger.Base.filtered?
test
def filtered?(log) return false if @filter.nil? @filter.is_a?(Regexp) ? (@filter =~ log.name).nil? : @filter.call(log) != true end
ruby
{ "resource": "" }
q26656
SemanticLogger.Base.log_internal
test
def log_internal(level, index, message = nil, payload = nil, exception = nil, &block) log = Log.new(name, level, index) should_log = if payload.nil? && exception.nil? && message.is_a?(Hash) # Check if someone just logged a hash payload instead of meaning to call semantic logger ...
ruby
{ "resource": "" }
q26657
SemanticLogger.Base.measure_internal
test
def measure_internal(level, index, message, params) exception = nil result = nil # Single parameter is a hash if params.empty? && message.is_a?(Hash) params = message message = nil end start = Process.clock_gettime(Process::CLOCK_MONOTONIC) begin if ...
ruby
{ "resource": "" }
q26658
SemanticLogger.Base.measure_method
test
def measure_method(index:, level:, message:, min_duration:, metric:, log_exception:, on_exception_level:) # Ignores filter, silence, payload exception = nil start ...
ruby
{ "resource": "" }
q26659
SemanticLogger.Logger.log
test
def log(log, message = nil, progname = nil, &block) # Compatibility with ::Logger return add(log, message, progname, &block) unless log.is_a?(SemanticLogger::Log) Logger.call_subscribers(log) Logger.processor.log(log) end
ruby
{ "resource": "" }
q26660
SemanticLogger.Log.assign
test
def assign(message: nil, payload: nil, min_duration: 0.0, exception: nil, metric: nil, metric_amount: nil, duration: nil, backtrace: nil, log_exception: :full, on_exception_level: nil, ...
ruby
{ "resource": "" }
q26661
SemanticLogger.Log.assign_positional
test
def assign_positional(message = nil, payload = nil, exception = nil) # Exception being logged? # Under JRuby a java exception is not a Ruby Exception # Java::JavaLang::ClassCastException.new.is_a?(Exception) => false if exception.nil? && payload.nil? && message.respond_to?(:backtrace) && messa...
ruby
{ "resource": "" }
q26662
SemanticLogger.Log.each_exception
test
def each_exception # With thanks to https://github.com/bugsnag/bugsnag-ruby/blob/6348306e44323eee347896843d16c690cd7c4362/lib/bugsnag/notification.rb#L81 depth = 0 exceptions = [] ex = exception while !ex.nil? && !exceptions.include?(ex) && exceptions.length < MAX_EXCEPTIONS_T...
ruby
{ "resource": "" }
q26663
SemanticLogger.Log.extract_file_and_line
test
def extract_file_and_line(stack, short_name = false) match = CALLER_REGEXP.match(stack.first) [short_name ? File.basename(match[1]) : match[1], match[2].to_i] end
ruby
{ "resource": "" }
q26664
DidYouMean.VerboseFormatter.message_for
test
def message_for(corrections) return "" if corrections.empty? output = "\n\n Did you mean? ".dup output << corrections.join("\n ") output << "\n " end
ruby
{ "resource": "" }
q26665
Flor.Ganger.gather_vars
test
def gather_vars(executor, tconf, message) # try to return before a potentially costly call to executor.vars(nid) return nil if (tconf.keys & %w[ include_vars exclude_vars ]).empty? # default behaviour, don't pass variables to taskers iv = expand_filter(tconf['include_vars']) return ni...
ruby
{ "resource": "" }
q26666
Flor.UnitExecutor.do_run
test
def do_run @unit.logger.log_run_start(self) counter_next('runs') t0 = Time.now (@unit.conf['exe_max_messages'] || 77).times do |i| break if @shutdown m = @messages.shift break unless m m = (@messages << m).shift \ if m['point'] == 'terminated' && ...
ruby
{ "resource": "" }
q26667
Flor.BasicTasker.route
test
def route(name) if name.is_a?(String) [ Flor.dup_and_merge( @message, 'tasker' => name, 'original_tasker' => @message['tasker'], 'routed' => true) ] else [ Flor.dup_and_merge( @message, 'routed' => !! name) ] end end
ruby
{ "resource": "" }
q26668
Flor.Waiter.row_waiter?
test
def row_waiter? @serie.find { |_, points| points.find { |po| pos = po.split(':') pos.length > 1 && ROW_PSEUDO_POINTS.include?(pos[0]) } } end
ruby
{ "resource": "" }
q26669
Flor.FlorModel.node
test
def node(reload=false) nid = @values[:nid]; return nil unless nid exe = execution(reload); return nil unless exe nodes = exe.data['nodes']; return nil unless nodes nodes[nid] end
ruby
{ "resource": "" }
q26670
Flor.Executor.vars
test
def vars(nid, vs={}) n = node(nid); return vs unless n (n['vars'] || {}) .each { |k, v| vs[k] = Flor.dup(v) unless vs.has_key?(k) } pnid = n['parent'] if @unit.loader && pnid == nil && n['vdomain'] != false @unit.loader.variables(n['vdomain'] || Flor.domain(@exid)) ...
ruby
{ "resource": "" }
q26671
Flor.Executor.lookup_on_error_parent
test
def lookup_on_error_parent(message) nd = Flor::Node.new(self, nil, message).on_error_parent nd ? nd.to_procedure_node : nil end
ruby
{ "resource": "" }
q26672
Flor.Trap.decrement
test
def decrement c = data['count'] return false unless c c = c - 1 data['count'] = c self[:status] = s = (c > 0) ? 'active' : 'consumed' self.update( content: Flor::Storage.to_blob(@flor_model_cache_data), status: s) c < 1 end
ruby
{ "resource": "" }
q26673
QC.Worker.work
test
def work queue, job = lock_job if queue && job QC.log_yield(:at => "work", :job => job[:id]) do process(queue, job) end end end
ruby
{ "resource": "" }
q26674
QC.Worker.lock_job
test
def lock_job log(:at => "lock_job") job = nil while @running @queues.each do |queue| if job = queue.lock return [queue, job] end end @conn_adapter.wait(@wait_interval, *@queues.map {|q| q.name}) end end
ruby
{ "resource": "" }
q26675
QC.Worker.call
test
def call(job) args = job[:args] receiver_str, _, message = job[:method].rpartition('.') receiver = eval(receiver_str) receiver.send(message, *args) end
ruby
{ "resource": "" }
q26676
LazyHighCharts.HighChart.method_missing
test
def method_missing(meth, opts = {}) if meth.to_s == 'to_ary' super end if meth.to_s.end_with? '!' deep_merge_options meth[0..-2].to_sym, opts else merge_options meth, opts end end
ruby
{ "resource": "" }
q26677
RackCAS.URL.remove_params
test
def remove_params(params) self.tap do |u| u.query_values = (u.query_values || {}).tap do |qv| params.each do |key, value| qv.delete key end end if u.query_values.empty? u.query_values = nil end end end
ruby
{ "resource": "" }
q26678
RackCAS.ServiceValidationResponse.parse_user_info
test
def parse_user_info(node) return nil if node.nil? {}.tap do |hash| node.children.each do |e| unless e.kind_of?(Nokogiri::XML::Text) || e.name == 'proxies' # There are no child elements if e.element_children.count == 0 if hash.has_key?(e.name) ...
ruby
{ "resource": "" }
q26679
ForemanRemoteExecutionCore.ScriptRunner.run_async
test
def run_async(command) raise 'Async command already in progress' if @started @started = false @user_method.reset session.open_channel do |channel| channel.request_pty channel.on_data do |ch, data| publish_data(data, 'stdout') unless @user_method.filter_password?(data) ...
ruby
{ "resource": "" }
q26680
ForemanRemoteExecutionCore.FakeScriptRunner.exit_code
test
def exit_code fail_chance = ENV.fetch('REX_SIMULATE_FAIL_CHANCE', 0).to_i fail_exitcode = ENV.fetch('REX_SIMULATE_EXIT', 0).to_i if fail_exitcode == 0 || fail_chance < (Random.rand * 100).round 0 else fail_exitcode end end
ruby
{ "resource": "" }
q26681
Transproc.Store.import_method
test
def import_method(source, name, new_name = name) from = name.to_sym to = new_name.to_sym fn = source.is_a?(Registry) ? source.fetch(from) : source.method(from) self.class.new(methods.merge(to => fn)) end
ruby
{ "resource": "" }
q26682
Transproc.Store.import_methods
test
def import_methods(source, names) names.inject(self) { |a, e| a.import_method(source, e) } end
ruby
{ "resource": "" }
q26683
Transproc.Store.import_all
test
def import_all(source) names = source.public_methods - Registry.instance_methods - Module.methods names -= [:initialize] # for compatibility with Rubinius names += source.store.methods.keys if source.is_a? Registry import_methods(source, names) end
ruby
{ "resource": "" }
q26684
Transproc.Registry.[]
test
def [](fn, *args) fetched = fetch(fn) return Function.new(fetched, args: args, name: fn) unless already_wrapped?(fetched) args.empty? ? fetched : fetched.with(*args) end
ruby
{ "resource": "" }
q26685
Transproc.Registry.fetch
test
def fetch(fn) return fn unless fn.instance_of? Symbol respond_to?(fn) ? method(fn) : store.fetch(fn) rescue raise FunctionNotFoundError.new(fn, self) end
ruby
{ "resource": "" }
q26686
Transproc.Function.to_ast
test
def to_ast args_ast = args.map { |arg| arg.respond_to?(:to_ast) ? arg.to_ast : arg } [name, args_ast] end
ruby
{ "resource": "" }
q26687
Transproc.Function.to_proc
test
def to_proc if args.size > 0 proc { |*value| fn.call(*value, *args) } else fn.to_proc end end
ruby
{ "resource": "" }
q26688
UserAgentParser.Parser.from_pattern_match
test
def from_pattern_match(keys, pattern, match) keys.each_with_index.map do |key, idx| # Check if there is any replacement specified if pattern[key] interpolate(pattern[key], match) else # No replacement defined, just return correct match group match[idx + 1] ...
ruby
{ "resource": "" }
q26689
UserAgentParser.Parser.interpolate
test
def interpolate(replacement, match) group_idx = replacement.index('$') return replacement if group_idx.nil? group_nbr = replacement[group_idx + 1] replacement.sub("$#{group_nbr}", match[group_nbr.to_i]) end
ruby
{ "resource": "" }
q26690
Consular.DSL.before
test
def before(*commands, &block) context = (@_context[:before] ||= []) block_given? ? run_context(context, &block) : context.concat(commands) end
ruby
{ "resource": "" }
q26691
Consular.DSL.window
test
def window(*args, &block) key = "window#{@_windows.keys.size}" options = args.extract_options! options[:name] = args.first unless args.empty? context = (@_windows[key] = window_hash.merge(:options => options)) run_context context, &block end
ruby
{ "resource": "" }
q26692
Consular.DSL.tab
test
def tab(*args, &block) tabs = @_context[:tabs] key = "tab#{tabs.keys.size}" return (tabs[key] = { :commands => args }) unless block_given? context = (tabs[key] = {:commands => []}) options = args.extract_options! options[:name] = args.first unless args.empty?...
ruby
{ "resource": "" }
q26693
Consular.DSL.run
test
def run(*commands) context = case when @_context.is_a?(Hash) && @_context[:tabs] @_context[:tabs]['default'][:commands] when @_context.is_a?(Hash) @_context[:commands] else @_context end con...
ruby
{ "resource": "" }
q26694
Aerospike.Command.set_write
test
def set_write(policy, operation, key, bins) begin_cmd field_count = estimate_key_size(key, policy) bins.each do |bin| estimate_operation_size_for_bin(bin) end size_buffer write_header_with_policy(policy, 0, INFO2_WRITE, field_count, bins.length) write_key(key, policy...
ruby
{ "resource": "" }
q26695
Aerospike.Command.set_delete
test
def set_delete(policy, key) begin_cmd field_count = estimate_key_size(key) size_buffer write_header_with_policy(policy, 0, INFO2_WRITE|INFO2_DELETE, field_count, 0) write_key(key) end_cmd end
ruby
{ "resource": "" }
q26696
Aerospike.Command.set_touch
test
def set_touch(policy, key) begin_cmd field_count = estimate_key_size(key) estimate_operation_size size_buffer write_header_with_policy(policy, 0, INFO2_WRITE, field_count, 1) write_key(key) write_operation_for_operation_type(Aerospike::Operation::TOUCH) end_cmd end
ruby
{ "resource": "" }
q26697
Aerospike.Command.set_exists
test
def set_exists(policy, key) begin_cmd field_count = estimate_key_size(key) size_buffer write_header(policy, INFO1_READ|INFO1_NOBINDATA, 0, field_count, 0) write_key(key) end_cmd end
ruby
{ "resource": "" }
q26698
Aerospike.Command.set_read_header
test
def set_read_header(policy, key) begin_cmd field_count = estimate_key_size(key) estimate_operation_size_for_bin_name('') size_buffer # The server does not currently return record header data with _INFO1_NOBINDATA attribute set. # The workaround is to request a non-existent bin. ...
ruby
{ "resource": "" }
q26699
Aerospike.Command.set_operate
test
def set_operate(policy, key, operations) begin_cmd field_count = estimate_key_size(key, policy) read_attr = 0 write_attr = 0 read_header = false operations.each do |operation| case operation.op_type when Aerospike::Operation::READ read_attr |= INFO1_READ ...
ruby
{ "resource": "" }