_id
string
title
string
partition
string
text
string
language
string
meta_information
dict
q24400
Rammer.ModuleGenerator.require_module_to_base
train
def require_module_to_base file = File.open("#{@target_dir}/app/apis/#{@project_name}/base.rb", "r+") file.each do |line| while line == "require_relative './modules/#{@module_name}_apis'\n" do $stdout.puts "\e[33mModule already mounted.\e[0m"
ruby
{ "resource": "" }
q24401
Rammer.ModuleGenerator.copy_module
train
def copy_module src = "#{@gem_path}/lib/modules/#{@module_name}/#{@module_name}_apis.rb" dest = "#{@target_dir}/app/apis/#{@project_name}/modules" presence = File.exists?("#{dest}/#{@module_name}_apis.rb")? true : false FileUtils.mkdir dest unless File.exists?(dest)
ruby
{ "resource": "" }
q24402
Rammer.ModuleGenerator.create_migrations_and_models
train
def create_migrations_and_models src = "#{@gem_path}/lib/modules/migrations" dest = "#{@target_dir}/db/migrate" copy_files(src,dest,AUTH_MIGRATE) if @module_name == "oauth"
ruby
{ "resource": "" }
q24403
Rammer.ModuleGenerator.copy_files
train
def copy_files(src,dest,module_model) module_model.each do |file| presence = File.exists?("#{dest}/#{file}")? true : false unless presence FileUtils.cp("#{src}/#{file}",dest)
ruby
{ "resource": "" }
q24404
Rammer.ModuleGenerator.configure_module_files
train
def configure_module_files source = "#{@target_dir}/app/apis/#{@project_name}/modules/#{@module_name}_apis.rb" application_module = @project_name.split('_').map(&:capitalize)*'' file = File.read(source) replace = file.gsub(/module
ruby
{ "resource": "" }
q24405
Rammer.ModuleGenerator.add_gems
train
def add_gems file = File.open("#{@target_dir}/Gemfile", "r+") file.each do |line| while line == "gem 'oauth2'\n" do return end end File.open("#{@target_dir}/Gemfile", "a+") do |f| f.write("gem 'multi_json'\ngem 'oauth2'\ngem 'songkick-oauth2-provider'\ngem 'ruby...
ruby
{ "resource": "" }
q24406
Rammer.ModuleGenerator.unmount_module
train
def unmount_module path = "#{@target_dir}/app/apis/#{@project_name}" temp_file = "#{path}/tmp.rb" source = "#{path}/base.rb" delete_file = "#{path}/modules/#{@module_name}_apis.rb" File.open(temp_file, "w") do |out_file| File.foreach(source) do |line| unless line =...
ruby
{ "resource": "" }
q24407
Validation.Rules.rule
train
def rule(field, definition) field = field.to_sym rules[field] = [] if rules[field].nil? begin if definition.respond_to?(:each_pair) add_parameterized_rules(field, definition) elsif definition.respond_to?(:each)
ruby
{ "resource": "" }
q24408
Validation.Rules.valid?
train
def valid? valid = true rules.each_pair do |field, rules| if ! @obj.respond_to?(field) raise InvalidKey, "cannot validate non-existent field '#{field}'" end rules.each do |r| if ! r.valid_value?(@obj.send(field))
ruby
{ "resource": "" }
q24409
Validation.Rules.add_single_rule
train
def add_single_rule(field, key_or_klass, params = nil) klass = if key_or_klass.respond_to?(:new) key_or_klass else
ruby
{ "resource": "" }
q24410
Validation.Rules.add_parameterized_rules
train
def add_parameterized_rules(field, rules) rules.each_pair do |key, params|
ruby
{ "resource": "" }
q24411
Validation.Rules.get_rule_class_by_name
train
def get_rule_class_by_name(klass) klass = camelize(klass)
ruby
{ "resource": "" }
q24412
Validation.Rules.camelize
train
def camelize(term) string = term.to_s string = string.sub(/^[a-z\d]*/) { $&.capitalize }
ruby
{ "resource": "" }
q24413
ValidationReflection.ClassMethods.remember_validation_metadata
train
def remember_validation_metadata(validation_type, *attr_names) configuration = attr_names.last.is_a?(::Hash) ? attr_names.pop : {} self.validations ||= [] attr_names.flatten.each do |attr_name|
ruby
{ "resource": "" }
q24414
Capypage.Element.element
train
def element(name, selector, options = {}) define_singleton_method(name) { Element.new(selector,
ruby
{ "resource": "" }
q24415
Rammer.RammerGenerator.create_base_dirs
train
def create_base_dirs BASE_DIR.each do |dir| FileUtils.mkdir "#{@project_name}/#{dir}" $stdout.puts "\e[1;32m \tcreate\e[0m\t#{dir}"
ruby
{ "resource": "" }
q24416
Rammer.RammerGenerator.create_api_module
train
def create_api_module File.open("#{@project_name}/app/apis/#{@project_name}/base.rb", "w") do |f| f.write('module ') f.puts(@module_name)
ruby
{ "resource": "" }
q24417
Rammer.RammerGenerator.config_server
train
def config_server file = File.open("#{@project_name}/server.rb", "r+") file.each do |line| while line == " def response(env)\n" do pos = file.pos rest = file.read file.seek pos file.write("\t::")
ruby
{ "resource": "" }
q24418
Rammer.RammerGenerator.copy_files_to_target
train
def copy_files_to_target COMMON_RAMMER_FILES.each do |file| source = File.join("#{@gem_path}/lib/modules/common/",file)
ruby
{ "resource": "" }
q24419
Rammer.ScaffoldGenerator.create_model_file
train
def create_model_file dir = "/app/models/#{@scaffold_name}.rb" unless File.exists?(File.join(Dir.pwd,dir)) File.join(Dir.pwd,dir) source = "#{@gem_path}/lib/modules/scaffold/model.rb" FileUtils.cp(source,File.join(Dir.pwd,dir)) config_model @valid = true
ruby
{ "resource": "" }
q24420
Rammer.ScaffoldGenerator.create_migration
train
def create_migration migration_version = Time.now.to_i dir = "/db/migrate/#{migration_version}_create_#{@scaffold_name}s.rb" unless File.exists?(File.join(Dir.pwd,dir)) source = "#{@gem_path}/lib/modules/scaffold/migration.rb"
ruby
{ "resource": "" }
q24421
Rammer.ScaffoldGenerator.config_migration
train
def config_migration(migration_version) source = "#{Dir.pwd}/db/migrate/#{migration_version}_create_#{@scaffold_name}s.rb" modify_content(source, 'CreateMigration', "Create#{@model_class}s") modify_content(source, 'migration', "#{@scaffold_name}s") @arguments.each do |value| @attri...
ruby
{ "resource": "" }
q24422
Rammer.ScaffoldGenerator.add_attributes
train
def add_attributes(source,attribute,data_type) file = File.open(source, "r+") file.each do |line| while line == " create_table :#{@scaffold_name}s do |t|\n" do pos = file.pos rest = file.read
ruby
{ "resource": "" }
q24423
Rammer.ScaffoldGenerator.enable_apis
train
def enable_apis dir = "/app/apis/#{@project_name}/#{@scaffold_name}s/base_apis.rb" base_dir = "#{Dir.pwd}/app/apis/#{@project_name}/#{@scaffold_name}s" unless File.exists?(File.join(Dir.pwd,dir))
ruby
{ "resource": "" }
q24424
Rammer.ScaffoldGenerator.config_apis
train
def config_apis source = "#{Dir.pwd}/app/apis/#{@project_name}/#{@scaffold_name}s/base_apis.rb" content = ['AppName','ScaffoldName', 'Model', 'model'] replacement
ruby
{ "resource": "" }
q24425
Rammer.ScaffoldGenerator.mount_apis
train
def mount_apis require_apis_to_base mount_class = "::#{@project_class}::#{@model_class}s::BaseApis" file = File.open("#{Dir.pwd}/app/apis/#{@project_name}/base.rb", "r+") file.each do |line|
ruby
{ "resource": "" }
q24426
Rammer.ScaffoldGenerator.require_apis_to_base
train
def require_apis_to_base File.open("#{Dir.pwd}/app/apis/#{@project_name}/base.rb", "r+") do |f| pos = f.pos rest = f.read f.seek pos
ruby
{ "resource": "" }
q24427
Rammer.ScaffoldGenerator.to_underscore
train
def to_underscore(value) underscore_value = value.gsub(/::/, '/').gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
ruby
{ "resource": "" }
q24428
Reth.ChainService.knows_block
train
def knows_block(blockhash) return true if @chain.include?(blockhash)
ruby
{ "resource": "" }
q24429
HaystackRuby.Config.load!
train
def load!(path, environment = nil) require 'yaml' environment ||= Rails.env
ruby
{ "resource": "" }
q24430
OpenNlp.Chunker.chunk
train
def chunk(str) raise ArgumentError, 'str must be a String' unless str.is_a?(String) tokens = tokenizer.tokenize(str) pos_tags = pos_tagger.tag(tokens).to_ary chunks =
ruby
{ "resource": "" }
q24431
Greeklish.GreeklishGenerator.generate_greeklish_words
train
def generate_greeklish_words(greek_words) @greeklish_list.clear greek_words.each do |greek_word| @per_word_greeklish.clear initial_token = greek_word digraphs.each_key do |key| greek_word = greek_word.gsub(key, digraphs[key]) end # Convert it back to arr...
ruby
{ "resource": "" }
q24432
OpenNlp.SentenceDetector.detect
train
def detect(str) raise ArgumentError, 'str must be a String' unless str.is_a?(String)
ruby
{ "resource": "" }
q24433
OpenNlp.SentenceDetector.pos_detect
train
def pos_detect(str) raise ArgumentError, 'str must be a String' unless str.is_a?(String) j_instance.sentPosDetect(str).map do |span|
ruby
{ "resource": "" }
q24434
Greeklish.GreekReverseStemmer.generate_greek_variants
train
def generate_greek_variants(token_string) # clear the list from variations of the previous greek token @greek_words.clear # add the initial greek token in the greek words @greek_words << token_string # Find the first matching suffix and generate the variants # of this word. S...
ruby
{ "resource": "" }
q24435
OpenNlp.NamedEntityDetector.detect
train
def detect(tokens) raise ArgumentError, 'tokens must be an instance of Array' unless tokens.is_a?(Array)
ruby
{ "resource": "" }
q24436
Reth.Synchronizer.receive_newblock
train
def receive_newblock(proto, t_block, chain_difficulty) logger.debug 'newblock', proto: proto, block: t_block, chain_difficulty: chain_difficulty, client: proto.peer.remote_client_version if @chain.include?(t_block.header.full_hash) raise AssertError, 'chain difficulty mismatch' unless chain_difficu...
ruby
{ "resource": "" }
q24437
Reth.Synchronizer.receive_status
train
def receive_status(proto, blockhash, chain_difficulty) logger.debug 'status received', proto: proto, chain_difficulty: chain_difficulty @protocols[proto] = chain_difficulty if @chainservice.knows_block(blockhash) || @synctask logger.debug 'existing task or known hash, discarding' ret...
ruby
{ "resource": "" }
q24438
Reth.Synchronizer.receive_newblockhashes
train
def receive_newblockhashes(proto, newblockhashes) logger.debug 'received newblockhashes', num: newblockhashes.size, proto: proto newblockhashes = newblockhashes.select {|h| !@chainservice.knows_block(h) } known = @protocols.include?(proto) if !known || newblockhashes.empty? || @synctask ...
ruby
{ "resource": "" }
q24439
HaystackRuby.Project.api_eval
train
def api_eval(expr_str) body = ["ver:\"#{@haystack_version}\""] body << "expr" body << '"'+expr_str+'"' res = self.connection.post('eval') do |req|
ruby
{ "resource": "" }
q24440
HaystackRuby.Project.equip_point_meta
train
def equip_point_meta begin equips = read({filter: '"equip"'})['rows'] puts equips equips.map! do |eq| eq.delete('disMacro') eq['description'] = eq['id'].match(/[(NWTC)|(\$siteRef)] (.*)/)[1] eq['id'] = eq['id'].match(/:([a-z0-9\-]*)/)[1] eq['points']...
ruby
{ "resource": "" }
q24441
OpenNlp.Parser.parse
train
def parse(text) raise ArgumentError, 'passed text must be a String' unless text.is_a?(String)
ruby
{ "resource": "" }
q24442
IGMarkets.ResponseParser.parse
train
def parse(response) if response.is_a? Hash response.each_with_object({}) do |(key, value), new_hash| new_hash[camel_case_to_snake_case(key).to_sym] = parse(value) end elsif
ruby
{ "resource": "" }
q24443
OpenNlp.Categorizer.categorize
train
def categorize(str) raise ArgumentError, 'str param must be a String' unless str.is_a?(String) outcomes
ruby
{ "resource": "" }
q24444
Udongo::Pages.TreeNode.data
train
def data { text: @page.description, type: :file, li_attr: list_attributes, data: { id: @page.id, url: @context.edit_translation_backend_page_path(@page, Udongo.config.i18n.app.default_locale), delete_url: @context.backend_page_path(@page, format: :json...
ruby
{ "resource": "" }
q24445
Greeklish.GreeklishConverter.identify_greek_word
train
def identify_greek_word(input) input.each_char do |char| if (!GREEK_CHARACTERS.include?(char))
ruby
{ "resource": "" }
q24446
IGMarkets.Position.close
train
def close(options = {}) options[:deal_id] = deal_id options[:direction] = { buy: :sell, sell: :buy }.fetch(direction) options[:size] ||= size model = PositionCloseAttributes.build options
ruby
{ "resource": "" }
q24447
IGMarkets.Position.update
train
def update(new_attributes) new_attributes = { limit_level: limit_level, stop_level: stop_level, trailing_stop: trailing_stop?, trailing_stop_distance: trailing_stop_distance, trailing_stop_increment: trailing_step } .merge new_attributes unless new_attributes...
ruby
{ "resource": "" }
q24448
IGMarkets.PasswordEncryptor.encoded_public_key=
train
def encoded_public_key=(encoded_public_key) self.public_key = OpenSSL::PKey::RSA.new
ruby
{ "resource": "" }
q24449
IGMarkets.PasswordEncryptor.encrypt
train
def encrypt(password) encoded_password = Base64.strict_encode64 "#{password}|#{time_stamp}" encrypted_password =
ruby
{ "resource": "" }
q24450
Smurfville.TypographyParser.is_typography_selector?
train
def is_typography_selector?(node) node.is_a?(Sass::Tree::RuleNode)
ruby
{ "resource": "" }
q24451
Reth.AccountService.coinbase
train
def coinbase cb_hex = (app.config[:pow] || {})[:coinbase_hex] if cb_hex raise ValueError, 'coinbase must be String' unless cb_hex.is_a?(String) begin cb = Utils.decode_hex Utils.remove_0x_head(cb_hex) rescue TypeError raise ValueError, 'invalid coinbase'
ruby
{ "resource": "" }
q24452
Reth.AccountService.add_account
train
def add_account(account, store=true, include_address=true, include_id=true) logger.info "adding account", account: account if account.uuid && @accounts.any? {|acct| acct.uuid == account.uuid } logger.error 'could not add account (UUID collision)', uuid: account.uuid raise ValueError, 'Could...
ruby
{ "resource": "" }
q24453
Reth.AccountService.update_account
train
def update_account(account, new_password, include_address=true, include_id=true) raise ValueError, "Account not managed by account service" unless @accounts.include?(account) raise ValueError, "Cannot update locked account" if account.locked? raise ValueError, 'Account not stored on disk' unless accou...
ruby
{ "resource": "" }
q24454
Reth.AccountService.find
train
def find(identifier) identifier = identifier.downcase if identifier =~ /\A[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\z/ # uuid return get_by_id(identifier) end begin address = Address.new(identifier).to_bytes raise AssertError unless address.size == 20...
ruby
{ "resource": "" }
q24455
Reth.AccountService.get_by_id
train
def get_by_id(id) accts = @accounts.select {|acct| acct.uuid == id } if accts.size == 0 raise KeyError, "account with id #{id} unknown" elsif accts.size > 1
ruby
{ "resource": "" }
q24456
Reth.AccountService.get_by_address
train
def get_by_address(address) raise ArgumentError, 'address must be 20 bytes' unless address.size == 20 accts = @accounts.select {|acct| acct.address == address }
ruby
{ "resource": "" }
q24457
IGMarkets.Model.to_h
train
def to_h attributes.each_with_object({}) do |(key, value), hash| hash[key] = if value.is_a? Model value.to_h
ruby
{ "resource": "" }
q24458
IGMarkets.DealingPlatform.sign_in
train
def sign_in(username, password, api_key, platform) session.username = username session.password = password session.api_key = api_key session.platform = platform
ruby
{ "resource": "" }
q24459
IGMarkets.Format.colored_currency
train
def colored_currency(amount, currency_name) return '' unless amount color = amount < 0 ? :red : :green
ruby
{ "resource": "" }
q24460
IGMarkets.RequestBodyFormatter.snake_case_to_camel_case
train
def snake_case_to_camel_case(value) pieces = value.to_s.split '_' (pieces.first
ruby
{ "resource": "" }
q24461
Reth.Account.dump
train
def dump(include_address=true, include_id=true) h = {} h[:crypto] = @keystore[:crypto] h[:version] = @keystore[:version]
ruby
{ "resource": "" }
q24462
Reth.Account.sign_tx
train
def sign_tx(tx) if privkey logger.info "signing tx", tx: tx, account: self tx.sign privkey else
ruby
{ "resource": "" }
q24463
SimpleXml.Document.detect_unstratified
train
def detect_unstratified missing_populations = [] # populations are keyed off of values rather than the codes existing_populations = @populations.map{|p| p.values.join('-')}.uniq @populations.each do |population| keys = population.keys - ['STRAT','stratification'] missing_populati...
ruby
{ "resource": "" }
q24464
Ganapati.Client.put
train
def put(localpath, destpath) create(destpath) { |dest| Kernel.open(localpath) { |source| # read 1 MB at a time
ruby
{ "resource": "" }
q24465
Ganapati.Client.get
train
def get(remotepath, destpath) Kernel.open(destpath, 'w') { |dest| readchunks(remotepath)
ruby
{ "resource": "" }
q24466
Ganapati.Client.readchunks
train
def readchunks(path, chunksize=1048576) open(path) { |source| size = source.length
ruby
{ "resource": "" }
q24467
OpenNlp.Tokenizer.tokenize
train
def tokenize(str) raise ArgumentError, 'str must be a String' unless str.is_a?(String)
ruby
{ "resource": "" }
q24468
OpenNlp.POSTagger.tag
train
def tag(tokens) !tokens.is_a?(Array) && !tokens.is_a?(String) && raise(ArgumentError,
ruby
{ "resource": "" }
q24469
IGMarkets.Account.reload
train
def reload self.attributes = @dealing_platform.account.all.detect { |a|
ruby
{ "resource": "" }
q24470
Contentstack.Query.only
train
def only(fields, fields_with_base=nil) q = {} if [Array, String].include?(fields_with_base.class) fields_with_base = [fields_with_base] if fields_with_base.class
ruby
{ "resource": "" }
q24471
IGMarkets.WorkingOrder.update
train
def update(new_attributes) existing_attributes = { good_till_date: good_till_date, level: order_level, limit_distance: limit_distance, stop_distance: stop_distance, time_in_force: time_in_force, type: order_type } model = WorkingOrderUpdateAttributes.new existing_attributes, n...
ruby
{ "resource": "" }
q24472
Smurfville.ColorVariableParser.add_color
train
def add_color(node, key = nil) key ||= node.expr.to_s self.colors[key] ||= { :variables => [], :alternate_values => [] } self.colors[key][:variables] << node.name
ruby
{ "resource": "" }
q24473
Rack.Rescue.apply_layout
train
def apply_layout(env, content, opts) if layout = env['layout'] layout.format = opts[:format] layout.content = content
ruby
{ "resource": "" }
q24474
MemoryIO.Process.read
train
def read(addr, num_elements, **options) mem_io(:read) {
ruby
{ "resource": "" }
q24475
MemoryIO.Process.write
train
def write(addr, objects, **options) mem_io(:write) {
ruby
{ "resource": "" }
q24476
Turbot.Helpers.netrc_path
train
def netrc_path unencrypted = Netrc.default_path encrypted = unencrypted + '.gpg' if File.exists?(encrypted)
ruby
{ "resource": "" }
q24477
Turbot.Helpers.open_netrc
train
def open_netrc begin Netrc.read(netrc_path) rescue Netrc::Error =>
ruby
{ "resource": "" }
q24478
Turbot.Helpers.save_netrc_entry
train
def save_netrc_entry(email_address, api_key) netrc = open_netrc
ruby
{ "resource": "" }
q24479
Humus.Snapshots.seed_from_dump
train
def seed_from_dump id target_path = File.expand_path("../../fixtures/trunk-#{id}.dump", __FILE__) raise "Dump #{id} could not be found." unless File.exists? target_path puts "Restoring #{ENV['RACK_ENV']} database from #{target_path}" # Ensure we're starting from a clean DB. s...
ruby
{ "resource": "" }
q24480
Humus.Snapshots.dump_prod
train
def dump_prod id target_path = File.expand_path("../../fixtures/trunk-#{id}.dump", __FILE__) puts "Dumping production database from Heroku (works only if you have access to the database)" command = "curl -o #{target_path} \`heroku pg:backups public-url #{id} -a cocoapods-trunk-service\`" puts "E...
ruby
{ "resource": "" }
q24481
Win.Library.try_function
train
def try_function(name, params, returns, options={}, &def_block) begin function name, params, returns, options, &def_block
ruby
{ "resource": "" }
q24482
Win.Library.define_api
train
def define_api(name, camel_name, effective_names, params, returns, options) params, returns = generate_signature(params.dup, returns) ffi_lib *(ffi_libraries.map(&:name) << options[:dll]) if options[:dll] libs = ffi_libraries.map(&:name) alternative = options.delete(:alternative) # Function ma...
ruby
{ "resource": "" }
q24483
Yap::Shell.Evaluation.recursively_find_and_replace_command_substitutions
train
def recursively_find_and_replace_command_substitutions(input) input = input.dup Parser.each_command_substitution_for(input) do |substitution_result, start_position, end_position| debug_log "found command substitution at position=#{(start_position..end_position)} #{substitution_result.inspect}" ...
ruby
{ "resource": "" }
q24484
Yap::Shell.Evaluation.visit_CommandNode
train
def visit_CommandNode(node) debug_visit(node) @aliases_expanded ||= [] @command_node_args_stack ||= [] with_standard_streams do |stdin, stdout, stderr| args = process_ArgumentNodes(node.args) if !node.literal? && !@aliases_expanded.include?(node.command) && Aliases.instance.has_k...
ruby
{ "resource": "" }
q24485
Danger.DangerJazzy.undocumented
train
def undocumented(scope = :modified) return [] unless scope != :ignore && File.exist?(undocumented_path) @undocumented = { modified: [], all: [] } if @undocumented.nil?
ruby
{ "resource": "" }
q24486
Spree.LiqpayStatusController.update
train
def update @payment_method = PaymentMethod.find params[:payment_method_id] data = JSON.parse Base64.strict_decode64 params[:data] render text: "Bad signature\n", status: 401 and return unless @payment_method.check_signature params[:data], params[:signature] @order = Order.find data['order_id'] ...
ruby
{ "resource": "" }
q24487
Kazoo.Cluster.brokers
train
def brokers @brokers_mutex.synchronize do @brokers ||= begin brokers = zk.get_children(path: "/brokers/ids") if brokers.fetch(:rc) != Zookeeper::Constants::ZOK raise NoClusterRegistered, "No Kafka cluster registered on this Zookeeper location." end res...
ruby
{ "resource": "" }
q24488
Kazoo.Cluster.consumergroups
train
def consumergroups @consumergroups ||= begin consumers = zk.get_children(path: "/consumers")
ruby
{ "resource": "" }
q24489
Kazoo.Cluster.topics
train
def topics(preload: Kazoo::Topic::DEFAULT_PRELOAD_METHODS) @topics_mutex.synchronize do @topics ||= begin topics = zk.get_children(path: "/brokers/topics") raise Kazoo::Error, "Failed to list topics. Error code:
ruby
{ "resource": "" }
q24490
Kazoo.Cluster.create_topic
train
def create_topic(name, partitions: nil, replication_factor: nil, config: nil) raise ArgumentError, "partitions must be a positive integer" if Integer(partitions) <= 0 raise ArgumentError, "replication_factor must be a positive integer" if Integer(replication_factor) <= 0
ruby
{ "resource": "" }
q24491
Kazoo.Cluster.preferred_leader_election
train
def preferred_leader_election(partitions: nil) partitions = self.partitions if partitions.nil? result = zk.create(path: "/admin/preferred_replica_election", data: JSON.generate(version: 1, partitions: partitions)) case result.fetch(:rc) when Zookeeper::Constants::ZOK return true wh...
ruby
{ "resource": "" }
q24492
Kazoo.Cluster.recursive_create
train
def recursive_create(path: nil) raise ArgumentError, "path is a required argument" if path.nil? result = zk.stat(path: path) case result.fetch(:rc) when Zookeeper::Constants::ZOK return when Zookeeper::Constants::ZNONODE recursive_create(path: File.dirname(path))
ruby
{ "resource": "" }
q24493
Kazoo.Cluster.recursive_delete
train
def recursive_delete(path: nil) raise ArgumentError, "path is a required argument" if path.nil? result = zk.get_children(path: path) raise Kazoo::Error, "Failed to list children of #{path} to delete them. Result code: #{result.fetch(:rc)}" if result.fetch(:rc) != Zookeeper::Constants::ZOK
ruby
{ "resource": "" }
q24494
Ikku.Reviewer.find
train
def find(text) nodes = parser.parse(text) nodes.length.times.find do |index| if
ruby
{ "resource": "" }
q24495
Ikku.Reviewer.judge
train
def judge(text) Song.new(parser.parse(text), exactly: true,
ruby
{ "resource": "" }
q24496
Ikku.Reviewer.search
train
def search(text) nodes = parser.parse(text) nodes.length.times.map do |index|
ruby
{ "resource": "" }
q24497
Kazoo.Broker.led_partitions
train
def led_partitions result, mutex = [], Mutex.new threads = cluster.partitions.map do |partition| Thread.new do Thread.abort_on_exception = true select = partition.leader ==
ruby
{ "resource": "" }
q24498
Kazoo.Broker.replicated_partitions
train
def replicated_partitions result, mutex = [], Mutex.new threads = cluster.partitions.map do |partition| Thread.new do Thread.abort_on_exception = true select = partition.replicas.include?(self)
ruby
{ "resource": "" }
q24499
Kazoo.Broker.critical?
train
def critical?(replicas: 1) result, mutex = false, Mutex.new threads = replicated_partitions.map do |partition| Thread.new do Thread.abort_on_exception = true
ruby
{ "resource": "" }