query
stringlengths 7
9.55k
| document
stringlengths 10
363k
| metadata
dict | negatives
listlengths 0
101
| negative_scores
listlengths 0
101
| document_score
stringlengths 3
10
| document_rank
stringclasses 102
values |
|---|---|---|---|---|---|---|
Checks if a network exists or not
|
def network_exists?(name)
net_obj = Com::Vmware::Vcenter::Network.new(vapi_config)
filter = Com::Vmware::Vcenter::Network::FilterSpec.new(names: Set.new([name]))
net = net_obj.list(filter)
raise format("Unable to find target network: %s", name) if net.empty?
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def network_exists?(network_name)\n networks_list.include?(network_name)\n end",
"def network_exists?(name)\n net_api = VSphereAutomation::VCenter::NetworkApi.new(api_client)\n raise_if_unauthenticated net_api, \"checking for VM network `#{name}`\"\n\n nets = net_api.list({ filter_names: name }).value\n\n raise_if_missing nets, format(\"Unable to find target network: `%s`\", name)\n end",
"def CheckNetwork(network)\n CheckNetwork4(network) || CheckNetwork6(network)\n end",
"def validate_network_name!(network_name, env)\n if !env[:machine].provider.driver.existing_named_network?(network_name)\n raise Errors::NetworkNameUndefined,\n network_name: network_name\n end\n true\n end",
"def use_existing_network?\n return false unless configured?\n\n @gcp_config['use_existing_network']\n end",
"def check_network(options, attributes)\n env.logger.info \"Checking network\"\n if options.nil? or options.empty? or options[\"network_type\"].nil? or options[\"network_type\"] == \"network\"\n check_default_network\n attributes[:network_interface_type] = \"network\"\n elsif options[\"network_type\"] == \"bridge\"\n options[\"network_bridge_name\"].nil?\n if options[\"network_bridge_name\"].nil?\n raise Veewee::Error, \"You need to specify a 'network_bridge_name' if you plan to use 'bridge' as network type\"\n else\n attributes[:network_interface_type] = \"bridge\"\n attributes[:network_bridge_name] = \"#{options[\"network_bridge_name\"]}\"\n end\n else\n raise Veewee::Error, \"You specified a 'network_type' that isn't known (#{options[\"network_type\"]})\"\n end\n end",
"def use_existing_network?\n @gcp_config['use_existing_network']\n end",
"def exists?(resource_group_name)\n OOLog.fatal('VNET name is nil. It is required.') if @name.nil?\n\n begin\n OOLog.info(\"Checking if Virtual Network '#{@name}' Exists! ...\")\n promise = @client.virtual_networks.get(resource_group_name, @name)\n response = promise.value!\n OOLog.info('VNET EXISTS!!')\n return true\n rescue MsRestAzure::AzureOperationError => e\n OOLog.info(\"Exception from Azure: #{e.body}\")\n # check the error\n # If the error is that it doesn't exist, return true\n OOLog.info(\"Error of Exception is: '#{e.body.values[0]}'\")\n OOLog.info(\"Code of Exception is: '#{e.body.values[0]['code']}'\")\n if(e.body.values[0]['code'] == 'ResourceNotFound')\n OOLog.info('VNET DOES NOT EXIST!!')\n return false\n else\n # for all other errors, throw the exception back\n OOLog.fatal(\"Error getting virtual network: #{@name} from resource group #{resource_group_name}. Exception: #{e.body}\")\n end\n rescue => ex\n OOLog.fatal(\"Error getting virtual network: #{@name} from resource group #{resource_group_name}. Exception: #{ex.message}\")\n end\n end",
"def exists?(resource_group_name)\n OOLog.fatal('VNET name is nil. It is required.') if @name.nil?\n OOLog.info(\"Checking if Virtual Network '#{@name}' Exists! ...\")\n begin\n result = @network_client.virtual_networks.check_virtual_network_exists(resource_group_name, @name)\n rescue MsRestAzure::AzureOperationError => e\n OOLog.fatal(\"Error getting virtual network: #{@name} from resource group #{resource_group_name}. Exception: #{e.body}\")\n rescue => ex\n OOLog.fatal(\"Error getting virtual network: #{@name} from resource group #{resource_group_name}. Exception: #{ex.message}\")\n end\n result\n end",
"def has_network?\n Friend.has_network?(self)\n end",
"def exists?\n File.directory?(\"/sys/class/net/#{name}\").tap do |exists|\n deconfigure unless exists || @clean\n end\n end",
"def network?\n if matches = match(/\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}(\\/\\d{1,2})/)\n matches.captures[0]\n else \n false\n end\n end",
"def eligible?()\n @networks.include? @remote_network\n end",
"def network n\n @logger.debug \"OpenStack: Looking up network '#{n}'\"\n @network_client.networks.find { |x| x.name == n } || raise(\"Couldn't find network: #{n}\")\n end",
"def exist?\n self.class.exists?(dn)\n end",
"def ensure_valid_network\n if valid_network.nil?\n self.build_valid_network(:tag => \"#{self.tag} Asset Config Network\")\n end\n end",
"def edge_net?(network_name:)\n @networks_nodes[network_name].nil? || @networks_nodes[network_name].length == 1\n end",
"def secure_network?\n (self.networks.count(:conditions => { :is_secure => true }) > 0)\n end",
"def missing_network_topology?\n !missing_network_topology.empty?\n end",
"def uplink_has_network_of_type?(uplink, type)\n uplink_networks(uplink).map do |network|\n network[\"type\"].downcase\n end.include?(type.downcase)\n end",
"def ensure_network\n ensure_valid_network\n if network.nil?\n valid_network.build_network(:tag => \"#{self.tag} View\")\n end\n end",
"def ip_subnet_exist?\n ip_exist? && subnet_exist?\n end",
"def subnet_exist?\n return false if current_resource.netmasks.nil? || current_resource.addresses.nil?\n current_resource.netmasks[current_resource.addresses.index(new_resource.address)] == new_resource.netmask\n end",
"def verify_networks(networks_in_zone, zone_name)\n b_verify_ok = true\n networks_in_zone.each do |network_name, network_data|\n $log.debug(\"Verifying network \\'#{network_name}\\'\")\n\n bridge_name = network_name\n\n $log.debug 'checking bridge ...'\n # we should have a bridge with that name.\n if @handler.handle_bridge(bridge_name) == false\n network_data.store :status, :failed\n b_verify_ok = false\n mark(\"Bridge \\'#{bridge_name}\\' does not exist.\",\n :network, network_name, network_data)\n else\n network_data.store :status, :ok\n\n hostip = network_data[:hostip]\n # if we have a host ip, then that bridge should have\n # this ip\n if hostip\n $log.debug 'checking host-ip ...'\n\n # if the hostip is not in cidr, take netmask\n # from network entry, add to hostip\n hostip = ensure_hostip_netmask(hostip, network_data)\n\n if @handler.handle_hostip(bridge_name, hostip) == false\n network_data.store :status, :failed\n b_verify_ok = false\n mark(\"Host ip \\'#{hostip}\\' not up on bridge \\'#{bridge_name}\\'.\",\n :network, network_name, network_data)\n else\n network_data.store :status, :ok\n end\n end\n\n # if we have dhcp, check this\n dhcp_data = network_data[:dhcp]\n if dhcp_data\n $log.debug 'checking dhcp ...'\n if @handler.handle_dhcp(zone_name, network_name, network_data,\n dhcp_data[:start],\n dhcp_data[:end]) == false\n network_data.store :status, :failed\n b_verify_ok = false\n mark(\"dnsmasq/dhcp not configured on network \\'#{bridge_name}\\'.\",\n :network, network_name, network_data)\n else\n network_data.store :status, :ok\n end\n end\n end\n end\n b_verify_ok\n end",
"def interface?(ifname)\n\n\t\tip('link', 'list', ifname)\n\t\trescue Puppet::ExecutionFailure\n\t\t\twarnonce(\"Network interface \" + ifname + \" does not exist\")\n\n\tend",
"def live?\n networks = self.class.all false\n network = networks.find { |net| net.name == name }\n network ? true : false\n end",
"def configured_network?(network, server)\n case network.type\n when \"FIP_SNOOPING\"\n false\n when \"PXE\"\n server.os_image_type == \"vmware_esxi\" || !server.os_installed?\n else\n true\n end\n end",
"def check_multipass_hostonly_network(options,if_name)\n gw_if_name = get_gw_if_name(options)\n check_nat(options,gw_if_name,if_name)\n return\nend",
"def RunningNetworkPopup\n Builtins.y2internal(\"RunningNetworkPopup %1\", isNetworkRunning)\n if isNetworkRunning\n return true\n else\n error_text = Builtins.sformat(\n \"%1\\n%2 %3\",\n _(\"No running network detected.\"),\n Mode.installation ?\n _(\"Restart installation and configure network in Linuxrc\") :\n _(\n \"Configure network with YaST or Network Manager plug-in\\nand start this module again\"\n ),\n _(\"or continue without network.\")\n )\n Popup.ContinueCancel(error_text)\n Builtins.y2error(\"Network not runing!\")\n return false\n end\n end",
"def validate_network_configuration!(network_name, root_options, network_options, driver)\n if root_options[:ip] &&\n driver.network_containing_address(root_options[:ip]) != network_name\n raise Errors::NetworkAddressInvalid,\n address: root_options[:ip],\n network_name: network_name\n end\n if network_options[:subnet] &&\n driver.network_containing_address(network_options[:subnet]) != network_name\n raise Errors::NetworkSubnetInvalid,\n subnet: network_options[:subnet],\n network_name: network_name\n end\n true\n end",
"def find_network(name)\n @networks.find { |nw| nw.name == name }\n end",
"def exists?\n # TODO: Expose window querying from driver\n url != ''\n end",
"def internet?(cmd)\n return true if cmd[:noinetchk]\n\n dns_resolver = Resolv::DNS.new\n begin\n dns_resolver.getaddress('icann.org')\n true\n rescue Resolv::ResolvError => _e\n print \"\\nThere appears to be no internet access on this computer, \".red,\n \"the script cannot continue.\\n\\n\".red\n false\n end\n end",
"def exists?\n start_time = Time.now\n timeout = resource[:timeout]\n try_sleep = resource[:try_sleep]\n\n success = validator.attempt_connection\n\n while success == false && ((Time.now - start_time) < timeout)\n # It can take several seconds for an HTTP service to start up;\n # especially on the first install. Therefore, our first connection attempt\n # may fail. Here we have somewhat arbitrarily chosen to retry every 2\n # seconds until the configurable timeout has expired.\n Puppet.notice(\"Failed to make an HTTP connection; sleeping #{try_sleep} seconds before retry\")\n sleep try_sleep\n success = validator.attempt_connection\n end\n\n if success\n Puppet.debug(\"Connected to the host in #{Time.now - start_time} seconds.\")\n else\n Puppet.notice(\"Failed to make an HTTP connection within timeout window of #{timeout} seconds; giving up.\")\n end\n\n success\n end",
"def computer_exists?(fwip)\n system(\"ping -c1 -w1 #{fwip}\")\nend",
"def exists?\n system = Sonos::System.new\n speaker = system.speakers.select { |s| s.name.downcase == @resource[:name].downcase }\n present = false\n if speaker.size < 1\n fail(\"Speaker #{resource[:name]} not associated to network?\")\n else\n if speaker[0].get_player_state[:state] == 'PLAYING'\n present = true\n end\n end\n\n present\n end",
"def network_device?(device)\n device_name = (device[\"productName\"] ? device[\"productName\"] : device[\"name\"]).try(:downcase)\n device[\"class\"] == \"Network controller\" || device_name =~ /nic/ || device_name =~ /ethernet/\n end",
"def check_vbox_hostonly_network()\n message = \"Checking:\\tVirtualBox hostonly network exists\"\n command = \"VBoxManage list hostonlyifs |grep '^Name' |awk '{print $2}' |head -1\"\n if_name = execute_command(message,command)\n if_name = if_name.chomp\n if !if_name.match(/vboxnet/)\n message = \"Plumbing:\\tVirtualBox hostonly network\"\n command = \"VBoxManage hostonlyif create\"\n execute_command(message,command)\n message = \"Finding:\\tVirtualBox hostonly network name\"\n command = \"VBoxManage list hostonlyifs |grep '^Name' |awk '{print $2}' |head -1\"\n if_name = execute_command(message,command)\n if_name = if_name.chomp\n if_name = if_name.gsub(/'/,\"\")\n message = \"Disabling:\\tDHCP on \"+if_name\n command = \"VBoxManage dhcpserver remove --ifname #{if_name}\"\n execute_command(message,command)\n end\n message = \"Checking:\\tVirtualBox hostonly network \"+if_name+\" has address \"+$default_hostonly_ip\n command = \"VBoxManage list hostonlyifs |grep 'IPAddress' |awk '{print $2}' |head -1\"\n host_ip = execute_command(message,command)\n host_ip = host_ip.chomp\n if !host_ip.match(/#{$default_hostonly_ip}/)\n message = \"Configuring:\\tVirtualBox hostonly network \"+if_name+\" with IP \"+$default_hostonly_ip\n command = \"VBoxManage hostonlyif ipconfig #{if_name} --ip #{$default_hostonly_ip} --netmask #{$default_netmask}\"\n execute_command(message,command)\n end\n gw_if_name = get_osx_gw_if_name()\n check_osx_nat(gw_if_name,if_name)\n return if_name\nend",
"def exists_ip_in_unique_net?(object, parent)\n puts \"\\\\\\\\ 1. IP IN UNIQUE_NET ?? \\\\\\\\\"\n temp = Ipnet.find(:first, :conditions => [\"parent_id = ? and unq = ?\", parent, true])\n if not temp.nil?\n puts \"ipnet.rb: Validierung fehlgeschlagen (Unique IP für das Netz bereits vergeben)\"\n errors.add(:ipaddr, \"ist für das Netz bereits vergeben.\") and puts \"ipnet.rb: Validierung fehlgeschlagen\"\n else\n return true\n end\n end",
"def exist?\n res = Net::HTTP.get_response(uri)\n res.class == Net::HTTPOK\nrescue\n false\nend",
"def available?\n fname = File.join(APP_ROOT, 'tmp', 'connection.txt')\n\n Socket.getaddrinfo(\"google.com\", \"http\")\n FileUtils.rm(fname, force: true) rescue true# if good\n true\n\n rescue => err\n File.open(fname, 'w') {|f| f << '1'}\n false\n end",
"def exist?\n request(:get)\n true\n rescue Stretcher::RequestError::NotFound\n false\n end",
"def link_is_existent?(url)\n \tbegin\n\t uri = URI.parse(url)\n \t http_conn = Net::HTTP.new(uri.host, uri.port)\n \t resp, data = http_conn.head(\"/\" , nil)\n \t puts \"=== RESPONSE CODE #{resp.code}\"\n \t resp.code != \"404\"\n \trescue URI::InvalidURIError, Errno::ECONNREFUSED, SocketError\n \t\tfalse\n \tend\n end",
"def route_exists?(subnet, netmask)\n each { |route|\n return true if (route.subnet == subnet and route.netmask == netmask)\n }\n\n false\n end",
"def IsActive\n RunSystemCtl(\"network\", \"is-active\") == 0\n end",
"def internet_http?\n host_http = 'http://www.google.com/index.html'\n check = Net::Ping::HTTP.new(host_http) #now http not as console\n check.ping?\n end",
"def internet_http?\n host_http = 'http://www.google.com/index.html'\n check = Net::Ping::HTTP.new(host_http) #now http not as console\n check.ping?\n end",
"def station_exist?(station)\n raise \"station don\\'t exist\" unless get_station(station)\n true\n end",
"def disabled?\n ::EmsNetwork.all.none? { |ems| CloudSubnet.class_by_ems(ems)&.supports?(:create) }\n end",
"def check_parallels_hostonly_network(options)\n message = \"Information:\\tChecking Parallels hostonly network exists\"\n command = \"prlsrvctl net list |grep ^prls |grep host-only |awk '{print $1}'\"\n if_name = execute_command(options,message,command)\n if_name = if_name.chomp\n if not if_name.match(/prls/)\n message = \"Information:\\tDetermining possible Parallels host-only network interface name\"\n command = \"prlsrvctl net list |grep ^prls\"\n if_count = execute_command(options,message,command)\n if_count = if_count.grep(/prls/).count.to_s\n if_name = \"prlsnet\"+if_count\n message = \"Information:\\tPlumbing Parallels hostonly network \"+if_name\n command = \"prlsrvctl net add #{if_name} --type host-only\"\n execute_command(options,message,command)\n end\n message = \"Information:\\tDetermining Parallels network interface name\"\n command = \"prlsrvctl net list |grep ^#{if_name} |awk '{print $3}'\"\n nic_name = execute_command(options,message,command)\n nic_name = nic_name.chomp\n message = \"Information:\\tChecking Parallels hostonly network \"+nic_name+\" has address \"+options['hostonlyip']\n command = \"ifconfig #{nic_name} |grep inet |awk '{print $2}\"\n host_ip = execute_command(options,message,command)\n host_ip = host_ip.chomp\n if not host_ip.match(/#{options['hostonlyip']}/)\n message = \"Information:\\tConfiguring Parallels hostonly network \"+nic_name+\" with IP \"+options['hostonlyip']\n command = \"sudo sh -c 'ifconfig #{nic_name} inet #{options['hostonlyip']} netmask #{options['netmask']} up'\"\n execute_command(options,message,command)\n end\n gw_if_name = get_gw_if_name(options)\n if options['host-os-release'].split(\".\")[0].to_i < 14\n check_osx_nat(gw_if_name,if_name)\n else\n check_osx_pfctl(options,gw_if_name,if_name)\n end\n\treturn nic_name\nend",
"def ValidNetwork\n # TRANSLATORS: description of the valid network definition\n _(\n \"A valid network definition can contain the IP,\\n\" +\n \"IP/Netmask, IP/Netmask_Bits, or 0/0 for all networks.\\n\" +\n \"\\n\" +\n \"Examples:\\n\" +\n \"IP: 192.168.0.1 or 2001:db8:0::1\\n\" +\n \"IP/Netmask: 192.168.0.0/255.255.255.0 or 2001:db8:0::1/56\\n\" +\n \"IP/Netmask_Bits: 192.168.0.0/24 or 192.168.0.1/32 or 2001:db8:0::1/ffff::0\\n\"\n )\n end",
"def allow_net_connect?\n allow_net_connect\n end",
"def mainnet?\n self.network.mainnet?\n end",
"def range?\n ip == network\n end",
"def exists?\n start = Time.now\n debug \"Checking if device group \\\"#{resource[:full_path]}\\\" exists\"\n connection = self.class.get_connection(resource[:account])\n if resource[:full_path].eql?('/')\n true\n else\n device_group = get_device_group(connection, resource[:full_path])\n debug device_group unless nil_or_empty?(device_group)\n debug \"Finished in #{(Time.now-start)*1000.0} ms\"\n nil_or_empty?(device_group) ? false : true\n end\n end",
"def ready?\n q = get_connection(\"network\")\n \n network = q.networks.select {|n| n.name == self.network}\n if network.empty?\n return false, \"Network #{self.network} does not exist on the tenant.\"\n end\n\n types = Array.new\n self.instances.each do |inst|\n types << inst.types\n end\n types.flatten!\n duplicates = types.select{|t| types.count(t) > 1}\n if duplicates.include?(\"named\")\n return false, \"Named is a component on multiple instances\" # If named is included more than once\n end\n if duplicates.include?(\"datastore\") && duplicates.count(\"datastore\") < 3\n return false, \"There are 2 mongodb hosts, there must be either one or more than two.\"\n end\n if self.valid_gear_sizes == []\n return false, \"No gear sizes are defined\"\n end\n limits = self.limits\n if limits[:max_instances] < self.instances.count\n return false, \"There are more #{self.instances.count - limits[:max_instances]} more instances than the project limit of \\\"#{limits[:max_instances]}\\\" allows.\"\n end\n types.uniq!\n types.compact!\n if types.sort == [\"named\", \"broker\", \"datastore\", \"activemq\", \"node\"].sort\n true\n else\n return false, \"All necessary components are not included: \" + types.join(\",\")\n end\n end",
"def delete_network(name)\n data = false\n conn = @ec2_main.environment.connection\n if conn != nil\n response = conn.delete_network(name)\n if response.status == 200\n data = response.body\n else\n data = {}\n end\n else\n raise \"Connection Error\"\n end\n return data\n end",
"def exists?\n name, type = resource[:name].split('/')\n # Create the resolver, pointing to the nameserver\n r = Resolv::DNS.new(:nameserver => server)\n # Do the look-up\n begin\n @dnsres = r.getresources(name, typeclass(type))\n rescue Resolv::ResolvError\n return false\n end\n # MX and SRV lookups will return empty arrays\n if @dnsres.is_a? Array\n return false if @dnsres.empty?\n end\n # The record exists!\n return true\n end",
"def network_available?(sample_uri = SAMPLE_URI.call)\n @agent.get('http://portal.titech.ac.jp').to_b\n rescue # check another website just to make sure\n @agent.get(sample_uri).to_b rescue return false\n end",
"def has_host?(wspace,addr)\n\t\twspace.hosts.find_by_address(addr)\n\tend",
"def internet_connection?\n begin\n true if open(\"http://www.google.com/\")\n rescue\n false\n end\n end",
"def check_exist_supporting_link\n check('supporting link existence') do |messages|\n all_links do |link, _nw|\n link.supports.each do |slink|\n begin\n next if find_link(slink.network_ref, slink.link_ref)\n rescue TopologyElementNotFoundError => e\n messages.push(message(:error, link.path, e.message))\n end\n\n msg = \"definition referred as supporting link #{slink} is not found.\"\n messages.push(message(:error, link.path, msg))\n end\n end\n end\n end",
"def host_exists?(host)\n # :nocov:\n # Patch for BZ840938 to support Ruby 1.8 on machines without /etc/resolv.conf\n dns = Resolv::DNS.new((Resolv::DNS::Config.default_config_hash || {}))\n dns.getresources(host, Resolv::DNS::Resource::IN::A).any?\n # :nocov:\n end",
"def exists?\n\t\tbegin\n\t\t\tdom\n\t\t\tdebug \"Domain %s exists? true\" % [resource[:name]]\n\t\t\ttrue\n\t\trescue Libvirt::RetrieveError => e\n\t\t\tdebug \"Domain %s exists? false\" % [resource[:name]]\n\t\t\tfalse # The vm with that name doesnt exist\n\t\tend\n\tend",
"def link_exists_on(host, link_path)\n # Links are weird on windows, fall back to seeing if the file exists\n return file_exists_on(host, link_path) if host[:platform].include?('windows')\n\n return on(host, Command.new(%(test -L \"#{link_path}\"), accept_all_exit_codes: true)).exit_code.zero?\n end",
"def exists?\n\n\t\tbegin\n\t\t\tdom\n\t\t\tdebug \"Domain %s exists? true\" % [resource[:name]]\n\t\t\ttrue\n\t\trescue Libvirt::RetrieveError => e\n\t\t\tdebug \"Domain %s exists? false\" % [resource[:name]]\n\t\t\tfalse # The vm with that name doesnt exist\n\t\tend\n\n\tend",
"def reachable?\n ping\n true\n rescue Orocos::ComError\n false\n end",
"def ceph_chef_ip4_address_in_network?(ip, params, net)\n net.contains?(ip) && params.key?('broadcast')\nend",
"def exists?\n # Unless the exception is hit we know its a 2xx response\n request(:head)\n true\n rescue Stretcher::RequestError::NotFound\n false\n end",
"def checkCxn(conn)\n res = conn.request(:method=>:get,:path=>\"/wapi/v1.0/network\")\n if(res.status != 200)\n raise res.body\n end\nend",
"def exists_on_server?\n false\n end",
"def exists?\n vnic\n end",
"def uri_exists(url)\n\n u = URI(url)\n\n Net::HTTP.start(u.host, u.port) do |http|\n http.open_timeout = 1\n http.read_timeout = 1\n res = http.head(u.path)\n\n if res.code == \"200\"\n return true\n end\n return false\n end\n end",
"def interface_network(driver, options)\n # no need to get interface network for tcp tunnel config\n return 'tunnel_interface' if options.fetch(:tunnel_type, nil)\n\n if options[:network_name]\n @logger.debug 'Found network by name'\n return options[:network_name]\n end\n\n # Get list of all (active and inactive) Libvirt networks.\n available_networks = libvirt_networks(driver)\n\n return 'public' if options[:iface_type] == :public_network\n\n if options[:ip]\n address = network_address(options[:ip], options[:netmask])\n available_networks.each do |network|\n if address == network[:network_address]\n @logger.debug 'Found network by ip'\n return network[:name]\n end\n end\n end\n\n raise Errors::NetworkNotAvailableError, network_name: options[:ip]\n end",
"def exists?\n start_time = Time.now\n timeout = resource[:timeout]\n\n success = validator.attempt_connection\n\n while success == false && ((Time.now - start_time) < timeout)\n # It can take several seconds for the Grafana server to start up;\n # especially on the first install. Therefore, our first connection attempt\n # may fail. Here we have somewhat arbitrarily chosen to retry every 2\n # seconds until the configurable timeout has expired.\n Puppet.notice('Failed to connect to Grafana API; sleeping 2 seconds before retry')\n sleep 2\n success = validator.attempt_connection\n end\n\n unless success\n Puppet.notice(\"Failed to connect to Grafana within timeout window of #{timeout} seconds; giving up.\")\n end\n\n success\n end",
"def valid?\n (ip.nil? || name.nil?) ? false : true\n end",
"def ip_exist?\n return false if current_resource.addresses.nil?\n current_resource.addresses.include?(new_resource.address)\n end",
"def valid?\n ping\n end",
"def unsafe_network?(item, options = {})\n return [:network, item] if in_pool?(:network, item)\n return unless options.fetch(:smarter, true)\n\n found = contained_in_network?(item)\n return [:in_network, found] if found\n end",
"def rule_exists?\n # To Action From\n # -- ------ ----\n # 22 ALLOW Anywhere\n # 192.168.0.1 25/tcp DENY 10.0.0.0/8\n shell_out!(\"ufw status\").stdout =~ \n/^(#{@new_resource.destination}\\s)?#{port_and_proto}\\s.*(#{@new_resource.action.to_s})\\s.*#{@new_resource.source || 'Anywhere'}$/i\n end",
"def exists\n $tracer.trace(format_method(__method__))\n @name_links.exists && @remove_buttons.exists\n end",
"def exists?(username)\n perform_request({:action => 'client-checkexists', :username => username})\n end",
"def valid?\n (internal_ip.nil? || name.nil?) ? false : true\n end",
"def process_public_network(root_options, net_options, env)\n if root_options[:name] && validate_network_name!(root_options[:name], env)\n network_name = root_options[:name]\n end\n if !network_name\n valid_interfaces = list_interfaces\n if valid_interfaces.empty?\n raise Errors::NetworkNoInterfaces\n elsif valid_interfaces.size == 1\n bridge_interface = valid_interfaces.first\n elsif i = valid_interfaces.detect{|i| Array(root_options[:bridge]).include?(i.name) }\n bridge_interface = i\n end\n if !bridge_interface\n env[:ui].info(I18n.t(\"vagrant.actions.vm.bridged_networking.available\"),\n prefix: false)\n valid_interfaces.each_with_index do |int, i|\n env[:ui].info(\"#{i + 1}) #{int.name}\", prefix: false)\n end\n env[:ui].info(I18n.t(\n \"vagrant.actions.vm.bridged_networking.choice_help\") + \"\\n\",\n prefix: false\n )\n end\n while !bridge_interface\n choice = env[:ui].ask(\n I18n.t(\"vagrant.actions.vm.bridged_networking.select_interface\") + \" \",\n prefix: false)\n bridge_interface = valid_interfaces[choice.to_i - 1]\n end\n base_opts = Vagrant::Util::HashWithIndifferentAccess.new\n base_opts[:opt] = \"parent=#{bridge_interface.name}\"\n subnet = IPAddr.new(bridge_interface.addr.ip_address <<\n \"/\" << bridge_interface.netmask.ip_unpack.first)\n base_opts[:subnet] = \"#{subnet}/#{subnet.prefix}\"\n subnet_addr = IPAddr.new(base_opts[:subnet])\n base_opts[:driver] = \"macvlan\"\n base_opts[:gateway] = subnet_addr.succ.to_s\n base_opts[:ipv6] = subnet_addr.ipv6?\n network_options = base_opts.merge(net_options)\n\n # Check if network already exists for this subnet\n network_name = env[:machine].provider.driver.\n network_containing_address(network_options[:gateway])\n if !network_name\n network_name = \"vagrant_network_public_#{bridge_interface.name}\"\n end\n\n # If the network doesn't already exist, gather available address range\n # within subnet which docker can provide addressing\n if !env[:machine].provider.driver.existing_named_network?(network_name)\n if !net_options[:gateway]\n network_options[:gateway] = request_public_gateway(\n network_options, bridge_interface.name, env)\n end\n network_options[:ip_range] = request_public_iprange(\n network_options, bridge_interface.name, env)\n end\n end\n [network_name, network_options]\n end",
"def online?\n\n require 'open-uri'\n\n begin\n open('http://www.openwfe.org')\n true\n rescue SocketError => se\n false\n end\n end",
"def znode_exists?(znode_path, zk_host=\"localhost:2181\")\n require 'rubygems'\n require 'zookeeper'\n znode_found = false\n begin\n @zk = Zookeeper.new(zk_host)\n if !@zk.connected?\n raise \"znode_exists : Unable to connect to zookeeper\"\n end \n r = @zk.get(:path => znode_path)\n if r[:rc] == 0\n znode_found = true\n end \n rescue Exception => e\n puts e.message\n ensure\n @zk.close unless @zk.closed?\n end\n return znode_found\nend",
"def connection?\n check = Netchecker.new() \n @alive = check.check_url(\"google.com\", 80) \n end",
"def get_networkid(network_name)\n network_res = find_match(@network.networks, network_name)\n network_to_use = (network_res != nil) ? network_res.id.to_s : nil\n if network_to_use.nil?\n Puppet.crit \"The network is not found on cloud account!, network_name => #{network_name}\"\n raise Puppet::Error, \"The network is not found on cloud account!, network_name => #{network_name}\"\n else\n Puppet.notice \"Network '#{network_name}' found : '#{network_to_use}'\"\n end\n return network_to_use\n end",
"def network\n lines, errs = networksetup(\"getairportnetwork #{options[:device_id]}\")\n lines.join('\\n') =~ /Current Wi-Fi Network: (.+)$/i\n $1\n end",
"def exists?\n !@not_found\n end",
"def eaddrnotavail?() EADDRNOTAVAIL == @error_code; end",
"def create_host_only_network(options)\n # Create the interface\n execute(\"hostonlyif\", \"create\") =~ /^Interface '(.+?)' was successfully created$/\n name = $1.to_s\n\n # Configure it\n execute(\"hostonlyif\", \"ipconfig\", name,\n \"--ip\", options[:ip],\n \"--netmask\", options[:netmask])\n\n # Return the details\n return {\n :name => name,\n :ip => options[:ip],\n :netmask => options[:netmask]\n }\n end",
"def neighborhood_exists\n errors.add(:neighborhood_id, \"doesn't exist\") unless Neighborhood.exists?(neighborhood_id)\n end",
"def node_exists?(name)\n exists?(\"node\", name)\n end",
"def exists?\n request :head\n true\n rescue Stretcher::RequestError::NotFound\n false\n end",
"def exists?\n begin \n CouchSpring.get uri\n true\n rescue\n false\n end \n end",
"def vlan_dev_exist?\n shell_out = Mixlib::ShellOut.new(\"powershell.exe -Command \\\"Get-NetlbfoTeam -Name '#{new_resource.device}'\\\"\")\n shell_out.run_command\n !shell_out.error?\n end",
"def layer?(name)\n response = get(\"/#{CitySDK::LAYER_PATH}/#{name}/\")\n case response.status\n when 200 then true\n when 404 then false\n else api_error(response)\n end # case\n end",
"def exists?\n assert_exists\n true\n rescue NoMatchingWindowFoundException\n false\n end",
"def has_host?(addr)\n\t\tHost.find(:first, :conditions => [ \"address = ?\", addr])\n\tend"
] |
[
"0.83544916",
"0.8068502",
"0.7202114",
"0.6857433",
"0.68385494",
"0.67289007",
"0.6660758",
"0.6647937",
"0.65889585",
"0.6517109",
"0.6439652",
"0.6284661",
"0.62508065",
"0.6232452",
"0.62237513",
"0.61374754",
"0.6129674",
"0.6090193",
"0.6085285",
"0.60835993",
"0.60765225",
"0.6072613",
"0.6051953",
"0.6043644",
"0.59082425",
"0.58977044",
"0.5881272",
"0.58768094",
"0.58763933",
"0.5827483",
"0.58022463",
"0.5780835",
"0.5776873",
"0.5774782",
"0.57599545",
"0.57497174",
"0.5746568",
"0.5741808",
"0.5739048",
"0.57325625",
"0.56968665",
"0.56876266",
"0.56756383",
"0.566989",
"0.5639162",
"0.5614791",
"0.5614791",
"0.56074667",
"0.56026614",
"0.55939215",
"0.55855095",
"0.5585312",
"0.5574139",
"0.5571552",
"0.5568899",
"0.55625546",
"0.5557807",
"0.555395",
"0.5552393",
"0.5543654",
"0.5542469",
"0.5521583",
"0.5520336",
"0.55160725",
"0.5513655",
"0.5509025",
"0.5507402",
"0.54976887",
"0.5486137",
"0.54802036",
"0.547511",
"0.54655606",
"0.5461287",
"0.54577154",
"0.5451797",
"0.5435011",
"0.5425047",
"0.5420728",
"0.5417617",
"0.5416735",
"0.54147255",
"0.5405208",
"0.5402201",
"0.54007053",
"0.53881645",
"0.53838164",
"0.53759587",
"0.5367724",
"0.53672904",
"0.53662777",
"0.5353099",
"0.53485996",
"0.5344906",
"0.53431016",
"0.53370583",
"0.5336538",
"0.5323789",
"0.5321102",
"0.5320985",
"0.53209025"
] |
0.82898605
|
1
|
Validates the host name of the server you can connect to
|
def get_host(name)
# create a host object to work with
host_obj = Com::Vmware::Vcenter::Host.new(vapi_config)
if name.nil?
host = host_obj.list
else
filter = Com::Vmware::Vcenter::Host::FilterSpec.new(names: Set.new([name]))
host = host_obj.list(filter)
end
raise format("Unable to find target host: %s", name) if host.empty?
host[0]
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def validate_server(name)\n return true unless name # if no name is provided, just go with the defaults\n valid = name.is_a? String\n begin\n u = URI.parse(name)\n valid = false unless u.class == URI::HTTP || u.class == URI::HTTPS\n rescue URI::InvalidURIError\n valid = false\n end\n valid || raise(Exceptions::InvalidOptions, 'Invalid server')\n end",
"def validate_server(name)\n return true unless name # if no name is provided, just go with the defaults\n\n valid = name.is_a? String\n begin\n u = URI.parse(name)\n valid = false unless u.is_a?(URI::HTTP) || u.is_a?(URI::HTTPS)\n rescue URI::InvalidURIError\n valid = false\n end\n valid || raise(Exceptions::InvalidOptions, 'Invalid server')\n end",
"def invalid_host?(host)\n !host.class.to_s.eql?(\"String\") || host.empty?\n end",
"def host_allowed?(arg)\n true\n end",
"def valid_format?\n if host_name =~ CANONICAL_HOST_REGEX && to_s.size <= MAX_HOST_LENGTH\n return true if localhost?\n return true if host_name.include?(\".\") # require FQDN\n end\n set_error(:domain_invalid)\n end",
"def validate_host_header(value)\n # allow only valid hostnames\n value.match?(host_regex) && !value.match?(/_/)\n end",
"def has_required_host?\n true\n end",
"def validate_hostname(userdata)\n if userdata =~ /\\A[A-Za-z0-9\\-\\.]{2,254}\\z/\n userdata\n else\n raise 'Illegal hostname'\n end\n end",
"def check_host\n # rubocop:disable Style/GuardClause\n if config[:host] == '0.0.0.0'\n logger.warn 'Will listen on all interfaces (0.0.0.0).' \\\n ' Consider using 127.0.0.1 (--host option).'\n end\n # rubocop:enable Style/GuardClause\n end",
"def check_host\n # rubocop:disable Style/GuardClause\n if config[:host] == '0.0.0.0'\n logger.warn 'Will listen on all interfaces (0.0.0.0).' \\\n ' Consider using 127.0.0.1 (--host option).'\n end\n # rubocop:enable Style/GuardClause\n end",
"def check_host(v)\n return v unless v\n\n if @opaque\n raise InvalidURIError,\n \"can not set host with registry or opaque\"\n elsif parser.regexp[:HOST] !~ v\n raise InvalidComponentError,\n \"bad component(expected host component): #{v}\"\n end\n\n return true\n end",
"def validate_hostname(hostname)\n hostname_regex = /(hostname)$/\n if hostname_regex =~ hostname\n $evm.log(\"info\",\"Hostname:<#{hostname}> found\") if @debug\n return true\n else\n $evm.log(\"error\",\"Hostname:<#{hostname}> not found\") if @debug\n return false\n end\n end",
"def validate_target_bosh_host\n URI.parse(target_bosh_host)\n true\n rescue\n false\n end",
"def valid_connection?(conn)\n conn.servers.length\n true\n rescue Excon::Errors::Forbidden, Excon::Errors::Unauthorized\n false\n end",
"def valid_host?\n return false if invalid_uri_error?\n \n # check for wildcard definition e.g. *.github.com\n wildcard_hosts = Array.new\n @valid_hosts.each do |valid_host|\n result = valid_host.scan(/^\\*\\.(.*\\..*)$/)\n wildcard_hosts << result[0] unless result.empty?\n end\n return wildcard_hosts.include?(@host.scan(/^(?:.*\\.)?(.*\\..*)$/)[0]) unless wildcard_hosts.empty?\n \n # basic check\n return @valid_hosts.include?(@host) || @valid_hosts.empty? \n end",
"def allowHost\n end",
"def build_host_string_check(hostname)\n @host_check = lambda do |url|\n if url.host != hostname\n [422, {}, \"URL must be from #{hostname}\"]\n end\n end\n end",
"def check_host(url)\n if url.scheme !~ /^https?$/\n [422, {}, \"Invalid url: #{url}\"]\n else\n @host_check.call url\n end\n end",
"def validate_remote_listen(host, port)\n if @server.authorized_keys and @out_hasher.nil?\n D \"Asked to open listen socket by unauthorized client\"\n return false\n end\n \n if port < @server.lowest_listen_port or port > @server.highest_listen_port\n D \"Asked to listen to forbidden port\"\n return false\n end\n \n true\n end",
"def hostname_correct?(host_name)\n host_name == capture(%{hostname}).chomp\nend",
"def verify_host\n @j_del.isVerifyHost\n end",
"def original_is_valid?\n valid_host? && valid_length? && valid_scheme?\n end",
"def visit_host?(host)\n @host_rules.accept?(host)\n end",
"def match_host(hostname)\n hostname === host\n end",
"def hostname\n raise 'empty hostname, something wrong' if @in_hostname.empty?\n @in_hostname\n end",
"def fix_host\n if host.blank?\n begin\n uri = URI(url)\n logger.debug (self.host = uri.host.match(/\\w*\\.\\w*$/)[0])\n rescue\n return false\n end\n end\n true\n end",
"def block_unknown_hosts\n return if Rails.configuration.hosts.blank?\n raise UnsafeHostError, \"#{request.host} is not a safe host\" unless Rails.configuration.hosts.include?(request.host)\n end",
"def host?\n self.host\n end",
"def host_is_app_host?(hostname)\n hostname == \"adapt.127.0.0.1.xip.io\"\n end",
"def does_resolve_to_host?\n mx_records.include? Socket.gethostname\n end",
"def is_fqdn? (host)\n\t\tputs \"Validate the host-name format is valid: #{host}\" if @verbose\n\t\treturn false if is_ip?(host) or is_url?(host)\n\t\tdomain=get_domain_root(host)\n\t\tif domain.nil?\n\t\t\treturn false\n\t\telsif is_domain_root?(domain)\n\t\t\treturn true\n\t\telse\n\t\t\treturn false\n\t\tend\n#\trescue => ee\n#\t\tputs \"Exception on method is_fqdn? for #{host}: #{ee}\" if @verbose\n#\t\treturn false\n\tend",
"def check_hostnames\n all_good = true\n \n @check_groups.each do |group|\n group.checks.each do |check|\n unless check.hostname && Dnsruby::Resolv.getaddress(check.hostname)\n puts \"Error: check #{check.name} has invalid hostname '#{check.hostname}'\"\n all_good = false\n end\n end\n end\n \n all_good\n end",
"def normalized_host; end",
"def check_server\n raise Exception.new(\"Could not reach Apocalypse server please check the address and port and try again.\") unless server_reachable?\n end",
"def generating_rules_for_current_host?\n Asbestos.hostname.to_s == @name.to_s\n end",
"def has_host?(wspace,addr)\n ::ApplicationRecord.connection_pool.with_connection {\n address, scope = addr.split('%', 2)\n wspace.hosts.find_by_address(addr)\n }\n end",
"def clean_server_name(name)\n dname = name.downcase\n\n if not dname.index(/[^0-9a-z\\-.]/).nil?\n raise FrontendHttpServerNameException.new(\"Invalid characters\", @container_uuid, \\\n @container_name, @namespace, dname )\n end\n\n if dname.length > 255\n raise FrontendHttpServerNameException.new(\"Too long\", @container_uuid, \\\n @container_name, @namespace, dname )\n end\n\n if dname.length == 0\n raise FrontendHttpServerNameException.new(\"Name was blank\", @container_uuid, \\\n @container_name, @namespace, dname )\n end\n\n if dname =~ /^\\d+\\.\\d+\\.\\d+\\.\\d+$/\n raise FrontendHttpServerNameException.new(\"IP addresses are not allowed\", @container_uuid, \\\n @container_name, @namespace, dname )\n end\n\n return dname\n end",
"def clean_server_name(name)\n dname = name.downcase\n\n if not dname.index(/[^0-9a-z\\-.]/).nil?\n raise FrontendHttpServerNameException.new(\"Invalid characters\", @container_uuid, \\\n @container_name, @namespace, dname )\n end\n\n if dname.length > 255\n raise FrontendHttpServerNameException.new(\"Too long\", @container_uuid, \\\n @container_name, @namespace, dname )\n end\n\n if dname.length == 0\n raise FrontendHttpServerNameException.new(\"Name was blank\", @container_uuid, \\\n @container_name, @namespace, dname )\n end\n\n if dname =~ /^\\d+\\.\\d+\\.\\d+\\.\\d+$/\n raise FrontendHttpServerNameException.new(\"IP addresses are not allowed\", @container_uuid, \\\n @container_name, @namespace, dname )\n end\n\n return dname\n end",
"def is_hostname?\n ip = Rex::Socket.addr_atoi( @dest_ip )\n if( ip & 0xFFFFFF00 == 0x00000000 )\n return true if( ip & 0x000000FF != 0x00 )\n end\n return false\n end",
"def host_exists?(host)\n `#{cmk} --list-hosts`.split(/\\n/).include?(host)\n end",
"def dev_host\n case Socket.gethostname\n when /romeo-foxtrot/i ; true\n else ; false\n end\nend",
"def fqdn_correct?(host_name, domain_name, ip_addr)\n cmd_if %{egrep -q '^#{ip_addr}[[:space:]]+#{host_name}.#{domain_name}' /etc/hosts >/dev/null}\nend",
"def url_valid?\n ALLOWED_URLS.each do |host, url_allowed|\n if url.include? url_allowed\n @host = host\n return true\n end\n end\n false\n end",
"def lookup_hostname(host)\n Socket.getaddrinfo(host, nil, nil, Socket::SOCK_STREAM)[0][3]\n rescue SocketError\n raise(InvalidHostname, Errstr::INVALID_HOST % host)\n end",
"def verify_domain(domain)\n begin\n Socket.gethostbyname(domain)\n rescue SocketError\n return false\n end\n\n true\n end",
"def host_with_port; end",
"def internal_host?(host)\n Resolv.getaddresses(host).all? { |ip| internal_ip?(ip) }\n rescue URI::Error\n false\n end",
"def check_host\n result = `ping -q -c 2 #{@conn[:host]}`\n # return true or false if exit status is 0\n $?.exitstatus == 0\n end",
"def valid_ip_or_hostname(string)\n if string\n # Simple IP address reg ex (from https://www.safaribooksonline.com/library/view/regular-expressions-cookbook/9780596802837/ch07s16.html)\n ip_match = /^(?:[0-9]{1,3}\\.){3}[0-9]{1,3}$/.match(string)\n return true if ip_match\n\n # Hostname reg ex\n host_match = /^(([a-zA-Z]|[a-zA-Z][a-zA-Z0-9\\-]*[a-zA-Z0-9])\\.)*([A-Za-z]|[A-Za-z][A-Za-z0-9\\-]*[A-Za-z0-9])$/.match(string)\n return true if host_match\n end\n\n return false\n end",
"def host_is_okay\n return false unless @report_data[:host]\n return false unless valid_ip(@report_data[:host])\n return false unless @report_data[:state] == Msf::HostState::Alive\n if @args[:blacklist]\n return false if @args[:blacklist].include?(@report_data[:host])\n end\n return true\n end",
"def post_connection_check(peer_cert, hostname) # :nodoc:\n check_common_name = true\n cert = peer_cert\n cert.extensions.each{|ext|\n next if ext.oid != \"subjectAltName\"\n ext.value.split(/,\\s+/).each{|general_name|\n if /\\ADNS:(.*)/ =~ general_name\n check_common_name = false\n reg = Regexp.escape($1).gsub(/\\\\\\*/, \"[^.]+\")\n return true if /\\A#{reg}\\z/i =~ hostname\n elsif /\\AIP Address:(.*)/ =~ general_name\n check_common_name = false\n return true if $1 == hostname\n end\n }\n }\n if check_common_name\n cert.subject.to_a.each{|oid, value|\n if oid == \"CN\"\n reg = Regexp.escape(value).gsub(/\\\\\\*/, \"[^.]+\")\n return true if /\\A#{reg}\\z/i =~ hostname\n end\n }\n end\n raise SSL::SSLError, \"hostname was not match with the server certificate\"\n end",
"def valid_dns?\n @host.exchanger.has_dns_a_record?\n end",
"def tls_hostname; end",
"def validates_as_hostname_label(*attrs)\n options = { :allow_underscores => false, :reserved => RESERVED_HOSTNAMES }.merge(attrs.last.is_a?(Hash) ? attrs.pop : {})\n \n format = 'a-z0-9\\-'\n format << '_' if options.delete(:allow_underscores)\n \n validates_length_of *attrs + [{\n :in => 1..63,\n :message => I18n.t('validates_as_hostname_label.invalid_length', :default => 'must be between 1 and 63 characters long')\n }.merge(options)]\n\n validates_exclusion_of *attrs + [{\n :in => options.delete(:reserved),\n :message => I18n.t('validates_as_hostname_label.reserved', :default => 'is reserved')\n }.merge(options)]\n\n validates_format_of *attrs + [{ :with => /^[#{format}]*$/i }.merge(options)]\n\n validates_format_of *attrs + [{\n :with => /^[^-_].*[^-_]$/i,\n :message => I18n.t('validates_as_hostname_label.invalid_first_character', :default => \"can't start or end with a hyphen or underscore\")\n }.merge(options)]\n end",
"def client_hostname\n @opts[:hostname]\n end",
"def hostname\n @options[:host][:name] if @options[:host]\n end",
"def valid_dns?\n return true unless dns_enabled?\n bool = dns_a_record.size > 0 || set_error(:domain_unknown)\n if localhost? && !@config[:host_local]\n bool = set_error(:domain_no_localhost)\n end\n bool\n end",
"def determine_hostname\n @info[:hostname] = @shell.query('HOST', 'hostname')\n end",
"def valid?\n (uri.host =~ LINK_REGEX || uri.host =~ LINK_IP_REGEX) ? true : false\n end",
"def allow_net_connect?\n allow_net_connect\n end",
"def server?\n response = Net::HTTP.get_response(URI.parse('http://localhost:9533/'))\n raise unless response.class == Net::HTTPOK\nrescue\n skip 'Local server not detected'\nend",
"def do_ssl_verify?\n if target_hostname == \"localhost\" ||\n target_hostname == \"a2-dev.test\" ||\n target_hostname =~ /\\d+\\.\\d+\\.\\d+\\.\\d+/\n return false\n end\n return true\n end",
"def check_host(host, path = '/', timeout = 5)\n begin\n status = Timeout::timeout(timeout) do\n Net::HTTP.start(URI.parse(host).host) do |http|\n response = http.get(path)\n\n if not response.code.match(/200/)\n log_error(\"Web Server down or not responding: #{response.code} #{response.message}\")\n return false;\n end\n\n if @test_regex && ! response.body.match(@test_regex)\n log_error(\"The response did not contain the regex '#{@test_regex}'\")\n return false\n end\n end\n end\n rescue SocketError => socket_error\n log_error(\"Error Connecting To Web: #{socket_error}\")\n return false;\n rescue TimeoutError => timeout_error\n log_error(\"Timeout occured checking #{host}#{path} after #{timeout} seconds.\")\n return false;\n rescue Exception => e\n log_error(\"An unknown error occured checking #{host}#{path}: #{e}\")\n return false;\n end\n\n return true\n end",
"def socket_host; end",
"def hostname_validation\n @hostname_validation ||= HostnameValidation.new(\n @node.at_xpath('hostnameValidation')\n )\n end",
"def validate_server\n ServerValidator.validate(lock_config)\n end",
"def validate_url\r\n url = @hostname\r\n #puts \"DEBUG: url: \" + url\r\n \r\n url_part = []\r\n url_parts = url.split('.') \r\n #puts \"DEBUG: url_parts[0]: \" + url_parts[0]\r\n \r\n if url_parts[0].is_a? Numeric \r\n validate_sub_url(url_parts[0])\r\n validate_sub_url(url_parts[1])\r\n validate_sub_url(url_parts[2])\r\n validate_sub_url(url_parts[3])\r\n else # letters\r\n #puts \"URL just letters\"\r\n end\r\n ping_url\r\n end",
"def has_host?(wspace,addr)\n\t\twspace.hosts.find_by_address(addr)\n\tend",
"def ensure_valid_aut_host_env(env)\r\n # Looks like they have multiple URLs for their environments. Make sure\r\n # the caller asked for a specific one.\r\n if env.nil? then\r\n raise ArgumentError.new(\r\n \"#{msg_prefix} > \\n\"\\\r\n \" AUT host has environments, but none were specified when asking \"\\\r\n \"for an AUT host URL.\")\r\n end\r\n # Make sure its a valid key too..\r\n unless @aut_host.key?(env) then\r\n raise ArgumentError.new(\r\n \"#{msg_prefix} > \\n\"\\\r\n \" Unknown AUT host #{env}.\\n\"\\\r\n \" Available hosts are #{@aut_host.keys.join(', ')}\")\r\n end\r\n end",
"def post_connection_check(peer_cert, hostname)\n check_common_name = true\n cert = peer_cert\n cert.extensions.each{|ext|\n next if ext.oid != \"subjectAltName\"\n ext.value.split(/,\\s+/).each{|general_name|\n if /\\ADNS:(.*)/ =~ general_name\n check_common_name = false\n reg = Regexp.escape($1).gsub(/\\\\\\*/, \"[^.]+\")\n return true if /\\A#{reg}\\z/i =~ hostname\n elsif /\\AIP Address:(.*)/ =~ general_name\n check_common_name = false\n return true if $1 == hostname\n end\n }\n }\n if check_common_name\n cert.subject.to_a.each{|oid, value|\n if oid == \"CN\"\n reg = Regexp.escape(value).gsub(/\\\\\\*/, \"[^.]+\")\n return true if /\\A#{reg}\\z/i =~ hostname\n end\n }\n end\n raise OpenSSL::SSL::SSLError, \"hostname not match\"\n end",
"def getServerName(servers, hostname, port)\n servername = nil\n upperCaseHostname = hostname.upcase;\n for server in servers\n hostFromServerName, portFromServerName = getHostPortFromServerName(server)\n hostFromServerName = hostFromServerName.upcase\n if hostFromServerName == upperCaseHostname and portFromServerName == port\n servername = server\n break\n end\n end\n raise ArgumentError, \"Server %s:%d not online\" % [hostname, port] unless servername\n return servername\nend",
"def is_local_host?(host)\n if host == 'localhost' || host == '127.0.0.1' || host == '::1'\n true\n else\n require 'socket'\n require 'resolv'\n Socket.ip_address_list.map { |a| a.ip_address }.include? Resolv.getaddress host\n end\n end",
"def connection_valid?\n begin\n result = client.call(:fe_dummy).body[:fe_dummy_response][:fe_dummy_result]\n @observations << \"app_server: #{result[:app_server]}, db_server: #{result[:db_server]}, auth_server: #{result[:auth_server]}\"\n result[:app_server] == \"OK\" and result[:db_server] == \"OK\" and result[:auth_server] == \"OK\"\n rescue => e\n @errors << e.message\n @backtrace = e.backtrace\n false\n end\n end",
"def hostname; end",
"def hostname; end",
"def check_request_host\n return if ['http://', 'https://'].include?(request.protocol.downcase) &&\n ((request.host =~ /\\A[A-Z0-9]*#{GlobalConstant::WebDomain.kyc_subdomain}\\Z/i) ||\n GlobalConstant::WebDomain.allowed_external_subdomains.include?(request.host.downcase))\n\n redirect_to GlobalConstant::Base.simple_token_web['kyc_root_url'], status: GlobalConstant::ErrorCode.temporary_redirect and return\n end",
"def server_in_pool?( host, port )\n server_list = servers\n !server_list.select{ |s| s[:addr] == host and s[:port] == port.to_i}.empty?\n end",
"def set_ip_or_hostname(opts)\n opts = check_params(opts,[:ip_or_hostnames])\n super(opts)\n end",
"def hosts_eql?(a, b) # rubocop:disable Naming/UncommunicativeMethodParamName\n parse_host(a) == parse_host(b)\n rescue IPAddr::InvalidAddressError\n false\n end",
"def set_host(v)\n v = \"\" if v.nil? || v == \"localhost\"\n @host = v\n end",
"def search_host\n begin\n if @host_search\n @host = Resolv.getname self.ip.to_s\n else\n @host = nil\n end\n rescue Resolv::ResolvError\n @host = nil\n end\n end",
"def valid?\n (internal_ip.nil? || name.nil?) ? false : true\n end",
"def validate_network_name!(network_name, env)\n if !env[:machine].provider.driver.existing_named_network?(network_name)\n raise Errors::NetworkNameUndefined,\n network_name: network_name\n end\n true\n end",
"def host_exists?(host)\n # :nocov:\n # Patch for BZ840938 to support Ruby 1.8 on machines without /etc/resolv.conf\n dns = Resolv::DNS.new((Resolv::DNS::Config.default_config_hash || {}))\n dns.getresources(host, Resolv::DNS::Resource::IN::A).any?\n # :nocov:\n end",
"def build_host_regex_check(regex)\n @host_check = lambda do |url|\n if url.host.to_s !~ regex\n [422, {}, \"URL must match #{regex.inspect}\"]\n end\n end\n end",
"def server_host\n Socket.gethostname\n end",
"def has_host?(addr)\n\t\tHost.find(:first, :conditions => [ \"address = ?\", addr])\n\tend",
"def port_bound?(host, port)\n Timeout.timeout(1) do\n s = TCPSocket.new(host, port)\n s.close rescue nil\n return true\n end\nrescue Timeout::Error, Errno::ECONNREFUSED, Errno::EHOSTUNREACH, \\\n Errno::ENETUNREACH, Errno::EACCES, Errno::ENOTCONN, \\\n Errno::EADDRNOTAVAIL\n return false\nend",
"def valid?\n (ip.nil? || name.nil?) ? false : true\n end",
"def validate_list?(args)\n @group.each do |item|\n return false if item[:host] == args[:host] && item[:port] == args[:port]\n end\n return true\n end",
"def set_hostname\n @hostname = Hostname.find_by_name(params[:name])\n end",
"def parsed_host\n sockets = new_resource.host.split if new_resource.host.is_a?(String)\n sockets = new_resource.host if new_resource.host.is_a?(Array)\n r = []\n sockets.each do |s|\n if s.match(/^unix:/) || s.match(/^tcp:/) || s.match(/^fd:/)\n r << s\n else\n Chef::Log.info(\"WARNING: docker_service host property #{s} not valid\")\n end\n end\n r\n end",
"def rescue_sock_error\n print \"--- Enter Enotify host [localhost:5000]: \".yellow\n host_and_port = STDIN.gets.strip\n if blank_string?(host_and_port)\n @enotify_host, @enotify_port = ['localhost', @default_options[:enotify_port]]\n else\n @enotify_host, @enotify_port = host_and_port.split(/\\s:\\s/)\n @enotify_port = @enotify_port.to_i\n end\n enotify_connect\n end",
"def parse_url_host\n url = self.url.gsub(/^https?\\:\\/\\//, '')\n url = url.gsub(/www\\./, '') unless (url.match(/www\\./).blank? && url.gsub(/www\\./, '').match(/[A-Za-z]/))\n self.url = \"https://\" + url\n end",
"def hostname\n @hostname ||= `hostname`.chomp\n end",
"def is_local_host\n require 'ipaddr'\n begin\n local = IPAddr.new(\"127.0.0.0/8\")\n private1 = IPAddr.new(\"10.0.0.0/8\")\n private2 = IPAddr.new(\"172.16.0.0/12\")\n private3 = IPAddr.new(\"192.168.0.0/16\")\n private4 = IPAddr.new(\"85.230.85.45\")\n private5 = IPAddr.new(\"94.234.170.18\")\n\n if local.include?(request.remote_ip)\n return true\n end\n if private1.include?(request.remote_ip)\n return true\n end\n if private2.include?(request.remote_ip)\n return true\n end\n if private3.include?(request.remote_ip)\n return true\n end\n if private4.include?(request.remote_ip)\n return true\n end\n if private5.include?(request.remote_ip)\n return true\n end\n return false\n rescue\n return false\n end\n end",
"def check_host\n unless @game.host == current_user\n render( :status => :unauthorized,\n :text => \"Cannot %s a game you didn't create.\" % params[:action])\n return false\n end\n return true\n end",
"def test_port(port)\n !EventMachine::Synchrony::TCPSocket.new('127.0.0.1', port).nil?\nrescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH\n false\nend",
"def check_multipass_hostonly_network(options,if_name)\n gw_if_name = get_gw_if_name(options)\n check_nat(options,gw_if_name,if_name)\n return\nend",
"def validate_network_config(server)\n provider.validate_network_config(server)\n end",
"def is_url_valid_www(url)\n return url.include? \"www.\"\nend"
] |
[
"0.74241996",
"0.73861295",
"0.7304909",
"0.7213267",
"0.7098527",
"0.70523435",
"0.6987495",
"0.69399804",
"0.6856166",
"0.6856166",
"0.6824608",
"0.6824093",
"0.680345",
"0.66413265",
"0.65983105",
"0.6589409",
"0.65585434",
"0.6521371",
"0.65205455",
"0.64969575",
"0.64735776",
"0.6435829",
"0.63418925",
"0.6334156",
"0.63259804",
"0.6279324",
"0.6251475",
"0.6224225",
"0.6180099",
"0.61474955",
"0.6121433",
"0.61120933",
"0.6082804",
"0.6078098",
"0.60674167",
"0.6054591",
"0.60315317",
"0.60315317",
"0.60314786",
"0.60270965",
"0.60254544",
"0.60209394",
"0.601921",
"0.59937555",
"0.59539",
"0.5942361",
"0.594044",
"0.5926739",
"0.59249264",
"0.5920074",
"0.5875796",
"0.58719486",
"0.58443487",
"0.582661",
"0.5821253",
"0.5820415",
"0.5814696",
"0.58064836",
"0.5802705",
"0.5793303",
"0.5792317",
"0.5791224",
"0.57893395",
"0.5782078",
"0.5776408",
"0.57642144",
"0.57600904",
"0.57598644",
"0.5759819",
"0.57586074",
"0.5753487",
"0.57490706",
"0.57391965",
"0.5737903",
"0.5737903",
"0.572286",
"0.570001",
"0.56936324",
"0.5692962",
"0.5687636",
"0.5671894",
"0.5663192",
"0.5656055",
"0.5651143",
"0.5647052",
"0.56386316",
"0.5638594",
"0.56300724",
"0.5627052",
"0.5625495",
"0.56236756",
"0.5623657",
"0.5622198",
"0.5599358",
"0.55946326",
"0.5593469",
"0.559082",
"0.5580849",
"0.5579997",
"0.5575835",
"0.5575467"
] |
0.0
|
-1
|
Gets the folder you want to create the VM
|
def get_folder(name)
# Create a filter to ensure that only the named folder is returned
filter = Com::Vmware::Vcenter::Folder::FilterSpec.new(names: Set.new([name]))
folder_obj = Com::Vmware::Vcenter::Folder.new(vapi_config)
folder = folder_obj.list(filter)
raise format("Unable to find folder: %s", name) if folder.empty?
folder[0].folder
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def get_vbox_vm_dir(client_name)\n message = \"Getting:\\tVirtualBox VM directory\"\n command = \"VBoxManage list systemproperties |grep 'Default machine folder' |cut -f2 -d':' |sed 's/^[ ]*//g'\"\n vbox_vm_base_dir = execute_command(message,command)\n vbox_vm_base_dir = vbox_vm_base_dir.chomp\n if !vbox_vm_base_dir.match(/[A-z]/)\n vbox_vm_base_dir=$home_dir+\"/VirtualBox VMs\"\n end\n vbox_vm_dir = \"#{vbox_vm_base_dir}/#{client_name}\"\n return vbox_vm_dir\nend",
"def path\n File.join Fission.config['vm_dir'], \"#{@name}.vmwarevm\"\n end",
"def path\n File.join Fission.config['vm_dir'], \"#{@name}.vmwarevm\"\n end",
"def path\n File.join Fission.config.attributes['vm_dir'], \"#{@name}.vmwarevm\"\n end",
"def root_folder\n connect\n\n @vm_folder\n end",
"def mkdir path\n parent = lookup_single! File.dirname(path), RbVmomi::VIM::Folder\n parent.CreateFolder(:name => File.basename(path))\nend",
"def get_migration_folder(instance)\n File.join(@migration_nfs, 'migration', service_name, instance)\n end",
"def gen_video_dir()\n dir = \"#{Rails.root}/public/secure/video/#{@folder}\"\n if Dir.exist? dir\n dir\n else\n dir if FileUtils.mkdir_p dir\n end\n end",
"def get_folder(name, type = \"VIRTUAL_MACHINE\", datacenter = nil)\n folder_api = VSphereAutomation::VCenter::FolderApi.new(api_client)\n raise_if_unauthenticated folder_api, \"checking for folder `#{name}`\"\n\n parent_path, basename = File.split(name)\n filter = { filter_names: basename, filter_type: type }\n filter[:filter_datacenters] = datacenter if datacenter\n filter[:filter_parent_folders] = get_folder(parent_path, type, datacenter) unless parent_path == \".\"\n\n folders = folder_api.list(filter).value\n\n raise_if_missing folders, format(\"Unable to find VM/template folder: `%s`\", basename)\n raise_if_ambiguous folders, format(\"`%s` returned too many VM/template folders\", basename)\n\n folders.first.folder\n end",
"def workspace_folder\n @pwd\n end",
"def folder\n connection.directories.get(folder_name)\n end",
"def folder\n @root_folder\n end",
"def vagrant_box(name)\n result = boxes_path.join(name)\n FileUtils.mkdir_p(result)\n result\n end",
"def vcenter_folder(vcenter_vm_folder, vc_template, dc)\n vcenter_vm_folder_object = nil\n\n if !vcenter_vm_folder.nil? && !vcenter_vm_folder.empty?\n vcenter_vm_folder_object =\n dc\n .item\n .find_folder(\n vcenter_vm_folder\n )\n end\n\n vcenter_vm_folder_object =\n vc_template\n .parent if vcenter_vm_folder_object.nil?\n vcenter_vm_folder_object\n end",
"def output_dir(vm_name, build_type)\n unless build_type == 'base'\n File.join('./output/', \"#{vm_name}-virtualbox\")\n else\n File.join('./output/', \"#{vm_name}-base-virtualbox\")\n end\nend",
"def get_parallels_vm_dir(options)\n\treturn options['vmdir']\nend",
"def folder\n File.join self.class::FOLDER, model_id.to_s\n end",
"def folder_path\n File.join(location.path, folder_name)\n end",
"def root_dir\n ManageIQ::Providers::Lenovo::Engine.root.join(\"content/ansible_runner\")\n end",
"def read_machine_folder\n end",
"def folder_path\n File.expand_path @folder_path\n end",
"def get_team_folder\n\n Team.get_team_folder(self.id)\n end",
"def gen_news_dir()\n dir = \"#{Rails.root}/public/secure/news/#{@folder}\"\n if Dir.exist? dir\n dir\n else\n dir if FileUtils.mkdir_p dir\n end\n end",
"def store_dir\n format(\n '%suploads/peoplefinder/%s/%s/%s',\n base_upload_dir,\n model.class.to_s.underscore,\n mounted_as_without_legacy_prefix,\n model.id\n )\n end",
"def dir\n Rails.root.join(ROOT, type, name).to_s\n end",
"def root_folder\n scheduler_service.GetFolder(\"\\\\\")\n end",
"def folder_name\n @folder_name\n end",
"def store_dir\n File.join Rails.root, root_dir, model_dir, partition_dir\n end",
"def path\n folder.path + name\n end",
"def path\n File.join(Settings.root, folder_name.to_path)\n end",
"def store_dir\n File.join(model.class.to_s.underscore.pluralize, model.id.to_s, mounted_as.to_s)\n end",
"def read_machine_folder\n execute(\"list\", \"systemproperties\").split(\"\\n\").each do |line|\n if line =~ /^Default machine folder:\\s+(.+?)$/i\n return $1.to_s\n end\n end\n\n nil\n end",
"def local_cache(basebox_name)\n cache_dir = Vagrant::Environment.new.home_path.join('cache', 'apt', basebox_name)\n # Vagrant::Environment.new.home_path\n print cache_dir\n cache_dir.mkpath unless cache_dir.exist?\n partial_dir = cache_dir.join('partial')\n partial_dir.mkdir unless partial_dir.exist?\n cache_dir\nend",
"def create_folder\n unless File.directory?(client.config.tmp_folder)\n FileUtils.mkdir_p(client.config.tmp_folder)\n end\n end",
"def folder_name\n\t\treturn 'st' + student_id.to_s + 'pr' + problem_id.to_s + 'so' + id.to_s + '/'\n\tend",
"def store_dir\n \"uploads/creation_ppt/#{model.id}\"\n end",
"def store_dir\n '%suploads/peoplefinder/%s/%s/%s' % [\n base_upload_dir,\n model.class.to_s.underscore,\n mounted_as_without_legacy_prefix,\n model.id\n ]\n end",
"def folder\n model.folder\n end",
"def create_synced_dir(config, host_dir, vm_dir, options = {})\n config.vm.synced_folder host_dir, vm_dir, options if File.directory?(host_dir)\nend",
"def store_dir\n if model[\"#{mounted_as}\"]\n fname = model[\"#{mounted_as}\"]\n else\n fname = self.filename\n end\n p1,p2 = fname[0,1],fname[1,1]\n [model.class.to_s.underscore,p1,p2].join(\"/\")\n end",
"def base\n result = sphere.cache_path.join('chef')\n result.mkpath\n result\n end",
"def folder\n @folder ||= File.expand_path('.')\n end",
"def store_dir\n \"city-of-meridian/files/\"\n end",
"def get_clone_directory()\n\n if @to\n folder_exists = File.directory?( @to )\n FileUtils.mkdir_p( @to ) unless folder_exists\n return @to\n end\n\n if @verse.has_key?( Indices::GIT_CLONE_BASE_PATH )\n folder_exists = File.directory?( @verse[ Indices::GIT_CLONE_BASE_PATH ] )\n FileUtils.mkdir_p( @verse[ Indices::GIT_CLONE_BASE_PATH ] ) unless folder_exists\n return @verse[ Indices::GIT_CLONE_BASE_PATH ]\n end\n\n return Dir.pwd()\n\n end",
"def get_uplift_config_folder\n path = File.expand_path(@@config_file_path)\n FileUtils.mkdir_p path\n\n return path\n end",
"def folder\n @folders[@folder_name]\n end",
"def folder\n @folder ||= './.tests_cli'\n end",
"def build_workspace_dir(root_dir, dirname, uuid)\n \"/#{root_dir}/#{dirname}-#{uuid}\"\nend",
"def store_dir\n %(#{Rails.root}/storage/#{model.parent.class.name.pluralize.downcase}/#{model.parent.id})\n end",
"def get_parallels_disk(options)\n message = \"Information:\\tDetermining directory for Parallels VM \"+options['name']\n command = \"prlctl list #{options['name']} --info |grep image |awk '{print $4}' |cut -f2 -d=\"\n vm_dir = execute_command(options,message,command)\n vm_dir = vm_dir.chomp.gsub(/'/,\"\")\n return vm_dir\nend",
"def create_folder(name)\n Dir.mkdir(\"#{name}\")\nend",
"def local_box_path name\n boxes_root = (self.local_field \"boxes_path\") || ENV['VAGRANT_BOXES'] || \"~/.boxes\"\n \"#{boxes_root}/#{name}\"\n end",
"def object_dir\n ::File.join(new_resource.config_home, type_from_name) + 's'\n end",
"def folder\n @folder ||= File.join('.', 'public', 'page', 'article')\n end",
"def generate_install_folder\n folder='./EdenApps'\n unless File.exist?(folder)\n Console.show \"Creating folder #{folder}\", 'info'\n FileUtils.mkdir_p(folder)\n FileUtils.chown_R('EdenManager','EdenManager',folder)\n FileUtils.chmod_R(0775, folder)\n end\n installFolder = \"./EdenApps/#{self.type}/#{self.name}\"\n unless File.exist?(installFolder)\n Console.show \"Creating folder #{installFolder}\", 'info'\n FileUtils.mkdir_p(installFolder)\n FileUtils.chown_R('EdenManager','EdenManager',installFolder)\n end\n installFolder\n end",
"def create_storage_dir\n placeholder = @placeholder || @dirname\n dirpath = File.join(storage_path, placeholder)\n FileUtils.mkdir dirpath unless Dir.exists? dirpath\n end",
"def bootstrap_folder\n FileUtils.mkdir_p folder_path\n end",
"def folder(name)\n Kamelopard::Folder.new(name)\n end",
"def create_folder()\n\n directory_name = \"./public/swap/imageuploader\"\n Dir.mkdir(directory_name) unless File.exists?(directory_name)\n\nend",
"def store_dir\n path = \"cliente/#{model.id}/logomarca\"\n\n # if Rails.env.development?\n # path = \"development/#{path}\"\n # end\n\n path\n end",
"def workdir\n result = base.join('cache')\n result.mkpath\n result\n end",
"def store_dir\n File.join(OpenInvoice.config.dir_prefix,\n model.class.to_s.underscore,\n mounted_as.to_s,\n model&.id.to_s)\n end",
"def directory\r\n \t@directory.path\r\n end",
"def store_dir(model)\n File.join Rails.root, \"public\", \"assets\", partition_dir(model)\n end",
"def create\n location.mkdir\n end",
"def get_local_dir\n return @resource[:local_dir]\n end",
"def getFolder\r\n\t\t\t\t\treturn @folder\r\n\t\t\t\tend",
"def store_dir\n \"#{model.guid}\"\n end",
"def team_folder_create(folder:, trace: false)\n dropbox_query(query: '2/team/team_folder/create', query_data: \"{\\\"name\\\":\\\"#{folder}\\\"}\", trace: trace)\n end",
"def folder\n @attributes[:folder]\n end",
"def local_cache(box_name, cache_name)\r\n cache_dir = File.join(File.expand_path(\"~/.vagrant.d\"), \"cache\", cache_name, box_name)\r\n if cache_name == \"apt\"\r\n partial_dir = File.join(cache_dir, \"partial\")\r\n FileUtils.mkdir_p(partial_dir) unless File.exists? partial_dir\r\n end\r\n cache_dir\r\nend",
"def store_dir\n\n \"#{model.publication.product_code}/#{model.product_id}\"\n end",
"def folder\n @folder ||= File.dirname(source)\n end",
"def path\n @@path ||= File.join(RAILS_ROOT, 'tmp', 'cache', 'vm')\n end",
"def folder\n nil\n end",
"def store_dir\n \"#{model.account.subdomain}/#{model.class.to_s.underscore}/#{model.id}\"\n end",
"def create_synced_dir(config, host_dir, vm_dir, owner = 'vagrant', group = 'vagrant')\n unless File.directory?(host_dir)\n require 'fileutils'\n FileUtils.mkdir_p(host_dir)\n end\n config.vm.synced_folder host_dir, vm_dir, owner: owner, group: group\nend",
"def local_cache(box_name)\n cache_dir = File.join(File.expand_path(\"~/.vagrant.d\"),\n 'cache',\n 'apt',\n box_name)\n partial_dir = File.join(cache_dir, 'partial')\n FileUtils.mkdir_p(partial_dir) unless File.exists? partial_dir\n cache_dir\nend",
"def find_vm_folder(pool_name, connection)\n # Find a folder by its inventory path and return the object\n # Returns nil when the object found is not a folder\n pool_configuration = pool_config(pool_name)\n return nil if pool_configuration.nil?\n\n folder = pool_configuration['folder']\n datacenter = get_target_datacenter_from_config(pool_name)\n return nil if datacenter.nil?\n\n propSpecs = { # rubocop:disable Naming/VariableName\n entity: self,\n inventoryPath: \"#{datacenter}/vm/#{folder}\"\n }\n\n folder_object = connection.searchIndex.FindByInventoryPath(propSpecs) # rubocop:disable Naming/VariableName\n return nil unless folder_object.instance_of? RbVmomi::VIM::Folder\n\n folder_object\n end",
"def clone_vm(drv_action)\n vcenter_name = vc_name\n\n dc = cluster.datacenter\n\n vcenter_vm_folder = drv_action['USER_TEMPLATE/VCENTER_VM_FOLDER']\n\n if !vcenter_vm_folder.nil? && !vcenter_vm_folder.empty?\n vcenter_vm_folder =\n vcenter_folder_name(vcenter_vm_folder, drv_action)\n\n vcenter_vm_folder_object =\n dc.item.find_folder(vcenter_vm_folder)\n\n if vcenter_vm_folder_object.nil?\n begin\n dc.item.vmFolder.CreateFolder(\n :name => vcenter_vm_folder\n )\n rescue StandardError => e\n error_message = e.message\n if VCenterDriver::CONFIG[:debug_information]\n error_message += ' ' + e.backtrace\n end\n raise 'Cannot create Folder in vCenter:'\\\n \"#{error_message}\"\n end\n end\n end\n\n vcenter_vm_folder = drv_action['USER_TEMPLATE/VCENTER_VM_FOLDER']\n\n if !vcenter_vm_folder.nil? && !vcenter_vm_folder.empty?\n vcenter_vm_folder =\n vcenter_folder_name(vcenter_vm_folder, drv_action)\n\n vcenter_vm_folder_object =\n dc.item.find_folder(vcenter_vm_folder)\n\n if vcenter_vm_folder_object.nil?\n begin\n vcenter_vm_folder_list = vcenter_vm_folder.split('/')\n folder_root = dc.item.vmFolder\n\n vcenter_vm_folder_list.each do |folder_name|\n folder_root = find_or_create_folder(\n folder_root,\n folder_name\n )\n end\n rescue StandardError => e\n error_message = e.message\n if VCenterDriver::CONFIG[:debug_information]\n error_message += ' ' + e.backtrace\n end\n\n raise 'Cannot create Folder in vCenter: '\\\n \"#{error_message}\"\n end\n end\n end\n\n vc_template_ref = drv_action['USER_TEMPLATE/VCENTER_TEMPLATE_REF']\n vc_template = RbVmomi::VIM::VirtualMachine(@vi_client.vim,\n vc_template_ref)\n\n ds = get_ds\n\n asking_for_linked_clones =\n drv_action[\n 'USER_TEMPLATE/VCENTER_LINKED_CLONES'\n ]\n disk_move_type = calculate_disk_move_type(ds,\n vc_template,\n asking_for_linked_clones)\n\n spec_hash = spec_hash_clone(disk_move_type)\n\n clone_spec = RbVmomi::VIM.VirtualMachineCloneSpec(spec_hash)\n\n vcenter_vm_folder_object =\n vcenter_folder(\n vcenter_vm_folder,\n vc_template,\n dc\n )\n\n if ds.instance_of? RbVmomi::VIM::StoragePod\n # VM is cloned using Storage Resource Manager for StoragePods\n begin\n opts = {\n :vc_template => vc_template,\n :vcenter_name => vcenter_name,\n :clone_spec => clone_spec,\n :storpod => ds,\n :vcenter_vm_folder_object => vcenter_vm_folder_object,\n :dc => dc\n }\n\n vm = storagepod_clonevm_task(opts)\n rescue StandardError => e\n error =\n \"Cannot clone VM Template to StoragePod: #{e.message}.\"\n\n if VCenterDriver::CONFIG[:debug_information]\n error += \"\\n\\n#{e.backtrace}\"\n end\n\n raise error\n end\n else\n vm = nil\n begin\n vm = vc_template.CloneVM_Task(\n :folder => vcenter_vm_folder_object,\n :name => vcenter_name,\n :spec => clone_spec\n ).wait_for_completion\n rescue StandardError => e\n if !e.message.start_with?('DuplicateName')\n raise \"Cannot clone VM Template: #{e.message}\"\n end\n\n vm_folder = dc.vm_folder\n vm_folder.fetch!\n vm = vm_folder.items\n .select {|_k, v| v.item.name == vcenter_name }\n .values.first.item rescue nil\n\n raise \"Cannot clone VM Template: #{e.message}\" unless vm\n\n # Detach all persistent disks to\n # avoid accidental destruction\n detach_persistent_disks(vm)\n\n vm.Destroy_Task.wait_for_completion\n vm = vc_template.CloneVM_Task(\n :folder => vcenter_vm_folder_object,\n :name => vcenter_name,\n :spec => clone_spec\n ).wait_for_completion\n end\n end\n\n # @item is populated\n @item = vm\n\n reference_unmanaged_devices(vc_template_ref)\n\n self['_ref']\n end",
"def generatedReportFolder\n currentData, currentTime = DateTime.now.strftime(\"%Y_%m_%d %H_%M\").split(' ')\n path = \"#{$ROOT}/../output\"\n creatFolder(path)\n path += \"/#{currentData}\"\n creatFolder(path)\n path += \"/#{currentTime}\"\n creatFolder(path)\n path\n end",
"def server_home\n FilePath.new(@build_dir, \"homes\", \"server\").ensure_directory\n end",
"def store_dir\n # \"images/#{model.class.to_s.underscore}/#{model.team_name}\"\n \"images/product_images/\"\n end",
"def directory\n File.dirname(@path) + '/'\n end",
"def d_objects_folder(basedir='bct/mss/dvd')\n dvd=self.dvd_originale\n return nil if dvd.nil?\n target = format 'T%04d', dvd['numero_dvd']\n path=File.dirname(dvd['path'])\n n=File.join(basedir,target,path)\n DObjectsFolder.find_by_name(n)\n end",
"def store_dir\n \"photos/#{model.id}/\"\n end",
"def get_output_folder\n File.join( Rails.root, 'public', 'output' )\n end",
"def store_dir\n \"uploads/creation_doc/#{model.id}\"\n end",
"def local_cache(box_name)\n cache_dir = File.join(File.expand_path(Vagrant::Environment::DEFAULT_HOME),\n 'cache',\n 'apt',\n box_name)\n partial_dir = File.join(cache_dir, 'partial')\n FileUtils.mkdir_p(partial_dir) unless File.exists? partial_dir\n cache_dir\nend",
"def store_dir\n \"system/#{object_class_name}/#{mounted_as}/#{model.id}\"\n end",
"def given_destination\n dir\n end",
"def current_folder_proximites\n ctp = current_texte_path\n File.join(File.dirname(ctp), \"proximites-#{File.basename(ctp,File.extname(ctp))}\")\n end",
"def create_app_folder_structure\n puts \"Create #{name} folder structure\"\n end",
"def store_dir\n \"sites/#{model.site_id}/#{model.class.to_s.pluralize.underscore}/#{model.id}\"\n end",
"def store_dir\n consecutivo = \"#{model.consecutivo}\"\n if consecutivo.nil?\n consecutivo = Design.all.count.to_s\n end\n \"uploads/#{mounted_as}/\"+consecutivo\n end",
"def userfolder\n # \"public/upload/user_id_\" + self.user_id.to_s\n User.find_by_id( self.user_id ).userfolder\n end",
"def traverse_and_create path\n root = @folder_cache.values.find{|file| file.name == ROOT_FOLDER and file.parents.nil?}\n\n #DriveV3::File (actually folders)\n files = [root]\n places = path.split '/'\n places.each do |place|\n next if place == ''\n folder = folder_with_name place, files.last\n folder = create_folder(place, files.last) if folder.nil?\n files << folder\n end\n files.last\n end",
"def google_create_folder(client)\n path = CGI::unescape(@fields[:path].to_s)\n result = client.create_folder_by_path(path)\n end",
"def get_remote_dir\n return @resource[:remote_dir]\n end",
"def path()\n file = File.join(Eddy.config.tmp_dir, \"eddy_persistent_data.json\")\n # FileUtils.mkdir_p(File.dirname(file))\n return Pathname.new(file)\n end"
] |
[
"0.68042755",
"0.6696341",
"0.6696341",
"0.6678664",
"0.66052973",
"0.64466584",
"0.6395029",
"0.63356286",
"0.6280226",
"0.62693256",
"0.6264736",
"0.6257353",
"0.6237181",
"0.6216561",
"0.6195987",
"0.6146943",
"0.6146176",
"0.6107727",
"0.6041936",
"0.60311973",
"0.6028049",
"0.60084146",
"0.5992503",
"0.5987522",
"0.5982009",
"0.5974748",
"0.5971949",
"0.5963963",
"0.5936083",
"0.5934905",
"0.59296644",
"0.5925667",
"0.59228045",
"0.59124434",
"0.59038484",
"0.5893365",
"0.5891139",
"0.5854887",
"0.58534604",
"0.5851042",
"0.58412296",
"0.583296",
"0.58320445",
"0.58309144",
"0.5814798",
"0.58052397",
"0.5801246",
"0.57976604",
"0.57886213",
"0.5785951",
"0.5774073",
"0.57700044",
"0.5763921",
"0.57540506",
"0.5744206",
"0.5728565",
"0.57250535",
"0.57216537",
"0.5721463",
"0.57108873",
"0.57030815",
"0.5693984",
"0.5690664",
"0.56839895",
"0.5678823",
"0.5676262",
"0.567253",
"0.56703234",
"0.5658399",
"0.5644705",
"0.5643807",
"0.5642714",
"0.5636844",
"0.56317693",
"0.56311053",
"0.5627689",
"0.562567",
"0.56237584",
"0.56228113",
"0.561548",
"0.56101525",
"0.5607346",
"0.56067497",
"0.56027484",
"0.560029",
"0.5594417",
"0.55929947",
"0.55912375",
"0.559072",
"0.5589544",
"0.5586755",
"0.5576497",
"0.5572114",
"0.5572069",
"0.556331",
"0.5561776",
"0.55596066",
"0.55530125",
"0.5545777",
"0.55444"
] |
0.5706598
|
60
|
Gets the name of the VM you are creating
|
def get_vm(name)
filter = Com::Vmware::Vcenter::VM::FilterSpec.new(names: Set.new([name]))
vm_obj = Com::Vmware::Vcenter::VM.new(vapi_config)
vm_obj.list(filter)[0]
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def vm_name\n if !name || name.empty?\n \"#{user.id}-#{project.name.gsub('.','-')}-#{Time.zone.now.to_i.to_s.sub(/^../,'')}\".downcase\n else\n name\n end\n end",
"def vagrant_vm_name(name)\n return \"vagrant-#{name}-#{ENV['USER']}\"\nend",
"def computername\n vm.os_profile.computer_name\n end",
"def virtual_machine_template(name)\n kubevirt_client.get_virtual_machine_template(name, @namespace)\n end",
"def vm(name)\n @conn.vms.get(name)\n end",
"def define_machine_name(config, name)\n config.vm.provider \"virtualbox\" do |v|\n v.name = name\n end\nend",
"def vm(name)\n @vms.find {|v| v.name == name}\n end",
"def myname(compute)\n\t\t# lookup the name of the running instance\n\t\tinstanceid = Facter.value('ec2_instance_id')\n\t\tif ( instanceid =~ /i-/ )\n\t\t\treturn lookupname(compute,instanceid)\n\t\telse\n\t\t\traise \"ebsvol[aws]->myname: Sorry, I can't find my instanceId - please check Facter fact ec2_instance_id is available\"\n\t\tend\n\t\tnil\n\tend",
"def objname()\n machine = self.get_machine()\n profile = self.get_profile()\n (machine.nil? ? \"no machine\" : machine.hostname) + \": \" + (profile.nil? ? \"no profile\" : profile.name)\n end",
"def vm_field name\n VMS_DICT.fetch(\"vms\").fetch(@id).fetch(name)\n end",
"def instance_name\n info.name\n end",
"def build_host_name\n if @build_host_template_name.nil?\n validate_platform\n @build_host_template_name = @platform.vmpooler_template\n end\n\n @build_host_template_name\n end",
"def hostname\n host_hash['vmhostname'] || @name\n end",
"def virtual_machine(name)\n kubevirt_client.get_virtual_machine(name, @namespace)\n end",
"def get_vm(_pool_name, _vm_name)\n # raise(\"#{self.class.name} does not implement get_vm\")\n\n return @virtual_box.get_machines_by_groups({ :groups => [_pool_name] }).select do | machine |\n begin\n machine.name\n rescue\n $logger.log('s', \"[x] skipping bad vm [#{_pool_name}] '#{machine}'\")\n next\n end\n end.map do | machine |\n { \n 'name' => machine.name,\n 'hostname' => 'localhost',\n 'template' => _pool_name,\n 'poolname' => _pool_name,\n 'boottime' => Time.new,\n 'powerstate' => machine.state, \n }\n end.first\n end",
"def template_name\n name.split(\"::\").last.downcase.gsub(/onebox/, \"\")\n end",
"def name\n @name ||= \"ec2-net-utils-kitchen-#{instance.id}-eth1\"\n end",
"def build_host_name\n if @platform.abs_resource_name\n @platform.abs_resource_name\n elsif @platform.vmpooler_template\n @platform.vmpooler_template\n else\n @platform.name\n end\n end",
"def build_host_name\n if @platform.abs_resource_name\n @platform.abs_resource_name\n elsif @platform.vmpooler_template\n @platform.vmpooler_template\n else\n @platform.name\n end\n end",
"def name\n vcloud_attributes[:name]\n end",
"def machine\n @machine = begin\n machine = manager.vbox.machines.detect { |machine| machine.name == name }\n raise VmNotFound, \"#{name} VirtualBox VM could not be found\" unless machine\n machine\n end\n end",
"def get_vm_host(_pool_name, _vm_name)\n\n #for v1 virtualbox support this is all local so the hostname will always be localhost\n return 'localhost'\n end",
"def default_name\n debug(\"Instance name: #{instance.name}\")\n \"#{instance.platform.name}-#{Time.now.to_i}\"\n end",
"def vm_instance(name)\n @conn.vminstances.get(name)\n end",
"def step_name\n Bebox::Provision.step_name(self.step)\n end",
"def vm(name)\n logger.debug \"Retrieving VM '#{name}' from #{description}\"\n Derelict::VirtualMachine.new(self, name).validate!\n end",
"def migratevm_host\n begin\n vm.runtime.host.name\n rescue Exception => e\n fail e.message\n end\n\n end",
"def name\n @_name ||= (@config[:supervisor_name_override] || \"#{@config[:root_name]}-#{`hostname`.chomp}\").gsub(/[^a-zA-Z0-9\\-\\_]/, ' ').gsub(/\\s+/, '-').downcase\n end",
"def get_vm_name(matching_options_hash, matching_tags_hash)\n log(:info, \"Processing get_vm_name\", true)\n if matching_options_hash[:vm_name].nil?\n matching_options_hash[:vm_name] = 'changeme'\n else\n unless $evm.vmdb('vm_or_template').find_by_name(matching_options_hash[:vm_name]).nil?\n # Loop through 0-999 and look to see if the vm_name already exists in the vmdb to avoid collisions\n for i in (1..999)\n new_vm_name = \"#{matching_options_hash[:vm_name]}#{i}\"\n log(:info, \"Checking for existence of vm: #{new_vm_name}\")\n if $evm.vmdb('vm_or_template').find_by_name(new_vm_name).nil?\n break\n end\n end\n matching_options_hash[:vm_name] = new_vm_name\n end\n end\n log(:info, \"Processing get_vm_name...Complete\", true)\n end",
"def name\n ssh.exec!(\"hostname\").chomp\n end",
"def get_box_name(vm_config)\n box_hostname = concat_array( \n [\n vm_config['lib']['key'],\n vm_config['lib']['namespace']\n ]\n )\n return box_hostname\nend",
"def get_vm_info()\n promise = @compute_client.virtual_machines.get(@rg_name, @instance_name)\n result = promise.value!\n OOLog.info(\"vm info :\"+result.body.inspect)\n return result.body\n end",
"def add_windows_jumpbox name\n virtual_machine name+'jbx' do\n public_ipaddress name\n image Azure::ARM::Compute::VirtualMachine::WINDOWS_SERVER_2012_R2_DATACENTER\n end\n end",
"def vm\n env.vm\n end",
"def name\n zombie_check\n @name\n end",
"def stored_virtual_machine(name)\n kubevirt_client.get_stored_virtual_machine(name, @namespace)\n end",
"def local_name\n ec2_user_data('local_name', 'local_name')\n end",
"def virtual_name(name = nil)\n if @config and @config['virtual_name'] and\n (!name or name == @config['virtual_name'])\n return @config['virtual_name']\n end\n nil\n end",
"def vm_rename\n requires :instance_uuid, :name\n service.vm_rename('instance_uuid' => instance_uuid, 'name' => name)\n end",
"def is_vm?\n cmd = \"VBoxManage showvminfo \\\"#{@vbox_name}\\\"\"\n _, stderr, _ = Open3.capture3(cmd)\n if stderr.include? 'Could not find a registered machine named'\n raise \"Virtual Machine #{@vbox_name} does not exist\"\n end\n end",
"def name\n system_name\n end",
"def get_vm(name)\n vm_api = VSphereAutomation::VCenter::VMApi.new(api_client)\n raise_if_unauthenticated vm_api, \"checking for VM `#{name}`\"\n\n vms = vm_api.list({ filter_names: name }).value\n\n raise_if_missing vms, format(\"Unable to find VM `%s`\", name)\n raise_if_ambiguous vms, format(\"`%s` returned too many VMs\", name)\n\n vms.first\n end",
"def name\n Properties[self.class] ||= {}\n return Properties[self.class][:name] || 'shell'\n end",
"def task_name\n raise \"This Stage has not been bound to a name\" if @name.nil?\n name.name\n end",
"def path\n File.join Fission.config['vm_dir'], \"#{@name}.vmwarevm\"\n end",
"def path\n File.join Fission.config['vm_dir'], \"#{@name}.vmwarevm\"\n end",
"def to_s\n id = @machine.id ? @machine.id : 'new VM'\n \"Parallels (#{id})\"\n end",
"def get_vm(_pool_name, _vm_name)\n raise(\"#{self.class.name} does not implement get_vm\")\n end",
"def template_name\n command.text_value\n end",
"def vm_names\n machines = manager.vbox.machines.find_all do |machine|\n machine.name =~ /#{Travis::Worker.config.vms.name_prefix}/\n end\n machines ? machines.map { |machine| machine.name } : []\n end",
"def get_machine_id()\n machine_id_filepath = \".vagrant/machines/default/virtualbox/id\"\n\n if not File.exists? machine_id_filepath\n # VM hasn't been created yet.\n return false\n end\n\n # This is probably not a great way to do this: shell out to the cat command.\n # It seems likely that ruby has a get-file-contents function somewhere,\n # but I'm definitely not a ruby dev right now.\n machine_id = `cat #{machine_id_filepath}`\nend",
"def path\n File.join Fission.config.attributes['vm_dir'], \"#{@name}.vmwarevm\"\n end",
"def get_vm_name(matching_options_hash, matching_tags_hash, prov)\n log(:info, \"Processing get_vm_name\", true)\n new_vm_name = matching_options_hash[:vm_name] || matching_options_hash[:vm_target_name] rescue nil\n unless new_vm_name.blank?\n matching_options_hash[:vm_target_name] = new_vm_name\n matching_options_hash[:vm_target_hostname] = new_vm_name\n matching_options_hash[:vm_name] = new_vm_name\n else\n matching_options_hash[:vm_target_hostname] = prov.get_option(:vm_target_name)\n matching_options_hash[:vm_name] = prov.get_option(:vm_target_name)\n end\n log(:info, \"Processing get_vm_name...Complete\", true)\nend",
"def create_vm(opts = {})\n opts = opts.with_indifferent_access.reverse_merge(\n VSphereConfig.create_vm_defaults.symbolize_keys || {}\n )\n\n opts[:template_path] = compute.image if compute.image\n\n VSphere.with_connection do |vs|\n dest_folder = opts[:dest_folder]\n vm_name = opts[:name] || \"#{compute.image}-\"\\\n \"#{SecureRandom.hex(4)}-#{Time.new.strftime(\"%Y%m%d\")}\"\n exception_cb = lambda do |_p1|\n LabManager.logger.warn(\n \"Failed attempt to create virtual machine: template_name: #{opts[:template_path]}\"\\\n \", vm_name: #{vm_name}\"\n )\n end\n\n Retryable.retryable(\n tries: VSphereConfig.create_vm_defaults[:vm_clone_retry_count],\n on: [RbVmomi::Fault, CreateVMError, Fog::Compute::Vsphere::NotFound],\n exception_cb: exception_cb,\n sleep: ->(n) { Random.rand(n*3..n*3+10.0) }\n ) do\n LabManager.logger.info \"creating machine with name: #{vm_name} options: #{opts.inspect}\"\n machine = vs.vm_clone(\n 'datacenter' => opts[:datacenter],\n 'datastore' => opts[:datastore],\n 'template_path' => opts[:template_path],\n 'name' => vm_name,\n 'cluster' => opts[:cluster],\n 'linked_clone' => opts[:linked_clone],\n 'dest_folder' => dest_folder,\n 'power_on' => opts[:power_on],\n 'wait' => true\n )\n\n setup_network_interfaces({\n uuid: machine['new_vm']['uuid'],\n connection: vs,\n network_name: VSphereConfig.create_vm_defaults[:network_interface_name]\n })\n\n fail CreateVMError, \"Creation of (#{vm_name}) machine failed, retrying\" unless machine || machine['vm_ref']\n set_provider_data(machine['new_vm'], vs: vs)\n end\n\n add_machine_to_drs_rule(\n vs,\n group: opts[:add_to_drs_group],\n machine: \"#{dest_folder}/#{vm_name}\",\n datacenter: opts[:datacenter]\n ) if opts[:add_to_drs_group]\n end\n poweron_vm unless compute.provider_data['power_state'] == 'poweredOn'\n rescue\n # Try to free unsuccessfully started/configured/... VM\n begin\n terminate_vm\n rescue\n nil\n end if instance_uuid\n raise\n end",
"def get_template(template)\n xapi.VM.get_by_name_label(template).first\n end",
"def get_template(template)\n xapi.VM.get_by_name_label(template).first\n end",
"def name\n 'vsphere'\n end",
"def get_virtual_machine(name, cloud_service_name)\n server = list_virtual_machines(cloud_service_name).select { |x| x.vm_name.casecmp(name) == 0 }\n server.first\n end",
"def name_factory\n V01::Name\n end",
"def get_virtual_machine(name, cloud_service_name)\n server = list_virtual_machines.select {|x| x.vm_name == name && x.cloud_service_name == cloud_service_name}\n server.first\n end",
"def name\n @name || Vedeu.focus\n end",
"def get_vm(vm_id)\n end",
"def create_vm(config, node_name)\n config.vm.define node_name do |vm|\n vm.vm.host_name = node_name\n vm.vm.network \"private_network\", type: \"dhcp\"\n vm.vm.box = \"ubuntu/xenial64\"\n end\nend",
"def inspect\n state_provider = \"[#{box_state} (#{provider})]\"\n \"#{name.ljust(max_length)} #{state_provider.ljust(max_length)} [VM OS <-- #{guest_os}]\"\n end",
"def vm\n object.vm.id\n end",
"def get_parallels_vm_uuid(options)\n message = \"Information:\\tDetermining UUID for Parallels VM \"+options['name']\n command = \"prlctl list --info \\\"#{options['name']}\\\" |grep '^ID' |cut -f2 -d:\"\n vm_uuid = vm_uuid.chomp.gsub(/^\\s+/,\"\")\n vm_uuid = execute_command(options,message,command)\n return vm_uuid\nend",
"def name\n return @name unless @name.nil?\n \"#{@name_prefix}host:#{Socket.gethostname} pid:#{Process.pid}\" rescue \"#{@name_prefix}pid:#{Process.pid}\"\n end",
"def create_virtual_machine(vm)\n kubevirt_client.create_virtual_machine(vm)\n end",
"def generate_name\r\n z = Time.now.getutc\r\n name = z.strftime(\"%Y%m%d.%H%M.%S.\") + sprintf(\"%03d\", (z.tv_usec / 1000))\r\n return name\r\n # Process.pid kddkd\r\n end",
"def name\n @name ||= begin \n ioctl(EVIOCGNAME(len = 256), out_name = \" \" * len)\n out_name.rstrip\n end\n end",
"def name()\n return @name\n end",
"def system_name\n self.name\n end",
"def name\n return \"New Firmware\" if !id\n version + \" (\" + description.to_s + \") \" +\n \" (\" + (for_external ? \"internal\" : \"external\") + \")\"\n end",
"def register_vbox_vm(client_name,client_os)\n message = \"Registering:\\tVM \"+client_name\n command = \"VBoxManage createvm --name \\\"#{client_name}\\\" --ostype \\\"#{client_os}\\\" --register\"\n execute_command(message,command)\n return\nend",
"def cloud_service_instance_name\n return @cloud_service_instance_name\n end",
"def vm_info\n unless @vm\n warn 'No VM assigned to get info from'\n return\n end\n @vm = locate_vm(@vm.to_hash['VM']['ID'].to_i)\n @vm.to_hash\n end",
"def get_storage_account_name(vm)\n storage_account_name=((vm.properties.storage_profile.os_disk.vhd.uri).split(\".\")[0]).split(\"//\")[1]\n OOLog.info(\"storage account to use:\"+storage_account_name)\n storage_account_name\n end",
"def name_template\n @name_template || self.to_s\n end",
"def instance\n \"deployment-#{target}\"\n end",
"def get_name(task_name)\n @view.get_name(task_name)\n end",
"def info_kvm(kvm_name)\n puts \"#{kvm_name}\"\n puts \" Type: #{kvm_type(kvm_name)}\"\n puts \" Address: #{kvm_ip(kvm_name)}\"\nend",
"def vm_by_name(name)\n vms = get('VM', :by_name_label, name)\n if vms.any?\n UltraVM::VM.new(self, vms.first)\n else\n false\n end\n end",
"def detailed_name\n \"#{label} ( #{name}_V#{version} )\"\n end",
"def gen_hostname(boxname)\n \"#{ENV['USER']}-#{(0...3).map { (65 + rand(26)).chr }.join.downcase}-#{boxname}\"\nend",
"def name\n @name ||= self.class.name\n end",
"def instance_name(suite, platform)\n Instance.name_for(suite, platform)\n end",
"def node_name(component, instance)\n name = ''\n @nodenameconvention.each do |i|\n case i\n when 'environment'\n name += @name\n when 'component'\n name += component\n when 'instance'\n name += instance.to_s.rjust(2, '0')\n when 'geo'\n name += @vcenter['geo'].to_s[0]\n else\n name += i\n end\n end\n name\n end",
"def get_name\n return @m_name\n end",
"def get_name\n return @m_name\n end",
"def get_name\n return @m_name\n end",
"def get_name\n return @m_name\n end",
"def name\n name = \"Cess Pool\"\n end",
"def name\n object[\"name\"]\n end",
"def description\n \"Derelict::VirtualMachine '#{name}' from #{connection.description}\"\n end",
"def name\n NAME\n end",
"def name\n @name ||= self.class.non_namespaced_name\n end",
"def create_kvm(kvm_name, template, options)\n ensure_name_availability!(kvm_name)\n clone_kvm(kvm_name, template)\n device = mount_kvm_volume(kvm_name)\n address = update_kvm_ip(kvm_name)\n update_hostname(kvm_name)\n make_console_accessible(kvm_name)\n unmount_kvm_volume(kvm_name, device)\n create_kvm_instance(kvm_name, options)\n puts \"KVM Node #{kvm_name} available at: #{address}\"\nend",
"def onebox_name\n name.split(\"::\").last.downcase.gsub(/onebox/, \"\")\n end",
"def name\n return service_name if info.nil?\n info[:name]\n end",
"def getName()\n return @name ;\n end"
] |
[
"0.76915306",
"0.69701385",
"0.6910907",
"0.67271996",
"0.6541935",
"0.6498251",
"0.6447349",
"0.64256537",
"0.6354848",
"0.63476133",
"0.63163006",
"0.6306579",
"0.6294003",
"0.62569034",
"0.62361115",
"0.6226915",
"0.6205531",
"0.6201566",
"0.6201566",
"0.6197333",
"0.61942124",
"0.61881804",
"0.6168849",
"0.61652166",
"0.6089095",
"0.6086464",
"0.6009302",
"0.6006109",
"0.5995545",
"0.59767497",
"0.59636027",
"0.5960467",
"0.5951702",
"0.59492683",
"0.5945209",
"0.59444314",
"0.5920926",
"0.5911929",
"0.58977485",
"0.5894929",
"0.5883864",
"0.586891",
"0.58657044",
"0.5861015",
"0.58370477",
"0.58370477",
"0.58150774",
"0.58063376",
"0.58023137",
"0.5789768",
"0.5787919",
"0.5764721",
"0.57434493",
"0.57421196",
"0.57266736",
"0.57266736",
"0.571279",
"0.5702194",
"0.5675341",
"0.5671753",
"0.56695116",
"0.5662219",
"0.56562585",
"0.56539035",
"0.5645039",
"0.5626335",
"0.5625755",
"0.5625229",
"0.5615721",
"0.5590835",
"0.55893666",
"0.5584993",
"0.5578425",
"0.55711085",
"0.55696607",
"0.5561962",
"0.55501556",
"0.55493134",
"0.5539646",
"0.5538483",
"0.55327666",
"0.5529895",
"0.5524729",
"0.5522904",
"0.5506691",
"0.5500729",
"0.549826",
"0.54970515",
"0.54970515",
"0.54970515",
"0.54970515",
"0.548977",
"0.5477305",
"0.5475055",
"0.54683954",
"0.54683787",
"0.546358",
"0.54624707",
"0.54623467",
"0.54583126"
] |
0.62187296
|
16
|
Gets the info of the cluster
|
def get_cluster(name)
cl_obj = Com::Vmware::Vcenter::Cluster.new(vapi_config)
# @todo: Use Cluster::FilterSpec to only get the cluster which was asked
# filter = Com::Vmware::Vcenter::Cluster::FilterSpec.new(clusters: Set.new(['...']))
clusters = cl_obj.list.select { |cluster| cluster.name == name }
raise format("Unable to find Cluster: %s", name) if clusters.empty?
cluster_id = clusters[0].cluster
cl_obj.get(cluster_id)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def __cluster_info\n health = JSON.parse(Net::HTTP.get(URI(\"#{__cluster_url}/_cluster/health\")))\n nodes = if version == '0.90'\n JSON.parse(Net::HTTP.get(URI(\"#{__cluster_url}/_nodes/?process&http\")))\n else\n JSON.parse(Net::HTTP.get(URI(\"#{__cluster_url}/_nodes/process,http\")))\n end\n master = JSON.parse(Net::HTTP.get(URI(\"#{__cluster_url}/_cluster/state\")))['master_node']\n\n result = [\"\\n\",\n ('-'*80).ansi(:faint),\n 'Cluster: '.ljust(20).ansi(:faint) + health['cluster_name'].to_s.ansi(:faint),\n 'Status: '.ljust(20).ansi(:faint) + health['status'].to_s.ansi(:faint),\n 'Nodes: '.ljust(20).ansi(:faint) + health['number_of_nodes'].to_s.ansi(:faint)].join(\"\\n\")\n\n nodes['nodes'].each do |id, info|\n m = id == master ? '*' : '-'\n result << \"\\n\" +\n ''.ljust(20) +\n \"#{m} \".ansi(:faint) +\n \"#{info['name'].ansi(:bold)} \".ansi(:faint) +\n \"| version: #{info['version'] rescue 'N/A'}, \".ansi(:faint) +\n \"pid: #{info['process']['id'] rescue 'N/A'}, \".ansi(:faint) +\n \"address: #{info['http']['bound_address'] rescue 'N/A'}\".ansi(:faint)\n end\n\n result\n end",
"def __print_cluster_info(port)\n health = JSON.parse(Net::HTTP.get(URI(\"http://localhost:#{port}/_cluster/health\")))\n nodes = JSON.parse(Net::HTTP.get(URI(\"http://localhost:#{port}/_nodes/process,http\")))\n master = JSON.parse(Net::HTTP.get(URI(\"http://localhost:#{port}/_cluster/state\")))['master_node']\n\n puts \"\\n\",\n ('-'*80).ansi(:faint),\n 'Cluster: '.ljust(20).ansi(:faint) + health['cluster_name'].to_s.ansi(:faint),\n 'Status: '.ljust(20).ansi(:faint) + health['status'].to_s.ansi(:faint),\n 'Nodes: '.ljust(20).ansi(:faint) + health['number_of_nodes'].to_s.ansi(:faint)\n\n nodes['nodes'].each do |id, info|\n m = id == master ? '+' : '-'\n puts ''.ljust(20) +\n \"#{m} #{info['name'].ansi(:bold)} | version: #{info['version']}, pid: #{info['process']['id']}, address: #{info['http']['bound_address']}\".ansi(:faint)\n end\n end",
"def getClusterInfo\n require 'rest_client'\n require 'uri'\n\n if @role.nil? and !current_actor.superadmin\n json_response({ message: \"You don't have permission to view the clusters in this project\" }, :unauthorized)\n return\n end\n\n # Env variables for Manager host and port\n serviceManagerHost = Settings.service_manager_host\n serviceManagerPort = Settings.service_manager_port.to_s\n serviceManagerURI = 'http://' + serviceManagerHost + ':' + serviceManagerPort + '/v1/swarm'\n\n # Create request for Service Manager\n stack = {\n 'engine-url' => @cluster.endpoint,\n 'ca-cert' => @cluster.ca,\n 'cert' => @cluster.cert,\n 'cert-key' => @cluster.key\n }.to_json\n\n begin\n response = RestClient.post(\n serviceManagerURI,\n stack,\n 'Accept' => 'application/json',\n 'Content-Type' => 'application/json'\n )\n puts \"Deploy Response: \" + response\n json_response(response, 200)\n rescue Exception => e\n # If error, respond with it\n puts e\n json_response({message: e}, :unprocessable_entity)\n end\n end",
"def info\n puts 'All clusters registered to ActiveRecord::ShardFor'\n puts\n clusters.each do |cluster|\n puts \"= Cluster: #{cluster.name} =\"\n cluster.connections.each do |name|\n puts \"- #{name}\"\n end\n puts\n end\n end",
"def info(decrypt = false)\n super(CLUSTER_METHODS[:info], 'CLUSTER', decrypt)\n end",
"def node_cluster_id() ; info[:node_cluster] ; end",
"def cluster() node[:cluster_name] ; end",
"def get_cluster instance_id, cluster_id\n instances.get_cluster name: cluster_path(instance_id, cluster_id)\n end",
"def getClusterMetrics\n @admin.getClusterMetrics\n end",
"def node_cluster\n @node_cluster ||= client.node_clusters.get_from_uri(info[:node_cluster]) unless info[:node_cluster].nil?\n end",
"def listCluster()\n @crosssiteadmin.listClusters()\n end",
"def info()\n super(VIRTUAL_CLUSTER_METHODS[:info], 'VCLUSTER')\n end",
"def cluster_info\n @os_aws.to_os_hash\n end",
"def overview\n data = { :clusters => [], :config => config }\n\n stats.each do |cluster_name, cluster_data|\n # Setting global server attributes ( like hostname, version etc...)\n unless cluster_data.is_a? Hash\n data[cluster_name] = cluster_data\n next\n end\n\n #next unless redis? cluster_name # skip memcached clusters\n\n aliases = node_aliases cluster_name\n cluster = { nodes: [], name: cluster_name }\n cluster_data.each do |node, node_value|\n # Adding node\n if node_value.kind_of? Hash\n node_data = cluster_data[node]\n node = aliases[node] || node\n url = ( node =~ /redis\\:\\/\\// ) ? node : \"redis://#{node}\"\n info = redis_info(url, config[cluster_name][\"redis_auth\"])\n cluster[:nodes] << {\n server_url: url, info: info, running: info.any?\n }.merge(node_data)\n else # Cluster attribute\n cluster[node] = node_value\n end\n end\n data[:clusters].push cluster\n end\n data\n end",
"def name\n @cluster.name\n end",
"def cluster( name )\n\n return ::Module::Cluster.instance_controller( self ).cluster( name )\n \n end",
"def cluster name\n Cluster.receive connection.resource(:get, \"clusters/#{name}\")\n end",
"def cluster()\n @cluster ||= $ip2cluster[@ip]\n @cluster\n end",
"def get_cluster(name)\n cluster_id = get_cluster_id(name)\n\n host_api = VSphereAutomation::VCenter::HostApi.new(api_client)\n raise_if_unauthenticated host_api, \"checking for cluster `#{name}`\"\n\n hosts = host_api.list({ filter_clusters: cluster_id, connection_states: \"CONNECTED\" }).value\n filter_maintenance!(hosts)\n raise_if_missing hosts, format(\"Unable to find active hosts in cluster `%s`\", name)\n\n cluster_api = VSphereAutomation::VCenter::ClusterApi.new(api_client)\n cluster_api.get(cluster_id).value\n end",
"def cluster_config\n Settings.clusters[name]\n end",
"def get_cluster instance_id, cluster_id\n execute do\n instances.get_cluster(\n cluster_path(instance_id, cluster_id)\n )\n end\n end",
"def get_cluster_by_key\n return @cluster_by\n end",
"def nodes\n @cluster.nodes\n end",
"def index\n @clusters = current_account.clusters\n end",
"def stats(params = {})\n response = client.get \"/_cluster/stats\", params.merge(action: \"cluster.stats\", rest_api: \"cluster.stats\")\n response.body\n end",
"def detect_cluster\n initialize_metadata\n result = {\n region: @region,\n instance_id: @instance_id,\n cluster_name: nil,\n cluster_role: nil\n }\n\n find_instance_tags.each do |tag|\n if tag[:key] === CLUSTER_TAG_NAME\n result[:cluster_name] = tag[:value]\n elsif tag[:key] === ROLE_TAG_NAME\n result[:cluster_role] = tag[:value].to_sym\n end\n end\n\n if result[:cluster_name].nil? || result[:cluster_role].nil?\n result[:cluster_name] = nil\n result[:cluster_role] = nil\n end\n\n result\n end",
"def info\n IbmCloudRest.get \"#{@uri}/\"\n end",
"def summary\n \"#<Client cluster=#{cluster.summary}>\"\n end",
"def getClusterFacts(host)\n\n #debugger\n Puppet.debug(\"Hostname = #{host}\")\n\n # Check if connected to a vserver\n vserver = @transport.get_vserver()\n Puppet.debug(\"Current vserver = #{vserver}\")\n\n if vserver.empty?\n Puppet.debug(\"Not connected to a vserver, so gather system facts\")\n\n #Pull out cluster info\n result = @transport.invoke(\"cluster-identity-get\")\n cluster_info = result.child_get(\"attributes\")\n identity_info = cluster_info.child_get(\"cluster-identity-info\")\n cluster_name = identity_info.child_get_string(\"cluster-name\")\n if host.downcase == identity_info.child_get_string(\"cluster-name\")\n system_host = identity_info.child_get_string(\"cluster-name\")\n end\n @facts[\"hostname\"] = system_host\n\n Puppet.debug(\"System info = #{@facts.inspect}\")\n\n # Pull out node system-info\n result = @transport.invoke(\"system-get-node-info-iter\")\n Puppet.debug(\"Result = #{result.inspect}\")\n\n # Pull out attributes-list and itterate\n systems = result.child_get(\"attributes-list\")\n system_host = systems.children_get().find do |system|\n # Check the system name matches the host we're looking for\n Puppet.debug(\"System-name = #{system.child_get_string('system-name')}. downcase = #{system.child_get_string(\"system-name\").downcase}\")\n Puppet.debug(\"Match = #{host.downcase == system.child_get_string(\"system-name\").downcase}\")\n host.downcase == system.child_get_string(\"system-name\").downcase\n end\n\n Puppet.debug(\"Cluster_Name = #{cluster_name}\")\n Puppet.debug(\"Host Name = #{host}\")\n if system_host\n # Pull out the required variables\n [\n 'system-name',\n 'system-id',\n 'system-model',\n 'system-machine-type',\n 'system-serial-number',\n 'partner-system-id',\n 'partner-serial-number',\n 'system-revision',\n 'number-of-processors',\n 'memory-size',\n 'cpu-processor-type',\n 'vendor-id',\n ].each do |key|\n @facts[key] = system_host.child_get_string(\"#{key}\".to_s)\n end\n\n # Facts dump\n Puppet.debug(\"System info = #{@facts.inspect}\")\n elsif cluster_name.downcase != host.downcase\n raise ArgumentError, \"No matching system found with the system name #{host}\"\n end\n\n # Get DNS domainname for fqdn\n #result = @transport.invoke(\"options-get-iter\")\n end\n\n @facts\n end",
"def cluster\n OodAppkit.clusters[cluster_id] || raise(ClusterNotFound, \"Session specifies nonexistent '#{cluster_id}' cluster id.\")\n end",
"def show\n @cluster = Cluster.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cluster }\n end\n end",
"def get_cluster\n if params[:jobcluster] && (OODClusters[params[:jobcluster]] || params[:jobcluster] == 'all')\n params[:jobcluster]\n end\n end",
"def get_cluster_ips\n node_ips get_nodes\nend",
"def show\n @galactic_cluster = GalacticCluster.find(params[:id])\n end",
"def inspect_cluster size_of_cluster\n @cluster.each do |c|\n if c.length == size_of_cluster\n c.each do |s|\n puts \"#{s.to_s}: #{@feature[s].to_s}\"\n end\n end\n end\n end",
"def read_cluster_config_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: NsxComponentAdministrationApi.read_cluster_config ...\"\n end\n # resource path\n local_var_path = \"/cluster\"\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'ClusterConfig')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: NsxComponentAdministrationApi#read_cluster_config\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def __get_cluster_health(port=9250)\n uri = URI(\"http://localhost:#{port}/_cluster/health\")\n if response = Net::HTTP.get(uri) rescue nil\n return JSON.parse(response)\n end\n end",
"def clusterstatus(as_json: false)\n # don't cache it\n status = Utils.solr_request(connection, 'CLUSTERSTATUS')\n if as_json\n status.to_json\n else\n status\n end\n end",
"def info\n response = rpc.request Riakpb::Util::MessageCode::GET_SERVER_INFO_REQUEST\n\n @node = response.node\n @server_version = response.server_version\n\n {:node => @node, :server_version => @server_version}\n end",
"def cloud_desc\n if @config['flavor'] == \"EKS\"\n resp = MU::Cloud::AWS.eks(region: @config['region'], credentials: @config['credentials']).describe_cluster(\n name: @mu_name\n )\n resp.cluster\n else\n resp = MU::Cloud::AWS.ecs(region: @config['region'], credentials: @config['credentials']).describe_clusters(\n clusters: [@mu_name]\n )\n resp.clusters.first\n end\n end",
"def cluster(name = context&.cluster)\n named_cluster(name)&.cluster\n end",
"def cluster_for_host(host)\n cluster_id = host['CLUSTER_ID'].to_i\n\n # host without cluster\n return nil if cluster_id == -1\n\n cluster = OpenNebula::Cluster.new(OpenNebula::Cluster.build_xml(cluster_id), @client)\n rc = cluster.info\n check_retval(rc, Errors::ResourceRetrievalError)\n\n cluster\n end",
"def list_clusters(opts = {})\n @transporter.read(:GET, '/1/clusters', {}, opts)\n end",
"def __get_nodes\n JSON.parse(Net::HTTP.get(URI(\"#{__cluster_url}/_nodes/process\")))\n end",
"def db_cluster_members\n data[:db_cluster_members]\n end",
"def nodetool_info()\n out = `/opt/cassandra/bin/nodetool info`\n if $? == 0\n props = {}\n out.split(\"\\n\").each do |line|\n p = line.split(':')\n props[p.first.strip] = p.last.strip\n end\n return props\n else\n Chef::Log.warn(\"nodetool info failed with #{out}\")\n return nil\n end\n end",
"def cluster_servers\n endpoint.config.nodes.map { |h| \"#{h[:host]}:#{h[:port]}\" }\n end",
"def cluster_nodes\n cluster_nodes_list = []\n @nodes_graph.each do |node_name, node_info|\n cluster_nodes_list << node_name if node_info[:type] == :cluster\n end\n cluster_nodes_list\n end",
"def info\n CouchRest.get \"#{@uri}/\"\n end",
"def cluster\n ElasticSearchHelpers.memoized_cluster\n end",
"def cluster_txt\n File.readlines(File.join(repo_dir, 'cluster.txt'))\n end",
"def fetch_cluster_utilization()\n logger.debug(\"Fetching Memory utilization for Cluster #{self.mob.name}\")\n properties = @client.cloud_searcher.get_properties(mob, Vim::ClusterComputeResource, 'summary')\n raise \"Failed to get utilization for cluster'#{self.mob.name}'\" if properties.nil?\n\n compute_resource_summary = properties[\"summary\"]\n return compute_resource_summary.effective_memory\n end",
"def cluster_list\n super\n end",
"def read_cluster_status(opts = {})\n data, _status_code, _headers = read_cluster_status_with_http_info(opts)\n return data\n end",
"def get_info(jid,node)\n iq = Iq.new(:get,jid)\n iq.from = @stream.jid\n discoinfo = Discovery::IqQueryDiscoInfo.new\n discoinfo.node = node\n iq.add(discoinfo)\n info = {}\n @stream.send_with_id(iq) do |answer|\n identity = answer.query.identity\n info['type'] = identity.type\n info['category'] = identity.category\n info['features'] = answer.query.features\n \n answer.query.each_element('x') { |x|\n info['nodeinformation'] = x\n }\n end\n info\n end",
"def cluster_by\n return @cluster_by\n end",
"def all_clusters\n @clusters ||= redshift.describe_clusters[:clusters].map { |c| c[:cluster_identifier] }\n end",
"def cluster_status\n report_metric 'Cluster Status/Partitioned', 'nodes', rmq_manager.nodes.count { |n| Array(n['partitions']).any? }\n report_metric 'Cluster Status/Stopped', 'nodes', rmq_manager.nodes.count { |n| !n['running'] }\n end",
"def server_info()\n #This is a stub, used for indexing\n end",
"def clusterStatusV6(host_name,port,collection_name,path=\"/solr/admin/zookeeper\",params=\"detail=true&path=/collections/\")\n path = \"#{path}?#{params}\"+\"#{collection_name}/state.json&wt=json\"\n Chef::Log.info(\" HostName = \" + host_name + \", Port = \" + port + \", Path = \" + path)\n http = Net::HTTP.new(host_name, port)\n req = Net::HTTP::Get.new(path)\n unless !SolrAuth::AuthUtils.auth_enabled?\n admin_creds = SolrAuth::AuthUtils.get_solr_admin_credentials\n req.basic_auth(admin_creds['username'], admin_creds['password'])\n end\n response = http.request(req)\n if response != nil then\n return JSON.parse(response.body())\n end\n raise StandardError, \"empty response\"\n end",
"def info\n info = Hash.new\n output = @filer.invoke(\"system-get-info\")\n if(output.results_errno() != 0)\n r = output.results_reason()\n raise \"Failed : \\n\" + r\n else \n output.children_get[0].children_get.each do |naelem|\n info[naelem.name] = naelem.content\n end\n end\n info\n end",
"def api_v11_clusters_get_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: DefaultApi#api_v11_clusters_get ...\"\n end\n \n # resource path\n path = \"/api/v11/clusters\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'view'] = opts[:'view'] if opts[:'view']\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n _header_accept = []\n _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result\n\n # HTTP header 'Content-Type'\n _header_content_type = []\n header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n\n auth_names = []\n data, status_code, headers = @api_client.call_api(:GET, path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DefaultApi#api_v11_clusters_get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def server_info\n {:node => \"riak@#{node.host}\", :server_version => '2.0'}\n end",
"def info\n connection.server_info\n end",
"def get_cluster_id(name)\n return if name.nil?\n\n cluster_api = VSphereAutomation::VCenter::ClusterApi.new(api_client)\n raise_if_unauthenticated cluster_api, \"checking for ID of cluster `#{name}`\"\n\n clusters = cluster_api.list({ filter_names: name }).value\n\n raise_if_missing clusters, format(\"Unable to find Cluster: `%s`\", name)\n raise_if_ambiguous clusters, format(\"`%s` returned too many clusters\", name)\n\n clusters.first.cluster\n end",
"def cluster_create_time\n data[:cluster_create_time]\n end",
"def manage_cluster\n @nodes = Node.find(:all)\n end",
"def cluster_id\n @grpc.name.split(\"/\")[5]\n end",
"def read_cluster_config\n defs_file = open(\"cluster_defs.json\")\n defs_json = defs_file.read\n clust_cfg = JSON.parse(defs_json)\n defs_file.close\n return clust_cfg\nend",
"def info\n container.info\n end",
"def check_cluster\n hostname = \"botha1.cs.ualberta.ca\"\n username = \"prion\"\n keys = ['/apps/phaster/.ssh/botha', '~/.ssh/id_rsa'] # private keys to test (not all the files need to exist)\n\n # Can we connect?\n begin\n ssh = Net::SSH.start(hostname, username, :keys => keys, :auth_methods => ['publickey']) # Only try public key authentication.\n rescue\n #puts \"Unable to connect to #{hostname} using #{username}\"\n return('Unable to connect to the computing cluster! Please contact PHASTER support so the issue can be addressed.')\n end\n\n # Can qsub command be found?\n res = ssh.exec!('which qsub')\n if res =~ /no qsub in/\n return('A problem was detected on the computing cluster! Please contact PHASTER support so the issue can be addressed.')\n end\n\n # Are there any cluster child nodes that are alive?\n res = ssh.exec!('alive')\n c = 0\n res.split(\"\\n\").each { |line|\n c += 1\n }\n #puts \"#{c} child nodes available\"\n if c == 0\n return('A problem was detected on the computing cluster! Please contact PHASTER support so the issue can be addressed.')\n end\n\n ssh.close\n return('')\n end",
"def get_cluster_state(host, port, timeout_sec)\n params = {\n :action => \"CLUSTERSTATUS\"\n }\n cluster_state = nil\n sleep_time_sec = 10\n attempts = timeout_sec/sleep_time_sec\n success = false\n while attempts >= 0 do\n begin\n Chef::Log.info(\"Getting cluster status. Remaining attempts : #{attempts}\")\n attempts = attempts - 1\n cluster_status_resp = solr_collection_api(host, port, params)\n cluster_state = cluster_status_resp[\"cluster\"]\n success = true\n break\n rescue => e\n Chef::Log.info(\"Error while getting cluster status : #{e.message}\")\n Chef::Log.info(\"Retry getting cluster status after #{sleep_time_sec} seconds\")\n sleep sleep_time_sec\n end\n end\n if !success\n error = \"Could not fetch the cluster state in #{timeout_sec} seconds\"\n puts \"***FAULT:FATAL=#{error}\"\n raise error\n end\n return cluster_state\n end",
"def get_cluster request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_get_cluster_request request_pb\n query_string_params = if query_string_params.any?\n query_string_params.to_h { |p| p.split \"=\", 2 }\n else\n {}\n end\n\n response = @client_stub.make_http_request(\n verb,\n uri: uri,\n body: body || \"\",\n params: query_string_params,\n options: options\n )\n operation = ::Gapic::Rest::TransportOperation.new response\n result = ::Google::Cloud::Dataproc::V1::Cluster.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end",
"def info()\n #This is a stub, used for indexing\n end",
"def info\n @info\n end",
"def info\n @info\n end",
"def help_health_data\n\t\t__elasticsearch__.client.cluster.health\n\tend",
"def api_v11_clusters_cluster_name_get_with_http_info(cluster_name, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: DefaultApi#api_v11_clusters_cluster_name_get ...\"\n end\n \n # verify the required parameter 'cluster_name' is set\n fail \"Missing the required parameter 'cluster_name' when calling api_v11_clusters_cluster_name_get\" if cluster_name.nil?\n \n # resource path\n path = \"/api/v11/clusters/{clusterName}\".sub('{format}','json').sub('{' + 'clusterName' + '}', cluster_name.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n _header_accept = []\n _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result\n\n # HTTP header 'Content-Type'\n _header_content_type = []\n header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n\n auth_names = []\n data, status_code, headers = @api_client.call_api(:GET, path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DefaultApi#api_v11_clusters_cluster_name_get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def cluster_stats(url, time)\n\n logger.info \"cluster_stats:start: url = #{url}, time = #{time.to_i}\"\n\n jsonResponse = rest_call(url)\n response_hash = JSON.parse(jsonResponse)\n #puts response_hash\n node_count = response_hash['nodes'].count\n nodes = response_hash['nodes']\n\n #puts \"Total number of nodes in the cluster = #{node_count.to_s}\"\n\n #rebalance status in the cluster\n rebalanceStatus = response_hash['rebalanceStatus']\n rebalance = rebalanceStatus.eql?('none') ? 0 : 1\n\n #ram metrics in the cluster\n ram_total = response_hash['storageTotals']['ram']['total']\n ram_quota_total = response_hash['storageTotals']['ram']['quotaTotal']\n ram_quota_used = response_hash['storageTotals']['ram']['quotaUsed']\n ram_used = response_hash['storageTotals']['ram']['used']\n ram_used_by_data = response_hash['storageTotals']['ram']['usedByData']\n ram_quota_used_per_node = response_hash['storageTotals']['ram']['quotaUsedPerNode']\n ram_quota_total_per_node = response_hash['storageTotals']['ram']['quotaTotalPerNode']\n\n #cluster RAM level stats\n write_to_graphite( construct_metric_name('rebalance', CONST_CLUSTER_LEVEL), rebalance, time)\n write_to_graphite( construct_metric_name('ram_total', CONST_CLUSTER_LEVEL), ram_total.to_s, time)\n write_to_graphite( construct_metric_name('ram_quota_total', CONST_CLUSTER_LEVEL), ram_quota_total.to_s, time)\n write_to_graphite( construct_metric_name('ram_quota_used', CONST_CLUSTER_LEVEL), ram_quota_used.to_s, time)\n write_to_graphite( construct_metric_name('ram_used', CONST_CLUSTER_LEVEL), ram_used.to_s, time)\n write_to_graphite( construct_metric_name('ram_used_by_data', CONST_CLUSTER_LEVEL), ram_used_by_data.to_s, time)\n write_to_graphite( construct_metric_name('ram_quota_used_per_node', CONST_CLUSTER_LEVEL), ram_quota_used_per_node.to_s, time)\n write_to_graphite( construct_metric_name('ram_quota_total_per_node', CONST_CLUSTER_LEVEL), ram_quota_total_per_node.to_s, time)\n\n #HDD metrics in the cluster\n hdd_total = response_hash['storageTotals']['hdd']['total']\n hdd_quota_total = response_hash['storageTotals']['hdd']['quotaTotal']\n hdd_used = response_hash['storageTotals']['hdd']['used']\n hdd_used_by_data = response_hash['storageTotals']['hdd']['usedByData']\n hdd_free = response_hash['storageTotals']['hdd']['free']\n\n #cluster HDD level stats\n write_to_graphite( construct_metric_name('hdd_total', CONST_CLUSTER_LEVEL), hdd_total.to_s, time)\n write_to_graphite( construct_metric_name('hdd_quota_total', CONST_CLUSTER_LEVEL), hdd_quota_total.to_s, time)\n write_to_graphite( construct_metric_name('hdd_used', CONST_CLUSTER_LEVEL), hdd_used.to_s, time)\n write_to_graphite( construct_metric_name('hdd_used_by_data', CONST_CLUSTER_LEVEL), hdd_used_by_data.to_s, time)\n write_to_graphite( construct_metric_name('hdd_free', CONST_CLUSTER_LEVEL), hdd_free.to_s, time)\n\n nodes.each do |node|\n\n #systemStats\n swap_total = node['systemStats']['swap_total']\n swap_used = node['systemStats']['swap_used']\n mem_total = node['systemStats']['mem_total']\n mem_free = node['systemStats']['mem_free']\n\n #interestingStats\n cmd_get = node['interestingStats']['cmd_get']\n couch_docs_actual_disk_size = node['interestingStats']['couch_docs_actual_disk_size']\n couch_docs_data_size = node['interestingStats']['couch_docs_data_size']\n curr_items = node['interestingStats']['curr_items']\n curr_items_tot = node['interestingStats']['curr_items_tot']\n ep_bg_fetched = node['interestingStats']['ep_bg_fetched']\n get_hits = node['interestingStats']['get_hits']\n mem_used = node['interestingStats']['mem_used']\n ops = node['interestingStats']['ops']\n vb_replica_curr_items = node['interestingStats']['vb_replica_curr_items']\n\n clusterMembership = node['clusterMembership']\n status = node['status']\n otpNode = node['otpNode']\n otpNode = otpNode.gsub('.','-')\n\n\n if (status =='healthy' && clusterMembership == 'active' )\n @healthy_nodes += 1\n end\n\n if (clusterMembership == 'inactiveFailed' )\n @failover_nodes += 1\n end\n\n #node level systemStats\n write_to_graphite( construct_metric_name(\"#{otpNode}.swap_total\", CONST_NODE_LEVEL), swap_total.to_s, time)\n write_to_graphite( construct_metric_name(\"#{otpNode}.swap_used\", CONST_NODE_LEVEL), swap_used.to_s, time)\n write_to_graphite( construct_metric_name(\"#{otpNode}.mem_total\", CONST_NODE_LEVEL), mem_total.to_s, time)\n write_to_graphite( construct_metric_name(\"#{otpNode}.mem_free\", CONST_NODE_LEVEL), mem_free.to_s, time)\n\n\n #node level interestingStats\n write_to_graphite( construct_metric_name(\"#{otpNode}.cmd_get\", CONST_NODE_LEVEL), cmd_get, time)\n write_to_graphite( construct_metric_name(\"#{otpNode}.couch_docs_actual_disk_size\", CONST_NODE_LEVEL), couch_docs_actual_disk_size, time)\n write_to_graphite( construct_metric_name(\"#{otpNode}.couch_docs_data_size\", CONST_NODE_LEVEL), couch_docs_data_size, time)\n write_to_graphite( construct_metric_name(\"#{otpNode}.curr_items\", CONST_NODE_LEVEL), curr_items)\n write_to_graphite( construct_metric_name(\"#{otpNode}.curr_items_tot\", CONST_NODE_LEVEL), curr_items_tot, time)\n write_to_graphite( construct_metric_name(\"#{otpNode}.ep_bg_fetched\", CONST_NODE_LEVEL), ep_bg_fetched, time)\n write_to_graphite( construct_metric_name(\"#{otpNode}.get_hits\", CONST_NODE_LEVEL), get_hits, time)\n write_to_graphite( construct_metric_name(\"#{otpNode}.mem_used\", CONST_NODE_LEVEL), mem_used, time)\n write_to_graphite( construct_metric_name(\"#{otpNode}.ops\", CONST_NODE_LEVEL), ops, time)\n write_to_graphite( construct_metric_name(\"#{otpNode}.vb_replica_curr_items\", CONST_NODE_LEVEL), vb_replica_curr_items, time)\n\n end\n\n\n healthy = nodes.length == @healthy_nodes ? 1 : 0\n write_to_graphite( construct_metric_name('healthy_node_num', CONST_CLUSTER_LEVEL), @healthy_nodes.to_s, time)\n write_to_graphite( construct_metric_name('node_num', CONST_CLUSTER_LEVEL), nodes.length.to_s, time)\n write_to_graphite( construct_metric_name('healthy', CONST_CLUSTER_LEVEL), healthy.to_s, time)\n\n logger.info 'cluster_stats:end: Completed'\n end",
"def get_node_details(name_list)\n rpc_get_facts_direct(name_list)\n end",
"def meta\n data,stat = @zk.get(:path => ZK::Config::ServicePath + \"/#{@service_name}/#{@name}\")\n stat\n end",
"def read_host_info\n json { execute_prlctl('server', 'info', '--json') }\n end",
"def node_names\n @cluster.nodes.map(&:name)\n end",
"def cluster_by_value\n return @cluster_by_value\n end",
"def measure_cluster_status cluster_name, private_ip\n begin\n connection = Net::HTTP.new(private_ip, 8080) # FIXME port\n request = Net::HTTP::Get.new('/status/cluster', 'Accept' => 'text/xml')\n response = connection.request(request)\n return false unless response.code.to_i == 200\n \n data = Crack::XML.parse(response.body)\n cluster_status = data['ClusterStatus']\n dead_nodes = cluster_status['DeadNodes'] ? cluster_status['DeadNodes']['Node'] : []\n live_nodes = cluster_status['LiveNodes']['Node']\n rescue NoMethodError, SocketError, REXML::ParseException, Errno::ECONNREFUSED => e\n # puts \"#{e.class} -- #{e.message}\"\n # puts e.backtrace\n return false\n end\n\n write({\n :hostname => \"#{cluster_name}-hbase\",\n :hostgroup => self.class::CLUSTER_HOSTGROUPS,\n :application => self.class::CLUSTER_APPLICATIONS,\n :templates => self.class::CLUSTER_TEMPLATES\n }) do |d|\n d << ['requests', cluster_status['requests']]\n d << ['regions', cluster_status['regions']]\n d << ['load', cluster_status['averageLoad']]\n d << ['nodes.dead', dead_nodes.size]\n d << ['nodes.alive', live_nodes.size]\n end\n measure_cluster_tables(cluster_name, data)\n measure_cluster_nodes(cluster_name, live_nodes)\n true\n end",
"def info\n return @info\n end",
"def read_cluster_status_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: NsxComponentAdministrationApi.read_cluster_status ...\"\n end\n if @api_client.config.client_side_validation && opts[:'source'] && !['realtime', 'cached'].include?(opts[:'source'])\n fail ArgumentError, 'invalid value for \"source\", must be one of realtime, cached'\n end\n # resource path\n local_var_path = \"/cluster/status\"\n\n # query parameters\n query_params = {}\n query_params[:'source'] = opts[:'source'] if !opts[:'source'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'ClusterStatus')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: NsxComponentAdministrationApi#read_cluster_status\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def __get_cluster_health(status=nil)\n uri = URI(\"#{__cluster_url}/_cluster/health\")\n uri.query = \"wait_for_status=#{status}\" if status\n\n begin\n response = Net::HTTP.get(uri)\n rescue Exception => e\n STDERR.puts e.inspect if ENV['DEBUG']\n return nil\n end\n\n JSON.parse(response)\n end",
"def read_cluster_boot_manager_service_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: NsxComponentAdministrationApi.read_cluster_boot_manager_service ...\"\n end\n # resource path\n local_var_path = \"/node/services/cluster_manager\"\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'NodeServiceProperties')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: NsxComponentAdministrationApi#read_cluster_boot_manager_service\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def gather_zk_ips(cluster)\n zk_ips = ''\n cluster['masters'].each_with_index do |master, i|\n if master['run'].include? 'zookeeper'\n if zk_ips != ''\n zk_ips = zk_ips + \",\"\n end\n zk_ips = zk_ips + cluster['master_ipbase']+\"#{10+i}\"\n end\n end\n return zk_ips\nend",
"def show\n @topiccluster = Topiccluster.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @topiccluster }\n end\n end",
"def measure_cluster_health cluster_name, private_ip\n begin\n cluster_health = JSON.parse(open(es_url(private_ip, '_cluster', 'health')).read)\n rescue SocketError, OpenURI::HTTPError, JSON::ParserError, Errno::ECONNREFUSED => e\n # This node may not be running a webnode...\n return false\n end\n write({\n :hostname => \"#{cluster_name}-elasticsearch\",\n :hostgroup => self.class::CLUSTER_HOSTGROUPS,\n :templates => self.class::CLUSTER_TEMPLATES,\n :application => self.class::CLUSTER_APPLICATIONS\n }) do |d|\n d << ['status', cluster_health['status'] ]\n d << ['nodes.total', cluster_health['number_of_nodes'] ]\n d << ['nodes.data', cluster_health['number_of_data_nodes'] ]\n d << ['shards.active', cluster_health['active_shards'] ]\n d << ['shards.relocating', cluster_health['relocating_shards'] ]\n d << ['shards.unassigned', cluster_health['unassigned_shards'] ]\n d << ['shards.initializing', cluster_health['initializing_shards'] ]\n end\n true\n end",
"def getinfo\n coind.getinfo\n end",
"def info\n request('getinfo')\n end",
"def info\n @info ||= {}\n end",
"def inspect\n \"#<Mongo::Client:0x#{object_id} cluster=#{cluster.summary}>\"\n end",
"def read_cluster_config\n if ENV['VAGRANT_CWD'] then\n folder = ENV['VAGRANT_CWD'] + \"/cluster_defs.json\"\n defs_file = open(folder)\n else\n defs_file = open(\"cluster_defs.json\")\n end\n defs_json = defs_file.read\n clust_cfg = JSON.parse(defs_json)\n defs_file.close\n return clust_cfg\nend",
"def cluster_id(cluster)\n id = cluster.getId\n return 'unclusterable' if id == -1\n return 'ignorable' if id == -2\n\n id\nend",
"def info &block\n em_get( \"/clients/#{uuid}\" ) { |response| block.call( response ) }\n end",
"def get_info\n end"
] |
[
"0.85554856",
"0.78559995",
"0.77614355",
"0.75723714",
"0.75172704",
"0.739303",
"0.73542136",
"0.70964354",
"0.7090487",
"0.7062964",
"0.70492405",
"0.70368177",
"0.7015252",
"0.70037967",
"0.69502634",
"0.6947804",
"0.693547",
"0.6921948",
"0.6805798",
"0.6773381",
"0.67532456",
"0.6733084",
"0.66734207",
"0.6649905",
"0.6644343",
"0.66321355",
"0.66195416",
"0.65521574",
"0.6550856",
"0.6529313",
"0.6528641",
"0.6518775",
"0.6513877",
"0.64976543",
"0.6495098",
"0.644775",
"0.64391863",
"0.6435995",
"0.64300394",
"0.6422125",
"0.64201003",
"0.63937706",
"0.63860583",
"0.63645595",
"0.63528603",
"0.6299086",
"0.6263848",
"0.6263367",
"0.62209195",
"0.62092304",
"0.616942",
"0.6162866",
"0.6161904",
"0.61375535",
"0.6131651",
"0.61201555",
"0.61041844",
"0.6102587",
"0.608035",
"0.60722375",
"0.6065636",
"0.6061222",
"0.6053701",
"0.60377127",
"0.60294706",
"0.6007991",
"0.6001707",
"0.60004246",
"0.59991235",
"0.59953487",
"0.5992199",
"0.599099",
"0.59898394",
"0.5984783",
"0.59846157",
"0.5982369",
"0.5975841",
"0.5964268",
"0.59641194",
"0.5956906",
"0.5955112",
"0.59489673",
"0.5944971",
"0.5935533",
"0.59154004",
"0.59069264",
"0.59006894",
"0.58787876",
"0.58701247",
"0.5866888",
"0.5858817",
"0.5844884",
"0.58441633",
"0.58314806",
"0.58238393",
"0.5822321",
"0.58211464",
"0.581316",
"0.581267",
"0.5802616"
] |
0.67662495
|
20
|
Gets the name of the resource pool
|
def get_resource_pool(name)
# Create a resource pool object
rp_obj = Com::Vmware::Vcenter::ResourcePool.new(vapi_config)
# If no name has been set, use the first resource pool that can be found,
# otherwise try to find by given name
if name.nil?
# Remove default pool for first pass (<= 1.2.1 behaviour to pick first user-defined pool found)
resource_pool = rp_obj.list.delete_if { |pool| pool.name == "Resources" }
debug("Search of all resource pools found: " + resource_pool.map { |pool| pool.name }.to_s)
# Revert to default pool, if no user-defined pool found (> 1.2.1 behaviour)
# (This one might not be found under some circumstances by the statement above)
return get_resource_pool("Resources") if resource_pool.empty?
else
# create a filter to find the named resource pool
filter = Com::Vmware::Vcenter::ResourcePool::FilterSpec.new(names: Set.new([name]))
resource_pool = rp_obj.list(filter)
debug("Search for resource pools found: " + resource_pool.map { |pool| pool.name }.to_s)
end
raise format("Unable to find Resource Pool: %s", name) if resource_pool.empty?
resource_pool[0].resource_pool
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def resource_pool(name)\n @manifest[\"resource_pools\"].find { |res| res[\"name\"] == name }\n end",
"def pool_name()\n #This is a stub, used for indexing\n end",
"def name\n 'pooler'\n end",
"def resource_name\n @resource_name ||= get_resource_name\n end",
"def resource_name\n return @resource_name\n end",
"def resource_name\n return @resource_name\n end",
"def resource_name\n return @resource_name\n end",
"def get_resource_name\n\t\t@name + '_' + @hot.resources_list.length.to_s unless @name.empty?\n\tend",
"def default_pool_name\n super\n end",
"def name\n @resource.name\n end",
"def get_resource_pool(name)\n # Create a resource pool object\n rp_api = VSphereAutomation::VCenter::ResourcePoolApi.new(api_client)\n raise_if_unauthenticated rp_api, \"checking for resource pool `#{name || \"(default)\"}`\"\n\n # If no name has been set, use the first resource pool that can be found,\n # otherwise try to find by given name\n if name.nil?\n # Unpredictable results can occur, if neither cluster nor resource_pool are specified,\n # as this relies on the order in which VMware saves the objects. This does not have large\n # impact on small environments, but on large deployments with lots of clusters and pools,\n # provisioned machines are likely to \"jump around\" available hosts.\n #\n # This behavior is carried on from versions 1.2.1 and lower, but likely to be removed in\n # a new major version due to these insufficiencies and the confusing code for it\n\n # Remove default pool for first pass (<= 1.2.1 behavior to pick first user-defined pool found)\n resource_pools = rp_api.list.value.delete_if { |pool| pool.name == \"Resources\" }\n debug(\"Search of all resource pools found: \" + resource_pools.map(&:name).to_s)\n\n # Revert to default pool, if no user-defined pool found (> 1.2.1 behavior)\n # (This one might not be found under some circumstances by the statement above)\n return get_resource_pool(\"Resources\") if resource_pools.empty?\n else\n resource_pools = rp_api.list({ filter_names: name }).value\n debug(\"Search for resource pools found: \" + resource_pools.map(&:name).to_s)\n end\n\n raise_if_missing resource_pools, format(\"Unable to find resource pool `%s`\", name || \"(default)\")\n\n resource_pools.first.resource_pool\n end",
"def connection_pool_name # :nodoc:\n replica = current_replica_name\n if replica\n \"#{name}_#{replica}\"\n elsif self == ActiveRecord::Base\n name\n else\n superclass.connection_pool_name\n end\n end",
"def resource_name\n \"#{self.class.to_s.split(\"::\").last.downcase}s\"\n end",
"def resource_name\n resource_class.resource_name\n end",
"def get_pool_names\n JSON.parse(get(\"http://#{@host}/loadbalancers/tenant/#{@tenant}/pools\"))['tenantpools']['pools']\n end",
"def get_pool_names\n (JSON.parse(get(url: \"https://#{@host}/mgmt/tm/ltm/pool\"))['items'] || []).map {|item| item['name']}\n end",
"def get_pool_names\n (JSON.parse(get(url: \"https://#{@host}/mgmt/tm/ltm/pool\"))['items'] || []).map {|item| item['name']}\n end",
"def resource_name\n @resource_name ||= plural_name\n end",
"def resources_name\n self.class.resources_name\n end",
"def resources_name\n @resources_name ||= resource_specification.name.pluralize\n end",
"def resource_name\n @resource_name ||= self.class.to_s.underscore.gsub(%r{.*/([^/]+)\\z}, '\\1')\n end",
"def resource_name\n resource_specification.name\n end",
"def resource_name\n @resource_name ||= singular_resource_name.pluralize\n end",
"def name\n FFI::Libvirt.virStoragePoolGetName(self)\n end",
"def resource_name\n resource_class.slice(0,1).downcase + resource_class.slice(1,resource_class.length)\n end",
"def resource_name\n @resource_name ||= model_name.element.pluralize\n end",
"def resource_name name=nil\n if name\n @resource_name = name\n end\n @resource_name || default_resource_name\n end",
"def resource_name\n current_definition.resource_name\n end",
"def resource_name\n resource_module.to_s.demodulize\n end",
"def resource_name\n resource[:name].gsub(/\\s/, '_').downcase.singularize\n end",
"def resource_name\n @resource_name ||= plural_resource_name.singularize\n end",
"def resource_name\n name.ns_underscore.pluralize\n end",
"def get_pool_type\n pool_type ? pool_type.i18n_short : '?'\n end",
"def description\n storage_hash = get_api_node(['storage-pools', resource[:name]])\n desc = storage_hash['description']\n return desc\n end",
"def resource_collection_name #:nodoc:\n self.resources_configuration[:self][:collection_name]\n end",
"def resource_instance_name #:nodoc:\n self.resources_configuration[:self][:instance_name]\n end",
"def get_system_pool\n get(\"cloud-instances/#{guid}/system-pools\")\n end",
"def resource_name\n @resource_name ||= Inflection.plural(singular_resource_name)\n end",
"def storage_pool_id(sys_id, name)\n response = request(:get, \"/devmgr/v2/storage-systems/#{sys_id}/storage-pools\")\n status(response, 200, 'Failed to get pool id')\n storage_pools = JSON.parse(response.body)\n storage_pools.each do |pool|\n return pool['id'] if pool['label'] == name\n end\n nil\n end",
"def storage_pool_id(sys_id, name)\n response = request(:get, \"/devmgr/v2/storage-systems/#{sys_id}/storage-pools\")\n status(response, 200, 'Failed to get pool id')\n storage_pools = JSON.parse(response.body)\n storage_pools.each do |pool|\n return pool['id'] if pool['label'] == name\n end\n nil\n end",
"def get_pool_names(corpus = false)\n pool_name_array = []\n self.pools.each do |pool_name, pool|\n\tunless corpus == false && pool_name == '__Corpus__'\n\t pool_name_array.push(pool_name)\n\tend\n end\n return pool_name_array\n end",
"def pool\n @pool=@vserver_hash.properties.basic.pool\n end",
"def root_resource_name\n components.keys.first.to_s\n end",
"def resource_label\n resource_name.translate count: 1,\n default: resource_name.to_s.gsub(\"::\", \" \").titleize\n end",
"def resource_name\n @resource_name\n end",
"def get_linked_swimming_pool( name_method = :get_verbose_name )\n object.get_swimming_pool ? object.get_swimming_pool.decorate.get_linked_name( name_method ) : '?'\n end",
"def get_linked_swimming_pool( name_method = :get_verbose_name )\n object.get_swimming_pool ? object.get_swimming_pool.decorate.get_linked_name( name_method ) : '?'\n end",
"def pool_config(pool_name)\n # Get the configuration of a specific pool\n @config[:pools].each do |pool|\n return pool if pool['name'] == pool_name\n end\n\n nil\n end",
"def resource_name\n @resource_name ||= controller_name.singularize\n end",
"def resource_name\n @resource_name ||= controller_name.singularize\n end",
"def get_pool_type\n self.pool_type ? self.pool_type.i18n_short : '?'\n end",
"def resource_name\n resource.name.singularize.underscore\n end",
"def resource_name\n resources_name.singularize\n end",
"def resource_name\n @resource_name ||= self.controller_name.singularize\n end",
"def resource_name\n @resource_name ||= self.controller_name.singularize\n end",
"def get_pool_names\n pool_names = []\n Dir.entries(@confdir).each do |entry|\n pool_names.push $1 if entry =~ @pool_fname_regex\n end\n pool_names\n end",
"def resource_name\n\t\t\t\t@resource_name ||= self.controller_name.singularize\n\t\t\tend",
"def pool\n @pool\n end",
"def enclosing_resource_name\n enclosing_resource.class.name.underscore\n end",
"def resource_name\n @resource_name ||= self.controller_name.singularize\n end",
"def resource_name\n @resource_name ||= self.controller_name.singularize\n end",
"def service_name\n resource[:name]\n end",
"def provided_pools\n @config[:pools].select { |pool| pool['dns_config'] == name }.map { |pool| pool['name'] }\n end",
"def resource_item_name\n resource_name.to_s.singularize.to_sym\n end",
"def name\n @name ||= new_resource.name[-1] == '.' ? new_resource.name : \"#{new_resource.name}.\"\n end",
"def resource_item_name\n current_definition.resource_item_name\n end",
"def resource_name\n @@resource_name ||= self.class.to_s.split('::').last.gsub('Controller', '').singularize.underscore\n end",
"def qualified_resource_name\n @qualified_resource_name ||=\n begin\n @resource_class.name.split('::').map do |str|\n tools.string.underscore(str)\n end.join('-')\n end # name\n end",
"def name\n\t\t\traise \"Resource#name must be overriden!\"\n\t\tend",
"def current_pool_size(pool_name)\n pool(pool_name).count\n end",
"def resource_name\n @resource_name ||= self.controller_name.singularize\n end",
"def resource_name\n self.class.name.ns_underscore.pluralize\n end",
"def resource_name\n @resource_name ||= controller_name.singularize\n end",
"def variable_name(resource)\n name = controller.instance_variables.index { |var| controller.instance_variable_get(var) === resources.first }\n name = controller.instance_variables[name].to_s.gsub(/@/, '') if name\n name.to_s\n end",
"def resource_name(seed=random_string(5))\n 'cli_' << HOSTNAME << '_' << Time.now.to_i.to_s << '_' << seed.to_s\n end",
"def name\n @name ||= (@config[:name] || self.class.name.split(/::/).last.titleize)\n end",
"def pool(session)\n read_task('rvpe.host.pool', session) do\n call_one_xmlrpc('one.hostpool.info', session)\n end\n end",
"def resource_name=(value)\n @resource_name = value\n end",
"def resource_name=(value)\n @resource_name = value\n end",
"def resource_name=(value)\n @resource_name = value\n end",
"def name\n @queue.queue_name\n end",
"def resource\n self.class.to_s.split('::').last.downcase\n end",
"def pool \n @pool\n end",
"def resource_class_name\n @resource_class_name ||= resource_name.classify.constantize\n end",
"def name\n name = \"Cess Pool\"\n end",
"def name\n return @name unless @name.nil?\n if ofs_name != 65535\n io = _root.resource_map.names_with_io._io\n _pos = io.pos\n io.seek(ofs_name)\n @name = Name.new(io, self, @_root)\n io.seek(_pos)\n end\n @name\n end",
"def name\n @name ||= self.class.non_namespaced_name\n end",
"def name\n @name ||= [action, resource.name, resource.type].compact.map(&:to_s).join('_').underscore\n end",
"def parent_resource_name\n command_has_resources ? resources.last : ''\n end",
"def name\n return @name unless @name.nil?\n \"#{@name_prefix}host:#{Socket.gethostname} pid:#{Process.pid}\" rescue \"#{@name_prefix}pid:#{Process.pid}\"\n end",
"def resource_template(name)\n \"#{resource}_#{name}\"\n end",
"def driver\n storage_hash = get_api_node(['storage-pools', resource[:name]])\n driver = storage_hash['driver']\n return driver\n end",
"def resource_item_name\n resource_name.to_s.singularize.to_sym\n end",
"def resource_name(resource)\n resource.xpath('string(command//tstring_content/@value)')\n end",
"def resource_name(resource)\n resource.xpath('string(command//tstring_content/@value)')\n end",
"def resource_name\n @resource_name ||= self.controller_name.singularize\n end",
"def resource_name\n @resource_name ||= self.controller_name.singularize\n end",
"def resource_name\n @resource_name ||= self.controller_name.singularize\n end",
"def resource_class\n (self.class.name.split('::').last || '').downcase\n end",
"def resource_base_uri\n @resource ||= \"#{Hyperloop::Resource::ClientDrivers.opts[:resource_api_base_path]}/#{self.to_s.underscore.pluralize}\"\n end"
] |
[
"0.7984184",
"0.791868",
"0.71183026",
"0.70955676",
"0.6997517",
"0.6997517",
"0.6997517",
"0.6932114",
"0.6919304",
"0.6879321",
"0.6873212",
"0.6858333",
"0.67995685",
"0.6781424",
"0.6704315",
"0.6655591",
"0.6655591",
"0.66438574",
"0.661397",
"0.6602401",
"0.65832496",
"0.65709513",
"0.65650666",
"0.6526676",
"0.6509633",
"0.6478579",
"0.6472193",
"0.64696324",
"0.64693546",
"0.6456742",
"0.6407579",
"0.6403807",
"0.63830245",
"0.6368449",
"0.63664263",
"0.6364963",
"0.6356859",
"0.63364416",
"0.6327051",
"0.6327051",
"0.6303312",
"0.6283055",
"0.6274976",
"0.62720233",
"0.62644434",
"0.62613225",
"0.62613225",
"0.62548417",
"0.62538904",
"0.62538904",
"0.62237805",
"0.61908495",
"0.6155138",
"0.6154683",
"0.6154683",
"0.61529183",
"0.6146103",
"0.61429006",
"0.61198974",
"0.6117637",
"0.6117637",
"0.61107194",
"0.6109553",
"0.60995466",
"0.60971034",
"0.6091537",
"0.6081777",
"0.6073157",
"0.6067519",
"0.6065239",
"0.60591537",
"0.6053225",
"0.60326296",
"0.6024928",
"0.59913236",
"0.5970602",
"0.59685576",
"0.59683925",
"0.59683925",
"0.59683925",
"0.59645367",
"0.59576285",
"0.59480304",
"0.5932164",
"0.5931608",
"0.5930921",
"0.5924445",
"0.5924264",
"0.59235626",
"0.59108055",
"0.59081423",
"0.5889739",
"0.5889083",
"0.58824223",
"0.58824223",
"0.5878586",
"0.5878586",
"0.5878586",
"0.5861041",
"0.5857634"
] |
0.65813
|
21
|
Get location of lookup service
|
def lookup_service_host
# Allow manual overrides
return config[:lookup_service_host] unless config[:lookup_service_host].nil?
# Retrieve SSO service via RbVmomi, which is always co-located with the Lookup Service.
vim = RbVmomi::VIM.connect @connection_options
vim_settings = vim.serviceContent.setting.setting
sso_url = vim_settings.select { |o| o.key == "config.vpxd.sso.sts.uri" }&.first&.value
# Configuration fallback, if no SSO URL found for some reason
ls_host = sso_url.nil? ? config[:vcenter_host] : URI.parse(sso_url).host
debug("Using Lookup Service at: " + ls_host)
ls_host
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def get_location(location)\n client = Weatherman::Client.new\n client.lookup_by_location(location)\nend",
"def location\n fetch('doraemon.locations')\n end",
"def location\n fetch('hey_arnold.locations')\n end",
"def get_location(user_location)\n\tclient=Weatherman::Client.new\n\tclient.lookup_by_location(user_location)\nend",
"def locationLookup(currLoc) \n client = Weatherman::Client.new\n client.lookup_by_location(currLoc)\nend",
"def get_location\n\n end",
"def location\n fetch('harry_potter.locations')\n end",
"def location\n @client.get(\"#{path}/location\")\n end",
"def lookup_business_location\n BusinessLocator.new(self).lookup\n end",
"def locate(address)\n get :location => address\n end",
"def location\n fetch('simpsons.locations')\n end",
"def locate\n @result ||= self.class.get(\n \"/\",\n :query => {:ip => @ip},\n :format => :xml\n )['HostipLookupResultSet']['gml:featureMember']\n end",
"def getDeviceLocation(opts={}) \n req_accuracy = (opts[:req_accuracy] || 100)\n accept_accuracy = (opts[:accept_accuracy] || 10_000)\n tolerance = (opts[:tolerance] || Tolerance::LOW)\n url = \"#{@fqdn}#{SERVICE_URL}\"\n\n url << \"?requestedAccuracy=#{req_accuracy}\"\n url << \"&acceptableAccuracy=#{accept_accuracy}\"\n url << \"&tolerance=#{tolerance}\"\n\n begin\n response = self.get(url)\n rescue RestClient::Exception => e\n raise(ServiceException, e.response || e.message, e.backtrace)\n end\n Model::TLResponse.createFromJson(response)\n end",
"def lookup(name)\n loc = nil # TODO: Periodic refresh of location database table\n=begin\n loc = IlsLocationList.lookup(name)\n=end\n return loc.name, loc.code if loc.present?\n end",
"def lookup_ip_location\n if Rails.env.development? || Rails.env.test?\n Geocoder.search(request.remote_ip).first\n else\n request.location\n end\n end",
"def location\n fetch('games.super_mario.locations')\n end",
"def get_location(id)\n response = perform(:get, \"Location/#{id}\", nil, headers)\n raise Common::Exceptions::BackendServiceException, 'LIGHTHOUSE_FACILITIES404' if response[:status] == 404\n\n response.body\n end",
"def get_location(zip)\n location = Weatherman::Client.new(:unit =>'f')\n location.lookup_by_location(zip)\nend",
"def location\n fetch('rick_and_morty.locations')\n end",
"def locate(address)\n get :geo, :q => address\n end",
"def location\n fetch('sword_art_online.location')\n end",
"def location\n # If \"addresses\" was eager loaded; then search for the \"location\" address. Otherwise\n # do a scoped find.\n if addresses.length > 0\n addresses.select {|a| a.label == \"location\"}[0]\n else\n addresses[:location]\n end\n end",
"def location\n @location ||= TermuxRubyApi::SubSystems::Location.new(self)\n end",
"def location_path\n @grpc.location\n end",
"def location\n fetch('how_to_train_your_dragon.locations')\n end",
"def locate(place)\n locations, = get :q => place\n return locations.first\n end",
"def location\n fetch('games.league_of_legends.location')\n end",
"def get_location\n as_json(get_results('/locations.json'))\n end",
"def getLocation\n loc = Addressable::URI.new(\n :scheme => \"https\",\n :host => \"maps.googleapis.com\",\n :path => \"maps/api/geocode/json\",\n :query_values => {:address => \"160+Folsom,+San+Francisco,+CA\",\n :sensor => \"false\"}).to_s\n\n location_request = RestClient.get(loc)\n parsed_location_request = JSON.parse(location_request)\n\n lat = parsed_location_request[\"results\"][0][\"geometry\"][\"location\"][\"lat\"].to_s\n lng = parsed_location_request[\"results\"][0][\"geometry\"][\"location\"][\"lng\"].to_s\n\n [lat,lng]\nend",
"def location\n result_hash['loc']\n end",
"def location\n response[\"location\"]\n end",
"def pickup_location_name(code)\n if Settings.ils.client == 'FolioClient'\n Folio::ServicePoint.name_by_code(code) || code\n else\n Mylibrary::Application.config.library_map[code] || code\n end\n end",
"def locate(location)\n get :q => location.is_a?(String) ? location : location_from_params(location).to_s, :output => 'locations'\n end",
"def get_location(ip)\n\t\t\tresponse_data = LocationApi.new.call(ip)\n\t\t\tLocationJsonParser.new.parse(response_data)\n\t\tend",
"def location\n fetch('books.the_kingkiller_chronicle.locations')\n end",
"def my_location\n freegeoip.get '/json/'\nend",
"def locate_by_ip\n request.location\n end",
"def location\n @gapi[\"location\"]\n end",
"def location\n ensure_full_data!\n @gapi[\"location\"]\n end",
"def find_local(query, options={})\n query = encode_query(query)\n options.merge!(:q => query)\n\n response = self.class.get(\"/local\", :query => options)\n locations(response)\n end",
"def location\r\n infoxml = get_info\r\n return infoxml.at('location').inner_text\r\n end",
"def thing_lookup(url)\n lookup = get(\"/rest/v2/things/lookup\", {:url => url})\n if lookup[\"location\"]\n thing = get(lookup['location'])\n Flattr::Thing.new(thing)\n else\n nil\n end\n end",
"def location(id, options = {})\n get \"locations/#{id}\", options\n end",
"def location\n @grpc.location.split(\"/\")[3]\n end",
"def location\n peer.get_location\n end",
"def location\n # and call a private getter method within\n puts \"I live on #{address.split[1]} street.\"\n end",
"def determine_weather(location)\n\tclient = Weatherman::Client.new\n\tresponse = client.lookup_by_location(location)\n\nend",
"def determine_weather(location)\n\tclient = Weatherman::Client.new\n\tresponse = client.lookup_by_location(location)\n\nend",
"def location\n return nil if reference?\n ensure_full_data!\n @gapi_json[:location]\n end",
"def legislators_locate(*args)\n get('/legislators/locate', extract_location(args))\n end",
"def geolookup(query)\n get_json(\"#{api_url}/geolookup/#{url_settings}/q/#{parse_query(query)}.#{@options[:format]}\")\n end",
"def get_locations\n response = execute_get(\"/reference/location\")\n Location.from_array(decode(response))\n end",
"def location\n Location.get(@entity['location_id'], client: @client)\n end",
"def get_location(io, context)\n generate_location(io, context)\n end",
"def locations(query = {})\n get('location', query)\n end",
"def locate(address)\n get :q => address.is_a?(String) ? address : location_from_params(address).to_s\n end",
"def locate(address)\n get :q => address.is_a?(String) ? address : location_from_params(address).to_s\n end",
"def locate(address)\n get :q => address.is_a?(String) ? address : location_from_params(address).to_s\n end",
"def location\n @location ||= locations.hq.first\n end",
"def location\n @location_cache || self.locations[0]\n end",
"def getLookupLocation( string, language, country, latitude, longitude)\n params = Hash.new\n params['string'] = string\n params['language'] = language\n params['country'] = country\n params['latitude'] = latitude\n params['longitude'] = longitude\n return doCurl(\"get\",\"/lookup/location\",params)\n end",
"def default_lookup(req, *args)\n req.address\n end",
"def lookup_services(extension, arg)\n extension += \"/#{arg}\"\n uri = URI.parse(API_URL + extension)\n response = connect(uri)\n puts response.body\n end",
"def getLocation\r\n\t\t\t\t\treturn @location\r\n\t\t\t\tend",
"def location\n @location ||= Station.get(@attrs['LocationCode'])\n end",
"def retrieve_location_from_cookie_or_service\n # return GeoLoc.new(YAML.load(cookies[:geo_location])) if cookies[:geo_location]\n return GeoLoc.new(JSON.parse(cookies[:geo_location])) if cookies[:geo_location]\n location = Geocoders::MultiGeocoder.geocode(get_ip_address)\n return location.success ? location : nil\n end",
"def locate(address)\n get :address => address.is_a?(String) ? address : location_from_params(address).to_s\n end",
"def find(query,options={})\n options.merge!(:q => query, :sll => @latlng) # Merge in the query and the lat/lng into the options\n fetch_locations(self.class.get(\"/local\", :query => options)) # Make the get request\n end",
"def get_location(loc)\n geo = Geocoder.search(\"#{loc} seattle\")\n lat = geo[0].latitude\n lon = geo[0].longitude\n [lon, lat]\n end",
"def location\n @location\n end",
"def location\n @location\n end",
"def maps_api_location\n \"#{self.city}+#{self.state.sub(\"International\", \"\")}\".sub(\" \", \"+\")\n end",
"def location\n\t\tfireeagle_user.best_guess.name\n\tend",
"def location_info(location = locations.first)\n if location\n location.full_location\n else\n []\n end\n end",
"def locate(service_name = nil)\n if service_name\n dir = File.join(services_dir, service_name)\n else\n dir = Dir.pwd\n end\n file = service_file_in_dir(dir)\n ServiceFileParser.parse(file, dir)\n end",
"def location\n @fog_wrapper.location\n end",
"def srv\n @service_finder\n end",
"def location\n return @location\n end",
"def locations\n get('locations')\n end",
"def locate(place)\n check_api_key\n @location = Hamweather::Location.parse(place)\n end",
"def location(id)\n @client.get(\"/BikePoint/#{id}\")\n end",
"def location\n\t\tif machine.blank?\n\t\t\t\"Location Unknown\"\n\t\telsif usage.blank?\n\t\t\t\"#{machine.name}\"\n\t\telse\n\t\t\t\"#{machine.name} (#{usage})\"\n\t\tend\n\tend",
"def location\n self.well_info.location\n end",
"def location\n @location\n end",
"def location\n translate! attribute('yweather:location')\n end",
"def get_start_location(name=:default)\n name = name.to_sym\n return @start_locations[name]\n end",
"def location\n puts \"I live on #{address.split[-2, 2].join(' ')}\"\n end",
"def location\n vm.location\n end",
"def full_location; end",
"def getlocation\r\n @myip = remote_ip()\r\n # based off freegeoip.net is really terrible\r\n result = Geocoder.search(@myip)\r\n @mylat = result.latitude\r\n @mylong = result.longitude\r\n @mycity = result.address\r\n #51.243048, -0.588458\r\n end",
"def lookup_server_uri\n server_lookup_attempts.times do\n first_alive_listing = service_directory.all_listings_for(service).find do |listing|\n host_alive?(listing.try(:address))\n end\n\n if first_alive_listing\n host = first_alive_listing.try(:address)\n port = first_alive_listing.try(:port)\n @stats.server = [port, host]\n return \"tcp://#{host}:#{port}\"\n end\n\n host = options[:host]\n port = options[:port]\n\n if host_alive?(host)\n @stats.server = [port, host]\n return \"tcp://#{host}:#{port}\"\n end\n\n sleep(1.0 / 100.0)\n end\n\n fail \"Host not found for service #{service}\"\n end",
"def location\n return Location.find_by_LOCATION_PROFILE_ID(self.LOCATION_PROFILE_ID)\n end",
"def my_location\n\t\t\"#{address}, #{city}, GA\"\n\tend",
"def suggest_location\n return @suggest_location\n end",
"def location\n # TODO Check this\n # return poi.location unless poi.nil?\n # return place.location unless place.nil?\n return get_location\n end",
"def location\n @gapi.job_reference.location\n end",
"def lookup(name)\n locations.find do |v|\n v.name.casecmp(name).zero? || (v.code == name)\n end\n end",
"def location_name\n LOCATIONS[location.to_s]\n end",
"def location_name\n LOCATIONS[location.to_s]\n end",
"def location_name\n LOCATIONS[location.to_s]\n end"
] |
[
"0.6801704",
"0.67613333",
"0.6681403",
"0.65907353",
"0.65626335",
"0.65594304",
"0.65248835",
"0.6492449",
"0.64749235",
"0.6453345",
"0.6439432",
"0.627982",
"0.62766397",
"0.62718785",
"0.6271654",
"0.62700903",
"0.6205303",
"0.619846",
"0.61938053",
"0.61883193",
"0.6172654",
"0.61605704",
"0.6144502",
"0.6139075",
"0.6128728",
"0.61012274",
"0.60766673",
"0.6061248",
"0.6056171",
"0.6053453",
"0.60142636",
"0.6006751",
"0.599823",
"0.5997318",
"0.5991846",
"0.5990855",
"0.59804636",
"0.5971081",
"0.5964595",
"0.5953521",
"0.5952074",
"0.59333587",
"0.59254456",
"0.59252876",
"0.59054893",
"0.5884006",
"0.5876045",
"0.5876045",
"0.58621746",
"0.58558065",
"0.58304375",
"0.581553",
"0.58140385",
"0.5791853",
"0.5786653",
"0.578625",
"0.578625",
"0.578625",
"0.5786181",
"0.57837087",
"0.5778122",
"0.57752144",
"0.57729185",
"0.57539696",
"0.57506883",
"0.5741737",
"0.57304144",
"0.57106173",
"0.57040596",
"0.569584",
"0.569584",
"0.5678348",
"0.5673796",
"0.56715935",
"0.5657829",
"0.5646506",
"0.5646293",
"0.564275",
"0.56394434",
"0.56274927",
"0.5622541",
"0.5612476",
"0.56122696",
"0.5597664",
"0.5582274",
"0.556925",
"0.5567657",
"0.5559953",
"0.5559698",
"0.55529475",
"0.5552416",
"0.55493134",
"0.5540957",
"0.55358875",
"0.55183065",
"0.5509951",
"0.55066603",
"0.5505636",
"0.5505636",
"0.5505636"
] |
0.6901233
|
0
|
The main connect method
|
def connect
# Configure the connection to vCenter
lookup_service_helper = LookupServiceHelper.new(lookup_service_host)
vapi_urls = lookup_service_helper.find_vapi_urls
debug("Found vAPI endpoints: [" + vapi_urls.to_s + "]")
vim_urls = lookup_service_helper.find_vim_urls
debug("Found VIM endpoints: [" + vim_urls.to_s + "]")
node_id = vim_urls.select { |id, url| url.include? vcenter_host }.keys.first
debug("NodeID of vCenter " + config[:vcenter_host] + " is " + node_id.to_s)
vapi_url = lookup_service_helper.find_vapi_url(node_id)
debug("vAPI Endpoint for vCenter is " + vapi_url)
# Create the VAPI config object
ssl_options = {}
ssl_options[:verify] = config[:vcenter_disable_ssl_verify] ? :none : :peer
@vapi_config = VAPI::Bindings::VapiConfig.new(vapi_url, ssl_options)
# get the SSO url
sso_url = lookup_service_helper.find_sso_url
sso = SSO::Connection.new(sso_url).login(config[:vcenter_username], config[:vcenter_password])
token = sso.request_bearer_token
vapi_config.set_security_context(
VAPI::Security.create_saml_bearer_security_context(token.to_s)
)
# Login and get the session information
@session_svc = Com::Vmware::Cis::Session.new(vapi_config)
@session_id = session_svc.create
vapi_config.set_security_context(
VAPI::Security.create_session_security_context(session_id)
)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def connect(*) end",
"def connect; end",
"def connect!; end",
"def connect!; end",
"def connect\n end",
"def connect!\n end",
"def connect\n\tend",
"def connect\n # Implement in subclass\n end",
"def run\n connect\n end",
"def connect(*args)\n raise NotImplementedError\n end",
"def connect\n super\n end",
"def connect\n super\n end",
"def connect\n @connector.connect\n @p.set_connection @connector\n end",
"def connect\n connection.connect\n nil\n end",
"def connect(p0) end",
"def connect\n connection.tap do |c|\n c.start\n end\n end",
"def connect\n @interface.connect\n end",
"def connect()\n\t\t\t# Check queen(s) for peer list\n\n\t\t\t# Connect to peers\n\t\tend",
"def connect\n raise NotImplementedError, \"#connect should be overridden by adapters\"\n end",
"def connect\n raise NotImplementedError, \"#connect should be overriden by adapters\"\n end",
"def connect\n @connection.open\n end",
"def connect\r\n begin\r\n TCPSocket.new(@server, @port) #used for checking the connection\r\n puts \"Connection successful!\"\r\n run()\r\n rescue => exception\r\n puts \"Failed to connect to : #{@server}:#{@port}\"\r\n puts \"Closing...\"\r\n sleep(2)\r\n end\r\n \r\n end",
"def connection; end",
"def connection; end",
"def connection; end",
"def connection; end",
"def connection; end",
"def connection; end",
"def connection; end",
"def connection; end",
"def start\n self.connect\n self.login if @connected\n end",
"def spawn_connection\n connect\n end",
"def connect!\n request! :connect\n end",
"def connect\n start_listener!\n end",
"def establish_connection\n end",
"def connect\n Connection.new\n end",
"def connect\n @comm.connect(opts.user, opts.password, opts.server)\n end",
"def connect parms={}\n send_frame \"CONNECT\", parms\n end",
"def connect \n log \"Connecting\"\n @socket = TCPSocket.new(config[:server], 6667)\n write \"USER #{config[:nick]} #{config[:nick]} #{config[:nick]} :#{config[:nick]}\"\n write \"NICK #{config[:nick]}\"\n write \"JOIN ##{config[:channel]}\"\n end",
"def connect\n\t\t\tbegin\n\t\t\t\tsuper\n\t\t\trescue Exception => ex\n\t\t\t\tdisconnect() #TODO RAE: This behaviour works when the problem is not due to SSL. Try to fix it for SSL\n\t\t\t\traise ex\n\t\t\tend\n\n\t\tend",
"def connect!\n sessions\n self\n end",
"def start\n _connect\n sleep 1\n end",
"def connect\n @connection.create\n end",
"def start\n\t\tself.socket.connect( self.class.host, self.class.port )\n\n\t\tsuper\n\tend",
"def connect()\n # HTTP doesnt use a static connection, so there's really nothing to do then call the connect method of the Interface class:\n super()\n end",
"def connect\n begin\n @mSocket = Net::Telnet::new(\"Host\" => @mHostname,\"Port\" => @mPort)\n print(\"addr| \", @mSocket.addr.join(\":\"), \"\\n\")\n print(\"peer| \", @mSocket.peeraddr.join(\":\"), \"\\n\")\n @mSocket.puts \"USER rubybot 0 * Testing\"\n @mSocket.puts \"NICK #{@mNick}\"\n @mSocket.puts \"JOIN #{@mChannel}\"\n @mSocket.puts \"PRIVMSG NickServ identify ruby-bot\"\n\n # Status of -1 is active / connected\n # I know, this doesn't make much sense\n @mStatus = -1\n\n # print the silly message for the lolz\n rubicante_message \n rescue SocketError\n storeDebug(\"can't connect\")\n end\n end",
"def connect\n @cluster.connect\n end",
"def connect(args)\n if (args.size != 2)\n puts \"usage: connect [host] [port]\"\n return\n else\n @connections.add(args[0], args[1])\n puts \"connected to #{args[0]}:#{args[1]}\"\n end\n end",
"def connected?; end",
"def connected?; end",
"def connected?; end",
"def connect\n require 'crubyflie' unless defined?(::Crubyflie)\n @crazyflie = ::Crubyflie::Crazyflie.new('/tmp/test')\n source = additional_params[:source] || \"\"\n if source.empty?\n flies = @crazyflie.scan_interface\n if flies.empty?\n raise \"No crazyflies!\"\n end\n source = flies.first\n end\n @crazyflie.open_link(source)\n @commander = ::Crubyflie::Commander.new(@crazyflie)\n super\n end",
"def connection\n raise NotImplementedError, \"Implement #{__callee__} in #{self.class.to_s}\"\n end",
"def connect_through_proxy; end",
"def connect\n succeed # Triggers all callbacks for class\n end",
"def connect\n platform.connect\n end",
"def connect\n @connection_manager.connect\n end",
"def connect()\n puts \"[#{getTime}]: Ship Bot started\"\n puts \"[#{getTime}]: What twitch channel do you want to connect to?\"\n @channelname = gets.chomp.downcase\n\n puts \"[#{getTime}]: Preparing to connect...\"\n @socket = TCPSocket.new(\"irc.chat.twitch.tv\", 6667)\n puts \"[#{getTime}]: Connected successfully\"\n\n puts \"[#{getTime}]: Authenticating...\"\n @socket.puts(\"PASS #{@oauth}\")\n @socket.puts(\"NICK #{@nickname}\")\n puts \"[#{getTime}]: Successfully authenticated\"\n\n puts \"[#{getTime}]: Joining #{@channelname}...\"\n @socket.puts(\"JOIN #\" + @channelname)\n puts \"[#{getTime}]: Joined #{@channelname}\"\n\n puts \"[#{getTime}]: Requesting permissions...\"\n @socket.puts(\"CAP REQ :twitch.tv/membership\")\n puts \"[#{getTime}]: Permissions granted\"\n puts \"\" #newline\n end",
"def reconnect!\n disconnect!\n connect\n end",
"def reconnect!\n disconnect!\n connect\n end",
"def connect\n\t\tp 'JabberClient.connect'\n\t\ttrue\n\tend",
"def connect_to_server\n @service.connect(connect_settings)\n end",
"def connect\n Drone::Client.connect\n end",
"def connect()\n @sock = TCPSocket.open(@server, @port)\n end",
"def connect\n\t\t@client.start\n\n\t\t# Set up our input and output exchange/queue\n\t\t@output = @client.exchange( @playername, :passive => false )\n\t\t@queue = @client.queue\n\n\t\t@exchange = @client.exchange( @playername, :passive => false )\n\t\t@queue = @client.queue( \"#{@playername}_output\", :exclusive => true )\n\n\t\tlogin_exchange = @client.exchange( 'login', :type => :direct, :auto_delete => true )\n\n\t\t# Set up the queue to handle incoming connections\n\t\tself.log.debug \" setting up the connections queue...\"\n\t\t@connect_queue = @playersbus.queue( 'connections', :exclusive => true )\n\t\t@connect_queue.bind( @login_exch, :key => :character_name )\n\t\t@connect_queue.subscribe(\n\t\t\t:header => true,\n\t\t\t:consumer_tag => 'engine',\n\t\t\t:exclusive => true,\n\t\t\t:no_ack => false,\n\t\t\t&self.method(:handle_connect_event)\n\t\t )\n\tend",
"def connect()\n @s = @s || TCPsocket.open(@host, @port)\n end",
"def handle_connect *args\n args.each {|a| @node.connect_peer(*a.split(':')) }\n {:state => \"Connecting...\"}\n end",
"def reconnect\n disconnect\n connect\n end",
"def reconnect!\n disconnect\n connect!\n end",
"def new_connection; end",
"def connect\n locate_ev3\n connect_to_ev3\n end",
"def connect\n force_connect unless @handler\n end",
"def reconnect\n end",
"def configure_connection\n end",
"def _connect!\n _log { \"_connect! #{uri}\" } if @verbose >= 1\n stream = _client_connect!\n _log { \"_connect! stream=#{stream}\" } if @verbose >= 1\n _after_connect! stream\n stream\n rescue ::Exception => err\n raise err.class, \"Cannot connect to #{self.class} #{uri}: #{err.inspect}\", err.backtrace\n end",
"def connect\n client.connect(config.host, config.port)\n client.auth(config.password)\n client.send(Jabber::Presence.new.set_type(:available))\n\n self.roster = Jabber::Roster::Helper.new(client)\n roster.wait_for_roster\n\n self.rooms = self.config.rooms.collect do |room_name|\n Robut::Room.new(self, room_name).tap {|r| r.join }\n end\n\n if self.config.enable_private_messaging\n Robut::PM.new(self, rooms)\n end\n\n trap_signals\n self\n end",
"def connect(conn)\n\t\t@host = conn.to_s\n\t\tbegin\n\t\t\t@conn.connect(@host)\n\t\trescue IOException\n\t\t\traise IOError, \"Cannot connect to #{@host}\"\n\t\tend\n\tend",
"def connect!\n @ssh = Net::SSH.start(@host, @user, :password => @pass)\n end",
"def configure_connection\n end",
"def connect\n unless @connected\n once('report_version', ->() do\n once('firmware_query', ->() do\n once('capability_query', ->() do\n once('analog_mapping_query', ->() do\n\n 2.times { |i| toggle_pin_reporting(i) }\n\n @connected = true\n emit('ready')\n end)\n query_analog_mapping\n end)\n query_capabilities\n end)\n end)\n\n until connected?\n read_and_process\n delay(0.5)\n end\n end\n\n self\n end",
"def connect_using conn\n @connection = conn\n end",
"def socket; end",
"def socket; end",
"def socket; end",
"def socket; end",
"def socket; end",
"def connect!\n host, port = @current_server.split(\":\")\n @socket = TCPSocket.new(host, port)\n @transport = Avro::IPC::SocketTransport.new(@socket)\n @requestor = Avro::IPC::Requestor.new(@options[:protocol], @transport)\n rescue Avro::AvroError, Errno::ECONNREFUSED, Errno::EPIPE, IOError => e\n @transport.close rescue nil\n raise e\n end",
"def connect\n \t\t#Se sigue la convencion para la identificacion del usuario\n \t\t#y buscamos alusuario que se intenta conectar\n \t\tself.current_user = find_user\n \tend",
"def start_connect\n # increment id to use as counter for each connections color\n if controller_store[:id] == 7\n controller_store[:id] = 0\n end \n controller_store[:id] += 1\n connection_store[:id] = controller_store[:id]\n\n # send the connection's color\n send_message :curColor, controller_store[:colors][connection_store[:id]]\n\n # sends array data used to display drawing\n send_message :Draw, [\n controller_store.collect_all(:x),\n controller_store.collect_all(:y),\n controller_store.collect_all(:drag),\n controller_store[:color]\n ]\n end",
"def connect(endpoint,hash)\r\n\t\t\t@endpoint = endpoint\r\n\t\t\t@hash = hash\r\n\t\t\tbegin\r\n\t\t\t\tip,port = @endpoint.strip.split(/:/)\r\n\t\t\t\t@fd = TCPSocket.new(ip,port.to_i)\r\n\t\t\trescue\r\n\t\t\t\t## remove chatroom\r\n\t\t\t\traise 'SocketError'\r\n\t\t\tend\r\n\t\t\t@state = 're'\r\n\t\tend",
"def peers_connect\r\n\t\t\tpr = protocols.first\r\n\t\t\th = {\r\n\t\t\t\thandler: self.type.to_s,\r\n\t\t\t\tprotocol: pr.type.to_s,\r\n\t\t\t\tssl: @parent.ssl_enabled?\r\n\t\t\t}\r\n\t\t\tps = hive.peers_random(h,20)\r\n\t\t\tcounter = 0\r\n\t\t\tps.each{|ph| \r\n\t\t\t\tpeer = hive.peer_from_hash(ph)\r\n\t\t\t\tnext if peer.host_id == @parent.queen_id\r\n\t\t\t\tnext if peer.uuid == @parent.uuid\r\n\t\t\t\tnext if peers.any?{|p| p.uuid == peer.uuid }\r\n\t\t\t\tret = pr.connect_peer(peer.host,peer.port)\r\n\t\t\t\tnext if !ret\r\n\t\t\t\tcounter += 1\r\n\t\t\t\tbreak if counter > 20# @parent::MIN_PEERS\r\n\t\t\t}\r\n\t\t\tcounter\r\n\t\tend",
"def connect\n \n if !self.connected?\n \n # connect to the MySQL server\n \n @dbh = DBI.connect(\"DBI:Mysql:#{@dataBase}:#{@host}\", \n\t \"#{@user}\", \"#{@password}\")\n \n @connected=true\n \n end\n end",
"def connect\r\n if @opts[:threadsafe]\r\n @conns = Knj::Threadhandler.new\r\n \r\n @conns.on_spawn_new do\r\n self.spawn\r\n end\r\n \r\n @conns.on_inactive do |data|\r\n data[:obj].close\r\n end\r\n \r\n @conns.on_activate do |data|\r\n data[:obj].reconnect\r\n end\r\n else\r\n @conn = self.spawn\r\n end\r\n end",
"def connect(username, password)\n @username, @password = username, password\n\n @read_thread = self.class.start_read_thread(helper, @socket.getInputStream)\n @write_thread = self.class.start_write_thread(helper, @socket.getOutputStream)\n @write_thread.send_cmd CMD00_ConnectRequest.new\n end",
"def connection\n @connection.connect\n end",
"def pre_connect\n\t\t\ttrue\n\t\tend",
"def connect\n \n if !self.connected?\n \n # connect to the MySQL server\n @dbh = DBI.connect(\"DBI:Mysql:#{@dataBase}:#{@host}\", \n\t \"#{@user}\", \"#{@password}\")\n @connected=true\n \n end\n end",
"def connect\n return if connected?\n self.adapters.each{|adapter| adapter.connect }\n self.connected = true\n end",
"def connect(socket_class, host, port, nodelay = T.unsafe(nil)); end",
"def connect\n TCPSocket.open(@host, @port)\n end",
"def connect opts\n @ts = find_tuplespace opts\n puts \"#{@name} connected to #{@ts.to_s}\"\n t = Utils::repeat_every(@heartbeat_refresh) do\n begin\n heartbeat\n rescue Exception => e\n @heartbeat_entry = nil\n @running = false\n cleanup rescue nil\n raise e\n end\n end\n end"
] |
[
"0.8985493",
"0.8954996",
"0.8809826",
"0.8809826",
"0.87242395",
"0.85432994",
"0.8534175",
"0.8248769",
"0.80545926",
"0.7658598",
"0.7457163",
"0.7457163",
"0.72509724",
"0.72356784",
"0.72230744",
"0.7221076",
"0.7205399",
"0.71830297",
"0.71814495",
"0.7173433",
"0.7172806",
"0.71515447",
"0.71292084",
"0.71292084",
"0.71292084",
"0.71292084",
"0.71292084",
"0.71292084",
"0.71292084",
"0.71292084",
"0.712508",
"0.709489",
"0.7013348",
"0.697832",
"0.69464123",
"0.6912313",
"0.68974996",
"0.68963337",
"0.6846252",
"0.683546",
"0.6825548",
"0.6817366",
"0.68021405",
"0.6800342",
"0.67969936",
"0.679034",
"0.6787821",
"0.67681986",
"0.6704979",
"0.6704979",
"0.6704979",
"0.6698062",
"0.66836303",
"0.66773814",
"0.6677308",
"0.6664902",
"0.66481316",
"0.66233194",
"0.662047",
"0.662047",
"0.65891576",
"0.6586942",
"0.657952",
"0.6558761",
"0.6558257",
"0.65512973",
"0.6542045",
"0.65382695",
"0.65364504",
"0.65322554",
"0.6528245",
"0.65214515",
"0.65080655",
"0.6506903",
"0.65013176",
"0.6500279",
"0.6484125",
"0.64823085",
"0.6476556",
"0.6469197",
"0.6468984",
"0.6464291",
"0.6464291",
"0.6464291",
"0.6464291",
"0.6464291",
"0.6461652",
"0.6460212",
"0.64562213",
"0.64446783",
"0.6440759",
"0.64266795",
"0.64183366",
"0.6418021",
"0.64082164",
"0.6399503",
"0.639434",
"0.63821024",
"0.63810754",
"0.63565224",
"0.6346723"
] |
0.0
|
-1
|
== GET /about The "About Virgo" page.
|
def index
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def about\n # Static Page\n end",
"def about\n @current_nav_identifier = :about\n params[:name] = @current_nav_identifier\n set_page\n render 'show'\n end",
"def about; render; end",
"def about_us\n # it's deliberate that there's no code in here... but we should have a helpful error when we request the URL again\n end",
"def about\n\n end",
"def about\n\tend",
"def about\n\tend",
"def info\n get '/'\n end",
"def about\n end",
"def about\r\n end",
"def about\n end",
"def about\n end",
"def about\n end",
"def about\n end",
"def about\n end",
"def about\n end",
"def about\n end",
"def about\n end",
"def about\n end",
"def about\n end",
"def about\n end",
"def about\n end",
"def about\n end",
"def about\n end",
"def about\n end",
"def about\n end",
"def about\n end",
"def about\n end",
"def about\n end",
"def about\n\n end",
"def about\n\n end",
"def about\n\n end",
"def about\n\n \tend",
"def about\n \n end",
"def about\n # STUB\n end",
"def about; end",
"def about; end",
"def about\n respond_to do |format|\n format.html # about.html.erb\n format.xml { render :xml => nil }\n end\n end",
"def about\n respond_to do |format|\n format.html { render :about }\n end\n end",
"def about\n\t\tabout_post = Post.of_type(Post::POST_TYPE_ABOUT)\n\t\tif about_post.present?\n\t\t\tgon.post = about_post.as_json\n\t\t\trender :show\n\t\telse\n\t\t\tredirect_to :root\n\t\tend\n\tend",
"def app_about\n end",
"def show\n @about_page = AboutPage.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @about_page }\n end\n end",
"def about\n\t\tunless params[:result].nil?\n\t\t\t@result = params[:result]\n\t\tend\n\n\t\t@about = Static.where(\"title = ?\", \"about\").first\n\tend",
"def about\n @about_object = instance_variable_get(\"@#{controller_name.singularize}\")\n render template: \"/dash/base/about\"\n end",
"def about_us\n\n\tend",
"def about_us\n end",
"def about_us\n end",
"def about\n @title = \"about\"\n end",
"def about\n @toc_id = 'about'\n end",
"def homepage\n get '/Pages/Default.aspx'\n end",
"def about?\n env[\"SCRIPT_NAME\"] == '/about'\n end",
"def show\n @aboutu = Aboutu.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @aboutu }\n end\n end",
"def about_us; end",
"def set_about\n @about = About.find(params[:id])\n end",
"def set_about\n @about = About.find(params[:id])\n end",
"def about\n puts \"Name: #{@name}\"\n end",
"def new\n @about_page = AboutPage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @about_page }\n end\n end",
"def about\n render :template =>\"bodysize/about\"\n end",
"def show\n @admin_about = About.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @admin_about }\n end\n end",
"def heros\n get('/hero/')\n end",
"def about\n\t\t@user = current_user\n\tend",
"def about_me\n\tend",
"def info( opts = {} )\n http_action :get, nil, opts\n end",
"def set_about\n @about = About.find(params[:id])\n end",
"def set_about\n @about = about.find(params[:id])\n end",
"def about_us\r\n\t@title = \"About Us\"\r\n end",
"def about\n @abouts = Accesory.where(acc_type: \"About\")\n end",
"def index\n ca_id = current_user.client_application_id\n @about = AboutU.where(client_application_id: ca_id).entries\n\n logger.debug(\"The Id #{ca_id}\")\n @about_us = @about.first\n if !@about_us.present? \n redirect_to new_about_u_path \n end \n\n end",
"def about\n\t\tcontent = Content.first.about_content\n\t\tif content.present?\n\t\t# response to the JSON\n \t render json: { success: true, response: {about_content: content.as_json} },:status=> 200\n\t else\n\t render :json=> { success: false, message: \"About Content is not present\" },:status=> 203\n\t end \n\tend",
"def about_us\n render(:about_us, layout:false) and return\n end",
"def test\n get(\"/help/test\")\n end",
"def info\n get(\"/api-info\")\n end",
"def about\n\t\tputs \"Make: \" + @make\n\t\tputs \"Model: \" + @model\n\t\tputs \"Miles: \" + @miles.to_s\n\t\tputs \"Type: \" + @type\n\t\tputs \"Color: \" + @color\n\t\tputs \"Year: \" + @year.to_s\n\t\tif @used\n\t\t\tputs \"The #{@make} #{@model} is used.\"\n\t\telse\n\t\t\tputs \"The #{@make} #{@model} is new\"\n\t\tend\n\tend",
"def new\n @aboutu = Aboutu.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @aboutu }\n end\n end",
"def about_command(stem, sender, reply_to, msg)\n # This method renders the file \"about.txt.erb\"\n end",
"def open\r\n visit \"/\"\r\n end",
"def about\n @about_html = current_institution&.about_html\n end",
"def about(widget)\n puts \"about\"\n Gnome::About.new(TITLE, VERSION ,\n \"Copyright (C) 2008 Universidad EAFIT\",\n \"Colatio Builder\",\n [\"Juan Guillermo Lalinde\",\"Federico Builes\",\"Alejandro Peláez\",\"Nicolás Hock\"],\n [\"Juan Guillermo Lalinde\",\"Federico Builes\",\"Alejandro Peláez\",\"Nicolás Hock\"],\n nil).show\n end",
"def home\n\t\t# Home Page\n\tend",
"def set_admin_about\n @about = Admin::AboutMe.find(params[:id])\n end",
"def about\n puts \"The CLI Tracker was developed by Dakota States as part of a Flatiron School CLI Project. The data source: https://covid.ourworldindata.org/data/owid-covid-data.json\"\n end",
"def about\n require \"github/markup\"\n @readme = GitHub::Markup.render(\"README.md\", File.read(\"README.md\")).html_safe\n end",
"def about(key, bucket = nil, options = {})\n response = head(path!(bucket, key, options), options)\n raise NoSuchKey.new(\"No such key `#{key}'\", bucket) if response.code == 404\n About.new(response.headers)\n end",
"def index\n @about_pages = AboutPage.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @about_pages }\n end\n end",
"def show_about\n @metadata_profile = @unit.effective_metadata_profile\n @num_downloads = MonthlyUnitItemDownloadCount.sum_for_unit(unit: @unit)\n @num_submitted_items = @unit.submitted_item_count\n @collections = Collection.search.\n institution(@unit.institution).\n filter(Collection::IndexFields::PRIMARY_UNIT, @unit.id).\n order(\"#{Collection::IndexFields::TITLE}.sort\").\n limit(999)\n @subunits = Unit.search.\n institution(@unit.institution).\n parent_unit(@unit).\n order(\"#{Unit::IndexFields::TITLE}.sort\").\n limit(999)\n render partial: \"show_about_tab\"\n end",
"def homepage\n end",
"def homepage\n end",
"def new\n @admin_about = About.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @admin_about }\n end\n end",
"def homepage\n end",
"def homepage\n end",
"def show\n head(:ok)\n end",
"def home(&block)\n check_language!\n route(\"GET\", \"/:lang\", { :skip_i18n => true }, &block)\n end",
"def homepage(request)\n \"#{request.protocol}#{request.host}:#{request.port}\"\n end",
"def me\n get(\"/me\")\n end",
"def getinfo\n request :getinfo\n end",
"def about\n Qt::MessageBox.about(self, 'Jacinthe Reports', ABOUT.join(\"\\n\"))\n end",
"def about\n Qt::MessageBox.about(self, 'Jacinthe Reports', ABOUT.join(\"\\n\"))\n end",
"def introduction\n #DEFAULT ROUTE DO NOT DELETE\n render 'layouts/application'\n end",
"def main_page\n visit '/'\n end",
"def about\r\n\t\tputs \"Gender: #{@gender}\"\r\n\t\tputs \"ethnicity: #{@ethnicity}\"\r\n\t\tputs \"reindeer_ranking: #{@reindeer_ranking}\"\r\n\t\tputs \"age: #{@age}\"\r\n\tend",
"def views_getting_started\n goes_to(\"/content/getting_started\", nil)\n end"
] |
[
"0.7456414",
"0.7287543",
"0.7133497",
"0.7106585",
"0.70982873",
"0.70844775",
"0.70844775",
"0.7071669",
"0.7057822",
"0.7037717",
"0.69981843",
"0.69981843",
"0.69981843",
"0.69981843",
"0.69981843",
"0.69981843",
"0.69981843",
"0.69981843",
"0.69981843",
"0.69981843",
"0.69981843",
"0.69981843",
"0.69981843",
"0.69981843",
"0.69981843",
"0.69981843",
"0.69981843",
"0.69981843",
"0.69981843",
"0.69686043",
"0.69686043",
"0.69686043",
"0.6962459",
"0.69044393",
"0.68167084",
"0.6695734",
"0.6695734",
"0.66889864",
"0.65556",
"0.6535448",
"0.6530175",
"0.64573336",
"0.64548755",
"0.6371641",
"0.63331145",
"0.6326806",
"0.6326806",
"0.627806",
"0.6205884",
"0.61570376",
"0.6153482",
"0.6088254",
"0.6074391",
"0.60460997",
"0.60460997",
"0.6038717",
"0.60334015",
"0.60190547",
"0.59528065",
"0.5951656",
"0.5912698",
"0.59089476",
"0.59080875",
"0.5873161",
"0.5870174",
"0.5853291",
"0.5844766",
"0.58186245",
"0.57777256",
"0.5714705",
"0.5703471",
"0.56974685",
"0.56679416",
"0.5658949",
"0.5630828",
"0.5598054",
"0.5586477",
"0.5578989",
"0.5564916",
"0.55631894",
"0.55401945",
"0.549519",
"0.5493687",
"0.54936224",
"0.5486376",
"0.5480068",
"0.5480068",
"0.5465671",
"0.5462485",
"0.5462485",
"0.5454578",
"0.54488814",
"0.5442743",
"0.5439846",
"0.5438376",
"0.5436711",
"0.5436711",
"0.54332453",
"0.5423582",
"0.5417831",
"0.540651"
] |
0.0
|
-1
|
== GET /about/list/:topic An informational listing on a given subject. == GET /about/list/library == GET /about/list/libraries == GET /about/list/location == GET /about/list/locations
|
def list
@topic = get_topic(params)
@topic_list = get_topic_list(@topic)
respond_to do |format|
format.html
format.xml { render xml: @topic_list.to_xml }
format.json { render json: @topic_list.to_json }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def list\n\t\t@notes = Note.where(topic: params[:topic])\n\tend",
"def index\n joins = {:user_id => doorkeeper_token.resource_owner_id, :slug => params[:topic_id]}\n joins.merge!(:application_id => doorkeeper_token.application_id) unless has_scope?(\"read_any_publications\")\n @publications = Topic::Publication.joins(:topic).where(:sensit_topics => joins).page(params[:page] || 1).per(params[:per] || 10)\n respond_with(@publications)\n end",
"def index\n @topics = Topic.getCommunityTopic(params)\n respond_with(@topics)\n end",
"def index\n opts = {\n parent_ids: @site.id,\n status: params[:status],\n headline_level: params[:head],\n rcmd_level: params[:rcmd]\n }.delete_if {|k,v|v.blank?}\n opts[:parent_id] = params[:channel_id] unless params[:channel_id].blank?\n opts[:title] = /.*#{params[:key]}.*/ unless params[:key].blank?\n @topics = Topic.includes(:channel).where(opts).order(id: :desc).page(params[:page])\n end",
"def index\n @topics = Topic.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @topics }\n end\n end",
"def index\n @topics = Admin::Topic.order(date: :desc).paginate(page: params[:page], per_page: 20)\n end",
"def index\n @api_v1_topics = Api::V1::Topic.all\n end",
"def get_topic(org_unit_id, topic_id) # GET\n query_string = \"/d2l/api/le/#{$le_ver}/#{org_unit_id}/content/topics/#{topic_id}\"\n _get(query_string)\nend",
"def index\n @topics = Topic.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @topics }\n end\n end",
"def index\n @topics = Topic.all\n end",
"def index\n @topics = Topic.all\n end",
"def index\n @topics = Topic.all\n end",
"def get(*topics)\n # FIXME: implement this\n end",
"def index\n @category = Category.find(params[:id])\n @topic = @category.topics.all\n end",
"def topics_for_course\n redirect_guest\n @course = Course.find(params[:id])\n @topics = @course.topics\n end",
"def index\n @topics = Topic.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @topics }\n end\n end",
"def index\n @topics = Topic.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @topics }\n end\n end",
"def index\n @topics = Topic.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @topics }\n end\n end",
"def view\n get_topic(@current_id, :resolve => false)\n get_complete_topic(@current_id, :resolve => false)\n get_related_for_current\n end",
"def index\n @topics = Topic.all\n end",
"def index\n if params[:topic_id]\n lessons = Lesson.where( topic_id: params[:topic_id] )\n else\n lessons = Lesson.all\n end\n\n respond_to do |format| \n format.html { }\n format.js { }\n format.json { render json: lessons }\n end\n end",
"def index\n @topics = @category.topics.preload(:category)\n render 'api/v1/topics/index'\n end",
"def index\n @topics = Topic.paginate :per_page => 10, :page => params[:page], :order => \"updated_at DESC\"\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @topics }\n end\n end",
"def index\n respond_with SeabTopic.all\n end",
"def index\n @content_pack = ContentPack.find(params[:content_pack_id])\n @topics = @content_pack.topics\n end",
"def index\n # require 'pry'\n # binding.pry\n handle_search_name\n handle_filters\n @topics = Topic.all\n end",
"def get_topics\n @chapter = Chapter.find(params[:id]) unless params[:id].blank?\n if current_user.is?(\"EA\") or current_user.is?(\"IA\")\n list = @chapter.topics.map {|u| Hash[value: u.id, name: u.name]}\n else\n topic_ids = ContentUserLayout.get_unlocked_topics(@chapter,current_user)\n if !topic_ids.nil?\n list = @chapter.topics.where(:id=>topic_ids).map {|u| Hash[value: u.id, name: u.name]}\n else\n list = @chapter.topics.map {|u| Hash[value: u.id, name: u.name]}\n end\n end\n render json: list\n end",
"def index\n joins = {:user_id => doorkeeper_token.resource_owner_id, :slug => params[:topic_id]}\n joins.merge!(:application_id => doorkeeper_token.application_id) unless has_scope?(\"read_any_reports\")\n @reports = Topic::Report.joins(:topic).where(:sensit_topics => joins).page(params[:page] || 1).per(params[:per] || 10)\n respond_with(@reports)\n end",
"def index\n @questions = Question.includes(:user, :topics, answers: [:user]).all\n @questions = @questions.topic(params[:topic_id]) if params[:topic_id]\n end",
"def index\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @topics }\n end\n end",
"def index\n @topics = Topic.all\n\n respond_to do |wants|\n wants.html # index.html.erb\n wants.xml { render :xml => @topics }\n end\n end",
"def find_list\n @list = @topic.lists.find(params[:list_id])\n end",
"def get_bookmarked_topics(org_unit_id) # GET\n query_string = \"/d2l/api/le/#{$le_ver}/#{org_unit_id}/content/bookmarks\"\n _get(query_string)\n # Returns: a JSON array of Topic ToC entries.\nend",
"def index\n session[:return_to] = topics_path\n session[:view_style] = 'topic'\n @topics = Topic.find(:all, :conditions => 'parent_id is null')\n @topic_news = Message.find :all, :conditions => \"message_type = 'topic'\", :order => 'created_at DESC', :limit => 6\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @topics }\n end\n end",
"def index\n @article_topics = ArticleTopic.all\n end",
"def show\n @topic = Topic.find(params[:id])\n render 'api/v1/topics/show'\n end",
"def list_topics\n outputter.print_topics(guides.keys)\n 0\n end",
"def index\n\n\t\t@topics = Topic.all\n\n\t\treturn @topics\n\n\tend",
"def index\n @approved_topics = sort Topic.approved.not_completed\n @pending_topics = sort Topic.pending_approval.not_completed\n @completed_topics = sort Topic.completed\n @topic_sections = [:approved_topics,\n :pending_topics,\n :completed_topics]\n @headings = [\n :student_id,\n :title,\n :description,\n :proposed_date,\n :completed_date\n ].inject({}){|hash, column| hash[column] = get_header_name_for(column); hash}\n @headings[:no_link1] = I18n.t('.actions', default: I18n.t(\"helpers.actions\"))\n @headings[:no_link2] = \"Admin Actions\" if current_user.is_admin?\n\n respond_to do |format|\n format.html\n format.json {render json: Topic.all.to_json(only: [:title, :description], methods: [:student_name])}\n end\n end",
"def index\n @topics = @ip.topics\n end",
"def topics\n topics = [\"News\", \"A.I.\", \"V.R.\", \"RMIT\", \"Game\", \"Rails\", \"Go\", \"Web\", \"M.L\", \"Joke\", \"React\", \"Vue\", \"Node\", \"iOS\", \"AWS\"]\n end",
"def index\n optional! :type, default: \"last_actived\"\n optional! :node_id\n optional! :offset, default: 0\n optional! :limit, default: 20, values: 1..150\n\n params[:type] = params[:type].downcase\n\n if params[:node_id].blank?\n @topics = Topic\n if current_user\n @topics = @topics.without_nodes(current_user.block_node_ids)\n @topics = @topics.without_users(current_user.block_user_ids)\n else\n @topics = @topics.without_hide_nodes\n end\n else\n @node = Node.find(params[:node_id])\n @topics = @node.topics\n end\n\n current_user&.touch_last_online_ts\n\n @topics = @topics.without_ban.fields_for_list.includes(:node, :user).send(scope_method_by_type)\n if %w[no_reply popular].index(params[:type])\n @topics = @topics.last_actived\n elsif params[:type] == \"excellent\"\n @topics = @topics.recent\n end\n\n @topics = @topics.offset(params[:offset]).limit(params[:limit])\n end",
"def topics\n r = bills_grouped_by_topic.map do |slug, bills|\n {\n :id => bills.first['id-categoria'],\n :slug => slug,\n :title => ActiveSupport::Inflector.transliterate(bills.first['categoria']),\n :views => bills.map { |b| b['value'] }.inject(:+)\n }\n end\n\n # Sort by views, descending\n r.sort_by! { |b| -b[:views] }\n\n # Set the relative view percentage for each of the topics\n views_total = r.map { |b| b[:views] }.inject(:+)\n\n r.each do |b|\n b[:perc] = b[:views].fdiv(views_total)\n end\n\n # Get the requested topic (if any)\n if params[:topic]\n if params[:topic] =~ /^\\d+$/\n r = r.map { |i| i if i[:id] == params[:topic].to_i }.compact.first\n else\n r = r.map { |i| i if i[:slug] == params[:topic] }.compact.first\n end\n elsif params[:ordered_index]\n # XXX Hack for the Arduino display which shouldn't show the\n # \"other topics\" entry\n r = r.map { |i| i if i[:slug] != 'outros-temas' }.compact\n r = r[params[:ordered_index].to_i]\n\n # They also dont like big jsons\n r.delete(:slug) if r\n end\n\n respond_with r\n end",
"def all_topics\n topics = Feed.find(params[:feed_id]).topics\n render :json => topics\n end",
"def index\n @topics = Topic.published\n end",
"def index\n @search_topics = SearchTopic.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @search_topics }\n end\n end",
"def index\n @topics = Topic.where(:appear => 1).order(\"updated_at DESC, id DESC\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @topics }\n end\n end",
"def index\n @topic_attributes = TopicAttribute.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @topic_attributes }\n end\n end",
"def index\n @admin_topics = Topic.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @admin_topics }\n end\n end",
"def index\n @data_topics = DataTopic.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @data_topics }\n end\n end",
"def show\n if params[:subject_id]\n @subject = Subject.find(params[:subject_id])\n #category = Category.find(params[:category_id])\n @tutorials = Tutorial.where(:subject_id => @subject)\n else\n @tutorials = Tutorial.all\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @subject }\n end\n end",
"def list(options = {})\n body = options.has_key?(:query) ? options[:query] : {}\n\n response = @client.get \"/api/topics\", body, options\n\n return response\n end",
"def index\n respond_to do |format|\n format.html { redirect_to forum_path(params[:forum_id]) }\n format.xml do\n @topics = Topic.find_all_by_forum_id(params[:forum_id], :order => 'sticky desc, replied_at desc', :limit => 25)\n render :xml => @topics.to_xml\n end\n end\n end",
"def index\n redirect_to forum_topic_path(params[:forum_id], params[:topic_id])\n end",
"def show\n @topic = Topic.find(params[:id])\n @page_title = \"Topic Show: #{@topic.topic_name}\"\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @topic }\n \n end\n end",
"def index\n @topic_search = params[:topic_search]\n conditions = [\"name like ?\", \"%#{@topic_search}%\"] unless @topic_search.nil?\n @topics = Topic.paginate(:all, :conditions => conditions, :order => \"name ASC\", :page => params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @topics }\n end\n end",
"def index\n\t\t@page = params[:page].to_i\n @topics = Topic.paginate :page => @page, :per_page => 10\n\n\t\trespond_to do |format|\n format.html\n format.js do\n render :update do |page|\n page.replace_html 'topics', :partial => \"topics/list\"\n end\n end\n end\n end",
"def index\n @topics = Topic.all\n respond_to do |format|\n format.html # index.html.erb\n format.mobile\n format.xml { render :xml => @topics }\n end\n end",
"def index\n @subtopics = Subtopic.all\n end",
"def show\n load_topic\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @topic }\n end\n end",
"def index\n @sub_topics = SubTopic.all\n end",
"def on_get(path)\n topics = I3.server.remote_account_as(Account).viewable_topics\n articles = Article.find_recent(MAX_ARTICLES, topics).collect do |article|\n item = I3::SharedObject.new\n if article.comments.count > 0\n item.modified_at = article.comments.last.posted_at\n item.last_contributor = article.comments.last.author.full_name\n else\n item.modified_at = article.posted_at\n item.last_contributor = article.author.full_name\n end #if\n item.author = article.author.full_name\n item.subject = article.subject\n item.uri = '/bboard/data/messages/%s/%s/%s' % [\n article.topic.permalink,\n article.posted_at.strftime(\"%Y/%m/%d\"),\n article.permalink\n ]\n item.comment_count = article.comments.count\n item\n end #collect\n I3.server.send_object(articles)\n end",
"def GetTopic id\n\n APICall(path: \"topics/#{id}.json\")\n\n end",
"def index\n @topics = Topic.includes(:user).includes(:responses).subscribed_by(@user).order('id DESC').page(params[:page])\n end",
"def get_topics_cohort\n # If affect is all, that means all matching tickets should be bulk updated\n if params[:affect].present? && params[:affect] == \"all\"\n if params[:status].present?\n @topics = Topic.where(current_status: params[:status]).all\n elsif params[:q].present?\n @topics = Topic.admin_search(params[:q])\n end\n\n # Select topics from params\n else\n @topics = Topic.where(id: params[:topic_ids]).all\n end\n \n end",
"def list_subjects\r\n #TODO only list subjects from my own schools \r\n #because then people can still it \r\n school = School.find(params[:nid]) rescue render_return\r\n render_return if !logged_in_user.see_course?(school)\r\n render_p 'course_display/course_selection',{'caller'=>params[:caller],'school'=>school}\r\n end",
"def show\n @forum = Forum.find(params[:forum_id])\n @messages = @topic.messages.accessible_by(current_ability).page params[:page]\n @feed_link = forum_topic_url(@forum, @topic, :format => :atom)\n\n if current_user\n @topic.mark_as_read! :for => current_user\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @topic }\n format.atom { render :layout => false }\n end\n end",
"def show\n @page = params[:page] || '1'\n @asc = (params[:asc] and params[:asc] == \"desc\") ? \"asc\" : 'desc'\n\n @forum = TogForum::Forum.find(params[:id])\n @topics = TogForum::Topic.paginate :per_page => Tog::Config[\"plugins.tog_social.profile.list.page.size\"],\n :page => @page,\n :conditions => ['tog_forum_topics.forum_id = ?', @forum.id]\n \n respond_to do |format|\n format.js { render :partial => \"/forums/partials/topics_paginated\" }\n format.html\n format.rss { render :rss => @forum }\n end\n end",
"def call\n routes.each do |route|\n any_topics = !route.responder&.topics.nil?\n\n if any_topics\n puts \"#{route.topic} =>\"\n\n route.responder.topics.each do |_name, topic|\n features = []\n features << (topic.required? ? 'always' : 'conditionally')\n features << (topic.multiple_usage? ? 'one or more' : 'exactly once')\n\n print topic.name, \"(#{features.join(', ')})\"\n end\n else\n puts \"#{route.topic} => (nothing)\"\n end\n end\n end",
"def index\n @topics = current_user.topics\n end",
"def show\n @forum = Forum.find(params[:id])\n\t\t@topics = Topic.find_all_by_forum_id(@forum.id)\n\t\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @forum }\n end\n end",
"def index\n @topics = @pool.topics.order(\"created_at DESC\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @topics }\n end\n end",
"def index\n @topics = Topic.all\n\n if params[:topic_id].nil?\n @posts = Post.paginate(:page => params[:page])\n elsif\n @active_topic = Topic.find(params[:topic_id])\n # @posts = @active_topic.posts\n @posts = Post.where(topic_id: @active_topic.id).paginate(:page => params[:page])\n\n end\n end",
"def index\n @topics = Topic.where('timeint >= :timeint', :timeint => Topic.current_timeint(Time.now))\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @topics }\n end\n end",
"def index\n @group_id = params[:group_id]\n logger.info \"the group id is : #{@group_id}\"\n if @group_id \n @topics = Topic.where(:group_id => params[:group_id])\n @group = Group.find(@group_id)\n else\n @topics = Topic.all\n end\n #logger.info \"the topics has #{@topics}\"\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @topics }\n end\n end",
"def show\n @topic = Topic.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @topic }\n end\n end",
"def show\n @topic = Topic.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @topic }\n end\n end",
"def show\n @topic = Topic.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @topic }\n end\n end",
"def show\n @topic = Topic.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @topic }\n end\n end",
"def retrieve_concept_list_from_params params, key, alternate_size\n concept_ids = []\n if params.has_key?(key)\n concept_ids = JSON.parse(params[key]).map { |fc| fc[\"id\"] }\n get_all_concepts = false\n concept_ids.each do |concept_id|\n if concept_id == \"nil\"\n get_all_concepts = true\n break\n end\n end\n end\n\n if get_all_concepts\n concepts = @course.topicconcepts.concepts\n elsif concept_ids.size > 0\n concepts = @course.topicconcepts.concepts.where(id: concept_ids)\n elsif alternate_size > 0\n concepts = @course.topicconcepts.concepts.limit(alternate_size)\n else\n concepts = []\n end\n\n concepts\n end",
"def get_topic\n Topic.find(params[:id])\n end",
"def index\n @topic02s = Topic02.all\n end",
"def get_topics_values\n @chapter = Chapter.find(params[:id]) unless params[:id].blank?\n if current_user.is?(\"EA\") or current_user.is?(\"IA\")\n list = @chapter.topics.map {|u| Hash[value: (u.id.to_s+'|'+get_params(u.params.to_s)), name: u.name]}\n else\n topic_ids = ContentUserLayout.get_unlocked_topics(@chapter,current_user)\n if !topic_ids.nil?\n list = @chapter.topics.where(:id=>topic_ids).map {|u| Hash[value: (u.id.to_s+'|'+get_params(u.params.to_s)), name: u.name]}\n else\n list = @chapter.topics.map {|u| Hash[value: (u.id.to_s+'|'+get_params(u.params.to_s)), name: u.name]}\n end\n end\n render json: list\n end",
"def index\n# @topics = Topic.find(:all)\n @new_topics = Topic.find(:all, :order => 'created_at desc', :limit => 10)\n @tags = Topic.tag_counts\n @active_posts = Post.find(:all, :order => 'replied_at desc', :limit => 10)\n @hottest_topics = Topic.find(:all, :order => 'posts_count desc', :limit => 20)\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @topics }\n end\n end",
"def index\n topic_breadcrums({})\n @topics = Topic.all\n end",
"def topics\n respond_to?(:topic) ? topic : []\n end",
"def index\n @topics = Topic.where(nil)\n\n @categories = Category.active().order(:name)\n @classifications = Classification.active().order(:name)\n @teams = Team.active().order(:name)\n\n @topic_name = params[:topic_name]\n @category_id = params[:category_id]\n @classification_id = params[:classification_id]\n @team_id = params[:team_id]\n #@sort_by = params[:sort_by]\n #if @sort_by == nil\n # @sort_by = :name\n #end\n\n @topics = @topics.name_includes(@topic_name) if params[:topic_name].present?\n @topics = @topics.category(@category_id) if params[:category_id].present?\n @topics = @topics.classification(@classification_id) if params[:classification_id].present?\n @topics = @topics.team(@team_id) if params[:team_id].present?\n @topics = @topics.includes(:category, :classification, :team)\n @topics = @topics.active()\n @topics = @topics.order(:name)\n end",
"def index\n @published_topics = current_user.topics.published\n @unpublished_topics = current_user.topics.unpublished\n end",
"def topics\n begin\n case params[:filter].to_i\n when 0: #everyone. unfiltered.\n @topics = @owner.topics.unfiltered\n when 1: #my topics\n @topics = @owner.topics.by_userlist(logged_in_user.id)\n when 2: #my friend's topics\n @topics = @owner.topics.by_userlist(logged_in_user.friends)\n when 3: #topics by classmates\n #@topics = @owner.topics.by_userlist(@logged_in_user.classmates)\n @topics = @owner.topics.unfiltered\n else\n params[:filter] = 0\n @topics = @owner.topics.unfiltered\n end\n case params[:sorter].to_i\n when 0: #latest replies\n @topics.sort! { |x,y| y.latest_post.created_on <=> x.latest_post.created_on}\n when 1: #newest posts\n @topics.sort! { |x,y| y.created_on <=> x.created_on }\n when 2: #most people\n @topics.sort! { |x,y| y.people_count <=> x.people_count }\n when 3: #most posts\n @topics.sort! { |x,y| y.posts.count <=> x.posts.count }\n else\n params[:sorter] = 0\n @topics.sort! { |x,y| y.latest_post.created_on <=> x.latest_post.created_on}\n end\n rescue Exception => e #render_return\n puts e.inspect\n end\n end",
"def list_topics\n\tputs \"1. Social Media\"\n\tputs \"2. Tech\"\n\tputs \"3. Business\"\n\tputs \"4. Entertainment\"\n\tputs \"5. World\"\n\tputs \"6. Watercooler\"\n\tputs \" \"\n\tputs \"Which topic interests you most?\"\n\tprint \"Please enter a number 1 through 6 or press any other # to quit: \"\nend",
"def show\n @forum = TogForum::Forum.find_by_id(params[:id]) || TogForum::Forum.top_level\n \n @order = params[:order] || 'tog_forum_topics.title' #'tog_forum_topics.current_rating'\n\n @page = params[:page] || '1'\n @asc = (params[:asc] and params[:asc] == \"desc\") ? \"asc\" : 'desc'\n\n @topics = TogForum::Topic.paginate :per_page => Tog::Config[\"plugins.tog_forum.topics.list.page.size\"],\n :page => @page,\n :conditions => ['tog_forum_topics.forum_id = ?', @forum.id],\n :order => @order + \" \" + @asc\n \n respond_to do |format|\n format.js { render :partial => \"/forums/partials/topics_paginated\" }\n format.html\n format.rss { render :rss => @forum }\n end\n end",
"def index\n @topic = Topic.find(params[:topic_id])\n @comments = @topic.root_comments\n end",
"def index\n\n\t @resource = User.find_by_authentication_token(params[:auth_token])\n\t # byebug\n\t return invalid_user unless @resource\n\t @subtopics = Subtopic.all\n\t # @user = current_user\n\tend",
"def show\n @subtopic = Subtopic.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @subtopic }\n end\n end",
"def show\n @topics = Topic.find(params[:id])\n @comments = @topics.comments.page(params[:page]).per(10).order(created_at: :desc)\n end",
"def list_topics\n req_hash = generate_request('ListTopics')\n request_info(req_hash, SnsListTopicsParser.new(:logger => @logger))\n rescue\n on_exception\n end",
"def index\n @replies = @topic.replies.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @replies }\n end\n end",
"def index\n #@topics = Topic.all\n redirect_to group_path(:id => params[:group_id])\n end",
"def index\n @class_topics = ClassTopic.all\n end",
"def index\n @forum_topics = Forum::Topic.all\n end"
] |
[
"0.6889292",
"0.6699159",
"0.6665145",
"0.66056716",
"0.6537002",
"0.65369064",
"0.6529126",
"0.65150285",
"0.6494337",
"0.64824903",
"0.64824903",
"0.64824903",
"0.64688253",
"0.64487106",
"0.6432399",
"0.6428444",
"0.6428444",
"0.6428444",
"0.64223737",
"0.6414862",
"0.6401684",
"0.6397256",
"0.63758993",
"0.63558316",
"0.6354153",
"0.6349854",
"0.63447475",
"0.6295318",
"0.6277683",
"0.62677276",
"0.62648857",
"0.62443",
"0.62367815",
"0.6218506",
"0.62088054",
"0.6205462",
"0.62054074",
"0.6202591",
"0.6169099",
"0.6143198",
"0.61284393",
"0.61192906",
"0.6114014",
"0.6106388",
"0.61028206",
"0.6092103",
"0.6083286",
"0.6081472",
"0.6080479",
"0.60737973",
"0.60712427",
"0.60701966",
"0.606917",
"0.6067938",
"0.6065729",
"0.6060161",
"0.60572416",
"0.6051079",
"0.60459256",
"0.6042518",
"0.60322165",
"0.60246736",
"0.6015529",
"0.60148585",
"0.60080653",
"0.6001809",
"0.60013866",
"0.59918976",
"0.5988801",
"0.5984478",
"0.5979352",
"0.59732205",
"0.59717053",
"0.5964664",
"0.59557575",
"0.59553695",
"0.59553695",
"0.59553695",
"0.59553695",
"0.5950222",
"0.59501964",
"0.59443116",
"0.5923479",
"0.59198564",
"0.59197664",
"0.5917856",
"0.5916014",
"0.59143883",
"0.59088266",
"0.58944273",
"0.5887501",
"0.5873731",
"0.58735865",
"0.58679783",
"0.5864863",
"0.58599883",
"0.5856864",
"0.58525693",
"0.5849735",
"0.5849556"
] |
0.7695852
|
0
|
== GET /about/solr == GET /about/solr?lens=:lens Administratoronly Solr information.
|
def solr
@solr_fields = get_solr_fields
@solr_info = get_solr_information
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def solr(url, handler, params={})\n connection, solr_url = connection(url)\n req_url = solr_url.path + '/select?' + hash_to_query_string(params.merge(:qt => handler))\n # puts \"*** requesting to Solr: #{req_url}\"\n connection.get(req_url)\nend",
"def solr_stats\n @solr_stats = get_solr_statistics\n render 'about/solr'\n end",
"def get_solr_response_for_doc_id(id=nil, extra_controller_params={})\n Blacklight.solr.find solr_doc_params(id, extra_controller_params)\n end",
"def url\n \"http://127.0.0.1:#{port}/solr/\"\n end",
"def solr\n @solr ||= RSolr.connect(url: solr_url)\n end",
"def search_solr( solr_args )\n raise \"solr_args should at least contain a ':q' key\" unless solr_args.has_key? :q\n\n unless defined? @solr\n @solr = RSolr.connect :url => 'http://www.sanger.ac.uk/mouseportal/solr'\n end\n\n @solr.get 'select', :params => solr_args\n end",
"def wrap_solr_request\n\n # Get fq parameters from request object\n fq =[]\n request.query_string.split(\"&\").each do |p|\n if p.starts_with?(\"fq=\")\n fq.push(URI.decode_www_form_component(p[3..-1]))\n end\n end\n\n q = params[:q] || \"*:*\"\n wt = params[:wt] || \"json\"\n start = params[:start] || 0\n rows = params[:rows] || 10\n sort = params[:sort] || 'pubyear desc,modified desc'\n\n\n response = solr.get 'select', :params => {:q => q, :fq => fq, :wt=> wt, :sort => sort, :start => start.to_i, :rows => rows.to_i}\n\n if wt.eql?(\"xml\")\n render xml: response\n elsif wt.eql?(\"json\")\n render json: response\n else\n render nothing: true\n end\n end",
"def getSolrDescription\n uri = URI.parse(\"http://#{@host}:#{@port}/solr/admin/cores\")\n out = Net::HTTP.get_response(uri)\n if out.code.to_i == 200 \n return out.body\n else \n STDERR.puts \"Error reaching Solr: \" + \n \"#{out.header.code} -- #{out.header.message}\"\n return nil\n end \n end",
"def details\n\t\tquery_params = QueryFormat.details_format()\n\t\tbegin\n\t\t\tQueryFormat.transform_raw_parameters(params)\n\t\t\tquery = QueryFormat.create_solr_query(query_params, params, request.remote_ip)\n\t\t\tis_test = Rails.env == 'test' ? :test : :live\n\t\t\tis_test = :shards if params[:test_index]\n\t\t\tsolr = Solr.factory_create(is_test)\n\t\t\t@document = solr.details(query)\n\n\t\t\trespond_to do |format|\n\t\t\t\tformat.html # index.html.erb\n\t\t\t\tformat.json { render json: { document: @document } }\n\t\t\t\tformat.xml\n\t\t\tend\n\t\trescue ArgumentError => e\n\t\t\trender_error(e.to_s)\n\t\trescue SolrException => e\n\t\t\trender_error(e.to_s, e.status())\n\t\trescue Exception => e\n\t\t\tExceptionNotifier.notify_exception(e, :env => request.env)\n\t\t\trender_error(\"Something unexpected went wrong.\", :internal_server_error)\n\t\tend\n\tend",
"def show\n respond_to do |format|\n format.html do\n # this strips the counter when we don't want it, ie when there is no search\n redirect_to(:action => \"show\", :id => params[:id]) if session[:search].blank? && params[:counter]\n\n # this cleans out the search criteria when we're coming from a copy/paste URL without counter\n # because we don't want the context of whatever search we were in\n session[:search] = {} unless params[:counter]\n\n @response = get_solr_response_for_doc_id(params[:id])\n @document = SolrDocument.new(@response.docs.first)\n\n setup_previous_document\n setup_next_document\n end\n format.xml do\n @response = get_solr_response_for_doc_id(params[:id])\n @document = SolrDocument.new(@response.docs.first)\n render :xml => @document.to_xml\n end\n end\n\n end",
"def show_solr_document_url doc, options\n if options[:controller]\n case options[:controller]\n when 'collections'\n collection_url doc\n when 'institutions'\n institution_url doc\n end\n else\n solr_document_url doc, options\n end\n\n end",
"def index\n @config_vars = ENVIRONMENT_VARIABLES_TO_PRINT\n @corpus_size = RLetters::Solr::CorpusStats.new.size\n @ping = RLetters::Solr::Connection.ping\n @solr_info = RLetters::Solr::Connection.info\n end",
"def solr_powered?\n self.solr_powered\n end",
"def get_search_results(extra_controller_params={})\n Blacklight.solr.find self.solr_search_params(extra_controller_params)\n end",
"def show_everything(solr_parameters)\n solr_parameters[:fq] ||= []\n solr_parameters[:fq] << 'internal_resource_ssim:(\"Collection::Archival\" OR \"Collection::Library\"' \\\n 'OR \"Collection::Curated\" OR \"Work::Submission\" OR \"Work::FileSet\")'\n end",
"def response\n @solr_response\n end",
"def get_solr_data_luke(url_params = nil, opt = nil)\n route = 'admin/luke'\n if url_params.present?\n route += (route.include?('?') ? '&' : '?')\n route <<\n if url_params.is_a?(Hash)\n url_params.to_query\n else\n Array.wrap(url_params).join('&')\n end\n end\n get_solr_data(route, opt)[:fields] || {}\n end",
"def do_local_indexing(solr_doc); end",
"def solr_url\n @solr_url ||= endpoint_url.gsub(/\\/select$/, '')\n end",
"def solr_url(interactive = false)\n #proto = 'http'\n #host = 'junco.lib.virginia.edu'\n #port = '8080'\n #path = [\"#{proto}://#{host}:#{port}\"]\n #path << 'solr'\n #path << '#' if interactive\n #path << 'test_core'\n #path.join('/')\n return ENV['SOLR_URL'] if interactive == false\n return ENV['SOLR_URL'].gsub( \"/solr/\", \"/solr/#/\" )\n end",
"def add_facetting_to_solr(solr_params)\n if %w[collection_context online_contents].include? blacklight_params[:view]\n return solr_params\n end\n\n super(solr_params)\n end",
"def render_solr_core\n unless request.host == 'search.library.cornell.edu' or request.host == 'catalog.library.cornell.edu'\n core = Blacklight.connection_config[:url]\n # Remove http protocol string\n start = core.rindex(/:\\/\\//) + 3\n display = '<p class=\"solr-core\">Solr core: ' + core[start..-1] + '</p>'\n display.html_safe\n end\n end",
"def search params = {}\n send_and_receive blacklight_config.solr_path, params.reverse_merge(qt: blacklight_config.qt)\n end",
"def get(**args)\n solr_service.get(build, **args)\n end",
"def solr_resp_single_doc(doc_id, solr_params = {})\n solr_response(solr_params.merge({'qt'=>'document','id'=>doc_id}))\nend",
"def get_solr_data(route, opt = nil)\n http = Curl.get(\"#{solr_url}/#{route}\")\n data = http.body_str\n opt = (opt || {}).reverse_merge(symbolize_names: true)\n JSON.parse(data, opt) || {}\n end",
"def username_solr\n self.username\n end",
"def get_single_doc_via_search(extra_controller_params={})\n solr_params = solr_search_params(extra_controller_params)\n solr_params[:per_page] = 1\n solr_params[:fl] = '*'\n Blacklight.solr.find(solr_params).docs.first\n end",
"def first_level_ead_components id, opts={}, docs = Array.new\n solr_response = Blacklight.solr.get \"select\", :params => first_level_solr_query(id,opts)\n return number_found_from_solr_response(solr_response), docs_from_solr_response(solr_response)\n end",
"def show_solr_document_url(doc, options)\n if options[:controller]\n case options[:controller]\n when 'collections'\n collection_url doc\n when 'institutions'\n institution_url doc\n end\n else\n solr_document_url doc, options\n end\n end",
"def solr_url\n @solr_url ||= @configurations[:solr_url]\n end",
"def action_documents\n # Code borrowed from [blacklight]/app/services/blacklight/search_service.rb\n solr_response = search_service.repository.find params[:id]\n # Not sure if we need to set @documents in this context (d.croney)\n @documents = solr_response.documents\n [solr_response, solr_response.documents]\n end",
"def core_url\n @blacklight_context.default_index.connection.uri.to_s.gsub(%r{^.*\\/solr}, '/solr')\n end",
"def url_for_document doc, options = {}\n require 'cgi'\n if respond_to?(:blacklight_config) and\n blacklight_config.show.route and\n (!doc.respond_to?(:to_model) or doc.to_model.is_a? SolrDocument)\n route = blacklight_config.show.route.merge(action: :show, id: doc).merge(options)\n route[:controller] = controller_name if route[:controller] == :current\n route\n else\n # This branch is the one executed for a search results index page \n if doc and doc[\"DocId\"]\n # IF doc exists and has this field\n Rails.logger.debug(\"Route - returning doc #{doc['DocId']}\" )\n # One mechanism is to return the doc itself (Ruby can recognize that it is an object and create the appropriate url)\n # In that case, the url would be catalog/id\n # but here, we want to ensure we pass the DocId parameter and we are escaping the ID in the parameter \n # Additionally, we tried updating the doc id to be the escaped uri, but that did not work correctly\n # What we are doing here is passing the local name (which has no slashes, etc. that could throw either apache or ruby off)\n # and then utilizing the normal behavior for showing a document but passing in the parameter as well\n # Code on the solr document helper side knows to expect that parameter and utilize that for the solr document id if it exists\n # Not passing in a local name in the url would make the code expect this was some search query, and without a query it jsut\n # goes back to the front page\n id = doc[\"DocId\"]\n uri_sliced = id.split(\"/\")\n local_name = uri_sliced.last\n uri_escaped = CGI::escape(id)\n # This was there originally before but let's try it without this, this would be useful if we were passing back doc\n # instead of passing the parameter in the URL\n # doc[\"id\"] = local_name \n \"/catalog/\" + local_name + \"?DocId=\" + id\n else \n #Does what this code would do without our updates \n doc \n end\n \n end\n end",
"def index\n @response, @documents = get_solr_response_for_field_values(\"id\",session[:folder_document_ids] || [])\n end",
"def show\n \n # @response, @document = get_solr_response_for_doc_id(params[:id], )\n @response, @document = get_solr_doc_with_gated_discovery(params[:id])\n folder_siblings(@document)\n\n \n respond_to do |format|\n format.html {setup_next_and_previous_documents}\n\n # Add all dynamically added (such as by document extensions)\n # export formats.\n @document.export_formats.each_key do | format_name |\n # It's important that the argument to send be a symbol;\n # if it's a string, it makes Rails unhappy for unclear reasons. \n format.send(format_name.to_sym) { render :text => @document.export_as(format_name), :layout => false }\n end\n \n end\n rescue Blacklight::Exceptions::InvalidSolrID\n flash[:notice]= \"You do not have sufficient access privileges to read this document, which has been marked private.\"\n redirect_to(\"/\") and return false\n end",
"def solr_core_api(host_name,port,params,path=\"/solr/admin/cores\")\n path = \"#{path}?\".concat(params.collect { |k,v| \"#{k}=#{CGI::escape(v.to_s)}\" }.join('&'))+\"&wt=json\"\n Chef::Log.info(\" HostName = \" + host_name + \", Port = \" + port + \", Path = \" + path)\n http = Net::HTTP.new(host_name, port)\n req = Net::HTTP::Get.new(path)\n unless !SolrAuth::AuthUtils.auth_enabled?\n admin_creds = SolrAuth::AuthUtils.get_solr_admin_credentials\n req.basic_auth(admin_creds['username'], admin_creds['password'])\n end\n response = http.request(req)\n if response != nil then\n return JSON.parse(response.body())\n end\n raise StandardError, \"empty response\"\n end",
"def show\n @lens_model = LensModel.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lens_model }\n end\n end",
"def internal_resource\n solr_document.fetch(Valkyrie::Persistence::Solr::Queries::MODEL).first\n end",
"def solr_params\n {\n fq: \"collection_code:#{collection_code}\",\n rows: 100\n }\n end",
"def solr_document\n document\n end",
"def index\n @solr = Solr.instance.connect\n callback = params.delete('callback') || 'callback'\n rows = [params.delete('rows').to_i, 100].min\n data = begin\n @solr.get('select', params: params.except(:action, :format, :controller).merge(rows: rows))\n rescue => e\n # RSolr dictates that responses be ruby data structures,\n # but the eval still scares me.\n eval(e.response[:body])\n end\n json = JSON.pretty_generate(data)\n respond_to do |format|\n format.js do\n render text: \"#{callback}(#{json});\",\n status: data['error'] ? 500 : 200\n end\n format.json do\n render text: json,\n status: data['error'] ? 500 : 200\n end\n format.xml do\n render text: data.to_xml,\n status: data['error'] ? 500 : 200\n end\n end\n end",
"def lws_api_get(path)\n options = {headers: solr_headers}\n response = HTTParty.get(\"#{FlareConfig.lws_api_url}#{path}\", options)\n Rails.logger.info(\"RESPONSE CODE: #{response.code}\")\n if response.code == 200\n result = JSON.parse(response.body)\n else\n nil\n end\n end",
"def results\n @solr_data[:docs]\n end",
"def load_permissions_from_solr(id=params[:asset_id], extra_controller_params={})\n unless !@permissions_solr_document.nil? && !@permissions_solr_response.nil?\n @permissions_solr_response, @permissions_solr_document = get_permissions_solr_response_for_doc_id(id, extra_controller_params)\n end\n end",
"def load_permissions_from_solr(id=params[:asset_id], extra_controller_params={})\n unless !@permissions_solr_document.nil? && !@permissions_solr_response.nil?\n @permissions_solr_response, @permissions_solr_document = get_permissions_solr_response_for_doc_id(id, extra_controller_params)\n end\n end",
"def overview\n authorize! :show, @pool\n (@response, @document_list) = get_search_results(rows:0)\n respond_to do |format|\n format.json { render :json=>{id:@pool.id, models:@pool.models.as_json, perspectives:@pool.exhibits.as_json, facets:@response[\"facet_counts\"][\"facet_fields\"], numFound:@response[\"response\"][\"numFound\"] } } \n end\n end",
"def show_works_or_works_that_contain_files(solr_parameters)\n return if blacklight_params[:q].blank?\n\n solr_parameters[:user_query] = blacklight_params[:q]\n solr_parameters[:q] = new_query\n solr_parameters[:defType] = 'lucene'\n end",
"def panel\r\n \t@authq = params[:authq] || \"\"\r\n \t@auth_type = params[:type] || \"\"\r\n \t# This should return the JSON for solr documents\r\n results = get_browse_info(@authq, @auth_type)\r\n @data = results[0]\r\n heading = @data[\"heading\"]\r\n #Call helper method to see whether external data should or should not be included within panel\r\n #This used to be @authq but changing it because the parameter from the link may have different\r\n #ending punctuation than the heading in the browse. Relying entirely on heading now\r\n permissions_key = heading.delete_prefix('\"').delete_suffix('\"')\r\n @exclusions = check_permissions(permissions_key)\r\n render \"panel\"\r\n \r\n end",
"def index_info(params={})\n params[:numTerms]||=0\n send_request @opts[:luke_path], params\n end",
"def cjk_adv_solr_resp(solr_params, req_handler = 'select')\n q_val = solr_params['q']\n if num_cjk_uni(q_val) == 0\n RSpecSolr::SolrResponseHash.new(solr_conn.send_and_receive(req_handler, method: :get, params: solr_params.merge(solr_args)))\n else\n if q_val =~ /\\{(.*)\\}(.*)/\n qf_pf_args = Regexp.last_match(1)\n terms = Regexp.last_match(2)\n end\n RSpecSolr::SolrResponseHash.new(solr_conn.send_and_receive(req_handler, method: :get,\n params: solr_params.merge(solr_args).merge(cjk_mm_qs_params(terms ? terms : q_val))))\n end\n end",
"def viewer_data_uri(solr_document_uri)\n uri = URI.parse(solr_document_uri)\n \"#{uri.path}.jsonld\"\n end",
"def mlt_results_for_show\n return unless controller_name == 'catalog'\n\n mlt_search_service = search_service_class.new(config: blacklight_config,\n user_params: { mlt_id: params[:id], rows: 4 },\n search_builder_class: CommonwealthMltSearchBuilder)\n _mlt_response, @mlt_document_list = mlt_search_service.search_results\n end",
"def results\n @solr_data[:docs]\n end",
"def search\n query = params[:q]\n works = ActiveFedora::SolrService.query(query, fq: @fq, fl: @fl, df: @df, rows: @max_rows) \n format_solr_keys(works)\n render(json: works)\n end",
"def solr_collection_api(host_name,port,params,config_name=nil,path=\"/solr/admin/collections\")\n if not config_name.nil?\n path = \"#{path}?\".concat(params.collect { |k,v| \"#{k}=#{CGI::escape(v.to_s)}\" }.join('&'))+\"&collection.configName=\"+config_name+\"&wt=json\"\n else\n path = \"#{path}?\".concat(params.collect { |k,v| \"#{k}=#{CGI::escape(v.to_s)}\" }.join('&'))+\"&wt=json\"\n end\n Chef::Log.info(\" HostName = \" + host_name + \", Port = \" + port + \", Path = \" + path)\n http = Net::HTTP.new(host_name, port)\n req = Net::HTTP::Get.new(path)\n\n unless !SolrAuth::AuthUtils.auth_enabled?\n admin_creds = SolrAuth::AuthUtils.get_solr_admin_credentials\n req.basic_auth(admin_creds['username'], admin_creds['password'])\n end\n response = http.request(req)\n if response != nil then\n return JSON.parse(response.body())\n end\n raise StandardError, \"empty response\"\n end",
"def to_solr(_solr_doc = {}, _opts = {})\n indexing_service.generate_solr_document\n end",
"def add_access_controls_to_solr_params(solr_parameters, user_parameters)\n apply_gated_discovery(solr_parameters, user_parameters)\n end",
"def solr_response(solr_params, req_handler='select')\n response = solr.send_and_receive(req_handler, {:method => :get, :params => solr_params})\n RSpecSolr::SolrResponseHash.new(response)\n end",
"def ocr_search_params(solr_parameters = {})\n solr_parameters[:facet] = false\n solr_parameters[:hl] = true\n solr_parameters[:'hl.fl'] = blacklight_config.iiif_search[:full_text_field]\n solr_parameters[:'hl.fragsize'] = 100\n solr_parameters[:'hl.snippets'] = 10\n solr_parameters[:qf] = blacklight_config.iiif_search[:full_text_field]\n # catalog controller puts params here when you call search_results\n solr_parameters[:fq] = solr_parameters[:fq] || []\n solr_parameters[:fq] += blacklight_params[:fq]\n end",
"def show\n @response = get_solr_response_for_doc_id\n @document = SolrDocument.new(@response.docs.first)\n respond_to do |format|\n format.html {setup_next_and_previous_documents}\n format.xml {render :xml => @document.marc.to_xml}\n format.refworks\n format.endnote\n end\n rescue ActiveRecord::RecordNotFound \n logger.error(\"Attempt to access invalid id: #{params[:id]}\") \n flash[:notice] = \"Sorry, I can't find the item you requested.\" \n redirect_to :action => 'index' \n rescue \n logger.error(\"Error encountered when trying to access: #{params[:id]}\") \n flash[:notice] = \"Sorry, you seem to have encountered an error.\" \n redirect_to :action => 'index', :q => nil , :f => nil\n end",
"def solr_select\n @solr_select ||= solr.select(params: solr_params)\n end",
"def pacscl_xml\n document = Blacklight.default_index.search(q: \"id:#{params[:id]}\")&.dig(\"response\", \"docs\")&.first\n document = SolrDocument.new(document)\n document.suppress_xml_containers!\n respond_to do |format|\n format.xml do\n render xml: document.export_as_xml\n end\n end\n end",
"def index\n @dataset_researchers = Lien.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @dataset_researchers }\n end\n end",
"def ocr_search_params(solr_parameters = {})\n solr_parameters[:facet] = false\n solr_parameters[:hl] = true\n solr_parameters[:'hl.fl'] = blacklight_config.ocr_search_field\n solr_parameters[:'hl.fragsize'] = 135\n solr_parameters[:'hl.snippets'] = 10\n end",
"def url_for_document doc, options = {}\n if respond_to?(:blacklight_config) and\n blacklight_config.show.route and\n (!doc.respond_to?(:to_model) or doc.to_model.is_a? SolrDocument)\n route = blacklight_config.show.route.merge(action: :show, id: doc).merge(options)\n route[:controller] = controller_name if route[:controller] == :current\n route\n else\n doc\n end\n end",
"def names\n\t\tquery_params = QueryFormat.names_format()\n\t\tbegin\n\t\t\tQueryFormat.transform_raw_parameters(params)\n\t\t\tquery = QueryFormat.create_solr_query(query_params, params, request.remote_ip)\n\t\t\tis_test = Rails.env == 'test' ? :test : :live\n\t\t\tis_test = :shards if params[:test_index]\n\t\t\tsolr = Solr.factory_create(is_test)\n\t\t\t@results = solr.names(query)\n\n\t\t\trespond_to do |format|\n\t\t\t\tformat.html # index.html.erb\n\t\t\t\tformat.json { render json: { results: @results }}\n\t\t\t\tformat.xml\n\t\t\tend\n\t\trescue ArgumentError => e\n\t\t\trender_error(e.to_s)\n\t\trescue SolrException => e\n\t\t\trender_error(e.to_s, e.status())\n\t\trescue Exception => e\n\t\t\tExceptionNotifier.notify_exception(e, :env => request.env)\n\t\t\trender_error(\"Something unexpected went wrong.\", :internal_server_error)\n\t\tend\n end",
"def index_to_solr(db, coll = \"\", auth = {})\n auth_line = \"\"\n\n auth.each do |db_name, auth|\n auth_line << \"db.getSiblingDB(\\\"#{db_name}\\\").auth(\\\"#{auth[:user]}\\\", \\\"#{auth[:pwd]}\\\");\"\n end\n\n if coll.empty? then\n index_line = \"db.getSiblingDB(\\\"#{db}\\\").solrIndex();\"\n else\n index_line = \"db.getSiblingDB(\\\"#{db}\\\").#{coll}.solrIndex();\"\n end\n\n code = auth_line\n code << <<JAVASCRIPT\n MSolr.connect(\"#{SOLR_LOC}\");\n #{index_line}\nJAVASCRIPT\n\n eval(code)\n end",
"def edit_facet_fields\n @fields = blacklight_solr.get('admin/luke', params: { fl: '*', 'json.nl' => 'map' })['fields']\n end",
"def find id, params = {}\n doc_params = params.reverse_merge(qt: blacklight_config.document_solr_request_handler)\n .reverse_merge(blacklight_config.default_document_solr_params)\n .merge(blacklight_config.document_unique_id_param => id)\n \n solr_response = send_and_receive blacklight_config.document_solr_path || blacklight_config.solr_path, doc_params\n raise Blacklight::Exceptions::InvalidSolrID.new if solr_response.documents.empty?\n solr_response\n end",
"def solr_response(solr_params, req_handler = 'select')\n RSpecSolr::SolrResponseHash.new(\n solr_conn.send_and_receive(req_handler,\n method: :get,\n params: solr_params.merge(\n 'testing' => 'trlnbib_index_testing'\n ))\n )\n end",
"def load_catalog_info(catalog_id=@catalog_id, extra_blacklight_controller_params={})\n begin\n @catalog_solr_response, @catalog_solr_doc = get_solr_response_for_doc_id(catalog_id, extra_blacklight_controller_params)\n rescue Blacklight::SolrHelper::InvalidSolrID => e\n logger.warn \"Warning:\" + e.message + \" when searching for #{catalog_id}\"\n end\n return [@catalog_solr_response, @catalog_solr_doc]\n end",
"def solr_document_path(solr_document)\n if controller.is_a?(SitesController) and !solr_document.site_result?\n # TODO: refactor after local site searches are implemented\n url_for(params.merge(action: 'show', id: solr_document, controller: 'catalog', slug: nil))\n else\n url_for(params.merge(action: 'show', id: solr_document))\n end\n end",
"def generate_solr_document\n super.tap do |solr_doc|\n # account\n solr_doc[Solrizer.solr_name('account', :displayable)] = object.account.to_json\n solr_doc[Solrizer.solr_name('account_type', :facetable)] = object.account.map { |a| a.account_type.first }.reject(&:blank?)\n # contact\n solr_doc[Solrizer.solr_name('contact_label', :facetable)] = object.contact.map { |c| c.label.first }.reject(&:blank?)\n solr_doc[Solrizer.solr_name('contact', :displayable)] = object.contact.to_json\n # template files\n solr_doc['template_path_ss'] = object.members.select {\n |m| m.resource_type.include? ('Data paper template')}.\n map{ |f| Hyrax::Engine.routes.url_helpers.download_path(f.id)\n }\n end\n end",
"def index\n # @search = Shelter.search do\n # fulltext params[:search]\n # end\n # @shelters = @search.results\n @shelters = Shelter.all\nend",
"def initialize url = nil\n @solr = url.nil? ? RSolr.connect(:url => RH_CONFIG[\"solr_discovery\"]) : RSolr.connect(:url => url)\n end",
"def solr_during_indexing\n {\n \"has_model_ssim\" => [\"Collection\"],\n :id => object.id,\n \"title_tesim\" => [object.title.first.to_s],\n \"title_sim\" => [object.title.first.to_s],\n \"collection_type_gid_ssim\" => [object.collection_type_gid],\n \"ark_ssi\" => object.ark,\n \"ursus_id_ssi\" => Californica::IdGenerator.blacklight_id_from_ark(object.ark),\n \"member_ids_ssim\" => [],\n \"object_ids_ssim\" => [],\n \"member_of_collection_ids_ssim\" => [], \"collection_ids_ssim\" => [],\n \"generic_type_sim\" => [\"Collection\"],\n \"bytes_lts\" => 0,\n \"visibility_ssi\" => \"restricted\"\n }\n end",
"def get_single_doc_via_search(params={})\n args = params ? params.symbolize_keys : {}\n args[:page] ||= 1\n args[:qt] ||= Blacklight.config[:default_qt]\n mapper = RSolr::Ext::Request::Standard.new\n solr_params = mapper.map({\n :q => args[:q], \n :phrase_filters => args[:f],\n :qt => args[:qt],\n :per_page => 1,\n :page => args[:page],\n :facet => false,\n :fl => '*'\n })\n raw_response = Blacklight.solr.select(solr_params)\n response = RSolr::Ext::Response::Standard.new(raw_response)\n response.docs.first\n end",
"def solr_response(solr_params, req_handler='select')\n silence_warnings { \n RSpecSolr::SolrResponseHash.new(@@solr.send_and_receive(req_handler, {:method => :get, :params => solr_params.merge(\"testing\"=>\"sw_index_test\")}))\n }\nend",
"def initialize opts={}\n opts[:url] ||= 'http://127.0.0.1:8983/solr'\n @opts = opts\n @uri = URI.parse opts[:url]\n @proxy = URI.parse opts[:proxy] if opts[:proxy]\n end",
"def index\n @lectors = Lector.all\n end",
"def generate_solr_document\n super.tap do |solr_doc|\n index_suppressed(solr_doc)\n index_workflow_fields(solr_doc)\n end\n end",
"def show_works_or_works_that_contain_files(solr_parameters)\n return if blacklight_params[:q].blank? || blacklight_params[:search_field] != 'all_fields'\n solr_parameters[:user_query] = blacklight_params[:q]\n solr_parameters[:q] = new_query\n solr_parameters[:defType] = 'lucene'\n end",
"def index\n @extra_controller_params ||= {}\n enforce_search_permissions\n @response = get_search_results( @extra_controller_params )\n @filters = params[:f] || []\n respond_to do |format|\n format.html { save_current_search_params }\n format.rss { render :layout => false }\n end\n rescue RSolr::RequestError\n logger.error(\"Unparseable search error: #{params.inspect}\" ) \n flash[:notice] = \"Sorry, I don't understand your search.\" \n redirect_to :action => 'index', :q => nil , :f => nil\n rescue \n logger.error(\"Unknown error: #{params.inspect}\" ) \n flash[:notice] = \"Sorry, you've encountered an error. Try a different search.\" \n redirect_to :action => 'index', :q => nil , :f => nil\n end",
"def get_solr_response_for_doc_id(doc_id)\n # TODO: shouldn't hardcode id field; should be setable to unique_key field in schema.xml\n # Note: hardcoding is also in rsolr connection base find_by_id() method\n solr_params = {:qt=>:document, :id=>doc_id}\n raw_response = Blacklight.solr.select(solr_params)\n RSolr::Ext::Response::Standard.new(raw_response)\n end",
"def generate_solr_document\n super.tap do |solr_doc|\n solr_doc['member_works_count_isi'] = member_works_count\n solr_doc['title_ssort'] = sort_title\n solr_doc['creator_ssort'] = object.creator.first\n solr_doc['generic_type_sim'] = [\"Collection\"]\n solr_doc['banner_path_ss'] = banner_path\n solr_doc['source_collection_title_for_collections_ssim'] = source_collection\n solr_doc['deposit_collection_titles_tesim'] = deposit_collection\n solr_doc['deposit_collection_ids_tesim'] = object.deposit_collection_ids\n end\n end",
"def components_from_solr\n query = \"#{Ddr::Index::Fields::COLLECTION_URI}:#{RSolr.solr_escape(internal_uri)}\"\n filter = ActiveFedora::SolrService.construct_query_for_rel(:has_model => Component.to_class_uri)\n results = ActiveFedora::SolrService.query(query, fq: filter, rows: 100000)\n results.lazy.map {|doc| SolrDocument.new(doc)}\n end",
"def set_lensa\n @lensa = Lensa.friendly.find(params[:id])\n end",
"def paginated_solr_query solr, params = { q: '*:*' }, page = 1, per_page = ApplicationController::SOLR_RESULTS_PER_PAGE\n params[:start] = (page - 1) * per_page\n response = solr.get 'select', params: params rescue response = nil\n\n # Replace fields with highlighting.\n if response != nil && response['highlighting'] != nil\n response['response']['docs'].each do |doc|\n h = response['highlighting'][doc['id']]\n if h != nil\n doc['title'] = h['title'][0] if h['title']\n doc['description'] = h['description'][0] if h['description']\n doc['body'] = h['body'][0] if h['body']\n end\n end\n end\n response\n end",
"def search_for_item\n search_service.fetch(params[:solr_document_id])\n end",
"def show\n # Render 404 if category_id not valid\n raise(ActionController::RoutingError, 'not found') unless collections_config[params[:category_id].to_sym]\n\n # If category_id is valid look up any additional solr parameters\n @category = send params[:category_id].to_sym\n facet_name = @category.use_queries ? \"featured_search\" : @category.facet\n response = AcademicCommons.search do |parameters|\n parameters.rows(0).facet_limit(-1)\n if @category.use_queries # {!ex=pt key=valueKey}field:query\n @category.values.each { |key, value| parameters.add_facet_query \"{!ex=featured_search key=#{key}}#{value.query}\" }\n else\n parameters.facet_by(facet_name)\n @category.filter.each { |f, v| parameters.filter(f, v) }\n end\n end\n\n facet_counts = @category.use_queries ? response.facet_queries : response.facet_fields[facet_name].each_slice(2).to_a.to_h\n facet_counts.keep_if { |k, _| @category.values.keys.include?(k) } if @category.values.present?\n\n @collections = facet_counts.map do |value, count|\n filters = { facet_name => value }.merge(@category.filter)\n c = @category.values.fetch(value, OpenStruct.new(label: value))\n c.count = count\n c.search_url = search_url(filters)\n c\n end\n end",
"def query_for_rendering(file_set_id)\n ::SolrDocument.find(file_set_id)\n end",
"def debug\n @solr_data[:debug]\n end",
"def show\n render_result('Current API has no definition for just calling /docs. Call /docs/changes or /docs/deletes')\n end",
"def run_solr_query(params, method = 'select')\n start_time = Time.now\n response = Solr.get method, :params => params\n elapsed_time = Time.now - start_time\n Rails.logger.info \"Request from #{request.remote_ip} to #{request.fullpath} at #{Time.now}\"\n Rails.logger.info \"Solr query: #{params}\"\n Rails.logger.info \"Query run time: #{elapsed_time.round(3)} seconds (#{(elapsed_time / 60.0).round(2)} minutes)\"\n response\n end",
"def get_solr_response_for_doc_id(id=nil, extra_controller_params={})\n solr_response = find solr_doc_params(id).merge(extra_controller_params)\n raise Blacklight::Exceptions::InvalidSolrID.new if solr_response.docs.empty?\n document = SolrDocument.new(solr_response.docs.first, solr_response)\n [solr_response, document]\n end",
"def solr_doc_params(id=nil)\n id ||= params[:id]\n # just to be consistent with the other solr param methods:\n {\n :qt => :document,\n :id => id # this assumes the document request handler will map the 'id' param to the unique key field\n }\n end",
"def conceptwiki_ep_search\n\t\tOPS_API_FREETEXT_SEARCH_URL\n\tend",
"def ping_solr\n begin\n solr = RSolr.connect :url => 'http://localhost:8983/solr'\n response = solr.get 'select', :params => {:q => '*:*'}\n puts 'Solr is up!'\n return\n rescue Errno::ECONNREFUSED\n puts 'Solr not up yet, sleeping for 10 seconds... zzz'\n sleep 10\n ping_solr\n end\n end",
"def url_for_map doc, options = {}\n require 'cgi'\n \n # This branch is the one executed for a search results index page \n if doc and doc[\"DocId\"]\n # IF doc exists and has this field\n Rails.logger.debug(\"Route - returning doc #{doc['DocId']}\" )\n # One mechanism is to return the doc itself (Ruby can recognize that it is an object and create the appropriate url)\n # In that case, the url would be catalog/id\n # but here, we want to ensure we pass the DocId parameter and we are escaping the ID in the parameter \n # Additionally, we tried updating the doc id to be the escaped uri, but that did not work correctly\n # What we are doing here is passing the local name (which has no slashes, etc. that could throw either apache or ruby off)\n # and then utilizing the normal behavior for showing a document but passing in the parameter as well\n # Code on the solr document helper side knows to expect that parameter and utilize that for the solr document id if it exists\n # Not passing in a local name in the url would make the code expect this was some search query, and without a query it jsut\n # goes back to the front page\n id = doc[\"DocId\"]\n uri_sliced = id.split(\"/\")\n local_name = uri_sliced.last\n uri_escaped = CGI::escape(id)\n # This was there originally before but let's try it without this, this would be useful if we were passing back doc\n # instead of passing the parameter in the URL\n # doc[\"id\"] = local_name \n \"/maps/\" + local_name + \"?DocId=\" + id\n else \n #Does what this code would do without our updates \n doc \n end\n \n \n end"
] |
[
"0.6705973",
"0.6662194",
"0.6624481",
"0.6564986",
"0.6513837",
"0.6383423",
"0.62608135",
"0.62519354",
"0.6242167",
"0.6222342",
"0.6206506",
"0.61802095",
"0.6170342",
"0.616341",
"0.6140831",
"0.608454",
"0.60834855",
"0.6073331",
"0.60699946",
"0.6045608",
"0.60370624",
"0.6020263",
"0.6017018",
"0.59934783",
"0.5935638",
"0.593402",
"0.591487",
"0.58712506",
"0.5863182",
"0.58605963",
"0.58250046",
"0.5820522",
"0.5807363",
"0.578602",
"0.57735884",
"0.5768138",
"0.5767406",
"0.5765647",
"0.5730782",
"0.5717598",
"0.56854075",
"0.56834644",
"0.56812197",
"0.5680102",
"0.56782645",
"0.56782645",
"0.5663781",
"0.5644953",
"0.56439084",
"0.56252277",
"0.56215084",
"0.5577841",
"0.55632895",
"0.55628103",
"0.55595714",
"0.5554691",
"0.555439",
"0.5526787",
"0.55113095",
"0.55096614",
"0.5507448",
"0.55066293",
"0.5499894",
"0.5493055",
"0.54878736",
"0.5484603",
"0.54778725",
"0.54767776",
"0.54742557",
"0.54687953",
"0.5466326",
"0.54199773",
"0.541198",
"0.5383531",
"0.5381189",
"0.5379339",
"0.5369393",
"0.5365314",
"0.5357024",
"0.5355497",
"0.5350918",
"0.5344821",
"0.53441703",
"0.53186",
"0.53099585",
"0.5306643",
"0.5305152",
"0.5299253",
"0.5293543",
"0.52893066",
"0.5287134",
"0.52753824",
"0.5272688",
"0.52711135",
"0.5270084",
"0.5262578",
"0.52600175",
"0.5247066",
"0.52429885",
"0.523951"
] |
0.71127635
|
0
|
== GET /about/solr_stats Administratoronly Solr information.
|
def solr_stats
@solr_stats = get_solr_statistics
render 'about/solr'
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def solr\n @solr_fields = get_solr_fields\n @solr_info = get_solr_information\n end",
"def index\n @config_vars = ENVIRONMENT_VARIABLES_TO_PRINT\n @corpus_size = RLetters::Solr::CorpusStats.new.size\n @ping = RLetters::Solr::Connection.ping\n @solr_info = RLetters::Solr::Connection.info\n end",
"def admin_stats\n logger.debug('Getting admin statistics') if @debug\n get('/api/admin/stats')\n end",
"def stats\n request :get, \"_stats\"\n end",
"def stats\n request :get, \"_stats\"\n end",
"def getSolrDescription\n uri = URI.parse(\"http://#{@host}:#{@port}/solr/admin/cores\")\n out = Net::HTTP.get_response(uri)\n if out.code.to_i == 200 \n return out.body\n else \n STDERR.puts \"Error reaching Solr: \" + \n \"#{out.header.code} -- #{out.header.message}\"\n return nil\n end \n end",
"def stats\n Client.current.get(\"#{resource_url}/stats\")\n end",
"def details\n\t\tquery_params = QueryFormat.details_format()\n\t\tbegin\n\t\t\tQueryFormat.transform_raw_parameters(params)\n\t\t\tquery = QueryFormat.create_solr_query(query_params, params, request.remote_ip)\n\t\t\tis_test = Rails.env == 'test' ? :test : :live\n\t\t\tis_test = :shards if params[:test_index]\n\t\t\tsolr = Solr.factory_create(is_test)\n\t\t\t@document = solr.details(query)\n\n\t\t\trespond_to do |format|\n\t\t\t\tformat.html # index.html.erb\n\t\t\t\tformat.json { render json: { document: @document } }\n\t\t\t\tformat.xml\n\t\t\tend\n\t\trescue ArgumentError => e\n\t\t\trender_error(e.to_s)\n\t\trescue SolrException => e\n\t\t\trender_error(e.to_s, e.status())\n\t\trescue Exception => e\n\t\t\tExceptionNotifier.notify_exception(e, :env => request.env)\n\t\t\trender_error(\"Something unexpected went wrong.\", :internal_server_error)\n\t\tend\n\tend",
"def results\n @solr_data[:docs]\n end",
"def stats\n _get(\"/system/stats\") { |json| json }\n end",
"def response\n @solr_response\n end",
"def admin_gists_stats\n get_admin_stats \"gists\"\n end",
"def results\n @solr_data[:docs]\n end",
"def index\n @system_stats = SystemStat.all\n end",
"def totals\n\t\tis_test = Rails.env == 'test' ? :test : :live\n\t\t@totals = Solr.get_totals(is_test)\n#\t\tresults = [ { :name => 'NINES', :total_docs => 400, :total_archives => 12}, { :name => '18thConnect', :total_docs => 800, :total_archives => 24 } ]\n\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\t\tformat.json { render json: @totals }\n\t\t\tformat.xml # index.xml.builder\n\t\tend\n\tend",
"def statistics\n authorize!(:read_statistics, current_course)\n end",
"def stats\n @stats ||= query\n end",
"def stats\n @stats ||= query\n end",
"def stats(params = {})\n response = client.get \"/_cluster/stats\", params.merge(action: \"cluster.stats\", rest_api: \"cluster.stats\")\n response.body\n end",
"def total\n @solr_data[:total]\n end",
"def names\n\t\tquery_params = QueryFormat.names_format()\n\t\tbegin\n\t\t\tQueryFormat.transform_raw_parameters(params)\n\t\t\tquery = QueryFormat.create_solr_query(query_params, params, request.remote_ip)\n\t\t\tis_test = Rails.env == 'test' ? :test : :live\n\t\t\tis_test = :shards if params[:test_index]\n\t\t\tsolr = Solr.factory_create(is_test)\n\t\t\t@results = solr.names(query)\n\n\t\t\trespond_to do |format|\n\t\t\t\tformat.html # index.html.erb\n\t\t\t\tformat.json { render json: { results: @results }}\n\t\t\t\tformat.xml\n\t\t\tend\n\t\trescue ArgumentError => e\n\t\t\trender_error(e.to_s)\n\t\trescue SolrException => e\n\t\t\trender_error(e.to_s, e.status())\n\t\trescue Exception => e\n\t\t\tExceptionNotifier.notify_exception(e, :env => request.env)\n\t\t\trender_error(\"Something unexpected went wrong.\", :internal_server_error)\n\t\tend\n end",
"def index\n @studies = Study.find_studies_with_details(current_user.superadmin? ? nil : current_user&.id)\n @study_statistics_by_id = Study.get_study_statistics(studies: @studies)\n authorize! :read, StudyCompletion\n end",
"def index\n @stats = Stat.all\n end",
"def index\n @stats = Stat.all\n end",
"def index\n @stats = Stat.all\n end",
"def overview\n authorize! :show, @pool\n (@response, @document_list) = get_search_results(rows:0)\n respond_to do |format|\n format.json { render :json=>{id:@pool.id, models:@pool.models.as_json, perspectives:@pool.exhibits.as_json, facets:@response[\"facet_counts\"][\"facet_fields\"], numFound:@response[\"response\"][\"numFound\"] } } \n end\n end",
"def index\n @stats = Stat.all\n end",
"def facets\n @solr_data[:facets]\n end",
"def total\n @solr_data[:total]\n end",
"def get_statistics\n raise 'Method unavailable for Synergy'\n end",
"def stats\n ## TODO:\n end",
"def get_node_solr_cores\n params = {:action => \"STATUS\"}\n node_solr_cores = solr_core_api(node['ipaddress'], node['port_no'], params)\n return node_solr_cores[\"status\"].keys\n end",
"def http_statistics\n super\n end",
"def render_solr_core\n unless request.host == 'search.library.cornell.edu' or request.host == 'catalog.library.cornell.edu'\n core = Blacklight.connection_config[:url]\n # Remove http protocol string\n start = core.rindex(/:\\/\\//) + 3\n display = '<p class=\"solr-core\">Solr core: ' + core[start..-1] + '</p>'\n display.html_safe\n end\n end",
"def get_statistics\n response = get_siteinfo('statistics')\n ret = {}\n response['query']['statistics'].each { |k, v| ret[k] = v }\n ret\n end",
"def admin_repository_stats\n get_admin_stats \"repos\"\n end",
"def admin_users_stats\n get_admin_stats \"users\"\n end",
"def username_solr\n self.username\n end",
"def solr_powered?\n self.solr_powered\n end",
"def stats\n repo = Repo.find(params[:id])\n\n render(:json => CodeburnerUtil.get_repo_stats(repo.id))\n rescue ActiveRecord::RecordNotFound\n render(:json => {error: \"Service or findings not found}\"}, :status => 404)\n end",
"def facets\n @solr_data[:facets]\n end",
"def stats\n @server.make_json_request('show.stats', tvdbid: @tvdbid)['data']\n end",
"def statistics\n @survey = Survey.find(params[:survey_id])\n @result = @survey.results.find(params[:id])\n end",
"def stats\n @db.command({:collstats => @name})\n end",
"def stats\n @client.stats\n end",
"def solr\n @solr ||= RSolr.connect(url: solr_url)\n end",
"def recent_status_solr_score\n Geomonitor.document_solr_score(name)\n end",
"def show\n if cookies[:message_shown].nil? && request.env['HTTP_USER_AGENT'] =~ /Firefox/\n flash.now[:notice] = \"To view the high-quality images for this item in Firefox, you'll need to change some browser settings\"\n end\n deprecated_response, @document = search_service.fetch(solr_id)\n @response = ActiveSupport::Deprecation::DeprecatedObjectProxy.new(deprecated_response, 'The @response instance variable is deprecated; use @document.response instead.')\n respond_to do |format|\n format.html { @search_context = setup_next_and_previous_documents }\n format.json\n additional_export_formats(@document, format)\n end\n if @document[:has_model_ssim][0] == 'Collection'\n facet_member_of_collections = blacklight_config.facet_fields['member_of_collections_ssim']\n if facet_member_of_collections\n @response_collection = search_service.facet_field_response(facet_member_of_collections.key, \"f.member_of_collections_ssim.facet.contains\" => @document[:title_tesim][0])\n @display_facet = @response_collection.aggregations[facet_member_of_collections.field]\n if @display_facet&.items && @display_facet.items.first\n @collection_count = @display_facet.items.first.hits\n end\n end\n end\n end",
"def stats\n response[\"stats\"]\n end",
"def get_search_results(extra_controller_params={})\n Blacklight.solr.find self.solr_search_params(extra_controller_params)\n end",
"def admin_hooks_stats\n get_admin_stats \"hooks\"\n end",
"def debug\n @solr_data[:debug]\n end",
"def collect_all_stats()\n\n begin\n\n time = Time.now\n\n medusaLogWriter = nil\n if (@enable_medusa == true)\n medusaLogger = Logger.new(File.new(@medusa_log_file, File::WRONLY | File::CREAT | File::TRUNC))\n # Ruby logger.formatter supports four input parameters : |severity, datetime, progname, msg|, here, we only need to pass msg into the proc.\n medusaLogger.formatter = proc { |_s, _d, _p, msg| \"#{msg}\\n\" }\n medusaLogWriter = MedusaLogWriter.new(medusaLogger)\n end\n\n graphiteWriter = nil\n if (@graphite_hosts != nil)\n # @environment holds the environment_profile, eg: dev/ prod/ qa/stg\n # @environment_name holds the user defined environment name. eg: datacenter name in ms-df-solrcloud prod clusters\n graphiteWriter = GraphiteWriter.new(@prefix, @environment, @node_ip, @graphite_hosts, @datacenter, @environment_name)\n graphiteWriter.open_tcp_sockets\n end\n\n # keeping both the node status metrics and jmx metrics separately since our JMX metrics scripts could stop working for any reason\n # (eg, metric names changes with diff solr versions etc).\n # If it breaks, telegraf will block all metrics that comes from jmx metrics file.\n # So better to keep node status metrics separately from JMX metrics. Telegraf will read from both at any point of time provided jmx_metrics are enabled.\n if (@enable_rest_metrics == \"true\" || @enable_jmx_metrics == \"true\")\n get_solr_node_status(time, medusaLogWriter, graphiteWriter)\n end\n\n if (@enable_rest_metrics == \"true\")\n # Get the metrics from Solr REST APIs\n SolrClusterSummaryStats.get_stats(@hostname, @port, time, medusaLogWriter, graphiteWriter, @solr_version, @collections)\n end\n\n if (@enable_jmx_metrics == \"true\")\n jmx_medusaLogWriter = nil\n if (@enable_medusa == true)\n jmx_medusaLogger = Logger.new(File.new(@jmx_medusa_log_file, File::WRONLY | File::CREAT | File::TRUNC))\n # Ruby logger.formatter supports four input parameters : |severity, datetime, progname, msg|, here, we only need to pass msg into the proc.\n jmx_medusaLogger.formatter = proc { |_s, _d, _p, msg| \"#{msg}\\n\" }\n jmx_medusaLogWriter = MedusaLogWriter.new(jmx_medusaLogger)\n end\n mbean_sum_stat_obj = SolrMBeanSummaryStats.new(jmx_medusaLogWriter, graphiteWriter, @metric_level, @jolokia_port, @solr_jmx_port, @solr_version, time)\n mbean_sum_stat_obj.collect_jmx_metrics()\n end\n\n rescue Exception => e\n puts \"collect_all_stats:exception: #{e}\"\n ensure\n if (@graphite_hosts != nil)\n graphiteWriter.close_tcp_sockets\n end\n end\n\n end",
"def stats\n end",
"def stats\n end",
"def show_site_stats # :nologin: :norobots:\n store_location\n @site_data = SiteData.new.get_site_data\n\n # Add some extra stats.\n @site_data[:observed_taxa] = Name.connection.select_value %(\n SELECT COUNT(DISTINCT name_id) FROM observations\n )\n @site_data[:listed_taxa] = Name.connection.select_value %(\n SELECT COUNT(*) FROM names\n )\n\n # Get the last six observations whose thumbnails are highly rated.\n query = Query.lookup(:Observation, :all,\n by: :updated_at,\n where: \"images.vote_cache >= 3\",\n join: :\"images.thumb_image\")\n @observations = query.results(limit: 6,\n include: { thumb_image: :image_votes })\n end",
"def index\n @response, @documents = get_solr_response_for_field_values(\"id\",session[:folder_document_ids] || [])\n end",
"def stats\n return self.endpoint.stats(self.id)\n end",
"def list_stats\r\n puts \"#{@name} Stats:\"\r\n puts \"Total HP: #{@hp}\"\r\n puts \"Class: #{@job}\"\r\n puts \"Total Strength: #{@strength}\"\r\n puts \"Total Speed: #{@speed}\"\r\n end",
"def pacscl_xml\n document = Blacklight.default_index.search(q: \"id:#{params[:id]}\")&.dig(\"response\", \"docs\")&.first\n document = SolrDocument.new(document)\n document.suppress_xml_containers!\n respond_to do |format|\n format.xml do\n render xml: document.export_as_xml\n end\n end\n end",
"def index\n @tw_stats = TwStat.all\n end",
"def stats\n @page_title = I18n.t(\"statistics\")\n redirect_to root_url unless current_user.is_admin? # don't release this yet...it's not ready for public consumption\n @stats = PageStatsTaxon.latest\n end",
"def url\n \"http://127.0.0.1:#{port}/solr/\"\n end",
"def index\n @sub_stats = SubStat.all\n end",
"def index\n\t\tpage_size = 10\n\t\t# If :q is passed in, it is a regular query string that we need to clean of weird characters.\n\t\t# If :qq is passed in, it is an advanced query string that we should pass verbatim.\n\t\t@query_string = params[:q]\n\t\tif @query_string\n\t\t\tsession[:search_current] = @query_string\n\t\t\t@query_string = @query_string.gsub(/[^\\w\\- ]/, '') if @query_string\n\t\telse\n\t\t\t@query_string = params[:qq]\n\t\t\tsession[:search_current] = @query_string\n\t\tend\n\t\t@curr_page = params[:page] || '0'\n\t\t@curr_page = @curr_page.to_i\n\t\thsh = { :query => @query_string, :start => @curr_page*page_size, :page_size => page_size }\n\t\tif session[:search_only_students] == 'true'\n\t\t\thsh[:schools] = [ 'school:LLS', 'school:LFA']\n\t\tend\n\t\tresponse_hash = solr().search(hsh)\n\t\t@page_title = 'Student List'\n\t\tif response_hash[:error]\n\t\t\t@error_msg = response_hash[:error]\n\t\t\t@total_hits = 0\n\t\t\t@total_pages = 1\n\t\t\t@students = []\n\t\t\tlogger.warn \"Search Query Error: #{@error_msg} ||||| /#{@query_string}/\"\n\t\telse\n\t\t\tresponse = response_hash[:response]\n\t\t\t@suggestions = response_hash[:suggestions]\n\t\t\t@total_hits = response['numFound']\n\t\t\t@total_pages = ((@total_hits + 0.0) / page_size).ceil()\n\t\t\t@students = Student.convert_solr_response(response['docs'])\n\t\tend\n\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\t\tformat.xml { render :xml => @students }\n\t\tend\n\tend",
"def index_stats\n Boson::Index.read\n Boson::Index.indexes.each do |repo|\n option_cmds = repo.commands.select {|e| !e.options.to_s.empty? }\n render_option_cmds = repo.commands.select {|e| !e.render_options.to_s.empty? }\n puts \"\\n=== Repo at #{repo.repo.dir} ===\"\n render [[:libraries, repo.libraries.size], [:commands, repo.commands.size],\n [:option_commands, option_cmds.size], [:render_option_commands, render_option_cmds.size], ]\n end\n nil\n end",
"def quick_stats\n\tend",
"def stats\n\t\t@counts\n\tend",
"def ping_solr\n begin\n solr = RSolr.connect :url => 'http://localhost:8983/solr'\n response = solr.get 'select', :params => {:q => '*:*'}\n puts 'Solr is up!'\n return\n rescue Errno::ECONNREFUSED\n puts 'Solr not up yet, sleeping for 10 seconds... zzz'\n sleep 10\n ping_solr\n end\n end",
"def solr_during_indexing\n {\n \"has_model_ssim\" => [\"Collection\"],\n :id => object.id,\n \"title_tesim\" => [object.title.first.to_s],\n \"title_sim\" => [object.title.first.to_s],\n \"collection_type_gid_ssim\" => [object.collection_type_gid],\n \"ark_ssi\" => object.ark,\n \"ursus_id_ssi\" => Californica::IdGenerator.blacklight_id_from_ark(object.ark),\n \"member_ids_ssim\" => [],\n \"object_ids_ssim\" => [],\n \"member_of_collection_ids_ssim\" => [], \"collection_ids_ssim\" => [],\n \"generic_type_sim\" => [\"Collection\"],\n \"bytes_lts\" => 0,\n \"visibility_ssi\" => \"restricted\"\n }\n end",
"def get_solr_response_for_doc_id(id=nil, extra_controller_params={})\n Blacklight.solr.find solr_doc_params(id, extra_controller_params)\n end",
"def index\n @statistics = Statistic.all\n end",
"def index\n @statistics = Statistic.all\n end",
"def index\n @statistics = Statistic.all\n end",
"def solr_core_api(host_name,port,params,path=\"/solr/admin/cores\")\n path = \"#{path}?\".concat(params.collect { |k,v| \"#{k}=#{CGI::escape(v.to_s)}\" }.join('&'))+\"&wt=json\"\n Chef::Log.info(\" HostName = \" + host_name + \", Port = \" + port + \", Path = \" + path)\n http = Net::HTTP.new(host_name, port)\n req = Net::HTTP::Get.new(path)\n unless !SolrAuth::AuthUtils.auth_enabled?\n admin_creds = SolrAuth::AuthUtils.get_solr_admin_credentials\n req.basic_auth(admin_creds['username'], admin_creds['password'])\n end\n response = http.request(req)\n if response != nil then\n return JSON.parse(response.body())\n end\n raise StandardError, \"empty response\"\n end",
"def stats\n StatsManager::StatsD.time(Settings::StatsConstants.api['user']['stats']) do\n if params[:id] == current_user.id.to_s\n # A regular user can only view his/her own stats\n @user = current_user\n elsif current_user.is_admin\n # admin users can view anyone's stats\n unless @user = User.where(:id => params[:id]).first\n return render_error(404, \"could not find that user\")\n end\n else\n return render_error(401, \"unauthorized\")\n end\n\n @status = 200\n num_recent_frames = params[:num_frames] ? params[:num_frames].to_i : Settings::UserStats.num_recent_frames\n @stats = GT::UserStatsManager.get_dot_tv_stats_for_recent_frames(@user, num_recent_frames)\n @stats.each {|s| s.frame.creator[:shelby_user_image] = s.frame.creator.avatar_url}\n end\n end",
"def stats\n @client.command(dbStats: 0).documents[0]\n end",
"def stats\n @client.command(dbStats: 0).documents[0]\n end",
"def index\n @runstats = Runstat.all\n end",
"def index\n @users = User.all(include: :stats)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { head :ok }\n end\n end",
"def index\n @gls = Gl.all\n end",
"def summary_site\n \t\tAPI.get_site_wordcount\n \tend",
"def statistics\n super\n end",
"def statistics\n super\n end",
"def statistics\n super\n end",
"def statistics\n super\n end",
"def statistics\n super\n end",
"def statistics\n super\n end",
"def statistics\n super\n end",
"def statistics\n super\n end",
"def statistics\n super\n end",
"def statistics\n super\n end",
"def statistics\n super\n end",
"def statistics\n super\n end",
"def index\n @solr = Solr.instance.connect\n callback = params.delete('callback') || 'callback'\n rows = [params.delete('rows').to_i, 100].min\n data = begin\n @solr.get('select', params: params.except(:action, :format, :controller).merge(rows: rows))\n rescue => e\n # RSolr dictates that responses be ruby data structures,\n # but the eval still scares me.\n eval(e.response[:body])\n end\n json = JSON.pretty_generate(data)\n respond_to do |format|\n format.js do\n render text: \"#{callback}(#{json});\",\n status: data['error'] ? 500 : 200\n end\n format.json do\n render text: json,\n status: data['error'] ? 500 : 200\n end\n format.xml do\n render text: data.to_xml,\n status: data['error'] ? 500 : 200\n end\n end\n end",
"def show_everything(solr_parameters)\n solr_parameters[:fq] ||= []\n solr_parameters[:fq] << 'internal_resource_ssim:(\"Collection::Archival\" OR \"Collection::Library\"' \\\n 'OR \"Collection::Curated\" OR \"Work::Submission\" OR \"Work::FileSet\")'\n end",
"def total\n @total ||= solr_response['numFound'] || 0\n end",
"def total\n @total ||= solr_response['numFound'] || 0\n end",
"def admin_pull_requests_stats\n get_admin_stats \"pulls\"\n end",
"def stats\n \n end"
] |
[
"0.654221",
"0.6466917",
"0.64406633",
"0.6387317",
"0.6387317",
"0.6262488",
"0.6156257",
"0.6109965",
"0.6075348",
"0.60701334",
"0.6035382",
"0.60095936",
"0.59551084",
"0.59423053",
"0.5930332",
"0.58983016",
"0.5861903",
"0.5861903",
"0.5857144",
"0.5856435",
"0.58140063",
"0.58123",
"0.5790412",
"0.5790412",
"0.5790412",
"0.57573056",
"0.5746784",
"0.57447046",
"0.57297873",
"0.57265407",
"0.57195383",
"0.571749",
"0.5716047",
"0.5713276",
"0.57105356",
"0.5688378",
"0.56849265",
"0.5642338",
"0.5639279",
"0.5629346",
"0.56170446",
"0.56148446",
"0.56057787",
"0.55746037",
"0.554922",
"0.55459684",
"0.554056",
"0.5538716",
"0.55189043",
"0.55140495",
"0.55079156",
"0.5501781",
"0.5500004",
"0.5492399",
"0.5492399",
"0.5490659",
"0.5476203",
"0.5473241",
"0.5471398",
"0.54646987",
"0.5451383",
"0.54438543",
"0.5435288",
"0.5433164",
"0.54193646",
"0.54118234",
"0.5403884",
"0.5398423",
"0.5391979",
"0.5380782",
"0.53769547",
"0.5371186",
"0.5371186",
"0.5371186",
"0.5367529",
"0.53647876",
"0.5354956",
"0.5354956",
"0.53509086",
"0.5339921",
"0.5337838",
"0.5323434",
"0.5320683",
"0.5320683",
"0.5320683",
"0.5320683",
"0.5320683",
"0.5320683",
"0.5320683",
"0.5320683",
"0.5320683",
"0.5320683",
"0.5320683",
"0.5320683",
"0.5320378",
"0.532031",
"0.53130215",
"0.53130215",
"0.53096986",
"0.53078514"
] |
0.8535216
|
0
|
== GET /about/eds Administratoronly EBSCO EDS information.
|
def eds
@eds_session = get_eds_session
@eds_fields = get_eds_fields
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n @eds = Ed.all\n end",
"def show\n @emedidor = Emedidor.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @emedidor }\n end\n end",
"def show\n @user = User.find(params[:user_id])\n @eod = Eod.find_by(params[:id]) \n end",
"def show\n @etd = Etd.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @etd }\n end\n end",
"def show\n raise Exceptions::EducatorNotAuthorized unless current_educator.districtwide_access\n educator = Educator.find(params[:id])\n render json: educator.as_json({\n :only => [\n :id,\n :email,\n :full_name,\n :staff_type,\n :restricted_to_sped_students,\n :restricted_to_english_language_learners,\n :can_view_restricted_notes,\n :schoolwide_access,\n :districtwide_access,\n :grade_level_access,\n :admin\n ],\n :methods => [:labels],\n :include => {\n :school => { :only => [:id, :name] },\n :sections => {\n :only => [:id, :section_number],\n :methods => [:course_description]\n },\n :homeroom => { :only => [:id, :name] }\n }\n })\n end",
"def show\n if administrador?\n @emergencium = Emergencium.find(params[:id])\n else\n @entidade = Entidade.where(\" user_id = ?\", current_user.id)\n @emergencium = Emergencium.find(params[:id], :conditions => [\" entidade_id = ?\", @entidade[0].id]) rescue nil\n render :action => \"index\" if @emergencium.nil?\n end\n end",
"def index\n @educ_infos = EducInfo.all\n end",
"def show\n @edetail = Edetail.find_by(id: params[:id])\n end",
"def show\n @ep = Ep.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @ep }\n end\n end",
"def show\n @edu_detail = EduDetail.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @edu_detail }\n end\n end",
"def index\n @elders = Elder.all\n end",
"def index\n @esses = Esse.all\n end",
"def show\n @emm_details = Emm.get_emm_details(@emm.id, get_user_id)\n end",
"def show\n @ecnuser = Ecnuser.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @ecnuser }\n end\n end",
"def about_us\n # it's deliberate that there's no code in here... but we should have a helpful error when we request the URL again\n end",
"def show\n @educators = Educator.where(verified: [false, nil]).all\n @dmcas = Dmca.all\n end",
"def index\n @emergencies = Emergency.all\n end",
"def index\n # This should never be called, just used for debugging\n @emergencies = Emergency.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @emergencies }\n end\n end",
"def index\n @guest_educators = GuestEducator.all\n end",
"def show\n @ecg = Ecg.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ecg }\n end\n end",
"def index\n @g4_dongal_board_edus = G4DongalBoardEdu.all\n end",
"def index\n @edesalfacts = Edesalfact.all\n end",
"def show\n @deed = Deed.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @deed }\n end\n end",
"def index\n @efemerides = Efemeride.all\n end",
"def index\n @erds = Erd.find_for_available(@project.id)\n end",
"def index\n @educators = Educator.all\n end",
"def index\n @educators = Educator.all\n end",
"def index\n if current_user.admin == 0\n @eleves_cu = @eleves.where(:user_id => current_user.id).all\n end\n end",
"def show\n @etsy = Etsy.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @etsy }\n end\n end",
"def show\n # This should never be called, just used for debugging\n @emergency = Emergency.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @emergency }\n end\n end",
"def show\n # implicit :get_sesh\n end",
"def show\n @enterprise_datum = EnterpriseDatum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @enterprise_datum }\n end\n end",
"def index\n @edrives = Edrive.all\n end",
"def index\n @demande_egs = DemandeEg.all\n end",
"def index\n @general_educators = GeneralEducator.all\n end",
"def show\n @e_date = EDate.find(params[:id])\n end",
"def show\n @estruturaindicebh = Estruturaindicebh.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @estruturaindicebh }\n end\n end",
"def show\n @estate = Estate.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @estate }\n end\n end",
"def show\n @diocese = Diocese.find(params[:id])\n end",
"def index\n @ephems = Ephem.page(params[:page])\n end",
"def index\n @employee = Employee.find(params[:employee_id])\n @direct_deposits = @employee.direct_deposits.all\n skip_authorization\n end",
"def index\n @epiphanies = Epiphany.all\n end",
"def show\n @emoneyout = Emoneyout.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @emoneyout }\n end\n end",
"def eadid\n first('ead_ssi')&.strip || collection&.first('ead_ssi')&.strip\n end",
"def show\n # Not showing hacker info right now, perhaps this will be a profile page in the future.\n redirect_to entries_path\n end",
"def show\n @descriptor_especifico = DescriptorEspecifico.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @descriptor_especifico }\n end\n end",
"def show\n @energy_datum = EnergyDatum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @energy_datum }\n end\n end",
"def show\n @eicon = Eicon.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @eicon }\n end\n end",
"def show\n if(params[\"format\"] != \"json\")\n if(is_admin)\n AllSeeingEye.create(ip: request.remote_ip, message: AllSeeingEye.create_message(@time_hole,\"Show One Caretaker\"))\n else\n AllSeeingEye.create(ip: request.remote_ip, message: AllSeeingEye.create_message(nil,\"Failed Show One Caretaker\"))\n render json: {error: \"You don't look like an admin to me. Who authorized this?\"}, status: 400\n end\n end\n end",
"def show\n @endorsement = Endorsement.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @endorsement }\n end\n end",
"def show\n @electoral_district = ElectoralDistrict.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @electoral_district }\n end\n end",
"def show\n @purpose_def = PurposeDef.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @purpose_def }\n end\n end",
"def show\n @digital_edition = DigitalEdition.find(params[:id])\n @desc_snippet = @digital_edition.digital_edition_description\n if @desc_snippet.length > 50\n @desc_snippet = @desc_snippet[0..49] + \"...\"\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @digital_edition }\n end\n end",
"def index\n @dor_informations = DorInformation.all\n end",
"def district_info_get\n @body_class = 'district'\n @admin = current_admin_user # TODO auth\n @district = @admin.district\n\n @saved = false\n return render 'district_info'\n end",
"def index\n @educational_details = EducationalDetail.all\n end",
"def attendees(event)\n get(:standard, {:method => \"event.getAttendees\", :event => event})\n end",
"def show\n @attendee = Attendee.find(params[:id])\n if @attendee.event_id != session[:current_event_id].to_i\n flash[:error] = t(:not_correspond)\n redirect_to attendees_path and return\n end\n @workshops = Workshop.joins(\"INNER JOIN attendee_workshops a ON workshops.id = a.workshop_id\")\n .joins(\"INNER JOIN attendees at ON a.attendee_id = at.id\")\n .where(\"at.id = ?\", @attendee.id)\n @expositions = Exposition.joins(\"INNER JOIN attendee_expositions a ON expositions.id = a.exhibitor_id\")\n .joins(\"INNER JOIN attendees at ON a.attendee_id = at.id\")\n .where(\"at.id = ?\", @attendee.id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @attendee }\n end\n end",
"def index\n drop_page_title(\"员工服务类别管理\")\n drop_breadcrumb\n @em_ser_cates = EmSerCate.cache_all\n end",
"def show\n @announcements = @cpd_event.announcements\n end",
"def index\n @energies = Energy.all\n end",
"def show\n @empsked = Empsked.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @empsked }\n end\n end",
"def educational_attainment\n fetch('demographic.educational_attainment')\n end",
"def show\n @especial = Especial.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @especial }\n end\n end",
"def index\n authorize! :index, Employee\n if current_employee.admin?\n @developers = @organization.employees.developers\n else\n raise CanCan::AccessDenied.new(\"Not authorized!\", :read, Employee)\n end\n end",
"def show\n authorize @orden\n end",
"def demon\n fetch('naruto.demons')\n end",
"def index\n @esod_outgoing_letters = Esod::OutgoingLetter.all\n end",
"def index\n @educates = Educate.all\n end",
"def show\n @eou = Eou.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @eou }\n end\n end",
"def show\n @eg_post = EgPost.find(params[:id])\n authorize @eg_post\n end",
"def show\n \n @erp = Erp.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json=> @erp }\n end\n end",
"def index\n @elder_gallaries = current_user.elder_gallaries rescue nil\n end",
"def show\n @eg_post = EgPost.find(params[:id])\n authorize @eg_post\n end",
"def show\n @user = User.new\n @response = HTTParty.get(\"https://www.eventbriteapi.com/v3/events/#{@event.event_id}/attendees/?token=R3MLTYFWNHNDB53GOBCP\")\n @response1 = HTTParty.get(\"https://www.eventbriteapi.com/v3/events/#{@event.event_id}/?token=R3MLTYFWNHNDB53GOBCP\")\n @peeps = @response['attendees']\n @event_name = @response1['name']['text']\n end",
"def show\n @enterprise = Enterprise.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @enterprise }\n end\n end",
"def show\n #TODO - only admin should be access people besides themselves\n @events = @user.events.all\n respond_to do |format|\n format.html\n format.json { render :json => { :user => @user } }\n end\n end",
"def index\n @ejes = Eje.all\n end",
"def show\n @emprendedor = Emprendedor.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @emprendedor }\n end\n end",
"def show\n @event = Event.shod(params[:id])\n @batches ||= Batch.all\n @departments ||= EmployeeDepartment.all\n authorize! :read, @event\n end",
"def show\n @expertise = current_user.expertises.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @expertise }\n end\n end",
"def index\n\t\tif current_admin.full_access? || current_admin.partial_access?\n\t\t\t@equipaments = Equipament.all\n\t\telse\n\t\t\tredirect_to \"/404.html\"# configurar pagina 403\n\t\tend\n\tend",
"def show\n @idata = @demand_response.dr_properties\n rescue RestClient::Exception, Errno::ECONNREFUSED => e\n @idata = @demand_response.dr_properties\n flash.now[:alert] = \"Failed to connect to GDRMS\"\n\n Rails.logger.debug e.message\n Rails.logger.debug e.response if e.respond_to? :response\n end",
"def show\n @estudio = Estudio.find(params[:id])\n\n respond_to do |format|\n format.xml { render :xml => @estudio }\n end\n end",
"def inportant_information\n RubyRedtail::Query.run(\"contacts/#{@id}/importantinfo\", @api_hash, \"GET\")\n end",
"def show\n @entradas = Entrada.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @entradas }\n end\n end",
"def show\n @evclient = Evclient.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @evclient }\n end\n end",
"def show\n @emirate = Emirate.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @emirate }\n end\n end",
"def show\n require 'uri'\n @event = EventOwner.find(params[:id])\n @is_admin = current_user && current_user.id == @event.id\n end",
"def show\n @attendee = Attendee.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @attendee }\n end\n end",
"def show\n @estatu = Estatu.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @estatu }\n end\n end",
"def info_for_edit_page\n @is_super_adm = is_super?\n\n if @is_super_adm\n # Loading Choosing of adm\n @admins = User.admins_list\n\n if @admins.empty?\n @mentors = [@admins]\n else\n employee = @user.client.employee\n if employee.present?\n @admins_cur = employee.employee_id\n @mentors_cur = @user.client.employee_id\n else\n @admins_cur = params[:administrator_id]\n @mentors_cur = 0\n end\n @mentors = User.mentors_list(@admins_cur, additional_users: User.all_local_admins)\n end\n elsif current_user.local_admin?\n @mentors = User.mentors_list(current_user.role_model.id, additional_users: [current_user])\n @mentors_cur = @user.client.employee_id\n end\n end",
"def show\n @evactivity = Evactivity.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @evactivity }\n end\n end",
"def show\n @eob = Eob.find(params[:id])\n # if the eob is assigned, bring up the claim details in the right sidebar\n @display_sidebar = true\n if !@eob.insurance_billing_id.blank?\n @patient = Patient.find(@eob.patient_id)\n @claim = @eob.insurance_billing(:joins => [:insurance_session, :subscriber])\n @office = @claim.insurance_session.office\n @claim_office = @claim.insurance_session.billing_office\n else\n # tell the right sidebar to pull data for unassigned eob\n @pull_from_eob = true\n end\n session[:return_to] = eobs_path\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @eobs }\n end\n end",
"def index\n @esselines = Esseline.all\n end",
"def show\n @event = Event.find(params[:id])\n @event_attendees = Event.find(params[:id]).attendees\n end",
"def show\n @discovery = Discovery.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @discovery }\n end\n end",
"def show\n @attendee = Attendee.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @attendee }\n end\n end",
"def index\n @despesas = @condominio.despesas\n end",
"def index\n @eita = Eitum.all\n end"
] |
[
"0.61865294",
"0.6038151",
"0.6032974",
"0.59458154",
"0.5898988",
"0.5857836",
"0.5843201",
"0.5842271",
"0.57661015",
"0.5714306",
"0.56690526",
"0.5663047",
"0.5659392",
"0.56367344",
"0.56284386",
"0.562764",
"0.56273156",
"0.5614681",
"0.5614054",
"0.5579406",
"0.55793226",
"0.55662817",
"0.55462325",
"0.55433583",
"0.55391467",
"0.5536361",
"0.5536361",
"0.55144143",
"0.5513889",
"0.5503178",
"0.54835004",
"0.54794776",
"0.5468466",
"0.54632306",
"0.5439469",
"0.5433272",
"0.5432475",
"0.54197246",
"0.5418908",
"0.54139906",
"0.541153",
"0.54042953",
"0.54004663",
"0.5394358",
"0.5394096",
"0.5385992",
"0.5382285",
"0.5367434",
"0.5365111",
"0.535154",
"0.5351168",
"0.5350865",
"0.5337117",
"0.5337031",
"0.5328189",
"0.5327719",
"0.5323861",
"0.53206104",
"0.53189385",
"0.5318324",
"0.53182214",
"0.53180766",
"0.53063154",
"0.53049475",
"0.5287108",
"0.52803147",
"0.5274756",
"0.5274503",
"0.5271591",
"0.5270189",
"0.5263042",
"0.5262618",
"0.5257286",
"0.5253334",
"0.5251484",
"0.5249647",
"0.52458715",
"0.5244763",
"0.52428573",
"0.5237812",
"0.5234579",
"0.52195996",
"0.5219118",
"0.5213021",
"0.5212237",
"0.52112347",
"0.5202057",
"0.51994455",
"0.5193057",
"0.51929533",
"0.5192365",
"0.51923335",
"0.51904",
"0.5189958",
"0.5186694",
"0.51838636",
"0.5183701",
"0.5182596",
"0.5182541",
"0.5182442"
] |
0.578008
|
8
|
== GET /about/log Administratoronly application log viewer.
|
def log
count = default_log_lines(params)
lines = get_file_lines(log: true, tail: count)
respond_with(lines)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def show\n unless current_user.has_role? :admin\n flash[:alert] = \"Access To Logs Denied\"\n redirect_to root_path\n end\n end",
"def logs(app_name)\n\t\tget(\"/apps/#{app_name}/logs\")\n\tend",
"def logs_for(application)\n logs_at_url(get(\"/apps/#{application}/logs?logplex=true\", 2))\n end",
"def index\n if current_user.admin\n @logs = Log.all\n \n\telse\n\t@logs = Log.where(:reference_code => current_user.content_code)\n\t@clientlogs = Log.where(:client_code => current_user.client_code)\n\tend\n end",
"def logs(app_name)\n deprecate # 07/31/2012\n get(\"/apps/#{app_name}/logs\").to_s\n end",
"def show\n @user = User.find(params[:user_id])\n @log = @user.logs.find(log_params[:id])\n end",
"def show\n @clothing_log = current_account.clothing_logs.find(params[:id])\n authorize! :view, @clothing_log\n respond_with @clothing_log\n end",
"def index\n if current_user\n @device = Device.find(params[:device_id])\n if current_user.is_admin?\n @devices = Device.all\n else\n @devices = Device.where(:user_id => current_user.id)\n end\n @logs = Log.where(:device_id => @device.id).paginate(:page => params[:page], :per_page => 5)\n else\n redirect_to devices_path, :notice => \"You can only view logs of your devices\"\n end\n end",
"def show\n authorize @shooting_log\n end",
"def show\n\tif user_signed_in?\n\t\t@eventlog = Eventlog.find(params[:id])\n\n\t\trespond_to do |format|\n\t\t format.html # show.html.erb\n\t\t format.json { render json: @eventlog }\n\t\tend\n\telse\n\t\tflash[:notice] = \"You don't have access to do that\"\n\t\tredirect_to :controller=>'home', :action => 'index'\n\tend\n end",
"def logs\n\n end",
"def logs\n end",
"def my_application_log_entries\n @logging.entries(\n filter: %(logName=\"#{my_application_log_name}\")\n )\n end",
"def log\n @client.get(\"#{path}/log\")\n end",
"def history\n\t\t@user.show_log\n\tend",
"def logme\n\t\tlogger.debug \"============Main ApplicationController get calls at #{Time.now}\"\n\tend",
"def show\n @log = @client.logs.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @log }\n end\n end",
"def edit\n @log = set_log\n unless current_user.admin?\n redirect_to logs_path\n end\n end",
"def log_wipe\n lines = wipe_log\n respond_with(lines, template: 'about/log')\n end",
"def index\n if current_user.has_role? :admin\n @shift_logs = ShiftLog.all.order(change_date: :desc)\n @date_value = nil\n else\n @shift_logs = []\n flash[:alert] = \"Access To Logs Denied\"\n redirect_to root_path\n end\n end",
"def show\n @log = Dmt::SiteLogger::Log.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @log }\n end\n end",
"def show_kannel_log\n @header = 'Kannel Log'\n @lines = `tail -200 log/kannel.log`\n render(:template => \"admin/show_lines\")\n end",
"def show\n @log = Log.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @log }\n end\n end",
"def show\n @log = Log.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @log }\n end\n end",
"def logs\n ret = @uri.logs\n render plain: ret[:message], status: ret[:status]\n end",
"def show\n @user_log = UserLog.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user_log }\n end\n end",
"def show\n @current_user = current_user\n not_found and return unless @timelog.user == @current_user\n end",
"def fetch_log\n assert_privileges(\"fetch_log\")\n disable_client_cache\n send_data(fetch_local_log(\"evm\"), :filename => \"evm.log\")\n AuditEvent.success(:userid => session[:userid], :event => \"download_evm_log\", :message => \"EVM log downloaded\")\n end",
"def access_logger\n Rails.application.config.another_logger.info(\"#{request.method} '#{request.path}' #{request.version} from: #{request.remote_ip}\")\n end",
"def show\n @log_entry = LogEntry.find(params[:id])\n end",
"def show\n @log = Log.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @log }\n end\n end",
"def index\n @server_monitor_logs = ServerMonitorLog.fetch_log(params) \n end",
"def log\n advanced[:log]\n end",
"def show\n @applicationlog = Applicationlog.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @applicationlog }\n end\n end",
"def index\n @current_user = current_user\n @timelogs = @current_user.timelogs\n end",
"def show\n @user = current_user;\n @toeic_log = ToeicLog.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @toeic_log }\n end\n end",
"def index\n @logs = Log.all\n end",
"def logs\n system \"tail -f ~/Library/Logs/Pow/access.log\"\n end",
"def show\n @log = Log.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @log }\n end\n end",
"def show\n @log = Log.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @log }\n end\n end",
"def show\n if current_user.admin?\n @event_log = EventLog.find(params[:id])\n else\n @event_log = EventLog.by_initiator(current_user.supervisor).by_mode_type(@mode_type).by_event_type(@event_type).by_id(params[:id])\n end\n end",
"def show\n authorize @news_log\n end",
"def index\n\t\t\t@logs = AppTracker::Log.order('created_at DESC').paginate(:page => params[:page], :per_page => 50)\n\t\tend",
"def show\n render json: @log\n end",
"def get_logs(opts = {})\n @transporter.read(:GET, '/1/logs', {}, opts)\n end",
"def new\n\tif user_signed_in?\n\t\t@eventlog = Eventlog.new\n\n\t\trespond_to do |format|\n\t\t format.html # new.html.erb\n\t\t format.json { render json: @eventlog }\n\t\tend\n\telse\n\t\tflash[:notice] = \"You don't have access to do that\"\n\t\tredirect_to :controller=>'home', :action => 'index'\n\tend\n end",
"def show\n @log_entry = LogEntry.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @log_entry }\n end\n end",
"def index # :nologin:\n list_rss_logs\n end",
"def log_entries\n @user = User.find(params[:id])\n @log_entries = LogEntry.where(:user_id => @user.id).page(params[:page] || 1)\n end",
"def index\n @accession_logs = AccessionLog.all\n end",
"def index\n @systemlogs = Systemlog.all\n end",
"def show_rss_log # :nologin:\n pass_query_params\n store_location\n @rss_log = find_or_goto_index(RssLog, params[\"id\"])\n end",
"def log_view(url, manual_expiration: false)\n record = {}\n\n # 0 - standard user view\n # 1 - manual expiration\n record[:kind] = manual_expiration ? 1 : 0\n\n record[:user_id] = current_user.id if user_signed_in?\n record[:ip] = request.env['HTTP_X_FORWARDED_FOR'].nil? ? request.env['REMOTE_ADDR'] : request.env['HTTP_X_FORWARDED_FOR']\n\n # Limit retrieved values to 256 characters\n record[:user_agent] = request.env['HTTP_USER_AGENT'].to_s[0, 255]\n record[:referrer] = request.env['HTTP_REFERER'].to_s[0, 255]\n\n record[:successful] = url.expired ? false : true\n\n url.views.create(record)\n url\n end",
"def read_log(offset, length)\n request('readLog', offset, length)\n end",
"def welcome\n __log_activity\n __debug_route\n end",
"def log\n end",
"def log\n Lita.logger\n end",
"def log(log_id)\n raise Auth0::MissingParameter, 'Must supply a valid log_id' if log_id.to_s.empty?\n path = \"#{logs_path}/#{log_id}\"\n get(path)\n end",
"def app_logger(**tags)\n logger_tags =\n { url: request.url,\n ip: request.ip,\n user_id: current_user.id,\n params: params.to_unsafe_h }.merge(tags)\n\n Helli::Logger.new(logger_tags)\n end",
"def log_request\n logger.info \"HTTP request received => #{request.fullpath} , params => #{params} \"\n end",
"def index\n @rcadmin_login_logs = Rcadmin::LoginLog.all\n end",
"def index\n Rails.logger.silence do\n render\n end\n end",
"def log\n @log\n end",
"def log_path\n \n @log_path = \"doc/mylog/articles\"\n \n end",
"def show\n @measurement_log = current_account.measurement_logs.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @measurement_log }\n end\n end",
"def index\n @user = User.find(current_user.id)\n @history_logs = @user.history_logs\n end",
"def index\n @user = current_user;\n @toeic_logs = ToeicLog.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @toeic_logs }\n end\n end",
"def log_history\n logger.info('[]' + request.method + \"\\t\" + request.fullpath + \"\\t\" + request.remote_ip + \"\\t\" + Time.now.strftime('%Y-%m-%d %H:%M:%S'))\n end",
"def show\n @dlog = Dlog.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dlog }\n end\n end",
"def cron_logs(app_name)\n\t\tget(\"/apps/#{app_name}/cron_logs\")\n\tend",
"def show\n if params[:log_type] == \"credits_logs\"\n @q = @user.credits_logs.search(params[:q])\n @credits_logs = @q.result(distinct: true).order(\"created_at DESC\")\n elsif params[:log_type] == \"wallet_logs\"\n @q = @user.wallet_logs.search(params[:q])\n @wallet_logs = @q.result(distinct: true).order(\"created_at DESC\")\n end\n end",
"def find_log\n @logs = Log.find(params[:id])\n end",
"def fetch_production_log\n assert_privileges(\"fetch_production_log\")\n disable_client_cache\n send_data(fetch_local_log(Rails.env), :filename => \"#{Rails.env}.log\")\n AuditEvent.success(:userid => session[:userid],\n :event => \"download_#{Rails.env}_log\",\n :message => \"#{@sb[:rails_log]} log downloaded\")\n end",
"def fetch_audit_log\n assert_privileges(\"fetch_audit_log\")\n disable_client_cache\n send_data(fetch_local_log(\"audit\"), :filename => \"audit.log\")\n AuditEvent.success(:userid => session[:userid],\n :event => \"download_audit_log\",\n :message => \"Audit log downloaded\")\n end",
"def log\n @log || MPDClient.log\n end",
"def show\n @time_log = TimeLog.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @time_log }\n end\n end",
"def show\n @activity_log = ActivityLog.find(params[:id])\n end",
"def get_query_access_log\n lines=`find #{Environment.instance.vespa_home}/logs/vespa/qrs -name 'QueryAccessLog*'| xargs -n 1 cat`\n return lines\n end",
"def request_log(request); end",
"def index\r\n unless read_fragment(\"#{log_owner.login}/log/index/#{params[:page]||1}/#{write_permission?}\")\r\n #Si es el dueo del log poner un botn para que pueda aadir sesiones\r\n @buttons = write_permission?\r\n\r\n conditions = \"user_id = #{log_owner.id}\"\r\n conditions << \" AND private = FALSE\" unless write_permission?\r\n\r\n #Listar las ultimas sesiones de entrenamiento (paginar)\r\n @pages, @ses = paginate(:training_sessions,\r\n :per_page =>15,\r\n :conditions => conditions,\r\n :order => 'done_on DESC, id DESC')\r\n end\r\n end",
"def show\n @server = Server.find(params[:server_id])\n @httping_log = @server.httping_logs.find(params[:id])\n\n respond_to do |format|\n format.html { render :show, layout: false } # show.html.erb\n format.json { render json: @httping_log }\n end\n end",
"def index\n @user_logs_all = UserLog.fetch_data(current_user)\n @user_logs = @user_logs_all.paginate(page: params[:page], per_page: 15)\n end",
"def log_contents\n if API_KEYS[\"logentries\"]\n account_key = API_KEYS[\"logentries\"][Rails.env][\"account_key\"]\n log_set = API_KEYS[\"logentries\"][Rails.env][\"log_set\"]\n log_name = \"nsc\"\n url = \"https://pull.logentries.com/#{account_key}/hosts/#{log_set}/#{log_name}/?filter=#{log_prefix}\"\n Rails.logger.debug { \"Fetching log from #{url}\" }\n open(url).read\n else\n File.read(log_path)\n end\n end",
"def audit_log_all\n\n if params[:controller] && params[:action]\n desc = params[:controller] + \"|\" + params[:action]\n desc << \"|id:#{params[:id]}\" if params[:id]\n\n ## log user email for now\n ## TODO: change to larger requester info set\n if current_user\n if desc =~ /sessions\\|destroy/\n desc << \"|LOGOUT\"\n end\n\n AuditLog.create(requester_info: current_user.email, event: \"USER_ACTION\", description: desc)\n else\n AuditLog.create(requester_info: \"NONE\", event: \"USER_ACTION\", description: desc)\n end\n\n end\n\n end",
"def audit_log_all\n\n if params[:controller] && params[:action]\n desc = params[:controller] + \"|\" + params[:action]\n desc << \"|id:#{params[:id]}\" if params[:id]\n\n ## log user email for now\n ## TODO: change to larger requester info set\n if current_user\n if desc =~ /sessions\\|destroy/\n desc << \"|LOGOUT\"\n end\n\n AuditLog.create(requester_info: current_user.email, event: \"USER_ACTION\", description: desc)\n else\n AuditLog.create(requester_info: \"NONE\", event: \"USER_ACTION\", description: desc)\n end\n\n end\n\n end",
"def logs\n cloud = Cloud.instance\n cloud.auth_for_accounts [id]\n cloud.get(['cloud-service-logging', 'accounts', id, 'logs', 'paginated?lang=DE']).body.logs\n end",
"def edit\n begin\n @entry = @current_user.log_entries.find(params[:id])\n rescue ActiveRecord::RecordNotFound\n flash[:error] = \"Unable to find log entry with id #{params[:id]}\"\n return redirect_to(:action => :index)\n end\n\n respond_to {|format| format.html}\n end",
"def history_log (event, options={})\n\n source = options.delete(:source) || current_user.login\n\n OpenWFE::Extras::HistoryEntry.log!(source, event, options)\n end",
"def history_log (event, options={})\n fname= \"#{self.class.name}.#{__method__}\"\n source = options.delete(:source) || @current_user.login\n #LOG.debug (fname){\"history_log:source=#{source}\"}\n \t#LOG.debug (fname){\"history_log:options=#{options}\"}\n Ruote::Sylrplm::HistoryEntry.log!(source, event, options)\n end",
"def find_log\n @log = Log.find(params[:id])\n end",
"def index\n # if current_user.admin?\n @room_histories = RoomHistory.all\n # else\n # @room_histories = RoomHistory.where(user_id: current_user)\n # end\n end",
"def show\n @error_log = ErrorLog.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @error_log }\n end\n rescue ActiveRecord::RecordNotFound => e\n prevent_access(e)\n end",
"def viewer\n admin\n end",
"def log_request\n \"#{request.ip} - #{session[:login] ? session[:login].name : '-'} [#{Time.now.strftime('%d/%m/%Y:%H:%M:%S %z')}] \\\"#{request.request_method} #{request.path} HTTP\\\" #{response.status} #{response.content_length} #{timer.stop(request.object_id).round(3)}\"\n end",
"def log()\n if user_signed_in?\n else\n \tredirect_to \"http://localhost:3000/users/sign_in\"\n end\n end",
"def show\n authorize! :show, @level\n end",
"def set_user_log\n @user_log = current_user.user_logs.where(id: params[:id]).first\n end",
"def index\n return error('Log access restricted') unless current_user.valet_admin?\n \n @logset = log_params[:logset]\n\n # If no set of logs was specified,\n # ask for which one.\n if @logset.blank?\n @logset_counts = Log.group('logset').distinct.count\n return render action: 'logset_list'\n end\n\n # If they've asked for access to a set, \n # make sure they're permitted\n\n # Have they asked to download a year of logs for a given logset?\n # download param may be a year (YYYY) or year/month (YYYY-MM).\n download = log_params[:download]\n if download.present?\n # @rows = Log.where(logset: @logset).by_year(download).order(:created_at)\n @rows = logs_by_date(download).order(created_at: :asc)\n\n # This set's keys, derived from the JSON logdata of an example row\n @logdata_keys = get_keys_from_logdata(@rows.last)\n # standard keys for any logged requests (ip, user-agent, etc.)\n @request_keys = request_keys\n\n filename = \"#{@logset} #{download}\".parameterize.underscore + '.csv'\n\n response.headers['Content-Type'] = 'text/csv'\n response.headers['Content-Disposition'] = \"attachment; filename=#{filename}\"\n return render template: 'logs/index.csv.erb'\n end\n\n @year_month = log_params[:year_month]\n\n # If they haven't told us which year/month to display,\n # ask them.\n if @year_month.blank?\n @year_counts = get_year_counts\n @month_counts = get_month_counts\n return render action: 'month_list'\n end\n\n # OK, we're going to move forward and display an interactive JS datatable\n # of a given year/month for a given logset.\n @rows = logs_by_date(@year_month).order(created_at: :desc)\n\n # This logset's keys, derived from the JSON logdata of an example row\n @logdata_keys = get_keys_from_logdata(@rows.first)\n\n # standard keys for any logged requests (ip, user-agent, etc.)\n @request_keys = request_keys\n end",
"def show\n @d_logger = DLogger.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @d_logger }\n end\n end",
"def edit\n @log = Log.find(params[:id])\n end",
"def command_show(date = Date.today)\n entries = @log.get_entries(date)\n if entries != nil\n entries.each { |i|\n puts i.to_s\n }\n end\n end"
] |
[
"0.6876982",
"0.67404073",
"0.66599977",
"0.65677613",
"0.6564658",
"0.65309817",
"0.6479322",
"0.64707935",
"0.64099896",
"0.64097726",
"0.6381973",
"0.6358364",
"0.6340605",
"0.62992835",
"0.62937105",
"0.62471324",
"0.6245345",
"0.61996603",
"0.6188809",
"0.6172863",
"0.6151641",
"0.614171",
"0.6140768",
"0.6140768",
"0.61316985",
"0.60938287",
"0.60855764",
"0.60789675",
"0.6039018",
"0.6026269",
"0.6000167",
"0.59877783",
"0.59869987",
"0.59786975",
"0.59589714",
"0.59538794",
"0.5942873",
"0.5897704",
"0.5889342",
"0.5889342",
"0.5875378",
"0.58721447",
"0.5834855",
"0.5788255",
"0.5781549",
"0.57788026",
"0.5778262",
"0.575633",
"0.5755797",
"0.5747476",
"0.5721149",
"0.57174593",
"0.5713511",
"0.5712206",
"0.5706963",
"0.5703117",
"0.5699698",
"0.5692802",
"0.5690419",
"0.5675921",
"0.56687176",
"0.5659659",
"0.56521016",
"0.56498134",
"0.564713",
"0.56388426",
"0.56325436",
"0.56111014",
"0.55984396",
"0.5597235",
"0.5586721",
"0.5582463",
"0.5582346",
"0.5575487",
"0.5574596",
"0.55717075",
"0.55491036",
"0.55470234",
"0.5545387",
"0.5545029",
"0.5542687",
"0.5538437",
"0.5531362",
"0.5526599",
"0.5526599",
"0.55265164",
"0.5513146",
"0.55123675",
"0.55115026",
"0.5493303",
"0.54914594",
"0.548972",
"0.54867715",
"0.5485521",
"0.5485315",
"0.5484949",
"0.5484637",
"0.5480837",
"0.5477806",
"0.54759336",
"0.5472527"
] |
0.0
|
-1
|
== DELETE /about/log Administratoronly command to wipe the application log.
|
def log_wipe
lines = wipe_log
respond_with(lines, template: 'about/log')
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def clear_log\n request('clearLog')\n end",
"def clear_log\r\n\r\n file = Rails.public_path.join('bg_worker.log')\r\n FileUtils.rm file\r\n flash[:warning] = \"Cleared log file\"\r\n redirect_to :action => :list\r\n end",
"def delete_log(log_file = '')\n File.delete(log_file) if File.exists?(log_file) && $SYNC_CONFIG[:wipe_log]\n log_file\n end",
"def destroy\n @log.destroy\n respond_to do |format|\n format.html { redirect_to admin_logs_url }\n format.json { head :no_content }\n end\n end",
"def delete_log\n unless UserSession.find == nil\n Log.create(user_id: UserSession.find.user.id, message: \n \"#{UserSession.find.user.name} har slettet rollen: #{self.name}\",\n logtype_id: 3)\n end\n end",
"def clear_log!(name)\n put :clear_log!, {:name => name}\n end",
"def destroy\n @log.destroy\n\n head :no_content\n end",
"def destroy\n if current_user.has_role? :admin\n @shift_log.destroy\n respond_to do |format|\n format.html {redirect_to shift_logs_url, notice: 'Shift log was successfully destroyed.'}\n format.json {head :no_content}\n end\n else\n flash[:alert] = \"Access To Logs Denied\"\n redirect_to root_path\n end\n end",
"def delete_sleep_log(log_id)\n successful_delete?(delete(path_user_version(\"/sleep/#{log_id}\")))\n end",
"def del_weblog_explain; \"Remove weblog from your list.\"; end",
"def delete_log name\n ensure_connection!\n resp = connection.delete_log name\n if resp.success?\n true\n else\n fail ApiError.from_response(resp)\n end\n end",
"def destroy\n render json: current_device.logs.destroy_all && \"\"\n end",
"def delete_weight_log(user_id: '-', log_id:)\n delete(\"#{API_URI}/#{BODY_API_VERSION}/user/#{user_id}/body/log/weight/#{log_id}.json\")\n end",
"def delete\n CONNECTION.execute(\"DELETE FROM logs WHERE id = #{self.id};\")\n end",
"def delete_water_log(log_id, opts={})\n delete(\"user/#{user_id}/foods/log/water/#{log_id}.json\", opts)\n end",
"def delete_body_fat_log(user_id: '-', log_id:)\n delete(\"#{API_URI}/#{BODY_API_VERSION}/user/#{user_id}/body/log/fat/#{log_id}.json\")\n end",
"def log_out\n session.delete(:admin_id)\n end",
"def log_reset\n @log_device.truncate(0) if defined? @log_device\n self\n end",
"def delete_sleep_log(sleep_log_id)\n delete(\"user/#{user_id}/sleep/#{sleep_log_id}.json\")\n end",
"def clear\n Log.delete_all\n render_index\n end",
"def destroy\n @log = @client.logs.find(params[:id])\n @log.destroy\n\n respond_to do |format|\n format.html { redirect_to(client_url(@client)) }\n format.xml { head :ok }\n end\n end",
"def destroy\n log_out\n end",
"def delete_log_logshuttle(opts = {})\n data, _status_code, _headers = delete_log_logshuttle_with_http_info(opts)\n data\n end",
"def destroy\n if @mList.size > 0\n str = @mList.join\n dt = Time.now.localtime\n fname = dt.year.to_s + \"_\" + dt.month.to_s + \"_\" + dt.day.to_s\n fh = File.open(\"logs/\" + fname, \"a\")\n fh.write(str)\n fh.close\n @mList.clear\n end\n @mSocket.close\n storeDebug(\"Dumped final logs.\")\n end",
"def destroy\n @log = Log.find(params[:id])\n @log.destroy\n respond_to do |format|\n format.html { redirect_to index_logs_path(params[:device_id], :page => 1) }\n format.json { head :no_content }\n end\n end",
"def command_delete(name, date)\n if @log.contains(name, date)\n @log.remove_logItem(name, date)\n @logChangedDB = true\n else\n puts \"Item not in log\"\n end\n end",
"def destroy\n # @user = User.find(params[:user_id])\n # @log = @user.logs.find(params[:id])\n @log.destroy\n respond_to do |format|\n format.html { redirect_to user_logs_url, notice: 'Log was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def clean\n FileUtils.remove_dir(@log_dir, true)\n end",
"def destroy\n @user_log = UserLog.find(params[:id])\n @user_log.destroy\n\n respond_to do |format|\n format.html { redirect_to user_logs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @clothing_log = current_account.clothing_logs.find(params[:id])\n authorize! :destroy, @clothing_log\n @clothing_log.destroy\n respond_with @clothing_log, :location => clothing_logs_url\n end",
"def destroy\n @log.destroy\n respond_to do |format|\n format.html { redirect_to logs_url, notice: 'Shift was successfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def delete_water_log(water_log_id)\n delete(\"/user/-/foods/log/water/#{water_log_id}.json\")\n end",
"def destroy\n @rcadmin_login_log.destroy\n respond_to do |format|\n format.html { redirect_to rcadmin_login_logs_url }\n format.json { head :no_content }\n end\n end",
"def clear\n Log.clear_all\n# PrivatePub.publish_to \"/status\", :chat_message => \"Hello, world!\"\n redirect_to :action => :index\n end",
"def clear\n Log.clear_all\n# PrivatePub.publish_to \"/status\", :chat_message => \"Hello, world!\"\n redirect_to :action => :index\n end",
"def clear_messages\n Facter::Log.clear_messages\n end",
"def logoff\n end",
"def clear_log\n @messages = []\n end",
"def destroy\n @log = Log.find(params[:id])\n @log.destroy\n\n respond_to do |format|\n format.html { redirect_to logs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @log = Log.find(params[:id])\n @log.destroy\n\n respond_to do |format|\n format.html { redirect_to logs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n log_record('users/delete', current_user.id)\n super\n end",
"def admin_log_out\n session.delete(:admin_user_id)\n @current_admin_user = nil\n end",
"def destroy\n @applicationlog = Applicationlog.find(params[:id])\n @applicationlog.destroy\n\n respond_to do |format|\n format.html { redirect_to applicationlogs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n # We are just removing the notification from display for the current user\n # The super-user can still access it\n if !params[:id].nil? && params[:id] == 'delete_all'\n @notification_logs = current_user.notification_logs\n @notification_logs.each {|n| n.update_attribute(:disabled, true) }\n else\n @notification_log = NotificationLog.find(params[:id])\n @notification_log.update_attribute(:disabled, true)\n end\n\n respond_to do |format|\n format.html { redirect_to notification_logs_url }\n format.json { head :no_content }\n end\n end",
"def drop_event_log\n session.left.drop_table \"#{options[:rep_prefix]}_logged_events\"\n end",
"def destroy\n @log.destroy\n respond_to do |format|\n format.html { redirect_to logs_url }\n format.json { head :no_content }\n end\n end",
"def sparkResetLogging()\n #logNormal($sparkPrefix + \" sparkResetLogging removing all log targets\\n\");\n\n logServer = get($serverPath+'log')\n if (logServer != nil)\n logServer.removeAllStreams()\n end\nend",
"def remove_log_file\r\n if RUBY_PLATFORM =~ /win32|win64/i then\r\n if File.exist?('C:\\temp\\BJLog.txt') then\r\n File.delete('C:\\temp\\BJLog.txt')\r\n end\r\n\r\n else\r\n if File.exist?(\"tmp/BJLog.txt\")\r\n File.delete(\"tmp/BJLog.txt\")\r\n end\r\n end\r\n end",
"def delete_logging_statement\n super\n end",
"def deleteGenerallog(projectId, logId)\r\n\t\t\t\turl = getBaseURL+\"projects/\"+String(projectId)+\"/logs/\"+String(logId)+\"/\"\t\t\r\n\t\t\t\tresponse = ZohoHTTPClient.delete(url, getQueryMap)\t\t\r\n\t\t\t\treturn $timesheetParser.getResult(response)\r\n\t\t\tend",
"def destroy\n @wr_log = WrLog.find(params[:id])\n @wr_log.destroy\n\n respond_to do |format|\n format.html { redirect_to wr_logs_url }\n format.json { head :no_content }\n end\n end",
"def log_remove_from(object)\n object.log(:log_image_removed, name: log_name, touch: false)\n end",
"def destroy\n @user = current_user;\n @toeic_log = ToeicLog.find(params[:id])\n @toeic_log.destroy\n\n respond_to do |format|\n format.html { redirect_to toeic_logs_url }\n format.json { head :no_content }\n end\n end",
"def logoff()\n #This is a stub, used for indexing\n end",
"def delete_body_fat_log(body_fat_log_id, options = {})\n successful_delete?(delete(path_user_version(\"/body/log/fat/#{body_fat_log_id}\", options)))\n end",
"def dont_delete_admin\n\t\t raise \"You cannot delete the last admin\" if self.id == 1 || User.count == 1\n\t end",
"def purge\n respond_to do |format|\n if @object.current_state == :deleted\n if @object.is_administrator?\n flash[:warning] = \"Administrators cannot be permanently deleted. If you truly wish to delete this user, remove their administrator role.\"\n format.html { redirect_to(users_path) }\n format.xml { render :status => :unprocessable_entity }\n else\n User.transaction do\n id = @object.id\n @object.destroy\n create_change_log_entry(id)\n end\n format.html { redirect_to(users_path) }\n format.xml { head :ok }\n end\n end\n end\n end",
"def destroy\n if @work_log.user == current_user && @work_log.date >= 4.days.ago\n @work_log.destroy\n elsif @work_log.user == current_user\n flash[:notice] = \"Log is older than 5 days\"\n elsif current_user.manager?\n flash[:notice] = \"Worklog deleted\"\n @work_log.destroy\n else\n flash[:notice] = \"Permission denied\"\n end\n respond_to do |format|\n unless current_user.manager?\n format.html { redirect_to root_url }\n else\n format.html { redirect_to reports_worklogs_path }\n end\n format.json { head :no_content }\n end\n end",
"def destroy\n @systemlog.destroy\n respond_to do |format|\n format.html { redirect_to systemlogs_url, notice: 'Systemlog was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def logs_delete(obj)\n @db.q_buffer do |db_buffer|\n buffer_hash = {:db_buffer => db_buffer}\n\n @ob.list(:Log_link, {\"object_class\" => obj.class.name, \"object_id\" => obj.id}) do |log_link|\n log = log_link.log\n @ob.delete(log_link, buffer_hash)\n @ob.delete(log, buffer_hash) if log and log.links(\"count\" => true) <= 0\n end\n end\n end",
"def clear_processes_logs\n request('clearAllProcessesLogs')\n end",
"def destroy\n\tif user_signed_in?\n\t\tif current_user.role_id == 1 || current_user.role_id == 2\n\t\t\t@eventlog = Eventlog.find(params[:id])\n\t\t\t@eventlog.destroy\n\n\t\t\trespond_to do |format|\n\t\t\t format.html { redirect_to eventlogs_url }\n\t\t\t format.json { head :no_content }\n\t\t\tend\n\t\telse\n\t\t\tflash[:notice] = \"You don't have access to do that\"\n\t\t\tredirect_to :controller=>'eventlogs', :action => 'index'\n\t\tend\n\telse\n\t\tredirect_to :controller=>'home', :action => 'index'\n\tend\n end",
"def destroy\n @accession_log.destroy\n respond_to do |format|\n format.html { redirect_to accession_logs_url, notice: 'Accession log was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n authorize @shooting_log\n @shooting_log.destroy\n respond_to do |format|\n format.html { redirect_to shooting_logs_url, notice: \"Shooting log was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @action_log.destroy\n respond_to do |format|\n format.html { redirect_to action_logs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @log.destroy\n\n respond_to do |format|\n format.html { redirect_to(logs_url) }\n format.xml { head :ok }\n end\n end",
"def delete_weight_log(body_weight_log_id, options = {})\n path = \"/body/log/weight/#{body_weight_log_id}\"\n successful_delete?(delete(path_user_version(path, options)))\n end",
"def log_out\n\t\tsession.delete(:id)\n\t\t@current_user = nil\n\t\tadmin_session(false)\n\tend",
"def icl_delete( args )\n prop = args.split(',')\n name = prop[0]\n date = prop[1]\n puts name + \" \" + date\n @log.delete( name, date )\n end",
"def erase_old_data()\n Djinn.log_run(\"rm -rf /tmp/h*\")\n Djinn.log_run(\"rm -f ~/.appscale_cookies\")\n Djinn.log_run(\"rm -f #{APPSCALE_HOME}/.appscale/status-*\")\n Djinn.log_run(\"rm -f #{APPSCALE_HOME}/.appscale/database_info\")\n\n Nginx.clear_sites_enabled\n HAProxy.clear_sites_enabled\n Djinn.log_run(\"echo '' > /root/.ssh/known_hosts\") # empty it out but leave the file there\n CronHelper.clear_crontab\n end",
"def destroy\n if @advertise.user == current_user\n # BUG: Log entry should contains the removed advertise\n # id even after its removal.\n Log.create(:user => current_user,\n :msg => _(\"advertise deleted\", :id => @advertise.id))\n\n @advertise.destroy\n else\n return forbidden\n end\n\n respond_to do |format|\n format.html { redirect_to target_url || advertises_url }\n format.json { head :no_content }\n end\n end",
"def reset_log_data\n self.class.without_logging { update_column(:log_data, nil) }\n end",
"def unmake_watchdog\n authorize! :manage_watchdogs, User\n @user.remove_role [:watchdog, :watchdog_probation]\n render_success_message('Removed successfully watchdog role.')\n end",
"def destroy\n @system.destroy\n respond_to do |format|\n format.html { redirect_to(admin_systems_url) }\n format.xml { head :ok }\n end\n website.add_log(user: current_user, action: \"Deleted system: #{@system.name}\")\n end",
"def delete_log_loggly(opts = {})\n data, _status_code, _headers = delete_log_loggly_with_http_info(opts)\n data\n end",
"def destroy\n @readonly_administrator = ReadonlyAdministrator.find(params[:id])\n @readonly_administrator.destroy\n head :no_content\n end",
"def destroy\n @error_log = ErrorLog.find(params[:id])\n @error_log.destroy\n\n respond_to do |format|\n format.html { redirect_to(error_logs_url) }\n format.xml { head :ok }\n end\n rescue ActiveRecord::RecordNotFound => e\n prevent_access(e)\n end",
"def destroy\n begin\n @entry = @current_user.log_entries.find(params[:id])\n @entry.destroy\n flash[:notice] = \"Deleted log entry id #{params[:id]}\"\n rescue ActiveRecord::RecordNotFound\n flash[:error] = \"Unable to find log entry with id #{params[:id]}\"\n rescue Exception => e\n flash[:error] = \"Unable to delete log entry: #{e}\"\n end\n\n redirect_to :action => :index\n end",
"def remove_log_file\r\n\r\n #Determine which platform the game is running on\r\n if RUBY_PLATFORM =~ /win32|win64|\\.NET|windows|cygwin|mingw32/i then\r\n #Delete the log file only if it exists\r\n if File.exist?('C:\\temp\\BJLog.txt') then\r\n File.delete('C:\\temp\\BJLog.txt')\r\n end\r\n\r\n else\r\n if File.exist?('/tmp/BJLog.txt') then\r\n File.delete('/tmp/BJLog.txt')\r\n end\r\n end\r\n\r\n end",
"def destroy\n @current_user = current_user\n not_found and return unless @timelog.user == @current_user\n\n @timelog.destroy\n respond_to do |format|\n format.html { redirect_to timelogs_url, notice: 'Timelog was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n redirect_to acm300_logs_path\n \n # @acm_logs300_log.destroy\n # respond_to do |format|\n # format.html { redirect_to acm300_logs_url, notice: 'Acm300 log was successfully destroyed.' }\n # format.json { head :no_content }\n # end\n end",
"def destroy\n @devlog.destroy\n respond_to do |format|\n format.html { redirect_to admin_devlogs_url, notice: 'Devlog was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n appctrl_delete( 'User' )\n end",
"def deleteOld(dir, logkey='')\n\tif File.exists?(dir)\n\t\tMcmlln::Tools.deleteDir(dir)\n\telse\n\t\tlogstring = 'n-a'\n\tend\nrescue => logstring\nensure\n Mcmlln::Tools.logtoJson(@log_hash, logkey, logstring)\nend",
"def reset_log_data\n without_logging { update_all(log_data: nil) }\n end",
"def destroy\n \t#call logout method in admin_helper but only if we r loggedin\n \tlog_out if logged_in?\n \t#redirect him to homepage\n \tredirect_to root_path\n end",
"def clear_patron_data\n if User.where(admin: [nil, false]).destroy_all\n flash[:success] = t('users.clear_patron_data_success')\n end\n redirect_to users_url\n end",
"def remove_error_log (wfid)\n\n path = get_path(wfid)\n\n File.delete(path) if File.exist?(path)\n end",
"def destroy\n @log_entry = LogEntry.find(params[:id])\n @log_entry.destroy\n\n redirect_to log_entries_path\n end",
"def destroy\n conf.delete 'dashboard'\n end",
"def destroy\n logout_killing_session! if @object == current_user\n User.transaction do\n @object.delete!\n create_change_log_entry\n end\n respond_to do |format|\n format.html { redirect_to(users_path) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @heat_log = HeatLog.find(params[:id])\n @heat_log.destroy\n\n respond_to do |format|\n format.html { redirect_to heat_logs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @measurement_log = current_account.measurement_logs.find(params[:id])\n @measurement_log.destroy\n\n respond_to do |format|\n format.html { redirect_to(measurement_logs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @ai_log.destroy\n respond_to do |format|\n format.html { redirect_to ai_logs_url }\n format.json { head :no_content }\n end\n end",
"def clear_administrator_accounts\n Administrator.destroy_all\n end",
"def destroy\n @log.destroy\n respond_to do |format|\n format.html { redirect_to logs_url, notice: 'Log was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @log.destroy\n respond_to do |format|\n format.html { redirect_to logs_url, notice: 'Log was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def logout\n session[:user] = nil\n session[:permissions] = {}\n session[:admin_user_id] = nil\n redirect_to '/'\n end",
"def destroy\n @action_log = ActionLog.find(params[:id])\n @action_log.destroy\n\n respond_to do |format|\n format.html { redirect_to(action_logs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @log = Log.find(params[:id])\n @log.destroy\n\n respond_to do |format|\n format.html { redirect_to goal_logs_url(@goal) }\n format.json { head :no_content }\n end\n end"
] |
[
"0.70575684",
"0.6709301",
"0.6520443",
"0.64608884",
"0.6441817",
"0.64084476",
"0.635158",
"0.6290828",
"0.62805754",
"0.60182387",
"0.59994334",
"0.59255266",
"0.5911193",
"0.5891146",
"0.58537716",
"0.5843142",
"0.58160335",
"0.5813592",
"0.58046234",
"0.57949734",
"0.57715726",
"0.5756403",
"0.5739496",
"0.5738468",
"0.57282823",
"0.5719343",
"0.57003754",
"0.56933665",
"0.5685448",
"0.56818646",
"0.567113",
"0.56693023",
"0.56669044",
"0.5661079",
"0.5661079",
"0.5652854",
"0.5648985",
"0.56410533",
"0.56251335",
"0.56251335",
"0.5622347",
"0.5608045",
"0.55783504",
"0.55779994",
"0.5577436",
"0.55572325",
"0.5553288",
"0.55528796",
"0.5544054",
"0.5541462",
"0.553767",
"0.5528615",
"0.5526584",
"0.5516206",
"0.5514915",
"0.5493358",
"0.54756564",
"0.54727364",
"0.5470587",
"0.5470372",
"0.5460178",
"0.54526067",
"0.5450168",
"0.54356694",
"0.5435379",
"0.54351795",
"0.5434086",
"0.5420016",
"0.541795",
"0.5410513",
"0.5410345",
"0.5404446",
"0.53999346",
"0.5397715",
"0.53965324",
"0.5395943",
"0.5390042",
"0.538414",
"0.5383263",
"0.5382609",
"0.53798497",
"0.53697884",
"0.5369106",
"0.5368894",
"0.53563577",
"0.5335213",
"0.53330344",
"0.53216827",
"0.5313867",
"0.53138053",
"0.530811",
"0.5308015",
"0.5301291",
"0.5300727",
"0.52996904",
"0.52987826",
"0.52987826",
"0.5296311",
"0.5292173",
"0.5292045"
] |
0.68820006
|
1
|
Override __prefix__ class method to have better prefixes for some of these longer vocabulary names.
|
def __prefix__
__name__.demodulize.underscore.dasherize.to_sym
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def name_prefix; end",
"def prefixes; end",
"def prefixes; end",
"def words_with_prefix(prefix, words)\n raise NotImplementedError # TODO\nend",
"def prefix; end",
"def prefix; end",
"def prefix; end",
"def prefix; end",
"def prefix; end",
"def prefix; end",
"def prefix; end",
"def prefix; end",
"def prefix; end",
"def prefix; end",
"def _prefixes; end",
"def set_prefix\n if self.prefix.nil? && self.title.present?\n self.prefix = self.title.to_s.gsub(/\\W/, '').downcase\n end\n end",
"def set_prefix\n @prefix = @str[@i_last_real_word...@i]\n end",
"def name_prefix=(_arg0); end",
"def prefix=(prefix) @prefix = prefix end",
"def build_prefix\n @prefix = @str[@i_last_real_word...@i]\n end",
"def prefix\n 'oai_dc' \n end",
"def prefix\n raise NotImplementedError\n end",
"def local_prefixes; end",
"def prefix=(_); end",
"def str_prefix\n\t\t\t\t\"\"\n\t\t\tend",
"def ns_prefixes\n {\n 'jerm' => JERMVocab.to_uri.to_s,\n 'dcterms' => RDF::Vocab::DC.to_uri.to_s,\n 'owl' => RDF::Vocab::OWL.to_uri.to_s,\n 'foaf' => RDF::Vocab::FOAF.to_uri.to_s,\n 'sioc' => RDF::Vocab::SIOC.to_uri.to_s\n }\n end",
"def prefixes(max_length:)\n names = %w()\n (names.select { |name| name.length <= max_length }.map { |name| str(name) }.reduce(:|) || str('1')).as(:prefix)\n end",
"def normalize_name(name, prefixes); end",
"def define_prefixes(prefs)\n\t\t\tprefs.each do |prefix, val|\n\t\t\t @@prefixes[prefix] = RDF::Vocabulary.new(val)\n\t\t\tend\n\t\tend",
"def inherited_prefix\n\t\t\tprefix\n\t\tend",
"def two_word_name; end",
"def prefix\n self.class.prefix\n end",
"def long_name\n name = ''\n if @name.to_s =~ /_/\n @name.to_s.split('_').each do |str|\n name << str.to_s.capitalize\n end\n else\n name = @name.to_s.capitalize\n end\n namespace = @namespace.to_s.split('::').map { |str| str.capitalize }\n \"#{namespace.join('::')}::#{name}\"\n end",
"def name_prefix\n unless @name_prefix\n @name_prefix = collect_first(&:name_prefix)\n end\n return @name_prefix\n end",
"def is_prefix?(word)\n Constants::PREFIXES.key?(word.downcase)\n end",
"def prefix\n regexify(bothify(fetch('aircraft.prefix')))\n end",
"def prefix\n ''\n end",
"def prefix(prefix)\n new(map { |attr| attr.prefixed(prefix) })\n end",
"def prefix(new_prefix = nil)\n return @prefix if new_prefix.nil?\n @prefix = new_prefix\n end",
"def prefix=(_arg0); end",
"def use_prefix\n prefix, @prefix = @prefix, nil\n @res << prefix if prefix\n\n prefix\n end",
"def _prefixes\n @_prefixes ||= super + ['catalog', 'hyrax/base']\n end",
"def _prefixes # :nodoc:\n self.class._prefixes\n end",
"def _prefixes # :nodoc:\n self.class._prefixes\n end",
"def wrap_prefix(prefix)\n prefix\n end",
"def prefix pref_name\n @context['prefix'] = pref_name\n end",
"def short_name\n self.name.demodulize\n end",
"def update_name_prefix(name_prefix)\n @name_prefix = \"#{@name_prefix}#{name_prefix}\"\n end",
"def three_word_name; end",
"def wikified_name\n self.name.slice(0,1).capitalize + self.name.slice(1..-1).gsub(/ /, '_')\n end",
"def _prefixes\n @_prefixes ||= super + ['catalog', 'curation_concerns/base']\n end",
"def _prefixes\n @_prefixes ||= super + ['catalog', 'curation_concerns/base']\n end",
"def prefix\n '[' + self.class.to_s + '] '\n end",
"def get_prefixed_words(prefix)\n return Lexicon.scan(prefix)\n end",
"def prefix\n fetch('university.prefix')\n end",
"def translation_prefix(context = :any)\n prefix = claim_public? ? 'UNAUTHENTICATED' : 'AUTHENTICATED'\n\n # If we only have 1 buyer, then the key used should be for a single buyer only.\n return \"#{prefix}_SINGLE\" if @number_of_buyers == 1 && context == :party_title\n\n prefix\n end",
"def prefix_method_string prefix\n puts \"About to call PREFIX TABLE.to_full with #{prefix}\" if SY::DEBUG\n full_prefix = SY::PREFIX_TABLE.to_full( prefix )\n full_prefix == '' ? '' : \".#{full_prefix}\"\n end",
"def rest_name\n short_name.downcase\n end",
"def prefix\n \"#{name}::\"\n end",
"def definite_name(prefix=\"the\")\n if name =~ /\\b(of|for)\\b/i\n \"#{prefix} #{name}\"\n else\n name\n end\n end",
"def prefix(num)\n namespace + '_prefix_' + num.to_s\n end",
"def alternatives(prefix)\n if @project\n word_list = Redcar::AutoCompleter::WordList.new\n tags = CompletionSource.project_tags(@project)\n tags.keys.sort_by{|tag| tag.downcase}.each do |tag|\n if tag[0..(prefix.length-1)] == prefix\n word_list.add_word(tag, 100000)\n end\n end\n word_list\n end\n end",
"def prefix\n @obj['prefix']\n end",
"def name_with_prefix(prefix, name)\n prefix ? \"#{prefix}[#{name}]\" : name.to_s\n end",
"def remove_prefix_and_suffix(table)\n super(table.sub(/\\A[a-z0-9_]*\\./, ''))\n end",
"def userprefix(value)\n merge(ucuserprefix: value.to_s)\n end",
"def general_prefix\n parts = []\n parts << label\n parts << ttl if ttl\n parts << 'IN'\n parts << type\n parts\n end",
"def prefix\n p = nil\n params.each { |k,v|\n if (k[-1,1] == \"_\") && (k[0,1] =~ /[A-Z]/)\n\tp = k\n\tbreak\n end\n }\n all_classes = WsCim::constants\n if p == \"CIM_\"\n @classes = all_classes.reject { |c| c =~ /_/ }\n elsif p\n @classes = all_classes.grep( Regexp.new( \"^#{p}\" ) )\n end\n @classes.sort!\n render(:partial => \"browse_class_prefix\", :layout => false)\n end",
"def prefix=(value)\n @prefix = value\n end",
"def set_prefix_to(a)\n Kamelopard.id_prefix = a\n end",
"def shortName\n self.short_name\n end",
"def var_prefix\n # ugh, i was generating meta/qb.yml files that set 'var_prefix' to\n # `null`, but it would be nice to\n # \n meta_or 'var_prefix', namespaceless\n end",
"def unmiga_name\n gsub(/_(str|sp|subsp|pv)__/,\"_\\\\1._\").tr('_', ' ')\n end",
"def name_prefix\n Faker::Name.prefix\n end",
"def name_prefix\n Faker::Name.prefix\n end",
"def prefix\n @data['prefix']\n end",
"def prefix_key\n if @struct.prefix_key.size > 0\n @struct.prefix_key[0..-1 - options[:prefix_delimiter].size]\n else\n \"\"\n end\n end",
"def prepare_key prefix, key\n \"oaf_#{prefix}_#{key.gsub('-', '_').downcase}\"\n end",
"def city_prefix; end",
"def with_prefixes_key_for(keys = EMPTY_ARRAY)\n [*prefixes, *keys].join('_').upcase\n end",
"def with_prefixes_key_for(keys = EMPTY_ARRAY)\n [*prefixes, *keys].join('_').upcase\n end",
"def _prefixes\n @_prefixes ||= PrefixesBuilder.new(\n super, controller_path, current_resources_name, params\n ).build\n end",
"def prefix( *pf )\r\n tokens.unshift(*TokenString.linearize_tokens(pf))\r\n self\r\n end",
"def aref_prefix\n raise NotImplementedError\n end",
"def cardinal_abbreviation; end",
"def prefix(path)\n path ? \"#{path.underscore}__\" : ''\n end",
"def key\n \"#{@@PREFIX}#{@name.gsub(\" \",\"-\")}\"\n end",
"def name(prefix = T.unsafe(nil)); end",
"def name(prefix = T.unsafe(nil)); end",
"def name(prefix = T.unsafe(nil)); end",
"def long_name\n \"#{ancestors_name} #{name}\"\n end",
"def property_prefix\n # TODO: try to use the inverse relationship name if possible\n Extlib::Inflection.underscore(Extlib::Inflection.demodulize(parent_model.base_model.name)).to_sym\n end",
"def metric_prefixes\n %w[k M G T P E Z Y]\n end",
"def prefix(value)\n merge(leprefix: value.to_s)\n end",
"def prefixes\n @prefixes ||= Hash[namespaces.sort_by { |k, v| k }.uniq { |k, v| v }].invert\n end",
"def longest_prefix(name)\n @symbols.longest_prefix(to_name(name))\n end",
"def name_with_middle; end",
"def metric_prefixes\n %w(k M G T P E Z Y)\nend",
"def prefix(str) # 'str' points to the same string, \"John\", as 'name' does (at he start of this method).\n \"Mr \" + str # Ruby Docs: \"str + other_str → new_str\".\nend",
"def name_underscored\n self.name.gsub(' ', '_')\n end"
] |
[
"0.6865738",
"0.675726",
"0.675726",
"0.66747403",
"0.6585286",
"0.6585286",
"0.6585286",
"0.6585286",
"0.6585286",
"0.6585286",
"0.6585286",
"0.6585286",
"0.6585286",
"0.6585286",
"0.6540014",
"0.65229684",
"0.6400325",
"0.63975704",
"0.6286913",
"0.6269063",
"0.62565523",
"0.6244474",
"0.6225956",
"0.62037253",
"0.62034976",
"0.61984587",
"0.6154086",
"0.6108322",
"0.60884386",
"0.60430735",
"0.6020159",
"0.60177356",
"0.6017337",
"0.60133594",
"0.6009242",
"0.5993837",
"0.5981886",
"0.59604746",
"0.5955292",
"0.5931388",
"0.59272146",
"0.59241104",
"0.59086406",
"0.59086406",
"0.5890184",
"0.5883194",
"0.5868833",
"0.5863673",
"0.5862058",
"0.58595103",
"0.5854679",
"0.5854679",
"0.5853407",
"0.5852653",
"0.58429116",
"0.58211994",
"0.5791556",
"0.5779944",
"0.5765488",
"0.5764727",
"0.576171",
"0.5750146",
"0.57471895",
"0.5745269",
"0.5743088",
"0.57354563",
"0.572902",
"0.57182163",
"0.571811",
"0.57114595",
"0.57104087",
"0.5702356",
"0.5688604",
"0.56848246",
"0.56848246",
"0.56839114",
"0.5677896",
"0.5675129",
"0.56641144",
"0.5663393",
"0.5663393",
"0.5654281",
"0.56527674",
"0.56513816",
"0.5641105",
"0.563138",
"0.5630161",
"0.5612903",
"0.5612903",
"0.5612903",
"0.5610347",
"0.5594777",
"0.5593518",
"0.5579711",
"0.5578386",
"0.55656415",
"0.5563493",
"0.55578005",
"0.5538051",
"0.55370355"
] |
0.69234943
|
0
|
change the board after a player turn
|
def update_board
n = 0
board.each do |i|
i.map do |j|
if j[0] == ' '
j[1] = movements[n].to_s
n += 1
end
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def turn\n marker = @turn_count.even? ? marker = \"X\" : marker = \"O\"\n move\n print \"Current board: \"\n show_board\n @player +=1\n end",
"def turn\n current_move = current_player.move(@board)\n current_token = current_player.token\n if self.board.valid_move?(current_move)\n self.board.update(current_move, current_player)\n self.board.display\n # binding.pry\n else\n turn\n end\n end",
"def turn\n input = current_player.move(board)\n if board.valid_move?(input)\n board.update(input, current_player)\n board.display\n else\n board.display\n turn\n end\n end",
"def update_board(board)\r\n @game_board = board\r\n end",
"def turn\n victory = false\n while victory == false do\n player_place\n @board.show_board\n end\n end",
"def play_turn\n @board.place_mark(@current_player.get_move, @current_player.mark)\n switch_players!\n end",
"def change_turn\n if @player_to_move == \"w\"\n @player_to_move = \"b\"\n else\n @player_to_move = \"w\"\n end\n end",
"def turn\n input = current_player.move(board)\n\n if board.valid_move?(input)\n board.update(input, current_player)\n board.display\n else\n turn\n end\n end",
"def play_turn\n board.render\n pos = get_pos\n decision = get_decision\n if decision == \"r\"\n board.reveal(pos)\n elsif decision == \"f\"\n board.flag(pos)\n else\n @saved_board = board.to_yaml\n end\n end",
"def update_board(turn)\n @board[turn][0] = @matches\n @board[turn][1] = @code_breaker_input\n end",
"def turn\n \n choice = current_player.move(board)\n if board.valid_move?(choice)\n board.update(choice, current_player)\n else\n turn\n end\n end",
"def turn\n choice = current_player.move(board)\n if board.valid_move?(choice)\n board.update(choice, current_player)\n end\n end",
"def turn(row, column)\n place_piece(row, column)\n puts display_board\n check_for_win() \n end",
"def turn\n most_recent_move = current_player.move(@board)\n if !@board.valid_move?(most_recent_move)\n turn\n else\n @board.update(most_recent_move, current_player)\n end\n end",
"def turn\n puts \"Turn #{@board.count_turn + 1}, player #{get_current_player.name} choose:\"\n @board.play_turn\n end",
"def board\r\r\n @board = true\r\r\n end",
"def turn\n choice = current_player.move(board)\n if board.valid_move?(choice)\n board.update(choice, current_player)\n else\n turn\n end\n end",
"def turn\n choice = current_player.move(board)\n if board.valid_move?(choice)\n board.update(choice, current_player)\n else\n turn\n end\n end",
"def change_board(user_hash,move,player)\n\t\tif player == 1\n\t\t\tuser_hash[move] = \"X\"\n\t\telsif player == 2\n\t\t\tuser_hash[move] = \"O\"\n\t\tend\n\t\tdisplay_board(user_hash)\n\n\tend",
"def perform\n @turn += 1\n if @turn%2 != 0\n slot = players[0].play(@board)\n else\n slot = players[1].play(@board)\n end\n @board.update_board(slot, @turn.even? ? 2 : 1)\n end",
"def play_turn\n move = @current_player.get_move\n switch_players!\n @board.place_mark(move, :X)\n end",
"def turn\n # move_value = current_player.move(board)\n # if !board.valid_move? move_value\n # turn\n # else\n # board.update(move_value, current_player)\n # move_value\n # end\n # end\n\n input = current_player.move(board)\n if board.valid_move?(input)\n board.update(input, current_player)\n board.display\n else\n turn\n end\n end",
"def turn\n puts \"Round #{@board.turn_count}\"\n input = current_player.move(@board)\n if @board.valid_move?(input)\n @board.cells[input.to_i - 1] = current_player.token\n @board.display\n else\n turn\n end\n end",
"def board\n puts \"PUTSING THE BOARD\"\n @current_board = @board_array.dup\n end",
"def turn\n puts \"Please enter 1-9:\"\n move = current_player.move(@board);\n if @board.valid_move?(move)\n @board.update(move, current_player);\n @board.display;\n else\n turn;\n end\n end",
"def play_turn\n move_info = FileReader.get_move(\"#{@turn}#{@player_to_move}\", @data) \n @cur_board.move_piece(move_info)\n end",
"def move(board)\n end",
"def player_turn(turn)\n get_player_input\n compare_guesses\n update_board(turn)\n system 'clear'\n display_board(turn)\n end",
"def play(move, peice = @current_player.peice)\n @board[move] = peice\n change_turns\n end",
"def reset_game\n @cur_board.clear_board\n @cur_board.setup_board\n @turn = 1\n @player_to_move = \"w\"\n end",
"def advance_turn!\n\t\tboard_history << @board.clone\n\t\t@current_player = (@current_player == hunter ? @prey : @hunter)\n\t\t@current_turn += 1\n\tend",
"def play_game\n @board.print_board\n until @quit || @restart || gameover?\n cell = take_turn(@current_player)\n if !cell.nil?\n coordinates = get_coordinates(cell)\n change_board(coordinates) if valid_cell?(coordinates)\n end\n @current_player = switch_player(@current_player)\n @board.print_board unless @restart || @quit\n end\n reset_board if @restart\n ending_screen if gameover?\n\n end",
"def change_turn\n @turn += 1\n @this_players_turn = @players.reject{|x| x == @this_players_turn}[0]\n take_turn(@this_players_turn)\n end",
"def set_board(board)\n @board = board\n end",
"def turn\n move_input = current_player.move\n if !board.valid_move?(move_input) # if #valid_move false\n puts \"That is not a valid move. Please try again.\\n\"\n turn\n else\n board.update(move_input,current_player)\n board.display\n end\n end",
"def turn\n player = current_player\n current_move = player.move(@board)\n\n if !@board.valid_move?(current_move)\n # Game turn asks for input again after a failed validation\n turn\n else\n # Game turn changes to player 2 after the first turn\n puts \"Turn: #{@board.turn_count+1}\\n\"\n @board.display\n @board.update(current_move, player)\n puts \"#{player.token} moved #{current_move}\"\n @board.display\n puts \"\\n\\n\"\n end\n end",
"def do_turn!\n raise \"Turn has already been finalized on original board\" if @finalized\n apply_turn(@original_board)\n @original_board.finalize_move!\n @finalized = true\n @original_board\n end",
"def do_turn\n raise \"Turn has already been finalized on original board\" if @finalized\n board = try_turn\n board.finalize_move!\n board\n end",
"def move(index, current_player)\n @board[index] = current_player\n end",
"def play_turn\n @players.each do |p|\n dice = @dice.roll\n move_player p, dice\n @board.landed_by p\n end\n end",
"def update(board)\n current_captures(board)\n current_moves(board)\n end",
"def update_board\n #clear previous move_list from all pieces\n @board.each do |row|\n row.each do |col|\n col.move_list = [] if !col.nil?\n end\n end\n #clear previous state of @all_pieces\n @all_pieces = []\n #adds every piece obj to all_pieces instance variable\n @board.each do |row|\n row.each do |col|\n @all_pieces << col if !col.nil?\n end\n end\n #give each piece a copy of the board state\n #then allow generate_moves method to come up with a list of possible moves\n #based on that board state\n @all_pieces.each do |n|\n n.board = self\n n.generate_moves\n end\n #add this state to the board_history instance variable\n @board_history << @board\n end",
"def fill_on_board(move, player)\n\n\t\t@board[move[0]][move[1]] = player\n\n\t\treturn @board\n\n\tend",
"def turn\n puts \"#{@current_player.name}\\'s turn. Choose your cell (1-9)\" \n choice = gets.chomp.to_i\n if choice > 9 || choice < 1\n puts \"Warning : number must be between 1 and 9\"\n elsif @current_player.move(choice) != false\n @winner = @current_player if @current_player.winner?\n @turn += 1\n switch_player\n end\n end",
"def play_move(from, to)\n #create duplicate of board, to correct pass by reference error\n #add top disk on from tower to the top of to tower\n to_dup = @board[to].dup\n to_dup.unshift(@board[from][0]) \n @board[to] = to_dup\n @board[from].shift\n \n if won?\n render\n puts \"congratulations you won!\\n\\n\"\n else\n get_move\n end\n end",
"def move(index, current_player)\n @board[index] = current_player\n end",
"def move(index, current_player)\n @board[index] = current_player\nend",
"def move(index, current_player)\n @board[index] = current_player\nend",
"def change_turns\n (@current_player == @p1) ? @current_player = @p2 : @current_player = @p1\n end",
"def turn\n # If I set @board = [\"o\", \"o\", \"o\", \"o\", nil, nil, nil, \"x\", \"x\"]\n # the moves method would return 6, b/c 6 spaces have values, and 3 are nil\n if @board.moves.to_i.even? == true\n current_player = @player[0]\n # if moves is an even number set current_player equal to the first object in @players\n # @players = [\"X\", \"O\"]\n elsif \n current_player = @player[1]\n end\n current_player\n # for our example this would return \"X\", if the moves method returned an odd number it would be \"O\"\n end",
"def board_refresh\n print_board(@@piece_locations)\n end",
"def board\n\n end",
"def set_move move\n@board[move] = @player\nend",
"def move(board, index, current_player)\n @board[index] = current_player\nend",
"def move(board)\nend",
"def board\n end",
"def play\n\t\tboard = Board.new # cree une instance de la class board\n\t\tfor i in 1..9 # fait une boucle qui vas de 1 a 9, quand on arrive a 9 ca veut dire que toutes les cases du tableau on ete remplis. \n\t\t\tboard.display_stat(@player_one.return_name, @player_two.return_name, @player_one.return_number_of_win, @player_two.return_number_of_win, @player_two.return_number_of_egality) # on appel la methode display stats qui vas servire a affichier les statistiques, nombre de parties, nom des joueurs, leur nombre de victoires...\n\t\t\tif @who_play == 1 # on cree une condition qui vas servire a afficher le nom du joueur qui doit jouer ce tours.\n\t\t\t\tputs \"A toi de jouer #{@player_one.return_name.colorize(:green)} !\\n\\n\\n\"\n\t\t\telse\n\t\t\t\tputs \"A toi de jouer #{@player_two.return_name.colorize(:green)} !\\n\\n\\n\"\n\t\t\tend\n\t\t\tboard.display_board(@board_case) # on affiche le plateau du jeux\n\t\t\tselect_board_case # on appel la methode qui demande a l'utilisateur de choisire la case sur laquel il vas jouer\n\t\t\tif is_win == true # on fait une condition qui appel la methode is_win, cette methode verifi si il y a un cas de victoire\n\t\t\t\tboard.display_board(@board_case) # on affiche le plateau une derniere fois pour montrer la derniere modification\n\t\t\t\tif @who_play == 1 # on fait une condition qui verifie qui a gagner\n\t\t\t\t\tputs \"le joueur #{@player_one.return_name} a gagner cette partie!\" # si c'est le joueur 1 qui a gagner on dit qu'il a gagner, on affiche son nom\n\t\t\t\t\t@player_one.increments_number_of_win\t# on incremente du nombre de victoire \n\t\t\t\telse\n\t\t\t\t\tputs \"le joueur #{@player_two.return_name} a gagner cette partie!\"\n\t\t\t\t\t@player_two.increments_number_of_win\n\t\t\t\tend\n\t\t\t\tbreak # On quitte la boucle car il y a eu une victoire\n\t\t\tend\n\t\t\t@who_play == 1 ? @who_play = 2 : @who_play = 1 # cette ligne sert a faire que c'est a l'autre joueur de jouer (c'est une condition de type ternaire)\n\t\tend\n\t\tif is_win == false # si on sort de la boucle et qu'il n'y a aucune victoire alor c'est un match nul\n\t\t\t@player_one.increments_number_of_egality # on incremente la variable qui compte le nombres de matchs nuls\n\t\t\t@player_two.increments_number_of_egality\n\t\t\tputs \"MATCH NULLLLLLL\".colorize(:red) # on affiche que c'est un match nul\n\t\tend\n\tend",
"def setup_board\n @startup = true\n @board = @board.map{|col| col.map{|piece| Piece.new if piece.nil?}}\n clear_matches\n @startup = false\n @pieces_removed = 0\n end",
"def resetBoard (player)\n\t\tif(player.side == 1)\n\t\t\t@p1Board.each do |c|\n\t\t\t\tc.played = false\n\t\t\tend\n\t\telsif(player.side == 2)\n\t\t\t@p2Board.each do |c|\n\t\t\t\tc.played = false\n\t\t\tend\n\t\tend\n\tend",
"def turn\n puts \"#{@player_1.name}'s turn.\"\n puts \"Choose your case:\"\n print \">\"\n check_if_empty(@player_1)\n if win\n @board.print_board\n return true\n end\n @board.print_board\n puts \"#{@player_2.name}'s turn.\"\n puts \"Choose your case:\"\n print \">\"\n check_if_empty(@player_2)\n if win\n @board.print_board\n return true\n end\n @board.print_board\n end",
"def make_move(move)\n\t\t@board[move]= $current_player\n\tend",
"def play\n #self.set_players # Only uncomment one of these two lines.\n self.set_computer_players # Uncomment this line to have two computer players\n until @board.winner?\n self.turn\n self.change_current_player\n end\n winner = (@current_player == @player1) ? @player2 : @player1\n puts \" #{winner.color.to_s.upcase} is the winner!!!!\"\n puts \"Thanks for playing.\"\n end",
"def populate_board\n #the six rows get updated\n players.each do |player|\n rows = player == players[0] ? [ 0,1,2 ] : [ 5,6,7 ]\n piece_count = 0\n col = 0\n\n player.pieces.each do |piece|\n\n rows.shift if piece_count % 4 == 0 and piece_count != 0\n\n col_start = rows[0] % 2 == 1 ? 0 : 1\n col = 0 if (col_start == 0 || col_start == 1) && piece_count % 4 == 0\n\n piece.position = [col + col_start, rows[0]]\n squares[[col + col_start, rows[0]]] = piece\n\n col += 2\n piece_count += 1\n\n end\n\n end\n\n end",
"def move(board)\n \trandom_move(board)\n\tend",
"def play\n\n @board.render(clear=true)\n until @board.won? \n\n # should call reveal two time\n guess_1 = @board.reveal # gonna get position guess from the user and return the value\n @board.render(clear=true)\n guess_2 = @board.reveal # gonna get position guess from the user and return the value\n @board.render(clear=true)\n \n if guess_1 == guess_2\n puts \"It's a match!\" \n else\n # reset the board - set all card to face_up == false\n puts \"Try Again!\"\n @board.reset \n end\n sleep 3\n \n @board.render(clear=true)\n end\n end",
"def reset_board\n @board = [1, 2, 3, 4, 5, 6, 7, 8, 9]\n end",
"def play(board)\n 9.times do |variable|\n turn(board)\n end\n end",
"def play\n @board.print_board\n 9.times do |turns|\n if turn\n break\n end\n end\n end",
"def play_turn(player)\n puts \"Tour #{@count_turn}\"\n puts \"C'est au tour de #{player.name} (#{player.symbol})\"\n puts \"Quelle case souhaitez-vous jouer ?\"\n print \"> \"\n boardcase_selected = gets.chomp.to_s\n # Check if boardcase_selected exists\n if @boardcases.count { |b_case| b_case.case_id.include?(boardcase_selected) } == 1\n @boardcases.each do |b_case|\n # Check if boardcase selected exists and its value has not been modified yet\n if b_case.case_id == boardcase_selected && b_case.case_value == \" \"\n b_case.case_value = player.symbol\n end\n end\n else\n puts \"La case sélectionnée n'est pas valide\"\n end\n Show.new.show_board(self)\n @count_turn += 1\n end",
"def comp_turn\n index = computer_index\n if valid_move?(index)\n move(index, current_player)\n display_board\n else\n comp_turn\n end\n end",
"def take_turn(turn_value)\n turn = turn_value\n \n if turn.even? \n @player_human.move(@board)\n puts drawgrid \n is_a_human_win(@board) \n else\n @player_computer.move(@board)\n puts drawgrid \n is_a_computer_win(@board) \n end \n end",
"def play\n # To start, the method takes two arguments, the players and board array. \n while @board.winner == false\n # Then I set up a while loop that will keep going until there is no winner.\n @board.display_board\n # I started by calling the display_board method (from the Board Class) to show \n # the array in the traditional Tic-Tac-Toe formatting. \n cell_prompt\n # I Prompt the Player to make their selection. \n get_move\n # Here is where the Player imputs their selection. \n @board.update_cell\n # Update_cell (from the Board Class) will take the Player's input and update the value of the object at the \n # corresponding Board[index]. \n if @board.winner == true \n puts @board.winner\n break\n # This ends the loop if there has been a winner.\n elsif @board.draw == true\n break\n # This ends the loop if the match is a draw. \n end\n end\n # Otherwise, the loop keeps going. \n end",
"def set(num)\n player_id = @players[@turn % 2].id\n @board[num - 1] = @player_char[player_id]\n @turn += 1\n end",
"def plays(game_board, case_to_play)\n\t\tgame_board.change_case(case_to_play, @camp)\n\t\t@turn_to_play = 0\n\tend",
"def move(board, index, current_player)\n board[index] = current_player\n end",
"def play(board)\n counter = 0\n until counter == 9\n turn(@board)\n counter += 1\n end\n end",
"def update_board(move)\n for i in 0...@board.length\n if move == @board[i]\n # replaces number with either X or O\n @board[i] = @taken[move]\n end\n end\n end",
"def update_board \n\t@the_board = Board.new(array[0].position, array[1].position, array[2].position, array[3].position, array[4].position, array[5].position, array[6].position, array[7].position, array[8].position) \n\t@the_board.display \n end",
"def view_turn\n Display.draw_board(@cur_board, @player_white, @player_black)\n Display.move_info(@turn, @player_to_move, FileReader.get_move(\"#{@turn}#{@player_to_move}\", @data))\n end",
"def update_move(board, player, position)\n\tboard[position.to_i - 1] = player\n\tboard\nend",
"def display_board(turn)\n # binding.pry\n temp_index = 0\n turn += 1\n turn.times do\n puts \"#{@board[temp_index][0]} #{@board[temp_index][1]} #{@board[temp_index][2]}\"\n temp_index += 1\n end\n end",
"def play\n until game_over\n start_new_turn\n show_board\n make_move @current_player\n end\n show_board\n puts \"#{game_over} wins!\"\n end",
"def increment_game\n change_turn\n @turn += 1 if @player_to_move == \"w\"\n end",
"def move(board, position, current_player)\n board[position] = current_player\nend",
"def play\n until @board.winner?(:X) || @board.winner?(:O)\n p \"#{@current_player.mark}'s turn\"\n @board.print\n self.play_turn\n end\n\n @board.print\n self.switch_players!\n p \"#{@current_player.mark} has won!\"\n end",
"def player_move(board, index, marker)\n board[index] = marker\n end",
"def move(board)\n\t\tgood = false\n\t\tuntil good == true\n\t\t\t@board.board = board\t\t\n\t\t\tai_pieces = Array.new\n\t\t\t@board.board.each do |key, piece|\n\t\t\t\tif piece.color == 'black'\n\t\t\t\t\tai_pieces << key\n\t\t\t\tend\n\t\t\tend\n\t\t\tai_pieces.each do |piece|\n\t\t\tend\n\t\t\tpiece_to_move = ai_pieces[rand(ai_pieces.length)]\n\t\t\tavailable_moves = board[piece_to_move].moves\n\t\t\tif available_moves.length > 0\n\t\t\t\ttarget = available_moves[rand(available_moves.length)]\n\t\t\t\tgood = @board.move(piece_to_move, target, 'black')\n\t\t\tend\n\t\tend\n\t\t@board\n\tend",
"def change_board(spot, symbol)\n 'WARNING: Tried to change taken spot, time to debug.' unless @board[spot] == ' '\n @board[spot] = symbol\n end",
"def move( index, current_player = \"X\" )\n @board[index] = current_player\n end",
"def switch_player\n @current_player = if @current_player == @player_o\n @player_x\n else\n @player_o\n end\n\n @number_of_turns += 1\n end",
"def player_move(board, index, current_player_token)\r\n board[index] = current_player_token\r\nend",
"def process_player_turn\n\t\tself.current_player = \"Computer\"\n\t\tindicate_player_turn\n\t\tplayer_good_move= self.get_good_move\n\t\tchange_state(player_symbol, player_good_move)\n\t\tplayer_good_move\n\tend",
"def move(board, index, current_player)\r\n board[index] = current_player\r\nend",
"def turns\n puts \"#{@p1_name} your move?\"\n p1_move = gets.chomp\n @board[p1_move] = @p1\n puts \"#{@p2_name} where will your move be? Remember the last move occupied position #{p1_move}\"\n p2_move = gets.chomp\n @board[p2_move] = @p2\nend",
"def win(boord)\n if board[0] == 'X' && board[0] == 'X'\n end\n\n\n def display_board\n puts\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]}\"\n puts \"-\" * 11\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]}\"\n puts \"-\" * 11\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]}\"\n puts\n end\n\n def one_player_game\n turn = rand(1)\n available_turns = 9\n while available_turns > 0\n display_board\n if turn % 2 == 1\n puts \"Player 1, please pick a square from 1 to 9\"\n p1 = gets.chomp.to_i\n if @board[p1-1] == \" \"\n @board[p1-1] = \"X\"\n available_turns -= 1\n turn += 1\n else\n puts \"That square is already taken - please try another.\"\n end\n else\n p2 = rand(9)\n if @board[p2-1] == \" \"\n @board.delete_at(p2-1)\n @board.insert(p2-1, \"O\")\n puts \"Computer player chooses square #{p2}\"\n available_turns -= 1\n turn += 1\n else\n puts \"That square is already taken - please try another.\"\n end\n end\n end\n end_game\n end\n\n def two_player_game\n turn = rand(1)\n available_turns = 9\n while available_turns > 0 && win == \"no\"\n display_board\n if turn % 2 == 1\n puts \"Player 1, please pick a square from 1 to 9\"\n p1 = gets.chomp.to_i\n if @board[p1-1] == \" \"\n @board.delete_at(p1-1)\n @board.insert(p1 - 1, \"X\")\n available_turns -= 1\n turn += 1\n else\n puts \"That square is already taken - please try another.\"\n end\n else\n puts \"Player 2, please pick a square from 1 to 9\"\n p2 = gets.chomp.to_i\n if @board[p2-1] == \" \"\n @board.delete_at(p2-1)\n @board.insert(p2-1, \"O\")\n available_turns -= 1\n turn += 1\n else\n puts \"That square is already taken - please try another.\"\n end\n end\n end\n end_game\n end\n\n def start_game\n available_turns = 9\n while available_turns == 9\n puts\n puts \"*\" * 36\n puts \"Are you ready for some Tic-Tac-Toe?!\"\n puts \"*\" * 36\n puts\n input = gets.chomp.downcase\n if input == \"yes\"\n puts\n puts \"*\" * 36\n puts \"One player or two?\"\n puts \"*\" * 36\n puts\n player_num = gets.chomp.downcase\n if player_num == \"one\"\n one_player_game\n else\n two_player_game\n end\n else\n puts \"Your loss, buddy!\"\n exit!\n end\n end\n end\nend",
"def turn\n move = self.current_player.move(self.board)\n # binding.pry\n if self.board.valid_move?(move)\n self.board.update(move, self.current_player)\n else\n puts \"Invalid entry. Please enter a valid space number 1-9.\"\n self.turn\n end\n end",
"def turn_card(guess)\n @board[guess].reveal\n @player.store_cards(guess, @board[guess].value)\n p @player.store\n end",
"def play_turn(board)\n jumps = board.find_jumps(@color)\n slides = board.find_slides(@color)\n move = (!jumps.empty?) ? [jumps.sample] : [slides.sample]\n readable_move = make_readable(move)\n puts \"Computer plays #{readable_move[0]} to #{readable_move[1]}\"\n move\n end",
"def move(board,index,current_player)\n board[index] = current_player\nend",
"def current_player_moves\r\n current_player.play(board)\r\n end",
"def play\n welcome\n loop do\n #lines 17-19 are my favorite\n until @game_board.drop_token(@current_player.get_move_column,@current_player.game_token) do \n puts \"Column full! Please choose another column!\"\n binding.pry\n print \">\"\n end\n @game_board.board_render\n swap_players\n end\n end"
] |
[
"0.8102404",
"0.7805564",
"0.773246",
"0.7715782",
"0.768786",
"0.7647275",
"0.7639785",
"0.7625166",
"0.76076376",
"0.7606632",
"0.7598623",
"0.75931555",
"0.75767934",
"0.75388366",
"0.75085104",
"0.7506252",
"0.747426",
"0.747426",
"0.7466406",
"0.7455933",
"0.74388796",
"0.74318296",
"0.74106115",
"0.7401146",
"0.7262798",
"0.72613114",
"0.7222695",
"0.7221865",
"0.7209565",
"0.718735",
"0.71618664",
"0.7157",
"0.711103",
"0.7103872",
"0.7097292",
"0.7086646",
"0.7082176",
"0.7080653",
"0.70399356",
"0.70236886",
"0.70185345",
"0.7011001",
"0.70087975",
"0.6996923",
"0.6977842",
"0.69770813",
"0.6972544",
"0.6972544",
"0.69609314",
"0.6946863",
"0.69457495",
"0.6932833",
"0.69270015",
"0.69256186",
"0.69228846",
"0.6902811",
"0.6890268",
"0.68871975",
"0.6886771",
"0.6886289",
"0.6882171",
"0.687568",
"0.68643075",
"0.6863696",
"0.68540996",
"0.6852707",
"0.68492717",
"0.6844288",
"0.68401086",
"0.68363875",
"0.6834876",
"0.6834096",
"0.68286777",
"0.6824451",
"0.68179196",
"0.680833",
"0.6808048",
"0.6793536",
"0.679183",
"0.6772362",
"0.67708445",
"0.6766424",
"0.6761488",
"0.6758894",
"0.67512536",
"0.6748592",
"0.6745811",
"0.67454505",
"0.6745385",
"0.6744553",
"0.6741105",
"0.67408013",
"0.6735679",
"0.6734001",
"0.67325485",
"0.6727706",
"0.6727385",
"0.6726073",
"0.6725635",
"0.67247015",
"0.6720353"
] |
0.0
|
-1
|
show the current state of the board
|
def show_board
i = 0
while i < board.length
j = 0
while j < board[i].length
print board[i][j]
j += 1
end
print "\n"
i += 1
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def display\n puts \"===Current Board Status===\"\n @bingo_board.each { |row| puts print row }\n end",
"def display_board\n board =\n \" _______ _______ _______\n | | | |\n A| #{@state[:A1]} | #{@state[:A2]} | #{@state[:A3]} |\n |_______|_______|_______|\n | | | |\n B| #{@state[:B1]} | #{@state[:B2]} | #{@state[:B3]} |\n |_______|_______|_______|\n | | | |\n C| #{@state[:C1]} | #{@state[:C2]} | #{@state[:C3]} |\n |_______|_______|_______|\n 1 2 3\n \"\n puts board\n end",
"def display_board(state)\n i = -1\n puts \" #{state[i+=1]} | #{state[i+=1]} | #{state[i+=1]} \"\n puts(\"-----------\")\n puts \" #{state[i+=1]} | #{state[i+=1]} | #{state[i+=1]} \"\n puts(\"-----------\")\n puts \" #{state[i+=1]} | #{state[i+=1]} | #{state[i+=1]} \"\nend",
"def show()\n\t\tputs (' \t|\t' + ' \t|\t')\n\t\tputs (@@board[7] + '\t|\t' + @@board[8] + '\t|\t' + @@board[9])\n\t\tputs ('------------------------------------')\n\t\tputs (@@board[4] + '\t|\t' + @@board[5] + '\t|\t' + @@board[6])\n\t\tputs (' \t|\t' + ' \t|\t')\n\t\tputs ('------------------------------------')\n\t\tputs (@@board[1] + '\t|\t' + @@board[2] + '\t|\t' + @@board[3])\n\t\tputs (' \t|\t' + ' \t|\t')\n\tend",
"def display_board(board_state)\n #row 1\n puts \" #{board_state[0]} | #{board_state[1]} | #{board_state[2]} \"\n puts \"-----------\"\n #row 2\n puts \" #{board_state[3]} | #{board_state[4]} | #{board_state[5]} \"\n puts \"-----------\"\n #row 3\n puts \" #{board_state[6]} | #{board_state[7]} | #{board_state[8]} \"\nend",
"def state\n board.state(index)\n end",
"def display_board\n\t\t\tsystem(\"cls\")\n\t\t\tprint \"\\n\"\n\t\t\t 7.downto(0).each_with_index{|x|\n\t\t\t\t print \"#{x+1}| \"\n\t\t\t\t\t8.times{|y|\n\t\t\t\t\tif y%2==0 && x%2 == 0 || y%2==1 && x%2 == 1\n\t\t\t\t\t\tif @board[y][x] != nil && @board[y][x].color == \"white\"\n\t\t\t\t\t\t\tprint @board[y][x].class.to_s[0].white.bold.on_red, \" \".on_red\n\t\t\t\t\t\telsif @board[y][x] != nil && @board[y][x].color == \"black\"\n\t\t\t\t\t\t\tprint @board[y][x].class.to_s[0].green.bold.on_red, \" \".on_red\n\t\t\t\t\t\telse \n\t\t\t\t\t\t\tprint \" \".on_red\n\t\t\t\t\t\tend\n\t\t\t\t\telse\n\t\t\t\t\t\tif @board[y][x] != nil && @board[y][x].color == \"white\"\n\t\t\t\t\t\t\tprint @board[y][x].class.to_s[0].white.bold, \" \"\n\t\t\t\t\t\telsif @board[y][x] != nil && @board[y][x].color == \"black\"\n\t\t\t\t\t\t\tprint @board[y][x].class.to_s[0].green.bold, \" \"\n\t\t\t\t\t\telse \n\t\t\t\t\t\t\tprint \" \", \" \"\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\t\t}\n\t\t\t\tprint \"\\n\"\n\t\t\t\t }\n\t\t\t print \"------------------\\n\"\n\t\t\t print \" a b c d e f g h\\n\\n\"\n\tend",
"def board_display\n puts @board\n end",
"def display_board(gameState)\n puts \" #{gameState[0]} | #{gameState[1]} | #{gameState[2]} \"\n puts \"-----------\"\n puts \" #{gameState[3]} | #{gameState[4]} | #{gameState[5]} \"\n puts \"-----------\"\n puts \" #{gameState[6]} | #{gameState[7]} | #{gameState[8]} \"\nend",
"def display_board\n\n puts \" #{@board[0].mark} | #{@board[1].mark} | #{@board[2].mark} \"\n puts \"-----------\"\n puts \" #{@board[3].mark} | #{@board[4].mark} | #{@board[5].mark} \"\n puts \"-----------\"\n puts \" #{@board[6].mark} | #{@board[7].mark} | #{@board[8].mark} \"\n end",
"def show_board\n puts \" \" + board_spaces[1] + \" | \" + board_spaces[2] + \" | \" + board_spaces[3] + \" \"\n puts \"-----------\"\n puts \" \" + board_spaces[4] + \" | \" + board_spaces[5] + \" | \" + board_spaces[6] + \" \"\n puts \"-----------\"\n puts \" \" + board_spaces[7] + \" | \" + board_spaces[8] + \" | \" + board_spaces[9] + \" \"\n end",
"def board\n s = $state\n \n puts \"\n 1 2 3\n\n a #{s[0]} | #{s[1]} | #{s[2]}\n ---+---+---\n b #{s[3]} | #{s[4]} | #{s[5]}\n ---+---+---\n c #{s[6]} | #{s[7]} | #{s[8]}\n \"\nend",
"def display\n system('clear')\n puts\n # show board with pieces\n print \"\\t\\tA\\tB\\tC\\tD\\tE\\tF\\tG\\tH\\n\\n\"\n print \"\\t +\", \" ----- +\"*8,\"\\n\\n\"\n 8.downto(1) do |rank|\n print \"\\t#{rank} |\\t\"\n 'A'.upto('H') do |file|\n if board[\"#{file}#{rank}\".to_cell] then piece = board[\"#{file}#{rank}\".to_cell]\n else piece = \" \"\n end\n print \"#{piece} |\\t\"\n end\n print \"#{rank}\\n\\n\\t +\", \" ----- +\"*8,\"\\n\\n\"\n end\n print \"\\t\\tA\\tB\\tC\\tD\\tE\\tF\\tG\\tH\"\n puts \"\\n\\n\"\n # show occupancy\n print \" White occupancy: \"\n puts whitePieces.to_cells.map{ |cell| cell.to_square}.join(\", \")\n print \" Black occupancy: \"\n puts blackPieces.to_cells.map{ |cell| cell.to_square}.join(\", \")\n puts\n # show whose move it is\n case @whitesMove\n when true\n puts \" WHITE to move.\"\n when false\n puts \" BLACK to move.\"\n end\n puts\n end",
"def view_board\n row = [\"A\",\"B\",\"C\"]\n i = 0\n puts \" 1 2 3\"\n puts \" ___________\"\n @@tab.each do |y|\n puts \"#{row[i]}: | #{y[0].status} | #{y[1].status} | #{y[2].status} |\"\n puts \" |___________|\"\n i +=1\n end\n end",
"def print_state\n @@rows.times do |row|\n @@columns.times do |column|\n print '%4.4s' % @state_array[row * @@columns + column].to_s,\" \"\n end\n print \"\\n\"\n end\n print \"\\n\"\n end",
"def drawBoard\n\t$firstRow.each do |i|\n\t\ti.printState\n\tend\n\tnewLine\n\t$secondRow.each do |i|\n\t\ti.printState\n\tend\n\tnewLine\n\t$thirdRow.each do |i|\n\t\ti.printState\n\tend\n\tnewLine\nend",
"def view_board\n row = [\"A\",\"B\",\"C\"]\n i = 0\n puts \" 1 2 3\"\n puts \" -------------\"\n @@tab.each do |y|\n puts \"#{row[i]}: | #{y[0].status} | #{y[1].status} | #{y[2].status} |\"\n puts \" -------------\"\n i +=1\n end\n end",
"def display_board\n\t board =\" | | \\n-----------\\n | | \\n-----------\\n | | \"\n\t puts board\n\tend",
"def showboard(currentBoard)\n\t puts \"\"\n\t print \"********\"\n\t puts \"\"\n\t print \" \" + currentBoard[:a3] +\n\t \t \" \" + currentBoard[:b3] +\n\t \t \" \" + currentBoard[:c3]\n\t puts \"\"\n\t print \" \" + currentBoard[:a2] +\n\t \t \" \" + currentBoard[:b2] +\n\t \t \" \" + currentBoard[:c2]\n\t puts \"\"\n\t print \" \" + currentBoard[:a1] +\n\t \t \" \" + currentBoard[:b1] +\n\t \t \" \" + currentBoard[:c1]\n\t puts \"\"\n\t puts \"\"\n\t print \"********\"\n\t puts \"\"\n\tend",
"def show_board\n @display.each do |row|\n puts row.join(' ')\n end\n end",
"def show_state\n puts \"#{name} a #{life_points} points de vie !!\"\n end",
"def display\n puts \"\\n GAME BOARD \"\n puts \" Turn #{turn_count}\"\n puts \"*************\"\n puts \"* #{self.cells[0]} | #{self.cells[1]} | #{self.cells[2]} *\"\n puts \"*-----------*\"\n puts \"* #{self.cells[3]} | #{self.cells[4]} | #{self.cells[5]} *\"\n puts \"*-----------*\"\n puts \"* #{self.cells[6]} | #{self.cells[7]} | #{self.cells[8]} *\"\n puts \"*************\\n\\n\"\n end",
"def show_board # show the game board\n print @board[0..2]\n puts \"\\n\"\n print @board[3..5]\n puts \"\\n\"\n print @board[6..8]\n puts \"\\n\"\n end",
"def display_board\n puts\n puts \"Here is the current board:\"\n puts \n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"---+---+---\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"---+---+---\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n puts \n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def show_state\n puts \"#{name} a #{life_points} points de vie!\"\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"---------------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"---------------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board\n\t\tsystem \"clear\" or system \"cls\"\n\t\tprint \" 1 2 3 4 5 6 7 8 \\n\\n\"\n\t\t(0..7).each do |row|\n\t\t\tprint \"#{(row+97).chr} \"\n\t\t\t(0..7).each do |collumn|\n\t\t\t\tprint \"#{@board[row][collumn]} \" if @board[row][collumn] == \"X\"\n\t\t\t\tprint @board[row][collumn].to_s + \" \" if @board[row][collumn].is_a?(Piece)\n\t\t\tend\n\t\t\tprint \" #{(row+97).chr} \"\n\t\t\tputs\n\n\t\tend\n\t\tprint \"\\n 1 2 3 4 5 6 7 8 \\n\"\n\tend",
"def show_state\n\t\tputs \"#{@name} a #{@life_points} points de vie.\"\n\tend",
"def display_board\n puts \"#{@board[0].value} | #{@board[1].value} | #{@board[2].value}\"\n puts \"-\"*10\n puts \"#{@board[3].value} | #{@board[4].value} | #{@board[5].value}\"\n puts \"-\"*10\n puts \"#{@board[6].value} | #{@board[7].value} | #{@board[8].value}\"\n end",
"def show_board\n\t\ti = 1\n\t\tgame_board_string = \"\\r\\n\"\n\t\twhile i < 10\n\t\t\tgame_board_string += @board_status[i]\n\t\t\tif i % 3 == 0\n\t\t\t\tgame_board_string += \"\\r\\n\"\n\t\t\tend\n\t\t\ti += 1\n\t\tend\n\t\tgame_board_string += \"\\r\\n\"\n\t\treturn game_board_string\n\tend",
"def show_board\n\t\tputs \n\t\tputs \"-------------------\"\n\t\tputs \"Board so far: \"\n\t\t# Go through each guess and answers and display them\n\t\t@board.each_with_index { |guess, i| puts \"#{guess.join} #{@evaluate[i]}\" }\n\t\tputs \"-------------------\"\n\tend",
"def display\n puts \"#{@board.join(\" \")}\"\n end",
"def displayCurrentHand\n\t\t\theader = \"\\nCurrentBoard:\\n\"\n\t\t\t@board.length().times do |i|\n\t\t\t\tputs \"\\n\\t\"\n\t\t\t\tputs \"\\tCard #{i+1}\"\n\t\t\t\tputs @board[i]\n\t\t\tend\n\t\tend",
"def display_board()\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board()\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display\n @board.each do |key, value|\n puts \"#{key} - #{value}\"\n end\n end",
"def display_board\n puts \" | | \"\n puts \"-----------\"\n puts \" | | \"\n puts \"-----------\"\n puts \" | | \"\nend",
"def display_board\n puts \" | | \"\n puts \"-----------\"\n puts \" | | \"\n puts \"-----------\"\n puts \" | | \"\nend",
"def display_board\n puts \" | | \"\n puts\"-----------\"\n puts \" | | \"\n puts\"-----------\"\n puts \" | | \"\nend",
"def show_board\n puts\n @board.each_with_index do |square, i|\n print \" #{square} \"\n puts \"\\n\\n\" if (i == 2 || i == 5 || i == 8)\n end\n end",
"def show_state\n puts \"#{@name} a #{@life_points} points de vie.\"\n end",
"def display_board\n puts \" | | \" \n puts \"-----------\"\n puts \" | | \"\n puts \"-----------\"\n puts \" | | \"\nend",
"def display\n \"\\n=============COMPUTER BOARD=============\\n\" +\n \"#{@npc.board.render}\\n\" +\n \"==============PLAYER BOARD==============\\n\" +\n \"#{@user_board.render(true)}\\n\"\n end",
"def show_state\r\n puts \"#{@name} à #{@life_points} points de vie\"\r\n end",
"def display_board\n\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \" ----------- \"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \" ----------- \"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n\n end",
"def board\r\r\n @board = true\r\r\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \" ----------- \"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \" ----------- \"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def show_state\n \tputs \"#{@name} a #{life_points} points de vie\"\n end",
"def show_state\n puts \"#{@name} a #{@life_points} de vie\"\n end",
"def display_current(game_hash)\n\treset_screen\n\tputs pretty_board(hash_to_array(game_hash))\n\tsleep(0.001)\nend",
"def show_state\n puts \"#{@name} a #{@life_points} points de vie\"\n end",
"def displayState(position)\n print \"\\n\"\n for x in 0..2\n for y in 0..2\n print position[x][y].to_s+\" \"\n end\n print \"\\n\"\n end\n print \"\\n\"\n end",
"def display_game\n\t\t@current_config.each.with_index(1) { |row, index|\n\t\t\tprint \"Row #{index}: \"\n\t\t\trow.times{|num| print 'X'}\n\t\t\tputs \"\"\n\t\t}\n\tend",
"def show_valid_moves\n @board = Board.new(session[:state])\n @board.show_valid_moves\n end",
"def display_board\n puts \" \" + (\"_\" * 47)\n 8.downto(1) do |l|\n puts \" \" +(\"| \" * 8 ) + \"|\"\n puts \" #{l} | \" + @board[l-1].join(\" | \") + \" |\"\n puts \" \" +(\"|_____\" * 8 ) + \"|\"\n end\n puts (\" \" * 8) + ('a'..'h').to_a.join(\" \")\n end",
"def display\n @board.each { |x| \n puts x.join(\" \")\n }\n end",
"def show_state\n puts \"#{@name} a #{@life_points} points de vie et une arme de niveau #{@weapon_level}\"\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board\r\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\r\n puts \"-----------\"\r\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\r\n puts \"-----------\"\r\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\r\n end",
"def display_board\r\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\r\n puts \"-----------\"\r\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\r\n puts \"-----------\"\r\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\r\n end",
"def get_board_state\n board_repr = []\n\n for row in @board\n board_repr.push(row.reject(&:empty?).join(''))\n end\n\n board_repr.reject(&:empty?).join(\"\\n\")\n end",
"def show_state\n puts \"#{@name} à #{@life_points} points de vie\"\n end",
"def display_board\n puts \"#{human.name}: #{human.marker}, #{computer.name}: #{computer.marker}\"\n puts \"Round #{@round}.\"\n puts \"Score: #{human.score} - #{computer.score}\"\n puts \"\"\n board.draw\n puts \"\"\n end",
"def show_state \n puts \"#{@name} à #{@life_points} points de vie\"\n end",
"def show_state\n puts \"#{self.name} a #{self.life_points} points de vie.\"\n end",
"def display_board\n row_idx = -1\n numera = [1,2,3,4,5,6,7,8,9]\n @display = @grid.map do |row|\n \n col_idx = -1\n row_idx += 1 \n row.map do |col| \n col_idx += 1 \n if @flag_pair.include? ((row_idx.to_s) + (col_idx.to_s))\n col = 'F'.orange\n elsif col == :B\n col = 'H'.green\n elsif (@known_empty.include? ((row_idx.to_s) + (col_idx.to_s))) && (numera.include? col)\n col = col.to_s.red\n elsif @known_empty.include? ((row_idx.to_s) + (col_idx.to_s))\n col = 'O'.blue\n else\n col = 'H'.green\n end \n end \n end\n end",
"def show_state \n puts \"#{@name} a #{@life_points} points de vie.\"\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts '---------------'\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts '---------------'\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def view\n pos = [\"A\", \"8\"]\n while pos[1] != \"0\" do\n while pos[0] != \"I\" do\n # handle board column legend\n if pos[0] == \"A\"\n print pos[1]\n print \" \"\n end\n print \" \"\n piece = @board.nodes[pos.join].piece\n if piece != nil\n print piece.icon\n else \n # print @board.nodes[pos.join].position\n print \"\\u25A2\".encode\n end\n # print @board.nodes[pos.join].position\n print \" \"\n letter = pos[0].ord + 1\n pos[0] = letter.chr\n end\n print \"\\n\"\n num = pos[1].ord - 1\n pos[1] = num.chr\n pos[0] = \"A\"\n end\n # handle board row legend\n letters = (\"a\"..\"h\")\n print \" \"\n letters.each do |let|\n print \" \"\n print let\n print \" \"\n end\n print \"\\n\"\n end",
"def display_board\n\t\tputs \"\\n\\n\"\n\t\tprint \"|\\u2460 |\\u2461 |\\u2462 |\\u2463 |\\u2464 |\\u2465 |\\u2466 |\"\n\t\t@board.plastic.reverse.each do |row|\n\t\t\tprint \"\\n|\"\n\t\t\trow.each {|x| print \"#{x.to_c} |\"} \t\t\t\n\t\tend\n\t\tputs \"\"\n\tend",
"def show_state\n puts \"#{name} à #{life_points} points de vie\"\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def show_state\n\t\tputs \"#{self.name} a #{self.life_points} points de vie et une arme de niveau #{self.weapon_level}.\"\n\tend",
"def print_board\n\t\tcell_index=1\n\t\tputs \"\\n\\n\\t[A]\\t[B]\\t[C]\"\n\t\t@cell_status.each_key do |cell|\n\t\t\tcase cell\n\t\t\twhen \"A1\" \n\t\t\t\tprint \" [1]\\t #{marker_on_cell(cell)}\"\n\t\t\twhen \"B1\" \n\t\t\t\tprint \" | #{marker_on_cell(cell)}\"\n\t\t\twhen \"C1\" \n\t\t\t\tprint \" |\\t#{marker_on_cell(cell)}\\n\"\n\t\t\t\tputs \"\\t--------------------\"\n\t\t\twhen \"A2\" \n\t\t\t\tprint \" [2]\\t #{marker_on_cell(cell)}\"\n\t\t\twhen \"B2\" \n\t\t\t\tprint \" | #{marker_on_cell(cell)}\"\n\t\t\twhen \"C2\" \n\t\t\t\tprint \" |\\t#{marker_on_cell(cell)}\\n\"\n\t\t\t\tputs \"\\t--------------------\"\n\t\t\twhen \"A3\" \n\t\t\t\tprint \" [3]\\t #{marker_on_cell(cell)}\"\n\t\t\twhen \"B3\" \n\t\t\t\tprint \" | #{marker_on_cell(cell)}\"\n\t\t\twhen \"C3\" \n\t\t\t\tprint \" |\\t#{marker_on_cell(cell)}\\n\"\n\t\t\tend\t\n\t\tend\n\tend",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display\n puts \"+-------------------+\"\n\n for row in 0..BOARD_MAX_INDEX\n print '|'\n for col in 0..BOARD_MAX_INDEX\n s=@board[row][col]\n if s==EMPTY_POS\n print col+(row*3)+1\n else\n print s\n end\n print \"|\"\n end\n puts \"\"\n end\n print \"\\n+--------------+\"\n\n end",
"def draw\n @board.to_s\n end",
"def show\n @board_grid = @board.board_grid\n @winner = has_player_won(1, @board_grid)\n @loser = has_player_won(2, @board_grid)\n end",
"def show_state\n puts \"#{@name} a #{@life_points} de PV\"\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n\n end",
"def display_board\n puts \" \" \"|\" \" \" \"|\" \" \"\n puts \"-----------\"\n puts \" \" \"|\" \" \" \"|\" \" \"\n puts \"-----------\"\n puts \" \" \"|\" \" \" \"|\" \" \"\nend",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def board\n # Returns a printed copy of the board\n end",
"def display_board\n\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n\n end",
"def show_state\n puts \"#{self.name} a #{self.life_points} points de vie et son arme est de niveau #{self.weapon_level}.\"\n end",
"def show_state\n puts \"#{names} a #{life_points} points de vie\"\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \" \n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def print_board\n\t\tputs \"GAME BOARD AT TIME: #{@current_turn}\"\n\t\tprint full_game_board.map{|c| c.join(\"\")}.join(\"\\n\")\n\tend",
"def show_state\n\t\tputs \"#{@name} a #{life_points} de points de vie et une arme de niveau #{weapon_level}\"\n\tend",
"def display_board\n str = \"\"\n 5.downto(0) do |i|\n @board.each {|row| str += row[i].to_s + \" \"}\n str += \"\\n\"\n end\n puts str\n end"
] |
[
"0.7617608",
"0.75484383",
"0.7472257",
"0.7432845",
"0.7389793",
"0.7350878",
"0.7260307",
"0.7223427",
"0.7216529",
"0.715123",
"0.7107057",
"0.7088462",
"0.7060572",
"0.7056883",
"0.70512",
"0.70473623",
"0.7043213",
"0.7008691",
"0.70036346",
"0.70026743",
"0.6998717",
"0.6997282",
"0.69935656",
"0.69923097",
"0.6980367",
"0.6971338",
"0.6961189",
"0.6954993",
"0.6954231",
"0.69377404",
"0.6926246",
"0.69239074",
"0.6923886",
"0.69238406",
"0.69180274",
"0.69180274",
"0.69043636",
"0.69028705",
"0.69028705",
"0.69018525",
"0.6887361",
"0.6880807",
"0.6870045",
"0.6868034",
"0.6862285",
"0.6860624",
"0.6838159",
"0.6837379",
"0.6837251",
"0.6836147",
"0.68313265",
"0.68309444",
"0.6821377",
"0.6820823",
"0.6812993",
"0.6802756",
"0.6799383",
"0.679506",
"0.6786203",
"0.6786203",
"0.6786203",
"0.6786203",
"0.6786203",
"0.6786203",
"0.6786203",
"0.6786203",
"0.6786203",
"0.6786203",
"0.6786203",
"0.67842263",
"0.67842263",
"0.6780372",
"0.6779033",
"0.6778679",
"0.6773856",
"0.6771236",
"0.6767903",
"0.6764306",
"0.6747286",
"0.6746063",
"0.67442095",
"0.6735052",
"0.6731422",
"0.67249113",
"0.6713281",
"0.67120904",
"0.6705286",
"0.67050856",
"0.67048115",
"0.67010885",
"0.66823995",
"0.6675406",
"0.66693616",
"0.66659814",
"0.6663626",
"0.6662738",
"0.66493225",
"0.6648135",
"0.6646687",
"0.6639874",
"0.6637583"
] |
0.0
|
-1
|
look if some diagonal or the row or the column of the last player movement provides a winner for the game
|
def find_winner(move)
condition1 = (move / 3).ceil * 3
condition2 = (move - 1) % 3
line = players[turn % 2].symbol + players[turn % 2].symbol + players[turn % 2].symbol
winner_conditions(condition1, condition2, line)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def check_winner\n cells_t = cells.transpose\n row_winner(cells)\n row_winner(cells_t)\n diagonal_winner unless winner\n announce_winner if winner\n winner\n end",
"def has_winner?\n (@last_insert_x > 0) ? (check_column || check_row) : false\n \n end",
"def check_columns_for_winner\n # @player = nil\n if board[0][0] == board[1][0] and board[1][0] == board[2][0] and not board[0][0] == nil\n @player = board[0][0]\n elsif board[0][1] == board[1][1] and board[1][1] == board[2][1] and not board[0][1] == nil\n @player = board[0][1]\n elsif board[0][2] == board[1][2] and board[1][2] == board[2][2] and not board[0][2] == nil\n @player = board[0][2]\n end\n end",
"def winner?\n directions = [[1,0], [1,-1], [1,1], [0,1]]\n max_x = grid[0].length\n max_y = grid.length\n directions.each do |dx, dy|\n for x in (0...max_x) do\n for y in (0...max_y) do\n last_x = x + 3 * dx\n last_y = y + 3 * dy\n if 0 <= last_x && last_x < max_x && 0 <= last_y && last_y < max_y\n val = get_cell(x, y).value\n if (!val.empty? && val == get_cell(x + dx, y + dy).value && \n val == get_cell(x + 2 * dx, y + 2 * dy).value &&\n val == get_cell(x + 3 * dx, y + 3 * dy).value)\n return true\n end\n end\n end\n end\n end\n return false\n end",
"def won?\n #diagonals first\n has_left_diagonal = true\n has_right_diagonal = true\n (1..@board.length-1).each do |i|\n has_left_diagonal = false unless @board[i][i] == @board[0][0]\n has_right_diagonal = false unless @board[i][-1-i] == @board[0][-1]\n end\n return @board[0][0] if has_left_diagonal\n return @board[-1][0] if has_right_diagonal\n \n #check rows\n (0..@board.length-1).each do |i|\n #slightly more concise but costly ( O(n^2) per uniq ) than a manual check\n return @board[i][0] if @board[i].uniq.length == 1\n end\n \n #check columns\n (0..@board.length-1).each do |i|\n player = @board[0][i]\n has_column = true\n (1..@board.length-1).each do |j|\n has_column = false unless @board[j][i] == player\n end\n return player if has_column\n end\n \n return 0\n end",
"def is_winner(x, y, player)\n return true if check_row(x, player)\n return true if check_col(y, player)\n return true if check_diagonals(player)\n return false\n end",
"def check_for_winner\n\t\tdid_player_win = false\n\t\tx = 1\n\t\twhile x < 8\n\t\t\ty = 1\n\t\t\twhile y < 7\n\t\t\t\tcurrent_key = \"#{x}-#{y}\"\n\t\t\t\tcurrent_hole = game_board[current_key]\n\t\t\t\t@x_to_check = x\n\t\t\t\t@y_to_check = y\n\t\t\t\tif current_hole.owned_by_player == @current_player\n\t\t\t\t\tdid_player_win = check_for_line(x, y)\n\t\t\t\t\tif did_player_win\n\t\t\t\t\t\treturn true\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\ty += 1\n\t\t\tend\n\t\t\tx += 1\n\t\tend\n\t\treturn false\n\tend",
"def check_board\n\n # starting at top left, check top row, diagonal and left column\n if ( ($game_board[0][0] == $game_board[0][1] && $game_board[0][0] == $game_board[0][2]) ||\n ($game_board[0][0] == $game_board[1][1] && $game_board[0][0] == $game_board[2][2]) ||\n ($game_board[0][0] == $game_board[1][0] && $game_board[0][0] == $game_board[2][0]) )\n $winner = $game_board[0][0] \n\n # starting at top middle, check middle column\n elsif ($game_board[0][1] == $game_board[1][1] && $game_board[0][1] == $game_board[2][1])\n $winner = $game_board[0][1]\n\n #starting at top right, check right column and diagonal\n elsif (($game_board[0][2] == $game_board[1][2] && $game_board[0][2] == $game_board[2][2]) ||\n ($game_board[0][2] == $game_board[1][1] && $game_board[0][2] == $game_board[2][0]))\n $winner = $game_board[0][2]\n\n #starting at middle left, check middle row\n elsif ($game_board[1][0] == $game_board[1][1] && $game_board[1][0] == $game_board[1][2])\n $winner = $game_board[1][0]\n\n #starting at bottom left, check bottom row\n elsif ($game_board[2][0] == $game_board[2][1] && $game_board[2][0] == $game_board[2][2])\n $winner = $game_board[2][0]\n end\n \n if $winner\n puts $winner.to_s + \" wins!\" \n exit\n end\n \n #if we don't have a winner at this point, and all the spaces are filled (not nil), then it's a tie\n if $game_board.flatten.all?\n puts \"It's a tie!\"\n exit\n end\n \nend",
"def check_win(player,grid,coordinates)\n win = false\n win_array = []\n play_row = coordinates[0]\n play_col = coordinates[1]\n\n # horizontal checking\n grid[play_row].each_index do | col |\n if win_array.length != 4\n if grid[play_row][col] == player\n win_array.push([play_row,col])\n else\n win_array = []\n end\n end\n end\n\n if win_array.length == 4\n win = true\n end\n\n # vertical checking\n if win == false\n\n win_array = []\n\n grid.each_index do | row |\n if win_array.length != 4\n if grid[row][play_col] == player\n win_array.push([row,play_col])\n else\n win_array = []\n end\n end\n end\n\n if win_array.length == 4\n win = true\n end\n end\n\n # diagonal checking SW to NE\n if win == false\n\n win_array = []\n row = play_row\n col = play_col\n\n # finds SW-most position in same diagonal line as most recently played piece\n # this is the starting point we check from\n until col == 0 || row == 7\n row += 1\n col -= 1\n end\n\n until col > 7 || row < 0\n if win_array.length != 4\n if grid[row][col] == player\n win_array.push([row,col])\n else\n win_array = []\n end\n end\n row -= 1\n col += 1\n end\n\n if win_array.length == 4\n win = true\n end\n end\n\n # diagonal checking NW to SE\n if win == false\n\n win_array = []\n row = play_row\n col = play_col\n\n # finds NW-most position in same diagonal line as most recently played piece\n # this is the starting point we check from\n until col == 0 || row == 0\n row -= 1\n col -= 1\n end\n\n until col > 7 || row > 7\n if win_array.length != 4\n if grid[row][col] == player\n win_array.push([row,col])\n else\n win_array = []\n end\n end\n row += 1\n col += 1\n end\n\n if win_array.length == 4\n win = true\n end\n end\n\n # winning four-in-a-row briefly \"flashes\" to show where it is\n if win == true\n flash_count = 0\n while flash_count < 4\n #flashing animation\n win_array.each do | element |\n grid[element[0]][element[1]] = \"@\"\n end\n print_board(grid)\n sleep(0.2)\n win_array.each do | element |\n grid[element[0]][element[1]] = player\n end\n print_board(grid)\n sleep(0.2)\n flash_count += 1\n end\n end\n\n return win\nend",
"def gameover?\n winning_row? || winning_column? || winning_diagonal? || full_board?\n end",
"def check_rows_for_winner\n\n if board[0][0] == board[0][2] and board[0][1] == board[0][2] and not board[0][1] == nil\n @player = board[0][0]\n elsif board[1][0] == board[1][2] and board[1][1] == board[1][2] and not board[1][1] == nil\n @player = board[1][1]\n elsif board[2][0] == board[2][2] and board[2][1] == board[2][2] and not board[2][1] == nil\n @player = board[2][2]\n end\n end",
"def winner_via_diagonal?(player)\n diagonals.any? do |diagonal|\n diagonal.cells.all? {|cell| cell.value == player.marker}\n end\n end",
"def verticalWin? (player)\n (0..6).any? {|c| (0..2).any? {|r| fourFromTowards?(player, r, c, 1, 0)}}\n end",
"def get_winner\n indexes_to_check = (0..@n-3).to_a\n\n # Check horizontal winners\n @board.each_with_index do |_, k|\n indexes_to_check.each do |idx|\n return @board[k][idx] if marked(k, idx) && similar_value([k, idx], [k, idx + 1], [k, idx + 2])\n end\n end\n\n # Check vertical winners\n @n.times do |k|\n indexes_to_check.each do |idx|\n return @board[idx][k] if marked(idx, k) && similar_value([idx, k], [idx + 1, k], [idx + 2, k])\n end\n end\n\n # Check diagonal winners\n indexes_to_check.product(indexes_to_check).each do |idx1, idx2|\n if marked(idx1, idx2) && similar_value([idx1, idx2], [idx1 + 1, idx2 + 1], [idx1 + 2, idx2 + 2])\n return @board[idx1][idx2]\n elsif marked(idx1, idx2 + 2) && similar_value([idx1, idx2 + 2], [idx1 + 1, idx2 + 1], [idx1 + 2, idx2])\n return @board[idx1][idx2+2]\n end\n end\n\n false\n end",
"def winner?\n return true if check_horizontal\n return true if check_vertical\n return true if check_diagonal1\n return true if check_diagonal2\n false\n end",
"def check_wins(column, player)\n\t\t# row checking\n\t\tfor i in 0...@@board.length\n\t\t\trow = @@board[i]\n\t\t\trow_counter = 0\n\t\t\tfor j in 0...row.length\n\t\t\t\tif row[j] === player\n\t\t\t\t\trow_counter += 1\n\t\t\t\t\tif row_counter === 4\n\t\t\t\t\t\treturn true\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\trow_counter = 0\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\t\t# column checking\n\t\tcolumn_counter = 0\n\t\tfor k in 0...@@board.length\n\t\t\tif @@board[k][column] === player\n\t\t\t\tcolumn_counter += 1\n\t\t\t\tif column_counter === 4\n\t\t\t\t\treturn true;\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\t\t# diagonal checking, chose to go to 11 because coordinates [5,6] can be\n\t\t#reached in this loop\n\t\tfor diagonal_sum in 0..11\n\t\t\tdiagonal_counter = 0\n\t\t\tfor x in 0..diagonal_sum\n\t\t\t\ty = diagonal_sum - x\n\t\t\t\tif (defined?(@@board[x][y])).nil?\n\t\t\t\t\t# some of the coordinates being checked are not defined, this is to\n\t\t\t\t\t# keep looping through the board to check values on the board\n\t\t\t\t\tnext\n\t\t\t\tend\n\t\t\t\tif @@board[x][y] === player\n\t\t\t\t\tdiagonal_counter += 1\n\t\t\t\t\tif diagonal_counter === 4\n\t\t\t\t\t\treturn true\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\tdiagonal_counter = 0\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\t\t# other diagonal checking\n\t\tfor diagonal_diff in (6).downto(-5)\n\t\t\ty = 0\n\t\t\tother_diagonal_counter = 0\n\t\t\tfor x in 0...7\n\t\t\t\ty = diagonal_diff + x\n\t\t\t\tif (defined?(@@board[x][y])).nil? #if a space is undefined, just keep checking\n\t\t\t\t\tnext\n\t\t\t\tend\n\t\t\t\tif y < 7\n\t\t\t\t\tif @@board[x][y] === player\n\t\t\t\t\t\tother_diagonal_counter += 1\n\t\t\t\t\t\tif other_diagonal_counter === 4\n\t\t\t\t\t\t\treturn true\n\t\t\t\t\t\tend\n\t\t\t\t\telse\n\t\t\t\t\t\tother_diagonal_counter = 0\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\tbreak;\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t# the check_wins method has many nested for loops, which is a\n\t\t# runtime complexity of O(n^2)\n\t\treturn false\n\tend",
"def player_won?(player)\n diagonals = []\n diagonals << (0..2).map { |i| @board[i][i] }\n diagonals << (0..2).map { |i| @board[i][-i - 1] }\n if @board.any? { |row| row.all? { |value| value == player.MARK } }\n return true\n elsif @board.transpose.any? { |row| row.all? { |value| value == player.MARK } }\n return true\n elsif diagonals.any? { |row| row.all? { |value| value == player.MARK } }\n return true\n end\n\n false\n end",
"def winner\n [\n [[0,0],[0,1],[0,2]], # column 0\n [[1,0],[1,1],[1,2]], # column 1\n [[2,0],[2,1],[2,2]], # column 2\n [[0,0],[1,0],[2,0]], # row 0\n [[0,1],[1,1],[2,1]], # row 1\n [[0,2],[1,2],[2,2]], # row 2\n [[0,0],[1,1],[2,2]], # descending diagonal\n [[0,2],[1,1],[2,0]], # ascending diagonal\n ].each do |cells|\n vals = cells.map {|x, y| board[y][x] }\n return :x if vals == %w( X X X )\n return :o if vals == %w( O O O )\n end \n return nil\n end",
"def winner\n #see if there are four in a row\n @columns.times do |c|\n @rows.times do |r|\n check = @slots[c][r]\n if check != nil\n if (r <= @rows - 4) && [check, @slots[c][r+1], @slots [c][r+2], @slots[c][r+3]].uniq.length == 1\n return check\n elsif (c <= (@columns - 4)) && [check, @slots[c+1][r], @slots[c+2][r], @slots[c+3][r]].uniq.length == 1\n return check\n elsif (r >= 3) && (c <= (@columns - 4)) && [check, @slots[c+1][r-1], @slots[c+2][r-2], @slots[c+3][r-3]].uniq.length ==1\n return check\n elsif (r >= 3) && (c >= (@columns - 4)) && [check, @slots[c-1][r-1], @slots[c-2][r-2], @slots[c-3][r-3]].uniq.length ==1\n return check\n end\n end\n end\n end\n return false\n end",
"def winner\n (@rows + cols + diagonals).each do |row|\n return :x if row.all? { |mark| mark == :x }\n return :o if row.all? { |mark| mark == :o }\n end\n \n nil\n end",
"def checkwinner\r\n\t\t\t\r\n\t\t\t@matrix.each do |row|\r\n\t\t\t\trow.join.gsub(\"|\",\"\")\r\n\t\t\tend\r\n\t\t\t\r\n\t\t\t#check horizontal winners\r\n\t\t\t@matrix.each do |row|\r\n\t\t\t if row.join.include? \"XXXX\"\r\n\t\t\t\t@winner = 2\t\r\n\t\t\t elsif row.join.include? \"OOOO\"\r\n\t\t\t\t@winner = 1\r\n\t\t\t end\r\n\t\t\tend\r\n\r\n\t\t\t#check vertical winners\r\n\t\t\t@matrix.transpose.each do |row|\r\n\t\t\t if row.join.include? \"XXXX\"\r\n\t\t\t\t@winner = 2\t\r\n\t\t\t elsif row.join.include? \"OOOO\"\r\n\t\t\t\t@winner = 1\r\n\t\t\t end\r\n\t\t\tend\r\n\t\t\t\r\n\t\t\tfor row_nr in 0..@matrix.count-4\r\n\t\t\t for col_nr in 0..@matrix[0].count-4\r\n\t\t\t\tel_1 = @matrix[row_nr] [col_nr]\r\n\t\t\t\tel_2 = @matrix[row_nr+1][col_nr+1]\r\n\t\t\t\tel_3 = @matrix[row_nr+2][col_nr+2]\r\n\t\t\t\tel_4 = @matrix[row_nr+3][col_nr+3]\r\n\r\n\t\t\t\tif el_1 + el_2 + el_3 + el_4 == 'XXXX'\r\n\t\t\t\t @winner = 2\t\r\n\t\t\t\telsif el_1 + el_2 + el_3 + el_4 == 'OOOO'\r\n\t\t\t\t @winner = 1\r\n\t\t\t\tend\r\n\t\t\t end\r\n\t\t\tend\r\n\t\t\t#right to left\r\n\t\t\tfor row_nr in 0..@matrix.count-4\r\n\t\t\t for col_nr in 0..@matrix[0].count-4\r\n\t\t\t\tel_1 = @matrix.reverse[row_nr] [col_nr]\r\n\t\t\t\tel_2 = @matrix.reverse[row_nr+1][col_nr+1]\r\n\t\t\t\tel_3 = @matrix.reverse[row_nr+2][col_nr+2]\r\n\t\t\t\tel_4 = @matrix.reverse[row_nr+3][col_nr+3]\r\n\r\n\t\t\t\tif el_1 + el_2 + el_3 + el_4 == 'XXXX'\r\n\t\t\t\t @winner = 2 \r\n\t\t\t\telsif el_1 + el_2 + el_3 + el_4 == 'OOOO'\r\n\t\t\t\t @winner = 1\r\n\t\t\t\tend\r\n\t\t\t end\r\n\t\t\tend\r\n\t\r\n\t\t\treturn @winner\r\n\t\tend",
"def winner\n # shortcut for less typing\n b = @board\n\n # rows\n return b[0] if b[0] == b[1] && b[1] == b[2]\n return b[3] if b[3] == b[4] && b[4] == b[5]\n return b[6] if b[6] == b[7] && b[7] == b[8]\n\n # cols\n return b[0] if b[0] == b[3] && b[3] == b[6]\n return b[1] if b[1] == b[4] && b[4] == b[7]\n return b[2] if b[2] == b[5] && b[5] == b[8]\n\n # diagonals\n return b[4] if b[0] == b[4] && b[4] == b[8]\n return b[4] if b[2] == b[4] && b[4] == b[6]\n\n end",
"def win_condition_met?(player)\n # Horizontal\n for row in (0..5) do\n counter = 0\n \n @board[row].each do |disc|\n if(disc == player)\n counter += 1\n return true if(counter >= 4)\n else\n counter = 0\n end\n end\n end\n \n # Vertical\n for col in (0..6) do\n counter = 0\n \n for row in (0..5) do\n if(@board[row][col] == player)\n counter += 1\n return true if(counter >= 4)\n else\n counter = 0\n end\n end\n end\n \n # Right diagonal\n starting_points = [[0, 0], [1, 0], [2, 0], [0, 1], [0, 2], [0, 3]]\n starting_points.each do |start|\n counter = 0\n \n row = start[0]\n col = start[1]\n \n while(row < 6 && col < 7)\n if(@board[row][col] == player)\n counter += 1\n return true if(counter >= 4)\n else\n counter = 0\n end\n \n row += 1\n col += 1\n end\n end\n \n # Left diagonal\n starting_points = [[0, 6], [1, 6], [2, 6], [0, 5], [0, 4], [0, 3]]\n starting_points.each do |start|\n counter = 0\n \n row = start[0]\n col = start[1]\n \n while(row < 6 && col >= 0)\n if(@board[row][col] == player)\n counter += 1\n return true if(counter >= 4)\n else\n counter = 0\n end\n \n row += 1\n col -= 1\n end\n end\n \n return false\n end",
"def winner\n (rows + cols + diagonals).each do |triple|\n return :x if triple == [:x, :x, :x]\n return :o if triple == [:o, :o, :o]\n end\n \n nil\n end",
"def check_winner\n row_filled_with_same_element = ->(row) { row.reduce(row[0]) { |acc, elem| acc if elem == acc } }\n winners = [board, board.transpose, diagonals].map do |board_version|\n board_version.map(&row_filled_with_same_element).find { |row| row && row != 0 }\n end\n winners.find { |row| row }\n end",
"def winner\n match = horizontal_match || vertical_match || diagonal_match\n match ? @last_drop[:piece] : nil\n end",
"def winner?(board)\n #vertical and horizonal equality checks\n j = 0\n for i in 0...3\n return true if (board[j]==board[j+1])&&(board[j+1]==board[j+2])\n\n j += 3\n end\n #verticals equality test\n j = 0\n for i in 0...3\n\n return true if (board[j]==board[j+3])&&(board[j+3]==board[j+6])\n j += 1\n end\n\n #diagonals equality test\n \n return true if (board[0]==board[4])&&(board[4]==board[8])\n return true if (board[2]==board[4])&&(board[4]==board[6])\n \n\n false\n end",
"def check_winner(col,row)\n return true if win?\n ranges = get_ranges_for(col, row)\n return true if ranges.any?{|range| is_winner_on_range?(range) }\n return false\n end",
"def winner\n\n # Check every row\n winner = winner_rows()\n\n # Winner?\n if winner\n\n # Yes, the game is over\n return winner\n\n end\n\n # No row winner, so check every column\n winner = winner_columns()\n\n # Winner?\n if winner\n\n # Yes, the game is over\n return winner\n\n end\n\n # No row or column winner, so check every diagonal\n winner = winner_diagonals()\n\n # Winner?\n if winner\n\n # Yes, the game is over\n return winner\n\n end\n\n # Otherwise, no winner\n return\n\n end",
"def win?\n horizontal || vertical || diagonal_left || diagonal_right\n end",
"def check_diagonals\n diagonal_winner = nil\n # stores the markers\n backward_diagonal = ''\n forward_diagonal = ''\n\n # for a diagonal to be a winner it takes the row[n], row[n+1], row[n+2] and so on..\n @board.each_with_index do |row,index|\n\n # check if left to right diagonal is a winner\n row.each_with_index do |marker, position|\n if position == index\n backward_diagonal += marker\n end\n end\n\n # check if right to left diagonal is a winner\n reversed_row = row.reverse\n reversed_row.each_with_index do |marker, position|\n if position == index\n forward_diagonal += marker\n end\n end\n end\n\n # checks iteration count of x or o in strings to find winner\n if backward_diagonal.count('x') == @board.size || forward_diagonal.count('x') == @board.size\n diagonal_winner = 'x'\n elsif backward_diagonal.count('o') == @board.size || forward_diagonal.count('o') == @board.size\n diagonal_winner = 'o'\n end\n\n diagonal_winner\n end",
"def winner\n [rows, columns, diagonals].each do |groups|\n win_groups = groups.select { |g| g.all? && g.uniq.size == 1 }\n return [@human_player, @computer_player].find { |p| p.to_s == win_groups[0][0] } if !win_groups.empty?\n end\n nil\n end",
"def check_for_winner\n winner = false\n until winner\n WINNING_CELLS.each do |combo|\n if board[combo[1] - 1] == board[combo[0] - 1] && board[combo[2] - 1] == board[combo[0] - 1]\n winner = true\n break\n else\n winner = false\n end\n end\n end\n winner\n end",
"def winning_condition?\n grid[0] == grid[1] && grid[1] == grid[2] ||\n grid[3] == grid[4] && grid[4] == grid[5] ||\n grid[6] == grid[7] && grid[7] == grid[8] ||\n grid[0] == grid[3] && grid[3] == grid[6] ||\n grid[1] == grid[4] && grid[4] == grid[7] ||\n grid[2] == grid[5] && grid[5] == grid[8] ||\n grid[0] == grid[4] && grid[4] == grid[8] ||\n grid[2] == grid[4] && grid[4] == grid[6]\n end",
"def winner\n result = nil\n @field.each do | row | result ||= winner_test(row) end # Horizontal\n @field.transpose.each do | row | result ||= winner_test(row) end # Vertical\n result || winner_test((0..2).map{|i| @field[i][i]}) || winner_test((0..2).map{|i| @field[2-i][i]}) # Diagonal\n end",
"def winCondition(player)\n #Loops through rows, then loops through columns.\n\tfor i in 0..2\n\t\tcheck = i*3\n\t\tif(@bo[check] == player && @bo[check+1] == player && @bo[check+2] == player) then\n\t\t\treturn player\n\t\tend\n\t\tif(@bo[i] == player && @bo[i+3] == player && @bo[i+6] == player) then\n\t\t\treturn player\n\t\tend\n\tend\n #Loops through diagonals\n\tif(@bo[0] == player && @bo[4] == player && @bo[8] == player) then\n\t\treturn player\n\tend\n\tif(@bo[2] == player && @bo[4] == player && @bo[6] == player) then\n\t\treturn player\n\tend\n\treturn nil\n end",
"def winner_columns\n\n # Outer loop to look for a winner down the column\n for column in 0..BOARD_MAXIMUM_INDEX\n\n # Get the player symbol (X or O) that must match\n first_symbol = @board[0][column]\n\n # Inner loop to look at all elements in this column's rows\n for row in 1..BOARD_MAXIMUM_INDEX\n\n # Does this cell match the first symbol?\n if first_symbol != @board[row][column]\n\n # No, this column IS NOT a winning combination\n break\n\n # At the end of this column and not all empty?\n elsif row == BOARD_MAXIMUM_INDEX and first_symbol != EMPTY_POSITION\n\n # Yes, this column IS a winning combination\n return first_symbol\n\n end\n\n end\n\n end\n\n # Nope, no winner in any columns\n return\n\n end",
"def win?(piece)\n check_rows(piece, grid) || check_rows(piece, grid.transpose) || check_diagonals(piece)\n end",
"def winning_move?\n winning_moves = [[1,2,3], [4,5,6], [7,8,9], [1,4,7], [2,5,8], [3,6,9], [1,5,9], [3,5,7]]\n winning_moves.each do |set|\n #check game board to see if XXX or OOO combination exists\n if (@board[set[0]] == \"X\") && (@board[set[1]] == \"X\") && (@board[set[2]] == \"X\")\n @winner = \"X\"\n return true\n elsif (@board[set[0]] == \"O\") && (@board[set[1]] == \"O\") && (@board[set[2]] == \"O\")\n @winner = \"O\"\n return true\n end\n end\n return false\n end",
"def winning_vertical?(piece)\n verticals.any? do |vert|\n vert.all?{|cell| prev = cell == piece }\n end\n end",
"def won?\n if (diagonal_match || across_match || down_match)\n return true\n end\n return false\n end",
"def check_board\t\n # Winner checker\n @winner = false\n \n # Board's status\n @empty_board = false\n\n # Checking the rows\n 3.times do |x|\n if !@winner\n if vector_value(x,0) == vector_value(x,1) and vector_value(x,1) == vector_value(x,2) and vector_value(x,2) != C_V\n if vector_value(x,2) == C_X\n JOptionPane.showMessageDialog nil,\"Player X is the winner!\"\n @points_player1 += 1\n elsif vector_value(x,2) == C_O\n JOptionPane.showMessageDialog nil,\"Player O is the winner!\"\n @points_player2 += 1\n end\n reset_board\n @moves = 0\n @winner = true\n end\n end\n end\n\n #Checking the columns\n if !@winner\n 3.times do |y|\n if !@winner\n if vector_value(0,y) == vector_value(1,y) and vector_value(1,y) == vector_value(2,y) and vector_value(2,y) != C_V \n if vector_value(2,y) == C_X\n JOptionPane.showMessageDialog nil,\"Player X is the winner!\"\n @points_player1 += 1\n elsif vector_value(2,y) == C_O\n JOptionPane.showMessageDialog nil,\"Player O is the winner!\"\n @points_player2 += 1\n end \n reset_board\n @moves = 0\n @winner = true\n end\n end\n end\n end\n\n #Checking the diagonals\n if !@winner\n if vector_value(0,0) == vector_value(1,1) and vector_value(1,1) == vector_value(2,2) and vector_value(2,2) != C_V\n if vector_value(2,2) == C_X\n JOptionPane.showMessageDialog nil,\"Player X is the winner!\"\n @points_player1 += 1\n elsif vector_value(2,2) == C_O\n JOptionPane.showMessageDialog nil,\"Player O is the winner!\"\n @points_player2 += 1\n end\n reset_board\n @moves = 0\n @winner = true\n elsif vector_value(0,2) == vector_value(1,1) and vector_value(1,1) == vector_value(2,0) and vector_value(2,0) != C_V\n if vector_value(2,0) == C_X\n JOptionPane.showMessageDialog nil,\"Player X is the winner!\"\n @points_player1 += 1\n elsif vector_value(2,0) == C_O\n JOptionPane.showMessageDialog nil,\"Player O is the winner!\"\n @points_player2 += 1\n end\n reset_board\n @moves = 0\n @winner = true\n else #Checking no winner\n @board.each do |i|\n if i == C_V\n @empty_board = true\n break\n end\n end\n if !@empty_board\n JOptionPane.showMessageDialog nil, \"No winner, the game will restart\"\n reset_board\n @moves = 0\n end\n end\n end\n end",
"def has_won(new_board)\n #check rows\n new_board.each_with_index do |row, i|\n if new_board[i][0] == new_board[i][1] && new_board[i][1] == new_board[i][2] && new_board[i][2] != '-'\n return new_board[i][0]\n end\n end\n\n #check columns\n new_board.each_with_index do |col, j|\n if new_board[0][j] == new_board[1][j] && new_board[1][j] == new_board[2][j] && new_board[2][j] != '-'\n return new_board[0][j] \n end\n end\n\n #Check Diagonals\n if new_board[0][0] == new_board[1][1] && new_board[1][1] == new_board[2][2] && new_board[2][2] != '-'\n return new_board[0][0]\n end\n\n if new_board[2][0] == new_board[1][1] && new_board[1][1] == new_board[0][2] && new_board[0][2] != '-'\n return new_board[0][0]\n end\n\n #No one has won\n return '-'\nend",
"def is_winner(b,l) \n return ((b[7] == l and b[8] == l and b[9] == l) or # across the top\n (b[4] == l and b[5] == l and b[6] == l) or # across the middle\n (b[1] == l and b[2] == l and b[3] == l) or # across the bttom\n (b[7] == l and b[4] == l and b[1] == l) or # down the left side\n (b[8] == l and b[5] == l and b[2] == l) or # down the middle\n (b[9] == l and b[6] == l and b[3] == l) or # down the right side\n (b[7] == l and b[5] == l and b[3] == l) or # diagonal\n (b[9] == l and b[5] == l and b[1] == l)) # diagonal\nend",
"def win?\n win=[false,false] #[player1,player2]\n @y.times do |y|\n \t#Winning Conditions\n if @board[y][0...@x].all? {|x| x==\"X\"} # Rows\n \t win=[true,false]\n \telsif @board[y][0...@x].all? {|x| x==\"O\"}\n \t win=[false,true]\n \telsif #Diagonals (Currently limited to 3x3)\n \t if @board[0][0] == \"X\" && @board[1][1] == \"X\" && @board[2][2] == \"X\" \n \t win=[true,false]\n \t elsif @board[0][2] == \"X\" && @board[1][1] == \"X\" && @board[2][0] == \"X\"\n \t win=[true,false]\n \t elsif @board[0][0] == \"O\" && @board[1][1] == \"O\" && @board[2][2] == \"O\"\n \t win=[false,true]\n \t elsif @board[0][2] == \"O\" && @board[1][1] == \"O\" && @board[2][0] == \"O\"\n \t win=[false,true]\n \t end\n \tend\n end\n \t\n\n @x.times do |x|\n if @board[0][x] == \"X\" && @board[1][x] == \"X\" && @board[2][x] == \"X\" #Columns\n \t win=[true,false]\n \telsif @board[0][x] == \"O\" && @board[1][x] == \"O\" && @board[2][x] == \"O\" \n \t win=[false,true]\n \tend\n end\n \t \t\n \n \n return win\n end",
"def check_columns\n column_winner = nil\n\n # index in arrays will be representations of board column\n x_arr =[]\n o_arr =[]\n # arrays will be the size of the board default value for each column will be 0\n @board.size.times do\n x_arr << 0\n o_arr << 0\n end\n\n # updates amount in x or o array as a column based on marker = x or o\n @board.each do |row|\n row.each_with_index do |marker, index|\n if marker == 'x'\n x_arr[index] += 1\n # checks if winner to break out of loop\n if x_arr[index] == @board.size\n column_winner = 'x'\n break\n end\n elsif marker == 'o'\n o_arr[index] += 1\n # checks if winner to break out of loop\n if o_arr[index] == @board.size\n column_winner = 'o'\n break\n end\n end\n\n end\n end\n\n column_winner\n end",
"def game_won?\n if diagonal_win?\n true\n elsif horizontal_win?\n true\n elsif vertical_win?\n true\n else\n false\n end\n end",
"def winner?\n (board[:a] == board[:b] && board[:b] == board[:c]) ||\n (board[:d] == board[:e] && board[:e] == board[:f]) ||\n (board[:g] == board[:h] && board[:h] == board[:i]) ||\n (board[:a] == board[:d] && board[:d] == board[:g]) ||\n (board[:b] == board[:e] && board[:e] == board[:h]) ||\n (board[:c] == board[:f] && board[:f] == board[:i]) ||\n (board[:a] == board[:e] && board[:e] == board[:i]) ||\n (board[:c] == board[:e] && board[:e] == board[:g])\n end",
"def winning_vertical?(piece)\n verticals.any? do |vert|\n vert.all?{|cell| cell == piece }\n end\n end",
"def winner?(letter=:X)\n win_arr = [letter, letter, letter]\n\n # check rows\n return true unless @squares.index(win_arr).nil?\n\n # check columns\n return true unless @squares.index(win_arr).nil?\n end",
"def diagonal_win?\n (0..3).each do |column|\n (0..2).each do |row|\n return true if down_right_win?(row, column)\n end\n end\n (3..6).each do |column|\n (0..2).each do |row|\n return true if down_left_win?(row, column)\n end\n end\n false\n end",
"def checkWinner(state, player1, player2)\n\n for i in 0..2\n\n row_candidate = true\n column_candidate = true\n\n for j in 1..2\n\n # check rows\n if state[i * 3 + j] == '0' || state[i * 3 + j] != state[i * 3 + j - 1] then\n row_candidate = false\n elsif row_candidate && state[i * 3 + j] == state[i * 3 + j - 1] then\n if j == 2 then\n winner = if state[i * 3 + j] == '1' then player1 else player2 end\n return winner\n end\n end\n\n # check columns\n if state[j * 3 + i] == '0' || state[j * 3 + i] != state[(j - 1) * 3 + i] then\n column_candidate = false\n elsif column_candidate && state[j * 3 + i] == state[(j - 1) * 3 + i] then\n if j == 2 then\n winner = if state[j * 3 + i] == '1' then player1 else player2 end\n return winner\n end\n end\n end\n end\n\n # check diagonals\n if state[0] == state[4] && state[4] == state[8] && state[0] != '0' then\n winner = if state[0] == '1' then player1 else player2 end\n return winner\n end\n\n if state[2] == state[4] && state[4] == state[6] && state[2] != '0' then\n winner = if state[2] == '1' then player1 else player2 end\n return winner\n end\n\n return nil\n end",
"def winner?\n\t\t if( \n\t\t\t\t([@grid[0], @grid[1], @grid[2]].uniq.length == 1 && @grid[0] != \" \") ||\n\t\t\t\t([@grid[0], @grid[3], @grid[6]].uniq.length == 1 && @grid[0] != \" \") ||\n\t\t\t\t([@grid[0], @grid[4], @grid[8]].uniq.length == 1 && @grid[0] != \" \") ||\n\t\t\t\t([@grid[6], @grid[7], @grid[8]].uniq.length == 1 && @grid[6] != \" \") ||\n\t\t\t\t([@grid[2], @grid[5], @grid[8]].uniq.length == 1 && @grid[2] != \" \") ||\n\t\t\t\t([@grid[2], @grid[4], @grid[6]].uniq.length == 1 && @grid[2] != \" \") ||\n\t\t\t\t([@grid[1], @grid[4], @grid[7]].uniq.length == 1 && @grid[1] != \" \") ||\n\t\t\t\t([@grid[3], @grid[4], @grid[5]].uniq.length == 1 && @grid[3] != \" \")\n\t\t\t\t)\n\t\t\t\ttrue\n\t\t else\n\t\t\t\tfalse\n\t\t end\n\t\tend",
"def check_diagonal\n RulesContracts.classic_model(@game_state_model)\n # testing for bitboard errors\n # (0..7).each { |y|\n # (0..7).each { |x|\n # if @grid[y][x] == 1 and y <= 4 and x >= 3\n # puts \" #{x}/#{y} #{@grid[y][x]} || #{x-1}/#{y+1} #{@grid[y + 1][x - 1]} || #{x-2}/#{y+2} #{@grid[y + 2][x - 2]} || #{x-3}/#{y+3} #{@grid[y + 3][x - 3]}\"\n # puts \"#{@grid[y][x] == 1 and @grid[y + 1][x - 1] == 1 and @grid[y + 2][x - 2] == 1 and @grid[y + 3][x - 3] == 1}\"\n # end\n # }\n # }\n \n (0..7).each { |y|\n (0..7).each { |x|\n if y <= 4 and x <= 4\n if @grid[y][x] == 2 and @grid[y + 1][x + 1] == 2 and @grid[y + 2][x + 2] == 2 and @grid[y + 3][x + 3] == 2\n @winner = 1\n return true\n elsif @grid[y][x] == 1 and @grid[y + 1][x + 1] == 1 and @grid[y + 2][x + 2] == 1 and @grid[y + 3][x + 3] == 1\n @winner = 0\n return true\n end \n end\n if y <= 4 and x >= 3\n if @grid[y][x] == 2 and @grid[y + 1][x - 1] == 2 and @grid[y + 2][x - 2] == 2 and @grid[y + 3][x - 3] == 2\n @winner = 1\n return true\n elsif @grid[y][x] == 1 and @grid[y + 1][x - 1] == 1 and @grid[y + 2][x - 2] == 1 and @grid[y + 3][x - 3] == 1\n @winner = 0\n return true\n end\n end\n if y >= 3 and x <= 4\n if @grid[y][x] == 2 and @grid[y - 1][x + 1] == 2 and @grid[y - 2][x + 2] == 2 and @grid[y - 3][x + 3] == 2\n @winner = 1\n return true\n elsif @grid[y][x] == 1 and @grid[y - 1][x + 1] == 1 and @grid[y - 2][x + 2] == 1 and @grid[y - 3][x + 3] == 1\n @winner = 0\n return true\n end \n end\n if y >= 3 and x >= 3\n \n if @grid[y][x] == 2 and @grid[y - 1][x - 1] == 2 and @grid[y - 2][x - 2] == 2 and @grid[y - 3][x - 3] == 2\n @winner = 1\n return true\n elsif @grid[y][x] == 1 and @grid[y - 1][x - 1] == 1 and @grid[y - 2][x - 2] == 1 and @grid[y - 3][x - 3] == 1\n @winner = 0\n return true\n end \n \n end \n }\n }\n return false\n end",
"def board_win?(board)\n first_row_win?(board) ||\n second_row_win?(board) ||\n third_row_win?(board) ||\n first_column_win?(board) ||\n second_column_win?(board) ||\n third_column_win?(board) ||\n diag_right_win?(board) ||\n diag_left_win?(board) \nend",
"def is_win?\n cell[0] == cell[1] && cell[1] == cell[2] ||\n cell[3] == cell[4] && cell[4] == cell[5] ||\n cell[6] == cell[7] && cell[7] == cell[8] ||\n cell[0] == cell[3] && cell[3] == cell[6] ||\n cell[1] == cell[4] && cell[4] == cell[7] ||\n cell[2] == cell[5] && cell[5] == cell[8] ||\n cell[0] == cell[4] && cell[4] == cell[8] ||\n cell[2] == cell[4] && cell[4] == cell[6]\n end",
"def check_vertical_win? \n \t\t(0...@board.length).each do |i| #assigns the count of rows in the array, board, to the variable i\n \t\t\tif(@board[0][i]!=0&&(@board[0][i])==@board[1][i]&&@board[1][i]==@board[2][i]&&@board[2][i]==@board[3][i]) \n \t\t\t#if the first element of column i is not equal to 0 and \n \t\t\t#the first element of column i is equal to the second element of column i and \n \t\t\t#the second element of column i is equal to third element of column i and \n \t\t\t#the third element of column i is equal to the fourth element, \n \t\t\t#then by the transitive property the statement is true\n \t\t\t\treturn true\n \t\t\tend\n \t\tend\n \t\treturn false\n \tend",
"def board_has_win?(positions)\n # x's\n if## Check for win ################################################\n # Check for horizontal wins\n (positions[:a] == positions[:b] and positions[:b] == positions[:c] and positions[:a] != \" \") or\n (positions[:d] == positions[:e] and positions[:e] == positions[:f] and positions[:d] != \" \") or\n (positions[:g] == positions[:h] and positions[:h] == positions[:i] and positions[:g] != \" \") or\n\n # Check for vertical wins\n (positions[:a] == positions[:d] and positions[:d] == positions[:g] and positions[:a] != \" \") or\n (positions[:b] == positions[:e] and positions[:e] == positions[:h] and positions[:b] != \" \") or\n (positions[:c] == positions[:f] and positions[:f] == positions[:i] and positions[:c] != \" \") or\n\n # Check for diagonal wins\n (positions[:a] == positions[:e] and positions[:e] == positions[:i] and positions[:a] != \" \") or\n (positions[:g] == positions[:e] and positions[:e] == positions[:c] and positions[:g] != \" \")\n # End conditional ########################################################\n\n # Determine who won -- if x won, he will have one more move than o. If o won, he will have the same amount of moves as x.\n num_of_x = 0\n num_of_o = 0\n\n positions.each do |k,v|\n if v == \"x\"\n num_of_x += 1\n elsif v == \"o\"\n num_of_o += 1\n end\n end\n\n if num_of_x > num_of_o\n # x won\n return true, :x\n else\n # o won\n return true, :o\n end\n else\n # No winner yet\n false\n end\nend",
"def winner\n WIN_COMBINATIONS.each do |win_combination|\n #puts win_combination.inspect\n win_index_1 = win_combination[0]\n win_index_2 = win_combination[1]\n win_index_3 = win_combination[2]\n \n position_1 = @board[win_index_1] \n position_2 = @board[win_index_2] \n position_3 = @board[win_index_3] \n \n if position_1 == position_2 && position_2 == position_3 && position_taken?(win_index_1)\n return position_1\n end\n end\n nil\n end",
"def check_vertical b, play\n y = 0\n while y < 7\n x = 0\n while x < 4\n if b[x][y] == play\n if b[x+1][y] == play\n if b[x+2][y] == play\n if b[x+3][y] == play\n win = true\n end\n end\n end\n end\n x = x + 1\n end\n y = y + 1\n end\n return win\nend",
"def block_diagonal_win?\n \tblank_x = -1\n \tx_row_total = 0\n \t\n \t3.times do |i|\t\n\t\t\tif @game_board[i][i] == \"X\"\n\t\t\t\tx_row_total += 1\n\t\t\telse \n\t\t\t\tblank_x = i\n\t\t\tend\n\n\t\t\tif x_row_total == 2 && blank_x > -1\n\t\t\t\t@game_board[blank_x][blank_x] = \"O\"\n\t\t\t\ttrue\n\t\t\tend\n \tend\n \tfalse\n end",
"def winner\n if check_rows_for_winner || check_columns_for_winner || check_diagonals_for_winner\n return @player\n else\n return nil\n end\n end",
"def winner\n horizontal_winner || vertical_winner || diagonal_winner\n end",
"def evaluate_game(game_board)\n game_finished = false\n for i in 0..5\n \n if game_finished == true\n break\n end\n \n #Vertical and Horizontal evaluation to see if 4 are connected\n for j in 0..3\n if (game_board[i+1][j] == game_board[i+1][j+1]) && (game_board[i+1][j]==game_board[i+1][j+2]) && (game_board[i+1][j]==game_board[i+1][j+3])&&(game_board[i+1][j]==\"X\"||game_board[i+1][j]==\"O\") #rows\n puts \"User \" + game_board[i+1][j].to_s + \" wins\"\n game_finished = true\n break\n end\n end\n \n end\n \n for i in 0..6\n for j in 0..2 #columns\n if (game_board[j+1][i] == game_board[j+2][i]) && (game_board[j+1][i] == game_board[j+3][i])&&(game_board[j+1][i] == game_board[j+4][i])&&((game_board[j+1][i] == \"X\")||(game_board[j+1][i] == \"O\")) #columns\n puts \"User \" + game_board[j+1][i].to_s + \" wins\"\n game_finished = true\n break\n end\n end\n end\n \n #Evaluate if Diagonals have 4 connected\n for i in 1..6 #rows\n \n if game_finished == true\n break\n end\n \n for j in 0..6 #columns\n \n \n if (j<=3) #if it has 4 spaces to the right\n if (i>=4)#if it has 4 spaces up\n if(game_board[i][j]==game_board[i-1][j+1])&&(game_board[i][j]==game_board[i-2][j+2])&&(game_board[i][j]==game_board[i-3][j+3])&&((game_board[i][j] == \"X\")||(game_board[i][j] == \"O\"))\n puts \"User \" + game_board[i][j].to_s + \" wins\"\n game_finished = true\n break\n end\n end\n if (i<=3)#if it has 4 spaces down\n #Evalaution\n if(game_board[i][j]==game_board[i+1][j+1])&&(game_board[i][j]==game_board[i+2][j+2])&&(game_board[i][j]==game_board[i+3][j+3])&&((game_board[i][j] == \"X\")||(game_board[i][j] == \"O\"))\n puts \"User \" + game_board[i][j].to_s + \" wins\"\n game_finished = true\n break\n end\n end\n \n end\n \n \n if (j>3) #if it has 4 spaces to the left\n if (i>=4)#if it has 4 spaces up\n if(game_board[i][j]==game_board[i-1][j-1])&&(game_board[i][j]==game_board[i-2][j-2])&&(game_board[i][j]==game_board[i-3][j-3])&&((game_board[i][j] == \"X\")||(game_board[i][j] == \"O\"))\n puts \"User \" + game_board[i][j].to_s + \" wins\"\n game_finished = true\n break\n end\n end\n \n if (i<4) #if it has 4 spaces down\n #puts(\"Llega a segundo if<4\")\n if(game_board[i][j]==game_board[i+1][j-1])&&(game_board[i][j]==game_board[i+2][j-2])&&(game_board[i][j]==game_board[i+3][j-3])&&((game_board[i][j] == \"X\")||(game_board[i][j] == \"O\"))\n puts \"User \" + game_board[i][j].to_s + \" wins\"\n game_finished = true\n break\n end\n end\n \n end\n \n end\n end\n \n return game_finished\n \nend",
"def is_winner?(disk)\n\t (0...@rows).each do |row|\n\t (0...@cols).each do |col|\n\t\t result = \n\t\t WIN_CONFIGS_OFFSETS.any? do |offset|\n\t\t positions = offset.map { |pos| [row + pos[0], col + pos[1]] }\n\t\t colors = positions.collect { |pos| ((0...@rows).include?(pos[0]) && (0...@cols).include?(pos[1])) ? @grid[pos[1]][pos[0]] : nil }\n\t\t colors.count(disk) == 4\n\t\t end\n\t\t return true if result\n\t\tend\n\t end\n\t false\n\tend",
"def check_win\n\tp = tokenize($current_player)\n\tvert1 = $row1[0] + $row2[0] + $row3[0]\n\tvert2 = $row1[2] + $row2[2] + $row3[2]\n\tvert3 = $row1[4] + $row2[4] + $row3[4]\n\n\thorz1 = vert1[0] + vert2[0] + vert3[0]\n\thorz2 = vert1[1] + vert2[1] + vert3[1]\n\thorz3 = vert1[2] + vert2[2] + vert3[2]\n\n\tdiag1 = $row1[0] + $row2[2] + $row3[4]\n\tdiag2 = $row3[0] + $row2[2] + $row1[4]\n\n\twinning_options = [vert1, vert2, vert3, horz1, horz2, horz3, diag1, diag2]\n\tif winning_options.any? {|x| (x.count p) >= 3}\n\t\treturn true\n\tend \nend",
"def winning_location board \n\tif board[0][0] == 1 && board[0][1] ==1 && board[0][2] == 1\n\t\tputs \"X Wins\"\n\t\t@gameon = false\n\tend\n\n\tif board[0][0] == 2 && board[0][1] ==2 && board[0][2] == 2\n\t\tputs \"O Wins\"\n\t\t@gameon = false\n\tend\n\n\n\tif board[1][0] == 1 && board[1][1] ==1 && board[1][2] == 1\n\t\tputs \"X Wins\"\n\t\t@gameon = false\n\tend\n\n\tif board[1][0] == 2 && board[1][1] ==2 && board[1][2] == 2\n\t\tputs \"O Wins\"\n\t\t@gameon = false\n\tend\n\n\n\tif board[2][0] == 1 && board[2][1] ==1 && board[2][2] == 1\n\t\tputs \"X Wins\"\n\t\t@gameon = false\n\tend\n\n\tif board[2][0] == 2 && board[2][1] ==2 && board[2][2] == 2\n\t\tputs \"O Wins\"\n\t\t@gameon = false\n\tend\n\n\n\tif board[0][0] == 1 && board[1][0] ==1 && board[2][0] == 1\n\t\tputs \"X Wins\"\n\t\t@gameon = false\n\tend\n\n\tif board[0][0] == 2 && board[1][0] ==2 && board[2][0] == 2\n\t\tputs \"O Wins\"\n\t\t@gameon = false\n\tend\n\n\n\tif board[0][1] == 1 && board[1][1] ==1 && board[2][1] == 1\n\t\tputs \"X Wins\"\n\t\t@gameon = false\n\tend\n\n\tif board[0][1] == 2 && board[1][1] ==2 && board[2][1] == 2\n\t\tputs \"O Wins\"\n\t\t@gameon = false\n\tend\n\n\n\tif board[0][2] == 1 && board[1][2] ==1 && board[2][2] == 1\n\t\tputs \"X Wins\"\n\t\t@gameon = false\n\tend\n\n\tif board[0][2] == 2 && board[1][2] ==2 && board[2][2] == 2\n\t\tputs \"O Wins\"\n\t\t@gameon = false\n\tend\n\n\n\tif board[0][0] == 1 && board[1][1] ==1 && board[2][2] == 1\n\t\tputs \"X Wins\"\n\t\t@gameon = false\n\tend\n\n\tif board[0][0] == 2 && board[1][1] ==2 && board[2][2] == 2\n\t\tputs \"O Wins\"\n\t\t@gameon = false\n\tend\n\n\n\tif board[2][0] == 1 && board[1][1] ==1 && board[0][2] == 1\n\t\tputs \"X Wins\"\n\t\t@gameon = false\n\tend\n\n\tif board[2][0] == 2 && board[1][1] ==2 && board[0][2] == 2\n\t\tputs \"O Wins\"\n\t\t@gameon = false\n\tend\n\nend",
"def winner_col\n for col_index in 0..BOARD_MAX_INDEX\n first_symbol=@board[0][col_index]\n\n for row_index in 1..BOARD_MAX_INDEX\n if first_symbol !=@board[row_index][col_index]\n break\n elsif\n row_index == BOARD_MAX_INDEX and first_symbol !=EMPTY_POS\n return first_symbol\n end\n end\n end\n return \n end",
"def who_is_winner(pieces_position_list)\n representation = create_representation(pieces_position_list)\n\n diagonal = get_diagonal(representation)\n on_row = by_row(representation)\n on_column = by_column(representation)\n\n [diagonal, on_column, on_row].select { |x| x != 'Draw' }.first\nend",
"def winner_via_column?(player)\n columns.any? do |column|\n column.cells.all? {|cell| cell.value == player.marker}\n end\n end",
"def won?\n longest_row(@player) >= 5\n end",
"def win\n table_keys = @board.boardcase.values\n if @board.boardcase[\"a1\"].shape == @board.boardcase[\"a2\"].shape && @board.boardcase[\"a3\"].shape == \"x\" && @board.boardcase[\"a2\"].shape == \"x\" ||\n @board.boardcase[\"a1\"].shape == @board.boardcase[\"b1\"].shape && @board.boardcase[\"c1\"].shape == \"x\" && @board.boardcase[\"b1\"].shape == \"x\" ||\n @board.boardcase[\"a2\"].shape == @board.boardcase[\"b2\"].shape && @board.boardcase[\"c2\"].shape == \"x\" && @board.boardcase[\"b2\"].shape == \"x\" ||\n @board.boardcase[\"a3\"].shape == @board.boardcase[\"b3\"].shape && @board.boardcase[\"c3\"].shape == \"x\" && @board.boardcase[\"b3\"].shape == \"x\" ||\n @board.boardcase[\"b1\"].shape == @board.boardcase[\"b2\"].shape && @board.boardcase[\"b3\"].shape == \"x\" && @board.boardcase[\"b2\"].shape == \"x\" ||\n @board.boardcase[\"c1\"].shape == @board.boardcase[\"c2\"].shape && @board.boardcase[\"c3\"].shape == \"x\" && @board.boardcase[\"c2\"].shape == \"x\" ||\n @board.boardcase[\"a1\"].shape == @board.boardcase[\"b2\"].shape && @board.boardcase[\"c3\"].shape == \"x\" && @board.boardcase[\"b2\"].shape == \"x\" ||\n @board.boardcase[\"a3\"].shape == @board.boardcase[\"b2\"].shape && @board.boardcase[\"c1\"].shape == \"x\" && @board.boardcase[\"b2\"].shape == \"x\"\n puts \"#{@player_1.name} Won!\"\n return true\n elsif\n @board.boardcase[\"a1\"].shape == @board.boardcase[\"a2\"].shape && @board.boardcase[\"a3\"].shape == \"o\" && @board.boardcase[\"a2\"].shape == \"o\" ||\n @board.boardcase[\"a1\"].shape == @board.boardcase[\"b1\"].shape && @board.boardcase[\"c1\"].shape == \"o\" && @board.boardcase[\"b1\"].shape == \"o\" ||\n @board.boardcase[\"a2\"].shape == @board.boardcase[\"b2\"].shape && @board.boardcase[\"c2\"].shape == \"o\" && @board.boardcase[\"b2\"].shape == \"o\" ||\n @board.boardcase[\"a3\"].shape == @board.boardcase[\"b3\"].shape && @board.boardcase[\"c3\"].shape == \"o\" && @board.boardcase[\"b3\"].shape == \"o\" ||\n @board.boardcase[\"b1\"].shape == @board.boardcase[\"b2\"].shape && @board.boardcase[\"b3\"].shape == \"o\" && @board.boardcase[\"b2\"].shape == \"o\" ||\n @board.boardcase[\"c1\"].shape == @board.boardcase[\"c2\"].shape && @board.boardcase[\"c3\"].shape == \"o\" && @board.boardcase[\"c2\"].shape == \"o\" ||\n @board.boardcase[\"a1\"].shape == @board.boardcase[\"b2\"].shape && @board.boardcase[\"c3\"].shape == \"o\" && @board.boardcase[\"b2\"].shape == \"o\" ||\n @board.boardcase[\"a3\"].shape == @board.boardcase[\"b2\"].shape && @board.boardcase[\"c1\"].shape == \"o\" && @board.boardcase[\"b2\"].shape == \"o\"\n puts \"#{@player_2.name} Won!\"\n return true\nelse\n i = 0\n table_keys.each do |u|\n if u.shape != \" \"\n i += 1\n end\n end\n if i == 9\n puts \"It's a Draw!\"\n return true\n end\n end\nend",
"def winner\n winner=winner_row()\n if winner\n return winner\n end\n\n winner=winner_col()\n if winner\n return winner\n end\n \n winner=winner_daigonal()\n if winner \n return winner\n end\n\n # if no winner \n return \n end",
"def is_player_winner(moves)\n grid = map_to_grid moves\n is_winner grid\n end",
"def won? (board)\n #for each row, column and diagnonal combination\n WIN_COMBINATIONS.each do | win_combination |\n #grab the winning combinaation of indices we are looking for\n win_index_1 = win_combination[0]\n win_index_2 = win_combination[1]\n win_index_3 = win_combination[2]\n\n #extract the value of these winning indices from the board\n position_1 = board[win_index_1]\n position_2 = board[win_index_2]\n position_3 = board[win_index_3]\n\n\n #check if either team has won\n if (position_1 == \"X\" && position_2 == \"X\" && position_3 == \"X\") ||\n (position_1 == \"O\" && position_2 == \"O\" && position_3 == \"O\")\n #we break out of here if we have a winning row, col, or diagnonal\n return win_combination\n end #end if\n end #end for each\n\n #if we get here the board may be empty\n #if we get here the board may be filled, but no winning combos\n return false\nend",
"def winner\n if won? == nil\n return nil\n else\n winning_position = won?\n winning_index = winning_position[0]\n @board[winning_index]\n end\n end",
"def won?(check_symbol)\n \trow_winner?(check_symbol) || \n \t col_winner?(check_symbol) ||\n \t diag_winner?(check_symbol)\n end",
"def winner\n self.won?? self.board.cells[self.won?[0]] : nil\n end",
"def check_rows_for_winner?(board, piece)\n return (board[0][0] == piece && board[0][1] == piece && board[0][2] == piece ||\n board[1][0] == piece && board[1][1] == piece && board[1][2] == piece ||\n board[2][0] == piece && board[2][1] == piece && board[2][2] == piece)\n end",
"def winner?(board)\n WINNING_LINES.each do |line|\n if board[line[0]] == 'X' && board[line[1]] == 'X' && board[line[2]] == 'X'\n return 'Player'\n elsif board[line[0]] == 'O' && board[line[1]] == 'O' && board[line[2]] == 'O'\n return 'Computer'\n end # end if \n end #end do\n return nil\nend",
"def is_win(x, y, player)\n create_pivot_vectors(x, y)\n\n # TODO: parameter key not used (fix)\n @moves.each do |key, array|\n win3 = 0\n array.each do |key, val|\n if val == player\n win3 += 1\n return true if win3 == @win_with\n else\n win3 = 0\n end\n end\n end\n false\n end",
"def gameOver(position)\n #horizontal rows\n for x in 0..2\n if position[x][0]!=0 and position[x][0]==position[x][1] and position[x][1]==position[x][2]\n return position[x][0]\n end\n end\n #vertical rows\n for y in 0..2\n if position[0][y]!=0 and position[0][y]==position[1][y] and position[1][y]==position[2][y]\n return position[0][y]\n end\n end\n #diagonals\n if position[0][0]!=0 and position[0][0]==position[1][1] and position[1][1]==position[2][2]\n return position[0][0]\n end\n if position[2][0]!=0 and position[2][0]==position[1][1] and position[1][1]==position[0][2]\n return position[2][0]\n end\n if fullBoard(position)\n return -1\n end\n return 0\n end",
"def winner_H(board,player) \n for i in 0..5\n check=0\n j=0\n\n while (j < 6)\n if (board[i][j] == player && board[i][j]!=\" \")\n check=check+1\n else\n check=0\n end\n\n if (check== 4) then\n return true\n end\n j=j+1\n end\n end\n\n return false\n end",
"def winner_diagonals\n\n # Start at the top left, get the player symbol (X or O) to match\n first_symbol = @board[0][0]\n\n # Traverse the diagonal from top left to bottom right\n for index in 1..BOARD_MAXIMUM_INDEX\n\n # Does this cell match the first symbol?\n if first_symbol != @board[index][index]\n\n # No, this diagonal IS NOT a winning combination\n break\n\n # At the end of this diagonal and not all empty?\n elsif index == BOARD_MAXIMUM_INDEX and first_symbol != EMPTY_POSITION\n\n # Yes, this diagonal IS a winning combination\n return first_symbol\n\n end\n\n end\n\n # Start at the top right, get the player symbol (X or O) to match\n row = 0 # Top\n column = BOARD_MAXIMUM_INDEX # Right\n first_symbol = @board[row][column]\n\n # Loop through each row (backwards diagonal)\n while row < BOARD_MAXIMUM_INDEX\n \n row += 1 # Down to the next row\n column -= 1 # Left to the next column\n\n # Does this cell match the first symbol?\n if first_symbol != @board[row][column]\n\n # No, this diagonal IS NOT a winning combination\n break\n\n # At the end of this diagonal and not all empty?\n elsif row == BOARD_MAXIMUM_INDEX and first_symbol != EMPTY_POSITION\n\n # Yes, this diagonal IS a winning combination\n return first_symbol\n\n end\n\n end\n\n # Nope, no winner in any diagonal\n return\n\n end",
"def check_board\n if in_row? || in_column? || in_descending_diagonal? || in_ascending_diagonal?\n puts \"BINGO!\"\n else\n puts \"SORRY!\"\n end\n end",
"def check_rows\n row_winner = nil\n\n # joins row and checks iteration count of x or o in strings to find winner\n @board.each do |row|\n row_str = row.join\n if row_str.count('x') == @board.size\n row_winner = 'x'\n elsif row_str.count('o') == @board.size\n row_winner = 'o'\n end\n end\n\n row_winner\n end",
"def win?(array,move,color)\n\n user_row = move[0]\n user_col = move[1]\n\n # check horizontal rows\n return true if horizontal_vertical_win?(array[user_row],color)\n # check vertical rows\n return true if horizontal_vertical_win?(array.collect {|row| row[user_col]},color)\n #check backslash diagonals\n return true if check_diagonals(BACKWARD_DIAGONALS,array, color, move)\n #check forwardslash diagonals\n return true if check_diagonals(FORWARD_DIAGONALS,array, color, move)\n end",
"def over?\n winner = @light_turn ? DARK : LIGHT\n if board.win?(winner)\n puts \"#{winner} Wins!\"\n return true\n elsif board.available_columns.empty?\n puts \"Tie game!\"\n return true\n end\n false\n end",
"def winner\n won? ? board.cells[won?[0]] : nil\n end",
"def winner_row\n for row_index in 0..BOARD_MAX_INDEX\n first_symbol=@board[row_index][0]\n for col_index in 1..BOARD_MAX_INDEX\n if first_symbol !=@board[row_index][col_index]\n break \n elsif col_index ==BOARD_MAX_INDEX and first_symbol != EMPTY_POS\n return first_symbol\n end\n end\n end\n return \n end",
"def win\n # horizontal win\n winner = horizontal_win?\n if winner\n victory(winner)\n return winner\n end\n\n # Vertical win (way harder to test for)\n winner = vertical_win?\n if winner\n victory(winner)\n return winner\n end\n\n # Diagonal win\n winner = diagonal_win?\n if winner\n victory(winner)\n return winner\n end\n\n # If the board is full and there are no declared winners\n\n if full?\n victory(\"Nobody\")\n return \"tie\"\n end\n return false\n end",
"def winner_mark\n check_columns ||\n check_rows ||\n check_left_diagonal ||\n check_right_diagonal\n end",
"def check_winner(player, color)\n if check_horiz(color)\n return true\n elsif check_vert\n return true\n elsif check_diag\n return true\n else\n return false\n end \n end",
"def row_winning_move\n\t\t@board.grid.each_with_index do |row, r|\n\t\t\tother_nil_index = contains_two_marks(row)\n\t\t\tif(other_nil_index)\n\t\t\t\treturn [r, other_nil_index]\n\t\t\tend\n\t\tend\n\t\treturn false\n\tend",
"def detect_winner(board)\n WINNING_LINES.each do |line|\n if board.values_at(*line).count('X') == 2\n return 'X'\n elsif board.values_at(*line).count('O') == 2\n return 'O'\n end\n end\n nil\nend",
"def is_winner?(mark)\n\t WIN_CONFIGS.any? do |line|\n\t line.all? do |elem|\n\t\t row, col = to_row_col(elem)\n\t\t @grid[row][col] == mark unless (row.nil? || col.nil?)\n\t\tend\n\t end\n\tend",
"def straight_check_col\n @in_a_col_counter = 0\n @row_up_iterater = 1\n @row_down_iterater = 1\n\n 3.times do #check for wins in that column\n if (0 <= (@row - @row_up_iterater) && (@row - @row_up_iterater) <= 5) && ((0 <= @col) and (@col <= 6))\n if @board[@row][@col] == board[@row - @row_up_iterater][@col] #checks up that column\n @row_up_iterater += 1 #if that cell is the same then increments the @row iterater so next loop will check the one even farther out\n @in_a_col_counter += 1 #increments column counter if it is the same\n end\n end\n if (0 <= (@row + @row_down_iterater) && (@row + @row_down_iterater) <= 5) && ((0 <= @col) and (@col <= 6))\n if @board[@row][@col] == board[@row + @row_down_iterater][@col] #checks down that column\n @row_down_iterater += 1\n @in_a_col_counter += 1\n end\n end\n end\n if @in_a_col_counter >= 3 \n puts \"#{@piece} won with that vert column of #{piece}'s!\"\n return true\n else\n \treturn false\n end\n end",
"def has_winner?\n result = nil\n if @board.is_win?(1.0)\n result = @player_one\n elsif @board.is_win?(-1.0)\n result = @player_two\n end\n return result\n end",
"def winner_daigonal\n first_symbol=@board[0][0]\n for index in 1..BOARD_MAX_INDEX\n if first_symbol !=@board[index][index]\n break\n elsif index==BOARD_MAX_INDEX and first_symbol!=EMPTY_POS\n return first_symbol\n end\n end\n\n \n first_symbol=@board[0][BOARD_MAX_INDEX]\n row_index=0\n col_index=BOARD_MAX_INDEX\n\n while row_index < BOARD_MAX_INDEX\n row_index+=1\n col_index-=1\n\n if first_symbol !=@board[row_index][col_index]\n break\n elsif row_index==BOARD_MAX_INDEX and first_symbol!=EMPTY_POS\n return first_symbol\n end\n \n end\n return \n end",
"def winner\n row_winners = rows.select{|r| identical_symbols(r)}.map{|r| r[0]}\n column_winners = columns.select{|c| identical_symbols(c)}.map{|c| c[0]}\n diagonal_winners = diagonals.select{|d| identical_symbols(d)}.map{|d| d[0]}\n winners = (row_winners + column_winners + diagonal_winners).uniq - %w(_)\n players = winners.map{|w| to_player_number(w)}\n players[0] # this would default to nil if players is empty\n end",
"def check_winner\r\n\t\tif board.winner?(p1.marker)\r\n\t\t\ttrue\r\n\t\telsif board.winner?(p2.marker)\r\n\t\t\ttrue\r\n\t\telse\r\n\t\t\tfalse\r\n\t\t\t\r\n\t\tend\r\n\tend"
] |
[
"0.79820615",
"0.7954588",
"0.79442495",
"0.7917773",
"0.789783",
"0.78936964",
"0.7892042",
"0.78843594",
"0.7867181",
"0.78084165",
"0.7803592",
"0.77971774",
"0.77396137",
"0.7722822",
"0.77032244",
"0.7686745",
"0.7679554",
"0.7673448",
"0.76709867",
"0.7666093",
"0.761983",
"0.7610007",
"0.7606661",
"0.75925887",
"0.7586243",
"0.7560406",
"0.754257",
"0.7501887",
"0.7501207",
"0.7485344",
"0.7470982",
"0.74514526",
"0.7439189",
"0.743369",
"0.74314445",
"0.7422382",
"0.74055225",
"0.73961943",
"0.7391337",
"0.7369902",
"0.73691237",
"0.73662466",
"0.7365879",
"0.73630506",
"0.73621106",
"0.73439556",
"0.7339291",
"0.73357177",
"0.73350203",
"0.7329623",
"0.73184365",
"0.73144615",
"0.7309508",
"0.7287856",
"0.727778",
"0.7274603",
"0.7260843",
"0.7259472",
"0.7255026",
"0.72537184",
"0.72522575",
"0.7250832",
"0.7249984",
"0.72482866",
"0.724245",
"0.7238183",
"0.7236997",
"0.7231459",
"0.72308856",
"0.72176456",
"0.7216825",
"0.7210392",
"0.72044176",
"0.71996987",
"0.71986306",
"0.71916544",
"0.71720105",
"0.7171311",
"0.7165755",
"0.7164116",
"0.7158413",
"0.71583635",
"0.71489173",
"0.71460944",
"0.7144542",
"0.71389925",
"0.7123241",
"0.7120759",
"0.7117833",
"0.70969856",
"0.70950675",
"0.7087034",
"0.7085553",
"0.70843095",
"0.7080764",
"0.7078687",
"0.7075776",
"0.70750785",
"0.7074571",
"0.70719135",
"0.70667505"
] |
0.0
|
-1
|
if some diagonal or the row or the colum has the same symbol three times then there is a winner
|
def winner_conditions(condition1, condition2, line)
row1 = (movements[condition1 - 1] + movements[condition1 - 2] + movements[condition1 - 3] == line)
column1 = (movements[condition2] + movements[condition2 + 3] + movements[condition2 + 6] == line)
diagonal1 = (movements[0] + movements[4] + movements[8] == line)
diagonal2 = (movements[2] + movements[4] + movements[6] == line)
return unless row1 or column1 or diagonal1 or diagonal2
show_board
puts players[turn % 2].name + ' is the winner'
@game_continue = false
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def winner\n #see if there are four in a row\n @columns.times do |c|\n @rows.times do |r|\n check = @slots[c][r]\n if check != nil\n if (r <= @rows - 4) && [check, @slots[c][r+1], @slots [c][r+2], @slots[c][r+3]].uniq.length == 1\n return check\n elsif (c <= (@columns - 4)) && [check, @slots[c+1][r], @slots[c+2][r], @slots[c+3][r]].uniq.length == 1\n return check\n elsif (r >= 3) && (c <= (@columns - 4)) && [check, @slots[c+1][r-1], @slots[c+2][r-2], @slots[c+3][r-3]].uniq.length ==1\n return check\n elsif (r >= 3) && (c >= (@columns - 4)) && [check, @slots[c-1][r-1], @slots[c-2][r-2], @slots[c-3][r-3]].uniq.length ==1\n return check\n end\n end\n end\n end\n return false\n end",
"def winner\n (@rows + cols + diagonals).each do |row|\n return :x if row.all? { |mark| mark == :x }\n return :o if row.all? { |mark| mark == :o }\n end\n \n nil\n end",
"def winner\n (rows + cols + diagonals).each do |triple|\n return :x if triple == [:x, :x, :x]\n return :o if triple == [:o, :o, :o]\n end\n \n nil\n end",
"def check_diagonals\n diagonal_winner = nil\n # stores the markers\n backward_diagonal = ''\n forward_diagonal = ''\n\n # for a diagonal to be a winner it takes the row[n], row[n+1], row[n+2] and so on..\n @board.each_with_index do |row,index|\n\n # check if left to right diagonal is a winner\n row.each_with_index do |marker, position|\n if position == index\n backward_diagonal += marker\n end\n end\n\n # check if right to left diagonal is a winner\n reversed_row = row.reverse\n reversed_row.each_with_index do |marker, position|\n if position == index\n forward_diagonal += marker\n end\n end\n end\n\n # checks iteration count of x or o in strings to find winner\n if backward_diagonal.count('x') == @board.size || forward_diagonal.count('x') == @board.size\n diagonal_winner = 'x'\n elsif backward_diagonal.count('o') == @board.size || forward_diagonal.count('o') == @board.size\n diagonal_winner = 'o'\n end\n\n diagonal_winner\n end",
"def diag_winner?(check_symbol)\n \t(@current_state[:A1] == check_symbol &&\n \t\t@current_state[:B2] == check_symbol &&\n \t\t@current_state[:C3] == check_symbol) ||\n \t(@current_state[:A3] == check_symbol &&\n \t\t@current_state[:B2] == check_symbol && \n \t\t@current_state[:C1] == check_symbol) \n end",
"def check_winner\n row_filled_with_same_element = ->(row) { row.reduce(row[0]) { |acc, elem| acc if elem == acc } }\n winners = [board, board.transpose, diagonals].map do |board_version|\n board_version.map(&row_filled_with_same_element).find { |row| row && row != 0 }\n end\n winners.find { |row| row }\n end",
"def winner?(board)\n #vertical and horizonal equality checks\n j = 0\n for i in 0...3\n return true if (board[j]==board[j+1])&&(board[j+1]==board[j+2])\n\n j += 3\n end\n #verticals equality test\n j = 0\n for i in 0...3\n\n return true if (board[j]==board[j+3])&&(board[j+3]==board[j+6])\n j += 1\n end\n\n #diagonals equality test\n \n return true if (board[0]==board[4])&&(board[4]==board[8])\n return true if (board[2]==board[4])&&(board[4]==board[6])\n \n\n false\n end",
"def checkwinner\r\n\t\t\t\r\n\t\t\t@matrix.each do |row|\r\n\t\t\t\trow.join.gsub(\"|\",\"\")\r\n\t\t\tend\r\n\t\t\t\r\n\t\t\t#check horizontal winners\r\n\t\t\t@matrix.each do |row|\r\n\t\t\t if row.join.include? \"XXXX\"\r\n\t\t\t\t@winner = 2\t\r\n\t\t\t elsif row.join.include? \"OOOO\"\r\n\t\t\t\t@winner = 1\r\n\t\t\t end\r\n\t\t\tend\r\n\r\n\t\t\t#check vertical winners\r\n\t\t\t@matrix.transpose.each do |row|\r\n\t\t\t if row.join.include? \"XXXX\"\r\n\t\t\t\t@winner = 2\t\r\n\t\t\t elsif row.join.include? \"OOOO\"\r\n\t\t\t\t@winner = 1\r\n\t\t\t end\r\n\t\t\tend\r\n\t\t\t\r\n\t\t\tfor row_nr in 0..@matrix.count-4\r\n\t\t\t for col_nr in 0..@matrix[0].count-4\r\n\t\t\t\tel_1 = @matrix[row_nr] [col_nr]\r\n\t\t\t\tel_2 = @matrix[row_nr+1][col_nr+1]\r\n\t\t\t\tel_3 = @matrix[row_nr+2][col_nr+2]\r\n\t\t\t\tel_4 = @matrix[row_nr+3][col_nr+3]\r\n\r\n\t\t\t\tif el_1 + el_2 + el_3 + el_4 == 'XXXX'\r\n\t\t\t\t @winner = 2\t\r\n\t\t\t\telsif el_1 + el_2 + el_3 + el_4 == 'OOOO'\r\n\t\t\t\t @winner = 1\r\n\t\t\t\tend\r\n\t\t\t end\r\n\t\t\tend\r\n\t\t\t#right to left\r\n\t\t\tfor row_nr in 0..@matrix.count-4\r\n\t\t\t for col_nr in 0..@matrix[0].count-4\r\n\t\t\t\tel_1 = @matrix.reverse[row_nr] [col_nr]\r\n\t\t\t\tel_2 = @matrix.reverse[row_nr+1][col_nr+1]\r\n\t\t\t\tel_3 = @matrix.reverse[row_nr+2][col_nr+2]\r\n\t\t\t\tel_4 = @matrix.reverse[row_nr+3][col_nr+3]\r\n\r\n\t\t\t\tif el_1 + el_2 + el_3 + el_4 == 'XXXX'\r\n\t\t\t\t @winner = 2 \r\n\t\t\t\telsif el_1 + el_2 + el_3 + el_4 == 'OOOO'\r\n\t\t\t\t @winner = 1\r\n\t\t\t\tend\r\n\t\t\t end\r\n\t\t\tend\r\n\t\r\n\t\t\treturn @winner\r\n\t\tend",
"def winner_diagonals\n\n # Start at the top left, get the player symbol (X or O) to match\n first_symbol = @board[0][0]\n\n # Traverse the diagonal from top left to bottom right\n for index in 1..BOARD_MAXIMUM_INDEX\n\n # Does this cell match the first symbol?\n if first_symbol != @board[index][index]\n\n # No, this diagonal IS NOT a winning combination\n break\n\n # At the end of this diagonal and not all empty?\n elsif index == BOARD_MAXIMUM_INDEX and first_symbol != EMPTY_POSITION\n\n # Yes, this diagonal IS a winning combination\n return first_symbol\n\n end\n\n end\n\n # Start at the top right, get the player symbol (X or O) to match\n row = 0 # Top\n column = BOARD_MAXIMUM_INDEX # Right\n first_symbol = @board[row][column]\n\n # Loop through each row (backwards diagonal)\n while row < BOARD_MAXIMUM_INDEX\n \n row += 1 # Down to the next row\n column -= 1 # Left to the next column\n\n # Does this cell match the first symbol?\n if first_symbol != @board[row][column]\n\n # No, this diagonal IS NOT a winning combination\n break\n\n # At the end of this diagonal and not all empty?\n elsif row == BOARD_MAXIMUM_INDEX and first_symbol != EMPTY_POSITION\n\n # Yes, this diagonal IS a winning combination\n return first_symbol\n\n end\n\n end\n\n # Nope, no winner in any diagonal\n return\n\n end",
"def won?(check_symbol)\n \trow_winner?(check_symbol) || \n \t col_winner?(check_symbol) ||\n \t diag_winner?(check_symbol)\n end",
"def check_matches\n #check for horizontal matches\n match_found = false \n for i in (0..@width-3)\n for j in (0..@height-1)\n if (@board[i][j] and @board[i+1][j] and @board[i+2][j] and \n @board[i][j].color == @board[i+1][j].color and @board[i][j].color == @board[i+2][j].color)\n @board[i][j].marked = @board[i+1][j].marked = @board[i+2][j].marked = true\n match_found = true\n end\n end\n end\n #check for vertical matches\n for i in (0..@width-1)\n for j in (0..@height-3)\n if (@board[i][j] and @board[i][j+1] and @board[i][j+2] and \n @board[i][j].color == @board[i][j+1].color and @board[i][j].color == @board[i][j+2].color)\n @board[i][j].marked = @board[i][j+1].marked = @board[i][j+2].marked = true\n match_found = true\n end\n end\n end\n\n return match_found \n end",
"def winner?\n (board[:a] == board[:b] && board[:b] == board[:c]) ||\n (board[:d] == board[:e] && board[:e] == board[:f]) ||\n (board[:g] == board[:h] && board[:h] == board[:i]) ||\n (board[:a] == board[:d] && board[:d] == board[:g]) ||\n (board[:b] == board[:e] && board[:e] == board[:h]) ||\n (board[:c] == board[:f] && board[:f] == board[:i]) ||\n (board[:a] == board[:e] && board[:e] == board[:i]) ||\n (board[:c] == board[:e] && board[:e] == board[:g])\n end",
"def winner\n [\n [[0,0],[0,1],[0,2]], # column 0\n [[1,0],[1,1],[1,2]], # column 1\n [[2,0],[2,1],[2,2]], # column 2\n [[0,0],[1,0],[2,0]], # row 0\n [[0,1],[1,1],[2,1]], # row 1\n [[0,2],[1,2],[2,2]], # row 2\n [[0,0],[1,1],[2,2]], # descending diagonal\n [[0,2],[1,1],[2,0]], # ascending diagonal\n ].each do |cells|\n vals = cells.map {|x, y| board[y][x] }\n return :x if vals == %w( X X X )\n return :o if vals == %w( O O O )\n end \n return nil\n end",
"def squarocol?(arr)\n (0..arr.length-1).each do |i|\n row_counter = 1\n col_counter = 1\n\n (0...arr.length-1).each do |j|\n row_counter += 1 if arr[i][j] == arr[i][j + 1]\n col_counter += 1 if arr[j][i] == arr[j + 1][i]\n \n end\n\n if row_counter == arr.length || col_counter == arr.length\n return true\n end\n \n end\n false\nend",
"def win\n table_keys = @board.boardcase.values\n if @board.boardcase[\"a1\"].shape == @board.boardcase[\"a2\"].shape && @board.boardcase[\"a3\"].shape == \"x\" && @board.boardcase[\"a2\"].shape == \"x\" ||\n @board.boardcase[\"a1\"].shape == @board.boardcase[\"b1\"].shape && @board.boardcase[\"c1\"].shape == \"x\" && @board.boardcase[\"b1\"].shape == \"x\" ||\n @board.boardcase[\"a2\"].shape == @board.boardcase[\"b2\"].shape && @board.boardcase[\"c2\"].shape == \"x\" && @board.boardcase[\"b2\"].shape == \"x\" ||\n @board.boardcase[\"a3\"].shape == @board.boardcase[\"b3\"].shape && @board.boardcase[\"c3\"].shape == \"x\" && @board.boardcase[\"b3\"].shape == \"x\" ||\n @board.boardcase[\"b1\"].shape == @board.boardcase[\"b2\"].shape && @board.boardcase[\"b3\"].shape == \"x\" && @board.boardcase[\"b2\"].shape == \"x\" ||\n @board.boardcase[\"c1\"].shape == @board.boardcase[\"c2\"].shape && @board.boardcase[\"c3\"].shape == \"x\" && @board.boardcase[\"c2\"].shape == \"x\" ||\n @board.boardcase[\"a1\"].shape == @board.boardcase[\"b2\"].shape && @board.boardcase[\"c3\"].shape == \"x\" && @board.boardcase[\"b2\"].shape == \"x\" ||\n @board.boardcase[\"a3\"].shape == @board.boardcase[\"b2\"].shape && @board.boardcase[\"c1\"].shape == \"x\" && @board.boardcase[\"b2\"].shape == \"x\"\n puts \"#{@player_1.name} Won!\"\n return true\n elsif\n @board.boardcase[\"a1\"].shape == @board.boardcase[\"a2\"].shape && @board.boardcase[\"a3\"].shape == \"o\" && @board.boardcase[\"a2\"].shape == \"o\" ||\n @board.boardcase[\"a1\"].shape == @board.boardcase[\"b1\"].shape && @board.boardcase[\"c1\"].shape == \"o\" && @board.boardcase[\"b1\"].shape == \"o\" ||\n @board.boardcase[\"a2\"].shape == @board.boardcase[\"b2\"].shape && @board.boardcase[\"c2\"].shape == \"o\" && @board.boardcase[\"b2\"].shape == \"o\" ||\n @board.boardcase[\"a3\"].shape == @board.boardcase[\"b3\"].shape && @board.boardcase[\"c3\"].shape == \"o\" && @board.boardcase[\"b3\"].shape == \"o\" ||\n @board.boardcase[\"b1\"].shape == @board.boardcase[\"b2\"].shape && @board.boardcase[\"b3\"].shape == \"o\" && @board.boardcase[\"b2\"].shape == \"o\" ||\n @board.boardcase[\"c1\"].shape == @board.boardcase[\"c2\"].shape && @board.boardcase[\"c3\"].shape == \"o\" && @board.boardcase[\"c2\"].shape == \"o\" ||\n @board.boardcase[\"a1\"].shape == @board.boardcase[\"b2\"].shape && @board.boardcase[\"c3\"].shape == \"o\" && @board.boardcase[\"b2\"].shape == \"o\" ||\n @board.boardcase[\"a3\"].shape == @board.boardcase[\"b2\"].shape && @board.boardcase[\"c1\"].shape == \"o\" && @board.boardcase[\"b2\"].shape == \"o\"\n puts \"#{@player_2.name} Won!\"\n return true\nelse\n i = 0\n table_keys.each do |u|\n if u.shape != \" \"\n i += 1\n end\n end\n if i == 9\n puts \"It's a Draw!\"\n return true\n end\n end\nend",
"def col_winner?(check_symbol)\n \t(@current_state[:A1] == check_symbol &&\n \t\t@current_state[:B1] == check_symbol &&\n \t\t@current_state[:C1] == check_symbol) ||\n \t(@current_state[:A2] == check_symbol &&\n \t\t@current_state[:B2] == check_symbol && \n \t\t@current_state[:C2] == check_symbol) ||\n \t(@current_state[:A3] == check_symbol &&\n \t\t@current_state[:B3] == check_symbol &&\n \t\t@current_state[:C3] == check_symbol)\n end",
"def check_rows\n row_winner = nil\n\n # joins row and checks iteration count of x or o in strings to find winner\n @board.each do |row|\n row_str = row.join\n if row_str.count('x') == @board.size\n row_winner = 'x'\n elsif row_str.count('o') == @board.size\n row_winner = 'o'\n end\n end\n\n row_winner\n end",
"def check_winner\n cells_t = cells.transpose\n row_winner(cells)\n row_winner(cells_t)\n diagonal_winner unless winner\n announce_winner if winner\n winner\n end",
"def squarocol?(array)\n height = array.length\n width = height\n (0...height).each do |i|\n count_c = 1\n count_r = 1\n (0...width - 1).each do |j|\n count_c += 1 if array[i][j] == array[i][j + 1]\n count_r += 1 if array[j][i] == array[j + 1][i]\n end\n return true if count_c == height || count_r == width\n end\n false\nend",
"def winner?(letter=:X)\n win_arr = [letter, letter, letter]\n\n # check rows\n return true unless @squares.index(win_arr).nil?\n\n # check columns\n return true unless @squares.index(win_arr).nil?\n end",
"def check_diagonal\n RulesContracts.classic_model(@game_state_model)\n # testing for bitboard errors\n # (0..7).each { |y|\n # (0..7).each { |x|\n # if @grid[y][x] == 1 and y <= 4 and x >= 3\n # puts \" #{x}/#{y} #{@grid[y][x]} || #{x-1}/#{y+1} #{@grid[y + 1][x - 1]} || #{x-2}/#{y+2} #{@grid[y + 2][x - 2]} || #{x-3}/#{y+3} #{@grid[y + 3][x - 3]}\"\n # puts \"#{@grid[y][x] == 1 and @grid[y + 1][x - 1] == 1 and @grid[y + 2][x - 2] == 1 and @grid[y + 3][x - 3] == 1}\"\n # end\n # }\n # }\n \n (0..7).each { |y|\n (0..7).each { |x|\n if y <= 4 and x <= 4\n if @grid[y][x] == 2 and @grid[y + 1][x + 1] == 2 and @grid[y + 2][x + 2] == 2 and @grid[y + 3][x + 3] == 2\n @winner = 1\n return true\n elsif @grid[y][x] == 1 and @grid[y + 1][x + 1] == 1 and @grid[y + 2][x + 2] == 1 and @grid[y + 3][x + 3] == 1\n @winner = 0\n return true\n end \n end\n if y <= 4 and x >= 3\n if @grid[y][x] == 2 and @grid[y + 1][x - 1] == 2 and @grid[y + 2][x - 2] == 2 and @grid[y + 3][x - 3] == 2\n @winner = 1\n return true\n elsif @grid[y][x] == 1 and @grid[y + 1][x - 1] == 1 and @grid[y + 2][x - 2] == 1 and @grid[y + 3][x - 3] == 1\n @winner = 0\n return true\n end\n end\n if y >= 3 and x <= 4\n if @grid[y][x] == 2 and @grid[y - 1][x + 1] == 2 and @grid[y - 2][x + 2] == 2 and @grid[y - 3][x + 3] == 2\n @winner = 1\n return true\n elsif @grid[y][x] == 1 and @grid[y - 1][x + 1] == 1 and @grid[y - 2][x + 2] == 1 and @grid[y - 3][x + 3] == 1\n @winner = 0\n return true\n end \n end\n if y >= 3 and x >= 3\n \n if @grid[y][x] == 2 and @grid[y - 1][x - 1] == 2 and @grid[y - 2][x - 2] == 2 and @grid[y - 3][x - 3] == 2\n @winner = 1\n return true\n elsif @grid[y][x] == 1 and @grid[y - 1][x - 1] == 1 and @grid[y - 2][x - 2] == 1 and @grid[y - 3][x - 3] == 1\n @winner = 0\n return true\n end \n \n end \n }\n }\n return false\n end",
"def get_winner\n indexes_to_check = (0..@n-3).to_a\n\n # Check horizontal winners\n @board.each_with_index do |_, k|\n indexes_to_check.each do |idx|\n return @board[k][idx] if marked(k, idx) && similar_value([k, idx], [k, idx + 1], [k, idx + 2])\n end\n end\n\n # Check vertical winners\n @n.times do |k|\n indexes_to_check.each do |idx|\n return @board[idx][k] if marked(idx, k) && similar_value([idx, k], [idx + 1, k], [idx + 2, k])\n end\n end\n\n # Check diagonal winners\n indexes_to_check.product(indexes_to_check).each do |idx1, idx2|\n if marked(idx1, idx2) && similar_value([idx1, idx2], [idx1 + 1, idx2 + 1], [idx1 + 2, idx2 + 2])\n return @board[idx1][idx2]\n elsif marked(idx1, idx2 + 2) && similar_value([idx1, idx2 + 2], [idx1 + 1, idx2 + 1], [idx1 + 2, idx2])\n return @board[idx1][idx2+2]\n end\n end\n\n false\n end",
"def row_winner?(check_symbol)\n \t(@current_state[:A1] == check_symbol &&\n \t\t@current_state[:A2] == check_symbol &&\n \t\t@current_state[:A3] == check_symbol) ||\n \t(@current_state[:B1] == check_symbol &&\n \t\t@current_state[:B2] == check_symbol && \n \t\t@current_state[:B3] == check_symbol) ||\n \t(@current_state[:C1] == check_symbol &&\n \t\t@current_state[:C2] == check_symbol &&\n \t\t@current_state[:C3] == check_symbol)\n end",
"def winner_via_diagonal?(player)\n diagonals.any? do |diagonal|\n diagonal.cells.all? {|cell| cell.value == player.marker}\n end\n end",
"def b_check sym \n\t\t#check rows\n\t\ti=0\n\t\twhile i<@arr.length\n\t\t\tgame_finished=true\n\t\t\tj=0\n\t\t\twhile j<@arr.length\n\t\t\t\tif @arr[i][j]!=sym\n\t\t\t\t\tgame_finished=false\n\t\t\t\t\tbreak\n\t\t\t\tend\n\t\t\t\tj=j+1\n\t\t\tend\n\t\t\tif game_finished\n\t\t\t\treturn game_finished\n\t\t\tend\n\t\t\ti=i+1\n\t\tend\n\t\t# check colmns\n\t\ti=0\n\t\twhile i<@arr.length\n\t\t\tgame_finished=true\n\t\t\tj=0\n\t\t\twhile j<@arr.length\n\t\t\t\tif @arr[j][i]!=sym\n\t\t\t\t\tgame_finished=false\n\t\t\t\t\tbreak\n\t\t\t\tend\n\t\t\t\tj=j+1\n\t\t\tend\n\t\t\tif game_finished\n\t\t\t\treturn game_finished\n\t\t\tend\n\t\t\ti=i+1\n\t\tend\n\t\t#check diagonals\n\t\ti=0\n\t\tgame_finished=true\n\t\tj=@arr.length-1\n\t\twhile i<@arr.length\n\t\t\tif @arr[i][j]!=sym\n\t\t\t\tgame_finished=false\n\t\t\t\tbreak\n\t\t\tend\n\t\t\ti=i+1\n\t\t\tj=j-1\n\t\tend\n\t\tif game_finished\n\t\t\treturn game_finished\n\t\tend\n\n\t\ti=0\n\t\tgame_finished=true\n\t\tj=0\n\t\twhile i<@arr.length\n\t\t\tif @arr[i][j]!=sym\n\t\t\t\tgame_finished=false\n\t\t\t\tbreak\n\t\t\tend\n\t\t\ti=i+1\n\t\t\tj=j+1\n\t\tend\n\t\tif game_finished\n\t\t\treturn game_finished\n\t\tend\n\t\treturn false\n\tend",
"def winner_columns\n\n # Outer loop to look for a winner down the column\n for column in 0..BOARD_MAXIMUM_INDEX\n\n # Get the player symbol (X or O) that must match\n first_symbol = @board[0][column]\n\n # Inner loop to look at all elements in this column's rows\n for row in 1..BOARD_MAXIMUM_INDEX\n\n # Does this cell match the first symbol?\n if first_symbol != @board[row][column]\n\n # No, this column IS NOT a winning combination\n break\n\n # At the end of this column and not all empty?\n elsif row == BOARD_MAXIMUM_INDEX and first_symbol != EMPTY_POSITION\n\n # Yes, this column IS a winning combination\n return first_symbol\n\n end\n\n end\n\n end\n\n # Nope, no winner in any columns\n return\n\n end",
"def winner?\n return true if check_horizontal\n return true if check_vertical\n return true if check_diagonal1\n return true if check_diagonal2\n false\n end",
"def board_win?(board)\n first_row_win?(board) ||\n second_row_win?(board) ||\n third_row_win?(board) ||\n first_column_win?(board) ||\n second_column_win?(board) ||\n third_column_win?(board) ||\n diag_right_win?(board) ||\n diag_left_win?(board) \nend",
"def winner?\n (self.array & [\"a1\",\"a2\",\"a3\"]).length == 3 || (self.array & [\"b1\",\"b2\",\"b3\"]).length == 3 || (self.array & [\"c1\",\"c2\",\"c3\"]).length == 3 || (self.array & [\"a1\",\"b1\",\"c1\"]).length == 3 || (self.array & [\"a2\",\"b2\",\"c2\"]).length == 3 || (self.array & [\"a3\",\"b3\",\"c3\"]).length == 3 || (self.array & [\"a1\",\"b2\",\"c3\"]).length == 3 || (self.array & [\"c1\",\"b2\",\"a3\"]).length == 3\n end",
"def winner_rows\n\n # Outer loop to look for a winner across the row\n for row in 0..BOARD_MAXIMUM_INDEX\n\n # Get the player symbol (X or O) that must match\n first_symbol = @board[row][0]\n\n # Inner loop to look at all elements in the given column\n for column in 1..BOARD_MAXIMUM_INDEX\n\n # Does this cell match the first symbol?\n if first_symbol != @board[row][column]\n\n # No, this row IS NOT a winning combination\n break\n\n # At the end of the row and not all empty?\n # (Make sure we haven't found three empty positions in a column)\n elsif column == BOARD_MAXIMUM_INDEX and first_symbol != EMPTY_POSITION\n\n # Yes, this row IS a winning combination\n return first_symbol\n\n end\n\n end\n\n end\n\n # Nope, no winner in any rows\n return\n\n end",
"def winner_daigonal\n first_symbol=@board[0][0]\n for index in 1..BOARD_MAX_INDEX\n if first_symbol !=@board[index][index]\n break\n elsif index==BOARD_MAX_INDEX and first_symbol!=EMPTY_POS\n return first_symbol\n end\n end\n\n \n first_symbol=@board[0][BOARD_MAX_INDEX]\n row_index=0\n col_index=BOARD_MAX_INDEX\n\n while row_index < BOARD_MAX_INDEX\n row_index+=1\n col_index-=1\n\n if first_symbol !=@board[row_index][col_index]\n break\n elsif row_index==BOARD_MAX_INDEX and first_symbol!=EMPTY_POS\n return first_symbol\n end\n \n end\n return \n end",
"def three_in_a_row(token, board)\n board.each do |thash|\n if thash.values.all? { |value| value == token}\n return true # returns true (won game) if seen once\n end\n end\n return false # return false if not three in a row yet\nend",
"def check_diagonal1\n cell = @last_cell_played\n count = 1\n while cell.ld && cell.ld.color == cell.color\n cell = cell.ld\n end\n while cell.ru && cell.ru.color == cell.color\n cell = cell.ru\n count += 1\n end\n return true if count >= 4\n false\n end",
"def winning_condition?\n grid[0] == grid[1] && grid[1] == grid[2] ||\n grid[3] == grid[4] && grid[4] == grid[5] ||\n grid[6] == grid[7] && grid[7] == grid[8] ||\n grid[0] == grid[3] && grid[3] == grid[6] ||\n grid[1] == grid[4] && grid[4] == grid[7] ||\n grid[2] == grid[5] && grid[5] == grid[8] ||\n grid[0] == grid[4] && grid[4] == grid[8] ||\n grid[2] == grid[4] && grid[4] == grid[6]\n end",
"def check_rows_for_winner?(board, piece)\n return (board[0][0] == piece && board[0][1] == piece && board[0][2] == piece ||\n board[1][0] == piece && board[1][1] == piece && board[1][2] == piece ||\n board[2][0] == piece && board[2][1] == piece && board[2][2] == piece)\n end",
"def is_winner(b,l) \n return ((b[7] == l and b[8] == l and b[9] == l) or # across the top\n (b[4] == l and b[5] == l and b[6] == l) or # across the middle\n (b[1] == l and b[2] == l and b[3] == l) or # across the bttom\n (b[7] == l and b[4] == l and b[1] == l) or # down the left side\n (b[8] == l and b[5] == l and b[2] == l) or # down the middle\n (b[9] == l and b[6] == l and b[3] == l) or # down the right side\n (b[7] == l and b[5] == l and b[3] == l) or # diagonal\n (b[9] == l and b[5] == l and b[1] == l)) # diagonal\nend",
"def check_diagonal2\n cell = @last_cell_played\n count = 1\n while cell.rd && cell.rd.color == cell.color\n cell = cell.rd\n end\n while cell.lu && cell.lu.color == cell.color\n cell = cell.lu\n count += 1\n end\n return true if count >= 4\n false\n end",
"def block_diagonal_win?\n \tblank_x = -1\n \tx_row_total = 0\n \t\n \t3.times do |i|\t\n\t\t\tif @game_board[i][i] == \"X\"\n\t\t\t\tx_row_total += 1\n\t\t\telse \n\t\t\t\tblank_x = i\n\t\t\tend\n\n\t\t\tif x_row_total == 2 && blank_x > -1\n\t\t\t\t@game_board[blank_x][blank_x] = \"O\"\n\t\t\t\ttrue\n\t\t\tend\n \tend\n \tfalse\n end",
"def check_diag2 b, play\n x = 0\n while x < 4\n y = 0\n while y < 3\n if b[x+3][y] == play\n if b[x+2][y+1] == play\n if b[x+1][y+2] == play\n if b[x][y+3] == play\n win = true\n end\n end\n end\n end\n y = y + 1\n end\n x = x + 1\n end\n return win\nend",
"def identical_symbols(row_or_column)\n row_or_column[0] * 3 == row_or_column\n end",
"def winner\n # shortcut for less typing\n b = @board\n\n # rows\n return b[0] if b[0] == b[1] && b[1] == b[2]\n return b[3] if b[3] == b[4] && b[4] == b[5]\n return b[6] if b[6] == b[7] && b[7] == b[8]\n\n # cols\n return b[0] if b[0] == b[3] && b[3] == b[6]\n return b[1] if b[1] == b[4] && b[4] == b[7]\n return b[2] if b[2] == b[5] && b[5] == b[8]\n\n # diagonals\n return b[4] if b[0] == b[4] && b[4] == b[8]\n return b[4] if b[2] == b[4] && b[4] == b[6]\n\n end",
"def check_columns_for_winner\n # @player = nil\n if board[0][0] == board[1][0] and board[1][0] == board[2][0] and not board[0][0] == nil\n @player = board[0][0]\n elsif board[0][1] == board[1][1] and board[1][1] == board[2][1] and not board[0][1] == nil\n @player = board[0][1]\n elsif board[0][2] == board[1][2] and board[1][2] == board[2][2] and not board[0][2] == nil\n @player = board[0][2]\n end\n end",
"def win?\n # COLUMNS - 1\n return true if @boardcases[0].case_value == @boardcases[3].case_value && @boardcases[3].case_value == @boardcases[6].case_value && @boardcases[0].case_value != ' '\n # 2\n return true if @boardcases[1].case_value == @boardcases[4].case_value && @boardcases[4].case_value == @boardcases[7].case_value && @boardcases[1].case_value != ' '\n # 3\n return true if @boardcases[2].case_value == @boardcases[5].case_value && @boardcases[5].case_value == @boardcases[8].case_value && @boardcases[2].case_value != ' '\n # ROWS - A\n return true if @boardcases[0].case_value == @boardcases[1].case_value && @boardcases[1].case_value == @boardcases[2].case_value && @boardcases[0].case_value != ' '\n # B\n return true if @boardcases[3].case_value == @boardcases[4].case_value && @boardcases[4].case_value == @boardcases[5].case_value && @boardcases[3].case_value != ' '\n # C\n return true if @boardcases[6].case_value == @boardcases[7].case_value && @boardcases[7].case_value == @boardcases[8].case_value && @boardcases[6].case_value != ' '\n # DIAGONALS\n return true if @boardcases[0].case_value == @boardcases[4].case_value && @boardcases[4].case_value == @boardcases[8].case_value && @boardcases[0].case_value != ' '\n return true if @boardcases[6].case_value == @boardcases[4].case_value && @boardcases[4].case_value == @boardcases[2].case_value && @boardcases[6].case_value != ' '\n end",
"def winner?\n\t\t if( \n\t\t\t\t([@grid[0], @grid[1], @grid[2]].uniq.length == 1 && @grid[0] != \" \") ||\n\t\t\t\t([@grid[0], @grid[3], @grid[6]].uniq.length == 1 && @grid[0] != \" \") ||\n\t\t\t\t([@grid[0], @grid[4], @grid[8]].uniq.length == 1 && @grid[0] != \" \") ||\n\t\t\t\t([@grid[6], @grid[7], @grid[8]].uniq.length == 1 && @grid[6] != \" \") ||\n\t\t\t\t([@grid[2], @grid[5], @grid[8]].uniq.length == 1 && @grid[2] != \" \") ||\n\t\t\t\t([@grid[2], @grid[4], @grid[6]].uniq.length == 1 && @grid[2] != \" \") ||\n\t\t\t\t([@grid[1], @grid[4], @grid[7]].uniq.length == 1 && @grid[1] != \" \") ||\n\t\t\t\t([@grid[3], @grid[4], @grid[5]].uniq.length == 1 && @grid[3] != \" \")\n\t\t\t\t)\n\t\t\t\ttrue\n\t\t else\n\t\t\t\tfalse\n\t\t end\n\t\tend",
"def squarocol?(square)\n #if row.all? { |val| val == row[0]} TRUE\n #OR if array.transpose ^^\n \n square.each do |row|\n return true if row.uniq.count == 1\n end\n square.transpose.each do |col|\n return true if col.uniq.count == 1\n end\n\n false\nend",
"def three_in_a_diagonal?\n\t\tboard = @board.board\n\t\tdiagonal_rows = [[0, 1, 2], [2, 1, 0]] # Order of row index accesses for top-left to\n\t\t\t\t\t\t\t\t\t\t\t # to bottom right traversal first and then\n\t\t\t\t\t\t\t\t\t\t\t # bottom-left to top-right traversal last.\n\t\tthree_in_a_diagonal = false\n\t\toccurrences = 0\n\t\tdiagonal_rows.each do |diagonal|\n\t\t\tif (current_letter = board[diagonal[0]][0]) != \"_\"\n\t\t\t\t3.times do |element|\n\t\t\t\t\tif board[diagonal[element]][element] == current_letter\n\t\t\t\t\t\toccurrences += 1\n\t\t\t\t\telse\n\t\t\t\t\t\toccurrences = 0\n\t\t\t\t\t\tbreak\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tnext\n\t\t\tend\n\t\t\tif occurrences == 3\n\t\t\t\treturn [true, current_letter]\n\t\t\tend\n\t\tend\n\t\t[three_in_a_diagonal]\n\tend",
"def winner_row\n for row_index in 0..BOARD_MAX_INDEX\n first_symbol=@board[row_index][0]\n for col_index in 1..BOARD_MAX_INDEX\n if first_symbol !=@board[row_index][col_index]\n break \n elsif col_index ==BOARD_MAX_INDEX and first_symbol != EMPTY_POS\n return first_symbol\n end\n end\n end\n return \n end",
"def winner\n result = nil\n @field.each do | row | result ||= winner_test(row) end # Horizontal\n @field.transpose.each do | row | result ||= winner_test(row) end # Vertical\n result || winner_test((0..2).map{|i| @field[i][i]}) || winner_test((0..2).map{|i| @field[2-i][i]}) # Diagonal\n end",
"def squarocol?(matrix)\n d = matrix.length\n d.times do |i|\n return true if matrix[i].all?{ |el| el == matrix[i][0]}\n end\n\n\n \n d.times do |c|\n flag = 0\n n = matrix[0][c]\n d.times do |r|\n if !(matrix[r][c] == n)\n flag = 1\n break\n end\n end\n return true if flag == 0\n end\n false\nend",
"def win_diagonal?(mark)\n a = (0...@grid.length).all? {|i| self[[i,i]] == mark }\n b = (0...@grid.length).all? {|i| self[[i, @grid.length - 1 - i]] == mark }\n a || b\n end",
"def check_diag b, play\n x = 0\n while x < 4\n y = 0\n while y < 4\n if b[x][y] == play\n if b[x+1][y+1] == play\n if b[x+2][y+2] == play\n if b[x+3][y+3] == play\n win = true\n end\n end\n end\n end\n y = y + 1\n end\n x = x + 1\n end\n return win\nend",
"def check_board\n\n # starting at top left, check top row, diagonal and left column\n if ( ($game_board[0][0] == $game_board[0][1] && $game_board[0][0] == $game_board[0][2]) ||\n ($game_board[0][0] == $game_board[1][1] && $game_board[0][0] == $game_board[2][2]) ||\n ($game_board[0][0] == $game_board[1][0] && $game_board[0][0] == $game_board[2][0]) )\n $winner = $game_board[0][0] \n\n # starting at top middle, check middle column\n elsif ($game_board[0][1] == $game_board[1][1] && $game_board[0][1] == $game_board[2][1])\n $winner = $game_board[0][1]\n\n #starting at top right, check right column and diagonal\n elsif (($game_board[0][2] == $game_board[1][2] && $game_board[0][2] == $game_board[2][2]) ||\n ($game_board[0][2] == $game_board[1][1] && $game_board[0][2] == $game_board[2][0]))\n $winner = $game_board[0][2]\n\n #starting at middle left, check middle row\n elsif ($game_board[1][0] == $game_board[1][1] && $game_board[1][0] == $game_board[1][2])\n $winner = $game_board[1][0]\n\n #starting at bottom left, check bottom row\n elsif ($game_board[2][0] == $game_board[2][1] && $game_board[2][0] == $game_board[2][2])\n $winner = $game_board[2][0]\n end\n \n if $winner\n puts $winner.to_s + \" wins!\" \n exit\n end\n \n #if we don't have a winner at this point, and all the spaces are filled (not nil), then it's a tie\n if $game_board.flatten.all?\n puts \"It's a tie!\"\n exit\n end\n \nend",
"def check_rows_for_winner\n\n if board[0][0] == board[0][2] and board[0][1] == board[0][2] and not board[0][1] == nil\n @player = board[0][0]\n elsif board[1][0] == board[1][2] and board[1][1] == board[1][2] and not board[1][1] == nil\n @player = board[1][1]\n elsif board[2][0] == board[2][2] and board[2][1] == board[2][2] and not board[2][1] == nil\n @player = board[2][2]\n end\n end",
"def won?(board)\n WIN_COMBINATIONS.detect do |combinations|\n index_1 = combinations[0]\n index_2 = combinations[1]\n index_3 = combinations[2]\n\n position_1 = board[index_1]\n position_2 = board[index_2]\n position_3 = board[index_3]\n\n position_1 == position_2 && position_2 == position_3 && position_3 != \" \"\n end\nend",
"def win_condition(cell_1, cell_2, cell_3)\n cell_1.present? && cell_2.present? && cell_3.present? && [cell_1, cell_2, cell_3].uniq.count == 1\n end",
"def winner?\n directions = [[1,0], [1,-1], [1,1], [0,1]]\n max_x = grid[0].length\n max_y = grid.length\n directions.each do |dx, dy|\n for x in (0...max_x) do\n for y in (0...max_y) do\n last_x = x + 3 * dx\n last_y = y + 3 * dy\n if 0 <= last_x && last_x < max_x && 0 <= last_y && last_y < max_y\n val = get_cell(x, y).value\n if (!val.empty? && val == get_cell(x + dx, y + dy).value && \n val == get_cell(x + 2 * dx, y + 2 * dy).value &&\n val == get_cell(x + 3 * dx, y + 3 * dy).value)\n return true\n end\n end\n end\n end\n end\n return false\n end",
"def is_win?\n cell[0] == cell[1] && cell[1] == cell[2] ||\n cell[3] == cell[4] && cell[4] == cell[5] ||\n cell[6] == cell[7] && cell[7] == cell[8] ||\n cell[0] == cell[3] && cell[3] == cell[6] ||\n cell[1] == cell[4] && cell[4] == cell[7] ||\n cell[2] == cell[5] && cell[5] == cell[8] ||\n cell[0] == cell[4] && cell[4] == cell[8] ||\n cell[2] == cell[4] && cell[4] == cell[6]\n end",
"def won?\n #diagonals first\n has_left_diagonal = true\n has_right_diagonal = true\n (1..@board.length-1).each do |i|\n has_left_diagonal = false unless @board[i][i] == @board[0][0]\n has_right_diagonal = false unless @board[i][-1-i] == @board[0][-1]\n end\n return @board[0][0] if has_left_diagonal\n return @board[-1][0] if has_right_diagonal\n \n #check rows\n (0..@board.length-1).each do |i|\n #slightly more concise but costly ( O(n^2) per uniq ) than a manual check\n return @board[i][0] if @board[i].uniq.length == 1\n end\n \n #check columns\n (0..@board.length-1).each do |i|\n player = @board[0][i]\n has_column = true\n (1..@board.length-1).each do |j|\n has_column = false unless @board[j][i] == player\n end\n return player if has_column\n end\n \n return 0\n end",
"def winning_diagonal?(piece)\n diagonals.any? do |diag|\n diag.all?{|cell| cell == piece }\n end\n end",
"def word_square?(arr)\n # first brute force, using i and j \n i = 0 \n while i < arr.length \n j = 0 \n while j < arr.length \n # next if i >= j will overflow as j never increments\n if i >= j \n j+= 1 \n next \n end \n return false unless arr[i][j] == arr[j][i]\n j += 1 \n end \n i+=1 \n end \n true\n # now think how i can optimize it when i == j \n # it's comparing itself against itself, so we don't need to check \n # also we checked each pair twice , [0][2] first and [2][0]\n # the first round since we increment inner loop first, second number\n # is bigger, so we don't need to check if first number is bigger than secodn number \n # means it's the same pair \nend",
"def win?(mark)\n win_row?(mark) || win_col?(mark) || win_diagonal?(mark)\n end",
"def check_wins(column, player)\n\t\t# row checking\n\t\tfor i in 0...@@board.length\n\t\t\trow = @@board[i]\n\t\t\trow_counter = 0\n\t\t\tfor j in 0...row.length\n\t\t\t\tif row[j] === player\n\t\t\t\t\trow_counter += 1\n\t\t\t\t\tif row_counter === 4\n\t\t\t\t\t\treturn true\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\trow_counter = 0\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\t\t# column checking\n\t\tcolumn_counter = 0\n\t\tfor k in 0...@@board.length\n\t\t\tif @@board[k][column] === player\n\t\t\t\tcolumn_counter += 1\n\t\t\t\tif column_counter === 4\n\t\t\t\t\treturn true;\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\t\t# diagonal checking, chose to go to 11 because coordinates [5,6] can be\n\t\t#reached in this loop\n\t\tfor diagonal_sum in 0..11\n\t\t\tdiagonal_counter = 0\n\t\t\tfor x in 0..diagonal_sum\n\t\t\t\ty = diagonal_sum - x\n\t\t\t\tif (defined?(@@board[x][y])).nil?\n\t\t\t\t\t# some of the coordinates being checked are not defined, this is to\n\t\t\t\t\t# keep looping through the board to check values on the board\n\t\t\t\t\tnext\n\t\t\t\tend\n\t\t\t\tif @@board[x][y] === player\n\t\t\t\t\tdiagonal_counter += 1\n\t\t\t\t\tif diagonal_counter === 4\n\t\t\t\t\t\treturn true\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\tdiagonal_counter = 0\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\t\t# other diagonal checking\n\t\tfor diagonal_diff in (6).downto(-5)\n\t\t\ty = 0\n\t\t\tother_diagonal_counter = 0\n\t\t\tfor x in 0...7\n\t\t\t\ty = diagonal_diff + x\n\t\t\t\tif (defined?(@@board[x][y])).nil? #if a space is undefined, just keep checking\n\t\t\t\t\tnext\n\t\t\t\tend\n\t\t\t\tif y < 7\n\t\t\t\t\tif @@board[x][y] === player\n\t\t\t\t\t\tother_diagonal_counter += 1\n\t\t\t\t\t\tif other_diagonal_counter === 4\n\t\t\t\t\t\t\treturn true\n\t\t\t\t\t\tend\n\t\t\t\t\telse\n\t\t\t\t\t\tother_diagonal_counter = 0\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\tbreak;\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t# the check_wins method has many nested for loops, which is a\n\t\t# runtime complexity of O(n^2)\n\t\treturn false\n\tend",
"def three_in_a_row?(xo_array)\n winning_moves = [[1,2,3], [4,5,6], [7,8,9], [1,4,7], [2,5,8], [3,6,9], [1,5,9], [3,5,7]]\n winning_moves.each do |array|\n if xo_array.sort == array\n return true\n end\n end\n return false\n end",
"def winner_H(board,player) \n for i in 0..5\n check=0\n j=0\n\n while (j < 6)\n if (board[i][j] == player && board[i][j]!=\" \")\n check=check+1\n else\n check=0\n end\n\n if (check== 4) then\n return true\n end\n j=j+1\n end\n end\n\n return false\n end",
"def check_columns\n column_winner = nil\n\n # index in arrays will be representations of board column\n x_arr =[]\n o_arr =[]\n # arrays will be the size of the board default value for each column will be 0\n @board.size.times do\n x_arr << 0\n o_arr << 0\n end\n\n # updates amount in x or o array as a column based on marker = x or o\n @board.each do |row|\n row.each_with_index do |marker, index|\n if marker == 'x'\n x_arr[index] += 1\n # checks if winner to break out of loop\n if x_arr[index] == @board.size\n column_winner = 'x'\n break\n end\n elsif marker == 'o'\n o_arr[index] += 1\n # checks if winner to break out of loop\n if o_arr[index] == @board.size\n column_winner = 'o'\n break\n end\n end\n\n end\n end\n\n column_winner\n end",
"def winner1\n if [$a[1,3], $a[4,3], $a[7,3], [$a[1],$a[4],$a[7]], [$a[2],$a[5],$a[8]], [$a[3],$a[6],$a[9]], [$a[1],$a[5],$a[9]], [$a[3],$a[5],$a[7]]].any? { |e| e==['X','X','X']} \n puts \"Congratulations, player 1 has won!\"\n $w=true\n end\nend",
"def squarocol?(grid)\n return true if grid.any? { |row| row.uniq.length == 1 }\n return true if grid.transpose.any? { |col| col.uniq.length == 1 }\n false\nend",
"def squarocol?(grid)\n return true if grid.any? { |row| row.uniq.length == 1 }\n return true if grid.transpose.any? { |col| col.uniq.length == 1 }\n false\nend",
"def win_diagonal?(mark)\n diag1 = []\n diag2 = []\n @grid.each_with_index do |row, idx|\n diag1 << @grid[idx][idx]\n diag2 << @grid[idx][(idx+1)*-1]\n end\n (diag1.uniq[0] == mark && diag1.uniq.length == 1) || (diag2.uniq[0] == mark && diag2.uniq.length == 1)\n end",
"def winner_col\n for col_index in 0..BOARD_MAX_INDEX\n first_symbol=@board[0][col_index]\n\n for row_index in 1..BOARD_MAX_INDEX\n if first_symbol !=@board[row_index][col_index]\n break\n elsif\n row_index == BOARD_MAX_INDEX and first_symbol !=EMPTY_POS\n return first_symbol\n end\n end\n end\n return \n end",
"def won?(board)\r\n sam_ex = []\r\n sam_oh = []\r\n i = 0\r\n board.each do |index|\r\n if index == \"X\"\r\n sam_ex.push(i)\r\n elsif index == \"O\"\r\n sam_oh.push(i)\r\n end\r\n i+=1\r\n end\r\n WIN_COMBINATIONS.each do |combination|\r\n if combination&sam_oh == combination || combination&sam_ex ==combination\r\n return combination\r\n end\r\n end\r\n nil\r\nend",
"def winner_mark\n check_columns ||\n check_rows ||\n check_left_diagonal ||\n check_right_diagonal\n end",
"def won?(board)\n WIN_COMBINATIONS.each do |win_combo|\n pos_one = win_combo[0]\n pos_two = win_combo[1]\n pos_three = win_combo[2]\n\n if board[pos_one] != \" \" && board[pos_one] == board[pos_two] && board[pos_two] == board[pos_three]\n return win_combo\n end\n end\n false\nend",
"def won?\n if (diagonal_match || across_match || down_match)\n return true\n end\n return false\n end",
"def winner_player1\n if @board.A1 == \"X \" && @board.A2 == \"X \" && @board.A3 == \"X \"\n return true \n elsif @board.B1 == \"X \" && @board.B2 == \"X \" && @board.B3 == \"X \"\n return true\n elsif @board.C1 == \"X \" && @board.C2 == \"X \" && @board.C3 == \"X \"\n return true\n elsif @board.A1 == \"X \" && @board.B1 == \"X \" && @board.C1 == \"X \"\n return true\n elsif @board.A2 == \"X \" && @board.B2 == \"X \" && @board.C2 == \"X \"\n return true\n elsif @board.A3 == \"X \" && @board.B3 == \"X \" && @board.C3 == \"X \"\n return true \n elsif @board.A1 == \"X \" && @board.B2 == \"X \" && @board.C3 == \"X \"\n return true\n elsif @board.A3 == \"X \" && @board.B2 == \"X \" && @board.C1 == \"X \"\n return true \n else\n return false\n end\nend",
"def check_win(player,grid,coordinates)\n win = false\n win_array = []\n play_row = coordinates[0]\n play_col = coordinates[1]\n\n # horizontal checking\n grid[play_row].each_index do | col |\n if win_array.length != 4\n if grid[play_row][col] == player\n win_array.push([play_row,col])\n else\n win_array = []\n end\n end\n end\n\n if win_array.length == 4\n win = true\n end\n\n # vertical checking\n if win == false\n\n win_array = []\n\n grid.each_index do | row |\n if win_array.length != 4\n if grid[row][play_col] == player\n win_array.push([row,play_col])\n else\n win_array = []\n end\n end\n end\n\n if win_array.length == 4\n win = true\n end\n end\n\n # diagonal checking SW to NE\n if win == false\n\n win_array = []\n row = play_row\n col = play_col\n\n # finds SW-most position in same diagonal line as most recently played piece\n # this is the starting point we check from\n until col == 0 || row == 7\n row += 1\n col -= 1\n end\n\n until col > 7 || row < 0\n if win_array.length != 4\n if grid[row][col] == player\n win_array.push([row,col])\n else\n win_array = []\n end\n end\n row -= 1\n col += 1\n end\n\n if win_array.length == 4\n win = true\n end\n end\n\n # diagonal checking NW to SE\n if win == false\n\n win_array = []\n row = play_row\n col = play_col\n\n # finds NW-most position in same diagonal line as most recently played piece\n # this is the starting point we check from\n until col == 0 || row == 0\n row -= 1\n col -= 1\n end\n\n until col > 7 || row > 7\n if win_array.length != 4\n if grid[row][col] == player\n win_array.push([row,col])\n else\n win_array = []\n end\n end\n row += 1\n col += 1\n end\n\n if win_array.length == 4\n win = true\n end\n end\n\n # winning four-in-a-row briefly \"flashes\" to show where it is\n if win == true\n flash_count = 0\n while flash_count < 4\n #flashing animation\n win_array.each do | element |\n grid[element[0]][element[1]] = \"@\"\n end\n print_board(grid)\n sleep(0.2)\n win_array.each do | element |\n grid[element[0]][element[1]] = player\n end\n print_board(grid)\n sleep(0.2)\n flash_count += 1\n end\n end\n\n return win\nend",
"def win_condition_met?(player)\n # Horizontal\n for row in (0..5) do\n counter = 0\n \n @board[row].each do |disc|\n if(disc == player)\n counter += 1\n return true if(counter >= 4)\n else\n counter = 0\n end\n end\n end\n \n # Vertical\n for col in (0..6) do\n counter = 0\n \n for row in (0..5) do\n if(@board[row][col] == player)\n counter += 1\n return true if(counter >= 4)\n else\n counter = 0\n end\n end\n end\n \n # Right diagonal\n starting_points = [[0, 0], [1, 0], [2, 0], [0, 1], [0, 2], [0, 3]]\n starting_points.each do |start|\n counter = 0\n \n row = start[0]\n col = start[1]\n \n while(row < 6 && col < 7)\n if(@board[row][col] == player)\n counter += 1\n return true if(counter >= 4)\n else\n counter = 0\n end\n \n row += 1\n col += 1\n end\n end\n \n # Left diagonal\n starting_points = [[0, 6], [1, 6], [2, 6], [0, 5], [0, 4], [0, 3]]\n starting_points.each do |start|\n counter = 0\n \n row = start[0]\n col = start[1]\n \n while(row < 6 && col >= 0)\n if(@board[row][col] == player)\n counter += 1\n return true if(counter >= 4)\n else\n counter = 0\n end\n \n row += 1\n col -= 1\n end\n end\n \n return false\n end",
"def check_win?(board)\n total_squares = board.length * board[0].length\n completed_squares = 0\n height = board.length\n width = board[0].length\n\n # Loop through each square of the board\n (0...height).each do |row|\n (0...width).each do |column|\n # Increment counter if square matches color\n completed_squares += 1 if board[row][column] == board[0][0]\n end\n end\n\n # Check if all of the squares are the same color\n if total_squares == completed_squares\n return true\n else\n return false\n end\nend",
"def squarocol?(arr)\n vert_test = false\n horz_test = false\n\n arr.each do |sub_arr| # [:x, :y, :x]\n horz_test = sub_arr.all? {|el| el == sub_arr[0]}\n return true if horz_test == true\n end\n\n columns = arr.transpose\n columns.each do |sub_arr| # [:x, :y, :x]\n vert_test = sub_arr.all? {|el| el == sub_arr[0]}\n return true if vert_test == true\n end\n\n false\nend",
"def is_over?(board)\n # if board has more than one row, compare rows\n if board.length > 1\n (0..board.length - 2).each do |element|\n #in case any 2 arrays are not equal, the game is not over\n return false if board[element] != board[element + 1]\n end\n # else compare each element on the single row\n else\n (0..board[0].length - 2).each do |element|\n return false if board[0][element] != board[0][element + 1]\n end\n end\n #all elements are equal therefore the game is over\n return true\nend",
"def diagonal_win?\n (0..3).each do |column|\n (0..2).each do |row|\n return true if down_right_win?(row, column)\n end\n end\n (3..6).each do |column|\n (0..2).each do |row|\n return true if down_left_win?(row, column)\n end\n end\n false\n end",
"def check_row\n @num_row.times do |row|\n consecutive = 0\n curr_tile = @board[row][0]\n @num_col.times do |col|\n if curr_tile == @board[row][col]\n next unless @board[row][col] #skip over empty tiles before the first non-empty\n consecutive += 1\n return true if consecutive == 4\n else\n curr_tile = @board[row][col]\n consecutive = 1\n end\n end\n end\n false\n end",
"def check_diagonals(player_mark)\n left_diag_arr = [@state[0][0], @state[1][1], @state[2][2]]\n right_diag_arr = [@state[0][2], @state[1][1], @state[2][0]]\n return true if count(left_diag_arr, player_mark) == 3\n return true if count(right_diag_arr, player_mark) == 3\n return false\n end",
"def is_winner(x, y, player)\n return true if check_row(x, player)\n return true if check_col(y, player)\n return true if check_diagonals(player)\n return false\n end",
"def check_victory(number)\n\t\t3.times do |i|\n\t\t\tif @board[i][0] == board[i][1] && board[i][1] == board[i][2] && @board[i][0] != 0\n\t\t\t\treturn true\n\t\t\telsif @board[0][i] == board[1][i] && board[1][i] == board[2][i] && @board[0][i] != 0\n\t\t\t\treturn true\n\t\t\tend\n\t\tend\n\t\tif @board[2][0] == board[1][1] && board[1][1] == board[0][2] && @board[0][2] != 0\n\t\t\treturn true\n\t\telsif @board[0][0] == board[1][1] && board[1][1] == board[2][2] && @board[2][2] != 0\n\t\t\treturn true\n\t\telse\n\t\t\treturn false\n\t\tend\n\tend",
"def three_in_a_row(winning_combo, player)\n board_spaces(winning_combo).count(player) == 3\n end",
"def check_row\n \n\tcount = 1\n\t\n\t# Checking to the left.\n\tif @last_insert_x > 1\n\t\n\t i = @last_insert_x - 1\n\t player_symbol = assignment[@last_insert_x - 1][@last_insert_y - 1]\n\t next_symbol = assignment[i - 1][@last_insert_y - 1]\n\t \n\t while (i >= 1) && (count < 4) && (next_symbol == player_symbol)\n\t count += 1\n\t\ti -= 1\n\t\tnext_symbol = assignment[i - 1][@last_insert_y - 1]\n\t end\n\t\n\tend \n\t\n\t# Checking to the right.\n\tif @last_insert_x < width\n\t\n\t i = @last_insert_x + 1\n\t player_symbol = assignment[@last_insert_x - 1][@last_insert_y - 1]\n\t next_symbol = assignment[i - 1][@last_insert_y - 1]\n\t \n\t while (i <= width) && (count < 4) && (next_symbol == player_symbol)\n\t count += 1\n\t\ti += 1\n\t\tnext_symbol = (i < width + 1) ? assignment[i - 1][@last_insert_y - 1] : !player_symbol\n\t end\n\t \n\tend\n\t\n count >= 4\n end",
"def check_win(b)\n\n\t\tboard_columns = b.transpose\n\t\tboard_diagonals = [[b[0][0],b[1][1],b[2][2]],[b[0][2],b[1][1],b[2][0]]]\n\n\t\tcase\n\n\t\twhen b.include?([\"X\",\"X\",\"X\"]) || b.include?([\"O\",\"O\",\"O\"])\n\t\t\treturn true\n\t\twhen board_diagonals.include?([\"X\",\"X\",\"X\"]) || board_diagonals.include?([\"O\",\"O\",\"O\"])\n\t\t\treturn true\n\t\twhen board_columns.include?([\"X\",\"X\",\"X\"]) || board_columns.include?([\"O\",\"O\",\"O\"])\n\t\t\treturn true\n\t\tend\n\n\tend",
"def winner_player2\n if @board.A1 == \"O \" && @board.A2 == \"O \" && @board.A3 == \"O \"\n return true \n elsif @board.B1 == \"O \" && @board.B2 == \"O \" && @board.B3 == \"O \"\n return true\n elsif @board.C1 == \"O \" && @board.C2 == \"O \" && @board.C3 == \"O \"\n return true\n elsif @board.A1 == \"O \" && @board.B1 == \"O \" && @board.C1 == \"O \"\n return true\n elsif @board.A2 == \"O \" && @board.B2 == \"O \" && @board.C2 == \"O \"\n return true\n elsif @board.A3 == \"O \" && @board.B3 == \"O \" && @board.C3 == \"O \"\n return true \n elsif @board.A1 == \"O \" && @board.B2 == \"O \" && @board.C3 == \"O \"\n return true\n elsif @board.A3 == \"O \" && @board.B2 == \"O \" && @board.C1 == \"O \"\n return true \n else\n return false\n end\n end",
"def winner(board)\n WIN_COMBINATIONS.each do |win|\n if [board[win[0]], board[win[1]], board[win[2]]] == [\"X\", \"X\", \"X\"]\n return \"X\"\n elsif [board[win[0]], board[win[1]], board[win[2]]] == [\"O\", \"O\", \"O\"]\n return \"O\"\n end\n end\n return nil\nend",
"def is_winner?(disk)\n\t (0...@rows).each do |row|\n\t (0...@cols).each do |col|\n\t\t result = \n\t\t WIN_CONFIGS_OFFSETS.any? do |offset|\n\t\t positions = offset.map { |pos| [row + pos[0], col + pos[1]] }\n\t\t colors = positions.collect { |pos| ((0...@rows).include?(pos[0]) && (0...@cols).include?(pos[1])) ? @grid[pos[1]][pos[0]] : nil }\n\t\t colors.count(disk) == 4\n\t\t end\n\t\t return true if result\n\t\tend\n\t end\n\t false\n\tend",
"def squarocol?(grid)\n return true if grid.any? { |row| row.uniq.length == 1 }\n return true if grid.transpose.any? { |col| col.uniq.length == 1 }\n false\nend",
"def check_for_winner\n #define what wins the game\n win_combinations = [ [0,3,6], [0,4,8], [0,1,2], [1,4,7], [2,4,6], [2,5,8], [3,4,5], [6,7,8] ]\n #if sym fills any of these combos of 3, that player wins else, game is tie..play again?\n for i in 0..7\n win_combinations.each do |x| \n if (@board[x[0]] == @board[x[1]] && @board[x[0]] == @board[x[2]] && @board[x[0]] != \"\" && @board[x[1]] != \"\" && @board[x[2]] != \"\")\n if @board[x[0]] == PLAYER1_SYM\n puts \"Player 1 Wins!!!!!!\"\n else\n puts \"Player 2 Wins!!!!!!\"\n end\n generate_board\n abort(\"game over\")\n elsif unless @board.include? \"\" #check for tie once board is ful\n abort(\"Game is a tie\")\n end\n else\n end\n end\n end\n end",
"def check_diagnal_win? \n \t\tfirst_diag=@board[2][1]!=0&&@board[1][2]!=0&&(@board[3][0]==@board[2][1]&&@board[3][0]==@board[1][2]&&@board[3][0]==@board[0][3]) #if center is not equal to 0, and \n \t\t#if two center elements from bottom left to top right are not 0 and\n \t\t#bottom left element is equal to center bottom left element and\n \t\t#bottom left element is equal to center top right element and \n \t\t#bottom left element is equal to top right element then first_diag is equal to true, else equal to false\n \t\tsecond_diag=@board[1][1]!=0&&@board[2][2]!=0&&(@board[0][0]==@board[1][1]&&@board[0][0]==@board[2][2]&&@board[0][0]==@board[3][3]) #if center is not equal to 0, and\n \t\t#if two center elements from top left to bottom right are not 0 and \n \t\t#top left element is equal to center top left element and\n \t\t#top left element is equal to center bottom right element and \n \t\t#top left element is equal to bottom right element then second_diag is equal to true, else equal to false\n \t\treturn true if (first_diag||second_diag) #if first_diag is true or second_diag is true, return true. If both are\n \t\t#false, return false.\n \t\treturn false\n \tend",
"def winning_diagonal?(piece)\n diagonals.any? do |diag|\n diag.all?{|cell| cell == piece }\n end\n end",
"def has_connected_four_horizontally(player, board_grid)\n player = player.to_s\n (0...6).each { |r| #row\n (0...4).each { |c| #column\n if (board_grid[r][c] == player and board_grid[r][c+1] == player and board_grid[r][c+2] == player and board_grid[r][c+3] == player)\n return true\n end\n }\n }\n return false\n end",
"def winner?(board, letter)\n # check top across\n if (board[6] == letter and board[7] == letter and board[8] == letter) then return true end\n # check middle across\n if(board[3] == letter and board[4] == letter and board[5] == letter) then return true end\n # check bottom across\n if(board[0] == letter and board[1] == letter and board[2] == letter) then return true end\n # check left side\n if(board[6] == letter and board[3] == letter and board[0] == letter) then return true end\n # check middle\n if(board[7] == letter and board[4] == letter and board[1] == letter) then return true end\n # check right side\n if(board[8] == letter and board[5] == letter and board[2] == letter)then return true end\n # diagnol\n if(board[6] == letter and board[4] == letter and board[2] == letter)then return true end\n # diagnol\n if(board[8] == letter and board[4] == letter and board[0] == letter)then return true end\n false\n end",
"def winning_horizontal?(piece)\n horizontals.any? do |horizontal|\n horizontal.all?{|cell| cell == piece }\n end\n end",
"def check_rows()\n # Returns true if row is filled by player\n 3.times do |x|\n if $game_board[x*3] == $game_board[x*3+1] && $game_board[x*3] == $game_board[x*3+2] && $game_board[x*3]\n return true\n end\n end\n false\nend",
"def combinations(board)\n winner = false\n \n rows(board).each do |row|\n next unless row.all?(X_TOKEN) || row.all?(O_TOKEN)\n \n winner = row\n end\n \n cols(board).each do |col|\n next unless col.all?(X_TOKEN) || col.all?(O_TOKEN)\n \n winner = col\n end\n \n diagonals(board).each do |diag|\n next unless diag.all?(X_TOKEN) || diag.all?(O_TOKEN)\n \n winner = diag\n end\n \n winner\n end",
"def won?(board)\n if board.all? == \" \" || board.all? == nil\n return nil\n else\nWIN_COMBINATIONS.detect do |win|\n board[win[0]] == \"X\" && board[win[1]] == \"X\" && board[win[2]] == \"X\" ||\n board[win[0]] == \"O\" && board[win[1]] == \"O\" && board[win[2]] == \"O\"\n\n end\n end\nend"
] |
[
"0.7630748",
"0.75893897",
"0.75762457",
"0.7372566",
"0.73712337",
"0.7312676",
"0.7307261",
"0.7251087",
"0.72448343",
"0.7225901",
"0.721839",
"0.72162235",
"0.7211894",
"0.7203242",
"0.7182131",
"0.7175452",
"0.7158557",
"0.7152796",
"0.71334827",
"0.71304524",
"0.70951694",
"0.7090996",
"0.70723355",
"0.70571905",
"0.7051942",
"0.7045941",
"0.70311785",
"0.7024814",
"0.70188457",
"0.7008013",
"0.7006949",
"0.699757",
"0.6987018",
"0.69854176",
"0.69778216",
"0.6973832",
"0.694969",
"0.69440275",
"0.6905477",
"0.6891148",
"0.68853325",
"0.6885198",
"0.6867161",
"0.6863023",
"0.68488455",
"0.6848295",
"0.68428254",
"0.68361384",
"0.6830358",
"0.68264294",
"0.68243426",
"0.68183124",
"0.67859346",
"0.67775786",
"0.6771647",
"0.67658854",
"0.67649794",
"0.6759859",
"0.67531586",
"0.6751788",
"0.67415214",
"0.674053",
"0.67401737",
"0.6739082",
"0.6739058",
"0.67299616",
"0.6729757",
"0.6729757",
"0.6724271",
"0.6723681",
"0.67216325",
"0.6717483",
"0.67173016",
"0.67138267",
"0.6712455",
"0.67031467",
"0.66918683",
"0.66875553",
"0.6685912",
"0.6685821",
"0.6685333",
"0.66825664",
"0.6682295",
"0.6679495",
"0.66790354",
"0.6678915",
"0.66768956",
"0.66760015",
"0.6669034",
"0.6663526",
"0.66615427",
"0.6660931",
"0.66594434",
"0.6657717",
"0.665418",
"0.6653469",
"0.6653322",
"0.66528535",
"0.6650583",
"0.664686",
"0.6646204"
] |
0.0
|
-1
|
`index` is expected to respond to `index_name` and `index_type`
|
def call
response = client.mget options
pairs = response["docs"].map { |doc| [doc["_id"], doc["_source"]] }
pairs.to_h
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index_type\n name\n end",
"def construct_index\n end",
"def index_type(env)\n @index_type\n end",
"def index\n set_index\n end",
"def indexes\n raise 'not implemented'\n end",
"def index(name, type = :find)\n @defined_indexes ||= {}\n @defined_indexes[name.to_sym] = type\n end",
"def index(name)\n query\n @options[:index_name] = name.to_s\n self\n end",
"def index\r\n build_index unless @index\r\n @index\r\n end",
"def index_signature; end",
"def index_name\n raise SearchFlip::MethodNotImplemented, \"You must implement #{name}::index_name\"\n end",
"def index; @index; end",
"def add_index_field(*) super end",
"def index(index)\n execute(:index, index)\n end",
"def index ; @index ; end",
"def require_index(name); end",
"def require_index(name); end",
"def [](index_or_name)\n end",
"def [](index_or_name)\n end",
"def index\n @@index ||= Ferret::Index::Index.new(default_index_params)\n end",
"def index\n @@index ||= Ferret::Index::Index.new(default_index_params)\n end",
"def set_index_type(type)\n @index_type = type\n end",
"def index_name=(name)\n @index_name = name\n end",
"def index_name=(name)\n @index_name = name\n end",
"def index_template\n :index\n end",
"def index_template\n :index\n end",
"def elastic_index(options = {})\n \n options.symbolize_keys!\n Escargot.register_model(self)\n \n if respond_to?('single_collection_inherited?') and single_collection_inherited?\n ivars = %w[@index_name @update_index_policy @index_options @indexing_options @mapping @current_schema_version @previous_schema_version]\n ivars.each do |ivar|\n if passed_option = options[ivar[1..-1].to_sym]\n instance_variable_set ivar, passed_option\n else\n instance_variable_set ivar, superclass.instance_variable_get(ivar)\n end\n end\n else\n @index_name = options[:index_name] || self.name.underscore.gsub(/\\//,'-')\n @update_index_policy = options.include?(:updates) ? options[:updates] : :immediate\n \n if @update_index_policy\n after_save :update_index\n after_destroy :delete_from_index\n end\n \n @index_options = options[:index_options] || {}\n @indexing_options = options[:indexing_options] || {}\n @mapping = options[:mapping] || false\n @current_schema_version = options[:current_schema_version] || \"0\"\n @previous_schema_version = options[:previous_schema_version] || \"0\"\n end\n \n end",
"def setup_index\n @index_driver.setup_index\n end",
"def index( index_name, ensure_exists = false )\n \n index_instance = nil\n \n if index_name.nil?\n raise ::ArgumentError, 'Index name required but received nil.'\n end\n \n unless index_instance = indexes[ index_name ]\n if ensure_exists\n raise ::ArgumentError, 'No index found by name ' << index_name.to_s + ' for ' << to_s + '.'\n end\n end\n \n return indexes[ index_name ]\n\n end",
"def [](index_name)\n Index.new(index_name, self)\n end",
"def create_search_index\n Tire.index self.index_name\n end",
"def index\n raise(NotImplementedError, \"You need to define your own index() method\")\n end",
"def index_information\n @db.index_information(@name)\n end",
"def index\n @index ||= self.class.index\n end",
"def index_information\n @db.index_information(@name)\n end",
"def index\n raise NotImplementedError\n end",
"def index()\n @index\n end",
"def create_index\n self[:create_index]\n end",
"def indexed\n meta(index: true)\n end",
"def index_exists?(*args)\n super\n end",
"def index\n raise \"not supported\"\n end",
"def index_name\n @index_name ||= @options[:index_name] ||\n __get_class_value(:index_name) ||\n DEFAULT_INDEX_NAME\n end",
"def index_finalized\n index\n end",
"def index_definition_sql(table_name, index)\n\t raise Error, \"Partial indexes are not supported for this database\" if index[:where]\n\n\t # Basic index creation DDL.\n\t sql = [\"CREATE\"]\n\t case index[:type]\n\t when :bitmap\n\t\t raise Error, \"Bitmap indexes cannot be unique\" if index[:unique]\n\t sql << 'BITMAP'\n\t when NilClass, :normal\n\t sql << 'UNIQUE' if index[:unique]\n\t else\n\t raise Error, \"Index type #{index[:type].inspect} is not supported for this database\"\n\t end\n\t index_name = index[:name] || default_index_name(table_name, index[:columns])\n\t qualified_table_name = quote_schema_table table_name\n\t sql << \"INDEX #{quote_identifier(index_name)} ON #{qualified_table_name}\"\n\t \n\t # Index columns and join indexes.\n index_join, index_columns = *index.values_at(:join,:columns)\n\t sql << literal(index_columns)\n if index_join\n\t\t raise Error, \"Join clauses are only supported for bitmap indexes\" if index[:type]!=:bitmap\n\t\t sql << \"FROM #{qualified_table_name},\"\n\t\t sql << index_columns.map{|k| quote_identifier schema_and_table(k).first }.uniq.join(', ')\n\t\t \n\t\t # TODO: Document this short-hand syntax: {:columns=>[:ref_table__ref_column], :join=>[:fk_column]}\n if Array===index_join and index_join.length==index_columns.length and index_join.all?{|k| Symbol===k}\n index_join = Hash[ index_join.map{|k| :\"#{table_name}__#{k}\" }.zip(index_columns) ]\n end\n\n\t sql << \"WHERE #{filter_expr(index_join)}\"\n\t end\n\t \n\t # Index attributes and options.\n\t sql << 'LOCAL' if index[:partitioned]\n\t sql << flag_option_sql(index, :parallel)\n\t sql << flag_option_sql(index, :logging)\n\t sql << \"TABLESPACE #{quote_identifier(index[:tablespace])}\" if index[:tablespace]\n\t sql << flag_option_sql(index, :visible, 'INVISIBLE')\n\t sql << compress_option_sql(index)\n\t sql << index[:options] if String === index[:options]\n\t sql << 'UNUSABLE' if FalseClass === index[:valid]\n\t sql.compact.join ' '\n\t end",
"def create_index_with(type, index_name)\n db = Neo4j.started_db\n index_config = lucene_config(type)\n if config.entity_type == :node\n db.lucene.for_nodes(index_name, index_config)\n else\n db.lucene.for_relationships(index_name, index_config)\n end\n end",
"def index(index)\n @_chewy_index = index\n end",
"def index_new\n Index.new(self)\n end",
"def setting_index\n end",
"def safe_add_index(*args, **options); end",
"def index_params\n params.require(:index).permit(:index_type, :category)\n end",
"def index_specification(index_hash, index_name = nil)\n index = OpenStruct.new(fields: index_hash.keys, key: index_hash)\n index_specifications.detect do |spec|\n spec == index || (index_name && index_name == spec.name)\n end\n end",
"def check_index_finder\n # Leave it alone\n end",
"def index_component\n if requires_index?\n # If index is a string (EG: \"uniq\"), pass that through\n if attribute.properties[:index].is_a?(String)\n attribute.properties[:index]\n # If no index is specified or a boolean is used, it should just be a regular index\n else\n \"index\"\n end\n end\n end",
"def index?\n INDEXES.include? self.name\n end",
"def index_valid?\n false\n end",
"def [](index)\n method_name = \"#{index.to_s.downcase}\"\n raise KeyError.new(\"Unkown index: #{index}\") unless respond_to? method_name\n send method_name\n end",
"def set_index\n @index = Index.find(params[:id] || params[:index_id])\n end",
"def set_index(index)\n @index = index\n end",
"def indexes(table_name, name = nil)\n opclasses\n result = select_rows(<<-SQL, name)\n SELECT distinct i.relname, d.indisunique, d.indkey, pg_get_indexdef(d.indexrelid), t.oid\n FROM pg_class t\n INNER JOIN pg_index d ON t.oid = d.indrelid\n INNER JOIN pg_class i ON d.indexrelid = i.oid\n WHERE i.relkind = 'i'\n AND d.indisprimary = 'f'\n AND t.relname = '#{table_name}'\n AND i.relnamespace IN (SELECT oid FROM pg_namespace WHERE nspname = ANY (current_schemas(false)) )\n ORDER BY i.relname\n SQL\n result.map do |row|\n index_name = row[0]\n unique = row[1] == 't'\n indkey = row[2].split(\" \")\n inddef = row[3]\n oid = row[4]\n\n columns = Hash[select_rows(<<-SQL, \"Columns for index #{row[0]} on #{table_name}\")]\n SELECT a.attnum::text, a.attname\n FROM pg_attribute a\n WHERE a.attrelid = #{oid}\n AND a.attnum IN (#{indkey.join(\",\")})\n SQL\n column_names = columns.values_at(*indkey).compact\n\n # add info on sort order for columns (only desc order is explicitly specified, asc is the default)\n desc_order_columns = inddef.scan(/(\\w+) DESC/).flatten\n orders = desc_order_columns.any? ? Hash[desc_order_columns.map {|order_column| [order_column, :desc]}] : {}\n #changed from rails 3.2\n where = inddef.scan(/WHERE (.+)$/).flatten[0]\n index_type = inddef.scan(/USING (.+?) /).flatten[0].to_sym\n if index_type\n index_op = inddef.scan(/USING .+? \\(.+? (#{opclasses.join('|')})\\)/).flatten\n index_op = index_op[0].to_sym if index_op.present?\n end\n if column_names.present?\n index_def = IndexDefinition.new(table_name, index_name, unique, column_names, [], orders)\n index_def.where = where\n index_def.index_type = index_type if index_type && index_type != :btree\n index_def.index_opclass = index_op if index_type && index_type != :btree && index_op\n index_def\n # else nil\n end\n #/changed\n end.compact\n end",
"def index_name(event)\n\n index_name, num_docs, write_alias, read_alias = index_status()\n @logger.error(\"status\", :index_name => index_name, :num_docs => num_docs, :write_alias => write_alias, :read_alias => read_alias)\n\n if num_docs == 0\n\n @logger.error(\"index does not exist, create one\", :index_name => index_name)\n\n create_index(index_name)\n\n create_index_aliases(index_name, write_alias, read_alias)\n\n elsif num_docs < @messages_per_slice\n\n @logger.error(\"less than, use the current index\", :index_name => index_name)\n\n else\n\n @logger.error(\"greater than or equal to, create new index and aliases\")\n\n slice = index_name.split('_')[0].to_i\n @logger.error(\"slice\", :slice => slice)\n\n new_index_name = to_index_name(slice += 1, @application, @domain)\n @logger.error(\"index_name\", :new_index_name => new_index_name)\n\n create_index(new_index_name)\n\n update_index_aliases(index_name, new_index_name, write_alias, read_alias)\n end\n\n write_alias\n\n end",
"def supports_index_parsing?\n respond_to?(:indexes)\n end",
"def index(type, options={}, &blk)\n type = to_key(type)\n\n define_method(\"#{type}_index\") do\n indices[type] ||= Index.new(options)\n end\n\n if options[:plural]\n alias_method options[:plural], :\"#{type}_index\"\n end\n\n type_initializers[type] = blk\n\n define_method type do |name, &block_for_index|\n index_get(type, name, &block_for_index)\n end\n end",
"def index_definition_sql(table_name, index)\n index_name = index[:name] || default_index_name(table_name, index[:columns])\n if index[:type]\n raise Error, \"Index types are not supported for this database\"\n elsif index[:where]\n raise Error, \"Partial indexes are not supported for this database\"\n else\n \"CREATE #{'UNIQUE ' if index[:unique]}INDEX #{quote_identifier(index_name)} ON #{quote_identifier(table_name)} #{literal(index[:columns])}\"\n end\n end",
"def index(model)\n model.index\n ElasticMapper.index.refresh\nend",
"def create_index o_class, name:, on: :automatic, type: :unique\n logger.progname = 'RestCreate#CreateIndex'\n begin\n c = classname o_class\n execute transaction: false do\n \t command = if on == :automatic\n \t\t \"CREATE INDEX #{c}.#{name} #{type.to_s.upcase}\"\n \t\telsif on.is_a? Array\n \t\t \"CREATE INDEX #{name} ON #{classname(o_class)}(#{on.join(', ')}) #{type.to_s.upcase}\"\n \t\telse\n \t\t nil\n \t\tend\n \t [{type: \"cmd\", language: 'sql', command: command}]\n end\n logger.info{\"Index on #{c} based on #{name} created.\"}\n rescue RestClient::InternalServerError => e\n response = JSON.parse(e.response)['errors'].pop\n \t error_message = response['content'].split(':').last\n logger.error{\"Index not created.\"}\n logger.error{\"Error-code #{response['code']} --> #{response['content'].split(':').last }\"}\n nil\n end\n end",
"def index_name(version)\n \"#{es_type_name}-v-#{version}\"\n end",
"def create_index(table_name, index_spec)\n @iadmin ||= IndexedTableAdmin.new(@configuration)\n @iadmin.addIndex(table_name.to_java_bytes, index_spec)\nend",
"def verify_index\n setup_index\n raise Exceptions::ElasticsearchError('Index not found') unless index_exists?\n end",
"def index_on( field, opts={} )\n opts = Gnash.new( opts )\n design_document(true).add!( opts.merge!(:name => field) )\n unless indexes.include?( field )\n indexes << field.to_sym \n indexes << field.to_s \n end \n self \n end",
"def index_name(table_name, options) #:nodoc:\n if Hash === options # legacy support\n if options[:column]\n column_names = Array.wrap(options[:column]).map {|c| expression_index_name(c)}\n \"index_#{table_name}_on_#{column_names * '_and_'}\"\n elsif options[:name]\n options[:name]\n else\n raise ArgumentError, \"You must specify the index name\"\n end\n else\n index_name(table_name, column: options)\n end\n end",
"def index_field?(name)\n index_fields.key?(name)\n end",
"def index_definition_sql(table_name, index)\n index_name = index[:name] || default_index_name(table_name, index[:columns])\n if index[:type]\n raise Error, \"Index types are not supported for this database\"\n elsif index[:where]\n raise Error, \"Partial indexes are not supported for this database\"\n else\n \"CREATE #{'UNIQUE ' if index[:unique]}INDEX #{index_name} ON #{quote_identifier(table_name)} #{literal(index[:columns])}\"\n end\n end",
"def index?\n true\n end",
"def index?\n true\n end",
"def index?\n true\n end",
"def index?\n true\n end",
"def index_options options\n defaults = {\n :type => 'string',\n :indexed => true,\n :stored => false,\n :multi_valued => false,\n :required => false,\n :copy_to => nil,\n }\n index_options = {}\n defaults.each_pair do |opt_name,default|\n if options.has_key?(opt_name)\n index_options[opt_name] = options[opt_name]\n else\n index_options[opt_name] = default \n end\n end\n index_options[:type] = index_options[:type].to_s\n index_options\n end",
"def add_indexes\n if hereditary? && !index_options[{ _type: 1 }]\n index({ _type: 1 }, { unique: false, background: true })\n end\n true\n end",
"def index\n @index ||= 1\n end",
"def supports_partial_indexes?\n true\n end",
"def index\n @index\n end",
"def ta_index\n end",
"def <<(index)\n @indexes[index.name] = index\n end",
"def index_name\n get_key('ALGOLIA_INDEX_NAME', 'index_name')\n end",
"def method_missing ( method, *args )\n # Handle all valid *_index/*_key calls:\n return _addIndexes( method, *args ) if VALID_INDEX_HINTS.include? method \n super\n end",
"def index_definition_sql(table_name, index)\n index_name = index[:name] || default_index_name(table_name, index[:columns])\n if index[:type]\n raise Error, \"Index types are not supported for this database\"\n elsif index[:where]\n raise Error, \"Partial indexes are not supported for this database\"\n else\n \"CREATE #{'UNIQUE ' if index[:unique]}INDEX #{quote_identifier(index_name)} ON #{quote_identifier(table_name)} #{literal(index[:columns])}\"\n end\n end",
"def update_index # :nodoc:\n self.class.indexer.index(self)\n end",
"def index?\n true\n end",
"def index *args\n # delegate\n self.class.names.index *args\n end",
"def index\n self.class.all.index(self)\n end",
"def index\n set_index_options\n load_index if params[:reload].to_s.to_boolean(true)\n end",
"def index\n set_index_options\n load_index if params[:reload].to_s.to_boolean(true)\n end",
"def index_name\n @element[:name] || @element[:column]\n end",
"def set_index\n @index = Index.find(params[:id])\n end",
"def set_index\n @index = Index.find(params[:id])\n end",
"def index_by_name(table_name, index_name)\n index_record = data_dictionary.index_by_name(table_name, index_name)\n\n index_space = space(index_record[\"SPACE\"])\n describer = data_dictionary.record_describer_by_index_name(table_name, index_name)\n index_space.index(index_record[\"PAGE_NO\"], describer)\n end",
"def create_index(index)\n\n parsed = @http.put(\"http://#{@host}:#{@port}/#{index}\")\n ok = parsed[\"ok\"]\n @logger.error(\"parsed???\", :parsed => parsed)\n\n @logger.error(\"create_index ok\", :ok => ok, :index => index)\n\n @http.get(\"http://#{@host}:#{@port}/_flush\")\n\n end",
"def index\n Index.new(self)\n end",
"def default_index_type?(index) # :nodoc:\n index.using == :btree || super\n end",
"def create_index(args)\n if args[:name]\n new_index = create_new_index(args)\n\n @conn.query({url_path: \"#{database}/_index\", opts: new_index, method: :post})\n else\n raise ArgumentError.new('name is required')\n end\n end",
"def test_indexes\n idx_name = \"accounts_idx\"\n\n indexes = @connection.indexes(\"accounts\")\n assert_empty indexes\n\n @connection.add_index :accounts, :firm_id, name: idx_name\n indexes = @connection.indexes(\"accounts\")\n assert_equal \"accounts\", indexes.first.table\n assert_equal idx_name, indexes.first.name\n assert !indexes.first.unique\n assert_equal [\"firm_id\"], indexes.first.columns\n ensure\n @connection.remove_index(:accounts, name: idx_name) rescue nil\n end",
"def test_indexes\n idx_name = \"accounts_idx\"\n\n indexes = @connection.indexes(\"accounts\")\n assert_empty indexes\n\n @connection.add_index :accounts, :firm_id, name: idx_name\n indexes = @connection.indexes(\"accounts\")\n assert_equal \"accounts\", indexes.first.table\n assert_equal idx_name, indexes.first.name\n assert !indexes.first.unique\n assert_equal [\"firm_id\"], indexes.first.columns\n ensure\n @connection.remove_index(:accounts, name: idx_name) rescue nil\n end"
] |
[
"0.8215665",
"0.7866423",
"0.770663",
"0.7693401",
"0.7592965",
"0.75419486",
"0.7472974",
"0.7468542",
"0.744928",
"0.7423644",
"0.74081415",
"0.7379237",
"0.7373606",
"0.73323494",
"0.7313775",
"0.7313775",
"0.73129433",
"0.73129433",
"0.7292974",
"0.7292974",
"0.72646356",
"0.72558665",
"0.72558665",
"0.7247407",
"0.7247407",
"0.72159624",
"0.7211455",
"0.71991825",
"0.71981174",
"0.71768636",
"0.71747446",
"0.7173938",
"0.71737045",
"0.71454585",
"0.70850456",
"0.7082731",
"0.7074364",
"0.70693433",
"0.70680475",
"0.70576763",
"0.7047841",
"0.70414037",
"0.70011437",
"0.6986203",
"0.69751626",
"0.69604224",
"0.6959427",
"0.69124925",
"0.6909179",
"0.6895314",
"0.6883956",
"0.68664134",
"0.68364376",
"0.68306196",
"0.68167436",
"0.68128616",
"0.68091923",
"0.6797222",
"0.67907643",
"0.6782997",
"0.67811495",
"0.6772662",
"0.67712957",
"0.6767415",
"0.67667615",
"0.6762232",
"0.67512125",
"0.6736491",
"0.67355084",
"0.67317486",
"0.6730874",
"0.6726571",
"0.6726571",
"0.6726571",
"0.6726571",
"0.671525",
"0.67095286",
"0.6707871",
"0.6707272",
"0.6706157",
"0.6703154",
"0.67015517",
"0.66969573",
"0.6686772",
"0.6685503",
"0.6680908",
"0.6671233",
"0.6663785",
"0.66599715",
"0.6653735",
"0.6653735",
"0.66454625",
"0.6642132",
"0.6642132",
"0.6637374",
"0.663661",
"0.6627677",
"0.66175467",
"0.6610665",
"0.6605724",
"0.6605724"
] |
0.0
|
-1
|
Use callbacks to share common setup or constraints between actions.
|
def set_partner
@partner = Partner.find_by(osra_id: params[:partner_id])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def define_action_helpers?; end",
"def set_actions\n actions :all\n end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def setup_handler\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def workflow\n end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup\n # override and do something appropriate\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def before_action \n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def setup_signals; end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def initialize(*args)\n super\n @action = :set\nend",
"def after_set_callback; end",
"def setup\n #implement in subclass;\n end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def around_hooks; end",
"def save_action; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def default_action; end",
"def setup(&blk)\n @setup_block = blk\n end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def duas1(action)\n action.call\n action.call\nend",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend"
] |
[
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576",
"0.53124547",
"0.529654",
"0.5296262",
"0.52952296",
"0.52600986",
"0.52442724",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.5232394",
"0.523231",
"0.5227454",
"0.52226824",
"0.52201617",
"0.5212327",
"0.52079266",
"0.52050185",
"0.51754695",
"0.51726824",
"0.51710224",
"0.5166172",
"0.5159343",
"0.51578903",
"0.51522785",
"0.5152022",
"0.51518047",
"0.51456624",
"0.51398855",
"0.5133759",
"0.5112076",
"0.5111866",
"0.5111866",
"0.5110294",
"0.5106169",
"0.509231",
"0.50873137",
"0.5081088",
"0.508059",
"0.50677156",
"0.50562143",
"0.5050554",
"0.50474834",
"0.50474834",
"0.5036181",
"0.5026331",
"0.5022976",
"0.5015441",
"0.50121695",
"0.5000944",
"0.5000019",
"0.4996878",
"0.4989888",
"0.4989888",
"0.49864885",
"0.49797225",
"0.49785787",
"0.4976161",
"0.49683493",
"0.4965126",
"0.4958034",
"0.49559742",
"0.4954353",
"0.49535993",
"0.4952725",
"0.49467874",
"0.49423352",
"0.49325448",
"0.49282882",
"0.49269363",
"0.49269104",
"0.49252945",
"0.4923091",
"0.49194667",
"0.49174926",
"0.49173003",
"0.49171105",
"0.4915879",
"0.49155936"
] |
0.0
|
-1
|
Only allow a trusted parameter "white list" through.
|
def product_params
params.require(:product).permit(:code, :name, :product_brand_id, :product_cost, :cargo_cost, :total_cost, :units_sale_allowed, :is_mix_box,
{prices_attributes: [:id, :customer_category_id, :company_profit_percent, :seller_profit_percent, :total_profit_percent, :seller_commission_over_price_percent, :price]},
{product_boxes_attributes: [:_destroy, :id, :box_id, :stock_min, :stock_max]},
{mix_box_details_attributes: [:_destroy, :id, :product_id, :quantity]},
{box_ids: []})
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def filtered_parameters; end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def valid_params?; end",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def filter_parameters; end",
"def filter_parameters; end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def check_params; true; end",
"def valid_params_request?; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def list_params\n params.permit(:name)\n end",
"def check_params\n true\n end",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def additional_permitted_params\n []\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def resource_params\n params[resource_singular_name].try(:permit, self.class.param_whitelist)\n end",
"def allow_params_authentication!; end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def param_params\n params.require(:param).permit(:param_category_id, :param_table_id, :name, :english_name, :weighting, :description)\n end",
"def quote_params\n params.permit!\n end",
"def list_params\n params.permit(:list_name)\n end",
"def allowed_params(parameters)\n parameters.select do |name, values|\n values.location != \"path\"\n end\n end",
"def all_params; end",
"def permitted_resource_params\n params[resource.object_name].present? ? params.require(resource.object_name).permit! : ActionController::Parameters.new\n end",
"def source_params\n params.require(:source).permit(all_allowed_params)\n end",
"def user_params\n end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def get_allowed_parameters\n return _get_specific_action_config(:allowed_action_parameters, :allowed_parameters)&.map(&:to_s)\n end",
"def permitted_params\n @wfd_edit_parameters\n end",
"def user_params\r\n end",
"def param_whitelist\n whitelist = [\n :comment,\n :old_progress, :new_progress,\n :metric_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:metric_id)\n end\n \n whitelist\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def get_params\n\t\t\n\t\treturn ActionController::Parameters.new(self.attributes).permit(:first_name, :last_name, :email, :provider)\n\n\tend",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def valid_parameters\n sort_symbols(@interface.allowed_parameters)\n end",
"def params_permit\n params.permit(:id)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def filter_params\n params.permit(*resource_filter_permitted_params)\n end",
"def community_params\n params.permit(:profile_image, :name, :description, :privacy_type, :viewed_by, {tags: []}, {features: []}, {admins: []}, :members, :location, :beacon, :creator, :ambassadors, :current_events, :past_events, :feed, :category, :address, :allow_member_post_to_feed, :allow_member_post_to_events)\n end",
"def specialty_params\n\t\tparams.require(:specialty).permit(*Specialty::DEFAULT_ACCESSIBLE_ATTRIBUTES)\n\tend",
"def authorize_params\n super.tap do |params|\n %w[display scope auth_type].each do |v|\n if request.params[v]\n params[v.to_sym] = request.params[v]\n end\n end\n end\n end",
"def feature_params_filter\n params.require(:feature).permit(:name, :cat, :lower, :upper, :opts, :category, :description, :company, :active, :unit, :icon)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def argument_params\n params.require(:argument).permit(:name)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def property_params\n params.permit(:name, :is_available, :is_approved, :owner_id)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def sponsor_params\n params.require(:sponsor).permit(WHITE_LIST)\n end",
"def whitelist_person_params\n params.require(:person).permit(:family, :pre_title, :given_name, :dates, :post_title, :epithet, :dates_of_office, same_as: [], related_authority: [], altlabel: [], note: []) # Note - arrays need to go at the end or an error occurs!\n end",
"def parameters\n nil\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def sequence_param_whitelist\n default_param_whitelist << \"show_index\"\n end",
"def resource_filter_permitted_params\n raise(NotImplementedError, 'resource_filter_permitted_params method not implemented')\n end",
"def normal_params\n reject{|param, val| param_definitions[param][:internal] }\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def special_device_list_params\n params.require(:special_device_list).permit(:name)\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end"
] |
[
"0.7121987",
"0.70541996",
"0.69483954",
"0.6902367",
"0.6733912",
"0.6717838",
"0.6687021",
"0.6676254",
"0.66612333",
"0.6555296",
"0.6527056",
"0.6456324",
"0.6450841",
"0.6450127",
"0.6447226",
"0.6434961",
"0.64121825",
"0.64121825",
"0.63913447",
"0.63804525",
"0.63804525",
"0.6373396",
"0.6360051",
"0.6355191",
"0.62856233",
"0.627813",
"0.62451434",
"0.6228103",
"0.6224965",
"0.6222941",
"0.6210244",
"0.62077755",
"0.61762565",
"0.61711127",
"0.6168448",
"0.6160164",
"0.61446255",
"0.6134175",
"0.6120522",
"0.6106709",
"0.60981655",
"0.6076113",
"0.60534036",
"0.60410434",
"0.6034582",
"0.6029977",
"0.6019861",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.60184896",
"0.60157263",
"0.6005857",
"0.6003803",
"0.60012573",
"0.59955895",
"0.5994598",
"0.5993604",
"0.5983824",
"0.5983166",
"0.5977431",
"0.597591",
"0.5968824",
"0.5965953",
"0.59647584",
"0.59647584",
"0.59566855",
"0.59506303",
"0.5950375",
"0.59485626",
"0.59440875",
"0.5930872",
"0.5930206",
"0.5925668",
"0.59235454",
"0.5917905",
"0.59164816",
"0.5913821",
"0.59128743",
"0.5906617",
"0.59053683",
"0.59052664",
"0.5901591",
"0.58987755",
"0.5897456",
"0.58970183",
"0.58942604"
] |
0.0
|
-1
|
Make department requirement junction when new requirement is made. Also serves as a Model.within(dept), minus foreign key injection
|
def core(d)
dept = Department.search!(d)
raise "[Requirement.core] Error: core already declared for department #{dept.name}" unless dept.core_requirements.empty?
requirement = make "#{dept.abbreviation}"
# make junctions
mk = self.method(:make)
self.define_singleton_method(:make) do |*args|
req = mk.call(*args)
Departments_Requirement.create(department_id: dept.id, requirement_id: req.id)
req
end
@within_model = dept
yield
@within_model = nil
self.define_singleton_method :make, mk
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def department_set(dept)\n self.department.set dept\n end",
"def setup_departments\n Department.delete_all \n Employee.delete_all\n dep = Department.create(:name=> 'department1', :city => 'Littleton', :state => 'CO') \n employee1 = dep.employees.create(:first_name=>\"first_1\", :last_name =>\"last_1\", :job_id => 12) \n employee2 = dep.employees.create(:first_name=>\"first_2\", :last_name =>\"last_2\", :job_id => 12) \n employee3 = dep.employees.create(:first_name=>\"first_3\", :last_name =>\"last_3\", :job_id => 12) \n employee3.manager = employee1\n \n departments = {:department1 => dep,\n :department2 => Department.create(:name=> 'department2', :city => 'Littleton', :state => 'CO') ,\n :department3 => Department.create(:name=> 'department3', :city => 'Littleton', :state => 'CO') \n }\n departments\n end",
"def for_department(department_name); end",
"def create_dependancies\n create_course_plan()\n end",
"def department; end",
"def department; end",
"def department; end",
"def set_department\n if action_name == 'new'\n @department = Department.new\n elsif action_name == 'create'\n @department = Department.new(department_params)\n else\n @department = Department.find(params[:id])\n end\n @department.permissions.build unless @department.permissions.present?\n end",
"def check_department\n if self.department_id.nil?\n self.department = Department.find_by_name(\"Management\")\n end\n end",
"def department=(new_department) \n\n @department.users.delete(self) \n\n @department = new_department \n\n @department.users << self \n\n end",
"def create\n @departments = Department.all\n\n if (params[:department][:parent_department_id].blank?)\n params[:department][:parent_department_id] = 0\n end\n\n @department = Department.create(department_params)\n end",
"def department\n self\n end",
"def set_departments\n @dptos=Department.where(enterprise_id: current_emp.id)\n end",
"def set_department\n @department = current_company.departments.find(params[:id])\n end",
"def dept_abbrev=(dept_abbrev)\n self.department = Department.find_or_create_by_abbrev(dept_abbrev)\n end",
"def set_department\n @department = @company.departments.find(params[:id])\n end",
"def add_dependency(job)\n Jobs::DependentJob.transaction { \n # d =Jobs::DependentJobDependency.create(:job=>self, :prereq=>job)\n self.dependencies << job\n self.save!\n }\n end",
"def set_department\n @department = current_ou.departments.find(params[:id])\n end",
"def set_department\n @department = Department.find(params[:id])\n end",
"def set_department\n @department = Department.find(params[:id])\n end",
"def set_department\n @department = Department.find(params[:id])\n end",
"def set_department\n @department = Department.find(params[:id])\n end",
"def set_department\n @department = Department.find(params[:id])\n end",
"def set_department\n @department = Department.find(params[:id])\n end",
"def set_department\r\n @department = Department.find(params[:id])\r\n end",
"def adding_plan_relation(transaction, parent, child, relations, info); end",
"def add_dependent obj\n $log.debug \" ADDING DEPENDE #{obj}\"\n @dependents ||= []\n @dependents << obj\n end",
"def add_dependency_condition(dc_obj)\n dc_obj.dependency_id = self.id\n self.dependency_conditions << dc_obj\n end",
"def create_department\n @department = @company.departments.create(name: params[:department][:name],division_id: params[:division_id])\n \trespond_to do |format|\n format.json { render json: @department }\n end\n end",
"def create\n \n \n @dept = current_user.depts.new(params[:dept])\n \n respond_to do |format|\n if @dept.save\n format.html { redirect_to @dept, :notice => 'Dept was successfully created.' }\n format.json { render :json => @dept, :status => :created, :location => @dept }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @dept.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @sub_department.update(sub_department_params)\n @sub_departments = SubDepartment.all\n @sub_department = SubDepartment.new\n end",
"def create\n authorize_action_for Department, at: current_store\n @department = current_store.departments.build(department_params.merge(priority: current_store.departments.count))\n\n respond_to do |format|\n if @department.save\n track @department\n format.html { redirect_to edit_admin_department_path(@department),\n notice: t('.notice', department: @department) }\n format.json { render :show, status: :created, location: admin_department_path(@department) }\n else\n format.html { render :new }\n format.json { render json: @department.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_department\n @department = Department.friendly.find(params[:id])\n end",
"def set_department\n @department = Department.friendly.find(params[:id])\n end",
"def department_params\n params.require(:department).permit(:uid, :name, :worktype_id, :upper_id, :is_stoped, :memo)\n end",
"def belongs_to(goal, options = { })\n self.foreign_keys[goal.foreign_key] = \"references\"\n self.validates(:presence_of, goal.foreign_key)\n self.associate(:belongs_to, goal, options)\n end",
"def set_department\n @department = Department.find(params[:id])\n end",
"def set_department\n @department = Department.find(params[:id])\n end",
"def set_department\n @department = Department.find(params[:id])\n end",
"def set_department\n @department = Department.find(params[:id])\n end",
"def set_department\n @department = Department.find(params[:id])\n end",
"def set_department\n @department = Department.find(params[:id])\n end",
"def set_department\n @department = Department.find(params[:id])\n end",
"def create\n @department = Department.new(department_params.merge(code: \"D#{((sprintf '%03d', ((MClass.where(\"parent_id IS NULL\").order(\"id DESC\").limit(1).last.code.gsub('D', '').to_i rescue 0)+1)))}\"), level: 0)\n if @department.save\n flash[:notice] = 'Department was successfully created'\n redirect_to departments_path\n else\n flash[:error] = @department.errors.full_messages.join(',')\n render \"new\"\n end\n end",
"def department\n ::HubEdos::Common::Reference::Descriptor.new(@data['department']) if @data['department']\n end",
"def setup\n @main_path = departments_path\n @new_path = new_department_path\n @edit_path = lambda { |record| edit_department_path(record) }\n @destroy_path = lambda { |record| department_path(record) }\n @model = Department\n end",
"def adopt_fund_tier_assignment\n return true if fund_tier_assignment || ( self.fund_tier_assignment =\n fund_source.fund_tier_assignments.\n where( organization_id: organization_id ).first ) ||\n fund_source.fund_tiers.empty?\n create_fund_tier_assignment do |assignment|\n assignment.fund_source = fund_source\n assignment.organization = organization\n assignment.fund_tier = fund_source.fund_tiers.first\n end\n end",
"def creat_discipline(json)\n # Create Discipline\n discipline = Discipline.new(:name => json[\"disciplin\"], :year => \"1.1.2013\")\n # save query in vars for Discipline joins\n sp = Sport.find_by_name(json[\"disc_group\"])\n cat = Category.find_by_name(json[\"category\"])\n ge = Gender.find_by_sex(json[\"gender\"])\n # when no unit set\n if json[\"req_unit\"].nil?\n un = Unit.find_by_name(\"bestanden\")\n else\n un = Unit.find_by_name(json[\"req_unit\"])\n end\n # joins Diciplines\n sp.disciplines << discipline\n cat.disciplines << discipline\n un.disciplines << discipline\n ge.disciplines << discipline\n # save Discipline\n discipline.save\nend",
"def create_department\n \t\t@department = Department.new(department_params)\n \t\t@department.facility_id = current_user.facility_id\n\t \trespond_to do |format|\n if @department.save\n format.html { redirect_to settings_path, notice: 'Department successfully created'}\n format.json { redirect_to settings_path, notice: 'Department successfully created'}\n else\n format.html {redirect_to settings_path, notice: 'Failed to create department'}\n format.json { render json: @department.errors, status: :unprocessable_entity}\n end\n\t end\n end",
"def set_user_pd_eligible(teacher)\n teacher.cohorts << Cohort.find_or_create_by('CSD-TeacherConHouston')\nend",
"def create\n @undergraduateprogram = UndergraduateProgram.create(params[:undergraduateprogram])\n @ugd=@undergraduateprogram.undergrad_departments.new(params[:undergraddepartment])\n @ugd.save\n #@undergraduatedeparment= @undergraduateprogram. undergrad_departments.build(params[:undergraddepartment])\n #@showugd = @undergraduateprogram.undergrad_departments\n \n if @undergraduateprogram.save\n \n \n #Rails.logger.info(\"----testttttttt--------\"+ @undergraduateprogram => params[:undergraduateprogram])\n #flash[:notice] = \"successfully saved\"\n #render :action => \"new\"\n #@showugd = @undergraduateprogram.undergrad_departments\n redirect_to :action => \"show\", :id => @undergraduateprogram.id\n #redirect_to :action =>\"show\", :undergraduateprogram => @undergraduateprogram\n else\n flash[:notice] = \"error saving the data\"\n render :action => \"new\"\n end\n \n end",
"def overridden_by_department?(cop); end",
"def create\n sp = speciality_params\n has_department = true\n has_department = !(!params[:speciality][:department_id].nil? && Department.where(\"id=?\",params[:speciality][:department_id]).empty?)\n # debugger\n if !has_department\n format.html { render :edit }\n else\n sp[:department] = Department.find(params[:speciality][:department_id])\n end\n @speciality = Speciality.new(sp)\n\n respond_to do |format|\n if @speciality.save\n format.html { redirect_to @speciality, notice: 'Department was successfully created.' }\n format.json { render :show, status: :created, location: @department }\n else\n format.html { render :new }\n format.json { render json: @speciality.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @discipline = Discipline.new(discipline_params)\n respond_to do |format|\n if @discipline.save\n format.html { redirect_to management_disciplines_path }\n format.json { render :json => @discipline.to_json(include: :department), status: :created }\n else\n format.html { render :new }\n format.json { render json: @discipline.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_department\n @department = current_user.userable.department\n end",
"def set_department\n @department = current_store.departments.friendly.find(params[:id])\n end",
"def achieve(ctx)\n relation.solver_for(actuals, ctx)\n end",
"def create\n access(:create)\n checked_params = check_params(DEPARTMENT_PROPERTIES)\n @department = Department.new(checked_params)\n respond_to do |format|\n if @department.save\n format.html { redirect_to departments_path}\n format.json { render :show, status: :created, location: departments_path }\n else\n format.html { render :new }\n format.json { render json: @department.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_sub_department\n @sub_department = SubDepartment.find(params[:id])\n end",
"def add_to_basis_or_remove_constraint(jk, j0)\n if can_add_to_basis?(j0)\n remove_artificial_variable(jk, j0)\n else\n process_linear_dependent(jk)\n end\n end",
"def add_parent_to_org_unit(parent_ou_id, child_ou_id)\n # Must follow structure of data\n # (course <-- semester <== org -->custom dept--> dept -->templates--> courses)\n # Refer to valence documentation for further structural understanding..\n path = \"/d2l/api/lp/#{$lp_ver}/orgstructure/#{child_ou_id}/parents/\"\n _post(path, parent_ou_id)\nend",
"def showdep\n @departments ||= EmployeeDepartment.all\n authorize! :create, Event\n end",
"def create\n # @department = Department.new(params[:department])\n #\n # respond_to do |format|\n # if @department.save\n # format.html { redirect_to @department, notice: 'Department was successfully created.' }\n # format.json { render json: @department, status: :created, location: @department }\n # else\n # format.html { render action: \"new\" }\n # format.json { render json: @department.errors, status: :unprocessable_entity }\n # end\n # end\n\n @department = @project.departments.build\n @department.safe_attributes = params[:department]\n if @department.save\n flash[:notice] = l(:notice_successful_create)\n redirect_to_settings_in_projects\n else\n render :action => 'new'\n end\n end",
"def propagate_course\n lesson_plan_item.course = tab.category.course\n end",
"def propagate_course\n lesson_plan_item.course = tab.category.course\n end",
"def departments\n @departments ||= DepartmentProxy.new(self)\n end",
"def department_params\n params.require(:department).permit(:department_title, :parent_department_id, :is_open, :notes)\n end",
"def create\n @dept = Dept.new(dept_params)\n\n if @dept.save\n render json: @dept, status: :created, location: @dept\n else\n render json: @dept.errors, status: :unprocessable_entity\n end\n end",
"def setup_concept_edge_stage_from submission, concept_stage, concept_edges\n concept_edges.each do |concept_edge|\n concept_edge_option = concept_edge.concept_edge_option\n if !concept_edge_option.nil? and concept_edge_option.enabled\n concept_edge_stage = concept_stage.concept_edge_stages.new\n concept_edge_stage.concept_edge_id = concept_edge.id\n concept_edge_stage.save\n\n concept_edge_stage.check_to_unlock submission\n end\n end\n end",
"def add_subject_died_operational_event\n\t\tif( ( vital_status_changed? ) &&\n\t\t\t\t( vital_status == 'Deceased' ) && \n\t\t\t\t( vital_status_was != 'Deceased' ) )\t\n\t\t\t#\n\t\t\t#\tIf it changed and is now Deceased, obviously it wasn't Deceased. \n\t\t\t#\tCould remove that check.\n\t\t\t#\n\t\t\tself.operational_events.create!(\n\t\t\t\t:project_id => Project['ccls'].id,\n\t\t\t\t:operational_event_type_id => OperationalEventType['subjectDied'].id,\n\t\t\t\t:occurred_at => DateTime.current\n\t\t\t)\n\t\tend\n\tend",
"def update\n @departments = Department.all.order(:department_title)\n @department = Department.find(params[:id])\n\n if (params[:department][:parent_department_id].blank?)\n params[:department][:parent_department_id] = 0\n end\n\n @department.update_attributes(department_params)\n end",
"def create_checklist\n self.checklist.each_check do |check|\n DesignCheck.add(self, check) if check.belongs_to?(self.design)\n end\n end",
"def create\n @department = Department.new(department_params)\n\n respond_to do |format|\n if @department.save\n @departmentSite = Cms::Site.new\n #Removes all url-unfriendly characters from the name to create an identifier Comfy can use.\n @ident = @department.name.gsub(/[^a-zA-Z 0-9]/, \"\")\n @ident = @ident.gsub(/\\s/,'_')\n @departmentSite.update_attributes(\n #binds Department sites to easy-to-remember mnemonics.\n identifier: \"#{@ident.downcase}\",\n\n #pulls the hostname for the parent site\n hostname: '0.0.0.0:3000',\n\n #sets the root path for the new site to /Departments. There is no actual /Departments route handled by Comfy, but it provides an easy mnemonic\n #GET \"/departments\" should be mapped to a static page that links to all sites created in this manner.\n path: \"departments/#{@ident.downcase}\"\n )\n @departmentSite.save!\n @department.update_attributes(cms_site_id: @departmentSite.id)\n format.html { redirect_to \"/departments\", notice: 'Department was successfully created.' }\n format.json { render json: @department, status: :created, location: @department }\n else\n format.html { render action: \"new\" }\n format.json { render json: @department.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_facility\n return unless account.per_facility? && facility&.id\n account.account_facility_joins.build(facility: facility)\n account\n end",
"def build_callback_to_dependee_model\n last_association_chain = @quickery_builder.association_chains.last\n last_association_chain.model.quickery_association_chain_dependees ||= []\n last_association_chain.model.quickery_association_chain_dependees << last_association_chain\n end",
"def new_requirement_attributes=(attributes)\n requirement = Requirement.find_or_create_by(attributes)\n self.requirements << requirement if requirement.valid? || !self.requirements\n end",
"def department\n @_department ||= ActiveRecord::Department.\n where(name: self.value).first!\n end",
"def set_department_entry\n @department_entry = DepartmentEntry.find(params[:id])\n end",
"def set_funding_requirement\n @funding_requirement = FundingRequirement.find(params[:id])\n end",
"def set_requirement\n @requirement = Requirement.find(params[:id])\n end",
"def set_requirement\n @requirement = Requirement.find(params[:id])\n end",
"def approve_setup_fee_collection( current_user )\n self.is_setup_fee_collection_approved = true \n self.setup_fee_collection_approver_id = current_user.id \n self.save\n \n # create all those payment payable : loan disbursement \n end",
"def create\n @request = Request.new(request_params)\n @request.user_id = current_user.id\n user=User.find(@request.user_id)\n @request.department=user.department\n respond_to do |format|\n if @request.save\n format.html { redirect_to @request, notice: 'Request was successfully created.' }\n format.json { render :show, status: :created, location: @request }\n else\n format.html { render :new }\n format.json { render json: @request.errors, status: :unprocessable_entity }\n end\n end\n end",
"def join_dependency\n jd = ::ActiveRecord::Associations::ClassMethods::JoinDependency\n @join_dependency ||= jd.new model,\n @conditions.to_find_include,\n nil\n end",
"def new\n @department = @project.departments.build\n @department.safe_attributes = params[:department]\n end",
"def dependency=(dep)\n unless dep.nil?\n dep.question_id = self.id\n end\n @dependency = dep\n end",
"def purchase_sub_existing_edu #much copied from static#students , but much not needed #in case use customer registers but then comes back later to finish purchasing\n @event = Event.find(ENV['demopage'].to_i)\n @commencement_plan = Plan.find_by_my_plan_id(plan_set_commencement) # sets @first_plan the first plan object ACCORDING TO MY LEGEND (with my_plan_id)\n @students_plan = Plan.find_by_my_plan_id(plan_set_students)\n @all_inclusive_plan = Plan.find_by_my_plan_id(plan_set_all_inclusive)\n @practiceobject = Practiceobject.new \n @practiceobject.event_id = @event.id #for the form_for(@practiceobject) which creatse a new practice object (and another form which just shows the labels - can find a better way for that)\n @registeredandrecordedpos = @event.practiceobjects.registered.recorded.visible\n @registeredandunrecordedpos = @event.practiceobjects.registered.unrecorded.visible\n @unregisteredpos = @event.practiceobjects.unregistered.visible\n @hiddenpos = @event.practiceobjects.hidden\n @hiddenandregisteredpos = @hiddenpos.registered\n @hiddenandunregisteredpos = @hiddenpos.unregistered \n\n @url = demo_record_directory_url(:event_code => @event.event_code)\nend",
"def set_appraisal_participate_department\n @appraisal_participate_department = AppraisalParticipateDepartment.find(params[:id])\n end",
"def create\r\n if !current_admin.super_user?\r\n flash[:error] = \"You dont have permissions to view this page\"\r\n redirect_to admin_departments_path and return\r\n end\r\n @department = Department.new(params[:department])\r\n\r\n respond_to do |format|\r\n if @department.save\r\n Log.add(current_admin, @department, params)\r\n if params[:permissions].is_a? Array\r\n params[:permissions].each do |d|\r\n DepartmentPermission.find_or_create_by_department_id_and_permission_id(@department.id,d.to_i)\r\n end\r\n end\r\n format.html { redirect_to([:admin, @department], :notice => 'Department was successfully created.') }\r\n format.xml { render :xml => @department, :status => :created, :location => @department }\r\n else\r\n format.html { render :action => \"new\" }\r\n format.xml { render :xml => @department.errors, :status => :unprocessable_entity }\r\n end\r\n end\r\n end",
"def add_constraints(scope)\n tables = construct_tables\n \n chain.each_with_index do |reflection, i|\n table, foreign_table = tables.shift, tables.first\n \n if reflection.source_macro == :has_and_belongs_to_many\n join_table = tables.shift\n \n scope = scope.joins(join(\n join_table,\n table[association_primary_key].\n eq(join_table[association_foreign_key])\n ))\n \n table, foreign_table = join_table, tables.first\n end\n \n if reflection.source_macro == :belongs_to\n if reflection.options[:polymorphic]\n key = reflection.association_primary_key(self.klass)\n else\n key = reflection.association_primary_key\n end\n \n foreign_key = reflection.foreign_key\n else\n key = reflection.foreign_key\n foreign_key = reflection.active_record_primary_key\n end\n \n # this is our addition\n table, key = maybe_split(table, key, reflection)\n foreign_table, foreign_key = maybe_split(foreign_table, foreign_key, reflection)\n # end\n \n if reflection == chain.last \n bind_val = bind scope, table.table_name, key.to_s, owner[foreign_key]\n scope = scope.where(table[key].eq(bind_val))\n \n if reflection.type\n value = owner.class.base_class.name\n bind_val = bind scope, table.table_name, reflection.type.to_s, value\n scope = scope.where(table[reflection.type].eq(bind_val))\n end\n else\n constraint = table[key].eq(foreign_table[foreign_key])\n \n if reflection.type\n type = chain[i + 1].klass.base_class.name\n constraint = constraint.and(table[reflection.type].eq(type))\n end\n \n scope = scope.joins(join(foreign_table, constraint))\n end\n \n # Exclude the scope of the association itself, because that\n # was already merged in the #scope method.\n scope_chain[i].each do |scope_chain_item|\n klass = i == 0 ? self.klass : reflection.klass\n item = eval_scope(klass, scope_chain_item)\n \n if scope_chain_item == self.reflection.scope\n scope.merge! item.except(:where, :includes)\n end\n \n scope.includes! item.includes_values\n scope.where_values += item.where_values\n scope.order_values |= item.order_values\n end\n end\n \n scope\n end",
"def join\n @plan = current_user.plans.create(:itinerary_id => params[:itinerary_id], :child_id => current_user.id, :parent_id => params[:parent_id])\n respond_to do |format|\n if @plan.save\n format.html { redirect_to(itineraries_path, :notice => 'Plan was successfully created.') }\n else\n format.html { redirect_to(itineraries_path, :notice => 'There was an error in joining this itinerary') }\n end\n end\nend",
"def create\n @doctor=Doctor.find(params[:doctor_id])\n @department = @doctor.departments.create(department_params)\n respond_to do |format|\n if @department\n format.html { redirect_to doctor_department_path(@doctor,@department), notice: 'Department was successfully created.' }\n format.json { render :show, status: :created, location: @department }\n else\n format.html { render :new }\n format.json { render json: @department.errors, status: :unprocessable_entity }\n end\n end\n end",
"def dept_tab_link_element(dept)\n link_element(xpath: \"//a[starts-with(@id, 'dept-#{dept.code}')]\")\n end",
"def check_add_foreign_key(*args); end",
"def sibling_id=(id)\n self.requirements_list = Requirement.find(id).requirements_list\n end",
"def make_related(parent, child, resource_config)\n proc = resource_config[:relation][:create]\n proc.call(parent, child) if proc\n child\n end",
"def create\n @dept = Dept.new params[:dept]\n\n flash[:notice] = 'Created Dept' if @dept.save\n respond_with @dept\n end",
"def department\n if self.is_a?(Department)\n self\n elsif self.is_a?(Entity)\n self.parent\n end\n end",
"def setup_concept_stages_from submission, concepts\n concepts.each do |concept|\n if !concept.concept_option.nil? and concept.concept_option.can_enter?\n concept_stage = submission.concept_stages.new\n concept_stage.topicconcept_id = concept.id\n concept_stage.save\n setup_concept_edge_stage_from submission, concept_stage, concept.concept_edge_dependent_concepts\n end\n end\n end",
"def create\n @plan = Plan.new(params[:plan])\n\n @plan.workers.each do |w|\nprint \"Adding \", w.name, \" to chore_lists\\n\"\n @plan.chore_lists.build(:worker_id => w.id)\n end \n @plan.save\n\n @plan.make_assignments\n\n# @plan.chore_lists.each do |cl|\n# cl.populate\n# end\n\n respond_to do |format|\n if @plan.save\n flash[:notice] = 'Plan was successfully created.'\n format.html { redirect_to(@plan) }\n format.xml { render :xml => @plan, :status => :created, :location => @plan }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @plan.errors, :status => :unprocessable_entity }\n end\n end\n end"
] |
[
"0.56608427",
"0.56564736",
"0.5552948",
"0.553551",
"0.5534745",
"0.5534745",
"0.5534745",
"0.5512788",
"0.54641384",
"0.5439059",
"0.52215725",
"0.5196148",
"0.5161448",
"0.5145264",
"0.5126229",
"0.51245975",
"0.5052786",
"0.49754107",
"0.49749613",
"0.49749613",
"0.49749613",
"0.49749613",
"0.49749613",
"0.49749613",
"0.49742812",
"0.49740833",
"0.4944855",
"0.49177673",
"0.49114588",
"0.4910243",
"0.49071205",
"0.4904222",
"0.49036917",
"0.49036917",
"0.48934627",
"0.4888475",
"0.48685625",
"0.48685625",
"0.48685625",
"0.48685625",
"0.48685625",
"0.48685625",
"0.48685625",
"0.486591",
"0.4860358",
"0.48550734",
"0.48449123",
"0.48415285",
"0.48407295",
"0.48386428",
"0.48382908",
"0.48106748",
"0.48004848",
"0.47882134",
"0.4788206",
"0.47846386",
"0.47802866",
"0.47761926",
"0.47723532",
"0.47692925",
"0.4765911",
"0.4755191",
"0.47481173",
"0.47379172",
"0.47379172",
"0.47358555",
"0.47310835",
"0.4729849",
"0.47093847",
"0.4698611",
"0.46960363",
"0.46838212",
"0.46761832",
"0.4667748",
"0.46676916",
"0.46586066",
"0.4650497",
"0.4642477",
"0.4633139",
"0.4631454",
"0.4631454",
"0.46313494",
"0.4630515",
"0.46270263",
"0.4614558",
"0.46109703",
"0.46093136",
"0.46082076",
"0.46069005",
"0.46019",
"0.45945585",
"0.45877767",
"0.45863613",
"0.45798647",
"0.457312",
"0.45715928",
"0.45704207",
"0.45698875",
"0.4563473",
"0.4557847"
] |
0.64783174
|
0
|
Configure the isaac backend for basic functions
|
def configure
# Give the bot a handle to config and handler
conf = @config
# Configure the bot
@bot = Isaac::Bot.new
@bot.configure{|c|
c.server = conf[:server]
c.port = conf[:port]
c.ssl = conf[:ssl]
c.nick = conf[:nick]
c.password = conf[:password]
c.realname = conf[:name]
c.environment = :production
c.verbose = conf[:verbose] || false
c.log = $log
}
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def main_audio ; end",
"def ayah_init\r\n ayah = AYAH::Integration.new(\"d5fbcc5d5d32f645158e72fc00b55eea205b13b4\", \"3969dc9a22c5378abdfc1d576b8757a8638b16d7\")\r\n end",
"def backends=(_arg0); end",
"def create_audio!(enc, manifest, s3_input, s3_output)\n\n # Create or load the Audio Config\n #audio_config = Bitmovin::Encoding::CodecConfigurations::AacConfiguration.find(\"<EXISTING_AAC_CONFIG_ID>\")\n audio_config = Bitmovin::Encoding::CodecConfigurations::AacConfiguration.new({\n name: \"AAC_PROFILE_128k\",\n bitrate: 128000,\n rate: 48000\n })\n audio_config.save!\n #\n # Adding Audio Stream to Encoding\n stream_aac = enc.streams.build(name: 'audio stream')\n stream_aac.codec_configuration = audio_config\n stream_aac.build_input_stream(input_path: INPUT_FILE_PATH, input_id: s3_input.id, selection_mode: 'AUTO')\n stream_aac.conditions = {\n type: \"CONDITION\",\n attribute: \"INPUTSTREAM\",\n operator: \"==\",\n value: \"TRUE\"\n }\n puts stream_aac.conditions.to_json\n stream_aac.save!\n\n # Audio Muxing\n audio_muxing = enc.muxings.fmp4.build(name: 'audio-muxing', segment_length: 4)\n audio_muxing.build_output({\n output_id: s3_output.id,\n output_path: File.join(OUTPUT_PATH, \"audio/aac\")\n })\n audio_muxing.build_output({\n output_id: s3_output.id,\n output_path: File.join(OUTPUT_PATH, \"audio/aac\"),\n acl: [{\n permission: \"PUBLIC_READ\"\n }]\n })\n audio_muxing.streams << stream_aac.id\n audio_muxing.save!\n\n # Adding Audio Stream to HLS Manifest\n audio_stream_medium = manifest.build_audio_medium({\n name: \"HLS Audio Media\",\n group_id: \"audio_group\",\n segment_path: \"audio/aac\",\n encoding_id: enc.id,\n stream_id: stream_aac.id,\n muxing_id: audio_muxing.id,\n language: \"en\",\n uri: \"audio_media.m3u8\"\n })\n audio_stream_medium.save!\nend",
"def enable_backend\n add option: \"-backend=true\"\n end",
"def convert_audio_to_aac(stream, index)\n disposition = (index == 0) ? 'default' : 'none'\n return [ \"-map 0:a:#{stream[:index]}\",\n \"-metadata:s:a:#{index} title='Stereo Track'\",\n \"-metadata:s:a:#{index} language=#{stream[:language]}\",\n \"-disposition:a:#{index} #{disposition}\",\n \"-codec:a:#{index} aac\",\n \"-ar:a:#{index} 48k\",\n \"-ab:a:#{index} 160k\",\n \"-ac:a:#{index} 2\" ]\nend",
"def backend=(backend); end",
"def config\n\n status=true\n\n # Set the audio carrier, but only if it's not false (so other\n # items can be updated without worrying about a little bit of\n # drift due to AFC).\n if @carrier\n @carrier=@carrier.to_i\n if @carrier!=self.get_carrier().to_i\n self.sendcmd(\"modem.set_carrier\", @carrier)\n end\n end\n \n # Set the modem. Also, take a stab at setting the timeouts for\n # that modem. ToDo: Add to these as additional modems are checked\n # out, and save the user some hassle.\n if @modem!=@modem_old\n case @modem\n when \"BPSK31\"\n @start_wait=5\n @char_wait=1\n when \"BPSK63\"\n @start_wait=5\n @char_wait=0.5\n when \"BPSK125\"\n @start_wait=5\n @char_wait=0.5\n when \"BPSK250\"\n @start_wait=5\n @char_wait=0.5\n else\n @start_wait=10\n @char_wait=2\n end\n \n if @modem==self.get_modem()\n @modem_old=@modem\n else\n self.sendcmd(\"modem.set_by_name\", @modem)\n if @modem==self.get_modem()\n @modem_old=@modem\n else\n self.error(\"modem.set_by_name failed with value #{@modem}\")\n puts \"modem.set_name failed\" if @debug\n status=false\n end\n end\n end\n \n # Turn spot on/off (true/false).\n if @spot!=@spot_old\n if torf(self.sendcmd(\"spot.get_auto\"))==@spot\n @spot_old=@spot\n else\n self.sendcmd(\"spot.set_auto\", @spot)\n if torf(self.sendcmd(\"spot.get_auto\"))==@spot\n @spot_old=@spot\n else\n self.error(\"spot.set_auto failed with value #{@spot}\")\n puts \"spot.set_auto failed\" if @debug\n status=false\n end\n end\n end\n\n # Turn AFC on/off (true/false). Some modes don't work with\n # AFC. There seems to be a great deal of inconsistency (a bug,\n # maybe?) in reading the AFC value back from FLDigi. Every test I\n # can come up with points to a bug in their code, not mine. Until\n # we can get this sorted out, don't consider failure to set AFC as\n # fatal. Just unset it, and continue on. ToDo: Verify bug in\n # FLDigi, then fix.\n if (@afc!=@afc_old)\n if torf(self.sendcmd(\"main.get_afc\"))==@afc\n @afc_old=@afc\n else\n self.sendcmd(\"main.set_afc\", @afc)\n sleep 0.25\n if torf(self.sendcmd(\"main.get_afc\"))==@afc\n @afc_old=@afc\n else\n @afc=false\n puts \"main.set_afc failed, so leaving turned off\" if @debug\n end\n end\n end\n\n # Set the sideband (\"USB\"/\"LSB\"). ToDo: make sure this is\n # correct.\n if @sideband!=@sideband_old\n if @sideband==self.sendcmd(\"main.get_sideband\")\n @sideband_old=@sideband\n else\n self.sendcmd(\"main.set_sideband\", @sideband)\n if @sideband==self.sendcmd(\"main.get_sideband\")\n @sideband_old=@sideband\n else\n self.error(\"main.set_sideband failed with value #{@sideband}\")\n puts \"main.set_sideband failed\" if @debug\n status=false\n end\n end\n end\n\n # Turn RSID receive on/off (true/false).\n if @rsid!=@rsid_old\n if torf(self.sendcmd(\"main.get_rsid\"))==@rsid\n @rsid_old=@rsid\n else\n self.sendcmd(\"main.set_rsid\", @rsid)\n if torf(self.sendcmd(\"main.get_rsid\"))==@rsid\n @rsid_old=@rsid\n else\n self.error(\"main.set_rsid failed with value #{@rsid}\")\n puts \"main.set_rsid failed\" if @debug\n status=false\n end\n end\n end\n \n # Turn squelch on/off (true/false).\n if @squelch!=@squelch_old\n if torf(self.sendcmd(\"main.get_squelch\"))==@squelch\n @squelch_old=@squelch\n else\n self.sendcmd(\"main.set_squelch\", @squelch)\n if torf(self.sendcmd(\"main.get_squelch\"))==@squelch\n @squelch_old=@squelch\n else\n self.error(\"main.set_squelch failed with value #{@squelch}\")\n puts \"main.set_squelch failed\" if @debug\n status=false\n end\n end\n end\n \n # Set the squelch value (3.0 seems to work well).\n if @slevel!=@slevel_old\n @slevel_old=@slevel\n if @slevel.to_f==self.sendcmd(\"main.get_squelch_level\").to_f\n @slevel=@slevel.to_f\n else\n self.sendcmd(\"main.set_squelch_level\", @slevel)\n if @slevel==self.sendcmd(\"main.get_squelch_level\")\n @slevel=@slevel.to_f\n else\n self.error(\"main.set_squelch_level failed with value #{@slevel}\")\n puts \"main.set_squelch_level failed\" if @debug\n status=false\n end\n end\n end\n\n # Set the radio frequency (in hz). If the user has specified no\n # rig control, it simply returns true and ignores the provided\n # value (this is so people who don't have rig control can still\n # use the other features of the library, they just can't set the\n # radio frequency). Otherwise, it returns true if successful in\n # setting the frequency, false if it fails. The sleep here gives\n # the radio time to change frequencies before checking. 0.5\n # seconds work with all of my radios, but it's possible this will\n # need to be tweaked. Send me an e-mail if this value is not\n # adequate for your radio, and I'll figure out a plan. So far, it\n # works on my IC-706MkII, my IC-756Pro, and my FT-817. The value\n # for @offset is added to the desired frequency. This is for use\n # when you want all of your radios to be on a very specific given\n # frequency. You must choose one as \"the standard\", then figure\n # out the offset for each rig from that standard. For example, my\n # FT-817 transmits 180hz lower (for a given equal temperature).\n # Assuming I've chosen my IC-706MkII as my standard (of course,\n # you could use WWV or some such, as well), I need to set @offset\n # to -180 whenever using my FT-817 if I want them to be on the\n # exact same frequency. This value could be added to either the\n # dial frequency or the carrier. I chose the dial frequency,\n # since a lot of people reference the carrier more often than the\n # dial. That way, when one person says he's at \"1000\", it'll be\n # \"1000\" on the other radio, as well. There's no good, clean,\n # all-purpose solution to this one, but at least it allows for\n # consistent and automated use of the library without having to do\n # the conversions in your own code. We give ourselves two tries to\n # get the freq right, since some rigs seem to act a bit odd when\n # changing bands.\n @dial_freq=@dial_freq.to_i\n if (@dial_freq!=@dial_freq_old or @offset!=@offset_old) and @rigctl\n @dial_freq_old=@dial_freq\n @offset_old=@offset\n if @dial_freq+@offset.to_i!=self.sendcmd(\"main.get_frequency\").to_f\n self.sendcmd(\"main.set_frequency\", @dial_freq+@offset.to_f)\n sleep 0.5\n if @dial_freq+@offset.to_i!=self.sendcmd(\"main.get_frequency\").to_f\n self.sendcmd(\"main.set_frequency\", @dial_freq+@offset.to_f)\n sleep 0.5\n if @dial_freq+@offset.to_i!=self.sendcmd(\"main.get_frequency\").to_f\n self.error(\"main.set_frequency failed with value #{@dial_freq}\")\n puts \"main.set_frequency failed\" if @debug\n status=false\n end\n end\n end\n end\n\n return status\n end",
"def initialize(env = :development, &block)\n @active_environment = env\n\n Loquacious.env_config = true\n Loquacious.env_prefix = \"AHN\"\n\n Loquacious::Configuration.for :core do\n root nil, :desc => \"Adhearsion application root folder\"\n\n lib \"lib\", :desc => <<-__\n Folder to include the own libraries to be used. Adhearsion loads any ruby file\n located into this folder during the bootstrap process. Set to nil if you do not\n want these files to be loaded. This folder is relative to the application root folder.\n __\n\n process_name \"ahn\", :desc => <<-__\n Adhearsion process name, useful to make it easier to find in the process list\n Pro tip: set this to your application's name and you can do \"killall myapp\"\n Does not work under JRuby.\n __\n\n event_threads 5, transform: Proc.new { |v| Adhearsion::Configuration.validate_number v }, desc: <<-__\n The number of threads to include in the event worker pool.\"\n __\n\n desc \"Log configuration\"\n logging {\n level :info, :transform => Proc.new { |v| v.to_sym }, :desc => <<-__\n Supported levels (in increasing severity) -- :trace < :debug < :info < :warn < :error < :fatal\n __\n formatter nil, :desc => <<-__\n A log formatter to apply to the stream. If nil, the Adhearsion default formatter will be used.\n __\n }\n\n type :xmpp , :transform => Proc.new { |v| v.to_sym }, :desc => <<-__\n Platform used to connect to the Telephony provider. Currently supported values:\n - :xmpp\n - :asterisk\n __\n username \"usera@127.0.0.1\", :desc => \"Authentication credentials\"\n password \"1\" , :desc => \"Authentication credentials\"\n host nil , :desc => \"Host to connect to (where rayo/asterisk is located)\"\n port Proc.new { Adhearsion::Configuration.default_port_for_platform type }, :transform => Proc.new { |v| Adhearsion::Configuration.validate_number v }, :desc => \"Port used to connect\"\n certs_directory nil , :desc => \"Directory containing certificates for securing the connection.\"\n root_domain nil , :desc => \"The root domain at which to address the server\"\n connection_timeout 60 , :transform => Proc.new { |v| Adhearsion::Configuration.validate_number v }, :desc => \"The amount of time to wait for a connection\"\n reconnect_attempts 1.0/0.0 , :transform => Proc.new { |v| Adhearsion::Configuration.validate_number v }, :desc => \"The number of times to (re)attempt connection to the server\"\n reconnect_timer 5 , :transform => Proc.new { |v| Adhearsion::Configuration.validate_number v }, :desc => \"Delay between connection attempts\"\n\n after_hangup_lifetime 1, :transform => Proc.new { |v| v.to_i }, :desc => <<-__\n Lifetime of a call after it has hung up. Should be set to the minimum functional value for your application. Call actors (threads) living after hangup consume more system resources and reduce the concurrent call capacity of your application.\n __\n\n desc \"Media configuration\"\n media {\n default_voice nil, desc: 'The default voice used for all output. Set nil to use platform default.'\n default_renderer nil, desc: 'The default renderer used for all output. Set nil to use platform default.'\n\n min_confidence 0.5, desc: 'The default minimum confidence level used for all recognizer invocations.', transform: Proc.new { |v| v.to_f }\n timeout 5, desc: 'The default timeout (in seconds) used for all recognizer invocations.', transform: Proc.new { |v| v.to_i }\n inter_digit_timeout 2, desc: 'The timeout used between DTMF digits and to terminate partial invocations', transform: Proc.new { |v| v.to_i }\n recognizer nil, desc: 'The default recognizer used for all input. Set nil to use platform default.'\n input_language 'en-US', desc: 'The default language set on generated grammars. Set nil to use platform default.'\n }\n\n desc \"Internationalisation\"\n i18n {\n locale_path [\"config/locales\"], transform: Proc.new { |v| v.split ':' }, desc: <<-__\n List of directories from which to load locale data, colon-delimited\n __\n audio_path \"app/assets/audio\", desc: <<-__\n Base path from which audio files can be found. May be a filesystem path or some other URL (like HTTP)\n __\n fallback true, desc: <<-__\n Whether to include text for translations that provide both text & audio. True or false.\n __\n }\n\n desc \"HTTP server\"\n http do\n enable true, desc: \"Enable or disable the HTTP server\"\n host \"0.0.0.0\", desc: \"IP to bind the HTTP listener to\"\n port \"8080\", desc: \"Port to bind the HTTP listener to\"\n rackup 'config.ru', desc: 'Path to Rack configuration file (relative to Adhearsion application root)'\n end\n end\n\n Loquacious::Configuration.for :core, &block if block_given?\n\n self\n end",
"def initialize settings\n super\n audio_settings = get_settings :audio\n @audio = load_audio audio_settings if (audio_settings)\n end",
"def configure; end",
"def audio; end",
"def backend=(backend)\n @backend = backend&.to_sym\n set_encoder\n end",
"def bass_intro\n play :f2, sustain: 3\n sleep 3.66\n play :g2, sustain: 0.66\n sleep 0.66\n play :a2, sustain: 0.66\n sleep 0.93\n play :c3, sustain: 3.5\n sleep 4.4\n play :D3, sustain: 0.66\n sleep 0.66\n play :e3, sustain: 0.66\n sleep 0.93\n play :d3, sustain: 3.5\n sleep 4.4\n play :e3, sustain: 0.66\n sleep 0.66\n play :f3, sustain: 0.66\n sleep 0.93\n play :bb2, sustain: 3.5\n sleep 4.4\n play :e3, sustain: 0.66\n sleep 0.66\n play :f3, sustain: 0.66\n sleep 0.93\n play :f2, sustain: 3.5\n sleep 4.4\n play :g2, sustain: 0.66\n sleep 0.66\n play :a2, sustain: 0.66\n sleep 0.93\n play :c3, sustain: 3.5\n sleep 4.4\n play :d3, sustain: 0.66\n sleep 0.66\n play :f3, sustain: 0.66\n sleep 0.93\n play :a2, sustain: 4\n sleep 5.4\n play :a2, sustain: 0.66\n sleep 0.66\n play :bb2, sustain: 3.5\n sleep 4.4\n play :E3, sustain: 0.66\n sleep 0.66\n play :f3, sustain: 0.66\n sleep 1.66\nend",
"def modernize_coderay_config; end",
"def backend; end",
"def setupBackend\n lBackendInitHere = false\n if (!@BackendInit)\n @BackendInstance.init_session(@Conf[:Backends][@Backend])\n @BackendInit = true\n lBackendInitHere = true\n end\n yield\n if (lBackendInitHere)\n @BackendInstance.close_session\n @BackendInit = false\n end\n end",
"def initialize_mixlib_config\n super\n end",
"def configure\n # NOTE Die control signale sind in PD schon auf den Bereich 0..11 gemapped.\n @eingang.add_method '/control' do | message |\n value, controller, channel = message.to_a\n case controller\n when 1,2,3,4\n stimme = [:bass, :tenor, :alt, :sopran][controller-1]\n @zeug.stimmvariation!(stimme, value)\n when 5\n # puts \"Umkehrung: #{value}\"\n @spiel.umkehrung = value\n when 6 \n # puts \"Transposition: #{value}\"\n @spiel.transposition = value\n else\n # p message.to_a\n end\n end\n @eingang.add_method '/note' do | message |\n note, velocity, channel = message.to_a\n case note\n when 39\n # FIXME toggle einbauen!\n @spiel.akkordkrebs = !velocity.zero?\n when 60\n @spiel.reihe = @spiel.reihe.shuffle if !velocity.zero?\n end\n end\n end",
"def initialize(*args, &block)\n super\n options[:audio_profile] ||= :default\n options[:format] ||= :ogg\n end",
"def backends; end",
"def configure_ai_client(client_name,client_arch,client_mac,client_ip,client_model,publisher_host,service_name,image_name)\n # Populate questions for AI profile\n if !service_name.match(/i386|sparc/)\n service_name = service_name+\"_\"+client_arch\n end\n check_ai_client_doesnt_exist(client_name,client_mac,service_name)\n populate_ai_client_profile_questions(client_ip,client_name)\n process_questions(service_name)\n if $os_name.match(/Darwin/)\n tftp_version_dir = $tftp_dir+\"/\"+service_name\n check_osx_iso_mount(tftp_version_dir,iso_file)\n end\n output_file = $work_dir+\"/\"+client_name+\"_ai_profile.xml\"\n create_ai_client_profile(output_file)\n puts \"Configuring:\\tClient \"+client_name+\" with MAC address \"+client_mac\n import_ai_client_profile(output_file,client_name,client_mac,service_name)\n create_ai_client(client_name,client_arch,client_mac,service_name,client_ip)\n if $os_name.match(/SunOS/) and $os_rel.match(/11/)\n clear_solaris_dhcpd()\n end\n return\nend",
"def _setup(action)\n @cipher ||= OpenSSL::Cipher.new(@options[:cipher]) \n # Toggles encryption mode\n @cipher.send(action)\n @cipher.padding = @options[:padding]\n @cipher.key = @key.unpack('a2'*32).map{|x| x.hex}.pack('c'*32)\n end",
"def get_audio_codec \n send_cmd(\"get_audio_codec\")\n end",
"def oai_config\n blacklight_config.oai || {}\n end",
"def oai_config\n blacklight_config.oai || {}\n end",
"def oai_config\n blacklight_config.oai || {}\n end",
"def configure t\n t.library_path << 'lib'\n t.source_path << 'src'\n t.include_sources << 'src'\n t.optimize = true\n # t.load_config << 'birdbase-config-sample.xml'\n t.load_config << 'birdbase-config.xml'\n t.target_player = '10.2'\nend",
"def start\n backend.start\n end",
"def setup\n @config[\"syntax_highlighter\"] ||= highlighter\n @config[\"syntax_highlighter_opts\"] ||= {}\n @config[\"syntax_highlighter_opts\"][\"default_lang\"] ||= \"plaintext\"\n @config[\"syntax_highlighter_opts\"][\"guess_lang\"] = @config[\"guess_lang\"]\n @config[\"coderay\"] ||= {} # XXX: Legacy.\n modernize_coderay_config\n make_accessible\n end",
"def set_algorithms( cipher, mac )\n @cipher, @hmac = cipher, mac\n end",
"def enable\n {\n method: \"WebAudio.enable\"\n }\n end",
"def init_cc\n raise NotImplementedError\n end",
"def convert_audio_to_ac3(stream, index)\n args = [ \"-map 0:a:#{stream[:index]}\",\n \"-metadata:s:a:#{index} title='Surround Track'\",\n \"-metadata:s:a:#{index} language=#{stream[:language]}\",\n \"-disposition:a:#{index} none\",\n \"-codec:a:#{index} ac3\",\n \"-ar:a:#{index} 48k\",\n \"-ab:a:#{index} 448k\",\n \"-ac:a:#{index} 6\" ]\n\n # DCA (DTS) is usually too quiet when converted to AAC.\n args << \"-af:a:#{index} volume=2.0\" if 'dca' == stream[:codec]\n\n return args\nend",
"def configure\n end",
"def quick_transcode(input, options={})\n quality = options[:quality] || 19\n log = options[:log]\n output = input.gsub(/\\.[^.]*$/, '.m4v')\n\n # TODO Next time this is needed, make the options below detect its use.\n pcm_input = nil\n # extract the audio to PCM with ffmpeg first because sometimes HandBrakeCLI has problems\n # pcm_input = \"#{input}-temp.avi\"\n # command = <<-EOS\n # nice -n 19 ffmpeg -i \"#{input}\" -acodec adpcm_ms -vcodec copy \"#{pcm_input}\"\n # EOS\n # input = pcm_input # we no longer care about the original.\n # command = command.strip\n # # log.info \"Extracting audio to PCM with ffmpeg...\"\n # puts \"Prepping with ffmpeg using: #{command}\"\n # system(command)\n\n # x264opts will be passed to the '-x' argument of HandBrakeCLI\n # I took these from the advanced tab of the HandBrake 0.9.5 x86_64 (2011010300) GUI for the AppleTV preset\n x264opts = {\n :'cabac' => '0',\n :'ref' => '2',\n :'me' => 'umh',\n :'b-pyramid' => 'none',\n :'b-adapt' => '2',\n :'weightb' => '0',\n :'trellis' => '0',\n :'weightp' => '0',\n :'vbv-maxrate' => '9500',\n :'vbv-bufsize' => '9500' }\n\n options = {\n :'-i' => %{\"#{input}\"},\n :'-o' => %{\"#{output}\"},\n :'--crop' => '0:0:0:0',\n :'-X' => '1280',\n :'-Y' => '720',\n :'-e' => 'x264',\n :'-q' => quality,\n :'--loose-anamorphic' => nil,\n :'--markers' => nil, # chapter markers\n :'-x' => x264opts.map{|k,v| \"#{k}=#{v}\"}.join(':') }\n\n # Now transcode the video and re-mux / transcode in the audio extracted by ffmpeg\n command = \"nice -n 19 HandBrakeCLI #{options.map{|k,v| \"#{k} #{v}\"}.join(\" \")}\"\n command = command.gsub(/ +/, ' ').strip\n # puts \"doing it!: #{command}\"\n system(command) # backticks wont work here.\n\n # if we're using the intermediate pcm-audio step, clean up after ourselves.\n if pcm_input\n # log.info \"Cleaning up ffmpeg intermediate step...\"\n File.delete(pcm_input)\n end\n\n if options[:source_type] == \"mkv\"\n mkv_options = []\n mkvoptions[:log] = log if log\n mkv_file = MkvFile.new(source_file, mkv_options)\n ##### TODO extract any chapter info and import it\n\n if mkv_file.subtitles?\n srt_file = mkv_file.export_subtitles_as_srt\n\n ##### Mux the M4V and SRT files\n log.info \"Muxing subtitles into .M4V file '#{m4v_file}' ...\" if log\n `SublerCLI -i \"#{m4v_file}\" -s \"#{srt_file}\"`\n\n mkv_file.cleanup_subtitle_files\n end\n end\nend",
"def set_backend(val)\n end",
"def initialize\n @amplitude = {}\n @mixpanel = {}\n @appmetrica = {}\n @appsflyer = {}\n end",
"def simple_audio_player_init_tag(config = {})\n # TODO: remove invalid config options\n \n # Transform the ruby config hash to a javascript styled config hash\n javascript_tag \"AudioPlayer.setup('/flash_files/simple_audio_player/player.swf', #{config.to_json});\"\n end",
"def configure(bitstream)\n\n validate_bitstream(bitstream)\n\n #Send the bitstream to the FPGA.\n initialize_configuration\n transmit_data(bitstream.to_s)\n finalize_configuration\n\n #And verify that the programming succeeded. \n unless bitstream.usercode == usercode || bitstrea.usercode.nil?\n raise ProgrammingError, \"Programming failed; expected a usercode of #{bitstream.usercode}, recieved #{usercode}.\" \n end\n\n end",
"def setup_aftinfo\n @afrate = @acts[1] || 3\n @afopac = @acts[2] || 20\n end",
"def setup_aftinfo\n @afrate = @acts[1] || 3\n @afopac = @acts[2] || 20\n end",
"def k_accionsys!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 34 )\n\n\n\n type = K_ACCIONSYS\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 389:4: ( 'beep' | 'help' | 'exit' )\n # at line 389:4: ( 'beep' | 'help' | 'exit' )\n alt_9 = 3\n case look_9 = @input.peek( 1 )\n when 0x62 then alt_9 = 1\n when 0x68 then alt_9 = 2\n when 0x65 then alt_9 = 3\n else\n raise NoViableAlternative( \"\", 9, 0 )\n\n end\n case alt_9\n when 1\n # at line 389:5: 'beep'\n match( \"beep\" )\n\n\n when 2\n # at line 389:12: 'help'\n match( \"help\" )\n\n\n when 3\n # at line 389:19: 'exit'\n match( \"exit\" )\n\n\n end\n\n\n @state.type = type\n @state.channel = channel\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 34 )\n\n\n end",
"def enableCaustics _args\n \"enableCaustics _args;\" \n end",
"def configure_frontend\n end",
"def init\n @inputs = {}\n @outputs = {}\n @triggers = []\n @filters = []\n @code_keys = []\n @songs = {} # key = name, value = song\n end",
"def audio_convert_to_aac_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: AudioApi.audio_convert_to_aac ...'\n end\n # resource path\n local_var_path = '/video/convert/to/aac'\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/octet-stream'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data'])\n header_params[:'fileUrl'] = opts[:'file_url'] if !opts[:'file_url'].nil?\n header_params[:'bitRate'] = opts[:'bit_rate'] if !opts[:'bit_rate'].nil?\n\n # form parameters\n form_params = {}\n form_params['inputFile'] = opts[:'input_file'] if !opts[:'input_file'].nil?\n\n # http body (model)\n post_body = nil\n auth_names = ['Apikey']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'String')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: AudioApi#audio_convert_to_aac\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def register!\n super do |conf|\n toolchain :clang\n\n conf.cc do |cc|\n cc.command = Emscripten.bin(:emcc)\n end\n\n conf.cxx.command = Emscripten.bin('em++')\n conf.linker.command = Emscripten.bin(:emcc)\n\n # Archive\n conf.exts.library = '.js'\n conf.archiver.archive_options = '-o %{outfile} %{objs}'\n conf.archiver.command = Emscripten.bin(:emcc)\n end\n end",
"def initialize\n setup_ohai\n configure\n end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def gen_acrostic(options)\r\n acrostic(options)\r\n end",
"def initialize\n self.cipher = AesCipher.new\n end",
"def init_ext()\n \n end",
"def initialize_configuration\n\n #Pulse the Program pin via JTAG.\n self.instruction = :jprogram\n\n #Put the device into configuration mode, and give it 14,000 cycles to start up.\n self.instruction = :cfg_in\n run_test(ConfigurationStartup)\n\n end",
"def initialize(config)\n self.zconfig = Zapi::Zconfig.new(config)\n\t\t\t savon_setup\n $session = self\t\n\t\t end",
"def codec\n \"-acodec libmp3lame -y\"\n end",
"def switch_audio _value=0\n send_cmd(\"switch_audio #{_value}\")\n end",
"def set_algorithms( cipher, hmac, compressor )\n super( cipher, hmac )\n @compressor = compressor\n end",
"def audios_test\n end",
"def init_compile_config\n end",
"def init \n { \"madlibs\" => :start_mad , \"madlibs-patterns\" => :list_patterns}\nend",
"def default_options\n { voice: 'en',\n pitch: 50,\n speed: 170,\n capital: 1,\n amplitude: 100,\n quiet: true }\n end",
"def enableAI _obj, _args\n \"_obj enableAI _args;\" \n end",
"def gamemodesetup(&b)\r\n\t$gamemode.setupgamemode &b\r\nend",
"def configure(&block); end",
"def configure(&block); end",
"def configure_backend!(config, backend, id = nil, secret = nil)\n return unless Rails.env.test? || APP_CONFIG.enabled?(\"oauth.#{backend}\")\n\n options = send(\"#{backend}_fetch_options\")\n\n if id\n config.omniauth backend, id, secret, options\n else\n config.omniauth backend, options\n end\nend",
"def set_crypto_hooks\n\n Binding.setopt_crypto_hooks(\n self,\n method(:aes_encrypt),\n method(:aes_decrypt),\n method(:random),\n method(:hmac_sha_512),\n method(:hmac_sha_256),\n method(:hmac_hash),\n )\n end",
"def snd_settle_mode\n Cproton.pn_link_snd_settle_mode(@impl)\n end",
"def autoconf(autoconf)\n @script.autoconf = autoconf\n end",
"def config\n\n end",
"def game_setup\n cls\n print \"----------------\\n\"\n print \"Cinnabar - A Game Of Rocks and Minerals\\n\"\n print \"----------------\\n\\n\"\n\n print \"DISCLAIMER\\n\"\n print \" Cinnabar (c) 1966, 1972, 1980 is a trademark of Naturegraph Publishers, Inc.\\n\"\n print \" No copyright or trademark infringement is intended in using Cinnabar.\\n\\n\"\n\n print \"Welcome to Cinnabar, a digital version of the 1966 card game by Vinson Brown.\\n\"\n print \"Rules can be found in RULES.md, and info can be found in README.md.\\n\"\n print \"Source code can be found at https://www.github.com/Pokeconomist/cinnabar.\\n\\n\"\n end",
"def set_backend\n @backend = Backend.find(params[:id])\n end",
"def initialize(audio_defaults, logger, temp_dir, run_program, opts = {})\n @audio_defaults = audio_defaults\n @logger = logger\n @temp_dir = temp_dir\n @run_program = run_program\n\n @audio_ffmpeg = opts[:ffmpeg]\n @audio_mp3splt = opts[:mp3splt]\n @audio_sox = opts[:sox]\n @audio_wavpack = opts[:wavpack]\n @audio_shntool = opts[:shntool]\n @audio_waveform = opts[:waveform]\n @audio_wac2wav = opts[:wac2wav]\n\n @class_name = self.class.name\n end",
"def initialize(options = {})\n @port = SerialPort.new(options[:port], options[:speed])\n cmd(\"AT\")\n # Set to text mode\n cmd(\"AT+CMGF=1\")\n # Set SMSC number\n cmd(\"AT+CSCA=\\\"#{SMSC}\\\"\") \n end",
"def update!(**args)\n @audio_encoding = args[:audio_encoding] if args.key?(:audio_encoding)\n @sample_rate_hertz = args[:sample_rate_hertz] if args.key?(:sample_rate_hertz)\n @synthesize_speech_config = args[:synthesize_speech_config] if args.key?(:synthesize_speech_config)\n end",
"def ca; end",
"def update!(**args)\n @audio_bitrate = args[:audio_bitrate] if args.key?(:audio_bitrate)\n @audio_channels = args[:audio_channels] if args.key?(:audio_channels)\n @audio_codec_id = args[:audio_codec_id] if args.key?(:audio_codec_id)\n @audio_end_timestamp = args[:audio_end_timestamp] if args.key?(:audio_end_timestamp)\n @audio_frame_size = args[:audio_frame_size] if args.key?(:audio_frame_size)\n @audio_length = args[:audio_length] if args.key?(:audio_length)\n @audio_number_of_frames = args[:audio_number_of_frames] if args.key?(:audio_number_of_frames)\n @audio_sample_rate = args[:audio_sample_rate] if args.key?(:audio_sample_rate)\n @audio_sample_size = args[:audio_sample_size] if args.key?(:audio_sample_size)\n @audio_start_timestamp = args[:audio_start_timestamp] if args.key?(:audio_start_timestamp)\n @audio_stream = args[:audio_stream] if args.key?(:audio_stream)\n @audio_stream_codec_tag = args[:audio_stream_codec_tag] if args.key?(:audio_stream_codec_tag)\n @av_distance = args[:av_distance] if args.key?(:av_distance)\n @av_length = args[:av_length] if args.key?(:av_length)\n @average_video_fps = args[:average_video_fps] if args.key?(:average_video_fps)\n @build_label = args[:build_label] if args.key?(:build_label)\n @container_id = args[:container_id] if args.key?(:container_id)\n @container_type = args[:container_type] if args.key?(:container_type)\n @contains_chapters = args[:contains_chapters] if args.key?(:contains_chapters)\n @data_stream = args[:data_stream] if args.key?(:data_stream)\n @display_height = args[:display_height] if args.key?(:display_height)\n @display_width = args[:display_width] if args.key?(:display_width)\n @file_header_fingerprint = args[:file_header_fingerprint] if args.key?(:file_header_fingerprint)\n @file_magic = args[:file_magic] if args.key?(:file_magic)\n @file_modified_time = args[:file_modified_time] if args.key?(:file_modified_time)\n @file_name = args[:file_name] if args.key?(:file_name)\n @file_size = args[:file_size] if args.key?(:file_size)\n @file_type = args[:file_type] if args.key?(:file_type)\n @google_video_clip_info = args[:google_video_clip_info] if args.key?(:google_video_clip_info)\n @image_stream = args[:image_stream] if args.key?(:image_stream)\n @is_asf = args[:is_asf] if args.key?(:is_asf)\n @is_image_file = args[:is_image_file] if args.key?(:is_image_file)\n @is_video_insane_size = args[:is_video_insane_size] if args.key?(:is_video_insane_size)\n @level = args[:level] if args.key?(:level)\n @metadata = args[:metadata] if args.key?(:metadata)\n @num_audio_streams = args[:num_audio_streams] if args.key?(:num_audio_streams)\n @num_data_streams = args[:num_data_streams] if args.key?(:num_data_streams)\n @num_image_streams = args[:num_image_streams] if args.key?(:num_image_streams)\n @num_timedtext_streams = args[:num_timedtext_streams] if args.key?(:num_timedtext_streams)\n @num_video_streams = args[:num_video_streams] if args.key?(:num_video_streams)\n @parsed_by_ffmpeg = args[:parsed_by_ffmpeg] if args.key?(:parsed_by_ffmpeg)\n @partial_file = args[:partial_file] if args.key?(:partial_file)\n @pix_fmt = args[:pix_fmt] if args.key?(:pix_fmt)\n @profile = args[:profile] if args.key?(:profile)\n @timedtext_stream = args[:timedtext_stream] if args.key?(:timedtext_stream)\n @video_bitrate = args[:video_bitrate] if args.key?(:video_bitrate)\n @video_clip_info = args[:video_clip_info] if args.key?(:video_clip_info)\n @video_codec_id = args[:video_codec_id] if args.key?(:video_codec_id)\n @video_end_timestamp = args[:video_end_timestamp] if args.key?(:video_end_timestamp)\n @video_fps = args[:video_fps] if args.key?(:video_fps)\n @video_frame_size = args[:video_frame_size] if args.key?(:video_frame_size)\n @video_has_b_frames = args[:video_has_b_frames] if args.key?(:video_has_b_frames)\n @video_has_fragments = args[:video_has_fragments] if args.key?(:video_has_fragments)\n @video_has_leading_moov_atom = args[:video_has_leading_moov_atom] if args.key?(:video_has_leading_moov_atom)\n @video_has_non_monotonic_dts = args[:video_has_non_monotonic_dts] if args.key?(:video_has_non_monotonic_dts)\n @video_has_non_monotonic_pts = args[:video_has_non_monotonic_pts] if args.key?(:video_has_non_monotonic_pts)\n @video_has_non_zero_start_edit_list = args[:video_has_non_zero_start_edit_list] if args.key?(:video_has_non_zero_start_edit_list)\n @video_has_possible_open_gop = args[:video_has_possible_open_gop] if args.key?(:video_has_possible_open_gop)\n @video_has_variable_aspect_ratio = args[:video_has_variable_aspect_ratio] if args.key?(:video_has_variable_aspect_ratio)\n @video_height = args[:video_height] if args.key?(:video_height)\n @video_interlace = args[:video_interlace] if args.key?(:video_interlace)\n @video_length = args[:video_length] if args.key?(:video_length)\n @video_number_of_frames = args[:video_number_of_frames] if args.key?(:video_number_of_frames)\n @video_number_of_invisible_frames = args[:video_number_of_invisible_frames] if args.key?(:video_number_of_invisible_frames)\n @video_pixel_aspect_ratio = args[:video_pixel_aspect_ratio] if args.key?(:video_pixel_aspect_ratio)\n @video_rotation = args[:video_rotation] if args.key?(:video_rotation)\n @video_start_timestamp = args[:video_start_timestamp] if args.key?(:video_start_timestamp)\n @video_stream = args[:video_stream] if args.key?(:video_stream)\n @video_stream_codec_tag = args[:video_stream_codec_tag] if args.key?(:video_stream_codec_tag)\n @video_width = args[:video_width] if args.key?(:video_width)\n @videostreaminfo_version = args[:videostreaminfo_version] if args.key?(:videostreaminfo_version)\n @y_psnr = args[:y_psnr] if args.key?(:y_psnr)\n end",
"def initialize\n @codice_fiscale = CodiceFiscaleConfiguration.new\n @cap_lookup = CapLookupConfiguration.new\n end",
"def setup\n if EXPA.client.nil?\n\t # Sets the client variable in the EXPA module\n\t\t# which can be used for authentication afterwards\n EXPA.client = EXPA::Client.new()\n end\n end",
"def configure_and_run(params = [])\n config_file = Configuration::DEFAULT_CONFIG_FILE_NAME\n tmp_config = Configuration.new\n action_wizard = false\n\n parser = OptionParser.new do |opts|\n opts.banner = if ENV['OCRA_EXECUTABLE']\n \"Usage: #{ENV['OCRA_EXECUTABLE'].gsub(\"#{Dir.pwd}/\".gsub('/', '\\\\'), '')} [options]\"\n else\n \"Usage: #{Gem.ruby} #{$PROGRAM_NAME} [options]\"\n end\n\n opts.on('-c', '--config CONFIG_FILE_NAME', 'Specify custom configuration file,'\\\n \" instead of #{Configuration::DEFAULT_CONFIG_FILE_NAME}.\") do |file_name|\n config_file = file_name\n end\n\n opts.on('-r', '--register FILE', 'Register a custom plugin, e.g. your own Datasource implementation') do |plugin|\n require plugin\n end\n\n opts.on('-d', '--debug LEVEL', 'Specify detail level: FATAL, ERROR, WARN, INFO, DEBUG.') do |level|\n tmp_config.set_param('grafana-reporter:debug-level', level)\n end\n\n opts.on('-o', '--output FILE', 'Output filename if only a single file is rendered') do |file|\n tmp_config.set_param('to_file', file)\n end\n\n opts.on('-s', '--set VARIABLE,VALUE', Array, 'Set a variable value, which will be passed to the '\\\n 'rendering') do |list|\n raise ParameterValueError, list.length unless list.length == 2\n\n tmp_config.set_param(\"default-document-attributes:#{list[0]}\", list[1])\n end\n\n opts.on('--ssl-cert FILE', 'Manually specify a SSL cert file for HTTPS connection to grafana. Only '\\\n 'needed if not working properly otherwise.') do |file|\n if File.file?(file)\n tmp_config.set_param('grafana-reporter:ssl-cert', file)\n else\n config.logger.warn(\"SSL certificate file #{file} does not exist. Setting will be ignored.\")\n end\n end\n\n opts.on('--test GRAFANA_INSTANCE', 'test current configuration against given GRAFANA_INSTANCE') do |instance|\n tmp_config.set_param('grafana-reporter:run-mode', 'test')\n tmp_config.set_param('grafana-reporter:test-instance', instance)\n end\n\n opts.on('-t', '--template TEMPLATE', 'Render a single ASCIIDOC template to PDF and exit') do |template|\n tmp_config.set_param('grafana-reporter:run-mode', 'single-render')\n tmp_config.set_param('default-document-attributes:var-template', template)\n end\n\n opts.on('-w', '--wizard', 'Configuration wizard to prepare environment for the reporter.') do\n action_wizard = true\n end\n\n opts.on('-v', '--version', 'Version information') do\n puts GRAFANA_REPORTER_VERSION.join('.')\n return -1\n end\n\n opts.on('-h', '--help', 'Show this message') do\n puts opts\n return -1\n end\n end\n\n begin\n parser.parse!(params)\n return ConsoleConfigurationWizard.new.start_wizard(config_file, tmp_config) if action_wizard\n rescue ApplicationError => e\n puts e.message\n return -1\n end\n\n # abort if config file does not exist\n unless File.file?(config_file)\n puts \"Config file '#{config_file}' does not exist. Consider calling the configuration wizard\"\\\n ' with option \\'-w\\' or use \\'-h\\' to see help message. Aborting.'\n return -1\n end\n\n # merge command line configuration with read config file\n @config.load_config_from_file(config_file)\n @config.merge!(tmp_config)\n\n run\n end",
"def configure(mode, compiler, path)\n # @config controls the compilation of a C Program\n @config = {\n # Use which compiler to compile the program\n generator: compiler,\n # Store the binary file to where\n path: path\n }\n\n # @mode can be :default, :quiet, :verbose, :help, :compile_only\n @mode = mode\n end",
"def skuby_init\r\n Skuby.setup do |config|\r\n config.method = 'send_sms_classic'\r\n config.username = @username\r\n config.password = @password\r\n config.sender_string = 'BLOMMING'\r\n #config.sender_number = 'xxxxxxxxxxxx'\r\n config.charset = 'UTF-8'\r\n end\r\nend"
] |
[
"0.58001405",
"0.5630417",
"0.5626259",
"0.56152296",
"0.54894656",
"0.54694736",
"0.54372865",
"0.54372686",
"0.53559417",
"0.53166527",
"0.52689433",
"0.52419055",
"0.5233905",
"0.5224675",
"0.51922506",
"0.5191189",
"0.51908624",
"0.51848185",
"0.51399815",
"0.5138905",
"0.5124285",
"0.5117031",
"0.5040181",
"0.50395304",
"0.5039188",
"0.5039188",
"0.5025482",
"0.5022897",
"0.5010028",
"0.50075734",
"0.4998602",
"0.49976006",
"0.49975368",
"0.4983026",
"0.4967424",
"0.49587172",
"0.4953187",
"0.49490649",
"0.49467227",
"0.49427554",
"0.4935391",
"0.4935391",
"0.49319142",
"0.49277622",
"0.492233",
"0.491926",
"0.49182048",
"0.4913614",
"0.49089673",
"0.49068752",
"0.49068752",
"0.49068752",
"0.49068752",
"0.49068752",
"0.49068752",
"0.49068752",
"0.49068752",
"0.49068752",
"0.49068752",
"0.49068752",
"0.49068752",
"0.49068752",
"0.49068752",
"0.49068752",
"0.49068752",
"0.49068752",
"0.49068752",
"0.4899829",
"0.48746514",
"0.4853841",
"0.48312286",
"0.4820369",
"0.48128265",
"0.48082605",
"0.48079747",
"0.4807888",
"0.47928005",
"0.47912648",
"0.47772",
"0.47750857",
"0.4772922",
"0.47722858",
"0.47722858",
"0.47688922",
"0.4751965",
"0.4751311",
"0.4746608",
"0.47424254",
"0.47244462",
"0.47239777",
"0.47186956",
"0.47144184",
"0.4711809",
"0.4711441",
"0.47097152",
"0.47086805",
"0.4695702",
"0.46916395",
"0.46859023",
"0.46852142"
] |
0.57062036
|
1
|
Registers a handler for all messages There can be only one handler, and this method basically defers to isaac's register call.
|
def register(handler)
conf = @config
bot = self
isaac = @bot
@bot.register{|type, msg|
begin
$log.debug "Received message: #{type} #{msg}"
handler.dispatch(type, msg, bot.clone_state(msg)) # TODO: send a binding?
rescue Exception => e
$log.warn e.to_s
$log.debug e.backtrace.join("\n")
end
}
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def add_message_handler(&block)\n @message_handlers << block\n end",
"def register_handler(handler)\n handler.handled_events.each do |event_type|\n (event_handlers[event_type] ||= []) << handler\n Twitch::Bot::Logger.debug \"Registered #{handler} for #{event_type}\"\n end\n end",
"def handler\n @handlers.push(proc do |msg|\n yield msg\n end)\n end",
"def add_handler(handler)\n @handlers << handler\n end",
"def register_inbound_handler(handler)\n\t\t@inbound_handlers << handler\n\tend",
"def register(client_id, message_handlers, options={})\n receiver = receiver(client_id)\n message_handler_names = []\n message_handlers = [message_handlers] unless message_handlers.is_a? Array\n message_handlers.each do |message_handler|\n if check(client_id, message_handler)\n handled_methods = message_handler.handled_methods || []\n handled_methods = [handled_methods] unless handled_methods.is_a? Array\n handled_methods_as_strings = []\n handled_methods.each do |method|\n handled_methods_as_strings << method.to_s\n (@registered_message_handlers_for_method[method.to_sym] ||= []) << message_handler\n end\n message_handler_name = message_handler.name.to_s\n @registered_message_handlers << message_handler\n @registered_message_handlers_by_fq_name[message_handler.fq_name] = message_handler\n message_handler.qsif = @qsif_public # Set the public service interface so that it is available in the message handler\n message_handler_names << message_handler_name\n notify(:type => :debug, :code => 5000, :receivers => receiver, :params => {:message_handler_name => message_handler_name, :handled_methods => handled_methods_as_strings.inspect, :modules => message_handler.modules.inspect, :message_handler_class => message_handler.class, :version => message_handler.version })\n end\n end\n notify(:type => :debug, :code => 5010, :receivers => receiver, :params => {:amount => @registered_message_handlers.size})\n end",
"def setup_default_handlers\n # Incoming events\n prepend_handler :incoming_msg, self.method(:r_msg)\n prepend_handler :incoming_act, self.method(:r_act)\n prepend_handler :incoming_notice, self.method(:r_notice)\n prepend_handler :incoming_ctcp, self.method(:r_ctcp)\n prepend_handler :incoming_ctcpreply, self.method(:r_ctcpreply)\n prepend_handler :incoming_mode, self.method(:r_mode)\n prepend_handler :incoming_join, self.method(:r_join)\n prepend_handler :incoming_part, self.method(:r_part)\n prepend_handler :incoming_kick, self.method(:r_kick)\n prepend_handler :incoming_quit, self.method(:r_quit)\n prepend_handler :incoming_nick, self.method(:r_nick)\n prepend_handler :incoming_miscellany, self.method(:r_miscellany)\n\n # Incoming numeric events here\n prepend_handler :incoming_welcome, self.method(:r_welcome)\n prepend_handler :incoming_bannedfromchan, self.method(:r_bannedfromchan)\n prepend_handler :incoming_badchannelkey, self.method(:r_badchannelkey)\n prepend_handler :incoming_nicknameinuse, self.method(:_nicknameinuse)\n prepend_handler :incoming_channelurl, self.method(:r_channelurl)\n prepend_handler :incoming_topic, self.method(:r_topic)\n prepend_handler :incoming_topicinfo, self.method(:r_topicinfo)\n prepend_handler :incoming_namreply, self.method(:_namreply)\n prepend_handler :incoming_endofnames, self.method(:r_endofnames)\n prepend_handler :incoming_motd, self.method(:r_motd)\n prepend_handler :incoming_motdstart, self.method(:r_motdstart)\n prepend_handler :incoming_endofmotd, self.method(:r_endofmotd)\n prepend_handler :incoming_invite, self.method(:r_invite)\n\n # Outgoing events\n prepend_handler :outgoing_begin_connection, self.method(:out_begin_connection)\n end",
"def define_handler(*extensions, &block)\n @handlers += extensions.map { |ext| [ext, block] }\n end",
"def add_handlers\n #endofmotd\n @bot.on Cinch::Constants::RPL_ENDOFMOTD do |event|\n handle_endofmotd event\n end\n\n @bot.on :privmsg do |event|\n handle_privmsg event\n end\n\n @bot.on :action do |event|\n handle_action event\n end\n\n @bot.handlers.each do |handler|\n handler.instance_eval do\n @execute_in_callback = false\n end\n end\n end",
"def register_handler(queues, opts={}, handler=nil, &block) #:nodoc:\n Array(queues).each do |queue|\n @handlers[queue] = [opts.symbolize_keys, handler || block]\n end\n end",
"def define_handler(*extensions, &block)\n Figgy::Root.handlers += extensions.map { |ext| [ext, block] }\n end",
"def set_message_handler(&block); end",
"def add_handler(handler)\n domains = handler.listen_to_domains\n domains = [domains] if domains.is_a?(String)\n\n domains.each do |domain|\n @maps[domain] ||= []\n @maps[domain].push(handler)\n @maps[domain] = @maps[domain].uniq\n end\n end",
"def handle(handler, *guards, &block)\n client.register_handler handler, *guards, &block\n end",
"def set_message_handler &block\n @message_handler = block\n end",
"def add_handler(new_handler)\n @handlers.push(new_handler)\n end",
"def _handlers\n @handlers ||= {}\n end",
"def setup_handlers\n # Discord will contact us with HELLO first, so we don't need to hook into READY\n @websocket.on(:message, &method(:handle_message))\n @websocket.on(:close, &method(:handle_close))\n\n # Setup payload handlers\n on(:DISPATCH, &method(:handle_dispatch))\n on(:HEARTBEAT, &method(:handle_heartbeat))\n on(:RECONNECT, &method(:handle_reconnect))\n on(:INVALID_SESSION, &method(:handle_invalid_session))\n on(:HELLO, &method(:handle_hello))\n on(:HEARTBEAT_ACK, &method(:handle_heartbeat_ack))\n on(:READY, &method(:handle_ready))\n end",
"def handlers\n @handlers ||= {}\n end",
"def handlers\n @handlers ||= Hash.new do |hash, key|\n if key.nil?\n raise NoHandler\n else\n raise InvalidHandler, key\n end\n end\n end",
"def handle_messages(&handler)\n raise NotImplementedError\n end",
"def register_handler\n @register_handler ||= Justdi::RegisterHandler\n end",
"def register_signal_handlers\n end",
"def on_message_call handler\n @@handler_symbol = handler\n end",
"def register_signal_handlers\n HANDLED_SIGNALS.each do |sig|\n if ::Signal.list.include? sig.to_s\n trap(sig) { Thread.main[:signal_queue] << sig ; notice_signal }\n end\n end\n end",
"def handlers_start(handler_count)\n end",
"def add_handler(name, handler)\n subscribe(name)\n subscriptions[name].handlers << handler\n end",
"def __handlers\n @__handlers ||= Hash.new([])\n end",
"def register_handler(action, &handler)\n @actions[action] = [] if @actions[action].nil?\n @actions[action] << handler\n end",
"def make_handlers(*args)\r\n make :handler, *args\r\n end",
"def add_default_handlers\n # Puts (for debugging)\n @handlers[\"#{NAMESPACE}.puts\"] = Proc.new { |dialog, *arguments|\n puts(*arguments.map { |argument| argument.inspect })\n }\n RESERVED_NAMES << \"#{NAMESPACE}.puts\"\n\n # Error channel (for debugging)\n @handlers[\"#{NAMESPACE}.error\"] = Proc.new { |dialog, type, message, backtrace|\n Utils.log_error(type + ': ' + message, {:language => 'javascript', :backtrace => backtrace})\n }\n RESERVED_NAMES << \"#{NAMESPACE}.error\"\n end",
"def add_hook_handlers(handler_hash)\n handler_hash.each do |hook, handlers|\n Array(handlers).each { |handler| on(hook, handler) }\n end\n end",
"def handlers\n @handlers ||= Set.new\n end",
"def register(*args, &block)\n h = Unobservable.handler_for(*args, &block)\n @handlers << h\n return h\n end",
"def register_handlers\n @driver.on(:open, &method(:on_open))\n @driver.on(:message, &method(:on_message))\n @driver.on(:close, &method(:on_close))\n end",
"def accept handlers, block\n begin\n receive do |msg|\n begin\n if block\n hname = '<block>'\n block.call msg\n next # skip other handlers\n end\n\n handlers.each do |h|\n hname = h.class.to_s\n h.handle msg\n end\n rescue => e\n puts \"Handler error (#{hname}): #{e.message}\"\n end\n end\n rescue Interrupt, SystemExit\n return\n rescue Huck::Error\n raise\n rescue => e\n puts \"Receiver error (#{self.class}): #{e.message}\"\n puts \"Retrying in 5s...\"\n sleep 5\n retry\n end\n end",
"def register_handler(extensions, handler_class)\n extensions.each do |ext|\n handlers[/\\.#{ext}$/i] = handler_class\n end\n known_extensions.concat extensions\n end",
"def initialize_handler_enums\n ContainerInstanceHandler.renew\n DigitalObjectHandler.renew\n SubjectHandler.renew\n end",
"def add_handler(handler)\n h, options = *(handler.is_a?(Array) ? handler : [handler, {}])\n name = coerce_handler(h)\n global_opts = { output: @output, config: @config }\n opts = global_opts.merge(options)\n ready_handler = name.new(opts)\n @ready_handlers << ready_handler\n end",
"def on_message(&handler)\n @on_message_handler = handler\n end",
"def handlers=(handlers)\n @handlers = handlers.dup\n end",
"def add_custom_handlers\n # Set up hooks\n @irc.on_msg self.method(:_in_msg)\n @irc.on_act self.method(:_in_act)\n @irc.on_invite self.method(:_in_invited)\n @irc.on_kick self.method(:_in_kick)\n @irc.saying_join self.method(:_out_join)\n end",
"def __set_handler(handler)\n @__handler = handler\n end",
"def initialize_inbound_handlers\n\t\t@inbound_handlers = []\n\tend",
"def handler(name, handler)\n # Construct an instance, if the handler is a class and needs to be initialized.\n handler = handler.new\n\n # Make sure it quacks like a handler.\n unless handler.respond_to?(:generate) && handler.respond_to?(:parse)\n raise ArgumentError, \"Media type handlers must respond to #generate and #parse\"\n end\n\n # Register that thing!\n @handlers[name.to_s] = handler\n end",
"def handler\n @handler ||= MailboxHandler.new(@mailbox, imap)\n end",
"def add_handler(opts={})\n return if not payload_instance\n return if not handler_enabled?\n payload_instance.add_handler(opts)\n end",
"def setup_signal_handlers\n # The Module declaration here will only close over local variables so we\n # need to assign self to a local variable to get access to the agent itself.\n clazz = self\n\n EM.attach(@signal_handler_pipe_reader, Module.new {\n define_method :receive_data do |_|\n\n handlers = clazz.instance_variable_get(:@signal_handlers)\n queue = clazz.instance_variable_get(:@signal_handler_queue)\n signal = queue.pop\n\n clazz.send(:logger).debug { \"Running signal handlers for: #{signal}\" }\n handlers[signal].each { |handler| handler.call(signal) }\n end\n })\n end",
"def handlers; end",
"def handlers; end",
"def handlers; end",
"def add_handler(opts={})\n end",
"def regist(event, handler)\n @events[event] ||= []\n @events[event] << handler\n end",
"def clear\n @handlers.clear\n end",
"def register(event_ids, handler_object = nil, &handler_proc)\n handler = handler_proc || handler_object\n\n if handler.nil? || !handler.respond_to?(:call)\n raise ArgumentError, \"Please pass either an object#call or a handler block\"\n end\n\n Array(event_ids).flatten.each do |id|\n @handlers[\n @resolver.transform(id).to_s\n ] << handler\n end\n\n nil\n end",
"def on(name, &block)\n @handlers[name.to_s] = block\n end",
"def register_handler_namespace(type, ns); end",
"def register_message_decoders(&block)\n\n # Create the message decoder context and register all the message decoders to the environment context message handler.\n ctx = MessageDecoderContext.new $ctx.message_handler \n block.call ctx \nend",
"def setup_legacy_handling\n ###\n # Simple counters for basic testing of successful handler registration\n ###\n\n @msg = Hash.new(0)\n @yail.prepend_handler(:incoming_welcome) { |text, args| @msg[:welcome] += 1 }\n @yail.prepend_handler(:incoming_endofmotd) { |text, args| @msg[:endofmotd] += 1 }\n @yail.prepend_handler(:incoming_notice) { |f, actor, target, text| @msg[:notice] += 1 }\n @yail.prepend_handler(:incoming_nick) { |f, actor, nick| @msg[:nick] += 1 }\n @yail.prepend_handler(:incoming_bannedfromchan) { |text, args| @msg[:bannedfromchan] += 1 }\n @yail.prepend_handler(:incoming_join) { |f, actor, target| @msg[:join] += 1 }\n @yail.prepend_handler(:incoming_mode) { |f, actor, target, modes, objects| @msg[:mode] += 1 }\n @yail.prepend_handler(:incoming_msg) { |f, actor, target, text| @msg[:msg] += 1 }\n @yail.prepend_handler(:incoming_act) { |f, actor, target, text| @msg[:act] += 1 }\n @yail.prepend_handler(:incoming_ctcp) { |f, actor, target, text| @msg[:ctcp] += 1 }\n @yail.prepend_handler(:incoming_ping) { |text| @msg[:ping] += 1 }\n @yail.prepend_handler(:incoming_quit) { |f, actor, text| @msg[:quit] += 1 }\n @yail.prepend_handler(:outgoing_mode) { |target, modes, objects| @msg[:o_mode] += 1 }\n @yail.prepend_handler(:outgoing_join) { |channel, pass| @msg[:o_join] += 1 }\n\n ###\n # More complex handlers to test parsing of messages\n ###\n\n # Channels list helps us test joins\n @channels = []\n @yail.prepend_handler(:incoming_join) do |fullactor, actor, target|\n @channels.push(target) if @yail.me == actor\n end\n\n # Gotta store extra info on notices to test event parsing\n @notices = []\n @yail.prepend_handler(:incoming_notice) do |f, actor, target, text|\n @notices.push({:server => f, :nick => actor, :target => target, :text => text})\n end\n\n @yail.prepend_handler(:incoming_ping) { |text| @ping_message = text }\n @yail.prepend_handler(:incoming_quit) { |f, actor, text| @quit = {:full => f, :nick => actor, :text => text} }\n @yail.prepend_handler(:outgoing_join) {|channel, pass| @out_join = {:channel => channel, :password => pass} }\n @yail.prepend_handler(:incoming_msg) {|f, actor, channel, text| @privmsg = {:channel => channel, :nick => actor, :text => text} }\n @yail.prepend_handler(:incoming_ctcp) {|f, actor, channel, text| @ctcp = {:channel => channel, :nick => actor, :text => text} }\n @yail.prepend_handler(:incoming_act) {|f, actor, channel, text| @act = {:channel => channel, :nick => actor, :text => text} }\n end",
"def handle(signature, callback = nil, &bl)\n if signature.is_a?(Array)\n signature.each { |s| handle(s, callback, &bl) }\n return self\n end\n @handlers[signature] = callback unless callback.nil?\n @handlers[signature] = bl unless bl.nil?\n self\n end",
"def handlers_set\n handlers.reject{|sym, handler| handler.nil?}\n end",
"def accept_handler(handler)\n #puts \"gazelle #{@handlers.size} loop running\"\n\n @handlers.add handler # add the new gazelle to the set\n @select_handler.rewind # update the enumerator with the new gazelle\n\n # If a gazelle dies or shuts down we update the set\n handler.finally do\n @handlers.delete handler\n @select_handler.rewind\n\n if @status == :running && @handlers.size == 0\n # I assume if we made it here something went quite wrong\n squash\n end\n end\n end",
"def set_handler(name,type,method)\n raise \"type must be one of #{@handlers.keys}\" unless @handlers.keys.include?(type)\n Log.log.debug(\"setting #{type} handler for #{name}\")\n @handlers[type][name]=method\n end",
"def register(name, &block)\n\n # Create the message decoder and register it to the handler.\n decoder = ProcMessageDecoder.new block\n @handler.register_decoder name, decoder\n end",
"def register_message_bus\n @message_bus_listeners = []\n subscriptions = self.class.instance_variable_get :@message_bus_subscriptions\n subscriptions ||= []\n\n subscriptions.each do |subscription|\n @message_bus_listeners << Volt.current_app.message_bus.on(subscription[:event]) do |*params|\n case subscription[:callback]\n when Symbol\n send(subscription[:callback])\n when Proc\n instance_eval(&subscription[:callback])\n end\n end\n end\n end",
"def execute_handlers\n @@handlers.each { |handler| handler.execute }\n end",
"def add_handler(type, callable=nil, &b)\n callable = callable(callable, b)\n regex = regex_for(type)\n sync do\n id = @handler_serial+=1\n handlers << [id, regex, callable]\n id\n end\n end",
"def set_handler(h, callback)\n\t\t@handler[h] = callback\n\tend",
"def register_message_encoders(&block)\n\n # Create the message decoder context and register all the message decoders to the environment context message handler.\n ctx = MessageEncoderContext.new $ctx.message_handler \n block.call ctx \nend",
"def handle_all_events\r\n @connection.set_generic_handler do |event|\r\n begin\r\n handle_event(event)\r\n rescue => exception\r\n $stderr.puts exception.inspect\r\n $stderr.puts exception.backtrace\r\n end\r\n end\r\n true\r\n end",
"def reset_handlers\n @handlers = nil\n end",
"def register_signal_handlers\n # If we're the parent process, we mostly want to forward the signals on\n # to the child processes. It's just that sometimes we want to wait for\n # them and then exit\n trap('TERM') do\n contention_aware_handler { stop!('TERM', in_signal_handler=true); exit }\n end\n trap('INT') do\n contention_aware_handler { stop!('INT', in_signal_handler=true); exit }\n end\n safe_trap('HUP') { sighup_handler.call }\n safe_trap('QUIT') do\n contention_aware_handler { stop!('QUIT', in_signal_handler=true); exit }\n end\n safe_trap('USR1') do\n contention_aware_handler { stop!('KILL', in_signal_handler=true) }\n end\n begin\n trap('CONT') { stop('CONT', in_signal_handler=true) }\n trap('USR2') { stop('USR2', in_signal_handler=true) }\n rescue ArgumentError\n warn 'Signals USR2, and/or CONT not supported.'\n end\n end",
"def unregister(client_id, message_handlers, options={})\n # Important internal note for qeemono developers:\n # Clients must not be unassigned from their modules when message handlers,\n # having these modules, are unregistered!\n # The one has nothing to do with the other!\n\n receiver = receiver(client_id)\n message_handler_names = []\n message_handlers = [message_handlers] unless message_handlers.is_a? Array\n message_handlers.each do |message_handler|\n if !message_handler.is_a?(Qeemono::MessageHandler::Base)\n # If it's not a message handler object it's probably\n # a full-qualified message handler name (see fq_name)...\n message_handler = @registered_message_handlers_by_fq_name[message_handler.to_sym]\n end\n if !message_handler.is_a?(Qeemono::MessageHandler::Base)\n # Still not a message handler object...? => Error\n notify(:type => :error, :code => 5040, :receivers => receiver, :params => {:message_handler => message_handler.inspect})\n else\n handled_methods = message_handler.handled_methods || []\n handled_methods = [handled_methods] unless handled_methods.is_a? Array\n handled_methods.each do |method|\n @registered_message_handlers_for_method[method.to_sym].delete(message_handler) if @registered_message_handlers_for_method[method.to_sym]\n @registered_message_handlers.delete(message_handler)\n @registered_message_handlers_by_fq_name.delete(message_handler.fq_name)\n end\n message_handler_names << message_handler.name.to_s\n end\n end\n notify(:type => :debug, :code => 5020, :receivers => receiver, :params => {:amount => message_handler_names.size, :message_handler_names => message_handler_names.inspect})\n notify(:type => :debug, :code => 5030, :receivers => receiver, :params => {:amount => @registered_message_handlers.size})\n end",
"def set_default_handler(name)\n @default_handler = name\n end",
"def all_handlers_for(event_type, source_name)\n handlers_for(event_type, source_name) + handlers_for(event_type, nil)\n end",
"def register(event = nil, &handler)\r\n \r\n @handler = handler\r\n @event_type = event\r\n \r\n @event_type = :any unless event\r\n \r\n if @event_type == :any\r\n handler.instance_eval(&handler)\r\n end\r\n \r\n end",
"def reset_signal_handlers\n Signal.list_trappable.each_key do |signal|\n begin\n prev_handler = trap(signal, DEFAULT)\n if prev_handler != DEFAULT\n @previous_signal_handlers[signal] = prev_handler\n end\n rescue ArgumentError\n # Signal cannot be trapped; ignore it.\n end\n end\n trap('HUP', IGNORE)\n PhusionPassenger.call_event(:after_installing_signal_handlers)\n end",
"def start_handler\n # we're just pretending to be a handler\n end",
"def handlers_idx; end",
"def run!\n before_run\n\n HANDLER_CALLS.each { |c|\n if (h = @handlers[c])\n send(c, *(h.opts)) do |obj|\n h.call(obj)\n end\n end\n }\n\n after_run\n end",
"def run!\n before_run\n\n HANDLER_CALLS.each { |c|\n if (h = @handlers[c])\n send(c, *(h.opts)) do |obj|\n h.call(obj)\n end\n end\n }\n\n after_run\n end",
"def scheme_handlers=(scheme_handlers); end",
"def add_handler_class handler_class\n unless (handler_class.is_a? Class) && (handler_class <= RubyArchive::Handler)\n raise TypeError, \"#{handler_class} is not a RubyArchive::Handler\"\n end\n @@archive_handlers << handler_class\n true\n end",
"def register_handler_obj(obj)\n @handler_ctx = obj\n end",
"def pre_hook_send(handler); end",
"def prepend_handler(event, *procs)\n raise \"Cannot change handlers while threads are listening!\" if @ioloop_thread\n\n # See if this is a word for a numeric - only applies to incoming events\n if (event.to_s =~ /^incoming_(.*)$/)\n number = @event_number_lookup[$1].to_i\n event = :\"incoming_numeric_#{number}\" if number > 0\n end\n\n @handlers[event] ||= Array.new\n until procs.empty?\n @handlers[event].unshift(procs.pop)\n end\n end",
"def accept(handler, *params)\n @streamhosts = @iq.streamhosts\n @streamhosts.delete_if {|s| begin IPAddr.new(s.host).private? rescue false end } unless @allow_private_ips\n @socket_address = Digest::SHA1.hexdigest(\"#{@iq.sid}#{@iq.from}#{@iq.to}\")\n\n @handler = handler\n @params = params\n\n connect_next_streamhost\n @stream.clear_handlers :s5b_open, :from => @iq.from\n end",
"def lock!\n @handlers.freeze\n end",
"def <<(command_handler)\n command_handler.commands.each do |command|\n @commands[command] = command_handler\n end\n end",
"def handle\n @queue << \"handle\"\n end",
"def start_handler\n end",
"def msgHandler()\n\tSTDOUT.puts \"WRITING\"\n\tloop do\n\t\t$semaphore.synchronize {\n\t\t\t$socketBuf.each do |socket, str|\n\t\t\t\tstr = str.strip()\n\t\t\t\targs = str.split(\" \")\n\t\t\t\tcmd = args[0]\n\t\t\t\tdestNode = args[1]\n\t\t\t\tcase (cmd)\t\t\n\t\t\t\t#Acknowledgements\n\t\t\t\twhen \"APPLYEDGE\"; handleEntryAdd(socket,destNode)\n\t\t\t\telse STDOUT.puts \"ERROR: INVALID COMMAND \\\"#{cmd}\\\"\"\n\t\t\t\tend\n\t\t\tend\n\t\t}\n\tend\nend",
"def on_message(&processor_block)\n raise \"Message processor already registered\" if @message_processor\n @message_processor = processor_block\n end",
"def listen_requests(handler)\n loop do\n message = handler.listen # expecting array\n command_data = message[0] if message != nil\n\n if command_data != nil && command_data != \"\"\n command = command_data.split(\"\\s\")[0]\n if command == \"close\" || command == \"quit\"\n remove_client(handler) # when client disconnects or closes communication\n elsif command == \"clients\"\n handler.send(\"Server has #{@@clients.length()} clients connected :D\")\n elsif command == \"server -v\"\n handler.send(\"Your SERVER VERSION is #{SERVER_VERSION} ;)\")\n else # if isn't a server request, let the client handler manage it\n handler.manage_requests(message)\n end\n end\n end\n end",
"def register_signal_handlers\r\n\t\t\ttrap('TERM') { shutdown! }\r\n\t\t\ttrap('INT') { shutdown! }\r\n\r\n\t\t\tbegin\r\n\t\t\t\ttrap('QUIT') { shutdown }\r\n\t\t\trescue ArgumentError\r\n\t\t\tend\r\n\t\tend",
"def receives_messages\n Messenger.resolve(@@default_messenger).add_message_handler do |message|\n new.received(message)\n end\n end",
"def default_handler\n @default_handler\n end",
"def start_handler\n\tend",
"def register( *objects )\n objects.each do |object|\n append_hook( :owner => object, \n :trigger => YesTrigger.new, \n :action => MethodAction.new(:handle) )\n end\n end",
"def fregister(message_type, message_subtype = nil, &listener)\n _register(message_type, message_subtype , Funnel.wrap(listener))\n end"
] |
[
"0.7107442",
"0.7007717",
"0.699381",
"0.6832381",
"0.6692404",
"0.6556771",
"0.6504314",
"0.6460172",
"0.63218206",
"0.6253323",
"0.62477714",
"0.6231994",
"0.620173",
"0.6184407",
"0.6158149",
"0.61345863",
"0.6126857",
"0.61178595",
"0.6112451",
"0.60783076",
"0.60772026",
"0.607308",
"0.6049871",
"0.6037754",
"0.60112554",
"0.5987306",
"0.5984148",
"0.59730506",
"0.59545034",
"0.5940892",
"0.5939801",
"0.5925165",
"0.59027624",
"0.5891451",
"0.5815104",
"0.5765993",
"0.573455",
"0.57235986",
"0.5713219",
"0.5709871",
"0.5697476",
"0.56532985",
"0.5628812",
"0.5594173",
"0.5585614",
"0.5577906",
"0.55715424",
"0.55274016",
"0.55147606",
"0.55147606",
"0.55147606",
"0.5511768",
"0.5506301",
"0.5500141",
"0.5487043",
"0.54530317",
"0.5435152",
"0.54290736",
"0.5368632",
"0.53634244",
"0.531455",
"0.529207",
"0.5289099",
"0.52782965",
"0.5277819",
"0.52749026",
"0.5260532",
"0.52585334",
"0.52454495",
"0.52424896",
"0.52150625",
"0.51647216",
"0.5159295",
"0.51490927",
"0.5142231",
"0.5134975",
"0.51333266",
"0.5129565",
"0.51286983",
"0.5128591",
"0.5128591",
"0.512167",
"0.509457",
"0.50785613",
"0.5071598",
"0.5066116",
"0.5064166",
"0.50508773",
"0.50427395",
"0.5040233",
"0.50363284",
"0.50234634",
"0.50234175",
"0.50095266",
"0.50089675",
"0.5007966",
"0.5006631",
"0.5005469",
"0.50036097",
"0.49992755"
] |
0.69780576
|
3
|
Run the bot This can be done in a blocking or nonblocking way if verify is true and threaded is true, the bot will sit and check that it has successfully connected before continuing (and raise an exception on connection failure).
|
def run(threaded=true, verify=true)
$log.info "Starting IRC Bot..."
if threaded then
# Run the bot.
@thread = Thread.new do
$log.info "Bot thread started."
@bot.start
end
# Wait for it to connect
if verify then
delay = 0
while(not @bot.connected? and delay < @config[:connect_timeout]) do
sleep(0.5)
delay += 0.5
end
raise "Bot timed out during first connect." if(delay >= @config[:connect_timeout])
end
else
@bot.start
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def run(async = false)\n @bot.run(async)\n end",
"def run\n @bot.run\n end",
"def run\n Telebot::Bot.new(@token).run do |chat, message|\n if block_given?\n yield(chat, message)\n elsif !chat.nil?\n id = message.chat.id\n if id.positive?\n post(\n message.chat.id,\n \"This is your chat ID: `#{message.chat.id}`.\"\n )\n end\n end\n end\n rescue Net::OpenTimeout\n retry\n end",
"def run_async\n # Handle heartbeats\n @heartbeat_interval = 1\n @heartbeat_active = false\n @heartbeat_thread = Thread.new do\n Thread.current[:discordrb_name] = 'heartbeat'\n loop do\n if @heartbeat_active\n send_heartbeat\n sleep @heartbeat_interval\n else\n sleep 1\n end\n end\n end\n\n @ws_thread = Thread.new do\n Thread.current[:discordrb_name] = 'websocket'\n\n # Initialize falloff so we wait for more time before reconnecting each time\n @falloff = 1.0\n\n loop do\n @should_reconnect = true\n websocket_connect\n\n break unless @should_reconnect\n\n if @reconnect_url\n # We got an op 7! Don't wait before reconnecting\n LOGGER.info('Got an op 7, reconnecting right away')\n else\n wait_for_reconnect\n end\n\n # Restart the loop, i. e. reconnect\n end\n\n LOGGER.warn('The WS loop exited! Not sure if this is a good thing')\n end\n\n debug('WS thread created! Now waiting for confirmation that everything worked')\n sleep(0.5) until @ws_success\n debug('Confirmation received! Exiting run.')\n end",
"def run_bot\n $bot.run(true)\n trap(\"INT\") { shutdown }\n leave_unknown_servers\n log(\"Bot connected to servers: #{$bot.servers.map{ |id, s| s.name }.join(', ')}.\")\nrescue => e\n fatal(\"Failed to execute bot: #{e}\")\n exit\nend",
"def run\r\n\r\n #############\r\n # INIT \r\n begin\r\n $ts = Teamspeak::Client.new IP, 10011\r\n $ts.login(LOGIN, PW)\r\n $ts.command('use', port: 10045)\r\n puts 'Connection successful!'\r\n rescue\r\n puts '[ERROR] problem connecting to server!'\r\n raise 'use'\r\n end\r\n begin \r\n bot_id = $ts.command('clientgetids', cluid: 'oszwEVqrBO1dCX89xIK95x6bHXE=')\r\n $ts.command('clientupdate', clid: bot_id['clid'], client_nickname: NAME)\r\n puts 'Clientupdate successful!'\r\n rescue\r\n puts '[ERROR] problem with \\'clientgetids\\' and/or clientupdate!'\r\n raise 'clientupdate'\r\n end\r\n puts 'INIT successful!'\r\n #############\r\n \r\n loop do\r\n puts 'running check...'\r\n check\r\n sleep $sleep_time\r\n \r\n# #$sleep_time = 60 #debug\r\n# puts 'next check in ' + ($sleep_time / 60.0).to_s + 'min.'\r\n# \r\n# #for stopping loop\r\n# for t in 1..($sleep_time / 30)\r\n# ready_fds = select [ $stdin ], [], [], 30\r\n# s = ready_fds.first.first.gets unless ready_fds.nil?\r\n# if s != nil\r\n# #$ts.disconnect\r\n# raise 'exit' if s.chomp == 'exit'\r\n# raise 'inspect' if s.chomp == 'inspect'\r\n# break if s == \"\\n\" \r\n# end\r\n# \r\n# if t%2 == 0 # once every minute\r\n# begin\r\n# $ts.command('whoami')\r\n# print '.'\r\n# rescue\r\n# sleep 5\r\n# begin\r\n# ts.disconnect\r\n# ts.login(LOGIN, PW)\r\n# bot_id = $ts.command('clientgetids', cluid: 'oszwEVqrBO1dCX89xIK95x6bHXE=')\r\n# $ts.command('clientupdate', clid: bot_id['clid'], client_nickname: NAME)\r\n# print 'o'\r\n# rescue\r\n# print 'x'\r\n# end\r\n# end\r\n# end\r\n# end\r\n# puts\r\n end\r\nend",
"def run\n until @socket.eof? do\n line = @socket.gets\n\n # Makes sure your bot doesn't timeout!\n if line.match(PING_MSG)\n say \"PONG #{ $~[1]}\"\n else\n bot_main(line)\n end\n end\n end",
"def run\n connect = false\n until connect do\n begin\n call { |server| @server = server ; start }\n rescue\n Waves::Logger.error e.to_s\n sleep 1\n end\n connect = true\n end\n end",
"def run_async\n @ws_thread = Thread.new do\n Thread.current[:discordrb_name] = 'websocket'\n connect_loop\n LOGGER.warn('The WS loop exited! Not sure if this is a good thing')\n end\n\n LOGGER.debug('WS thread created! Now waiting for confirmation that everything worked')\n loop do\n sleep(0.5)\n\n if @ws_success\n LOGGER.debug('Confirmation received! Exiting run.')\n break\n end\n\n if @should_reconnect == false\n LOGGER.debug('Reconnection flag was unset. Exiting run.')\n break\n end\n end\n end",
"def run\n begin\n @socket = TCPSocket.open(server, port)\n rescue => e\n puts \"An error occurred: #{e.message}\"\n exit 1\n end\n\n send 'USER ruben 0 * :Ruben'\n send \"NICK #{@nick}\"\n send \"JOIN ##{@channel}\"\n\n listen until @socket.eof?\n end",
"def run\n # Include all handlers now.\n Dir['./handlers/*.rb'].sort.each do |file|\n require file\n end\n\n @config.bots.each do |bot_id, bot_data|\n conn = DiscordConnection.new(bot_data)\n\n conn.connection_id = bot_id\n\n conn.message do |msg|\n next unless @config.discord.allowed_channel_types.include?(msg.channel.channel_type)\n\n if (prefix = check_prefix(msg.text))\n CommandDispatcher.handle prefix, msg\n else\n @handlers.each do |handler|\n break if handler.call(msg) == true\n end\n end\n end\n\n conn.mention do |msg|\n next unless @config.discord.allowed_channel_types.include?(msg.channel.channel_type)\n next if msg.content.match? /^(\\.|\\!)(a|d|add_|del_|delete_|remove_|count_)?q(uote|s|uotes|uote_count)?\\b/\n next unless msg.content.present?\n next if bot_data.client_type == :user\n\n msg.send_message \"#{msg.message.author.mention}, please type `.help` if you would like to learn more about my functions!\"\n end\n\n @connections.push conn\n conn.connect\n end\n\n SweetieBot.log \"Made #{@connections.length} connection#{@connections.length > 1 ? 's' : ''}.\"\n SweetieBot.log 'Ready!'\n\n # keep the main thread alive\n loop do\n if @should_stop\n stop!\n exit\n end\n\n sleep 1\n end\n end",
"def start\n @client = ::Slack::RealTime::Client.new(token: @token)\n @running = true\n\n client.on :open do |event|\n @connected = true\n log \"connected to '#{team_name}'\"\n run_callbacks(:start)\n end\n\n client.on :message do |data|\n begin\n debug message: data\n @last_received_user_message = data\n handle_message(data)\n rescue => e\n log_error e, \"Error handling message #{data.inspect}\"\n end\n end\n\n client.on :close do |event|\n log \"disconnected\"\n @connected = false\n run_callbacks(:finish)\n end\n\n register_low_level_callbacks\n\n client.start_async\n rescue Slack::Web::Api::Error => e\n log \"Connection error for bot #{key}\"\n raise ConnectionError.new(e.message, e.response)\n end",
"def run\r\n Settings::DEFAULT_TRIGGERS.each_key{|k| load_trigger(k, true)}\r\n Settings::TRIGGERS.each_key{|k| load_trigger(k)}\r\n @socket = TCPSocket.open(self.server, self.port)\r\n\r\n $log.info(\"Initiating handshake with server...\")\r\n say \"USER #{nick} 0 * #{nick}\"\r\n say \"NICK #{nick}\"\r\n\r\n until @socket.eof? do\r\n msg = @socket.gets\r\n msg = (msg.split(\" \")[1] == \"PRIVMSG\" ? PrivateMessage.new(msg) : Message.new(msg))\r\n\r\n if msg.type == \"PRIVMSG\"\r\n cache_message(msg)\r\n fire_triggers(msg)\r\n end\r\n\r\n #keep alive\r\n if msg.parts[0] == \"PING\"\r\n say \"PONG :pingis\"\r\n else\r\n case msg.parts[1]\r\n when \"001\"\r\n $log.info(\"Processing connection to server...\")\r\n when \"376\"\r\n $log.info(\"Connected to server, joining channel...\")\r\n join_chan(self.chan)\r\n when \"366\"\r\n @in_chan = true\r\n $log.info(\"Successfully joined ##{self.chan}\")\r\n else\r\n end\r\n end\r\n #output to terminal window whatever the server is giving our socket\r\n $log.info(\"#{msg.stringify}\")\r\n end\r\n end",
"def run\n EventMachine::run do\n @tcp = EventMachine::connect(config.server.host, config.server.port, TCPConnection)\n @tcp.client = self\n spectator_join\n end\n end",
"def run(continuously)\n loop do\n run_bots\n return unless continuously\n sleep 1\n end\n end",
"def run\n\t\t# Empezamos a escuchar al servidor\n\t\tlisten\n\t\t# Empezamos a enviar al servidor\n\t\tsend\n\t\t# Revisamos el estado de la conexion\n\t\t# check_alvie\n\t\t# Al terminar cerramos los Threads\n\t\t@request.join if @request.alive?\n\t\t@response.join if @response.alive?\n\tend",
"def run\n puts \"------------------ NEW TURN ------------------\"\n ask_question\n get_answer\n validate_answer\n end",
"def run\n client.run\n end",
"def run\n if running?\n initialize_protocols\n initialize_threadpool\n initialize_sighandlers\n return true\n else\n fail 'Must run from within reactor'\n end\n end",
"def run\n Thread.start do\n begin\n while true\n main_loop\n end\n ensure\n @protocol.close if @protocol\n end\n end\n end",
"def perform\n puts \"Running...\"\n looping = true\n \n while(looping) do\n @bots.each { |bot|\n has_error = bot.error\n assessment = bot.assess\n if has_error == false && assessment == false\n @an_error_ocurred = true\n puts bot.message\n elsif has_error && assessment\n puts \"\\e[32m\" + bot.referer + \" is back online.\" + \"\\e[0m\"\n end\n }\n if @first_attempt\n if @an_error_ocurred\n puts \"Some services are down. I'll continue monitoring the targets anyway.\"\n else\n puts \"Everything's working fine. I'll continue monitoring the targets.\"\n end\n \n @first_attempt = false\n end\n @total_attempts += 1\n sleep(5)\n end\n \n end",
"def run!\n @thread && @thread.alive? ? @thread : start!\n end",
"def run(options)\n run_with_rescue do\n # ensure the public and log directory are present\n Dir::mkdir(Dir.pwd + PUBLIC_DIR) if not File.directory?(Dir.pwd + PUBLIC_DIR)\n\n # the global watchdog\n $watchdog = Mutex.new\n\n # config file parsing\n return 1 unless Config.instance.load_from_file\n\n # get the external ip address\n $external_address = MyIp.get\n\n # test the connection to the database\n begin\n if database.connect!(component) then\n trace :info, \"Database connection succeeded\"\n else\n trace :warn, \"Database connection failed, using local cache...\"\n end\n\n # cache initialization\n database.cache_init\n\n # wait 10 seconds and retry the connection\n # this case should happen only the first time we connect to the db\n # after the first successful connection, the cache will get populated\n # and even if the db is down we can continue\n if database.agent_signature.nil?\n trace :info, \"Empty global signature, cannot continue. Waiting 10 seconds and retry...\"\n sleep 10\n end\n # do not continue if we don't have the global agent signature\n end while database.agent_signature.nil?\n\n # Retrive the updater signature if needed\n # TODO: this can be removed after version 9.6\n database.updater_signature\n\n # if some instance are still in SYNC_IN_PROGRESS status, reset it to\n # SYNC_TIMEOUT. we are starting now, so no valid session can exist\n EvidenceManager.instance.sync_timeout_all\n\n # enter the main loop (hopefully will never exit from it)\n Events.new.setup\n end\n end",
"def start\n EM.run do\n @running = true\n @bots.each do |key, bot|\n begin\n bot.start\n rescue => e\n log_error(e, \"attempting to start bot #{bot.key}\")\n end\n end\n listen_for_instructions if queue\n end\n end",
"def run\n logger.debug \"[Cottontail] Connecting to client\"\n @client = Bunny.new( *settings(:client) )\n @client.start\n\n logger.debug \"[Cottontail] Declaring exchange\"\n exchange = @client.exchange( *settings(:exchange) )\n\n logger.debug \"[Cottontail] Declaring queue\"\n queue = @client.queue( *settings(:queue) )\n\n routes.keys.each do |key| \n logger.debug \"[Cottontail] Binding #{key.inspect} to exchange\"\n queue.bind( exchange, :key => key )\n end\n\n logger.debug \"[Cottontail] Entering subscribe loop\"\n subscribe! queue\n rescue => e\n @client.stop if @client\n reset!\n\n logger.error \"#{e.class}: #{e.message}\\n\\t#{e.backtrace.join(\"\\n\\t\")}\"\n\n # raise when no retries are defined\n raise( e, caller ) unless settings(:retries)\n\n logger.debug \"[Cottontail] Going to retry in #{settings(:delay_on_retry)} seconds...\"\n sleep settings(:delay_on_retry) if settings(:delay_on_retry)\n retry\n end",
"def run_bot\n return if !ENV['LOOMIO_USER']\n\n # initialize the handler here so that the authentication doesn't have to be repeated\n loomio = LoomioHandler.new()\n\n # start a new thread and run an infinite loop inside it\n #Thread.new do\n loop do\n LogEntry\n .where(loomio_consumed: [false, nil]) # extract all log_entries that haven't been processed yet\n .each { |log_entry|\n process(log_entry, loomio)\n }\n sleep 5 # check for new events every 5 seconds\n end\n #end\nend",
"def new_bot email, password, room\n counter = Thread.new do\n TT.run do\n client = TT::Client.new(email, password, room: room)\n my_bot = Bot.new(client)\n client.on :user_spoke do |message|\n puts \"**** in :user_spoke message: #{message.content}\"\n my_bot.tell(message.content, message.sender) if message.content.split[0] == client.user.name\n end\n client.on :user_entered do |user|\n my_bot.say_hello user\n end\n client.on :song_started do |song|\n my_bot.bop song\n end\n end\n end\nend",
"def run\n connect\n end",
"def verify!\n reconnect! unless active?\n end",
"def run!\n client.on(:hello, &responder.hello)\n client.on(:message, &responder.message)\n client.start!\n end",
"def run()\n login()\n end",
"def run!\n load_settings\n title \"Let's connect your Raspberry Pi to the Particle Cloud!\\n\"\n if keep_credentials\n auth_client\n restore_device_id\n else\n perform_login\n save_credentials\n end\n\n ensure_device_id\n ensure_device_path_exists\n save_device_id\n prompt_device_name\n save_device_name\n generate_device_key\n ensure_server_key_exists\n copy_tinker_firmware\n\n Spinner.show \"Claiming the device to your Particle account\" do\n publish_device_key\n restart_agent\n claim_device\n rename_device\n end\n\n post_install_message\n rescue KeyUpdateError => e\n error \"#{e.message}. Are you sure this device is not owned by another account?\"\n\n rescue ClaimError => e\n error \"Error claiming the device. #{e.message}\"\n\n rescue ProvisioningError => e\n error \"Error getting a device ID. #{e.message}\"\n\n rescue Particle::Error => e\n error \"Particle cloud error. #{e.short_message}\"\n\n rescue Faraday::ClientError\n error \"Network error. Check your internet connection and try again\"\n end",
"def login\n converse_multi_step(connection, conversation,\n speculative_auth_result: speculative_auth_result,\n ).tap do\n unless conversation.server_verified?\n raise Error::MissingScramServerSignature\n end\n end\n end",
"def run\n room = robot.config.adapters.shell.private_chat ? nil : \"shell\"\n @source = Source.new(user: user, room: room)\n puts t(\"startup_message\")\n robot.trigger(:connected)\n\n run_loop\n end",
"def start\n @client.ping\n @state.set :run\n @thread ||= Thread.new{ work_loop }\n end",
"def initialize(env, threaded=false)\n @threaded = threaded\n puts \"Starting up in #{env}!\"\n @tasks = []\n ActiveRecord::Base.connect_to_testbot(env)\n loop\n end",
"def run\n begin\n execute\n say('')\n success \"Done.\"\n rescue CommandAborted, UnrecoverableError => e\n error(e.message)\n exit(255)\n end\n end",
"def work!(robot=nil)\n return if !test? && is_running?\n prepare_robots(robot)\n\n unless cli?\n Celluloid::Actor[:api] = Api.new(self.api_host, self.api_port) if self.use_api\n Celluloid::Actor[:master].start_work\n self.running = true\n sleep # sleep main thread, and let the work commence!\n end\n end",
"def run(*args, &block)\n if EM.reactor_running?\n EM.next_tick do\n EM.synchrony do\n begin\n if args.any?\n # Run the block within a client\n Client.new(*args, &block)\n else\n # Just run the block within a fiber\n block.call\n end\n rescue StandardError => ex\n logger.error(([ex.message] + ex.backtrace) * \"\\n\")\n end\n end\n end\n else\n EM.synchrony { run(*args, &block) }\n end\n end",
"def connect\n begin\n @mSocket = Net::Telnet::new(\"Host\" => @mHostname,\"Port\" => @mPort)\n print(\"addr| \", @mSocket.addr.join(\":\"), \"\\n\")\n print(\"peer| \", @mSocket.peeraddr.join(\":\"), \"\\n\")\n @mSocket.puts \"USER rubybot 0 * Testing\"\n @mSocket.puts \"NICK #{@mNick}\"\n @mSocket.puts \"JOIN #{@mChannel}\"\n @mSocket.puts \"PRIVMSG NickServ identify ruby-bot\"\n\n # Status of -1 is active / connected\n # I know, this doesn't make much sense\n @mStatus = -1\n\n # print the silly message for the lolz\n rubicante_message \n rescue SocketError\n storeDebug(\"can't connect\")\n end\n end",
"def connect\n unless connected?\n hostname = 'api.syncano.com'\n port = 8200\n\n sleep(3)\n\n Thread.new do\n begin\n EM.run do\n EM.connect(hostname, port, Syncano::SyncConnection)\n end\n rescue Exception => e\n p e.message\n p e.backtrace\n end\n end\n\n timeout = 30\n\n while connection.blank? && timeout > 0\n timeout -= 1\n sleep 1\n end\n\n raise ::Syncano::ConnectionError.new('Connection timeout') unless timeout > 0\n\n timeout = 300\n\n while (response = connection.get_response('auth')).blank? && timeout > 0\n timeout -= 1\n sleep 1.0/10.0\n end\n\n raise ::Syncano::ConnectionError.new(response.error) if response.status == 'NOK'\n end\n end",
"def run\n @thread = Thread.start do\n loop do\n begin\n register unless registered?\n rescue DRb::DRbConnError\n @ring_server = nil\n rescue RuntimeError => e\n raise unless e.message == 'RingNotFound'\n end\n sleep @check_every\n end\n end\n end",
"def start_bot\n Telegram::Bot::Client.run(@token) do |bot|\n @bot=bot\n bot.listen do |message|\n @last_message=message\n # print message to terminal for debug\n puts message\n # switch case for different command\n # TODO: extract each command to a new method\n case message.text\n when /\\A\\/start/\n bot.api.send_message(chat_id: message.chat.id, text: \"Hello, #{message.from.first_name}. I am started! >.<\")\n when /\\A\\/stop/\n bot.api.send_message(chat_id: message.chat.id, text: \"Bye, #{message.from.first_name}. Why did you stop me? T^T\")\n when /\\A\\/help/\n bot.api.send_message(chat_id: message.chat.id, text:\n \"/run\\nFormat: /run {code}\\nAvailable method: times, puts, print, each, p \\nExample: \\n/run 3.times{|x| puts x*x}\\n/run puts 'I am a happy little bot.'\\nThis bot is created by @Energy0124. \\nSource code is avaliable here:\\n https://github.com/Energy0124/EnergyRubyTelegramBot.git \")\n # running ruby code on server in a sandbox\n when /\\A\\/run/\n if message.text=~ /\\A\\/run@Energy0124TestBot/\n message.text.slice! '/run@Energy0124TestBot'\n else\n message.text.slice! '/run'\n end\n begin\n # capture the stdout\n stdout=with_captured_stdout {\n s = Sandbox.new\n priv = Privileges.new\n # whitelist some safe method\n priv.allow_const_read *@allowed_const_read\n priv.allow_methods *@allowed_methods\n # eval the ruby code\n s.run(priv, message.text, :timeout => 3)\n }\n # print the stdout\n puts(stdout)\n # send stdout as telegram message\n send_reply(\"Result:\\n#{stdout}\")\n # catch exception\n rescue Exception => ex\n send_reply(\"Error:\\n#{ex}\")\n end\n # for fun\n when /fuck/i\n send_reply(\"I fucking hate people saying 'fuck'.\")\n when /dota/i\n send_reply('Dota is the best!')\n when /stupid bot/i\n send_reply('Still a bit smarter than you :P')\n when /\\A\\/(admin|secret)/i\n send_reply('https://youtu.be/dQw4w9WgXcQ')\n end\n end\n end\n end",
"def loop( &block )\n sanity_check\n @connection.loop(&block)\n end",
"def run\n Pantry.set_proc_title(\"pantry client #{Pantry::VERSION} :: #{identity}\")\n @networking.run\n send_registration_message\n Pantry.logger.info(\"[#{identity}] Client registered and waiting for commands\")\n end",
"def run\n return if halted?\n\n http = request.em\n http.callback {\n Benchy.logger.info \"#{name}\\t| #{request.method.upcase} #{request.url} - HTTP #{http.response_header.status}\"\n run\n }\n http.errback {\n Benchy.logger.error \"#{name}\\t| Connection error!\"\n halt # TODO - Make this fail the ping and try again, not halt\n }\n end",
"def run\n # Run all the steps below. Stop as soon as one of them returns\n # false or throws an error.\n true &&\n fetch_internal_date_and_size &&\n check_for_really_old_internal_date &&\n check_for_pre_creation_internal_date &&\n check_for_relapsed_internal_date &&\n check_for_big_messages &&\n fetch_uid_envelope_rfc822 &&\n update_user_mark_email_processed &&\n handle_tracer_email &&\n check_for_duplicate_message_id &&\n check_for_duplicate_sha1 &&\n create_mail_log &&\n deploy_webhook &&\n update_daemon_stats\n ensure\n clean_up\n end",
"def run\n Lita.logger.debug 'Slack::run started'\n sleep\n rescue Interrupt\n Lita.logger.info 'Slack::shutting down'\n end",
"def verify\n create_order\n start_challenge\n wait_verify_status\n check_verify_status\n rescue Acme::Client::Error => e\n retry_on_verify_error(e)\n end",
"def start!(options = {})\n @client.auth_test if options[:test_authentication]\n\n @client.on :hello do\n @output.puts \"==> Successfully connected as '#{@client.self.name}' to the '#{@client.team.name}' team at https://#{@client.team.domain}.slack.com.\"\n my_channels = channels_i_am_a_member_of\n @output.puts \"==> I'm currently a member of these channels: #{channel_names_with_hash(my_channels)}\" if my_channels.count > 0\n end\n\n @client.on :channel_joined do |e|\n @output.puts \"==> I've joined channel ##{e['channel']['name']}\"\n end\n\n @client.on :channel_left do |e|\n @output.puts \"==> I've left channel ##{@client.channels[e.channel]['name']}\"\n end\n\n @client.on :message do |message_data|\n next if message_data[\"text\"].to_s.empty?\n next if message_originates_from_the_bot? message_data\n next unless message_is_addressed_to_the_bot? message_data\n\n command = get_command_from_incoming_message message_data[\"text\"]\n\n case command.downcase\n when \"help\"\n clean_output = help_information\n else\n clean_output = handle_ri_lookup(command)\n end\n\n @client.message channel: message_data[\"channel\"], text: clean_output\n end\n\n @client.start!\n end",
"def connect!\n # Keep existing connections\n return unless @backend.nil?\n\n @backend = train_connection.connection\n @backend.wait_until_ready\n\n # When the testing function `mock_instance` is used, it will set\n # this instance variable to false and handle this function call\n # after the platform data is mocked; this will allow binding\n # of mixin functions based on the mocked platform.\n mix_in_target_platform! unless @mocked_connection\n rescue Train::UserError => e\n raise ConnectionFailure.new(e, config)\n rescue Train::Error => e\n # These are typically wrapper errors for other problems,\n # so we'll prefer to use e.cause over e if available.\n raise ConnectionFailure.new(e.cause || e, config)\n end",
"def run\n parse_quiz_questions\n\n # First thing to do is to connect to the server\n connect\n\n # Here we keep the connection open, as long as it's not getting closed by the server (that would result in\n # @socket.eof? returning true).\n until @socket.eof? do\n\n # We read the next incoming message from the socket connection.\n message = @socket.gets\n\n # We ouput the message on the terminal, so we can see what our bot's input is.\n puts message\n\n # If the message we are getting is a \"PING\" message...\n if message.start_with?(\"PING\")\n # ...then we need to react to that PING, so as to not get disconnected accidentally.\n handle_ping_message(message)\n\n # If the message is a private message sent inside our channel...\n elsif message.include?(\"PRIVMSG #{@channel}\")\n # ...then we react in some way to that message.\n handle_channel_message(message)\n\n # If we haven't joined our channel yet and the message includes \"MODE\" and the bot's name...\n elsif !@joined && message.include?(\"MODE #{@name}\")\n # ...then the server is ready for us to join the channel.\n irc_send_join(@channel)\n # We set @joined to true, so we don't try to join the channel twice accidentally.\n @joined = true\n end\n end\nend",
"def start\n Thread.new do\n connect = false\n until connect do\n begin\n call do |server| \n @server = server\n Waves::Logger.info \"#{self.class.basename} started on #{host}:#{port}.\"\n end\n rescue RuntimeError => e\n Waves::Logger.error e.to_s\n sleep 1\n end\n connect = true\n end\n end\n end",
"def run\n info \"Run on node: #{node}\"\n self.status = :running\n node.run self\n end",
"def main\n @t.each do \n |line|\n info = grab_info(line) # grabs the info from an PRIVMSG\n STDOUT.puts line, \"\\n\" # puts to the console\n ##\n # An IRC client (a bot is a client) must respond to PINGs from the IRC server.\n # If not, the bot will be kicked.\n pong(line) if line[0..3] == \"PING\"\n if info and info[4] # only called if grabbing the info was successful\n log_it info # logs in a friendly format, in chat.txt\n ##\n # Are there any commands? This bot won't even check for a command unless it starts with a dot (.)\n # and the caller is authorized\n check_for_cmd(info[4], info[0]) if info and info[4] =~ /^\\.(.+)/ and auth(info)\n self.check_for_greet(info[4], info[0]) if info[4].include?(@config[:nick]) # should i respond with a greeting?\n if @config[:mode] == \"trivia\"\n check_answer(info[4], info[0]) # did the user answer correctly?\n end\n end\n end\n end",
"def run\n log.info(\"Running...\")\n result = run_internal()\n log.info(\"Success! #{result.message}\")\n return result\n end",
"def run\n validate\n setup\n before_sync\n sync\n after_sync\n rescue => e\n on_error(e)\n raise e\n end",
"def sit\n\t\twhile connected?\n\t\t\tif block_given?\n\t\t\t\tyield\n\t\t\telse\n\t\t\t\tsleep(0.1)\n\t\t\tend\n\t\tend\n\tend",
"def start\n self.connect\n self.login if @connected\n end",
"def start\n init_client unless @client\n\n log.info 'Bot starting to sync'\n\n @client.start_syncing\n end",
"def run!\n run\n die\n end",
"def perform\n\n handle_errors_and_exceptions do\n\n r = validate\n return r unless r.success?\n\n r = fetch_manager_device\n return r unless r.success?\n\n r = create_device_verification_token\n return r unless r.success?\n\n r = send_device_verification_token\n return r unless r.success?\n\n success\n\n end\n\n end",
"def connect!\n start_em\n @client.ensure_connect\n end",
"def run target, &block\n server = start target, &block\n server.wait_until_stopped\n self\n end",
"def run\n loop {\n # Thread.start -> takes arguments that it yields to block for creating thread\n # # server#accept -> returns a new Socket object and Addrinfo object\n Thread.start(@server.accept) do |client| # each client thread\n nick_name = client.gets.chomp.to_sym\n # check if client connectiont already exists\n @connections[:clients].each do |other_name, other_client|\n if nick_name == other_name || client == other_client\n puts \"This username already exists\"\n Thread.kill self\n end\n end\n puts \"#{nick_name} #{client}\"\n @connections[:clients][nick_name] = client\n client.puts \"Connection established, Thank you for joining! Happy Chatting\"\n # listen for client messages\n listen_for_user_messages(nick_name, client)\n end\n }\n end",
"def run\n load_options\n\n @logger = Logger.new File.join( File.expand_path(@options['logdir']), 'traut.log')\n @logger.level = boolean(@options['debug']) ? Logger::DEBUG : Logger::INFO\n\n ## We start the AMQP connection out here, rather than in Server, to\n ## isolate that code from its specific duties and so that we do not have\n ## to pass extranious configuration details into it.\n amqp = @options['amqp']\n\n AMQP.connect(:host => amqp['host'], :port => amqp['port'], :vhost => amqp['vhost'],\n :username => amqp['username'], :password => amqp['password'], :ssl => {\n :cert_chain_file => amqp['ssl']['cert_chain'],\n :private_key_file => amqp['ssl']['private_key']\n },\n :on_tcp_connection_failure => Proc.new { |settings|\n puts \"TCP Connection failure; details:\\n\\n#{settings.inspect}\\n\\n\"; exit 1\n },\n :on_possible_authentication_failure => Proc.new { |settings|\n puts \"Authentication failure, I'm afraid:\\n\\n#{settings.inspect}\\n\\n\"; exit 1\n }) do |connection|\n @logger.info \"Traut #{Traut::VERSION} started\"\n channel = AMQP::Channel.new(connection)\n exchange = channel.topic(amqp['exchange'] || 'traut')\n\n Traut::Server.new(:channel => channel, :exchange => exchange,\n :events => @options['events'], :log => @logger).run\n end\n end",
"def run\n RightLinkLog.init(@identity, @options[:log_path])\n RightLinkLog.level = @options[:log_level] if @options[:log_level]\n begin\n @serializer = Serializer.new(@options[:format])\n @status_proc ||= lambda { parse_uptime(`uptime 2> /dev/null`) rescue 'no status' }\n pid_file = PidFile.new(@identity, @options)\n pid_file.check\n if @options[:daemonize]\n daemonize(@identity, @options)\n pid_file.write\n at_exit { pid_file.remove }\n end\n @amq = start_amqp(@options)\n @registry = ActorRegistry.new\n @dispatcher = Dispatcher.new(@amq, @registry, @serializer, @identity, @options)\n setup_mapper_proxy\n load_actors\n setup_traps\n setup_queues\n advertise_services\n setup_heartbeat\n at_exit { un_register } unless $TESTING\n start_console if @options[:console] && !@options[:daemonize]\n rescue SystemExit => e\n raise e\n rescue Exception => e\n RightLinkLog.error(\"Agent failed startup: #{e.message}\\n\" + e.backtrace.join(\"\\n\")) unless e.message == \"exit\"\n raise e\n end\n true\n end",
"def connect\n say \"NICK #{@botname}\"\n say \"USER #{@botname} 0 * #{@botname}\"\n say \"JOIN #{@channel}\"\n end",
"def run_em\n if !EM.reactor_running?\n Thread.new {\n EM.run {}\n }\n end \n end",
"def run_tests(sideload_config:)\n telnet_config ={\n 'Host' => @roku_ip_address,\n 'Port' => 8085\n }\n\n loader = Loader.new(**@device_config)\n connection = Net::Telnet.new(telnet_config)\n code, _build_version = loader.sideload(**sideload_config)\n\n if code == SUCCESS\n in_tests = false\n connection.waitfor(@end_reg) do |txt|\n in_tests = handle_text(txt: txt, in_tests: in_tests)\n end\n connection.puts(\"cont\\n\")\n end\n end",
"def run\n tried = false\n \n # Error handler\n begin\n \n # This is where the real work gets done\n yield m\n \n # Catch errors\n rescue => err\n \n # Display error in console\n puts ( error_details = \"#{ err.message }\\n\\n#{ err.backtrace.join($/) }\" )\n \n if tried\n \n # Email failure message if automated\n logerror( \"#{ Time.now }\\n#{ error_details }\" ) if automation && !test\n exit\n \n else\n \n tried = true\n \n # Only retry if automated\n if automation\n retry\n else\n # Only hold the console window open if not automated\n gets\n exit\n end\n \n end # tried\n \n end # errorhandler\n \n if automation\n \n begin\n \n # Send email and log success if automated and successful\n sendmail\n File.write( checkname, today )\n \n # Catch failures like invalid email addresses\n rescue => err\n \n # Display error in console\n puts ( error_details = \"#{ err.message }\\n\\n#{ err.backtrace.join($/) }\" )\n \n # Email failure message\n logerror( \"#{ Time.now }\\n#{ error_details }\" ) if automation && !test\n raise err\n \n end # errorhandler\n \n end # if automation\n \n end",
"def run\n loop do\n # Wait for a client to connect and then create a thread for it\n Thread.new(@server.accept) do |client_socket|\n logger.info \"Accepted client: #{client_socket.peeraddr.join(':')}\"\n server_socket = TCPSocket.new(@server_host, @server_port)\n begin\n process_packets(client_socket, server_socket)\n rescue Exception => exp\n logger.error exp.to_s\n end\n logger.info \"Disconnected: #{client_socket.peeraddr.join(':')}\"\n server_socket.close\n client_socket.close\n end\n end\n end",
"def start\n @client.on :hello do\n puts \"Successfully connected, welcome '#{@client.self.name}' to the '#{@client.team.name}' team at https://#{@client.team.domain}.slack.com.\"\n end\n @client.on :close do |_data|\n puts \"Client is about to disconnect\"\n end\n @client.on :closed do |_data|\n puts \"Client has disconnected successfully!\"\n end\n\n @client.on :message do |data|\n message = data.text\n bot_id = @client.self.id\n if self.needs_help?(message, bot_id)\n @client.message channel: data.channel, text: self.respond_help\n else\n symbol_doc = self.read(message, bot_id)\n if self.must_respond?(symbol_doc)\n if symbol_doc.success\n @client.message channel: data.channel, text: self.respond_ok(symbol_doc)\n else\n if message.split.count > 1\n @client.message channel: data.channel, text: self.respond_error(symbol_doc)\n end\n end\n end\n end\n end\n\n @client.start!\n end",
"def check\n return true if @checked\n @checked = true\n @spam = akismet(:check) || false\n rescue => boom\n logger.error \"An error occured while connecting to Akismet: #{boom.to_s}\"\n @checked = false\n end",
"def run_em_if_necessary!\n require 'eventmachine' unless defined?(EM)\n unless EM.reactor_running?\n Thread.new do\n EM.error_handler{ |e| handle_unexpected_error(e) }\n begin\n EM.run\n rescue Pry::RescuableException => e\n handle_unexpected_error(e)\n end\n end\n end\n sleep 0.01 until EM.reactor_running?\n end",
"def start\n # Synchronous (mutual exclusion) message processing is handled by a\n # producer-consumer approach. The socket pushes messages onto this queue,\n # which are processed by a consumer thread one at a time.\n @messages = Queue.new\n @message_consumer = Thread.new do\n loop do\n meths = @messages.pop\n begin\n meths.each { |meth, args| broadcast_sync meth, *args }\n rescue\n options[:logger].error $!\n end\n end\n end\n \n @socket = connect\n username = @options[:user]\n username ||= @nick\n realname = @options[:name]\n realname ||= @nick\n \n pass @options[:server_password] if @options[:server_password]\n user username, @nick, @nick, realname\n nick @nick\n \n while line = @socket.gets\n meths = receive line # parse the line and get a list of methods to call\n @messages.push meths # push the methods on the queue; the consumer thread will execute all the synchronous methods\n # then execute all the other methods in their own thread\n meths.each { |meth, args| broadcast meth, *args }\n end\n end",
"def run\n initialize_trackers\n @start_time = Time.now\n @client.send(*@message) do |status|\n puts \"#{status.text}\" if $DEBUG\n @trackers.each do |t|\n t.record(status)\n end\n end\n end",
"def run(*args)\n if running?\n Puppet.notice \"Run of #{client_class} already in progress; skipping\"\n return\n end\n if disabled?\n Puppet.notice \"Skipping run of #{client_class}; administratively disabled; use 'puppet agent --enable' to re-enable.\"\n return\n end\n\n result = nil\n block_run = Puppet::Application.controlled_run do\n splay\n with_client do |client|\n begin\n sync.synchronize { lock { result = client.run(*args) } }\n rescue SystemExit,NoMemoryError\n raise\n rescue Exception => detail\n puts detail.backtrace if Puppet[:trace]\n Puppet.err \"Could not run #{client_class}: #{detail}\"\n end\n end\n true\n end\n Puppet.notice \"Shutdown/restart in progress (#{Puppet::Application.run_status.inspect}); skipping run\" unless block_run\n result\n end",
"def start\n Thread.new do\n loop do\n @connection.wait_for_notify do |channel|\n @actions[channel].call\n end\n end\n end\n end",
"def start\n puts 'Booting BubBot'\n Thread.new do\n loop do\n #puts \"Checking for servers to shutdown\"\n # TODO: actually do that ^\n sleep 10# * 60\n end\n end\n\n app = Rack::Builder.new do\n # if development (TODO)\n use Rack::Reloader\n # end\n run BubBot\n end.to_app\n\n Rack::Handler::Thin.run(app, BubBot.configuration.rack_options_hash)\n end",
"def start\n @quit = nil\n @socket = self.connect()\n self.on_message(/^PING/) { |event|\n self.send_raw_line(\"PING \"+event[:matchdata].post_match)\n }\n self.on_server_message(353) { |event|\n }\n self.on_server_message(376) do |event|\n if @password and !@authenticated then\n self.message 'NickServ', \"IDENTIFY #{@password}\"\n @authenticated = true\n end\n @channels.each { |channel|\n if channel.kind_of? Hash then\n self.send_raw_line(\"JOIN \"+channel.keys.first+\" \"+channel.values.first)\n else\n self.send_raw_line(\"JOIN \"+channel)\n end\n }\n end\n \n self.send_raw_line(\"USER \"+@nickname+\" \"+@nickname+\" \"+@nickname+\" \"+@nickname)\n self.send_raw_line(\"NICK \"+@nickname)\n begin\n while line = @socket.gets\n handle_raw_line(line) \n end\n rescue IOError => ioe\n raise ioe unless @quit\n end\n end",
"def run_tests(sideload_config:)\n telnet_config ={\n 'Host' => @roku_ip_address,\n 'Port' => 8085\n }\n\n @device_config[:init_params] = {\n root_dir: @root_dir\n }\n loader = Loader.new(**@device_config)\n connection = Net::Telnet.new(telnet_config)\n code, _build_version = loader.sideload(**sideload_config)\n if code == SUCCESS\n @device_config[:init_params] = nil\n linker = Linker.new(**@device_config)\n linker.launch(options: \"RunTests:true\")\n\n connection.waitfor(@end_reg) do |txt|\n handle_text(txt: txt)\n end\n print_logs\n connection.puts(\"cont\\n\")\n end\n end",
"def connect\n EM.run do\n client = Faye::WebSocket::Client.new(@url)\n reconnect_url = nil\n\n client.on :message do |msg|\n message_received(client, msg)\n end\n\n client.on :open do |e|\n OutputLogger.logger.info 'Connection Opened!'\n end\n\n client.on :close do |e|\n OutputLogger.logger.info 'Connection closed, trying to reconnect.'\n\n reconnect\n end\n\n client.on :error do |e|\n OutputLogger.logger.error e.inspect\n end\n\n client.on 'transport:down' do |e|\n OutputLogger.logger.info 'Connection down.'\n end\n\n client.on 'transport:up' do |e|\n OutputLogger.logger.info 'Connection back up, trying to reconnect.'\n\n reconnect\n end\n end\n end",
"def run\n # UI.message(\"Starting login with user '#{WatchBuild.config[:username]}'\")\n\n ENV['FASTLANE_ITC_TEAM_ID'] = WatchBuild.config[:itc_team_id] if WatchBuild.config[:itc_team_id]\n ENV['FASTLANE_ITC_TEAM_NAME'] = WatchBuild.config[:itc_team_name] if WatchBuild.config[:itc_team_name]\n ENV['FASTLANE_PASSWORD'] = WatchBuild.config[:password] if WatchBuild.config[:password]\n\n build_number = WatchBuild.config[:build_number]\n\n Spaceship::ConnectAPI.login(WatchBuild.config[:username], WatchBuild.config[:password])\n Spaceship::ConnectAPI.select_team\n UI.message('Successfully logged in')\n\n start = Time.now\n build = wait_for_build(start, build_number)\n minutes = ((Time.now - start) / 60).round\n notification(build, minutes)\n end",
"def claim_thread_runner\n while running?\n User.select(:id, :email, :connected_at, :archived).find_each do |user|\n if server_rhash.hash(user.id) == server_tag && !user.archived && user.connected_at\n schedule_work(:connect_user, :hash => user.id, :user_id => user.id)\n else\n schedule_work(:disconnect_user, :hash => user.id, :user_id => user.id)\n end\n\n # Try not to peg the processor.\n sleep 0.01\n end\n light_sleep 10\n end\n rescue Exception => e\n Log.exception(e)\n raise e\n ensure\n Log.info(\"Stopping claim thread.\")\n end",
"def work\n Logger.info \"Starting work...\"\n execute_startup(connections) {|c| c.future.connect}\n execute_startup(devices) {|d| d.future.start_device}\n execute_working_code\n end",
"def setup\n puts \"Starting test\"\n TRConnector.instance.start\n sleep(1)\n end",
"def run\n capture_signals\n load_config\n\n EM.synchrony do\n connect\n start_throttle\n end\n end",
"def run(run_type = :UV_RUN_DEFAULT)\n if @reactor_thread.nil?\n @loop_notify = @loop.defer\n\n begin\n @reactor_thread = Thread.current\n LOOPS[@reactor_thread] = @loop\n if block_given?\n if @@use_fibers\n Fiber.new { yield @loop_notify.promise }.resume\n else\n yield @loop_notify.promise\n end\n end\n ::Libuv::Ext.run(@pointer, run_type) # This is blocking\n ensure\n @reactor_thread = nil\n @run_queue.clear\n end\n elsif block_given?\n if @@use_fibers\n schedule { Fiber.new { yield @loop_notify.promise }.resume }\n else\n schedule { yield @loop_notify.promise }\n end\n end\n @loop\n end",
"def run\n #p @app_settings\n if @app_settings[:log_level] == :develop || \n @app_settings[:log_level] == :develop_withfile\n log_debug\n end\n #puts YAML.dump(@settings_default)\n @join_game = @app_settings[:join_curr_game]\n @game_bot_name = @app_settings[:game_bot_classname]\n # load option on supported games\n load_supported_games\n \n @control_net_conn = ControlNetConnection.new(self)\n @model_net_data = ModelNetData.new\n @model_net_data.add_observer(\"cuperativa_gui\", self)\n @model_net_data.add_observer(\"control_net\", @control_net_conn)\n @control_net_conn.set_model_view(@model_net_data, self)\n # ready to use the model\n @model_net_data.event_cupe_raised(:ev_gui_controls_created)\n \n # connect to the server\n info_conn_hash = {}\n @control_net_conn.prepare_info_conn_hash(info_conn_hash)\n info_conn_hash[:host_server] = @server_ip\n info_conn_hash[:port_server] = @server_port\n info_conn_hash[:login_name] = @login_name\n info_conn_hash[:password_login_md5] = @password_login_md5\n info_conn_hash[:admin_port] = @app_settings[:admin_port]\n info_conn_hash[:ws_prefix] = @app_settings[:ws_prefix]\n \n if @app_settings[:debug_server_messages] == true\n @control_net_conn.server_msg_aredebugged = true\n end\n \n #p info_conn_hash\n #p @app_settings\n @control_net_conn.connect_to_remote_server(info_conn_hash)\n @proc_thread_run = Thread.new{\n begin\n @state_game = :initial\n while @state_game != :end\n # process game\n if @current_game_gfx\n @current_game_gfx.do_core_process\n end\n @control_net_conn.process_next_server_message\n sleep 0.1 #use sleep to avoid cpu overload\n end\n sleep 0.1 #use sleep to avoid cpu overload \n rescue => detail\n @log.error \"Process server message error (#{$!})\\n\"\n @log.error detail.backtrace.join(\"\\n\")\n end\n }\n\n \n end",
"def run\n require 'client'\n\n begin\n client = Client.new params[:address].value, params[:port].value\n puts \"Connected to Chain Reactor server, version #{client.version}\"\n data_input = params[:data].value\n\n if data_input\n client.send(data_input.gets.strip)\n else\n client.send_as_json(get_hash_from_stdin)\n client.close()\n end\n exit_status exit_success\n rescue ClientError => e\n STDERR.puts e.message\n exit_status exit_failure\n rescue SystemExit, Interrupt\n STDERR.puts \"Caught exit signal\" \n exit_status exit_failure\n rescue Exception => e\n STDERR.puts \"An error occured {#{e.class.name}}: #{e.message}\" \n exit_status exit_failure\n end\n end",
"def run\n raise 'Server has shutdown.' unless @server\n @server.run_till_terminated\n @server = nil\n end",
"def run!\n title(label)\n\n inside do\n Strainer.ui.debug \"Running '#{command}'\"\n speak(command)\n defined?(PTY) ? run_as_pty(command) : run_as_system(command)\n\n unless $?.success?\n Strainer.ui.error label_with_padding + Strainer.ui.set_color('Terminated with a non-zero exit status. Strainer assumes this is a failure.', :red)\n Strainer.ui.error label_with_padding + Strainer.ui.set_color('FAILURE!', :red)\n false\n else\n Strainer.ui.success label_with_padding + Strainer.ui.set_color('SUCCESS!', :green)\n true\n end\n end\n end",
"def run\n assign_process_name!\n\n wrap_chain(:start) do\n STDOUT.sync = true\n\n logger.info(\"Engine \\##{id} Running\")\n \n switch_to_effective_user! if (self.class.user)\n\n @state = :running\n end\n end",
"def test_run_block\n assert !EM.reactor_running?\n a = nil\n EM.run_block { a = \"Worked\" }\n assert a\n assert !EM.reactor_running?\n end",
"def run(run_type = :UV_RUN_DEFAULT)\n if not @reactor_running\n begin\n @reactor_running = true\n raise 'only one reactor allowed per-thread' if Thread.current.thread_variable_get(:reactor)\n\n Thread.current.thread_variable_set(:reactor, @reactor)\n @throw_on_exit = nil\n update_time\n @fiber_pool.reset\n @fiber_pool.exec { yield @reactor } if block_given?\n @run_count += 1\n ::Libuv::Ext.run(@pointer, run_type) # This is blocking\n ensure\n Thread.current.thread_variable_set(:reactor, nil)\n @reactor_running = false\n @run_queue.clear\n end\n\n # Raise the last unhandled error to occur on the reactor thread\n raise @throw_on_exit if @throw_on_exit\n\n elsif block_given?\n if reactor_thread?\n update_time\n yield @reactor\n else\n raise 'reactor already running on another thread'\n end\n end\n\n @reactor\n end",
"def attempt_connection\n @connection_future = Concurrent::Future.new do\n connection_method.call\n end\n connection_future.execute\n end",
"def perform\n\n handle_errors_and_exceptions do\n\n r = validate\n return r unless r.success?\n\n r = fetch_client_manager\n return r unless r.success?\n\n r = validate_invitee_manager_exists\n return r unless r.success?\n\n r = create_invite_token\n return r unless r.success?\n\n r = enqueue_job\n return r unless r.success?\n\n success\n\n end\n\n end",
"def perform\n r = validate_and_sanitize\n return r unless r.success?\n\n r = fetch_and_validate_client\n return r unless r.success?\n\n r = fetch_and_validate_admin\n return r unless r.success?\n\n r = extra_validations\n return r unless r.success?\n\n r = fetch_invite_admin\n return r unless r.success?\n\n r = create_invite_token\n return r unless r.success?\n\n send_invite\n\n success_with_data({})\n end",
"def test_connect(standalone = true)\n\tif standalone\n\t start_peers\n\n\t notified = []\n\t local.on_neighbour do |n|\n\t\tnotified << n\n\t end\n\tend\n\n\tassert(local.discovery_thread)\n\n\t# Initiate the connection from +local+\n\tremote_neighbour = local.neighbours.find { true }\n\tengine.execute do\n\t did_yield = nil\n\t Peer.initiate_connection(local, remote_neighbour) do |did_yield|\n\t end\n\n\t # Wait for the remote peer to take into account the fact that we\n\t # try connecting\n\t local.synchronize do\n\t\tremote_id = remote_neighbour.remote_id\n\t\tassert(local.pending_connections[remote_id] ||\n\t\t local.peers[remote_id])\n\t end\n\n\t sleep(1)\n\t local.synchronize do\n\t\tremote_id = remote_neighbour.remote_id\n\t\tassert(@remote_peer = local.peers[remote_id], local.peers)\n\t\tassert_equal(remote_peer, did_yield)\n\t end\n\t assert(remote_peer.connected?)\n\t assert(remote.send_local_peer(:connected?))\n\t assert(remote_peer.link_alive?)\n\t assert(remote.send_local_peer(:link_alive?))\n\n\t did_yield = nil\n\t Peer.initiate_connection(local, remote_neighbour) do |did_yield|\n\t end\n\t assert_equal(remote_peer, did_yield)\n\t assert_equal(remote_peer, Peer.connect(remote_neighbour))\n\tend\n\n\tengine.wait_one_cycle\n\tassert(remote_peer.task.running?)\n\t#assert_raises(ArgumentError) { Peer.initiate_connection(local, remote_neighbour) }\n\tassert(remote_peer.link_alive?)\n\n\tremote_peer.synchro_point\n\tassert(remote_peer.connected?)\n\tassert(remote_peer.task.ready?)\n\n\tassert_equal('remote', remote_peer.remote_name)\n\tassert_equal('remote', remote_peer.local_server.remote_name)\n\tassert_equal('local', remote_peer.local_server.local_name)\n\n\tif standalone\n\t assert_equal(1, notified.size)\n\t assert_equal([remote_neighbour], notified)\n\tend\n end"
] |
[
"0.64450514",
"0.6265872",
"0.62259525",
"0.6147667",
"0.61247224",
"0.6115461",
"0.5882167",
"0.5845172",
"0.58262604",
"0.5772978",
"0.5741848",
"0.56309247",
"0.56008327",
"0.5597614",
"0.55508184",
"0.550517",
"0.5467129",
"0.5466942",
"0.5432297",
"0.54012644",
"0.53977776",
"0.53958946",
"0.53868735",
"0.53836656",
"0.5368094",
"0.5362528",
"0.53438526",
"0.5316859",
"0.526594",
"0.5239846",
"0.5234358",
"0.5227776",
"0.5226523",
"0.5225636",
"0.5220167",
"0.5216931",
"0.52039",
"0.5202809",
"0.5198659",
"0.5196132",
"0.5190707",
"0.5181348",
"0.51708496",
"0.5159191",
"0.5137264",
"0.5126078",
"0.51213914",
"0.5116902",
"0.51121867",
"0.51051694",
"0.5103684",
"0.5102901",
"0.50917464",
"0.50904167",
"0.50833917",
"0.50781405",
"0.50717",
"0.5069435",
"0.50648576",
"0.50513744",
"0.5019649",
"0.5018688",
"0.50161356",
"0.5015605",
"0.50086945",
"0.50044006",
"0.49986023",
"0.49884248",
"0.49783403",
"0.49722308",
"0.49669087",
"0.49666905",
"0.4962085",
"0.49590886",
"0.49395674",
"0.49229062",
"0.4922482",
"0.4917969",
"0.49166536",
"0.49151063",
"0.49056134",
"0.49033877",
"0.48946553",
"0.4887662",
"0.48842487",
"0.48838663",
"0.48819423",
"0.48745623",
"0.4868576",
"0.48657748",
"0.48657203",
"0.48606786",
"0.48573983",
"0.48512077",
"0.4851123",
"0.48353782",
"0.48297632",
"0.4826104",
"0.4824923",
"0.48247665"
] |
0.80901283
|
0
|
Is the bot currently connected? Falls through to Isaac.
|
def connected?
@bot.connected?
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def connected?\n @bot.connected?\n end",
"def is_connected?\n if @client.is_connected?\n @log.info \"Asked if bot is connected: YES it is\"\n return true\n else\n @log.info \"Asked if bot is connected: NO it isn't\"\n return false\n end\n end",
"def connected?\n @conn.connected? && @channel.open?\n end",
"def connected?\n client.is_connected?\n end",
"def connected?\n status == CONNECTED\n end",
"def connected?\n app.speakers.ID(@id).connected.get\n end",
"def connected?\n !!@connected\n end",
"def connected?\n with_timeout { listening? }\n end",
"def connected?\n with_timeout { listening? }\n end",
"def connected?\n !@connected.nil? && @connected\n end",
"def connected?\n @status == :connected\n end",
"def connected?\n !!@connected_to\n end",
"def connected?\n !!@session_id && !!@cluster\n end",
"def connected?\n @connected\n end",
"def connected?\n @connected\n end",
"def connected?\n @connected\n end",
"def connected?\n @connected\n end",
"def connected?\n @connected\n end",
"def connected?\n @connected ||= false\n end",
"def bot?\n bot.bot?\n end",
"def connected?\n @connected\n end",
"def connected?\n @connected\n end",
"def connected?\n @connected\n end",
"def connected?\n @connected\n end",
"def connected?\n @connected\n end",
"def connected?\n @connected\n end",
"def connected?\n unless @server.nil?\n true\n else\n false\n end\n end",
"def connected?\n @state == :connected\n end",
"def connected?\n not @handle.nil?\n end",
"def connected?\n if @connected\n true\n else\n puts \"Drone is not yet connected. Run `connect` first.\"\n false\n end\n end",
"def established?\n @connected == true\n end",
"def connected?\n authenticated? && !@user.jid.bared?\n end",
"def connected?\n !connection.blank?\n end",
"def connected?\n return @connected\n end",
"def connected?\n\t\t@connected\n\tend",
"def open?\n @connected\n end",
"def connected?\n @started\n end",
"def connected?\n !@vim.serviceContent.sessionManager.currentSession.nil?\n end",
"def connected?\n !!@socket\n end",
"def connected?\n !!@socket\n end",
"def connected?\n\t\t\t\t@@connected\n\t\t\tend",
"def connected?\n self.connected\n end",
"def is_connected?\n if @connection == nil\n return false\n else \n return true\n end\n end",
"def connected?\n if @ssh\n return true\n else\n return false\n end\n end",
"def still_connected?\n true\n end",
"def connected?(conn)\n conn && conn.active?\n end",
"def connected?\n return false unless @connection\n return false unless @connection.started?\n true\n end",
"def is_connected?\n\t\tif @connection == nil\n\t\t\treturn false\n\t\telse\n\t\t\treturn true\n\t\tend\n\tend",
"def connected?\r\n @connection && @connection.connected?\r\n end",
"def connected?\n self.connected_cache ||= session_info.success?\n end",
"def connected?\n return false unless @connection\n return false unless @connection.started?\n true\n end",
"def current_bot?\n @bot.profile.id == @id\n end",
"def connected?\n @connection.present?\n end",
"def connected?\n\t\treturn self.connected ? true : false\n\tend",
"def connected?\n !closed?\n end",
"def connected?\n !closed?\n end",
"def connected?\n !!@socket && @socket.alive?\n end",
"def isConnected()\r\n return @isConnected\r\n end",
"def connected?\n synchronize { @connections.any? }\n end",
"def connected?\n # FIXME: check if connection is connected\n not @connection.nil?\n end",
"def connectable?\n begin; ping; rescue; false; end\n end",
"def activeConnections?\n if @connectedClients then do return true else return false end\n end",
"def connected?\n (conn=self.conn) && conn.connected? && @pid == Process.pid || false\n end",
"def connected?\n connection_handler.connected?(connection_specification_name, role: current_role, shard: current_shard)\n end",
"def connected?\n connection { |conn| conn.alive? }\n end",
"def connected?\n return !@@connection.nil?\n end",
"def connected?\n\t\treturn @conn ? true : false\n\tend",
"def connected?\n Drone::Client.connected?\n end",
"def ready?\n @connected && @logged_in\n end",
"def connected?\n @token.present?\n end",
"def connected?\n\t\t\t\t\t\t@stream&.connected?\n\t\t\t\t\tend",
"def connect?\n connect != false\n end",
"def connected?\n connection_handler.connected?(self)\n end",
"def connected?\n !@connections.empty?\n end",
"def connected_with? nick\n @connection_cache.has_key? nick\n end",
"def connected?\n @connection && !@connection.expired?\n end",
"def connected?\n @connections.any?\n end",
"def connected?()\n (self.remote_address rescue nil) ? true : false\n end",
"def connected?\n\t\t@conn.connected?\n\tend",
"def connected?\n /^[0-9a-z]{8}$/.match(@response.session_id).is_a? MatchData\n end",
"def connected?\n @host && @port\n end",
"def connected?\r\n\t\t\t\t\treturn false if (@connections.nil?)\r\n\t\t\t\t\treturn false if (@connections.empty?)\r\n\t\t\t\t\treturn true\r\n\t\t\t\tend",
"def chat?\n self.state == :chat\n end",
"def connect\n\t\t@state = STATE_ONLINE\n\t\treturn true\n\tend",
"def connected?\n @connections.size > 0 # synchronize { @connections.any? }\n end",
"def connected?\n !!@access_token\n end",
"def connected?\r\n !@conn.nil?\r\n end",
"def connect?\n if !!@connect\n puts \"okai\"\n @frame.destroy()\n else\n print_error_message\n puts \"wrong password or login\"\n return\n end\n end",
"def selfconnected?\n !selfconnection.weight.zero?\n end",
"def playing?\n connection.write(\"is_playing\", false) == \"1\"\n end",
"def playing?\n connection.write(\"is_playing\", false) == \"1\"\n end",
"def playing?\n connection.write(\"is_playing\", false) == \"1\"\n end",
"def connected?\n raise NotImplementedError\n end",
"def available?\n online? and (presence.show == nil or presence.show == :chat)\n end",
"def connected?\n not @sp.closed?\n end",
"def connected?\n return false if @connection.nil?\n return false if @connection.closed?\n return true\n end",
"def on_chan?\n location =~ /^#/\n end",
"def connected?\n @token\n end",
"def connected?\n !@aborted\n end",
"def connected?; end"
] |
[
"0.7953467",
"0.78557104",
"0.74663305",
"0.72863525",
"0.7250291",
"0.718196",
"0.7154962",
"0.7110553",
"0.7110553",
"0.71059996",
"0.7084845",
"0.704109",
"0.6996413",
"0.69754934",
"0.69754934",
"0.69754934",
"0.69754934",
"0.69754934",
"0.69680333",
"0.6943595",
"0.69175637",
"0.69175637",
"0.69175637",
"0.69175637",
"0.69175637",
"0.69175637",
"0.6899574",
"0.6899245",
"0.6869767",
"0.6829665",
"0.68195796",
"0.68148637",
"0.6814595",
"0.6814121",
"0.6796624",
"0.678415",
"0.6781346",
"0.67804515",
"0.67803216",
"0.67803216",
"0.67701906",
"0.6766026",
"0.67643964",
"0.67555326",
"0.67084163",
"0.67043006",
"0.66920274",
"0.66869044",
"0.66779375",
"0.6673627",
"0.66597617",
"0.6659269",
"0.66530216",
"0.6650862",
"0.6635975",
"0.6635975",
"0.6635772",
"0.6631098",
"0.662456",
"0.66046065",
"0.6585992",
"0.65791667",
"0.6577196",
"0.6572741",
"0.65706676",
"0.6570661",
"0.65639347",
"0.6552653",
"0.6535389",
"0.6528109",
"0.6517816",
"0.65174603",
"0.6502608",
"0.6499064",
"0.6493629",
"0.6479391",
"0.64638364",
"0.64486295",
"0.644468",
"0.6435543",
"0.64112514",
"0.63754445",
"0.63509285",
"0.6335046",
"0.6334023",
"0.6329866",
"0.63267064",
"0.63173234",
"0.63118845",
"0.63098085",
"0.63098085",
"0.63098085",
"0.6291372",
"0.62906677",
"0.6287714",
"0.6278059",
"0.6267547",
"0.6265351",
"0.62549",
"0.6251768"
] |
0.8032407
|
0
|
Close the bot's connection to the server Accepts a timeout to allow the server to respond.
|
def disconnect(reason = nil, timeout = 5)
# Quit and wait for replies from server
@bot.quit(reason)
sleep(timeout)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def close(timeout = false)\n # Return immediately if the server isn't listening\n return unless @ml.locked?\n \n # Ask the loop to close\n @close_in.putc 'x' # Tell select to close\n\n \n # Wait for loop to end\n elapsed_time = 0\n while @ml.locked? do\n sleep(0.05)\n elapsed_time += 0.05\n\n # If a timeout is given, try killing threads at this point\n if timeout && elapsed_time > timeout\n @clients.each {|id, thread| thread.kill() }\n end\n end\n end",
"def close\n\t\t\treturn unless @client.alive?\n\n\t\t\tTimeout::timeout(15) do\n\t\t\t\tsleep 0.1 until @client.sendq.empty?\n\t\t\tend rescue nil\n\n\t\t\t@client.close\n\t\tend",
"def close\n conn.write(\"(api-quit)\") if connected?\n rescue Errno::ECONNRESET\n ensure\n self.conn = nil\n end",
"def close(timeout=10)\n # Prevent any new connections from being handed out\n self.pool_size = 0\n start_time = Time.now\n while (Time.now - start_time) < timeout\n sleep 1\n @mutex.synchronize do\n return if @connections.empty?\n @logger.info \"#{@name}: Waiting to close, #{@connections.size} connections are still in use\"\n end\n end\n @logger.warn \"#{@name}: Timed out while waiting to close, #{@connections.size} connections are still in use\"\n end",
"def server_close_timeout\n super\n end",
"def close_connection(*args)\n EM.next_tick do\n @socket.close_connection(*args)\n end\n end",
"def close\n frame = Hash.new\n frame['command'] = 'close'\n @close_txnr=self.frame_write(@socket, frame)\n #TODO: ought to properly wait for a reply etc. The serverclose will make it work though\n sleep @retransmission_timeout\n return @buffer\n ensure\n @socket.close\n end",
"def close(cause = nil)\n if @heartbeat\n @scheduler.cancel_timer(@heartbeat)\n @heartbeat = nil\n end\n\n if @terminate\n @scheduler.cancel_timer(@terminate)\n @terminate = nil\n end\n\n @scheduler.schedule_timer(0).on_value do\n @connection.close(cause)\n end\n\n @closed_promise.future\n end",
"def close_connection(*args)\n EM.next_tick do\n @socket.close_connection(*args)\n end\n end",
"def close_connection\n current_connection.logout if current_connection?\n current_connection = nil\n end",
"def close\n @closing = true\n cancel_ping_timer\n cancel_reconnect_timer\n close_connection_after_writing if connected?\n process_disconnect if reconnecting?\n end",
"def close_connection\n @connection.expunge\n @connection.logout\n @connection.disconnect\n end",
"def close #:nodoc:\n @server.shutdown\n end",
"def close\n log \"Closing connection\", level: :warning\n close_stream\n close_socket\n stop_reader\n set_state :disconnected\n notify_error DisconnectError.new(\"Connection was closed\")\n\n # stop timer\n # as we're running inside the timer, code after stop_timer() will not be called,\n # unless it's in the ensure block\n stop_timer\n end",
"def close(handler)\n puts '! Connection closed' if handler.bot.debug\n exit false\n end",
"def client_close_timeout\n super\n end",
"def close\n info { \"closing connection\" }\n socket.shutdown\n end",
"def close\n @server.close if @server\n @accept_thread.kill if @accept_thread\n @accept_thread = nil\n end",
"def timeout(*args, &blk)\n (@client ||= connect).timeout(*args, &blk)\n end",
"def close()\n @connection.disconnect\n @connection = nil\n end",
"def close_connection\n @connection.finish\n end",
"def close_remote(port, host = \"127.0.0.1\")\n ensure_open!\n\n @session_mutex.synchronize do\n @session.forward.cancel_remote(port, host)\n end\n end",
"def close &on_disconnect\n @heartbeat_timer.cancel if @heartbeat_timer\n @heartbeat_timer = nil\n if on_disconnect\n @closing = true\n @on_disconnect = proc{\n on_disconnect.call\n @closing = false\n }\n end\n\n callback{ |c|\n if c.channels.any?\n c.channels.each do |ch, mq|\n mq.close\n end\n else\n send Protocol::Connection::Close.new(:reply_code => 200,\n :reply_text => 'Goodbye',\n :class_id => 0,\n :method_id => 0)\n end\n }\n end",
"def terminate_connection\n @intentionally_closed = true\n close_connection\n end",
"def closeServer()\n com = Sumo::Traci::Command_Close.new() ;\n execCommands(com) ;\n close() ;\n end",
"def close_connection\n cls if connected?\n stop_read_loop\n stop_write_loop\n @socket.close if @socket\n @socket = nil\n @connected = false\n end",
"def close\n @connection.close # Close the active mailbox\n @connection.logout # Send the logout command\n @connection.disconnect # Close the actual connection\n end",
"def shutdown(timeout=10)\n @pool.close(timeout)\n end",
"def disconnect!(timeout: 120)\n start_time = ::Gitlab::Metrics::System.monotonic_time\n\n while (::Gitlab::Metrics::System.monotonic_time - start_time) <= timeout\n break if pool.connections.none?(&:in_use?)\n\n sleep(2)\n end\n\n pool.disconnect!\n end",
"def close\n @channel.close\n @connection.close\n end",
"def server_inactivity_timeout(timeout, elapsed)\n LOGGER.error \"Disconnecting #{@remote.join(':')} after #{elapsed}s of inactivity (> #{timeout.inspect})\"\n @server_side = nil\n close_connection\n BeanstalkProxy.inactivity_error_callback.call(@remote.join(':'))\n end",
"def close_remote(port, host = \"127.0.0.1\") \r\n ensure_open! \r\n\r\n @session_mutex.synchronize do \r\n @session.forward.cancel_remote(port, host) \r\n end \r\n end",
"def check_tunnel_timeout\n if tunnel_timeout?\n W 'Tunnel timeout. Disconnecting from server.'\n disable_tunnel_timeouts\n close_connection_after_writing\n end\n end",
"def close\n @channel.close\n @conn.close\n end",
"def close_idle_connections(idle_time) # in sec\n @http_client.keep_alive_timeout = idle_time # set timeout value\n close_expired_connections\n end",
"def close_idle_connections(idle_time) # in sec\n @http_client.keep_alive_timeout = idle_time # set timeout value\n close_expired_connections\n end",
"def close\n # Only one CLOSE request may be sent. Guard your close calls by\n # checking the value of {#closed?}\n raise DoubleCloseError if @closed\n\n # Send the CLOSE\n @session.blocking_call { @native_channel.close }\n\n # Mark that we closed\n @closed = true\n end",
"def shutdown(timeout = 300)\n @running = false\n @thread.join(timeout) if @thread and @thread.alive?\n end",
"def disconnect\n info 'closing connection to host'\n @connected = false\n end",
"def close\n parser_thread.kill if parser_thread # why if?\n poll_thread.kill\n socket.close if socket\n\n @status = DISCONNECTED\n end",
"def shutdown_connection\n teardown_timers\n @conn.shutdown if @conn.respond_to? :shutdown\n @conn.terminate if @conn.respond_to? :terminate\n @conn = nil\n end",
"def close\n @notification_server.close_connection\n end",
"def close()\n\t\t@connection.disconnect\n\t\t@connection = nil\n\tend",
"def set_server_close_timeout(opts)\n opts = check_params(opts,[:timeouts])\n super(opts)\n end",
"def shutdown\n log(\"Shutting down...\")\n # We need to perform the shutdown in a new thread, because this method\n # gets called from within a trap context\n Thread.new {\n Sock.off\n stop_bot\n disconnect_db\n unblock_threads\n exit\n }\nrescue => e\n fatal(\"Failed to shut down bot: #{e}\")\n exit\nend",
"def close\n @log.info { \"Closing connection to client #{@ip}\" }\n @socket.close\n end",
"def shutdown_after(timeout); end",
"def logout(timeout: \"60\")\n return _logout(timeout: timeout)\n end",
"def setconnectiontimeout(timeout)\r\n setvalue(@@CONNECTION_TIMEOUT, timeout)\r\n end",
"def stop\n log \"closing connection\"\n @running = false\n client.stop!\n log \"closed\"\n end",
"def disconnect!\n @client&.close\n rescue StandardError\n nil\n end",
"def safe_timeout(conn, meth, name)\n Timeout.timeout(5) { conn.send(meth) }\n true\nrescue Timeout::Error\n $stderr.puts \"Timed out waiting to close #{name} connection\"\n false\nrescue Exception => ex\n $stderr.puts(\"#{ex.class}: #{ex.message}\")\n false\nend",
"def disconnect!\n @connection.close rescue nil\n end",
"def close\n @sock.close if @sock && !@sock.closed?\n @sock = nil\n @retry = nil\n @status = \"NOT CONNECTED\"\n end",
"def close_connection\n @connection.close\n end",
"def close_connection\n @endpoint.close\n end",
"def close\n close_connection(CLOSED, true)\n end",
"def close\n send(\"DONE\")\n @socket.close\n end",
"def disconnect\n _logout\n @connection.close\n end",
"def close command, timeout=cli_option(:default_timeout)\n assert_raise EOFError, \"#{cli_option(:name)} failed to close properly\" do\n self << command\n self.>>(//, timeout)\n self.>>(//, timeout)\n end\n super()\n end",
"def close_remote_srv_conn\n if @socket_srv\n @socket_srv.close\n @log.debug \"close_remote_srv_conn requested\"\n @cup_gui.log_sometext \"Bye, connessione col server terminata\\n\"\n @rd_sock_thread.join\n @socket_srv = nil\n end\n rescue => detail\n @log.error \"Server connection error (#{$!})\\n\"\n @log.error detail.backtrace.join(\"\\n\")\n ensure\n @socket_srv = nil \n end",
"def disconnect\n unless @server.nil?\n @server.cmd \"quit\"\n @server.close\n end\n @authenticated = false\n @server = nil\n end",
"def force_close_connection\n destroy_transport\n connection.transition_state_machine :closed\n end",
"def close\n # Send close when going away only if we have been able to successfully connect\n if @close_req_subject\n req = STAN::Protocol::CloseRequest.new(clientID: @client_id)\n raw = nats.request(@close_req_subject, req.to_proto, timeout: options[:connect_timeout])\n\n resp = STAN::Protocol::CloseResponse.decode(raw.data)\n unless resp.error.empty?\n raise Error.new(resp.error)\n end\n end\n\n # If we do not even have a connection then return already...\n return unless @nats\n\n # TODO: If connection to nats was borrowed then we should\n # unsubscribe from all topics from STAN. If not borrowed\n # and we own the connection, then we just close.\n begin\n # Remove all related subscriptions for STAN\n @sub_map.each_pair do |_, sub|\n nats.unsubscribe(sub.sid)\n end\n\n # Finally, remove the core subscriptions for STAN\n nats.unsubscribe(@hb_inbox_sid)\n nats.unsubscribe(@ack_subject_sid)\n nats.flush(options[:connect_timeout])\n rescue NATS::IO::Timeout\n raise CloseReqTimeoutError.new(\"stan: close request timeout\")\n ensure\n if @borrowed_nats_connection\n @nats = nil\n else\n @nats.close\n end\n end\n end",
"def timeout(seconds, &block)\n Timeout.timeout seconds, Pinglish::TooLong, &block\n end",
"def close(await_response = true)\n return unless active?\n\n @subject.close(await_response)\n logger.info \"Connection #{connection_uri} closed.\"\n end",
"def close\n assert_rc @sock.close\n end",
"def close\n @logger.debug(@host) { 'Closing session' }\n @transport.close\n @transport = nil\n end",
"def close_expired_connections\n # By default the keep alive timeout is 15 sec, which is the HTTP 1.1\n # standard. To change the value, use keep_alive_timeout= method\n # do nothing, handled by HTTPClient\n end",
"def close_expired_connections\n # By default the keep alive timeout is 15 sec, which is the HTTP 1.1\n # standard. To change the value, use keep_alive_timeout= method\n # do nothing, handled by HTTPClient\n end",
"def close\n @socket.close\n end",
"def close\n @socket.close\n end",
"def sends_close\n script.sends_channel_close(self)\n end",
"def timeout!(*args, &block)\n Timeout::timeout(*args, &block)\n end",
"def wait_close(timeout = 0)\n Window.functions[__method__] ||= AU3_Function.new(\"WinWaitClose\", 'SSL', 'L')\n Window.functions[__method__].call(@title.wide, @text.wide, timeout) != 0\n end",
"def close\n server_list.each { |server| server.close_channels }\n loop(0) { busy?(true) }\n server_list.each { |server| server.close }\n default_gateway.shutdown! if default_gateway\n end",
"def close &on_disconnect\n @on_disconnect = on_disconnect if on_disconnect\n\n callback{ |c|\n if c.channels.any?\n c.channels.each do |ch, mq|\n mq.close\n end\n else\n send Protocol::Connection::Close.new(:reply_code => 200,\n :reply_text => 'Goodbye',\n :class_id => 0,\n :method_id => 0)\n end\n }\n end",
"def close\n connection.close\n end",
"def timeout_wrap(&block)\n ::Timeout.timeout(timeout, &block)\n rescue ::Timeout::Error\n failure(:RPC_FAILED, \"The server took longer than #{timeout} seconds to respond\")\n end",
"def close(context)\n context.debug('Logout connection')\n @connection_info = nil\n @client.logout\n @client = nil\n @system = nil\n end",
"def close!\n logger.debug \"Closing...\",\n socket: socket,\n server: server,\n path_exists: path.exist?,\n thread: thread,\n env_var: {\n env_var_name => ENV[env_var_name],\n }\n \n # Remove the path from the ENV so if we do anything after this the\n # old one isn't hanging around\n ENV.delete env_var_name\n \n # Kill the thread first so that it can't try to do anything else\n thread.kill if thread && thread.alive?\n \n socket.close unless socket.nil?\n @socket = nil\n server.close unless server.nil?\n @server = nil\n FileUtils.rm( path ) if path.exist?\n \n logger.debug \"Closed.\",\n socket: socket,\n server: server,\n path_exists: path.exist?,\n thread: thread,\n env_var: {\n env_var_name => ENV[env_var_name],\n }\n \n nil\n end",
"def disconnect\n @thread.kill\n @socket.close\n end",
"def close(event)\n if event && !event.target.kind_of?(Faye::WebSocket::Client) then\n logger.debug { \"closed connection from #{event.target.env[\"REMOTE_ADDR\"]} (code=#{event.code}; reason=\\\"#{event.reason}\\\")\" }\n end\n if @connected then\n @connected = false\n @handler.new(nil).disconnect(self)\n end\n end",
"def disconnect; @connection.close end",
"def close(allow_reconnect = false)\n if @connection\n # Disable reconnects if specified\n reconnect = @reconnect\n @reconnect = reconnect && allow_reconnect\n\n # Clean up timers / connections\n @keepalive_timer.cancel if @keepalive_timer\n @keepalive_timer = nil\n @connection.close\n\n # Revert change to reconnect config once the final signal is received\n wait do |&resume|\n on(:session_ended, :once => true) { resume.call }\n end\n @reconnect = reconnect\n end\n \n true\n end",
"def handle_timeout\n err = \"No response from server: Timed out connecting to server. Server is either down or connection is slow.\"\n redirect_to root_path, flash: { error: err }\n end",
"def close\n client.close\n @client = nil\n end",
"def close\n connection.close if connection\n end",
"def disconnect\n @socket.close\n end",
"def close\n tagged_response(\"CLOSE\")\n end",
"def close\n @client.close\n end",
"def close\n @client.close\n end",
"def close\n write_message(Vertica::Protocol::Terminate.new)\n ensure\n close_socket\n end",
"def timeout_stop(timeout)\n model.timeout_stop(timeout)\n end",
"def close\n @socket.close if @socket\n end",
"def close\n @connection.close\n end",
"def close\n @connection.close\n end",
"def close\n @transport.close\n @transport = nil\n @close_handler and @close_handler.call\n end",
"def close\n inactive!\n close_connections\n end",
"def test_exit_close\n\t\tserver = TelnetServer.new\n\t\tserver.start()\n\n\t\tclient = TCPSocket.open(\"localhost\", 23)\n\t\twait\n\t\twelcome_msg = client.recv(200)\n\t\tclient.print(\"exit\\r\\n\")\n\t\t\n\t\tbye_msg = client.read\n\t\tassert_equal(\"\\r\\nClosing the connection. Bye!\", bye_msg)\n\t\twait\n\t\tserver.stop()\n\tend"
] |
[
"0.71344316",
"0.6993407",
"0.65065193",
"0.643313",
"0.6368979",
"0.63612384",
"0.6358971",
"0.6353435",
"0.63488334",
"0.63235235",
"0.62913907",
"0.6269492",
"0.6260138",
"0.6253904",
"0.6249656",
"0.61766124",
"0.61196434",
"0.6100018",
"0.6086067",
"0.60844946",
"0.6065351",
"0.6063999",
"0.6060479",
"0.60446626",
"0.59994406",
"0.59933287",
"0.598579",
"0.5965263",
"0.5960783",
"0.5953469",
"0.59482574",
"0.59397674",
"0.59228945",
"0.5917846",
"0.59156835",
"0.59156835",
"0.5914529",
"0.5907745",
"0.59062845",
"0.58893096",
"0.5888851",
"0.58887106",
"0.588817",
"0.58579034",
"0.58471376",
"0.58101803",
"0.5799712",
"0.57908076",
"0.57796437",
"0.57741183",
"0.5766483",
"0.57661",
"0.5766082",
"0.5765833",
"0.57645136",
"0.576071",
"0.5750722",
"0.57428557",
"0.5738843",
"0.573041",
"0.5718755",
"0.5714669",
"0.56957906",
"0.5692773",
"0.56904733",
"0.56790876",
"0.56743014",
"0.5671563",
"0.56702834",
"0.56702834",
"0.5668964",
"0.5668964",
"0.5666795",
"0.5665968",
"0.5664336",
"0.56609875",
"0.56604165",
"0.5653005",
"0.5649857",
"0.5649449",
"0.56411415",
"0.56373256",
"0.5634483",
"0.563366",
"0.5632759",
"0.5628819",
"0.5613612",
"0.5612251",
"0.5610501",
"0.56011593",
"0.5596128",
"0.5596128",
"0.5590276",
"0.5590091",
"0.5577402",
"0.5577261",
"0.5577261",
"0.5563924",
"0.5558657",
"0.55463743"
] |
0.6988718
|
2
|
Produce a bot object with stateful defaults. IMPORTANT: This must remain threadsafe, since it is the unsafe side of all interactions between services and the [safe] isaac lib.
|
def clone_state(msg)
# Construct a new class
cls = Class.new() do
# Require the isaac agent and
# the raw message from isaac
def initialize(isaac, msg)
@msg = msg
@bot = isaac
end
# Which server is the bot
# connected to?
def server
@bot.server
end
# Which nick does the bot
# currently have?
def nick
@bot.nick
end
# Tell the bot to join a channel
def join(channel)
@bot.join(channel)
end
# Is the bot currently connected?
def connected?
@bot.connected?
end
# Say something.
#
# Wraps isaac's call with a default value
# from msg
def say(msg, recipient = nil)
recipient ||= @msg.reply_to if @msg
@bot.msg(recipient, msg)
end
# Action something
#
# Wraps isaac's call with a default value
# from msg
def action(msg, recipient)
recipient ||= @msg.reply_to if @msg
@bot.action(recipient, msg)
end
end
# Return an instance of the new class
# with defaults from the message
# and a link back to isaac.
return cls.new(@bot, msg)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def bot()\n merge(bot: 'true')\n end",
"def bot\n @bot ||= Bot.new(ua)\n end",
"def create_bot\n $bot = Discordrb::Bot.new(\n token: $config['discord_secret'],\n client_id: $config['discord_client'],\n log_mode: :quiet,\n intents: [\n :servers,\n :server_members,\n :server_bans,\n :server_emojis,\n :server_integrations,\n :server_webhooks,\n :server_invites,\n :server_voice_states,\n #:server_presences,\n :server_messages,\n :server_message_reactions,\n :server_message_typing,\n :direct_messages,\n :direct_message_reactions,\n :direct_message_typing\n ]\n )\n log(\"Created bot\")\nrescue => e\n fatal(\"Failed to create bot: #{e}\")\n exit\nend",
"def new(bot)\n @bot = bot\n end",
"def my_bot\n Discordrb::Bot.new token: @token, application_id: @app_id\n end",
"def configure\n # Users to block instead of interacting with\n self.blacklist = ['mcamargo1997']\n\n # Range in seconds to randomize delay when bot.delay is called\n self.delay_range = 1..6\n\n @userinfo = {}\n @botinfo = {\n ENV[\"BOT_NAME_1\"] => BotInfo.new(ENV[\"BOT_NAME_1\"]),\n ENV[\"BOT_NAME_2\"] => BotInfo.new(ENV[\"BOT_NAME_2\"])\n }\n end",
"def initialize(token, clientId, prefix, initDicts=Hash.new, helloStringArr=[\"Hello!\"], byeStringArr=[\"Goodbye!\"], rejectStringArr=[\"You're not my creator.\"], botChannelName=\"\", joinChannelName=\"\", logFilename=\"log\", welcomeMessage=\"Welcome!\")\r\n err = setup_args_valid?([token, clientId, prefix])\r\n if err\r\n puts(\"Cannot initialize bot. \" + err)\r\n return nil\r\n end\r\n\r\n @token = token\r\n @clientId = clientId\r\n @prefix = prefix\r\n @bot = Discordrb::Commands::CommandBot.new(token: @token, client_id: @clientId, prefix: @prefix)\r\n\r\n @wordLength = 30\r\n @timeout = 60\r\n @numSentences = 1\r\n\r\n @dict = Hash.new\r\n @desc = Hash.new\r\n @sentenceGens = Hash.new\r\n @logger = ChatLogger.new\r\n @commands = BotCommands.new(@sentenceGens, @wordLength, @timeout)\r\n\r\n @awakenStrings = helloStringArr\r\n @byeStrings = byeStringArr\r\n @rejectStrings = rejectStringArr\r\n @botChannelName = botChannelName\r\n @logFilename = logFilename\r\n @joinChannelName = joinChannelName\r\n @welcomeMessage = welcomeMessage\r\n\r\n add_dictionaries(initDicts)\r\n end",
"def establecer_bot(bot)\n @bot = bot\n end",
"def create_bot\n derp = @config\n @bot = Cinch::Bot.new do \n configure(&derp)\n end\n end",
"def initialize(responses, queue)\n @id = \"Bot-\" + SecureRandom.uuid\n @responses = responses\n @queue = queue\n @agent = Mechanize.new\n @state = {}\n @thread = Thread.new {run}\n end",
"def bot_instance\n @bot_instance ||= BotInstance.find_by(bot_id: bot.id)\n end",
"def default\n game = self.new\n game.state = 'Texas' if game.respond_to? :state\n game.origin = 'hunted' if game.respond_to? :origin\n game.gender = 'male' if game.respond_to? :gender\n if game.respond_to? :parts\n parts = Part::NAMES.map { |part_name| {name: part_name} }\n parts << { other: true }\n game.parts = parts\n end\n game\n end",
"def setup_bot\n Facebook::Messenger::Profile.set({\n greeting: {\n locale: 'default',\n text: 'Welcome to your friendly Ads Bot! :)' \n },\n get_started: {\n payload: 'GET_STARTED' # make sure to handle this postback\n }\n # @TODO: Add persistent menu\n }, access_token: access_token)\n end",
"def initialize(session, msg_timeout = 2, max_delay = 12, bot_list = false)\n @session = session\n @msg_timeout = msg_timeout\n @max_delay = max_delay\n @purged = false\n @aid = \"#{@@next_id}\"\n @@next_id += 1\n\n @response_text = {}\n @responded = {}\n @finished = []\n\n # The initial bot list for when the aggregator is started\n if (!bot_list)\n @bot_list = @session.bot_list\n else\n @bot_list= bot_list\n end\n \n #@bot_list = bot_list\n #if @session.kind_of?(HiBot::MUCSessionHandler)\n # @bot_list.map! { |jid| jid.split(\"/\").pop }\n #end\n # print \"Bot list: #{@bot_list.sort.join(\", \")}\\n\"\n\n @delay_thread = Thread.new {\n sleep( @max_delay )\n self.purge\n }\n reset_wait()\n # reset_auto_destruct()\n end",
"def initialize(options = {})\n\t\t@name = options[:name] || \"Unnamed Bot\"\n\t\tbegin \n\t\t\t# @data = YAML.load(File.read(options[:data_file]))\n\t\t\t@data = BOT_DATA\n\t rescue\n\t \traise \"Cant load bot data\"\n\t end\n\tend",
"def create_bot(opts)\n\tCinch::Bot.new do\n\t configure do |c|\n\t\t c.server = opts[:server]\n\t\t c.channels = opts[:channels]\n\t\t c.nick = opts[:name]\n\t\t c.plugins.plugins = [Seen, Hello, TopicHistory, Memo]\n\t end\n\n\t helpers do\n\t\t def shorten(url)\n\t\t\turl = open(\"http://tinyurl.com/api-create.php?url=#{URI.escape(url)}\").read\n\t\t\turl == \"Error\" ? nil : url\n\t\t rescue OpenURI::HTTPError\n\t\t\tnil\n\t\t end\n\t end\n\n\t on :channel do |m|\n\t\t return if m =~ /\\A!/\n\t\t urls = URI.extract(m.message, \"http\").reject { |url| url.length < 70 }\n\n\t\t if urls.any?\n\t\t\tshort_urls = urls.map {|url| shorten(url) }.compact\n\n\t\t\tunless short_urls.empty?\n\t\t\t m.reply short_urls.join(\", \")\n\t\t\tend\n\t\t end\n\t end\n\tend\nend",
"def setup_bot\n # Respond to DMs\n $bot.private_message do |event|\n next if !RESPOND && event.user.id != BOTMASTER_ID\n remove_mentions!(event.content)\n special = event.user.id == BOTMASTER_ID && event.content[0] == '!'\n special ? respond_special(event) : respond(event)\n str = special ? 'Special ' : ''\n str = \"#{str}DM by #{event.user.name}: #{event.content}\"\n special ? succ(str) : msg(str)\n rescue => e\n lex(e, 'Failed to handle Discord DM')\n ensure\n release_connection\n end\n\n # Respond to pings\n $bot.mention do |event|\n next if !RESPOND && event.user.id != BOTMASTER_ID\n remove_mentions!(event.content)\n respond(event)\n msg(\"Mention by #{event.user.name} in #{event.channel.name}: #{event.content}\")\n rescue => e\n lex(e, 'Failed to handle Discord ping')\n ensure\n release_connection\n end\n\n # Parse all messages, and optionally respond\n $bot.message do |event|\n next if !RESPOND && event.user.id != BOTMASTER_ID\n remove_mentions!(event.content)\n if event.channel == $nv2_channel\n $last_potato = Time.now.to_i\n $potato = 0\n end\n mishnub(event) if MISHU && event.content.downcase.include?(\"mishu\")\n robot(event) if !!event.content[/eddy\\s*is\\s*a\\s*robot/i]\n if event.content[0] == '!' && event.user.id == BOTMASTER_ID && event.channel.type != 1\n respond_special(event)\n succ(\"Special command: #{event.content}\")\n end\n rescue => e\n lex(e, 'Failed to handle Discord message')\n ensure\n release_connection\n end\n\n # Respond to button interactions\n $bot.button do |event|\n next if !RESPOND && event.user.id != BOTMASTER_ID\n respond_interaction_button(event)\n rescue => e\n lex(e, 'Failed to handle Discord button interaction')\n ensure\n release_connection\n end\n\n # Respond to select menu interactions\n $bot.select_menu do |event|\n next if !RESPOND && event.user.id != BOTMASTER_ID\n respond_interaction_menu(event)\n rescue => e\n lex(e, 'Failed to handle Discord select menu interaction')\n ensure\n release_connection\n end\n\n log(\"Configured bot\")\nrescue => e\n fatal(\"Failed to configure bot: #{e}\")\n exit\nend",
"def configure\n\n # Give the bot a handle to config and handler\n conf = @config\n\n # Configure the bot\n @bot = Isaac::Bot.new\n @bot.configure{|c|\n c.server = conf[:server]\n c.port = conf[:port]\n c.ssl = conf[:ssl]\n c.nick = conf[:nick]\n c.password = conf[:password]\n c.realname = conf[:name]\n\n c.environment = :production\n c.verbose = conf[:verbose] || false \n c.log = $log\n }\n\n end",
"def initialize(config = nil, skip_query: nil)\n @status = {}\n @barriers = {}\n @last_activity = nil\n @config = config[\"irc\"]\n @nick = @config[\"nicks\"].first\n @store = PStore.new 'irc_state.pstore'\n @store.transaction(true) do\n @last_turn = @store.fetch(:last_turn, 0)\n @last_needed = @store.fetch(:last_needed, Set.new)\n @reported_players = @store.fetch(:reported_players, Set.new)\n end\n\n add_info_methods\n\n @bot = Cinch::Bot.new\n @bot.configure do |c|\n c.server = @config['serveraddr']\n c.nicks = @config['nicks']\n c.user = @config['username']\n c.realname = @config['realname']\n c.channels = [@config['channel']]\n end\n\n # Set up bot and connect to server\n add_handlers\n @connection_thread = Thread.start do\n @bot.start\n end\n\n reinitialize(skip_query: skip_query)\n end",
"def defaults\n state.flash_at ||= 0\n state.zombie_min_spawn_rate ||= 60\n state.zombie_spawn_countdown ||= random_spawn_countdown state.zombie_min_spawn_rate\n state.zombies ||= []\n state.killed_zombies ||= []\n\n # Declares player as a new entity and sets its properties.\n # The player begins the game in the center of the screen, not moving in any direction.\n state.player ||= state.new_entity(:player, { x: 640,\n y: 360,\n attack_angle: 0,\n dx: 0,\n dy: 0 })\n end",
"def defaults args\n fiddle args\n args.state.enemy.hammers ||= []\n args.state.enemy.hammer_queue ||= []\n args.state.tick_count = args.state.tick_count\n args.state.bridge_top = 128\n args.state.player.x ||= 0 # initializes player's properties\n args.state.player.y ||= args.state.bridge_top\n args.state.player.w ||= 64\n args.state.player.h ||= 64\n args.state.player.dy ||= 0\n args.state.player.dx ||= 0\n args.state.enemy.x ||= 800 # initializes enemy's properties\n args.state.enemy.y ||= 0\n args.state.enemy.w ||= 128\n args.state.enemy.h ||= 128\n args.state.enemy.dy ||= 0\n args.state.enemy.dx ||= 0\n args.state.game_over_at ||= 0\nend",
"def set_defaults\n self.state ||= 'ACTIVE'\n self.account_user_id ||= Gizmo::Util::Uuid.generate\n self.is_owner ||= false\n end",
"def initialize_defaults\n @messenger = @@default_messenger\n @message = Message.new\n end",
"def defaults args\n\n # general defaults\n args.state.margin ||= 40\n args.state.game_state ||= \"playing\"\n\n # player defaults\n args.state.player_y ||= args.state.margin\n args.state.player_x ||= 100\n args.state.player_w ||= 80\n args.state.player_h ||= 80\n args.state.player_speed ||= 5\n\n # player bullet defaults\n args.state.player_bullet_x ||= -500\n args.state.player_bullet_y ||= -500\n args.state.player_bullet_w ||= 10\n args.state.player_bullet_h ||= 40\n args.state.player_bullet_speed ||= 10\n args.state.player_bullet_shooting ||= false\n\n # enemy defaults\n args.state.enemy_x ||= 40\n args.state.enemy_y ||= 600\n args.state.enemy_w ||= 370\n args.state.enemy_h ||= 370\n args.state.enemy_speed ||= 2\n args.state.enemy_dir ||= 1\n\n # enemy bullet defaults\n args.state.enemy_bullet_x ||= -500\n args.state.enemy_bullet_y ||= -500\n args.state.enemy_bullet_w ||= 10\n args.state.enemy_bullet_h ||= 40\n args.state.enemy_bullet_speed ||= 10\n args.state.enemy_bullet_shooting ||= false\nend",
"def initialize(bot, data, params)\n @bot = bot\n @data = data\n @params = params\n end",
"def initialize\n\n # Objects noted with the 'the_' prefix are used to be passed without risking\n # execution context name collisions\n\n # Put itself to be referenced by the internal irc bot #THE\n #the_faye_sender = self\n\n # Load IRC config part from APP_CONFIG #THE\n load_irc_config\n the_irc_config = @config\n\n #Load device_channels #THE\n the_device_channels = get_device_channels(true)\n\n # Initialize the message processor instance # THE\n the_message_processor = initialize_message_processor\n the_irc_gateway = self\n\n\n # Create the ZBOT, instance of GBot...lol\n @zbot = GBot.new do\n\n configure do |c|\n c.server = the_irc_config[:server][:ip]#'127.0.0.1'#\n c.nick = \"#{the_irc_config[:client][:nick_prefix]}#{the_irc_config[:client][:nick]}\"\n c.channels = the_irc_config[:client][:default_channels] + the_device_channels\n end\n\n #if the_irc_config[:client][:logger].eql? 'null'\n #\n #end\n\n #self.logger = Cinch::Logger::NullLogger.new($stderr)\n\n #Listen and do...\n on :message do |m|\n # self === Callback.new\n\n # Retrieve important params\n rcvd_message = m.message # \"the message\" the actual message\n rcvd_channel = m.channel.name # \"#lobby\" the channel it was sent on\n rcvd_user = m.user.nick # \"charles\" who sent it\n\n # Process it and get the required data to send\n\n # ELIMINATE\n the_message_processor=DeviceCommandProcessor.new(the_irc_gateway)\n\n the_message_processor.process_irc_message rcvd_channel, rcvd_user, rcvd_message\n\n end\n end\n\n # Finally...start da bot\n start\n end",
"def initialize(botname, body, webhook_url=nil)\n self.botname = botname\n self.webhook_url = webhook_url\n parsed = URI.decode_www_form(body)\n parsed.each do |p|\n # puts \"#{p[0]}=#{p[1]}\"\n if p[0] == \"command\"\n self.command = p[1]\n # puts \"command=#{self.command}\"\n end\n if p[0] == \"trigger_word\"\n # This is for trigger words, not slash commands\n self.trigger_word = p[1]\n end\n if p[0] == \"channel_name\"\n self.channel = p[1]\n end\n if p[0] == \"user_name\"\n self.username = \"@#{p[1]}\"\n # puts \"username #{username}\"\n end\n if p[0] == \"text\"\n self.text = p[1].strip\n # puts \"text=#{text}\"\n end\n if p[0] == \"response_url\" && !webhook_url \n # we get it in the post body with more recent slack apps\n self.webhook_url = p[1]\n end\n end\n if self.channel == \"directmessage\"\n self.channel = self.username\n else\n self.channel = \"\\##{self.channel}\" unless self.channel[0] == '#'\n end\n\n end",
"def bot=(bot)\n @bot = bot\n end",
"def defaults args\n args.state.game_definition ||= game\n args.state.decision_id ||= args.state.game_definition[:starting_decision]\nend",
"def client\n @client ||= Gamewisp::Client.new\nend",
"def bot_mode\n self['BOT']\n end",
"def initialize(bot, key, type, attributes, block = nil)\n @bot = bot\n @key = key\n @type = type\n @attributes = attributes\n @block = block\n end",
"def initialize(options = {})\n @master = options.delete(:master)\n @output_dir = options.delete(:output_dir) || File.dirname(__FILE__)\n\n # Log files per channel - logs rotate every so often, so we have to store\n # filenames on a per-channel basis\n @current_log = {}\n @log_date = {}\n @passwords = options[:passwords] || {}\n\n options[:username] = BOTNAME\n options[:realname] = BOTNAME\n options[:nicknames] = ['LoggerBot', 'Logger_Bot', 'logger_bot', '_LoggerBot', 'LoggerBot_']\n\n # Set up IRCBot, our loving parent, and begin\n super(options)\n self.connect_socket\n self.start_listening\n end",
"def initialize(bot = nil, update = nil)\n if update.is_a?(Hash) && (update.key?(:from) || update.key?(:chat))\n options = update\n update = nil\n end\n @_update = update\n @_bot = bot\n @_chat, @_from = options && options.values_at(:chat, :from)\n\n payload_data = nil\n update && PAYLOAD_TYPES.find do |type|\n item = update[type]\n payload_data = [item, type] if item\n end\n @_payload, @_payload_type = payload_data\n end",
"def initialize(options = {})\n @options = OPTION_DEFAULTS.merge(options)\n @state = {\n user: \"user\",\n channel: \"#channel\"\n }\n end",
"def create_bot(bot_name:,\n branch_name: \"master\",\n performs_analyze_action: true,\n performs_archive_action: false,\n performs_test_action: true,\n project_path:,\n repo_url:,\n scheme_name:,\n testing_schedule: TestingSchedule::Type::ON_COMMIT,\n working_copy_path:)\n repo_identifier = SecureRandom.uuid\n res = post('bots',\n group: {\n name: SecureRandom.uuid\n },\n configuration: {\n builtFromClean: 1, # Always\n periodicScheduleInterval: 0, # Run manually\n performs_test_action: performs_test_action,\n performs_analyze_action: performs_analyze_action,\n scheme_name: scheme_name,\n sourceControlBlueprint: {\n DVTSourceControlWorkspaceBlueprintLocationsKey: {\n repo_identifier => {\n DVTSourceControlBranchIdentifierKey: branch_name,\n DVTSourceControlBranchOptionsKey: 156, # Mystery meat\n DVTSourceControlWorkspaceBlueprintLocationTypeKey: \"DVTSourceControlBranch\" # \"Pull a git branch\"\n }\n },\n DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey: repo_identifier,\n DVTSourceControlWorkspaceBlueprintRemoteRepositoryAuthenticationStrategiesKey: {\n repo_identifier => {\n DVTSourceControlWorkspaceBlueprintRemoteRepositoryAuthenticationTypeKey: \"DVTSourceControlAuthenticationStrategy\"\n }\n },\n DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey: {\n repo_identifier => 0\n },\n DVTSourceControlWorkspaceBlueprintIdentifierKey: repo_identifier,\n DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey: {\n repo_identifier => working_copy_path\n },\n DVTSourceControlWorkspaceBlueprintNameKey: project_path,\n DVTSourceControlWorkspaceBlueprintVersion: 203, # Mystery meat\n DVTSourceControlWorkspaceBlueprintRelativePathToProjectKey: project_path,\n DVTSourceControlWorkspaceBlueprintRemoteRepositoriesKey: [{\n DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey: project_url,\n DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey: \"com.apple.dt.Xcode.sourcecontrol.Git\",\n DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey: repo_identifier\n }]\n },\n hourOfIntegration: 0,\n scheduleType: testing_schedule,\n performs_archive_action: performs_archive_action,\n testingDestinationType: 0 # \"iOS All Devices and All Simulators\"\n },\n requiresUpgrade: false, # Mystery meat\n name: bot_name,\n type: 1 # Mystery meat\n )\n\n Bot.new(self, JSON.load(res.body))\n end",
"def default\n # setup default configuration\n @code_send_repeats = 10\n self.set_timer( frequency: 36_000, duty: 0.45 )\n self.indicator = false\n self.broadcasting_gap = 0.1 # seconds between each pulse\n usb_set_indicator_as_debug_light( wValue: 0 ) # turn off debugging light mode\n self # return self for nifty chaining\n end",
"def initialize(bot:, user:)\n super\n @settings = user.student_settings\n end",
"def initialize\n load_config\n @token = ENV.fetch('DISCORD_TOKEN', @config[:DISCORD_TOKEN])\n @app_id = ENV.fetch('DISCORD_APP_ID', @config[:DISCORD_APP_ID])\n @bot = my_bot\n @bot.info \"The first few characters of the discord token are: #{@token[0, 5]}\"\n @bot.info \"App_id is: #{@app_id}\"\n end",
"def defaults args\n fiddle args\n\n args.state.tick_count = args.state.tick_count\n args.state.bridge_top = 128\n args.state.player.x ||= 0 # initializes player's properties\n args.state.player.y ||= args.state.bridge_top\n args.state.player.w ||= 64\n args.state.player.h ||= 64\n args.state.player.dy ||= 0\n args.state.player.dx ||= 0\n args.state.player.r ||= 0\n args.state.game_over_at ||= 0\n args.state.animation_time ||=0\n\n args.state.timeleft ||=0\n args.state.timeright ||=0\n args.state.lastpush ||=0\n\n args.state.inputlist ||= [\"j\",\"k\",\"l\"]\nend",
"def run()\r\n @bot.run :async\r\n @bot.online\r\n wake_up(@bot)\r\n\r\n @bot.bucket :helpBucket, limit: 1, time_span: 30, delay: 1\r\n @bot.bucket :hamBucket, limit: 5, time_span: 1, delay: 1\r\n\r\n # Create all markov commands, invoked by dictionary name.\r\n @dict.each_pair do |dictName, dictionary|\r\n commandName = dictName.gsub(/\\s+/,\"_\").downcase.to_sym\r\n @bot.command(commandName, bucket: :hamBucket, rate_limit_message: \"Slow down please!\") do |event, flag|\r\n if bot_can_respond?(@bot, event)\r\n event.respond( @commands.markov_command(event, flag, @numSentences, dictName) )\r\n GC.start\r\n end\r\n end\r\n end\r\n\r\n # Recite all public commands.\r\n @bot.command(:help, bucket: :helpBucket, rate_limit_message: \"Slow down please!\") do |event, flag|\r\n if bot_can_respond?(@bot, event)\r\n event.respond( @commands.get_help(@desc, @prefix) )\r\n end\r\n end\r\n\r\n # Set the num sentences.\r\n @bot.command(:setlength, bucket: :hamBucket, rate_limit_message: \"Slow down please!\") do |event, num|\r\n @numSentences = [1, [num.to_i, 8].min].max # Clamp between 1 and 8.\r\n if bot_can_respond?(@bot, event)\r\n event.respond( \"Number of sentences to generate set to \" + @numSentences.to_s + \".\" )\r\n end\r\n end\r\n\r\n # Report current memory usage.\r\n # Only works when run on linux!\r\n @bot.command(:memory, bucket: :helpBucket, rate_limit_message: \"Slow down please!\") do |event, flag|\r\n if bot_can_respond?(@bot, event)\r\n event.respond( \"Previously I was using \" + @commands.get_prev_mem_usage().to_s() + \" kilobytes of memory.\\n\" + \"I am now using \" + @commands.get_mem_usage().to_s() + \" kilobytes of memory.\" )\r\n end\r\n end\r\n\r\n # Sleep.\r\n @bot.command(:sleep, bucket: :hamBucket, rate_limit_message: \"Slow down please!\") do |event, flag|\r\n if event.author == @bot.bot_application.owner\r\n # Save and close everything.\r\n @commands.save_dicts(@dict.values)\r\n @logger.close_open_logs()\r\n\r\n # Say goodnight.\r\n if bot_can_respond?(@bot, event) and @byeStrings.size > 0\r\n event.respond(@byeStrings.sample)\r\n end\r\n\r\n # Set status to offline and stop the bot.\r\n @bot.invisible\r\n @bot.stop\r\n else\r\n # Respond with a no-no.\r\n if bot_can_respond?(@bot, event) and @rejectStrings.size > 0\r\n event.respond(@rejectStrings.sample)\r\n end\r\n end\r\n end\r\n\r\n # Chat logger.\r\n @bot.message do |event|\r\n @logger.process_message(event, @dict[@logFilename], @prefix)\r\n end\r\n\r\n # Add to dictionary.\r\n @bot.command(:addto, bucket: :hamBucket, rate_limit_message: \"Slow down please!\") do |event, dictName|\r\n if bot_can_respond?(@bot, event) && event.author == @bot.bot_application.owner\r\n messageArray = event.content.strip.split(\" \")[2 .. -1]\r\n success = true\r\n response = \"\"\r\n\r\n if nil==dictName\r\n response = response + \"Please specify a dictionary name. \"\r\n success = false\r\n end\r\n if nil==messageArray or messageArray.length <= 0 \r\n response = response + \"Please provide a string. \"\r\n success = false\r\n end\r\n\r\n if success\r\n message = messageArray.join(\" \")\r\n success = @logger.add_to_dict(event, @dict[dictName], message)\r\n end\r\n\r\n if success==0\r\n response = \"Got it.\"\r\n elsif success==1\r\n response = \"Couldn't do it. That dictionary doesn't exist. \" + response\r\n else\r\n response = \"Couldn't do it. \" + response\r\n end\r\n\r\n event.respond(response)\r\n else\r\n # Respond with a no-no.\r\n if bot_can_respond?(@bot, event) and @rejectStrings.size > 0\r\n event.respond(@rejectStrings.sample)\r\n end\r\n end\r\n end\r\n\r\n # Member join Message.\r\n @bot.member_join do |event|\r\n channel = (event.server.channels.keep_if{|chan| chan.name == @joinChannelName} )[0]\r\n if not channel or not @welcomeMessage or @welcomeMessage==\"\" then return end\r\n\r\n @bot.send_message(channel, \"<@!\" + event.user.id.to_s + \"> \" + @welcomeMessage)\r\n end\r\n\r\n @bot.sync\r\n end",
"def initialize(options)\n\t\t@name = options[:name] || \"Unnamed Bot\" # name = name otherwise it is an Unnamed bot\n\t\tbegin\n\t\t\t@data = YAML.load(File.read(options[:data_file]))\n\t\trescue \n\t\t\traise \"Can't load bot data\"\n\t\tend\n\tend",
"def initialize(client, roster, args)\n @client = client\n @client.add_message_callback {|m| handle_message(m) }\n @client.add_presence_callback {|p| handle_presence(p) }\n\n @roster = roster\n @roster.add_subscription_request_callback do |item, presence|\n handle_subscription_request(item, presence)\n end\n\n @client.send(Jabber::Presence.new)\n\n # JID -> User\n @users = {}\n\n # name -> Channel\n @channels = {}\n\n @commands = {\n 'alias' => AliasCommand,\n 'help' => HelpCommand,\n 'join' => JoinCommand,\n 'list' => ListCommand,\n 'me' => MeCommand,\n 'part' => PartCommand,\n 'reset' => ResetCommand,\n 'scores' => ScoresCommand,\n }\n\n @line_handlers = [\n PlusPlusHandler,\n VamosQuestionHandler,\n ]\n\n @logger = args[:logger] ? args[:logger] : Logger.new(STDOUT)\n interval_sec = args[:message_buffer_sec] ? args[:message_buffer_sec] : 0.5\n @sender = MessageSender.new(\n @client,\n { :interval_sec => interval_sec,\n :logger => @logger,\n :use_separate_messages => args[:use_separate_messages],\n })\n\n @current_version = 0\n @saved_version = 0\n\n @state_mutex = Mutex.new\n @current_version_condition = ConditionVariable.new\n\n if args[:state_file]\n @state_file = args[:state_file]\n if File.exists?(@state_file)\n @state_mutex.synchronize do\n File.open(@state_file, 'r') do |f|\n deserialize(f) or raise RuntimeError.new(\n \"Unable to load state from #@state_file.\")\n end\n end\n end\n\n @save_thread = Thread.new { loop { save_state_when_changed } }\n @save_interval = 10 # Wait at least 10 sec between saving state.\n @last_save_time = 0\n end\n end",
"def start_bot\n bot = Nexy::Irc::Bot.new\n bot.start\n bot\nend",
"def set_defaults\n self.state ||= 'NEW'\n self.account_id ||= Gizmo::Util::Uuid.generate\n self.account_name ||= self.subdomain\n end",
"def init!\n @defaults = {\n :@refresh_token => ShakeTheCounter::Config.refresh_token,\n :@id => ShakeTheCounter::Config.client_id,\n :@secret => ShakeTheCounter::Config.client_secret,\n :@language_code => ShakeTheCounter::Config.language_code,\n }\n end",
"def simulate!\n bots = @bot_specifications.each_with_object({}) do |(bot, spec), hash|\n initial_values = @initial_values.find_all { |k, v| v == bot }\n hash[bot] = Bot.new(initial_values.map(&:first), spec[:low], spec[:high])\n end\n\n loop do\n steps = bots.map { |id, bot| [id, bot.run_step] }.find_all(&:last)\n return if steps.empty?\n steps.each do |id, commands|\n commands.each do |command|\n case command[0]\n when :compared\n if @watch && command[1] == @watch[0] && command[2] == @watch[1]\n @watch[2].call(id)\n end\n when :give\n if command[1] == 'bot'\n recipient_bot = command[2]\n recipient_value = command[3]\n bots[recipient_bot].receive_value(recipient_value)\n elsif command[1] == 'output'\n recipient_output = command[2]\n recipient_value = command[3]\n puts \"output #{recipient_output} gets value #{recipient_value}\"\n end\n end\n end\n end\n end\n end",
"def initialize(bot = nil, update = nil)\n if update.is_a?(Hash) && (update.key?(:from) || update.key?(:chat))\n options = update\n update = nil\n end\n @_update = update\n @_bot = bot\n @_chat, @_from = options && options.values_at(:chat, :from)\n @_payload, @_payload_type = self.class.payload_from_update(update)\n end",
"def set_defaults\n # IRC Logging\n self.irc_log_file = ENV['IRC_LOG_FILE'] || STDOUT\n self.irc_log_rotation = ENV['IRC_LOG_ROTATION'] || 'weekly'\n self.irc_log_level = ENV['IRC_LOG_LEVEL'] || :INFO\n self.irc_adapter = ENV['IRC_ADAPTER'] || 'spunk'\n\n # IRC Login\n self.username = ENV['IRC_USERNAME'] || 'bender'\n self.fullname = ENV['IRC_FULLNAME'] || 'Bender'\n self.nickname = ENV['IRC_NICKNAME'] || 'bender'\n self.irc_server = ENV['IRC_SERVER'] || 'localhost'\n self.irc_port = ENV['IRC_PORT'] || 6667\n self.irc_token = ENV['IRC_TOKEN'] || nil\n self.nickserv_password = ENV['NICKSERV_PASSWORD'] || nil\n\n # HTTP\n self.disable_http = ENV['DISABLE_HTTP'] || false\n self.http_log_file = ENV['HTTP_LOG_FILE'] || '!BENDER_LOGGER'\n self.http_log_rotation = ENV['HTTP_LOG_ROTATION'] || 'weekly'\n self.http_log_level = ENV['HTTP_LOG_LEVEL'] || :INFO\n self.http_port = ENV['PORT'] || 9091\n self.http_max_clients = ENV['HTTP_MAX_CLIENTS'] || 4\n self.http_listen_address = ENV['HTTP_MAX_CLIENTS'] || '0.0.0.0'\n self.http_auth_token = ENV['HTTP_AUTH_TOKEN'] || nil\n\n self.pid_file = ENV['PID_FILE'] || './bender.pid'\n\n self.irc_rooms = ENV['IRC_ROOMS'] ? ENV['IRC_ROOMS'].split(',') : []\n self.irc_accept_invites = ENV['IRC_ACCEPT_INVITES'] ? ENV['IRC_ACCEPT_INVITES'].to_bool : true\n self.irc_use_ssl = ENV['IRC_USE_SSL'] ? ENV['IRC_USE_SSL'].to_bool : false\n\n self.log = MonoLogger.new(self.irc_log_file, self.irc_log_rotation)\n self.log.level = self.irc_log_level\n end",
"def initialize(*args)\n\t\t\t\tsuper\n\t\t\t\t#super called in order to call the same method from the parent class and then adding our thing (next line)\n\t\t\t\t@cleverbot = ::Cleverbot::Client.new #:: means look not at this namespace but at the very top and search down.\n\t\t\tend",
"def client\n @client ||= Line::Bot::Client.new { |config|\n config.channel_secret = 'a6d984f5eb9e6aaf8da518757c6f43e9'\n config.channel_token = '3Pz7B0d5DzzVndFPsA6hMkQerbpd0fERm7O1NzpW80M5KhI6KpAGQPYxzjE7R0fXa3vLqHbYhLWRet8fXlkdf4GaKrfsQKaTzgh8Fu9cnqR+wiHMOJ5mzzLUVeLXuaT7yuFxgCiq6Kd19TVj8ZnxQAdB04t89/1O/w1cDnyilFU='\n }\n end",
"def initialize(opts = {})\n @config = DEFAULTS.merge(opts)\n @buffer = Buffer.new\n @mutex = Mutex.new\n reconnect!\n end",
"def initialize()\n @bet = \"user:#{settings.id}:bet\"\n @redis = settings.redis\n @redis_money = \"user:#{settings.id}:money\"\n @redis_chips = \"user:#{settings.id}:chips\"\n @money = @redis.get @redis_money\n @money = @money.to_i\n end",
"def set_bot_instance\n @bot_instance = BotInstance.find(params[:id])\n end",
"def initialize\n @setup = false\n @reply_to = UUID.generate\n @pending = Hash.new\n end",
"def defaults\n default_pass = 'demo'\n \n self.step ||= 0 # can be 0, 1, 2, 3 (done)\n @timerange ||= TimeRange.new(Date.today.strftime(\"%F\"), \"15:00\", \"18:00\")\n self.party_of ||= 'single'\n self.host ||= User.new( :completeness => 'discovery', :password => default_pass ) # can receive current_user from the controller\n self.friend ||= User.new( :completeness => 'invite' ) # only validate if it's a single date\n end",
"def initialize(opts = {})\n @opts = opts\n @opts[:type] ||= :block\n @opts[:timeout] ||= 10\n\n sanitize_opts!\n create_client\n end",
"def set_bot\n @bot = Bot.find(params[:id])\n end",
"def initialize(options)\n @name = options[:name] || \"Unnamed Bot\"\n begin\n @data = YAML.load(File.open(options[:data_file]).read)\n rescue\n raise \"Can't load bot data\"\n end\n end",
"def bot_application\n return unless @type == :bot\n\n response = API.oauth_application(token)\n Application.new(JSON.parse(response), self)\n end",
"def initialize(settings)\n @settings = settings\n \n @botname = settings[\"botname\"]\n @server = settings[\"server\"]\n @port = settings[\"port\"]\n @channel = settings[\"channel\"]\n \n @socket = TCPSocket.open(@server, @port)\n\n connect # to IRC channel\n end",
"def initialize(api_user, api_key, nick = nil)\n @api_user = api_user\n @api_key = api_key\n @nick = nick\n @client = HTTPClient.new\n\n params = {\n user: @api_user,\n key: @api_key\n }\n params[:nick] = @nick unless @nick.nil?\n response = Oj.load(@client.post('https://cleverbot.io/1.0/create', params).body)\n try_throw(response['status'])\n @nick = response['nick']\n end",
"def defaults args\n args.state.enemies ||= []\n args.state.bullets ||= []\nend",
"def new(&block)\n Builder.new(&block).to_client\n end",
"def initialize(options)\n\t\t@name = options[:name] || \"Unnamed Bot\"\n\t\tbegin\n\t\t# Load data files\n\t\t\t@data = YAML.load(File.read(options[:data_file]))\n\t\t# In case data cannot be loaded\n\t\trescue\n\t\t\traise \"Can't load bot data\"\n\t\tend\n\tend",
"def spawn(options)\n # Check that all the required keys exist in the options hash\n required_values = [:server]\n required_values.each do |key|\n # If the given options don't include the required minimum options\n # We raise an error and don't let the bot spawn\n unless options.has_key?(key)\n raise InvalidArgumentError(\"You must provide at least the following parameters: #{required_values.join(', ')}\")\n end\n end\n\n # Merge options with defaults\n options = @defaults.merge(options)\n\n # Get identifier\n identifier = generate_identifier(options)\n\n # Format nickname\n prepared_nick = options[:nick] + format_identifier(identifier)\n\n # Plugins list\n plugins = options[:plugins] | common_plugins\n\n # Create new instance\n @spawns[identifier] = Cinch::Bot.new do\n configure do |c|\n c.server = options[:server]\n c.channels = options[:channels]\n c.nick = prepared_nick\n c.realname = options[:realname] || @defaults[:realname]\n c.user = options[:user] || @defaults[:user]\n c.password = options[:password] || nil\n c.reconnect = true\n c.plugins.plugins = plugins\n c.plugins.prefix = options[:plugins_prefix]\n c.storage.backend = Cinch::Storage::YAML\n c.storage.basedir = \"./data/\"\n c.storage.autosave = true\n end\n end\n\n # Save last spawn information\n @last_spawn = @spawns[identifier]\n @last_identifier = identifier\n\n # Increase spawn count\n @spawns_count += 1\n\n @last_spawn\n end",
"def _network_init\n # A note on special_rooms. Special rooms are \"rooms\" that may or may not\n # be tied to an actual chatroom, and even if they are, it may be inappropriate\n # to log their contents. Whiteboard rooms, for instance, are connected to\n # an actual chatroom, but logging the rooms' contents would be absurd.\n # Private message \"rooms\" aren't actual chatrooms, but logging is probably a\n # good idea. The special room hash persists across network restarts but is\n # not saved to disk. Any value evaluating to true means \"log\".\n special_rooms = @var.delete :special_rooms\n\n # Flush out all blacklisted state\n @var[:blacklist_env].each { |rm| @var.delete rm unless rm == :blacklist_env }\n @var[:special_rooms] = special_rooms\n\n # Add the key hashes\n @var[:user_keys].each do |name, key|\n keyhash = MD5::digest(key)[0,8]\n @connection.comm.rsa_keys[name] = key\n @connection.comm.names[keyhash] = name\n end\n\n # Keys and access\n @var[:granted] = [ @var[:our_name] ]\n @var[:granted_by] = [ @var[:our_name] ]\n @var[:revoked] ||= []\n\n # Chat rooms and presense\n @var[:room] = 'chat' # current room\n @var[:membership] = {} # maps room-name to known room members' keyhashes\n @var[:presence] = {} # maps peer keyhash to presence + salutation\n @var[:membership][EMPTY_ROOM] = [ @connection.comm.our_keyhash ]\n @var[:presence][@connection.comm.our_keyhash] = [ 'offline', '' ]\nend",
"def create_default_client(client_opts = {}, member_opts = {})\n last_name = Faker::Name.last_name.upcase\n given_names = Faker::Name.first_name.upcase\n birth_date = Faker::Date.between(from: 60.years.ago, to: 21.years.ago)\n title = Faker::Name.prefix.gsub(\".\", \"\").upcase\n sex = [\"M\", \"F\",].sample\n marital_status = [\"D\", \"M\", \"S\", \"W\", \"X\", nil].sample\n # email = Faker::Internet.email\n email = \"Project_testemail@qsuper.qld.gov.au\"\n birth_place = \"TEST AUTOMATION FARM\"\n post_code = \"4000\"\n \n default_options = {\n :surname => last_name,\n :given_names => given_names,\n :birth => birth_date,\n :title => title, # Mrs. => MRS\n :sex => sex,\n :marital_status => marital_status,\n :state => \"QLD\",\n :birth_place => birth_place,\n :email=> email,\n :post_code => post_code\n }\n puts \"[INFO] merge client options: #{client_opts}\"\n client = Client.new(default_options.merge(client_opts))\n client.save # will create one in Acurity\n\n default_member_options = {\n :fund => \"GSUP\", \n :payroll => \"031000\", \n :category => \"AP\",\n :client_number => client.client_number, \n :joined_fund => Faker::Date.between(from: 3.years.ago, to: 1.years.ago).to_s,\n :status => \"C\"\n }\n unless member_opts.nil? \n member = Member.new(default_member_options.merge(member_opts))\n member.save\n end\n \n if member \n return client.client_number, member.member, client\n else\n return client.client_number, nil, client\n end\n end",
"def new(*)\n # return new mock session\n BunnyMock::Session.new\n end",
"def turbot_api\n @turbot_api ||= begin\n require 'turbot_api'\n\n Turbot::API\n end\n end",
"def init\n\t\t@state = NewGame.new(self)\n\t\t# Deck.create({:game => self})\n\tend",
"def set_defaults\n self.mmr ||= 1500\n self.k_value ||= 40\n self.home_mmr ||= self.mmr\n self.away_mmr ||= self.mmr\n self.active ||= true\n self.total_games ||= 0\n end",
"def on_connect(*)\n @storage = TickingAway::JSONFileStorage.new\n @ta_bot = config[:time_api] ? TickingAway::Bot.new(storage: @storage, time_api: config[:time_api]) : TickingAway::Bot.new(storage: @storage)\n end",
"def set_defaults\n self.state ||= 'NEW'\n self.user_id ||= Gizmo::Util::Uuid.generate\n end",
"def initialize_vars\n # Initialize global variables\n $config = nil\n $channel = nil\n $mapping_channel = nil\n $nv2_channel = nil\n $content_channel = nil\n $last_potato = Time.now.to_i\n $potato = 0\n $last_mishu = nil\n $status_update = Time.now.to_i\n $twitch_token = nil\n $twitch_streams = {}\n $boot_time = Time.now.to_i\n $active_tasks = {}\n $memory_warned = false\n $memory_warned_c = false\n $linux = RbConfig::CONFIG['host_os'] =~ /linux/i\n $mutex = { ntrace: Mutex.new }\n\n # Set environment variables\n ENV['DISCORDRB_NONACL'] = '1' # Prevent libsodium warning message\n\n # Create additional needed folders\n [DIR_LOGS].each{ |d| Dir.mkdir(d) unless Dir.exist?(d) }\n\n log(\"Initialized global variables\")\nrescue => e\n fatal(\"Failed to initialize global variables: #{e}\")\n exit\nend",
"def s\n @state_wrapper ||= EntwinedWrapperObject.new(@subgame_state.state, @subgame_state)\n end",
"def oai_config\n blacklight_config.oai || {}\n end",
"def initialize\n @betId = nil\n @gameId = nil\n @game = nil\n @type = nil\n @state = nil\n @betAmount = nil\n @result = \"Undefined\"\n @odd = nil\n end",
"def default_body_obj(*args)\n BoundBody.new(*args)\n end",
"def initialize(options = {})\n @me = ''\n @nicknames = options[:nicknames]\n @registered = false\n @username = options[:username]\n @realname = options[:realname]\n @address = options[:address]\n @port = options[:port] || 6667\n @silent = options[:silent] || false\n @loud = options[:loud] || false\n @throttle_seconds = options[:throttle_seconds] || 1\n @password = options[:server_password]\n\n # Read in map of event numbers and names. Yes, I stole this event map\n # file from RubyIRC and made very minor changes.... They stole it from\n # somewhere else anyway, so it's okay.\n eventmap = \"#{File.dirname(__FILE__)}/yail/eventmap.yml\"\n @event_number_lookup = File.open(eventmap) { |file| YAML::load(file) }.invert\n\n # We're not dead... yet...\n @dead_socket = false\n\n # Build our socket - if something goes wrong, it's immediately a dead socket.\n begin\n @socket = TCPSocket.new(@address, @port)\n rescue StandardError => boom\n report \"+++ERROR: Unable to open socket connection in Net::YAIL.initialize: #{boom.inspect}\"\n @dead_socket = true\n end\n\n # Shared resources for threads to try and coordinate.... I know very\n # little about thread safety, so this stuff may be a terrible disaster.\n # Please send me better approaches if you are less stupid than I.\n @input_buffer = []\n @input_buffer_mutex = Mutex.new\n @privmsg_buffer = {}\n @privmsg_buffer_mutex = Mutex.new\n\n # Buffered output is allowed to go out right away.\n @next_message_time = Time.now\n\n # Setup handlers\n @handlers = Hash.new\n setup_default_handlers\n end",
"def default_values!\n self.name ||= 'DEFAULT ACHIEVEMENT'\n self.description ||= 'This is a default achievement.'\n end",
"def agent\n @agent ||= initialize_agent\n end",
"def oai_config\n blacklight_config.oai || {}\n end",
"def oai_config\n blacklight_config.oai || {}\n end",
"def with_bot(key)\n if bot = bot(key)\n yield bot\n else\n log(\"Unknown bot: #{key}\")\n end\n end",
"def initialize(*args)\n super\n\n @config = @bot.config\n @db = @config.db\n @keywords = eval(\"/#{@config.keywords.join(\"|\")}/i\")\n @passwd = config['command']['password'] ||\n Digest::SHA1.hexdigest(\"impersonate!\")\n @users = []\n end",
"def initialize (is_open, is_locked, inscription_message = nil)\n\n @is_open = is_open\n @is_locked = is_locked\n @inscription = inscription_message\n\n end",
"def set_bot\n @bot = Bot.find(params[:bot_id])\n authorize @bot\n end",
"def use_defaults_if_nil\n @move = TactBattleManager::Defaults::Move if @move.nil?\n @jump_length = TactBattleManager::Defaults::Jump if @jump_length.nil?\n @passables = TactBattleManager::Defaults::Passables if @passables.nil?\n @jumpables = TactBattleManager::Defaults::Jumpables if @jumpables.nil?\n end",
"def initialize(await, event, bot)\n @await = await\n @event = event\n @bot = bot\n end",
"def initialize_current_gfx(nome_game)\n @log.debug \"**** bot: initialize current gfx #{nome_game}\"\n #p self.app_settings\n select_engine(nome_game)\n #@current_game_gfx = eval(@game_to_play[:class_name]).new()\n # override @game_bot_name only to use a test robot. For a game GameBasebot is enought\n # simply add the new game to @all_games_bots\n \n @current_game_gfx = eval( @game_bot_name ).new #GameBasebot.new\n @current_game_gfx.set_game_info(@game_to_play[:core_name],\n @game_to_play[:alg_name], @game_to_play[:key],\n @game_to_play[:nalgfx_name],\n @login_name)\n @current_game_gfx.net_controller = @control_net_conn\n @current_game_gfx.join_game = @join_game\n #p self.app_settings\n end",
"def new *args\n instance = __actor_new *args\n instance.instance_variable_set :@audience, {}\n instance.instance_variable_set :@mailbox, Queue.new\n \n audience = {}\n audience[:before] = {}\n audience[:after] = {}\n instance.instance_variable_set :@audience, audience\n\n Thread.new do\n loop do\n mailbox = instance.instance_variable_get :@mailbox\n method_name, args, block = mailbox.pop\n \n if audience[:before][method_name]\n audience[:before][method_name].each { |callback| callback.call }\n end\n\n result = instance.method(method_name).call *args, &block\n \n if audience[:after][method_name]\n audience[:after][method_name].each { |callback| callback.yield result }\n end\n end\n end\n\n Proxy.new instance\n end",
"def set_default_options!\n @options ||= OpenStruct.new\n @options.skip_uncovered = false\n @options.mute = false\n @options.reports = []\n end",
"def initialize\n @savon_client = nil\n @message_body = {}\n end",
"def crawlbot options = {}\n Diffbot::APIClient::Crawlbot.new self, options\n end",
"def init_bots\r\n p1 = Player.new(\"José\")\r\n p2 = Player.new(\"Josiane\")\r\nend",
"def initialize(**args)\n @user_data = (args[:user_data] || {})\n @conversation_state = (args[:conversation_state] || DismalTony::ConversationState.new(idle: true, user_identity: self))\n \n possible = ('A'..'Z').to_a + ('a'..'z').to_a + ('0'..'9').to_a\n @user_data[:uuid] ||= (0..24).each_with_object([]) { |_n, i| i << possible.sample }.join\n end",
"def set_bot\n @bot = Bot.find(params[:id])\n authorize @bot\n end",
"def default_body_obj(*args)\n Body.new(*args)\n end",
"def initialize(online = false)\n @online = online\n end"
] |
[
"0.6545891",
"0.6527316",
"0.63246363",
"0.6132673",
"0.5985924",
"0.59445447",
"0.5904658",
"0.58430815",
"0.5829416",
"0.56998587",
"0.56829256",
"0.5665055",
"0.56577706",
"0.5585114",
"0.5574673",
"0.5553582",
"0.5547002",
"0.5543602",
"0.5518594",
"0.54613763",
"0.5420345",
"0.54015166",
"0.53504",
"0.53356385",
"0.53095734",
"0.5291902",
"0.5249321",
"0.5249303",
"0.5238489",
"0.5207552",
"0.52031946",
"0.52013755",
"0.51769006",
"0.5176295",
"0.51652735",
"0.5162242",
"0.5156264",
"0.5155344",
"0.51522845",
"0.5123283",
"0.5115032",
"0.5108822",
"0.5065703",
"0.5055016",
"0.5054858",
"0.5049194",
"0.50434476",
"0.50361794",
"0.5036039",
"0.5035359",
"0.5032229",
"0.5023827",
"0.5016117",
"0.50160027",
"0.50104964",
"0.50023764",
"0.4985949",
"0.49802884",
"0.49790052",
"0.49757904",
"0.49756983",
"0.49753907",
"0.4969836",
"0.49655962",
"0.496478",
"0.49596232",
"0.49478564",
"0.49401504",
"0.49370164",
"0.49317595",
"0.49310058",
"0.49276462",
"0.4922409",
"0.49178073",
"0.49127382",
"0.48892736",
"0.48735657",
"0.48733944",
"0.48658928",
"0.4854125",
"0.48502138",
"0.48374343",
"0.48349264",
"0.48349264",
"0.4830386",
"0.48286507",
"0.48114517",
"0.4810799",
"0.4805523",
"0.4804565",
"0.48032564",
"0.4797086",
"0.47939095",
"0.47902682",
"0.47902516",
"0.4786937",
"0.47858104",
"0.4785363",
"0.47842994",
"0.4781075"
] |
0.6130291
|
4
|
Which server is the bot connected to?
|
def server
@bot.server
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def current_server\n @_current_server\n end",
"def current_server\n @_current_server\n end",
"def server\n @server.to_s\n end",
"def get_server\n get_general['server']\n end",
"def bot_mode\n self['BOT']\n end",
"def server\n servers[0]\n end",
"def server_info\n check_connection\n @protocol.server_info\n end",
"def bot?\n bot.bot?\n end",
"def server_host\n Socket.gethostname\n end",
"def nick\n @bot.nick\n end",
"def server\n platform.server\n end",
"def info\n connection.server_info\n end",
"def client_name\n sockname[0]\n end",
"def server?\r\n @connect_type == :server\r\n end",
"def server\n arrayCommand( \"show server\", DictArray, RESPONSE_SERVER_INFO_FOLLOWS )\n end",
"def server\n arrayCommand( \"show server\", DictArray, RESPONSE_SERVER_INFO_FOLLOWS )\n end",
"def current_bot?\n @bot.profile.id == @id\n end",
"def server?\n return @mode == :server\n end",
"def botmaster\n $bot.servers.each{ |id, server|\n member = server.member(BOTMASTER_ID)\n return member if !member.nil?\n }\n err(\"Couldn't find botmaster\")\n nil\nrescue => e\n lex(e, \"Error finding botmaster\")\n nil\nend",
"def server?\n return (server == true)\n end",
"def server\n @@server ||= Server::Cli.new\n #@@server ||= Server::SkypeBot.new\n end",
"def current_server\n \"#{request.protocol}#{request.host_with_port}\"\n end",
"def server\r\n\t\t@usr_server\r\n\tend",
"def get_current_client\n get_current_hub&.current_client\n end",
"def server\n @servers.first\n end",
"def current_guild\n if current_user\n @current_guild || find_current_guild\n end\n end",
"def app_server\n app_server_integration.name\n end",
"def is_connected?\n if @client.is_connected?\n @log.info \"Asked if bot is connected: YES it is\"\n return true\n else\n @log.info \"Asked if bot is connected: NO it isn't\"\n return false\n end\n end",
"def get_outgoing_server\n @outgoing_server\n end",
"def client?\n return @mode == :client\n end",
"def hostname\n session.transport.socket.client_name\n end",
"def get_incoming_server\n @incoming_server\n end",
"def server_id\n @host.id\n end",
"def current_server\n drb = Thread.current['DRb']\n server = (drb && drb['server']) ? drb['server'] : @primary_server\n raise DRbServerNotFound unless server\n return server\n end",
"def server\n @server ||= ScoutScout::Server.first(client_id)\n end",
"def server\n node.server\n end",
"def connected?\n @bot.connected?\n end",
"def this_server\n if (s = @server)\n s\n elsif (t = @this)\n t.opts[:server] || :default\n else\n model.dataset.opts[:server] || :default\n end\n end",
"def this_server\n if (s = @server)\n s\n elsif (t = @this)\n t.opts[:server] || :default\n else\n model.dataset.opts[:server] || :default\n end\n end",
"def bot_user_id\n client.self.id\n end",
"def server_name\n return @server_name\n end",
"def server?\n @role == :server\n end",
"def connected?\n @bot.connected?\n end",
"def server\n @database.server\n end",
"def server\n @database.server\n end",
"def server_version\n check_connection\n @protocol.server_version\n end",
"def server_channel\n \"#{access_key}-server\"\n end",
"def server_name\n self.setup\n @server_name ||= self.attributes[\"connection\"]||self.class::DEFAULT_SERVER_NAME\n end",
"def client?\r\n @connect_type == :client\r\n end",
"def set_bot_server\n @bot_server = BotServer.find(params[:id])\n end",
"def host\n Socket.gethostname\n end",
"def host\n Socket.gethostname\n end",
"def is_bot?\n Bot.is_bot? request.user_agent\n end",
"def server_info()\n #This is a stub, used for indexing\n end",
"def server_version(server=nil)\n @server_version ||= (synchronize(server){|conn| conn.info[:id]})\n end",
"def find_connection host_info\n conn = @backend_connections.detect { |x| x.server_info == host_info }\n raise NoServerAvailable.new(\"BackgrounDRb server is not found running on #{host_info}\") unless conn\n return conn\n end",
"def inspect_server(server)\n strings = [server.hostname]\n if !is_unix_socket?(server)\n strings << \":#{server.port}\"\n strings << \":#{server.weight}\" if options[:ketama_weighted]\n end\n strings.join\n end",
"def get_bot_profile\n bot_profile = command.event.bot.profile.on(command.event.server)\n end",
"def default_server\n server?(:default)\n end",
"def get_server_version\n server_info[:server_version]\n end",
"def servercount\n url = \"https://discordbots.org/api/bots/#{@id}\"\n JSON.parse(RestClient.get(url))['server_count'].to_i\n end",
"def client\n user_thread.client\n end",
"def connection_for nick\n @connection_cache[nick]\n end",
"def bot()\n merge(bot: 'true')\n end",
"def connection_status_server; end",
"def socket_host; end",
"def client_name\n me.client.name\n end",
"def client_id\n connection.id\n end",
"def server_host\n AgileProxy.config.server_host\n end",
"def server_id\n @server_id ||= Gititback::Support.hostname\n end",
"def client?\n return (server == false)\n end",
"def server_mechanisms\n mechanisms :server\n end",
"def connector_server_name\n return @connector_server_name\n end",
"def msg_SERVER(source, args)\n if !@seenuplinkname\n # SERVER name 1 :desc\n Server.new(@uplinksid, args[0], args[2])\n @seenuplinkname = true\n end\n return nil\n end",
"def _determine_server_comm(srv_comm = datastore['ListenerComm'].to_s)\n case srv_comm\n when 'local'\n comm = ::Rex::Socket::Comm::Local\n when /\\A[0-9]+\\Z/\n comm = framework.sessions[srv_comm.to_i]\n raise(RuntimeError, \"Socket Server Comm (Session #{srv_comm}) does not exist\") unless comm\n raise(RuntimeError, \"Socket Server Comm (Session #{srv_comm}) does not implement Rex::Socket::Comm\") unless comm.is_a? ::Rex::Socket::Comm\n when nil, ''\n comm = nil\n else\n raise(RuntimeError, \"SocketServer Comm '#{srv_comm}' is invalid\")\n end\n\n comm\n end",
"def status\n passworded = (self.password != \"\")\n scrollback = self.scrollback\n log \"#{@server_name} running on GlobalChat2 3.0 platform Replay:#{scrollback} Passworded:#{passworded}\"\n end",
"def bot(key)\n @bots[key]\n end",
"def username\n client.username if client\n end",
"def check(client)\n client.user.current\n end",
"def client_name\n return @hostname if defined? @hostname\n\n sockaddr = @socket.getsockname\n begin\n @hostname =\n Socket.getnameinfo( sockaddr, Socket::NI_NAMEREQD ).first\n rescue\n begin\n @hostname = Socket.getnameinfo( sockaddr ).first\n rescue\n begin\n @hostname = Socket.gethostbyname( Socket.gethostname ).first\n rescue\n @logger.error \"the client ipaddr/name could not be determined\"\n end\n end\n end\n\n return @hostname\n end",
"def host\n @connection.host\n end",
"def connected?\n unless @server.nil?\n true\n else\n false\n end\n end",
"def connection_status_client_status; end",
"def client\n Thread.current[:client]\n end",
"def server(token, server_id)\n request(\n __method__,\n :get,\n \"#{api_base}/guilds/#{server_id}\",\n Authorization: token\n )\n end",
"def check_server_connection\n\t\tsession[:foo] = \"bar\" unless session.id \n\t\traise \"session.id is nil\" unless session.id\n\t\tunless @client = ClientConnections.get(session.id.public_id)\n\t\t\tredirect_to root_path, flash: { error: \"Please connect to a formulary server\" }\n\t\tend\n\tend",
"def check_server_connection\n\t\tsession[:foo] = \"bar\" unless session.id \n\t\traise \"session.id is nil\" unless session.id\n\t\tunless @client = ClientConnections.get(session.id.public_id)\n\t\t\tredirect_to root_path, flash: { error: \"Please connect to a formulary server\" }\n\t\tend\n\tend",
"def get_devserver\n devserver = all_info[:devserver]\n if devserver!=nil\n return devserver.split(':').last\n end\n end",
"def dev_host\n case Socket.gethostname\n when /romeo-foxtrot/i ; true\n else ; false\n end\nend",
"def get_server_greeting\n \"EventMachine SMTP Server\"\n end",
"def guild\r\n\t\t@usr_guild\r\n\tend",
"def server_info\n db(\"admin\").command({:buildinfo => 1}, {:admin => true, :check_response => true})\n end",
"def node\n @node ||= Socket.gethostname\n end",
"def peer_info; socket.peer_info if socket end",
"def from_server?\n @origin == :server\n end",
"def is_bot?\n !!self.bot_name\n end",
"def current_client\n self.clients.where(status: true).first\n end",
"def details\n data = servers_client.get(server_path, json_headers).body\n JSON.parse(data)['server']\n end",
"def connect\n say \"NICK #{@botname}\"\n say \"USER #{@botname} 0 * #{@botname}\"\n say \"JOIN #{@channel}\"\n end",
"def nick\r\n return for_context(nil, false) { |c| c.nick }\r\n end"
] |
[
"0.6890562",
"0.6890562",
"0.6842552",
"0.6810676",
"0.673647",
"0.67030543",
"0.6667216",
"0.6579218",
"0.65775716",
"0.65214145",
"0.64920014",
"0.6402963",
"0.63250816",
"0.630544",
"0.62802505",
"0.62802505",
"0.62707716",
"0.6261175",
"0.6242128",
"0.6240805",
"0.6227667",
"0.6208825",
"0.62086576",
"0.62024534",
"0.6177304",
"0.61654794",
"0.61651695",
"0.6155398",
"0.61465806",
"0.6121871",
"0.6116569",
"0.61153454",
"0.6110507",
"0.6109324",
"0.60977495",
"0.60861796",
"0.6074532",
"0.60742116",
"0.60742116",
"0.60708696",
"0.6068303",
"0.603826",
"0.600293",
"0.59941804",
"0.59941804",
"0.5981567",
"0.59727097",
"0.5957334",
"0.59569013",
"0.59567744",
"0.59045833",
"0.5902727",
"0.59020907",
"0.5897951",
"0.58813536",
"0.5867414",
"0.5863787",
"0.58324647",
"0.5816681",
"0.58101326",
"0.5805743",
"0.57742953",
"0.5772991",
"0.5770076",
"0.5763759",
"0.57622844",
"0.576082",
"0.5751508",
"0.57472694",
"0.57368016",
"0.57310236",
"0.5727999",
"0.5727922",
"0.57157254",
"0.57015693",
"0.5697899",
"0.5697606",
"0.5695632",
"0.5690363",
"0.56834066",
"0.56664884",
"0.5665871",
"0.56617004",
"0.5656701",
"0.5649117",
"0.5644272",
"0.5644272",
"0.5635896",
"0.56312025",
"0.5616837",
"0.5613966",
"0.5613901",
"0.56078476",
"0.5605191",
"0.55899924",
"0.5587293",
"0.5581261",
"0.55789745",
"0.5571576",
"0.5566651"
] |
0.7476169
|
0
|
Which nick does the bot currently have?
|
def nick
@bot.nick
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def nick\r\n return for_context(nil, false) { |c| c.nick }\r\n end",
"def nickname\n @nick\n end",
"def nick\n @name\n end",
"def nick(nick)\n @nick = nick\n sendmsg(\"NICK #{nick}\")\n end",
"def nick(msg)\n if msg.user.last_nick == @settings['identity']['nick']\n bot.nick = @settings['identity']['nick']\n return\n end\n str = sprintf('*** %s is now known as %s',msg.user.last_nick,msg.user.nick)\n # gotta log to every channel this user is in\n (msg.user.channels & msg.bot.channels).each do |channel|\n log(msg,str,channel)\n end\n @beans[:nick]+=1\n end",
"def getnick(nickname)\n send_command(:getnick, @options[:nickname] = nickname.to_s)\n read_response # \"Nickname set to #{nickname}\"\n self\n end",
"def on_nick msg\n return unless msg.connection == self\n\n if msg.me?\n @nick = msg.text\n return\n end\n end",
"def nick(nickname)\n raw \"NICK #{nickname}\\r\\n\"\n end",
"def connection_for nick\n @connection_cache[nick]\n end",
"def nick\n @prefix =~ PREFIX_PAT and $1\n end",
"def nickname\n data = get 'name', resource: 'leaderboard'\n data.name\n end",
"def nickname\n @nickname\n end",
"def change_nick(new_nick)\n nick new_nick\n end",
"def nickname\n user_info['nickname']\n end",
"def single_nick?\n @nick != '*'\n end",
"def nickname\n return @nickname\n end",
"def nicks\n match(/Nicks\\s+:\\s+([^\\s]+(?:\\s[^\\s]+)*)$/).split.map{|nick| Atheme::User.new(@session, nick)} rescue []\n end",
"def nick(nick)\n @socket << \"NICK #{nick}\"\n end",
"def nick(nicknam)\n raise 'invalid nick' unless IRC.nickname?(nicknam)\n @nickname = nicknam\n send_msg(\"NICK #{@nickname}\")\n end",
"def change_nick(nick)\n join(nick)\n end",
"def to_label\n nick\n end",
"def nickname\r\n return @user.nickname\r\n end",
"def getNick jid\n\t\tuser = @users.read [\"nick\"], [\"jid\", jid]\n\t\tif user.count > 0\n\t\t\tuser[0]['nick']\n\t\telse\n\t\t\tnil\n\t\tend\n\tend",
"def update_nick!\n discord_user.on(game.text_channel.server).nick = \"(#{score} AP) #{discord_nick}\"\n rescue\n # Fail silently if we can't change nicks\n end",
"def r_nick(event)\n report \"#{event.nick} changed nick to #{event.message}\" unless event.nick == @yail.me\n end",
"def modify_current_user_nick(guild_id, nick:)\n response = request(\n :guilds_gid_members_me_nick, guild_id,\n :patch,\n \"guilds/#{guild_id}/members/@me/nick\",\n nick: nick,\n )\n response.body\n end",
"def nick?(str)\n str.match(nick_regex) != nil\n end",
"def getNickFromId id\n\t\tuser = @users.read [\"nick\"], [\"id\", id]\n\t\tif user.count > 0\n\t\t\tuser[0]['nick']\n\t\telse\n\t\t\tnil\n\t\tend\n\tend",
"def on_nick_in_use msg\n return if @registered or msg.connection != self\n\n if @nick == Bot::Conf[:core][:nick]\n\n if Bot::Conf[:core].key? :altnick\n @nick =Bot::Conf[:core][:altnick]\n else\n @nick = 'TerminusBot'\n end\n\n raw \"NICK #{@nick}\"\n return\n end\n\n @nick << \"_\"\n\n raw \"NICK #{@nick}\"\n end",
"def r_nick(fullactor, actor, nickname)\n report \"#{actor} changed nick to #{nickname}\" unless nickname == @me\n end",
"def reply_to\n sent_to_channel? ? dest : nick\n end",
"def update_nick(new_nick)\n @last_nick, @name = @name, new_nick\n @last_id, @id = @id, sanitize(new_nick)\n @bot.user_list.update_nick(self)\n end",
"def changenick(m, n)\n @lastchanged = m.user.nick\n bot.nick = n\n end",
"def me?\n nick_canon == @connection.canonize(@connection.nick)\n end",
"def nick(m)\n channel_users do |users|\n unless users.has_key?(m.user.last_nick)\n fail \"user '#{m.user.last_nick}' not found\"\n end\n\n users[m.user.nick] = users[m.user.last_nick]\n users.delete(m.user.last_nick)\n\n users[m.user.nick].each do |chan|\n @loggers[chan].each { |l| l.log(:nick, m) }\n end\n end\n end",
"def nickname\n Blogical::Application.nickname\n end",
"def nick_canon\n @nick_canon ||= @connection.canonize @nick\n end",
"def nick_part(nick, reason=nil)\n return if not @names.include?(nick)\n\n @names.delete(nick)\n reason = \" (#{reason})\" if reason\n @bridge.add(:xmpp, :irc, SYSTEM_USER, \"#{nick} just left the IRC channel#{reason}\")\n end",
"def find(nick)\n @users.find { |u| u.nick.downcase == nick.downcase }\n end",
"def relayed_nick_parts\n @relayed_nick_parts ||= cinch_user.nick.split('/', 2)\n end",
"def change_own_nickname(token, server_id, nick)\n request(\n __method__,\n :patch,\n \"#{api_base}/guilds/#{server_id}/members/@me/nick\",\n { nick: nick }.to_json,\n Authorization: token,\n content_type: :json\n )\n end",
"def toggle_nick(bot, channel)\n @use_nicks[channel] = (not @use_nicks[channel] == true)\n \n if use_nicks?(channel)\n bot.say(\"Nicks will be sent with messages.\")\n else\n bot.say(\"Nicks will not be sent (omegle users will just see anonymous text)\")\n end\n end",
"def local_nick(body)\n name1 = _pop_token(body)\n name2 = _pop_token(body)\n raise \"Usage: /nick <old_name> <new_name>\" if name1.to_s.empty?\n if name2.to_s.empty?\n name2 = name1\n name1 = @var[:our_name]\n end\n raise \"Name '#{name2}' is already in use\" if @var[:user_keys][name2]\n\n # Perform the renaming\n kh = @connection.comm.sender_keyhash(name1)\n key = @connection.comm.rsa_keys[name1]\n raise \"Invalid user name: '#{name1}'\" unless kh and key\n @connection.comm.rsa_keys[name2] = key\n @connection.comm.rsa_keys.delete(name1)\n @connection.comm.names[kh] = name2\n @var[:user_keys][name2] = key\n @var[:user_keys].delete name1\n @var[:granted].collect! { |x| x = name2 if x == name1 ; x }\n @var[:granted_by].collect! { |x| x = name2 if x == name1 ; x }\n @var[:revoked].collect! { |x| x = name2 if x == name1 ; x }\n \n # And lastly, if this is us, update our special name attribute\n @var[:our_name] = name2 if @var[:our_name] == name1\n _notice(\"#{name1} is now known as #{name2}\")\n _save_env\nend",
"def nickname(user)\n nickname = (!user.blank? && !user.nickname.blank?)? user.nickname : I18n.t('guest_name')\n nickname\n end",
"def get_user_with_nick(nick)\n @users.values.each do |u|\n return u if u.nick == nick\n end\n nil\n end",
"def invent_nick(jid)\n /^([^@]+)/ =~ jid.to_s\n return jid if not $1 or not User.valid_nick?($1)\n return $1 if not get_user_with_nick($1)\n (2 .. 100).each do |i|\n new_nick = \"#{$1}#{i}\"\n return new_nick if not get_user_with_nick(new_nick)\n end\n jid\n end",
"def who\n\t\t\t@username\n\t\tend",
"def on_nick(connection, before, after)\n end",
"def isNickAuthed(usr)\n msg(\"NickServ\", \"ACC #{usr}\")\n data = nickservData(@IRCsocket.readline.split(\" \"))\n if(data[\"rusr\"] == \"NickServ\" && data[\"to\"] == @name && data[\"usr\"] == usr && data[\"status\"] == \"3\")\n return true\n else\n return false\n end\n end",
"def colorize_nick(gamer)\n if gamer[:premium?]\n case gamer.role\n when 2\n Format(:green, gamer.irc_nick)\n else\n Format(:yellow, gamer.irc_nick)\n end\n else\n gamer.irc_nick\n end\n end",
"def change_nick(new_nick)\n return false if not User.valid_nick?(new_nick)\n @nick = new_nick.to_s\n true\n end",
"def normalise_nick(nick)\n return /^[@+]?(.*)$/.match(nick)[1]\n end",
"def reveal_author(nick)\n case nick\n when 'lddev' then 'MM'\n when '1bardesign' then 'Geti'\n when 'flieslikeabrick' then 'FliesLikeABrick'\n else I18n.news_fetcher.someone\n end\n end",
"def nickname\n (preferred_name && !preferred_name.strip.empty?) ? preferred_name : first_name\n end",
"def current_guild\n if current_user\n @current_guild || find_current_guild\n end\n end",
"def get_current_winner\r\n if self.rank_one == nil\r\n return nil\r\n else\r\n return rank_one.owner\r\n end\r\n end",
"def get_nickname(member)\n nickname = \"\"\n entry = @client[:nicknamer].first(server_id: member.server.id, role: member.colour_role.id)\n if entry\n nickname += (entry[:upper_prefix] || \"\") + \" \"\n end \n\n nickname += member.roles.map {|role| \n role_entry = @client[:nicknamer].first(server_id: role.server.id, role: role.id)\n role_entry[:normal_prefix] if role_entry\n }.join(\" \")\n nickname += member.name + \" \"\n \n nickname += member.roles.map {|role| \n role_entry = @client[:nicknamer].first(server_id: role.server.id, role: role.id)\n role_entry[:normal_suffix] if role_entry\n }.join(\" \")\n\n if entry\n nickname += (entry[:upper_suffix] || \"\")\n end \n nickname\n end",
"def without_nick(message)\n possible_nick, command = message.split(' ', 2)\n if possible_nick.casecmp(at_nick) == 0\n command\n else\n message\n end\n end",
"def send_nick(n=@nick)\n @nick = n\n @connection.send_data(make_packet(\"nick\", {\"name\" => n}))\n end",
"def current_player_name\n Player.find(player_turn).name unless player_turn.nil?\n end",
"def username\n client.username if client\n end",
"def cwhois(m, nick)\n nick = User(nick)\n if is_supadmin?(m.user) || is_admin?(m.user) || is_chanadmin?(m.channel, m.user) || is_mod?(m.user)\n if userroles(m.channel,nick).empty?\n m.reply \"That's #{nick},\" + (!User(nick).authname.nil? ? \" authenticated as #{User(nick).authname},\" : \" unauthenticated,\") + \" with no roles.\"\n else\n m.reply \"That's #{nick}, \" + (!User(nick).authname.nil? ? \" authenticated as #{User(nick).authname},\" : \" unauthenticated,\") + \" with the following roles #{userroles(m.channel,nick)}.\", true\n end\n else\n m.reply NOTADMIN, true\n end\n end",
"def on_nick_already_in_use(connection, nick_name)\n end",
"def name\n [\n model.discord_guild.name,\n model.discord_user.username\n ].join(' - ')\n end",
"def change_nickname(token, server_id, user_id, nick)\n request(\n __method__,\n :patch,\n \"#{api_base}/guilds/#{server_id}/members/#{user_id}\",\n { nick: nick }.to_json,\n Authorization: token,\n content_type: :json\n )\n end",
"def nickname\n (f, l) = full_name.split(\" \", 2)\n \"#{f}#{l.split(/[\\s']/).collect(&:first).join}\"\n end",
"def username\n \"rocky\"\n end",
"def cpanel_username\n @username = `/scripts/whoowns #{domain}`.chomp\n username\n end",
"def username\n account = github_accounts.first || slack_accounts.first\n account ? account.username : id\n end",
"def get_nickname(user_info)\n return user_info[\"screen_name\"]\n end",
"def nickname\n @attributes[:nickname]\n end",
"def irc_nick_event(stem, sender, arguments) # :nodoc:\n @nick = arguments[:nick] if sender[:nick] == @nick\n @chan_mutex.synchronize do\n @channel_members.each { |chan, members| members[arguments[:nick]] = members.delete(sender[:nick]) }\n #TODO what should we do if we are in the middle of receiving NAMES replies?\n end\n end",
"def network_label\n network == \"users\" ? \"\" : network\n end",
"def target_channel\n name = case self.command\n when :invite then self.params[1]\n when RPL_NAMREPLY then self.params[2]\n when ERR_USERNOTINCHANNEL then self.params[2]\n when ERR_USERONCHANNEL then self.params[2]\n when ERR_UNKNOWNMODE then self.trail[/\\S+$/]\n else self.params.fetch(numeric? ? 1 : 0, \"\")\n end\n\n if name.start_with?('&', '#', '+', '!')\n return name\n end\n\n return nil\n end",
"def guild\r\n\t\t@usr_guild\r\n\tend",
"def renickify \n @bot.msg(\"nickserv\", \"ghost #{bot.nick} pearljam\")\n @bot.msg(\"nickserv\", \"identify pearljam\")\n @bot.nick = 'infobot-clone'\n return \"Renickifying!\"\n end",
"def guild_name\n\t\t@guild_name\n\tend",
"def setNick(server,nick)\n if(@connectors.has_key?(server))\n @connectors[server].nick=nick\n end\n end",
"def connected_with? nick\n @connection_cache.has_key? nick\n end",
"def screen_name\n name || nickname\n end",
"def current_bot?\n @bot.profile.id == @id\n end",
"def random_nick() (0..8).map { rand(65..90).chr }.join'' end",
"def nick_quit(nick, reason=nil)\n nick_part(nick, reason)\n end",
"def connect\n say \"NICK #{@botname}\"\n say \"USER #{@botname} 0 * #{@botname}\"\n say \"JOIN #{@channel}\"\n end",
"def _user_name(kh)\n @connection.comm.sender_name(kh) || 'unknown_user'\nend",
"def current_user_screen_name\n session[:user_info][\"nickname\"]\n end",
"def nick_change(nick, new_nick)\n @names.delete(nick) if @names.include?(nick)\n @names << new_nick \n\n @bridge.add(:xmpp, :irc, SYSTEM_USER, \"#{nick} is now known as #{new_nick}\")\n end",
"def send_whois(nick)\n send_raw(WHOIS, nick)\n end",
"def username\n return username_nada if !username_nada.nil?\n username_kth\n end",
"def nickname=(value)\n @nickname = value\n end",
"def winner\n\t\tvictor = false\n\t\tvictor = \"Player1\" unless @board.on_board? player2.tokens[-1][0].position\n\t\tvictor = \"Player2\" unless @board.on_board? player1.tokens[-1][0].position\n\t\tvictor\n\tend",
"def displayed_name_for(watchman)\n conns=watchman.friend_connections.where(friend: self)\n if conns.present?\n conns.first.name\n else\n displayed_name\n end \n end",
"def current_player()\n # Assume player X goes first\n return turn_count() % 2 == 0 ? \"X\" : \"O\"\n end",
"def now_playing_user(m)\n\t\t\t\tnick = @backend.get(m.user)\n\t\t\t\tif nick\n\t\t\t\t\tartist, track = get_data(nick)\n\t\t\t\t\tm.reply(\"#{nick} has recently played: #{artist} - #{track}\")\n\t\t\t\tend\n\t\t\tend",
"def nickname\n return @poco_data[:nickname] unless @poco_data == nil\n pick_first_node(@poco.xpath('./poco:nickname'))\n end",
"def displayed_name_for(watchman)\n conns = watchman.friend_connections.where(friend: self)\n conns.present? ? conns.first.name : displayed_name\n end",
"def setnick(nickname)\n send_command(:setnick, @options[:nickname] = nickname.to_s)\n read_response # \"Nickname set to #{nickname}\"\n self\n end",
"def set_nickname\n @nickname = Nickname.find(params[:id])\n end",
"def read_message\n if (line = @sock.gets and msg = IRC.parse_message(line))\n case msg.command\n when IRC::RPL_WELCOME\n i = msg.params[-1].rindex(' ') || -1\n @prefix = msg.params[-1][i + 1..-1]\n when IRC::CMD_PING\n pong(msg)\n when IRC::CMD_NICK\n # check if our nick got changed by the server\n @nickname = msg.params[0] if msg.nick == @nickname\n end\n msg\n end\n end",
"def full_username\r\n return @user.username + '#' + @user.discriminator\r\n end"
] |
[
"0.7959913",
"0.78586936",
"0.7832504",
"0.73713166",
"0.7224003",
"0.71348643",
"0.7099389",
"0.7083882",
"0.69918257",
"0.6970741",
"0.69122684",
"0.6911308",
"0.6890828",
"0.68761694",
"0.6825434",
"0.6795342",
"0.67913824",
"0.67271507",
"0.67045605",
"0.66967267",
"0.6673891",
"0.6610119",
"0.658278",
"0.65698147",
"0.6564736",
"0.65577644",
"0.6526703",
"0.6483771",
"0.6471724",
"0.64716613",
"0.6471563",
"0.646937",
"0.64387214",
"0.64314896",
"0.6427063",
"0.6390184",
"0.6362713",
"0.63593906",
"0.6349454",
"0.6339367",
"0.63298225",
"0.6329431",
"0.6315635",
"0.6291385",
"0.62876916",
"0.6272772",
"0.6244101",
"0.6227348",
"0.6211636",
"0.620294",
"0.6188956",
"0.6176673",
"0.61672103",
"0.61601746",
"0.615803",
"0.6151209",
"0.61357856",
"0.61016583",
"0.60586447",
"0.6057105",
"0.6027769",
"0.6023735",
"0.6020124",
"0.601965",
"0.60102427",
"0.6009257",
"0.5997022",
"0.5994689",
"0.5985779",
"0.59845215",
"0.5961483",
"0.59524584",
"0.5951176",
"0.59309745",
"0.59269917",
"0.5921739",
"0.59145814",
"0.59102654",
"0.59046084",
"0.58808243",
"0.58461785",
"0.5837966",
"0.58313584",
"0.5826223",
"0.5825948",
"0.58208615",
"0.5816031",
"0.5806251",
"0.5805896",
"0.5805105",
"0.5794797",
"0.5780903",
"0.5778971",
"0.5760371",
"0.5756601",
"0.5724352",
"0.57180136",
"0.5716617",
"0.57154465",
"0.57090896"
] |
0.8594065
|
0
|
Tell the bot to join a channel
|
def join(channel)
@bot.join(channel)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def channel_join(m, channel)\r\n if_admin(m) { @bot.join(channel) }\r\n end",
"def join(channel)\n\t\t\tsend_to_server(\"JOIN #{channel}\")\n\t\tend",
"def join_channel(message)\n message.send_raw \"JOIN ##{message.channel.name}\"\n end",
"def irc_send_join(channel)\n # We send an IRC message that joins a channel\n irc_send(\"JOIN #{channel}\")\nend",
"def join(m, channel)\n return unless @bot.admin?(m.user)\n Channel(channel).join\n end",
"def join(channel)\n self.class.post('/channels.join', body: {name: channel, token: @token}).tap do |response|\n raise \"error posting message: #{response.fetch('error', 'unknown error')}\" unless response['ok']\n end\n end",
"def join\n if request_valid?\n request_user.online!\n \n msg = message(\"joined\")\n msg = javascript_chat_message(msg)\n \n # Inform all joined channels that the user has joined\n Juggernaut.send_to_channels(msg, params[:channels])\n \n render :nothing => true\n else\n # Prevent the user from joining the channel if the request is not\n # from a valid session/user combination\n render :text => \"403\", :status => 403\n end\n end",
"def on_join(connection, channel, user)\n end",
"def join_channel(channel, password=nil)\n channel = normalized_channel_name(channel)\n return if channels.include? channel\n join channel, password\n @channel_passwords[channel] = password if password\n end",
"def in_a_channel \n unless joined_channel?\n flash[:danger] = \"Please join a channel\"\n redirect_to join_channel_url\n end\n end",
"def someone_did_join_channel(stem, person, channel)\n end",
"def join(channel)\n if channel.is_a?(Channel)\n @channels.push(channel)\n else\n @channels.push(Channel.find(channel))\n end\n end",
"def join(m)\n # self.reset_timer(m)\n if Channel(@channel_name).has_user?(m.user)\n if @game.accepting_players?\n added = @game.add_player(m.user)\n unless added.nil?\n Channel(@channel_name).send \"#{m.user.nick} has joined the game (#{@game.players.count}/#{@game.max_players})\"\n Channel(@channel_name).voice(m.user)\n end\n else\n if @game.started?\n Channel(@channel_name).send \"#{m.user.nick}: Game has already started.\"\n elsif @game.at_max_players?\n Channel(@channel_name).send \"#{m.user.nick}: Game is at max players. Switch to ONUWW to add more players\"\n else\n Channel(@channel_name).send \"#{m.user.nick}: You cannot join.\"\n end\n end\n else\n User(m.user).send \"You need to be in #{@channel_name} to join the game.\"\n end\n end",
"def changeChannel(channel, password)\n @IRCsocket.write(\"PART #{@ch}\\n\")\n @ch = channel\n @ch_pw = password\n @IRCsocket.write(\"JOIN #{@ch} #{@ch_pw}\\n\")\n end",
"def msg_JOIN(source, args)\n u = User.find(source)\n if u == nil\n return nil\n end\n\n if args[0] == '0' && args.length == 1\n u.channels.each do |c|\n c.del_user(u)\n end\n u.part_all()\n return nil\n end\n\n # Ignoring TS rules since we don't even keep track of cmodes\n\n c = Channel.find_by_name(args[1])\n if c == nil\n c = Channel.new(args[1], args[0].to_i())\n end\n\n c.add_user(u)\n u.join(c)\n return nil\n end",
"def join_channel(chan, bot)\n\n @channel_mutex.synchronize{\n @channels[chan] = bot\n }\n\n # First, stop listening for this event\n # unregister_hooks(\"twitter_join_#{chan}\".to_sym)\n\n # And hook for when we leave it\n me = self\n register_hook(\"twitter_part_#{chan}\".to_sym, lambda{|m| m.channel == chan}, /part/){\n me.part( bot, channel ) if nick == bot_nick # Ensure we only fire if the bot has parted, not other people\n }\n register_hook(\"twitter_quit_#{chan}\".to_sym, lambda{|m| m.channel == chan}, /kick/){\n me.part( bot, channel ) \n }\n end",
"def c_join(chan)\n if @muc[chan].nil? then\n\t\t @muc[chan], junk = Muc.new(chan, self, @jid, @pass, @confhost)\n else\n on_join(muc)\n end\n end",
"def link_to_channel(text, channel_name, *args)\n link_to_function text, \"CCPEVE.joinChannel(#{channel_name.inspect})\", *args\n end",
"def join(m, channel_name = nil)\n channel = channel_name ? Channel(channel_name) : m.channel\n\n if (game2 = @user_games[m.user])\n # Be silent if the user's game is already started and user re-joins it\n # by sending !join in the same channel, or !join in a PM\n # This is so games can reuse the join command.\n different_channel = channel && channel.name != game2.channel_name\n m.reply(\"You are already in the #{game2.channel_name} game\", true) if different_channel\n return\n end\n\n if (waiting_room = @user_waiting_rooms[m.user])\n m.reply(\"You are already in the #{waiting_room.channel_name} game\", true)\n return\n end\n\n unless channel\n m.reply('To join a game via PM you must specify the channel: ' +\n '!join #channel')\n return\n end\n\n waiting_room = @waiting_rooms[channel.name]\n unless waiting_room\n m.reply(channel.name + ' is not a valid channel to join', true)\n return\n end\n\n unless channel.has_user?(m.user)\n m.reply(\"You need to be in #{channel.name} to join the game.\", true)\n return\n end\n\n if @games[channel.name]\n m.reply('Game has already started.', true)\n return\n end\n\n if waiting_room.size >= waiting_room.capacity\n m.reply(\"Game is already at #{waiting_room.capacity} players, the maximum supported for #{self.game_name}.\", true)\n return\n end\n\n waiting_room.add(m.user)\n channel.send(\"#{m.user.nick} has joined the game (#{waiting_room.size}/#{waiting_room.capacity})\")\n channel.voice(m.user)\n @user_waiting_rooms[m.user] = waiting_room\n end",
"def join_channel(channel_id, opts = {})\n data, _status_code, _headers = join_channel_with_http_info(channel_id, opts)\n data\n end",
"def _in_invited(event)\n join event.channel\n end",
"def connect\n say \"NICK #{@botname}\"\n say \"USER #{@botname} 0 * #{@botname}\"\n say \"JOIN #{@channel}\"\n end",
"def user_join_channel\n @lecture = Lecture.find(params[:lecture])\n @user = current_user\n join_channel_slack\n flash[:notice] = \"Vous avez rejoins le canal sur Slack, félicitations! Ouvrez maintenant slack et échangez avec les profs et les élèves...\"\n redirect_to lecture_path(@lecture)\n end",
"def join(channels, keys = nil)\n channels = comma_join(channels) if channels.is_a?(Array)\n keys = comma_join(keys) if keys.is_a?(Array)\n send_msg(\"JOIN #{channels} #{keys}\".rstrip)\n end",
"def join(chan)\n\t\tif chan =~ /#.*/ then\n\t\t\t@int.join(chan)\n\t\t\t#@chans << chan\n\t\telse\n\t\t\t@int.join(\"#\" + chan)\n\t\t\t#@chans << \"#\" + chan\n\t\tend\n\tend",
"def join_on_connect(bot)\n @config[:channels].each{|chan|\n join_channel( bot, chan )\n }\n \n # If we are not required to do anything else, unhook\n if @config[:connect_only] then\n unregister_all(0.5) # Give my hooks half a second to disconnect\n # or unregister_hooks(0.5, :chanman_connect)\n end\n end",
"def irc_join_event(stem, sender, arguments) # :nodoc:\n if sender[:nick] == @nick then\n should_broadcast = false\n @chan_mutex.synchronize do\n @channels << arguments[:channel]\n @channel_members[arguments[:channel]] ||= Hash.new\n @channel_members[arguments[:channel]][sender[:nick]] = :unvoiced\n #TODO what should we do if we are in the middle of receiving NAMES replies?\n #TODO can we assume that all new channel members are unvoiced?\n end\n @join_mutex.synchronize do\n if @channels_to_join then\n @channels_to_join.delete arguments[:channel]\n if @channels_to_join.empty? then\n should_broadcast = true unless @ready\n @ready = true\n @channels_to_join = nil\n end\n end\n end\n # The ready_thread is also looking to set ready to true and broadcast,\n # so to prevent us both from doing it, we enter a critical section and\n # record whether the broadcast has been made already. We set @ready to\n # true and record if it was already set to true. If it wasn't already\n # set to true, we know the broadcast hasn't gone out, so we send it out.\n broadcast :stem_ready, self if should_broadcast\n else\n @chan_mutex.synchronize do\n @channel_members[arguments[:channel]][sender[:nick]] = :unvoiced\n #TODO what should we do if we are in the middle of receiving NAMES replies?\n #TODO can we assume that all new channel members are unvoiced?\n end\n end\n end",
"def event_join m\n uid = get_uid m\n reward_logic uid, m.channel, m.user.nick\n end",
"def join \n\n #Check if user exists\n user = User.find_by!(id: params[:user_id])\n\n if (ChannelJoined.exists?({ channel_id: params[:id], user_id: params[:user_id]}))\n json_response({\n \"joined\": true\n })\n else\n joined = ChannelJoined.create!(user_id: params[:user_id], channel_id: params[:id])\n json_response(joined.channel)\n end\n \n \n end",
"def join(c, k=nil)\n @socket << \"JOIN #{c} #{k}\".strip\n end",
"def send_irc(channel, message)\n real_channel = @zbot.get_channel(channel)\n if real_channel\n real_channel.send(message)\n else\n puts \"############## CHANNEL #{channel} NOT FOUND !\"\n end\n end",
"def send_channel(message)\n @bot.message_queue.push(\"PRIVMSG ##{bot.channel.name} :#{message}\")\n end",
"def process_join(message)\n channel = message.channel\n /:(?<user>\\w+)/ =~ message.raw\n channel.users[user] = User.new user unless channel.users.key? user\n end",
"def welcome_email(channel)\n @channel = channel\n @url = 'http://example.com/login'\n mail(to: @channel.email, subject: 'Welcome to your Constructeev Channel')\n end",
"def joinRoom(roomname, username)\n room = @chats.fetch roomname #get record of \"chats\"\n #puts(room)\n userID = @users.fetch username\n puts(\"joinroom userID #{userID}\")\n puts(userID)\n room.addUser(userID, username) #add user to that chat\n puts room.printMe\n end",
"def channel!\n return true unless query?\n\n raise 'This command may only be used in channels.'\n end",
"def start!(options = {})\n @client.auth_test if options[:test_authentication]\n\n @client.on :hello do\n @output.puts \"==> Successfully connected as '#{@client.self.name}' to the '#{@client.team.name}' team at https://#{@client.team.domain}.slack.com.\"\n my_channels = channels_i_am_a_member_of\n @output.puts \"==> I'm currently a member of these channels: #{channel_names_with_hash(my_channels)}\" if my_channels.count > 0\n end\n\n @client.on :channel_joined do |e|\n @output.puts \"==> I've joined channel ##{e['channel']['name']}\"\n end\n\n @client.on :channel_left do |e|\n @output.puts \"==> I've left channel ##{@client.channels[e.channel]['name']}\"\n end\n\n @client.on :message do |message_data|\n next if message_data[\"text\"].to_s.empty?\n next if message_originates_from_the_bot? message_data\n next unless message_is_addressed_to_the_bot? message_data\n\n command = get_command_from_incoming_message message_data[\"text\"]\n\n case command.downcase\n when \"help\"\n clean_output = help_information\n else\n clean_output = handle_ri_lookup(command)\n end\n\n @client.message channel: message_data[\"channel\"], text: clean_output\n end\n\n @client.start!\n end",
"def mention_channel(name: nil, id: nil, server_name: nil, server_id: nil)\n channel = find_channel(id: id, name: name, server_id: server_id, server_name: server_name)\n return '' if channel.nil?\n channel.mention\nrescue => e\n lex(e, 'Failed to mention Discord channel')\n ''\nend",
"def invite_bot\n SlackUtils::SingletonClient.instance.invite_channel(@bot.channel_id, Bot.slack_bot_id, session[:token])\n end",
"def sent_to_channel?\n IRC.channel_name?(dest)\n end",
"def join(room, service, nickname = nil)\n join = Blather::Stanza::Presence::MUC.new\n join.to = if nickname\n \"#{room}@#{service}/#{nickname}\"\n else\n \"#{room}/#{service}\"\n end\n client.write join\n end",
"def local_join(body)\n room = body.dup\n room[0,1] = '' until room[0,1] != '@'\n return nil unless room.length >= 1\n unless @var[:special_rooms].include?(room)\n room_hash = MD5::digest(room)[0,8]\n room_hash = EMPTY_ROOM if room == 'chat'\n @connection.room_names[room_hash] = room\n @connection.room_ids[room] = room_hash\n _remote_control(@var[:our_name], :invite, body, true)\n _server_control('join', room_hash)\n end\n local_switch(room.dup)\nend",
"def invite(nickname, channel)\n send_data(\"INVITE #{nickname} #{channel}\")\n end",
"def send_channel(message)\n @handler.send_channel message\n end",
"def toggle_nick(bot, channel)\n @use_nicks[channel] = (not @use_nicks[channel] == true)\n \n if use_nicks?(channel)\n bot.say(\"Nicks will be sent with messages.\")\n else\n bot.say(\"Nicks will not be sent (omegle users will just see anonymous text)\")\n end\n end",
"def join(subdomain = nil, room_name = nil, &block)\n #raise \"#{su}: #{caller[0]}\"\n\n if subdomain && room_name && !subdomain.kind_of?(Firetower::Session) && !room_name.kind_of?(Firetower::Room)\n warn \"WARNING: `join` is deprecated. use `join_room` instead: #{Kernel.caller.first.gsub(/:in .*$/, '')}\"\n join_room(subdomain, room_name)\n else\n # gross, copy pasta from hookr\n add_callback(:join, subdomain, &block)\n end\n end",
"def find_channel\n debug 'Looking for channel...'\n _response = self.signed_request'/api/v1/channels.list.joined', 'GET'\n _channels = _response['channels']\n\n _channels.each { |ch|\n if ch['name'] == $config.get_channel\n @channel_id = ch['_id']\n break\n end\n }\n\n if @channel_id\n debug \"Channel found! Channel ID is #{@channel_id}\"\n else\n puts \"Channel not found. Check if channel ##{$config.get_channel} exists and bot user is added to the channel.\"\n exit 1\n end\n end",
"def login(name, channel, password)\n @name = name\n @ch = channel\n @ch_pw = password\n @IRCsocket.write(\"PASS *\\n\")\n @IRCsocket.write(\"NICK #{@name}\\n\")\n @IRCsocket.write(\"USER #{@name} 8 * :#{@name}\\n\")\n @IRCsocket.write(\"JOIN #{@ch} #{@ch_pw}\\n\")\n end",
"def change_nick(nick)\n join(nick)\n end",
"def on_kick(connection, channel, kicker_user, kicked_user, reason)\n end",
"def cmd_channel(*args)\n\t\tif (args.length == 0)\n\t\t\targs.unshift(\"-h\")\n\t\tend\n\n\t\tmode = nil\n\n\t\t# Parse options\n\t\t@@channel_opts.parse(args) { |opt, idx, val|\n\t\t\tcase opt\n\t\t\t\twhen \"-h\"\n\t\t\t\t\tprint(\n\t\t\t\t\t\t\"Usage: channel [options]\\n\\n\" +\n\t\t\t\t\t\t\"Displays information about active channels.\\n\" +\n\t\t\t\t\t\t@@channel_opts.usage)\n\t\t\t\t\treturn true\n\t\t\t\twhen \"-l\"\n\t\t\t\t\tmode = 'list'\n\t\t\tend\n\t\t}\n\n\t\t# No mode, no service.\n\t\tif (mode == nil)\n\t\t\treturn true\n\t\telsif (mode == 'list')\n\t\t\ttbl = Rex::Ui::Text::Table.new(\n\t\t\t\t'Indent' => 4,\n\t\t\t\t'Columns' =>\n\t\t\t\t\t[\n\t\t\t\t\t\t'Id',\n\t\t\t\t\t\t'Class',\n\t\t\t\t\t\t'Type'\n\t\t\t\t\t])\n\t\t\titems = 0\n\n\t\t\tclient.channels.each_pair { |cid, channel|\n\t\t\t\ttbl << [ cid, channel.class.cls, channel.type ]\n\t\t\t\titems += 1\n\t\t\t}\n\n\t\t\tif (items == 0)\n\t\t\t\tprint_line(\"No active channels.\")\n\t\t\telse\n\t\t\t\tprint(\"\\n\" + tbl.to_s + \"\\n\")\n\t\t\tend\n\t\tend\n\tend",
"def join_channel_with_http_info(channel_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ChatChannelsApi.join_channel ...'\n end\n # verify the required parameter 'channel_id' is set\n if @api_client.config.client_side_validation && channel_id.nil?\n fail ArgumentError, \"Missing the required parameter 'channel_id' when calling ChatChannelsApi.join_channel\"\n end\n # resource path\n local_var_path = '/chat/channels/{channelId}/members/me'.sub('{' + 'channelId' + '}', channel_id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json', 'application/xml'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json', 'multipart/form-data'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['OAuth']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'InlineResponse2014')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ChatChannelsApi#join_channel\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def channel=(name)\n @channel = name\n end",
"def msg_SJOIN(source, args)\n c = Channel.find_by_name(args[1])\n if !c\n c = Channel.new(args[1], args[0])\n end\n offset = 0\n args[2].each_char do |c|\n case c\n when 'q', 'k', 'l', 'I', 'f', 'j', 'e', 'b', 'o', 'v'\n offset += 1\n end\n end\n parse_modestr(c, args[3..(3+offset)])\n if args[3 + offset] == nil\n # Can happen with +P channels\n return nil\n end\n args[3 + offset].split(\" \").each do |user|\n # First number is start of UID because of SID definition\n idx = 0\n user.each_char do |c|\n case c\n when '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'\n break\n else\n idx += 1\n end\n end\n begin\n u = User.find_by_uid(user[idx..-1])\n c.add_user(u)\n u.join(c)\n rescue NoMethodError => e\n puts(\"Error getting UID (#{user[(idx - 1)..-1]} for idx=#{idx} and user=#{user}): #{e.inspect}\")\n end\n end\n return nil\n end",
"def test_parse_join\n msg = Message.parse(@join_message)\n assert_equal @join_message, msg.raw_message\n assert_equal CMD_JOIN, msg.message_type\n assert_equal ['#chan'], msg.params\n end",
"def handle(time, send, message)\n match(message, \"(join|switch to) (.*)\") do |md|\n new_room_name = md[2]\n \n old_room_name = Robut::Connection.config.room\n \n # nasty gsub of the room name in the room name string\n full_new_room_name = old_room_name.gsub(/[\\d]+_(.*)\\@.*/) { |str| str.gsub($1, new_room_name) }\n \n Robut::Connection.config.room = full_new_room_name\n \n # Reconnect to the new channel.\n # There is a lighter-weight way to accomplish this,\n # but we don't have access to the muc accessor here.\n begin\n Robut::Connection.new.connect\n rescue => e\n $stderr.puts e\n # reply(\"I can't join that room, bro.\")\n \n # reconnect to the original room if we can't connect to the new one\n Robut::Connection.config.room = old_room_name\n Robut::Connection.new.connect\n end\n end\n end",
"def target_channel\n name = case self.command\n when :invite then self.params[1]\n when RPL_NAMREPLY then self.params[2]\n when ERR_USERNOTINCHANNEL then self.params[2]\n when ERR_USERONCHANNEL then self.params[2]\n when ERR_UNKNOWNMODE then self.trail[/\\S+$/]\n else self.params.fetch(numeric? ? 1 : 0, \"\")\n end\n\n if name.start_with?('&', '#', '+', '!')\n return name\n end\n\n return nil\n end",
"def open_channel(type = T.unsafe(nil), *extra, &on_confirm); end",
"def tell_all(m, message)\r\n if_admin(m) do\r\n @bot.channels.each {|c| c.send(message) }\r\n end\r\n end",
"def channels()\n return MicrosoftGraph::Me::JoinedTeams::Item::Channels::ChannelsRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def reply_to\n sent_to_channel? ? dest : nick\n end",
"def invite(nickname, channel)\n raw \"INVITE #{nickname} #{channel}\\r\\n\"\n end",
"def on_part(connection, channel, user)\n end",
"def open_channel\n @@game_channels.delete(@event.channel)\n nil\n end",
"def hello\n lambda do |_|\n puts \"Connected! As: '#{client.bot_name}' to: '#{client.team_name}' \\\n at #{client.domain}.\".gsub(/ +/, \" \")\n end\n end",
"def kick(channel, user, comment = nil)\n if comment.nil?\n raw \"KICK #{channel} #{user}\\r\\n\"\n else\n raw \"KICK #{channel} #{user} :#{comment}\\r\\n\"\n end\n end",
"def channel\n Channel.get(@name)\n end",
"def kick(reason=nil)\n reason.kind_of?(String) ? @session.chanserv.kick(self.name, nick) : @session.chanserv.kick(self.name, nick, reason)\n end",
"def channel_name\n client_channel.present? ? self.client_channel.channel_name : \"\"\n end",
"def kick(*args)\n channels = args.select {|arg| channel?(arg)}\n nicks = args.select {|arg| !channel?(arg)}\n raise ArgumentError.new(\"Missing channels\") if channels.empty?\n send_data(\"KICK #{channels.join(',')} #{nicks.join(',')}\".strip)\n end",
"def join\n @character = Character.find(params[:id])\n return_to = Rails.application.routes.recognize_path(request.referrer)[:controller] == \"characters\" ? @character : request.referrer\n if @character.join!\n redirect_to return_to, notice: \"Character is now adventuring in this campaign\"\n else\n flash[:alert] = \"Unable to proccess\"\n render 'show'\n end\n end",
"def join\n @group = Group.find(params[:id])\n\n if !current_user.is_member_of?(@group)\n current_user.join!(@group)\n flash[:notice] = \"Successfully joined the group!\"\n else\n flash[:warning] = \"You are a member of this group!\"\n end\n\n redirect_to group_path(@group)\n end",
"def respond(message)\n @channel.send_message(message) if @channel\n end",
"def to_channel\n self\n end",
"def user_joined\n user = User.find_by!(id: params[:user_id])\n return json_response({\n \"joined\": ChannelJoined.exists?({\n channel_id: params[:id],\n user_id: params[:user_id]\n })\n })\n end",
"def join(force = false)\n post 'join'\n end",
"def set_channel\n @channel = Channel.find_by(:name => params[:name])\n end",
"def channel\n # Create new channel if closed\n if @channel.nil? || @channel.closed?\n @channel = connection.create_channel\n end\n @channel\n end",
"def join_thread\n @thread&.join\n end",
"def join(channels, keys = nil)\n channel_slices = Array(channels).each_slice(5).to_a\n key_slices = Array(keys).each_slice(5).to_a\n\n messages = channel_slices.zip(key_slices).map do |cs, ks|\n channel_list = cs.map(&:to_s).join ','\n key_list = ks ? ks.join(\" \") : ks\n\n \"JOIN #{channel_list} #{key_list}\".strip << \"\\r\\n\"\n end\n\n raw messages.join\n end",
"def join(c)\n connections << c\n end",
"def set_channel\n @channel = ::Channel.find(params[:id])\n end",
"def channel(token, channel_id)\n request(\n __method__,\n :get,\n \"#{api_base}/channels/#{channel_id}\",\n Authorization: token\n )\n end",
"def _in_kick(event)\n if event.target == bot_name\n # Rejoin almost immediately - logging is important.\n join event.channel\n end\n\n return true\n end",
"def open_channel( type, extra_data=nil, &on_confirm )\n channel = @factories[:open].call( type, extra_data )\n channel.on_confirm_open(&on_confirm)\n @channel_map[ channel.local_id ] = channel\n end",
"def update\n Channel.channels_to_update\n end",
"def send_kick(user, channel, reason)\n send_raw(KICK, channel, user, reason)\n end",
"def on_join_failure(connection, channel, code, reason)\n end",
"def on_player_join(player)\n p \"#{player}, joins the game\"\n end",
"def set_channel\n @channel = Channel.find(params[:id])\n end",
"def update!(**args)\n @channel = args[:channel] if args.key?(:channel)\n end",
"def public_channel(ns)\n # [\"chat\", \"rumor\", \"wldh\", \"tianshi\", \"bwxy\", \"bh\"]\n get_client(ns).public_channel\n end",
"def join\n \n #TODO add player to hunt\n #player = User.find(params[:id])\n redirect_to hunt_player_path()\n end",
"def send_msg(msg, channel)\n prefix = \"PRIVMSG #{channel} :\"\n max_len = 255 - prefix.length\n msg = msg.dup()\n while(msg.length > 0)\n send_irc(prefix + msg.slice!(0, max_len))\n end\n end",
"def channel_leave(m, channel)\r\n if_admin(m) { @bot.part(channel, \"#{m.user.nick} requested I leave\") }\r\n end",
"def join_room(id)\n @rooms.join id\n end",
"def channel\n @channel ||= Proletariat.connection.create_channel\n end",
"def channel\n @channel ||= Proletariat.connection.create_channel\n end",
"def hook_thyself\n me = self\n\n\n\n # Add something to tell someone\n register_command(:tweet_cmd, /^tweet$/, [/channel/, /private/]){|*args| \n me.tweet(bot, nick, args.join(\" \"))\n }\n\n\n \n # Hook for when we have successfully joined\n @config[:channels].each do |chan|\n register_hook(\"twitter_join_#{chan}\".to_sym, lambda{|m| m.channel == chan}, /join/){\n me.join_channel( chan, bot ) if nick == bot_nick # Ensure we only fire if the bot has joined, not other people\n }\n end\n\n end",
"def set_channel\n @channel = Channel.find(params[:id])\n end"
] |
[
"0.80779046",
"0.80608284",
"0.8025712",
"0.7705018",
"0.7528838",
"0.75123936",
"0.71361214",
"0.7085131",
"0.6968965",
"0.6820501",
"0.6793049",
"0.67460245",
"0.6730669",
"0.6632969",
"0.66176176",
"0.66052604",
"0.65724325",
"0.65570456",
"0.6484972",
"0.6443919",
"0.644012",
"0.6427175",
"0.64177126",
"0.6179525",
"0.61386704",
"0.611351",
"0.6060845",
"0.60446703",
"0.60313356",
"0.60005015",
"0.59112966",
"0.59093416",
"0.58384734",
"0.5793091",
"0.5738725",
"0.56866884",
"0.5672962",
"0.56662416",
"0.5621777",
"0.5615387",
"0.5565375",
"0.55576444",
"0.5556098",
"0.55542403",
"0.55542016",
"0.55450374",
"0.55310696",
"0.5495411",
"0.5494279",
"0.5459036",
"0.54452425",
"0.54349697",
"0.5402246",
"0.5400797",
"0.53987056",
"0.5389857",
"0.5344803",
"0.53335005",
"0.53314173",
"0.53309375",
"0.53304785",
"0.5319656",
"0.5315789",
"0.5295503",
"0.5266884",
"0.5265377",
"0.5260178",
"0.52342266",
"0.523065",
"0.52197325",
"0.52169484",
"0.5211813",
"0.52068514",
"0.51919705",
"0.5189597",
"0.5188157",
"0.51788473",
"0.51713836",
"0.51710576",
"0.5141775",
"0.5137502",
"0.51357615",
"0.5132894",
"0.5132887",
"0.5131034",
"0.5128918",
"0.512674",
"0.5122645",
"0.5117278",
"0.5115549",
"0.5113452",
"0.5110394",
"0.51020074",
"0.50995743",
"0.5092297",
"0.5076408",
"0.50741744",
"0.50741744",
"0.5073686",
"0.5073448"
] |
0.83357835
|
0
|
Is the bot currently connected?
|
def connected?
@bot.connected?
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def connected?\n @bot.connected?\n end",
"def is_connected?\n if @client.is_connected?\n @log.info \"Asked if bot is connected: YES it is\"\n return true\n else\n @log.info \"Asked if bot is connected: NO it isn't\"\n return false\n end\n end",
"def connected?\n client.is_connected?\n end",
"def connected?\n @conn.connected? && @channel.open?\n end",
"def connected?\n status == CONNECTED\n end",
"def connected?\n @status == :connected\n end",
"def bot?\n bot.bot?\n end",
"def connected?\n @token.present?\n end",
"def connected?\n !!@connected\n end",
"def connected?\n !@connected.nil? && @connected\n end",
"def is_connected?\n if @connection == nil\n return false\n else \n return true\n end\n end",
"def connected?\n authenticated? && !@user.jid.bared?\n end",
"def connected?\n !!@connected_to\n end",
"def connected?\n !connection.blank?\n end",
"def connected?\n app.speakers.ID(@id).connected.get\n end",
"def connected?\n !@vim.serviceContent.sessionManager.currentSession.nil?\n end",
"def connected?\n @connected\n end",
"def connected?\n @connected\n end",
"def connected?\n @connected\n end",
"def connected?\n @connected\n end",
"def connected?\n @connected\n end",
"def is_connected?\n\t\tif @connection == nil\n\t\t\treturn false\n\t\telse\n\t\t\treturn true\n\t\tend\n\tend",
"def connected?\n unless @server.nil?\n true\n else\n false\n end\n end",
"def connected?\n !!@session_id && !!@cluster\n end",
"def connected?\n @connection.present?\n end",
"def current_bot?\n @bot.profile.id == @id\n end",
"def connected?\n @connected\n end",
"def connected?\n @connected\n end",
"def connected?\n @connected\n end",
"def connected?\n @connected\n end",
"def connected?\n @connected\n end",
"def connected?\n @connected\n end",
"def connected?\n with_timeout { listening? }\n end",
"def connected?\n with_timeout { listening? }\n end",
"def connected?\n @connected ||= false\n end",
"def connected?\n # FIXME: check if connection is connected\n not @connection.nil?\n end",
"def connected?\r\n @connection && @connection.connected?\r\n end",
"def connected?\n return @connected\n end",
"def connected?(conn)\n conn && conn.active?\n end",
"def connected?\n Drone::Client.connected?\n end",
"def connected?\n if @connected\n true\n else\n puts \"Drone is not yet connected. Run `connect` first.\"\n false\n end\n end",
"def connected?\n if @ssh\n return true\n else\n return false\n end\n end",
"def connected?\n\t\t@connected\n\tend",
"def connected?\n self.connected\n end",
"def ready?\n @connected && @logged_in\n end",
"def connected?\n @state == :connected\n end",
"def connected_with? nick\n @connection_cache.has_key? nick\n end",
"def connected?\n self.connected_cache ||= session_info.success?\n end",
"def connected?\n not @handle.nil?\n end",
"def connected?\n return !@@connection.nil?\n end",
"def connected?\n\t\treturn @conn ? true : false\n\tend",
"def connected?\n\t\t\t\t@@connected\n\t\t\tend",
"def connected?\n connection_handler.connected?(connection_specification_name, role: current_role, shard: current_shard)\n end",
"def isConnected()\r\n return @isConnected\r\n end",
"def connected?\n return false unless @connection\n return false unless @connection.started?\n true\n end",
"def connected?\n\t\treturn self.connected ? true : false\n\tend",
"def connected?\n return false unless @connection\n return false unless @connection.started?\n true\n end",
"def connected?\n @connection && !@connection.expired?\n end",
"def connected?\n (conn=self.conn) && conn.connected? && @pid == Process.pid || false\n end",
"def connected?\n\t\t@conn.connected?\n\tend",
"def connected?\n @token\n end",
"def connected?\n connection_handler.connected?(self)\n end",
"def connected?\n !!@access_token\n end",
"def connected?\n connection { |conn| conn.alive? }\n end",
"def connected?()\n (self.remote_address rescue nil) ? true : false\n end",
"def connected?\n synchronize { @connections.any? }\n end",
"def connected?\n !@connections.empty?\n end",
"def still_connected?\n true\n end",
"def connected?\n @started\n end",
"def connected?\n !!@socket\n end",
"def connected?\n !!@socket\n end",
"def connected?\r\n !@conn.nil?\r\n end",
"def connected?\n @connections.any?\n end",
"def open?\n @connected\n end",
"def connected?\n !!@socket && @socket.alive?\n end",
"def connected?\n return false if @connection.nil?\n return false if @connection.closed?\n return true\n end",
"def activeConnections?\n if @connectedClients then do return true else return false end\n end",
"def established?\n @connected == true\n end",
"def is_connected\n begin\n if session.key?(:sos_note_email)\n true\n else\n false\n end\n rescue Exception => e \n false\n end\n end",
"def connected?\n if @ticket && @soap_client\n return true\n end\n return false\n end",
"def connected?\n !closed?\n end",
"def connected?\n !closed?\n end",
"def connected?\r\n\t\t\t\t\treturn false if (@connections.nil?)\r\n\t\t\t\t\treturn false if (@connections.empty?)\r\n\t\t\t\t\treturn true\r\n\t\t\t\tend",
"def db_connected?\n return false unless _send_command(\"db_status\") =~ /connected/\n true\n end",
"def connected?\n @host && @port\n end",
"def connected?\n @connections.size > 0 # synchronize { @connections.any? }\n end",
"def connected?\n if @connection\n @connection.stat\n @connection.errno.zero?\n else\n false\n end\n end",
"def connected?\n @cluster.connected?\n end",
"def fb_connected?\n fb_user_id.present?\n end",
"def connected?\n /^[0-9a-z]{8}$/.match(@response.session_id).is_a? MatchData\n end",
"def connect?\n connect != false\n end",
"def chat?\n self.state == :chat\n end",
"def connected?\n if @db_connection\n return true\n else\n return false\n end\n end",
"def connected?\n begin\n @client.cluster.health\n rescue => e\n raise Xi::ML::Error::CaughtException, \\\n \"ES client not connected: #{e.message}\"\n end\n true\n end",
"def active?\n !!@raw_connection&.ping\n end",
"def alive?\n\t\tconnection.alive?\n\tend",
"def alive?\n\t\tconnection.alive?\n\tend",
"def connected?\n connections = nil\n @lock.lock\n begin\n connections = @connections\n ensure\n @lock.unlock\n end\n connections.any?\n end",
"def usable?\n [:connected, :connecting].include?(@status)\n end",
"def server_connected?\n ! chef_server.nil?\n end"
] |
[
"0.89154196",
"0.8841808",
"0.82395846",
"0.78141755",
"0.77785826",
"0.7771428",
"0.773878",
"0.77067035",
"0.7702226",
"0.7694188",
"0.7681079",
"0.7657826",
"0.76428205",
"0.76137465",
"0.75990915",
"0.7592038",
"0.7586019",
"0.7586019",
"0.7586019",
"0.7586019",
"0.7586019",
"0.75842",
"0.7581867",
"0.7551753",
"0.75323",
"0.7510891",
"0.7498954",
"0.7498954",
"0.7498954",
"0.7498954",
"0.7498954",
"0.7498954",
"0.7498513",
"0.7498513",
"0.74933374",
"0.74860436",
"0.7466016",
"0.745713",
"0.7443886",
"0.744199",
"0.7434512",
"0.7421588",
"0.74084586",
"0.73823625",
"0.73790693",
"0.73693943",
"0.7367929",
"0.7359894",
"0.7351731",
"0.7348561",
"0.73353237",
"0.7323933",
"0.7322288",
"0.73149014",
"0.73108435",
"0.73077095",
"0.73052585",
"0.7287887",
"0.72861296",
"0.72842246",
"0.728232",
"0.72619236",
"0.7254352",
"0.7245459",
"0.7238352",
"0.72335494",
"0.7190925",
"0.7190745",
"0.71524376",
"0.7138658",
"0.7138658",
"0.71308047",
"0.71143264",
"0.7105528",
"0.7101688",
"0.70990866",
"0.70894647",
"0.70885915",
"0.70786464",
"0.70298594",
"0.6998008",
"0.6998008",
"0.69909304",
"0.69469327",
"0.6911385",
"0.6871009",
"0.6848354",
"0.68189824",
"0.6815936",
"0.6776583",
"0.6763209",
"0.6755964",
"0.6751696",
"0.6739718",
"0.67311555",
"0.67235225",
"0.67235225",
"0.67210346",
"0.67082566",
"0.6708217"
] |
0.8816846
|
2
|
Say something. Wraps isaac's call with a default value from msg
|
def say(msg, recipient = nil)
recipient ||= @msg.reply_to if @msg
@bot.msg(recipient, msg)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def say_hi(name, age = -1) #age has default value (-1)\r\n puts (\"Hello\" + name + \", you are\" + age.to_s)\r\nend",
"def greeting (msg = \"Hello World\")\n puts msg\nend",
"def say(words = 'hello') #a default parameter that is used whenever our method is called without any arguments.\n puts words + '.'\n end",
"def sayhi(name=\"no name\", age= -1) #specify default values can be a good way to control this methods.\n puts (\"Hello\" + name + \", you are \" + age.to_s)\nend",
"def message(msg = T.unsafe(nil), ending = T.unsafe(nil), &default); end",
"def say_hi( name = \"World\" )\n return \"rude\"\n \"Hello #{name}\"\nend",
"def say(msg)\n puts \"=> #{msg}\"\nend",
"def say(msg)\n puts \"=> #{msg}\"\nend",
"def say(msg)\n puts \"=> #{msg}\"\nend",
"def say(words = \"hello\") # \"hello\" is the default parameter unless changed when called\n put words + \".\"\nend",
"def say(msg)\n puts \"#{msg}\"\nend",
"def say(msg)\n puts \"#{msg}\"\nend",
"def speak(msg=\"foo-instance speaking... \")\n msg=\"foo-instance speaking... \"\n msg + (defined?(super) ? super() : \"\")\n end",
"def say(something)\n \"Say #{something}\"\n end",
"def sayhi(name = \"no name\", age = -1)\n\tputs(\"Hello \"+name+\", you are \"+age.to_s)\nend",
"def say(msg)\n puts \"@Dealer: #{msg}\"\nend",
"def ok(msg='')\n if msg.empty?\n puts \"ok\"\n else\n puts \"ok (#{msg})\"\n end\n end",
"def say(message, level=:default)\n string = if level == :default\n message\n else\n prefix = \"[#{level.capitalize}]\"\n \"#{prefix} #{message}\"\n end\n\n puts string\nend",
"def say_hello(name,health=0)\n\t\"Ich bin #{name} und mir geht es zu #{health}% gut.\"\nend",
"def say(msg)\n print msg + \"\\r\\n\"\n end",
"def say(msg, title = nil)\n unless title == nil\n puts title.center(62, '~')\n end\n puts \"=> #{msg}\".ljust(62)\nend",
"def say(payload)\n {\n action: 'say',\n options: {\n payload: payload,\n voice: 'male',\n language: 'en-US'\n }\n }\nend",
"def prompt(msg, default)\n result = nil\n while not result\n display(msg)\n result = gets.strip\n if result.downcase == \"q\"\n throw :quit\n elsif result.downcase == \"i\"\n result = nil\n instructions\n elsif result.downcase == \"m\"\n display(\"Statistics can only be shown during a round!\")\n elsif result == \"\"\n return default.to_s\n else \n return result \n end\n end\n return result\n end",
"def say(*_args)\n end",
"def meal_choice(phrase = \"meat\")\n puts \"meat\"\n return phrase\nend",
"def say(message)\n puts \"=>\" + message\nend",
"def sayHi(name = \"User\", age = -1)\n puts(\"Hi #{name}, you are \" + age.to_s + \" old\")\nend",
"def say\n send_text \"You just said: #{params}\"\n end",
"def message(msg = nil, ending = nil)\n proc {\n msg = msg.call.chomp(\".\") if msg.is_a?(Proc)\n custom_message = \"#{msg.ai}.\\n\" unless msg.nil? || msg.to_s.empty?\n \"#{custom_message}#{yield}#{ending || '.'}\"\n }\n end",
"def say(statement = '')\n ui.say statement\n end",
"def rude_greeting(name=nil)\n name ||= \"you jerk\" #if name is nil, substitute the later argument\n puts \"Hey there, #{name}\"\n end",
"def say_hello(your_name, my_name = \"Dory\")\n puts \"Hello #{your_name}, I'm #{my_name}!\"\nend",
"def greet(greeting=\"Hello\")\n\tgreeting\nend",
"def greet(greeting=\"Hello\")\n\tgreeting\nend",
"def hey(message)\n case message\n when shout then \"Woah, chill out!\"\n when question then \"Sure.\"\n when silence then \"Fine. Be that way!\"\n else \"Whatever.\"\n end\n end",
"def speak\n \"#{name} says Assalaam alaykum\"\n end",
"def say(words='hello')\n\tputs words + '.'\nend",
"def message=(_arg0); end",
"def message=(_arg0); end",
"def say(words = \"hello\")\n puts words + '.'\nend",
"def msg(msg)\n if @name\n \"[#{name}] #{msg}\"\n else\n msg\n end\n end",
"def default_action(msg)\n #\n # do nothing.\n #\n end",
"def yield_or_default(message, default_message = \"\")\n message.nil? ? default_message : message\n end",
"def yield_or_default(message, default_message = \"\")\n message.nil? ? default_message : message\n end",
"def yield_or_default(message, default_message = \"\")\n message.nil? ? default_message : message\n end",
"def yield_or_default(message, default_message = \"\")\n message.nil? ? default_message : message\n end",
"def yield_or_default(message, default_message = \"\")\n message.nil? ? default_message : message\n end",
"def say_hello(name = \"world!\")\n puts \"Hello, #{name}\"\nend",
"def msg(m, fg = nil, bg = nil)\n m\nend",
"def msg(m, fg = nil, bg = nil)\n m\nend",
"def say_hello (name= \"Ruby Programmer\")\n\n\tputs \"Hello #{name}!\"\nend",
"def say_hello (name, health=0)\n\t\t\t\t\"Ich bin #{name} mit einem Wert von #{health}\"\n\t\t\tend",
"def say_hi_to(name=\"Noname\", age=-1)\n puts (\"Hello \" + name)\n puts (\"You are \" + age.to_s) #Remember .to_s when printing numbers with strings !!!!!\nend",
"def say(words='hello')\n puts words + '.'\nend",
"def say(words='hello')\n puts words + '.'\nend",
"def interact(msg)\n put msg\n get\n end",
"def message(type, *args)\n case type\n when :trainer_no_money\n puts \"Du hast ja gar nicht genug Geld!!\"\n end\n end",
"def hello(name=\"World\") # Default parameter\n puts \"Hello #{ name }\"\nend",
"def greet(greeting=\"Hello\")\n\tputs greeting\nend",
"def say_something(something)\n puts \"#{something}, said Becca\"\nend",
"def speak\r\n \"#{name} say Arf!\"\r\n end",
"def say(words = 'hello')\n puts words + '.' ## only make the change here\nend",
"def speak\n \"#{name} says arf!\"\n end",
"def disp_msg(msg_in)\n puts \"=> #{msg_in}\"\nend",
"def foo_greeting(recipient = \"you\")\n puts \"Hello there, #{recipient.upcase}!\"\nend",
"def show(msg)\n puts 'EXAMPLE<basic> ' + msg\nend",
"def say(message)\n output.puts message\n end",
"def speak\n \"#{name} says Arf!\"\n end",
"def say (v, msg)\n if v == true\n puts '+ %s' % [msg]\n end\nend",
"def talk_about(name, &mprc)\n puts \"let me tell you about #{name}\"\n mprc.call(name)\nend",
"def say(text)\n `say #{text}`\n end",
"def say(words=\"hello\")\n puts words + '.'\nend",
"def speak\n \"#{@name} says arf!\"\n end",
"def speak\n \"#{@name} says arf!\"\n end",
"def say_hi(name,moment='Morning')\n puts \"Hello #{name}, have a good #{moment}\"\nend",
"def sayMessage(person)\r\n puts \"Hello \" + person + \".\"\r\n \r\nend",
"def choose(message = nil, *choices, &block)\n say message if message\n super(*choices, &block)\n end",
"def speak\n \"#{@name} says Arf!\"\n end",
"def speak\n \"#{name} says arf!\"\n end",
"def out_msg( x = :bork, v = nil )\n x = :bork if !x.is_a? Symbol\n\n if x == :delfail\n ret = \"Failed to delete the demo file, #{self.hub.store.file}. Lame.\"\n\n elsif x == :delok\n ret = \"\\nDelete the demo file, #{self.hub.store.file}.\"\n\n elsif x == :done\n if v.nil?\n ret = \"\\nAnd that's how it works! To get started, type \\\"star -i\\\", or add a line with something like \\\"star -n what ever\\\".\"\n else\n ret = \"\\nRemoved the demo file, #{self.hub.store.file}.\"\n end\n\n elsif x == :start\n ret = \"This is a demo. It is using a demo file at #{self.hub.store.file}.\\n\\n\"\n\n elsif x == :startfail\n ret = \"Unable to run the demo :(\"\n\n else\n ret = Star::Message.out(x, v)\n end\n\n return ret\n end",
"def say_hello(name)\n\t\"Ich bin #{name}.\"\nend",
"def msg(message)\n end",
"def message() end",
"def say (something)\n puts something\nend",
"def default_messages=(_arg0); end",
"def say_hello\n\t'hello'\nend",
"def directSay _obj, _args\n \"_obj directSay _args;\" \n end",
"def say something\n puts dude_format something\n end",
"def hi(name = 'World')\n puts \"Hello 'k' #{name.capitalize}\"\nend",
"def say_hello(name= \"Ruby Programmer\")\n puts \"Hello #{name}!\"\n\nend",
"def say(words='hello')\n puts words + '.' ## <= We only make the change here!\nend",
"def speak\n \"#{name} says arf!\"\nend",
"def speak\n \"#{name} says arf!\"\nend",
"def speak\n \"#{name} says arf!\"\nend",
"def say_hi(\n name,# String\n greeting = \"hi\"# please\n )\nend",
"def say(words='hello')\n #prints string for words\n puts words + '.'\n # ends defining of method\nend",
"def say_hello(name = \"Ruby Programmer\")\n puts \"Hello #{name}!\"\nend",
"def say_hello(name = \"Ruby Programmer\")\n puts \"Hello #{name}!\"\nend",
"def say_hello(name = \"Ruby Programmer\")\n puts \"Hello #{name}!\"\nend",
"def say_hello(name = \"Ruby Programmer\")\n puts \"Hello #{name}!\"\nend",
"def say_hello(name = \"Ruby Programmer\")\n puts \"Hello #{name}!\"\nend"
] |
[
"0.6711911",
"0.6651502",
"0.6518562",
"0.6458587",
"0.644703",
"0.6440648",
"0.6389932",
"0.6389932",
"0.6389932",
"0.63770586",
"0.63670427",
"0.63670427",
"0.6351791",
"0.63340735",
"0.629681",
"0.6273162",
"0.6245632",
"0.62354666",
"0.6220577",
"0.61735755",
"0.6170899",
"0.61691606",
"0.61669105",
"0.61630434",
"0.6146205",
"0.610348",
"0.61027867",
"0.60984886",
"0.60932595",
"0.6085147",
"0.6081393",
"0.6080622",
"0.6051191",
"0.6051191",
"0.603515",
"0.6017246",
"0.6012718",
"0.60005903",
"0.60005903",
"0.59877306",
"0.598051",
"0.5973323",
"0.59647614",
"0.59647614",
"0.59647614",
"0.59647614",
"0.59647614",
"0.5959198",
"0.5954911",
"0.5954911",
"0.59454805",
"0.5941447",
"0.5935454",
"0.5933172",
"0.5933172",
"0.59217316",
"0.59106326",
"0.59105176",
"0.5899533",
"0.5895286",
"0.5892714",
"0.58798975",
"0.586876",
"0.5863601",
"0.5861761",
"0.585794",
"0.5851204",
"0.58467674",
"0.5846455",
"0.5843495",
"0.5838278",
"0.58362967",
"0.58295196",
"0.58295196",
"0.5829485",
"0.58163047",
"0.58099383",
"0.58067536",
"0.58065826",
"0.5798477",
"0.5794445",
"0.5791547",
"0.57905686",
"0.5777431",
"0.57720006",
"0.5764915",
"0.57633394",
"0.57556635",
"0.5755615",
"0.57246464",
"0.5722916",
"0.57218444",
"0.57218444",
"0.57218444",
"0.5721568",
"0.57190204",
"0.57131845",
"0.57131845",
"0.57131845",
"0.57131845",
"0.57131845"
] |
0.0
|
-1
|
Action something Wraps isaac's call with a default value from msg
|
def action(msg, recipient)
recipient ||= @msg.reply_to if @msg
@bot.action(recipient, msg)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def default_action(msg)\n #\n # do nothing.\n #\n end",
"def message=(_arg0); end",
"def message=(_arg0); end",
"def ACK02=(arg)",
"def message(msg = T.unsafe(nil), ending = T.unsafe(nil), &default); end",
"def ACK01=(arg)",
"def ACK03=(arg)",
"def ACK10=(arg)",
"def action=(_arg0); end",
"def ACK05=(arg)",
"def greeting (msg = \"Hello World\")\n puts msg\nend",
"def say_hi(name, age = -1) #age has default value (-1)\r\n puts (\"Hello\" + name + \", you are\" + age.to_s)\r\nend",
"def default_messages=(_arg0); end",
"def mech=(_arg0); end",
"def mech=(_arg0); end",
"def ACK09=(arg)",
"def ACK04=(arg)",
"def default _args\n \"default _args;\" \n end",
"def say(payload)\n {\n action: 'say',\n options: {\n payload: payload,\n voice: 'male',\n language: 'en-US'\n }\n }\nend",
"def say_hi( name = \"World\" )\n return \"rude\"\n \"Hello #{name}\"\nend",
"def interact(msg)\n put msg\n get\n end",
"def ok(msg='')\n if msg.empty?\n puts \"ok\"\n else\n puts \"ok (#{msg})\"\n end\n end",
"def send_action(*_arg0); end",
"def ACK06=(arg)",
"def yield_or_default(message, default_message = \"\")\n message.nil? ? default_message : message\n end",
"def yield_or_default(message, default_message = \"\")\n message.nil? ? default_message : message\n end",
"def yield_or_default(message, default_message = \"\")\n message.nil? ? default_message : message\n end",
"def yield_or_default(message, default_message = \"\")\n message.nil? ? default_message : message\n end",
"def yield_or_default(message, default_message = \"\")\n message.nil? ? default_message : message\n end",
"def default=(_arg0); end",
"def default!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 42 )\n\n type = DEFAULT\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 163:11: 'default'\n match( \"default\" )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 42 )\n\n end",
"def attempt(message, &block)\n perform_action(message, false, nil, false, &block)\nend",
"def meal_choice(phrase = \"meat\")\n puts \"meat\"\n return phrase\nend",
"def message=(_); end",
"def prompt(msg, default)\n result = nil\n while not result\n display(msg)\n result = gets.strip\n if result.downcase == \"q\"\n throw :quit\n elsif result.downcase == \"i\"\n result = nil\n instructions\n elsif result.downcase == \"m\"\n display(\"Statistics can only be shown during a round!\")\n elsif result == \"\"\n return default.to_s\n else \n return result \n end\n end\n return result\n end",
"def to_ruby_arg\n \"#{to_s_name}#{@default ? ' = ' + @default : ''}\"\n end",
"def action(message)\n print(6, message)\n end",
"def resent_sender( val = nil )\n default :resent_sender, val\n end",
"def began msg\n end",
"def ACK07=(arg)",
"def noop(msg); \"200 \"; end",
"def action a\n text a.name\n mnemonic a.mnemonic unless a.mnemonic.nil?\n command { a.call }\n end",
"def action a\n text a.name\n mnemonic a.mnemonic unless a.mnemonic.nil?\n command { a.call }\n end",
"def message(type, *args)\n case type\n when :trainer_no_money\n puts \"Du hast ja gar nicht genug Geld!!\"\n end\n end",
"def message() end",
"def say(words = \"hello\") # \"hello\" is the default parameter unless changed when called\n put words + \".\"\nend",
"def default *args\n @actor.gate.default( [ :object ] + args )\n end",
"def say(words = 'hello') #a default parameter that is used whenever our method is called without any arguments.\n puts words + '.'\n end",
"def message(message) end",
"def message( message )\n\tend",
"def sayhi(name=\"no name\", age= -1) #specify default values can be a good way to control this methods.\n puts (\"Hello\" + name + \", you are \" + age.to_s)\nend",
"def action(text)\n reply(\"\\001ACTION #{text}\\001\")\n end",
"def sender( val = nil )\n default :sender, val\n end",
"def ask_for_action\n @response.gather(numDigits: 1) do |g|\n g.say('To call Julien directly, press 1. To leave a message, press 2.')\n end\n end",
"def speak(msg=\"foo-instance speaking... \")\n msg=\"foo-instance speaking... \"\n msg + (defined?(super) ? super() : \"\")\n end",
"def default\n [:default, nil, Reader::Position.caller(2)]\n end",
"def message(msg = nil, ending = nil)\n proc {\n msg = msg.call.chomp(\".\") if msg.is_a?(Proc)\n custom_message = \"#{msg.ai}.\\n\" unless msg.nil? || msg.to_s.empty?\n \"#{custom_message}#{yield}#{ending || '.'}\"\n }\n end",
"def default(a,b,c=2)\n puts \"c should equal 3 now: \"\n puts c\nend",
"def hello(name=\"World\") # Default parameter\n puts \"Hello #{ name }\"\nend",
"def rude_greeting(name=nil)\n name ||= \"you jerk\" #if name is nil, substitute the later argument\n puts \"Hey there, #{name}\"\n end",
"def whiny=(_arg0); end",
"def greet(greeting=\"Hello\")\n\tgreeting\nend",
"def greet(greeting=\"Hello\")\n\tgreeting\nend",
"def ask_with_default(question, color, default)\n question = (question.split(\"?\") << \" [#{default}]?\").join\n answer = ask(question, color)\n answer.to_s.strip.empty? ? default : answer\nend",
"def act notification, options={}\n # ...or nothing\n end",
"def choose(message = nil, *choices, &block)\n say message if message\n super(*choices, &block)\n end",
"def msg=(_); end",
"def msg=(_); end",
"def foo_greeting(recipient = \"you\")\n puts \"Hello there, #{recipient.upcase}!\"\nend",
"def msg(m, fg = nil, bg = nil)\n m\nend",
"def msg(m, fg = nil, bg = nil)\n m\nend",
"def pass(message=nil) [:pass, message.to_s]; end",
"def meal_choice(arg1 = \"meat\")\n \"#{arg1}\"\nend",
"def default_action; end",
"def msg(message)\n end",
"def process_message(msg)\n launcher = @IA_Info[:launcher]\n case msg.first\n when :msg_fail, :unefficient_msg, :useless_msg\n @IA_Info[:failure] = true\n when :efficiency_sound\n @IA_Info[:failure] = true if msg.last == 0\n when :hp_down, :hp_down_proto\n if msg[1] == launcher\n @IA_Info[:recoil] += msg[2] if @IA_Info[:symbol] != :s_explosion\n else\n @IA_Info[:damage] += msg[2]\n end\n when :hp_up\n if msg.first == launcher\n @IA_Info[:recoil] -= msg[2]\n else\n @IA_Info[:damage] -= msg[2]\n end\n when :OHKO\n if msg[1] == launcher\n @IA_Info[:recoil] += msg[1].max_hp\n else\n @IA_Info[:damage] += msg[1].max_hp\n end\n when :rand_check\n @IA_Info[:randomness] = msg[1] ? msg[1].to_f / msg.last : msg.last / 100.0\n when :weather_change\n unless BattleEngine.state[:air_lock]\n @IA_Info[:other_factor] = get_weather_advantage_factor(msg[1]) if $env.current_weather == 0\n end\n when :attract_effect\n if msg[1] == launcher\n @IA_Info[:other_factor] = 0.1\n else\n @IA_Info[:other_factor] = get_attract_factor(msg[1])\n end\n when :effect_afraid\n @IA_Info[:status_factor] = rand\n when :status_confuse\n unless @IA_Info[:target].confused?\n @IA_Info[:status_factor] = rand * turn_status_factor(launcher) unless detect_protect_on_status(msg[1], false)\n end\n when :perish_song\n unless @IA_Info[:target].battle_effect.has_perish_song_effect? or launcher.battle_effect.has_perish_song_effect?\n @IA_Info[:other_factor] = get_basic_factor\n end\n when :future_skill\n @IA_Info[:other_factor] = get_basic_factor unless @IA_Info[:target].battle_effect.is_locked_by_future_skill? or launcher.battle_effect.has_future_skill?\n when :stat_reset_neg, :stat_reset\n @IA_Info[:other_factor] = get_basic_factor if launcher.battle_stage.sum < 0\n when :stat_set\n if msg[1] == launcher\n if msg.last > 0\n @IA_Info[:other_factor] = get_basic_factor if (launcher.battle_stage[msg[2]] - msg.last) < 0\n end\n else\n if msg.last < 0\n @IA_Info[:other_factor] = get_basic_factor if (@IA_Info[:target].battle_stage[msg[2]] - msg.last) > 0\n end\n end\n when :set_type\n @IA_Info[:other_factor] = get_basic_factor unless msg[1].type?(msg[2])\n when :set_ability\n @IA_Info[:other_factor] = get_basic_factor unless msg[1].ability_current == msg[2]\n when :switch_pokemon\n @IA_Info[:other_factor] = get_basic_factor if launcher.hp_rate < 0.5\n when :mimic\n @IA_Info[:other_factor] = get_basic_factor if $game_temp.battle_turn > 1 and msg[2].last_skill != 0\n when :entry_hazards_remove\n if BattleEngine.state[:enn_spikes] > 0 or\n BattleEngine.state[:enn_toxic_spikes] > 0 or\n BattleEngine.state[:enn_stealth_rock] or\n BattleEngine.state[:enn_sticky_web]\n @IA_Info[:other_factor] = get_basic_factor(0.8)\n end\n when :apply_out_of_reach\n @IA_Info[:other_factor] = get_basic_factor\n when :set_hp\n if msg[1] == launcher\n @IA_Info[:recoil] += launcher.hp - msg[2]\n else\n @IA_Info[:damage] += @IA_Info[:target] - msg[2]\n end\n when :berry_use\n @IA_Info[:other_factor] = 0.2\n when :after_you\n @IA_Info[:other_factor] = get_basic_factor\n when :change_atk, :change_dfe, :change_spd, :change_dfs, :change_ats, :change_eva, :change_acc\n if msg[1] == launcher\n if msg.last > 0\n @IA_Info[:other_factor] = get_basic_factor if (launcher.battle_stage.sum - msg.last) < 0\n end\n else\n if msg.last < 0\n @IA_Info[:other_factor] = get_basic_factor if (@IA_Info[:target].battle_stage.sum - msg.last) > 0\n end\n end\n when :status_sleep\n unless detect_protect_on_status(msg[1])\n if msg[1].can_be_asleep?\n @IA_Info[:status_factor] = get_basic_factor * turn_status_factor(launcher)\n end\n end\n when :status_frozen\n unless detect_protect_on_status(msg[1])\n if msg[1].can_be_frozen?(@IA_Info[:skill].type)\n @IA_Info[:status_factor] = get_basic_factor * 2\n end\n end\n when :status_poison\n unless detect_protect_on_status(msg[1])\n if msg[1].can_be_poisoned?\n @IA_Info[:status_factor] = get_basic_factor * turn_status_factor(launcher)\n end\n end\n when :status_toxic\n unless detect_protect_on_status(msg[1])\n if msg[1].can_be_poisoned?\n @IA_Info[:status_factor] = get_basic_factor * 2\n end\n end\n when :status_paralyze\n unless detect_protect_on_status(msg[1])\n if msg[1].can_be_paralyzed?\n @IA_Info[:status_factor] = get_basic_factor * turn_status_factor(launcher)\n end\n end\n when :status_burn\n unless detect_protect_on_status(msg[1])\n if msg[1].can_be_burn?\n @IA_Info[:status_factor] = get_basic_factor * 2\n end\n end\n when :status_cure\n if msg[1].status != 0 and msg[1] == launcher\n @IA_Info[:status_factor] = get_basic_factor\n end\n when :set_state\n @IA_Info[:other_factor] = get_basic_factor(0.8) if BattleEngine.state[msg[1]] != msg[2]\n when :send_state\n @IA_Info[:other_factor] = get_basic_factor(0.6)\n when :apply_effect\n @IA_Info[:other_factor] = get_basic_factor(0.3)\n when :status_chance\n @IA_Info[:status_chance] = msg.last / 100.0\n when :chance\n @IA_Info[:randomness] = msg.last / 100.0\n end\n end",
"def ACK08=(arg)",
"def method_missing(*args)\n default\n end",
"def default(symbol)\n case symbol\n when :about\n puts \"Default 'about me' text\"\n end\n end",
"def always_run=(_arg0); end",
"def getcommand(msg)\n msg.message =~ /#{$COMMAND}(\\w+)/\n commandused = $1\n case commandused\n when 'roll', 'nobotch', 'special'\n if msg.message =~ /#{commandused}\\s*help\\s*$/\n # show command help\n \"#{HELP_TEXT(commandused)}\"\n elsif msg.message =~ /#{commandused}\\s+(.*)\\s*$/\n begin\n \"<b>#{$names[msg.actor]}: </b>#{substitute($1,commandused)}\"\n rescue ArgumentError => e\n \"\\\"<b>Error</b>: #{e}</b>\\\",#{[msg.actor]}\"\n end\n end\n \n when 'help'\n \"<br>I'm here to make your V20 playing much more pleasureable!<br><br>\n Commands:<br>\n <b>#{$COMMAND}roll</b> <input> - Regular ol' dice rollin!<br>\n <b>#{$COMMAND}nobotch</b> <input> - Roll dice where 1s don't botch!<br>\n <b>#{$COMMAND}special</b> <input> - Make those 10s count DOUBLE!<br><br>\n\n use '<b>help</b>' as the input for more information on any command!\"\n else\n #wat r u doin dolan pls\n \"wat r u doin stahp\"\n end\nend",
"def say\n send_text \"You just said: #{params}\"\n end",
"def meal_choice(arg1 = \"meat\")\n return arg1\nend",
"def func(my_data = \"defaultInput\")\n puts \"data is #{my_data}\" \nend",
"def playActionNow _obj, _args\n \"_obj playActionNow _args;\" \n end",
"def SAC15=(arg)",
"def default\n # create default action for emails from valid users.\n Mailman.logger.info 'Message matched the default route. Message ignored'\n end",
"def act q = nil\n\n if !q.nil? && q != \"\" then\n topic = q\n else\n puts \"What would you like to work on?\"\n puts \"(summaries, arcs, or scenes)\"\n topic = STDIN.gets.chomp\n end\n\n case topic\n when \"arcs\"\n listen_arcs\n when \"scenes\"\n listen_scenes\n else\n puts \"#{topic} is not a valid option\"\n return nil\n end\n\n end",
"def disp_msg(msg_in)\n puts \"=> #{msg_in}\"\nend",
"def call\r\n 'Squaaaaaaawk!'\r\n end",
"def attempt(message, &block)\n perform_action(message, false, @passfail, nil, true, false, &block)\nend",
"def process_action(*_arg0); end",
"def process_action(*_arg0); end",
"def process_action(*_arg0); end",
"def process_default(exp)\n until exp.size == 0\n exp.shift\n end\n s()\n end",
"def msg_AWAY(source, args)\n return nil # I don't care, get lost\n end",
"def say(msg)\n puts \"=> #{msg}\"\nend",
"def say(msg)\n puts \"=> #{msg}\"\nend",
"def say(msg)\n puts \"=> #{msg}\"\nend",
"def call_action(input)\n @action.respond_to?(:call) ? @action.call(input) : Rc.send(@action, input)\n rescue StandardError, SyntaxError\n message = $!.is_a?(NoMethodError) && !@action.respond_to?(:call) &&\n !Rc.respond_to?(@action) ? \"Completion action '#{@action}' doesn't exist.\" :\n \"Failed during completion action with '#{$!.message}'.\"\n raise FailedMissionError.new(self), message\n end",
"def PO110=(arg)"
] |
[
"0.66745883",
"0.6062719",
"0.6062719",
"0.5985372",
"0.5946264",
"0.5938049",
"0.59353685",
"0.5877914",
"0.5841647",
"0.5830896",
"0.58167243",
"0.57681346",
"0.575328",
"0.5717683",
"0.5717683",
"0.5696746",
"0.56804657",
"0.56781524",
"0.5678042",
"0.566213",
"0.5653517",
"0.56284094",
"0.562291",
"0.56218445",
"0.5608041",
"0.5608041",
"0.5608041",
"0.5608041",
"0.5608041",
"0.55890125",
"0.5563598",
"0.55364233",
"0.55346024",
"0.55338734",
"0.55293787",
"0.5528041",
"0.5514472",
"0.5504796",
"0.5479929",
"0.54779476",
"0.5461779",
"0.5459552",
"0.5459552",
"0.5442702",
"0.5437797",
"0.5436512",
"0.5432808",
"0.5420705",
"0.54013634",
"0.5390465",
"0.53817505",
"0.5375141",
"0.53746766",
"0.5363347",
"0.5360176",
"0.5358915",
"0.5356612",
"0.53563994",
"0.5355583",
"0.53483355",
"0.5344716",
"0.53150505",
"0.53150505",
"0.53127944",
"0.53108937",
"0.52979225",
"0.52839786",
"0.52839786",
"0.52785146",
"0.52752495",
"0.52752495",
"0.5269175",
"0.52655184",
"0.52568394",
"0.52542824",
"0.5251731",
"0.5244892",
"0.5238026",
"0.5234952",
"0.5232984",
"0.5231088",
"0.52300435",
"0.5227612",
"0.52172685",
"0.5214698",
"0.5210128",
"0.5203945",
"0.5201796",
"0.51951027",
"0.519482",
"0.51943177",
"0.51906675",
"0.51906675",
"0.51906675",
"0.5187442",
"0.51871264",
"0.5186531",
"0.5186531",
"0.5186531",
"0.5177179",
"0.5176423"
] |
0.0
|
-1
|
Construct a hook bot
|
def initialize
# Keep track of hooks and what object owns what
@hooks = {}
@cmds = {}
@modules = {}
# Prevent access to hooks when other things are
# editing or using them.
@hooks_mutex = Mutex.new
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def make_hooks(*args)\r\n make :hook, *args\r\n end",
"def create_bot\n derp = @config\n @bot = Cinch::Bot.new do \n configure(&derp)\n end\n end",
"def create_hook!\n hook = client.create_hook(\n full_name,\n 'web',\n {\n url: Constants::HOOK_URL,\n content_type: 'json'\n },\n {\n events: ['release'],\n active: true\n }\n )\n\n self.github_hook_id = hook.id\n end",
"def initialize(hook)\n @hook = hook\n end",
"def create_hook(lesson)\n client = github_client lesson.user\n resp = client.repos.hooks.create(*hook_params(lesson.owner, lesson.name))\n lesson.hook = resp.id\n rescue Github::Error::ServiceError => e\n Rails.logger.error 'Unable to create hook. Error was %s' % e\n end",
"def new(bot)\n @bot = bot\n end",
"def initialize(botname, body, webhook_url=nil)\n self.botname = botname\n self.webhook_url = webhook_url\n parsed = URI.decode_www_form(body)\n parsed.each do |p|\n # puts \"#{p[0]}=#{p[1]}\"\n if p[0] == \"command\"\n self.command = p[1]\n # puts \"command=#{self.command}\"\n end\n if p[0] == \"trigger_word\"\n # This is for trigger words, not slash commands\n self.trigger_word = p[1]\n end\n if p[0] == \"channel_name\"\n self.channel = p[1]\n end\n if p[0] == \"user_name\"\n self.username = \"@#{p[1]}\"\n # puts \"username #{username}\"\n end\n if p[0] == \"text\"\n self.text = p[1].strip\n # puts \"text=#{text}\"\n end\n if p[0] == \"response_url\" && !webhook_url \n # we get it in the post body with more recent slack apps\n self.webhook_url = p[1]\n end\n end\n if self.channel == \"directmessage\"\n self.channel = self.username\n else\n self.channel = \"\\##{self.channel}\" unless self.channel[0] == '#'\n end\n\n end",
"def hook_thyself\n me = self;\n\n # Show blacklist\n register_command(:omeg_blacklist_show, /^[Oo]megleBlacklist$/, /channel/){\n me.report_blacklist(bot, channel)\n }\n \n # Toggle use of blacklist for a user \n register_command(:omeg_blacklist, /^[Tt]oggleMe$/, /channel/){\n me.toggle_blacklist(bot, channel, nick)\n }\n\n # Toggle use of nick template\n register_command(:omeg_toggle, /^[Tt]oggleNick$/, /channel/){\n me.toggle_nick(bot, channel)\n }\n\n # Connect to a single stranger with <nickname> support\n register_command(:omeg_connect, /^[Oo]megle$/, /channel/){|*topics|\n me.ensure_not_blacklisted(channel, nick)\n me.summon_omegleite(bot, channel, topics)\n }\n \n # Connect to a single stranger with <nickname> support\n register_command(:omeg_ask, /^[Aa]skMe$/, /channel/){\n me.ensure_not_blacklisted(channel, nick)\n me.summon_omegleite(bot, channel, nil, true)\n }\n\n # Spy mode, ask a question and watch two people debate.\n register_command(:omeg_spy, /^[Aa]sk$/, /channel/){|*question|\n if(question.length < 0)\n bot.say(\"Please provide a question!\")\n else\n me.spy_mode(bot, channel, question.join(\" \"))\n end\n }\n\n end",
"def new\n @hook = Hook.new\n respond_with(@hook)\n end",
"def hipchat_hook\n #curl -d \"auth_token=AUTHTOKEN&room_id=ROOM_ID&from=test_bot&message=hello%20world\" http:/v1/rooms/message/\n base_params = {\n auth_token: ENV['HIPCHAT_API_KEY'],\n room_id: ENV['HIPCHAT_ROOM_ID'],\n from: \"Deploy Bot\"\n }\n\n CaptainHook::Hook.new(\"http://api.hipchat.com/v1/rooms/message/\") do |deploy_params|\n host_url = \"<a href='#{deploy_params[:url]}'>#{deploy_params[:url]}</a>\"\n base_params.merge({\n message: \"#{deploy_params[:user]} deployed #{deploy_params[:head]} to #{host_url}\"\n })\n end\n end",
"def hook_thyself\n me = self\n\n register_command(:fortune, /^[Ff]ortune$/, /channel/){ \n me.fortune(bot)\n }\n\n register_command(:eight_ball, /^8(ball)?$/, /channel/){|*msg|\n me.eight_ball(bot, msg.join(\" \"))\n }\n end",
"def create_webhook(repo, config = {}, options = {})\n opts = options.dup\n opts[:config] = config\n raise Octokit::MissingKey unless config.key? :url\n\n post \"#{Repository.path repo}/hooks\", opts\n end",
"def create_bot\n $bot = Discordrb::Bot.new(\n token: $config['discord_secret'],\n client_id: $config['discord_client'],\n log_mode: :quiet,\n intents: [\n :servers,\n :server_members,\n :server_bans,\n :server_emojis,\n :server_integrations,\n :server_webhooks,\n :server_invites,\n :server_voice_states,\n #:server_presences,\n :server_messages,\n :server_message_reactions,\n :server_message_typing,\n :direct_messages,\n :direct_message_reactions,\n :direct_message_typing\n ]\n )\n log(\"Created bot\")\nrescue => e\n fatal(\"Failed to create bot: #{e}\")\n exit\nend",
"def hook\n if Bot.exists?(params[:id])\n JobDaemon.enqueue(JobDaemons::BotJob.new(params[:id].to_i, 'onHook', [request.method, hook_params]))\n render json: {status: 'ok'}, status: :ok\n else\n render json: {status: 'ng'}, status: :not_found\n end\n end",
"def create_hook(repository, callback_url)\n return unless self.class.enable_hook?\n hook = client.create_hook(repository.full_name, 'web',\n {url: callback_url, content_type: 'json'},\n events: ['push'], active: true)\n yield hook if block_given?\n hook\n rescue Octokit::UnprocessableEntity => e\n if e.message.include? 'Hook already exists'\n true\n else\n raise\n end\n end",
"def initialize(token, clientId, prefix, initDicts=Hash.new, helloStringArr=[\"Hello!\"], byeStringArr=[\"Goodbye!\"], rejectStringArr=[\"You're not my creator.\"], botChannelName=\"\", joinChannelName=\"\", logFilename=\"log\", welcomeMessage=\"Welcome!\")\r\n err = setup_args_valid?([token, clientId, prefix])\r\n if err\r\n puts(\"Cannot initialize bot. \" + err)\r\n return nil\r\n end\r\n\r\n @token = token\r\n @clientId = clientId\r\n @prefix = prefix\r\n @bot = Discordrb::Commands::CommandBot.new(token: @token, client_id: @clientId, prefix: @prefix)\r\n\r\n @wordLength = 30\r\n @timeout = 60\r\n @numSentences = 1\r\n\r\n @dict = Hash.new\r\n @desc = Hash.new\r\n @sentenceGens = Hash.new\r\n @logger = ChatLogger.new\r\n @commands = BotCommands.new(@sentenceGens, @wordLength, @timeout)\r\n\r\n @awakenStrings = helloStringArr\r\n @byeStrings = byeStringArr\r\n @rejectStrings = rejectStringArr\r\n @botChannelName = botChannelName\r\n @logFilename = logFilename\r\n @joinChannelName = joinChannelName\r\n @welcomeMessage = welcomeMessage\r\n\r\n add_dictionaries(initDicts)\r\n end",
"def create_rgithook_instance\n # This is not really a rgithook_instance ;-P\n ::RGitHook::RGitHook.stubs(:parse_path).with(@repo).returns(@repo)\n ::RGitHook::Runner.stubs(:new).with(@repo).returns(@runner)\n @runner.stubs(:load).with('hooks_file')\n ::RGitHook::RGitHook.any_instance.stubs(:hooks_file).returns('hooks_file')\n ::RGitHook::RGitHook.new(@repo)\n end",
"def create_bot(opts)\n\tCinch::Bot.new do\n\t configure do |c|\n\t\t c.server = opts[:server]\n\t\t c.channels = opts[:channels]\n\t\t c.nick = opts[:name]\n\t\t c.plugins.plugins = [Seen, Hello, TopicHistory, Memo]\n\t end\n\n\t helpers do\n\t\t def shorten(url)\n\t\t\turl = open(\"http://tinyurl.com/api-create.php?url=#{URI.escape(url)}\").read\n\t\t\turl == \"Error\" ? nil : url\n\t\t rescue OpenURI::HTTPError\n\t\t\tnil\n\t\t end\n\t end\n\n\t on :channel do |m|\n\t\t return if m =~ /\\A!/\n\t\t urls = URI.extract(m.message, \"http\").reject { |url| url.length < 70 }\n\n\t\t if urls.any?\n\t\t\tshort_urls = urls.map {|url| shorten(url) }.compact\n\n\t\t\tunless short_urls.empty?\n\t\t\t m.reply short_urls.join(\", \")\n\t\t\tend\n\t\t end\n\t end\n\tend\nend",
"def init_bottomline\n unless @bottomline\n require 'forwardable'\n require 'rbcurse/extras/bottomline'\n @bottomline = Bottomline.new self, $error_message_row\n @bottomline.name = \"window.rb\"\n extend Forwardable\n def_delegators :@bottomline, :ask, :say, :agree, :choose\n end\n end",
"def initialize\n register_script \"Provide on-protocol help for bot scripts and commands.\"\n\n register_command \"help\", :cmd_help, 0, 0, nil, \"Show help for the given command or a list of all commands. Parameters: [command]\"\n register_command \"script\", :cmd_script, 0, 0, nil, \"Show a description of the given script or a list of all scripts. Parameters: [script]\"\nend",
"def initialize(id, hook, &block)\n self.id = id\n self.hook = hook\n self.block = block\n end",
"def create_bot(bot_name:,\n branch_name: \"master\",\n performs_analyze_action: true,\n performs_archive_action: false,\n performs_test_action: true,\n project_path:,\n repo_url:,\n scheme_name:,\n testing_schedule: TestingSchedule::Type::ON_COMMIT,\n working_copy_path:)\n repo_identifier = SecureRandom.uuid\n res = post('bots',\n group: {\n name: SecureRandom.uuid\n },\n configuration: {\n builtFromClean: 1, # Always\n periodicScheduleInterval: 0, # Run manually\n performs_test_action: performs_test_action,\n performs_analyze_action: performs_analyze_action,\n scheme_name: scheme_name,\n sourceControlBlueprint: {\n DVTSourceControlWorkspaceBlueprintLocationsKey: {\n repo_identifier => {\n DVTSourceControlBranchIdentifierKey: branch_name,\n DVTSourceControlBranchOptionsKey: 156, # Mystery meat\n DVTSourceControlWorkspaceBlueprintLocationTypeKey: \"DVTSourceControlBranch\" # \"Pull a git branch\"\n }\n },\n DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey: repo_identifier,\n DVTSourceControlWorkspaceBlueprintRemoteRepositoryAuthenticationStrategiesKey: {\n repo_identifier => {\n DVTSourceControlWorkspaceBlueprintRemoteRepositoryAuthenticationTypeKey: \"DVTSourceControlAuthenticationStrategy\"\n }\n },\n DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey: {\n repo_identifier => 0\n },\n DVTSourceControlWorkspaceBlueprintIdentifierKey: repo_identifier,\n DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey: {\n repo_identifier => working_copy_path\n },\n DVTSourceControlWorkspaceBlueprintNameKey: project_path,\n DVTSourceControlWorkspaceBlueprintVersion: 203, # Mystery meat\n DVTSourceControlWorkspaceBlueprintRelativePathToProjectKey: project_path,\n DVTSourceControlWorkspaceBlueprintRemoteRepositoriesKey: [{\n DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey: project_url,\n DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey: \"com.apple.dt.Xcode.sourcecontrol.Git\",\n DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey: repo_identifier\n }]\n },\n hourOfIntegration: 0,\n scheduleType: testing_schedule,\n performs_archive_action: performs_archive_action,\n testingDestinationType: 0 # \"iOS All Devices and All Simulators\"\n },\n requiresUpgrade: false, # Mystery meat\n name: bot_name,\n type: 1 # Mystery meat\n )\n\n Bot.new(self, JSON.load(res.body))\n end",
"def hook_thyself\n me = self\n\n\n\n # Add something to tell someone\n register_command(:tweet_cmd, /^tweet$/, [/channel/, /private/]){|*args| \n me.tweet(bot, nick, args.join(\" \"))\n }\n\n\n \n # Hook for when we have successfully joined\n @config[:channels].each do |chan|\n register_hook(\"twitter_join_#{chan}\".to_sym, lambda{|m| m.channel == chan}, /join/){\n me.join_channel( chan, bot ) if nick == bot_nick # Ensure we only fire if the bot has joined, not other people\n }\n end\n\n end",
"def InitializeHooks\n end",
"def bot\n @bot ||= Bot.new(ua)\n end",
"def initialize_hook(hook, payload)\n @initialize_hook.call(hook, payload)\n end",
"def invoke(vars, block, args=[], thread_to_await=nil)\n # Construct a new class\n cls = Class.new \n\n # Set up pre-defined variables\n vars.each{|n, v|\n cls.send :define_method, n.to_sym, Proc.new{|| return v} \n }\n # and the call that runs the hook\n cls.send :define_method, :__hookbot_invoke, block\n\n # then call, in a thread, waiting for any old threads\n # should we have been passed one\n return Thread.new(thread_to_await, cls, args){ |thread_to_await, cls, args|\n thread_to_await.join if thread_to_await and thread_to_await.is_a(Thread) and thread_to_await.alive?\n\n begin\n cls.new.__hookbot_invoke(*args)\n rescue Exception => e\n $log.error \"Error in callback thread: #{e}\"\n $log.debug \"#{e.backtrace.join(\"\\n\")}\"\n end\n }\n end",
"def my_bot\n Discordrb::Bot.new token: @token, application_id: @app_id\n end",
"def initialize(options = {})\n\t\t@name = options[:name] || \"Unnamed Bot\"\n\t\tbegin \n\t\t\t# @data = YAML.load(File.read(options[:data_file]))\n\t\t\t@data = BOT_DATA\n\t rescue\n\t \traise \"Cant load bot data\"\n\t end\n\tend",
"def _hooks\n @hooks ||= SlackRubyBot::Hooks::Set.new\n end",
"def initialize\n @hook_url = self.class.hook_url || ENV['SIMPLECOV_IDOBATA_HOOK_URL']\n end",
"def initialize(hook_dir, git = Git.new)\n @config = Raincoat::Configuration.new\n @script_dir = File.join(@config.script_dir, hook_dir)\n @git = git\n end",
"def hook_name; end",
"def add(hook)\n @hooks << hook\n self\n end",
"def new_bot email, password, room\n counter = Thread.new do\n TT.run do\n client = TT::Client.new(email, password, room: room)\n my_bot = Bot.new(client)\n client.on :user_spoke do |message|\n puts \"**** in :user_spoke message: #{message.content}\"\n my_bot.tell(message.content, message.sender) if message.content.split[0] == client.user.name\n end\n client.on :user_entered do |user|\n my_bot.say_hello user\n end\n client.on :song_started do |song|\n my_bot.bop song\n end\n end\n end\nend",
"def define_hook(id, &block)\n\t\t\t\t\th = Hook.new id, &block\n\t\t\t\t\t@hooks[id] = [] unless @hooks[id]\n\t\t\t\t\t@hooks[id] << h\n\t\t\t\tend",
"def setup_bot\n Facebook::Messenger::Profile.set({\n greeting: {\n locale: 'default',\n text: 'Welcome to your friendly Ads Bot! :)' \n },\n get_started: {\n payload: 'GET_STARTED' # make sure to handle this postback\n }\n # @TODO: Add persistent menu\n }, access_token: access_token)\n end",
"def create\n @hook = Hook.new(params[:hook])\n @hook.save\n respond_with(@hook)\n end",
"def initialize(bot, data, params)\n @bot = bot\n @data = data\n @params = params\n end",
"def get_instance(payload)\n CompositionHookInstance.new(@version, payload, )\n end",
"def add_hooks(repo, endpoint)\n hook = api.create_hook(\n repo,\n 'web',\n {\n url: endpoint,\n secret: ENV['GITHUB_SECRET_TOKEN']\n },\n {\n events: %w(push pull_request), active: true,\n }\n )\n\n yield hook.id\n rescue Octokit::UnprocessableEntity => error\n raise unless error.message.include? 'Hook already exists'\n end",
"def bot()\n merge(bot: 'true')\n end",
"def webhook(request)\n WebHook.new(request, self)\n end",
"def webhooks\n SpaceWebhookMethodsFactory.new(self)\n end",
"def initialize webhook\n @nfe_webhook = @nfe_account.nfe_webhook\n @webhook = webhook\n \n response = update\n end",
"def initialize(webhook_inspector)\n super()\n @webhook_inspector = webhook_inspector\n end",
"def build\n WebhooksHelper.new(@marshaller, @secret_key_store)\n end",
"def hook(&block)\n @hooks << block\n end",
"def bootstrap\n STDERR.puts \"My oauth authorization URL is: #{@bot.invite_url}\"\n load_plugins\n end",
"def fire(hook, *args); end",
"def create\n processor = Mandrill::WebHook::Processor.new(params, self)\n processor.on_unhandled_mandrill_events = self.class.on_unhandled_mandrill_events!\n processor.run!\n head(:ok)\n end",
"def initialize(cli, configuration, hooks, environment)\n @cli = cli\n @configuration = configuration\n @hooks = hooks\n @environment = environment\n @perform_hooks = false\n end",
"def start\n until @done\n json = retrieve_hook\n HookRunner.new(json) if json\n end\n end",
"def web_hook\n unless instance_variable_defined?(:@web_hook)\n @web_hook = if (cls = web_hook_class)\n cls.new(self)\n end\n end\n\n @web_hook\n end",
"def initialize\n load_config\n @token = ENV.fetch('DISCORD_TOKEN', @config[:DISCORD_TOKEN])\n @app_id = ENV.fetch('DISCORD_APP_ID', @config[:DISCORD_APP_ID])\n @bot = my_bot\n @bot.info \"The first few characters of the discord token are: #{@token[0, 5]}\"\n @bot.info \"App_id is: #{@app_id}\"\n end",
"def initialize(responses, queue)\n @id = \"Bot-\" + SecureRandom.uuid\n @responses = responses\n @queue = queue\n @agent = Mechanize.new\n @state = {}\n @thread = Thread.new {run}\n end",
"def initialize(bot, key, type, attributes, block = nil)\n @bot = bot\n @key = key\n @type = type\n @attributes = attributes\n @block = block\n end",
"def webhook\n @config = ZipMoney::Configuration \n @_webhook = ZipMoney::WebHook if @_webhook.nil?\n @_webhook\n end",
"def around_hook(hook)\n define_method hook do |&block|\n add_hook(hook, &block)\n end\n define_method \"run_#{hook}\" do |*args, &block|\n run_around_hook(hook, *args, &block)\n end\n end",
"def hook1; end",
"def add_hook(url)\n post(\"/hooks\", :body => {:url => url})\n end",
"def hooks\n # ???\n end",
"def run\n @bot.run\n end",
"def hook\n self.class.hook\n end",
"def pre_hook_send(handler); end",
"def establecer_bot(bot)\n @bot = bot\n end",
"def webhooks\n @webhooks ||= WebhookRegistry.new\n end",
"def create\n processor = Mailgun::WebHook::Processor.new(mailgun_params, self)\n processor.on_unhandled_mailgun_events = self.class.on_unhandled_mailgun_events!\n processor.run!\n block_given? ? yield : head(:ok)\n end",
"def hook_owner; end",
"def initialize\n register_script \"Provides several game commands.\"\n\n register_command \"dice\", :cmd_dice, 1, 0, nil, \"Roll dice. Parameters: <count>d<sides>[+/-<modifier>]\"\n register_command \"eightball\", :cmd_eightball, 0, 0, nil, \"Shake the 8-ball.\"\n register_command \"coin\", :cmd_coin, 0, 0, nil, \"Flip a coin.\"\nend",
"def set_hook\n @hook = Hook.find(params[:id])\n end",
"def initialize(*args)\n super\n\n @config = @bot.config\n @db = @config.db\n @keywords = eval(\"/#{@config.keywords.join(\"|\")}/i\")\n @passwd = config['command']['password'] ||\n Digest::SHA1.hexdigest(\"impersonate!\")\n @users = []\n end",
"def hook(&block)\n @hook = block if block_given?\n @hook\nend",
"def hooks\n @hooks ||= []\n end",
"def start_bot\n Telegram::Bot::Client.run(@token) do |bot|\n @bot=bot\n bot.listen do |message|\n @last_message=message\n # print message to terminal for debug\n puts message\n # switch case for different command\n # TODO: extract each command to a new method\n case message.text\n when /\\A\\/start/\n bot.api.send_message(chat_id: message.chat.id, text: \"Hello, #{message.from.first_name}. I am started! >.<\")\n when /\\A\\/stop/\n bot.api.send_message(chat_id: message.chat.id, text: \"Bye, #{message.from.first_name}. Why did you stop me? T^T\")\n when /\\A\\/help/\n bot.api.send_message(chat_id: message.chat.id, text:\n \"/run\\nFormat: /run {code}\\nAvailable method: times, puts, print, each, p \\nExample: \\n/run 3.times{|x| puts x*x}\\n/run puts 'I am a happy little bot.'\\nThis bot is created by @Energy0124. \\nSource code is avaliable here:\\n https://github.com/Energy0124/EnergyRubyTelegramBot.git \")\n # running ruby code on server in a sandbox\n when /\\A\\/run/\n if message.text=~ /\\A\\/run@Energy0124TestBot/\n message.text.slice! '/run@Energy0124TestBot'\n else\n message.text.slice! '/run'\n end\n begin\n # capture the stdout\n stdout=with_captured_stdout {\n s = Sandbox.new\n priv = Privileges.new\n # whitelist some safe method\n priv.allow_const_read *@allowed_const_read\n priv.allow_methods *@allowed_methods\n # eval the ruby code\n s.run(priv, message.text, :timeout => 3)\n }\n # print the stdout\n puts(stdout)\n # send stdout as telegram message\n send_reply(\"Result:\\n#{stdout}\")\n # catch exception\n rescue Exception => ex\n send_reply(\"Error:\\n#{ex}\")\n end\n # for fun\n when /fuck/i\n send_reply(\"I fucking hate people saying 'fuck'.\")\n when /dota/i\n send_reply('Dota is the best!')\n when /stupid bot/i\n send_reply('Still a bit smarter than you :P')\n when /\\A\\/(admin|secret)/i\n send_reply('https://youtu.be/dQw4w9WgXcQ')\n end\n end\n end\n end",
"def initialize\n @hook_register = Hash.new(nil)\n @lever_register = Hash.new(nil)\n end",
"def hook(id, params={})\n\t\t\t\tparams[:self] = self\n\t\t\t\tself.class.hooks.execute id, params\n\t\t\tend",
"def setup()\n \n # validates the hook token\n beef_hook = @data['beefhook'] || nil \n if beef_hook.nil?\n print_error \"[EVENTS] beef_hook is null\"\n return\n end\n\n # validates that a hooked browser with the beef_hook token exists in the db\n zombie = Z.first(:session => beef_hook) || nil\n if zombie.nil?\n print_error \"[EVENTS] Invalid beef hook id: the hooked browser cannot be found in the database\"\n return\n end\n \n events = @data['results']\n\n # push events to logger\n if (events.kind_of?(Array))\n logger = BeEF::Core::Logger.instance\n events.each{|e|\n logger.register('Event', parse(e), zombie.id)\n }\n end\n\n end",
"def initialize(options = {})\n @master = options.delete(:master)\n @output_dir = options.delete(:output_dir) || File.dirname(__FILE__)\n\n # Log files per channel - logs rotate every so often, so we have to store\n # filenames on a per-channel basis\n @current_log = {}\n @log_date = {}\n @passwords = options[:passwords] || {}\n\n options[:username] = BOTNAME\n options[:realname] = BOTNAME\n options[:nicknames] = ['LoggerBot', 'Logger_Bot', 'logger_bot', '_LoggerBot', 'LoggerBot_']\n\n # Set up IRCBot, our loving parent, and begin\n super(options)\n self.connect_socket\n self.start_listening\n end",
"def initialize(options)\n\t\t@name = options[:name] || \"Unnamed Bot\" # name = name otherwise it is an Unnamed bot\n\t\tbegin\n\t\t\t@data = YAML.load(File.read(options[:data_file]))\n\t\trescue \n\t\t\traise \"Can't load bot data\"\n\t\tend\n\tend",
"def create\n Tipsy::Runners::Generator.new(args, @site)\n end",
"def command cmd, help = \"\", &blk\n Bot::Commands.create self, cmd, help, &blk\n end",
"def initialize(options)\n\t\t@name = options[:name] || \"Unnamed Bot\"\n\t\tbegin\n\t\t# Load data files\n\t\t\t@data = YAML.load(File.read(options[:data_file]))\n\t\t# In case data cannot be loaded\n\t\trescue\n\t\t\traise \"Can't load bot data\"\n\t\tend\n\tend",
"def initialize(await, event, bot)\n @await = await\n @event = event\n @bot = bot\n end",
"def welcome_message\n bolt = <<~BOLT\n `.::-`\n `.-:///////-.`\n `-:////:. `-:///:- /ooo. .ooo/\n `.-:///::///:-` `-//: ymmm- :mmmy .---.\n :///:-. `.:////. -//: ymmm- :mmmy +mmm+\n ://. ///. -//: ymmm--/++/- `-/++/:` :mmmy-:smmms::-\n ://. ://. .://: ymmmdmmmmmmdo` .smmmmmmmmh: :mmmysmmmmmmmms\n ://. ://:///:-. ymmmh/--/hmmmy -mmmd/-.:hmmm+:mmmy.-smmms--.\n ://:.` .-////:-` ymmm- ymmm:hmmm- `dmmm/mmmy +mmm+\n `-:///:-..:///:-.` ymmm- ommm/dmmm` hmmm+mmmy +mmm+\n `.-:////:-` ymmm+ /mmmm.ommms` /mmmh:mmmy +mmmo\n `-.` ymmmmmhhmmmmd: ommmmhydmmmy`:mmmy -mmmmdhd\n oyyy+shddhs/` .+shddhy+- -yyyo .ohddhs\n\n\n BOLT\n example_cmd = if Bolt::Util.windows?\n \"Invoke-BoltCommand -Command 'hostname' -Targets localhost\"\n else\n \"bolt command run 'hostname' --target localhost\"\n end\n prev_cmd = String.new(\"bolt\")\n prev_cmd << \" #{@argv[0]}\" unless @argv.empty?\n\n message = <<~MSG\n 🎉 Welcome to Bolt #{VERSION}\n 😌 We're here to help bring order to the chaos\n 📖 Find our documentation at https://bolt.guide\n 🙋 Ask a question in #bolt on https://slack.puppet.com/\n 🔩 Contribute at https://github.com/puppetlabs/bolt/\n 💡 Not sure where to start? Try \"#{example_cmd}\"\n\n We only print this message once. Run \"#{prev_cmd}\" again for help text.\n MSG\n\n $stdout.print \"\\033[36m#{bolt}\\033[0m\"\n $stdout.print message\n end",
"def configure\n # Users to block instead of interacting with\n self.blacklist = ['mcamargo1997']\n\n # Range in seconds to randomize delay when bot.delay is called\n self.delay_range = 1..6\n\n @userinfo = {}\n @botinfo = {\n ENV[\"BOT_NAME_1\"] => BotInfo.new(ENV[\"BOT_NAME_1\"]),\n ENV[\"BOT_NAME_2\"] => BotInfo.new(ENV[\"BOT_NAME_2\"])\n }\n end",
"def configure\n\n # Give the bot a handle to config and handler\n conf = @config\n\n # Configure the bot\n @bot = Isaac::Bot.new\n @bot.configure{|c|\n c.server = conf[:server]\n c.port = conf[:port]\n c.ssl = conf[:ssl]\n c.nick = conf[:nick]\n c.password = conf[:password]\n c.realname = conf[:name]\n\n c.environment = :production\n c.verbose = conf[:verbose] || false \n c.log = $log\n }\n\n end",
"def initialize(*args)\n\t\t\t\tsuper\n\t\t\t\t#super called in order to call the same method from the parent class and then adding our thing (next line)\n\t\t\t\t@cleverbot = ::Cleverbot::Client.new #:: means look not at this namespace but at the very top and search down.\n\t\t\tend",
"def hooks\n fetch_or_create_hooks.dup.freeze\n end",
"def initialize(bot = nil, update = nil)\n if update.is_a?(Hash) && (update.key?(:from) || update.key?(:chat))\n options = update\n update = nil\n end\n @_update = update\n @_bot = bot\n @_chat, @_from = options && options.values_at(:chat, :from)\n\n payload_data = nil\n update && PAYLOAD_TYPES.find do |type|\n item = update[type]\n payload_data = [item, type] if item\n end\n @_payload, @_payload_type = payload_data\n end",
"def build_embed(embed = Discordrb::Webhooks::Embed.new, message = nil)\n embed.title = AcnhBot.client.bot_app.name\n embed.timestamp = Time.at(Time.now.to_i)\n if message\n embed.footer = Discordrb::Webhooks::EmbedFooter.new(:text => \"Demandé par #{message.author.name}\",\n :icon_url => message.author.avatar_url)\n end\n embed\n end",
"def on_connect(*)\n @storage = TickingAway::JSONFileStorage.new\n @ta_bot = config[:time_api] ? TickingAway::Bot.new(storage: @storage, time_api: config[:time_api]) : TickingAway::Bot.new(storage: @storage)\n end",
"def hook(id)\n get(\"/hooks/#{id}\")\n end",
"def webhooks_create(owner, repo, opts = {})\n data, _status_code, _headers = webhooks_create_with_http_info(owner, repo, opts)\n return data\n end",
"def initialize\n register_script \"Leave messages for inactive users.\"\n\n register_event :PRIVMSG, :on_privmsg\n\n register_command \"tell\", :cmd_tell, 2, 0, nil, \"Have the bot tell the given user something the next time they speak. Parameters: nick message\"\nend",
"def init\n \n # Setup Slack\n Slack.configure do |config|\n config.token = ENV['SLACK_TOKEN']\n if not config.token\n puts('Missing ENV[SLACK_TOKEN]! Exiting program')\n exit\n end\n end\n @client = Slack::RealTime::Client.new\n @client.on :hello do\n puts(\"Connected '#{@client.self['name']}' to '#{@client.team['name']}' team at https://#{@client.team['domain']}.slack.com.\")\n end\n\n # Setup GA\n @GA_manager = Galerts::Manager.new(ENV['GMAIL_USER'], ENV['GMAIL_PASS'])\n @alert_cache = @GA_manager.alerts\n \n # Setup message hooks\n setupMessageHook()\n\n # Cleanup hooks\n @client.on :close do |_data|\n puts 'Connection closing, exiting.'\n EM.stop\n end\n @client.on :closed do |_data|\n puts 'Connection has been disconnected.'\n end\n\n # Run this bad boy\n @client.start!\n \nend",
"def initialize(params={})\n if params.has_key?(:name)\n @botname = params.delete(:name)\n end\n\n @config = load_config(params)\n @run_count = 0\n\n #\n # check for command line options\n # handle resets, etc\n #\n\n at_exit do\n if !@handlers.empty? && @run_count <= 0 && skip_run? != true\n run!\n end\n \n raise $! if $!\n end\n @handlers = {}\n end",
"def telegram_webhook(controller, bot = :default, **options)\n bot = Client.wrap(bot)\n params = {\n to: Middleware.new(bot, controller),\n as: RoutesHelper.route_name_for_bot(bot),\n format: false,\n }.merge!(options)\n post(\"telegram/#{RoutesHelper.escape_token bot.token}\", params)\n UpdatesPoller.add(bot, controller) if Telegram.bot_poller_mode?\n end",
"def define_hook(name, *params)\n fetch_or_create_hooks << make_hook(name, nil, params)\n\n # We must use string evaluation in order to define a method that can\n # receive a block.\n instance_eval(<<-END)\n def #{name}(handle_or_method=nil, &block)\n add_callback(:#{name}, handle_or_method, &block)\n end\n END\n module_eval(<<-END)\n def #{name}(handle=nil, &block)\n add_external_callback(:#{name}, handle, block)\n end\n END\n end",
"def weechat_init\n Weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, '', '')\n Weechat.hook_command('roll', SCRIPT_DESC, '', '', '', 'roll_handler', '')\n Weechat.hook_print('', '', '', 1, 'roll_msg', '')\n return Weechat::WEECHAT_RC_OK\nend"
] |
[
"0.68922573",
"0.68791735",
"0.68699443",
"0.67480004",
"0.6576622",
"0.64313495",
"0.6293837",
"0.6262295",
"0.6184542",
"0.60404617",
"0.6029501",
"0.6029349",
"0.59977984",
"0.597626",
"0.5916502",
"0.5914196",
"0.58998305",
"0.58806276",
"0.58385444",
"0.5832876",
"0.58240753",
"0.5817543",
"0.58174276",
"0.5783308",
"0.57782525",
"0.5758825",
"0.5745727",
"0.5692113",
"0.56628925",
"0.5656067",
"0.5653229",
"0.5649059",
"0.56474465",
"0.56094563",
"0.55986446",
"0.55973405",
"0.5581642",
"0.5576523",
"0.5552537",
"0.55436814",
"0.553952",
"0.5539322",
"0.5529792",
"0.55265737",
"0.55184525",
"0.5515737",
"0.55143505",
"0.5512571",
"0.54715896",
"0.5471233",
"0.54707265",
"0.5458649",
"0.5457263",
"0.54561335",
"0.54520863",
"0.5428122",
"0.5415817",
"0.5415705",
"0.54128635",
"0.53971076",
"0.5390284",
"0.538421",
"0.5379742",
"0.5370255",
"0.5368763",
"0.5359389",
"0.5358836",
"0.5354514",
"0.5337614",
"0.5335954",
"0.53335834",
"0.53302276",
"0.5315107",
"0.53063333",
"0.5301601",
"0.5285076",
"0.52836496",
"0.52773315",
"0.5271875",
"0.52624786",
"0.52534944",
"0.5243539",
"0.52373224",
"0.5235553",
"0.5233585",
"0.5229335",
"0.5227704",
"0.52227813",
"0.52094257",
"0.5206119",
"0.52012306",
"0.5197844",
"0.5186674",
"0.5176364",
"0.5170914",
"0.516209",
"0.51616424",
"0.51591355",
"0.51586753",
"0.51522523"
] |
0.5878174
|
18
|
Register a command, only invoked when COMMAND_RX is triggered. mod A link to the module object, used in tracking threads name A name for this command, for unregistering later trigger A regex which, if the command matches (see COMMAND_RX), will cause the callback to fire types The types of message to respond to. p A procedure to run when all the checks work out
|
def register_command(mod, name, trigger, types = /channel/, &p)
raise "Please define a block" if not block_given?
raise "That command is already hooked." if @cmds[name]
raise "The module given is not a module" if not mod.is_a?(HookService)
# Ensure types is an array and is full of regex
types = [types] if not types.is_a?(Array)
types.map!{|x| (x.is_a? Regexp) ? x : Regexp.new(x.to_s)} # convert to rx if not already
@hooks_mutex.synchronize{
# Ensure default and register
@cmds[name] ||= {}
@cmds[name] = {:types => types, :trigger => trigger, :proc => p, :module => mod}
# register hook or command for a given module
@modules[mod] ||= {:hooks => [], :cmds => [], :threads => [], :threaded => mod.threaded?}
@modules[mod][:cmds] << name
}
$log.debug "Registered command '#{name}'"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def register_hook(mod, name, trigger = nil, types = /channel/, &p)\n raise \"Please define a block\" if not block_given?\n raise \"That command is already hooked.\" if @hooks[name]\n raise \"The module given is not a module\" if not mod.is_a?(HookService)\n trigger ||= lambda{|*| return true} # set trigger if someone has allowed it to be default\n raise \"Cannot call the trigger expression (type: #{trigger.class})! Ensure it responds to call()\" if not trigger.respond_to?(:call)\n \n # Ensure types is an array and is full of regex\n types = [types] if not types.is_a?(Array)\n types.map!{|x| (x.is_a? Regexp) ? x : Regexp.new(x.to_s)} # convert to rx if not already\n \n @hooks_mutex.synchronize{\n # Ensure defaults and register \n @hooks[name] ||= {}\n @hooks[name] = {:types => types, :trigger => trigger, :proc => p, :module => mod}\n \n # Register a given hook or command for a give module\n @modules[mod] ||= {:hooks => [], :cmds => [], :threads => [], :threaded => mod.threaded?}\n @modules[mod][:hooks] << name\n }\n\n $log.debug \"Registered hook '#{name}'\"\n end",
"def register_command cmd\n $commandlist << cmd\nend",
"def register_command command\n @commands ||= {}\n @commands[command.expression.to_regexp] = command\n end",
"def register_command(cmd)\n registered_commands << cmd\n\n self\n end",
"def registration_commands(command, bot_webhook)\n return check_user_consist(bot_webhook) if command.eql?(:message)\n\n self.class.send_message(StrContainer.need_number, bot_webhook)\n end",
"def register_observer(observer, cmd_name=nil)\n codes= []\n if cmd_name\n codes << Protocol.find_cmd_by_name(cmd_name).code\n else\n codes+= CMDS_BY_CODE.keys\n end\n codes.each {|code|\n list= @observers[code]\n if list.nil?\n @observers[code]= list= []\n end\n list.push(observer)\n }\n end",
"def on_command(command_name, &block)\n handlers[{ regexp: command_name, type: :command_name }] = block\n end",
"def add_command(id, &command)\n\t\tif @config['Commands'].nil? || @config['Commands'][id].nil?\n\t\t\tputs \"Plugin Manager: No command '#{id}' defined for #{@config['General']['Title']}\"\n\t\t\treturn nil\n\t\tend\n\t\tcmd = @config['Commands'][id]\n\t\t@procs[id] = UI::Command.new(cmd['Label'], &command)\n\t\t# Tooltips\n\t\t@procs[id].tooltip = cmd['Label']\n\t\t@procs[id].status_bar_text = cmd['Description'] if cmd.key?('Description')\n\t\t# Add Icons\n\t\ticon_path = @config['General']['ConfigPath'] + @config['General']['IconPath']\n\t\t@procs[id].small_icon = icon_path + cmd['SmallIcon'] if cmd.key?('SmallIcon')\n\t\t@procs[id].large_icon = icon_path + cmd['LargeIcon'] if cmd.key?('LargeIcon')\n\t\t#puts \"> Command '#{id}' registered!\"\n\t\treturn @procs[id]\n\tend",
"def call(*command)\n @commands << command\n end",
"def commands=(cmd)\n @queue << \"com #{cmd}\"\n end",
"def register_command(klass)\n boot.register_command(klass) if boot\n end",
"def register(msg, callback)\n key = msg.kind_of?(Numeric) \\\n ? (\"%03d\" % msg) \\\n : msg.to_s.upcase\n @callbacks.add(key, callback)\n end",
"def register_command(klass)\n @command_classes << klass\n end",
"def register_command(klass)\n @command_classes << klass\n end",
"def listen\n command = gets\n\n command_name, *args = command.split(COMMAND_SEPERATOR)\n\n if FARM_ACTIVITY_COMMANDS.key?(command_name)\n command_object = build_farm_command(command_name, args)\n elsif UTILITY_COMMANDS.key?(command_name)\n command_object = build_utility_command(command_name, args)\n end\n\n commands.push command_object\n end",
"def queue_cmd(cmd)\n\t\tself.commands << cmd\n\tend",
"def send_command(mod, command, *args, &block)\n\t\t#\n\t\t# Accept String, argument array\n\t\t#\tString\n\t\t#\n\t\tmod = mod.to_sym if mod.class == String\n\t\tlogger.debug \"-- Command requested #{mod}.#{command}(#{args})\"\n\t\t\n\t\tbegin\n\t\t\t@command_lock.synchronize {\n\t\t\t\t@system.modules[mod].instance.public_send(command, *args)\t# Not send string however call function command\n\t\t\t}\n\t\trescue => e\n\t\t\tControl.print_error(logger, e, {\n\t\t\t\t:message => \"module #{mod} in communicator.rb, send_command : command unavaliable or bad module code\",\n\t\t\t\t:level => Logger::WARN\n\t\t\t})\n\t\t\tbegin\n\t\t\t\tblock.call() unless block.nil?\t# Block will inform of any errors\n\t\t\trescue => x\n\t\t\t\tControl.print_error(logger, x, {\n\t\t\t\t\t:message => \"in communicator.rb, send_command : interface provided bad block\",\n\t\t\t\t\t:level => Logger::ERROR\n\t\t\t\t})\n\t\t\tend\n\t\tensure\n\t\t\tActiveRecord::Base.clear_active_connections!\n\t\tend\n\tend",
"def protocol_manager_command(name, data = nil)\n command('ProtocolManager.Command', name, data)\n end",
"def process_command command\n\n # The decision maker will validate the command\n # and get rid of the commands that is invalid\n # and make the right order of commands and notify different observers.\n\n # Notify the observers that a new valid command comes.\n command\n end",
"def register(interface, mod, status, &block)\n\t\tmod_sym = mod.class == String ? mod.to_sym : mod\t# remember the symbol used by the interface to reference this module\n\t\tstatus = status.to_sym if status.class == String\n\t\t\n\t\tif @system.modules[mod_sym].present?\n\t\t\tmod = @system.modules[mod_sym].instance\t# most efficient\n\t\n\t\t\ttheVal = nil\n\t\t\t@status_lock.synchronize {\n\t\t\t\t@status_register[mod] ||= {}\n\t\t\t\t@status_register[mod][status] ||= {}\n\t\t\t\t@status_register[mod][status][interface] = mod_sym\n\t\t\t\t@connected_interfaces[interface] << @status_register[mod][status] unless @connected_interfaces[interface].nil?\n\t\t\t\ttheVal = mod[status]\n\t\t\t}\n\t\t\t\n\t\t\tmod.add_observer(self)\n\t\t\tlogger.debug \"-- Interface #{interface.class} registered #{mod_sym}:#{status}\"\n\t\t\t\n\t\t\t#\n\t\t\t# Send the status to this requestor!\n\t\t\t#\tThis is the same as in update\n\t\t\t#\n\t\t\tif !theVal.nil?\n\t\t\t\tbegin\n\t\t\t\t\tfunction = \"#{mod_sym.to_s.downcase}_#{status}_changed\".to_sym\n\t\t\t\t\t\n\t\t\t\t\tif interface.respond_to?(function)\n\t\t\t\t\t\tinterface.__send__(function, theVal)\n\t\t\t\t\telse\n\t\t\t\t\t\tinterface.notify(mod_sym, status, theVal)\n\t\t\t\t\tend\n\t\t\t\trescue => e\n\t\t\t\t\tControl.print_error(logger, e, {\n\t\t\t\t\t\t:message => \"in communicator.rb, register : bad interface or user module code\",\n\t\t\t\t\t\t:level => Logger::ERROR\n\t\t\t\t\t})\n\t\t\t\tend\n\t\t\tend\n\t\telse\n\t\t\tlogger.warn \"in communicator.rb, register : #{interface.class} called register on a bad module name\"\n\t\t\tblock.call() unless block.nil?\t# Block will inform of any errors\n\t\tend\n\trescue => e\n\t\tbegin\n\t\t\tControl.print_error(logger, e, {\n\t\t\t\t:message => \"in communicator.rb, register : #{interface.class} failed to register #{mod.inspect}.#{status.inspect}\",\n\t\t\t\t:level => Logger::ERROR\n\t\t\t})\n\t\t\tblock.call() unless block.nil?\t# Block will inform of any errors\n\t\trescue => x\n\t\t\tControl.print_error(logger, x, {\n\t\t\t\t:message => \"in communicator.rb, register : #{interface.class} provided a bad block\",\n\t\t\t\t:level => Logger::WARN\n\t\t\t})\n\t\tend\n\tensure\n\t\tActiveRecord::Base.clear_active_connections!\n\tend",
"def register(count, regex, reply)\n register_hook(\"autoreply_msg#{count}\".to_sym, lambda{|raw| raw.message =~ regex}, /channel/){\n bot.say( reply )\n }\n end",
"def register(klass, subcommand_name, usage, description, options = {})\n if klass <= Foreman::Thor::Group\n desc usage, description, options\n define_method(subcommand_name) { |*args| invoke(klass, args) }\n else\n desc usage, description, options\n subcommand subcommand_name, klass\n end\n end",
"def process_command(rep)\n\t \t\taddress = rep[:address]\n\n\t \t\tif address==1\n\t \t\t\tqueue = @cmd_queue_1\n\t \t\telse\n\t \t\t\tqueue = @cmd_queue_0\n\t \t\tend\n\n\t \t\tcase rep[:type]\n\t \t\t\twhen 0\n\t \t\t\t\t@log.info \"Command OK\"\n\t \t\t\twhen 1\n\t \t\t\t\t@log.error \"Invalid Command\"\t\n\t \t\t\twhen 2\n\t \t\t\t\t@log.error \"Busy - command ignored\"\t\t\n\t \t\t\twhen 3\n\t \t\t\t\t@log.error \"Can't Process - input out of range or error\"\n\t \t\t\t\t\n\t \t\tend\n\t \t\twrite_command_status(queue)\n\t end",
"def command(name)\n load_commands.select { |lc| lc.type == name.to_sym }\n end",
"def command_need m\n channel = escape m.channel.to_s\n locked = locked_logic channel\n need_logic channel, locked #logic/pug\n end",
"def register(&prc)\n @eff.perform prc\n end",
"def on_system(command, &callback)\n @midi.add_system_callback(command, &callback)\n end",
"def add_command(name, symbol, enabled = true, ext = nil)\r\n @list.push({:name=>name, :symbol=>symbol, :enabled=>enabled, :ext=>ext})\r\n end",
"def register(name, command, options={})\n options[:env] ||= env\n options[:cwd] ||= File.dirname(command.split(\" \").first)\n process = Foreman::Process.new(command, options)\n @names[process] = name\n @processes << process\n end",
"def register(command)\n args = command.split(\" \")[1..-1]\n params = { :name => args[0], :number => args[1], :email => args[2] }\n add_application(params)\nend",
"def add_commands\n end",
"def add_command(name, handler)\n @commands[name] = handler\n end",
"def run(command, &callback)\n if reset?(command)\n callback.call(run_built_in(command))\n else\n @commands.push({command: command.strip, callback: callback})\n end\n end",
"def execute_hook(command); end",
"def plugin(command)\n command(command)\n end",
"def initialize\n register_script \"Leave messages for inactive users.\"\n\n register_event :PRIVMSG, :on_privmsg\n\n register_command \"tell\", :cmd_tell, 2, 0, nil, \"Have the bot tell the given user something the next time they speak. Parameters: nick message\"\nend",
"def record(*command)\n @commands << command\n end",
"def call(*command); end",
"def register_new_command(command)\n reset_history_if_task_changed\n\n first_execution = !history.include?(command.to_s)\n history << command.to_s\n history.uniq!\n first_execution\n end",
"def on_command(name, params)\n return Node.new(\n :method,\n [name.children[0], on_params(params), nil, nil],\n metadata(name)\n )\n end",
"def cmd(command, val)\n @emq.push( raw_cmd command, val )\n end",
"def command(cmd_name)\n cmd = Command.new(cmd_name, self)\n yield cmd\n @commands[cmd_name] = cmd\n end",
"def register_ctcp(msg, callback)\n @ctcp_callbacks.add(msg.to_s.upcase, callback)\n end",
"def received(data, command)\n\t\tlogger.debug \"Extron IPCP sent #{data}\"\n\t\t\n\t\tif command.nil? && data =~ /Copyright/i\n\t\t\tpass = setting(:password)\n\t\t\tif pass.nil?\n\t\t\t\tdevice_ready\n\t\t\telse\n\t\t\t\tdo_send(pass)\t\t# Password set\n\t\t\tend\n\t\telsif data =~ /Login/i\n\t\t\tdevice_ready\n\t\telse\n\t\t\tcase data[0..2].to_sym\n\t\t\twhen :Irs\t# IR Sent\n\t\t\twhen :Cpn\t# IO or Relay\n\t\t\t\tport = data[3..-1].to_i\n\t\t\t\t\n\t\t\t\tdata = data.split(' ')[1]\n\t\t\t\tcase data[0..2]\n\t\t\t\twhen 'Iom'\t# IO mode\n\t\t\t\t\tdata = data[3..-1].split(',')\n\t\t\t\t\tself[\"IO#{port}_mode\"] = data[0].to_i\n\t\t\t\t\tif data.length > 1\n\t\t\t\t\t\tself[\"IO#{port}_upper\"] = data[1].to_i\n\t\t\t\t\t\tself[\"IO#{port}_lower\"] = data[2].to_i\n\t\t\t\t\tend\n\t\t\t\twhen 'Sio'\n\t\t\t\t\tself[\"IO#{port}\"] = data[3..-1].to_i\n\t\t\t\t\t\n\t\t\t\twhen 'Rly'\t\t\t\t\t\t# Relay\n\t\t\t\t\tself[\"relay#{port}\"] = data[3..-1].to_i == 1\n\t\t\t\t\t\n\t\t\t\tend\n\t\t\twhen :Dcp\t# Power\n\t\t\t\tdata = data.split('*')\n\t\t\t\tport = data[0][5..-1].to_i\n\t\t\t\tself[\"power#{port}\"] = data[1] == '1'\n\t\t\telse\n\t\t\t\tif data == 'E22'\t# Busy! We should retry this one\n\t\t\t\t\tsleep(1)\n\t\t\t\t\treturn :failed\n\t\t\t\telsif data[0] == 'E'\n\t\t\t\t\tlogger.info \"Extron Error #{ERRORS[data[1..2].to_i]}\"\n\t\t\t\t\tlogger.info \"- for command #{command[:data]}\" unless command.nil?\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t\n\t\treturn :success\n\tend",
"def process_cmd(command, input_tokens)\n send command, input_tokens\n end",
"def process_protocol(cmds, vars)\n end",
"def proccess_command(command)\n # branch based on command type\n case command[0]\n when COMScript # script [code]\n # evaluate script\n result = eval(command[1])\n when COMWait # wait [int]\n # decrease wait counter by 1\n command[1] -= 1\n # proceed if wait time is up\n return command[1] <= 0\n when COMMove # move [int, int]\n # add to move commands\n @moves.push(command)\n when COMTurn # turn [int]\n # add to move commands\n @moves.push(command)\n when COMJump # jump [int, int]\n # add to move commands\n @moves.push(command)\n when COMAttack # attack\n # use attack\n @ch.use_attack\n when COMSkill # skill [int]\n # use skill\n @ch.use_skill($data_skills[command[1]])\n when COMItem # item [int]\n # use item\n @ch.use_item($data_items[command[1]])\n when COMDefend # defend [int]\n # decrease time\n time = command[1] - 1\n # use defend\n @ch.use_defend\n # set penalty\n @ch.set_action(1)\n # if not done with command\n if time > 0\n # update the command counter\n command[1] = time\n # do not proceed\n return false\n end\n when COMCharacter # character [CH, value]\n # handle based on sub-command\n case command[1]\n when CHSpeed # move speed\n # set movement speed\n @ch.move_speed = command[2]\n when CHFrequency # move frequency\n # set movement frequency\n @ch.move_frequency = command[2]\n when CHSprite # change sprite\n # set sprite\n @ch.character_name = command[2]\n when CHAnimation # play animation\n # set animation\n @ch.animation_id = command[2]\n when CHFix # direction fix\n # set direction fix flag\n @ch.direction_fix = command[2]\n when CHThrough # through\n # set through flag\n @ch.through = command[2]\n when CHOnTop # always on top\n # set always on top flag\n @ch.always_on_top = command[2]\n when CHOpacity # opacity\n # set opacity\n @ch.opacity = command[2] \n end\n when COMInput # create input window [int, [keys], IN, int]\n # create new input window\n @inputs[command[1]] = [command[2], command[3], command[4], false]\n when COMVariable # variable [VAR, value1, '=', VAR, value2]\n val1 = get_variable(command[1], command[2])\n val2 = get_variable(command[4], command[5])\n # branch handling based on operator type\n case command[3]\n when '+=' then val2 = val1 + val2 # add\n when '-=' then val2 = val1 - val2 # subtract\n when '*=' then val2 = val1 * val2 # multiply\n when '/=' then val2 = val1 / val2 # divide\n when '%=' then val2 = val1 % val2 # modulo\n end\n # set the variable\n set_variable(command[1], command[2], val2)\n when COMCondition # condition [VAR, value1, '==', VAR, value2]\n # initialize result\n result = false\n # initialize values\n val1 = get_variable(command[1], command[2])\n val2 = get_variable(command[4], command[5])\n # branch handling based on operator type\n case command[3]\n when '==' # equal to\n # result is value 1 equal to value 2\n result = val1 == val2\n when '!=' # not equal to\n # result is value 1 not equal to value 2\n result = val1 != val2\n when '>' # greater than\n # result is value 1 equal to value 2\n result = val1 > val2\n when '>=' # greater than or equal to\n # result is value 1 not equal to value 2\n result = val1 >= val2\n when '<=' # less than\n # result is value 1 equal to value 2\n result = val1 < val2\n when '<=' # less than or equal to\n # result is value 1 not equal to value 2\n result = val1 <= val2\n end \n # if input or script\n if command[1] == VARInput || command[1] == VARScript\n # value 1 contains the result\n result = val1\n # do not proceed if waiting on an input window\n if command[1] == VARInput && @inputs[command[2]][2] > 0 && !result\n return false\n end\n end\n # skip next command if exists and condition not met\n @commands.delete_at(1) if !result && @commands.size > 1\n when COMFreeze # freeze input [bool]\n # set freeze input flag\n @freeze_character = command[1]\n when COMCompletion # wait for move completion\n # proceed if no more moves and character no longer moving\n return @moves.size == 0 && !@ch.moving?\n when COMGoTo # go to action [int]\n raise 'ERROR: Invalid action' if !is_valid_action?(command[1])\n # setup the action\n setup_action(command[1])\n # do not proceed - new set of commands\n return false\n when COMAbort # abort\n # set ended flag\n @ended = true\n end\n return true\n end",
"def process_cmd(data)\n ##Dyndoc.warn \"process_cmd\",data\n if data =~ /^__send_cmd__\\[\\[(.*)\\]\\]__/\n ##cmd=\"do_\"+$1+\"(\\\"\"+$'+\"\\\")\"\n cmd,param=$1,$'\n ##puts \"cmd\";p cmd;puts \"param\";p param\n param.empty? ? method(\"do__\"+cmd).call : method(\"do__\"+cmd).call(param)\n return true\n else \n return nil\n end\n end",
"def communicate_command( *data )\n\t\t\t\tCommunicateCommand.new @interface, data\n\t\t\tend",
"def load_commands\n command(:linescore) { feed_for_event(_1)&.send_line_score }\n command(:lineups) { feed_for_event(_1)&.send_lineups }\n command(:umpires) { feed_for_event(_1)&.send_umpires }\n\n register_commands_with_arguments\n end",
"def newcommand(options, &block)\n raise \"No name given in command\" unless options.include?(:name)\n\n command = options[:name]\n\n SLAF::Commands.module_eval {\n define_method(\"#{command}_command\", &block)\n }\n\n SLAF::command_options || SLAF.command_options = {}\n\n if options.include?(:allow_arguments)\n SLAF::command_options[command] = options[:allow_arguments]\n else\n SLAF::command_options[command] = false\n end\nend",
"def command_found; end",
"def search_for_command(command)\n @command_map[ command ]\n end",
"def process\n \n # Check for commands\n @command = self.check_commands\n \n # Begin switch if command is found\n # Registration\n if @command == \"reg\"\n unless self.process_registration_information\n @response = false\n end\n \n # Sell command\n elsif @command == \"sell\"\n unless self.process_sell\n @response = false\n end\n \n # Buy command\n elsif @command == \"buy\"\n unless self.process_buy\n @response = false\n end\n \n # Find command \n elsif @command == \"find\"\n unless self.process_find\n @response = false\n end \n \n #Failover \n else \n @response = false\n end \n end",
"def command\n consume 1, :command\n end",
"def add_callback(command_class, callback)\n @callbacks[command_class] = [] unless @callbacks.include?(command_class)\n @callbacks[command_class] << callback\n end",
"def register_command(rel_name, rel_meta, parent_relation = nil)\n options = {\n rel_name: rel_name,\n meta: meta,\n rel_meta: rel_meta,\n parent_relation: parent_relation,\n plugins: plugins\n }\n\n key = \"commands.#{rel_name}.#{id}-compiled-#{options.hash}\"\n\n registry.fetch(key) do\n relation = relations[rel_name]\n klass = command_class.create_class(relation: relation, **options)\n\n if gateways.key?(relation.gateway)\n # TODO: add explicit specs covering this case\n gateways[relation.gateway].command(klass, relation: relation, **options)\n else\n klass.build(relation, **options)\n end\n end\n\n key\n end",
"def send(command, *args)\n debug(\"send: args(#{args.length})'#{args.join('#')}\")\n notQueued = true\n @mutex.synchronize do\n if (!up?)\n debug \"Deferred message: #{command} #{@nodeSelector} #{args.join(' ')}\"\n @deferred << [command, args]\n notQueued = false\n end\n end\n if (up? && notQueued)\n Communicator.instance.send(@nodeSelector, command, args)\n return\n end\n end",
"def push(cmd); end",
"def on_command(args, rest)\n # [:@ident, \"public\", [6, 8]]\n (_, name, (line, _column)) = args\n\n method_name = \"on_#{name}_command\"\n if respond_to? method_name\n return send(method_name, line, args, rest)\n else\n RubyLanguageServer.logger.debug(\"We don't have a #{method_name} with #{args}\")\n end\n\n case name\n when 'public', 'private', 'protected'\n # FIXME: access control...\n process(rest)\n when 'delegate'\n # on_delegate(*args[0][1..-1])\n when 'def_delegator', 'def_instance_delegator'\n # on_def_delegator(*args[0][1..-1])\n when 'def_delegators', 'def_instance_delegators'\n # on_def_delegators(*args[0][1..-1])\n end\n end",
"def command(type)\n end",
"def on_registered msg\n return unless msg.connection == self\n\n @isupport, @registered = {}, true\n\n raw \"MODE #{@nick} +#{@config[:umodes]}\" if @config.key? :umodes\n end",
"def fregister(message_type, message_subtype = nil, &listener)\n _register(message_type, message_subtype , Funnel.wrap(listener))\n end",
"def command(name, help, &b)\r\n\t\t\t@commands[name] = Command.new(name, help, &b)\r\n\t\tend",
"def initialize\n register_script \"Provide on-protocol help for bot scripts and commands.\"\n\n register_command \"help\", :cmd_help, 0, 0, nil, \"Show help for the given command or a list of all commands. Parameters: [command]\"\n register_command \"script\", :cmd_script, 0, 0, nil, \"Show a description of the given script or a list of all scripts. Parameters: [script]\"\nend",
"def trigger_callbacks_for(msg)\n case msg.message_type\n\n # ----- server messages\n when RPL_WELCOME\n notify :registered_with_server\n when CMD_PING\n notify :server_ping, msg.params[0] # server wants the params back\n when CMD_ERROR\n notify :server_error\n\n # ----- nick-related -----\n when CMD_NICK\n @state[:nick] = msg.params[0] if msg.prefix[:nick] == @state[:nick]\n threaded_notify :nick_changed, msg.prefix[:nick], msg.params[0]\n when ERR_NICKNAMEINUSE\n # nickname errors are deterministic, that is, the client keeps track of the \n # state of attempted nick changes in @state, and the server responds to them\n # in order, so no additional info needs to be sent in the callback.\n # (this is tested)\n notify :nick_in_use\n when ERR_ERRONEUSNICKNAME\n notify :nick_invalid\n\n # ----- channel-related -----\n when CMD_JOIN\n threaded_notify :joined_channel, msg.user, msg.params[0]\n when CMD_PART\n threaded_notify :left_channel, msg.user, msg.params[0], msg.params[1]\n when CMD_QUIT\n threaded_notify :quit_server, msg.user, msg.params[0]\n when RPL_TOPIC # negative indices handle rfc and non-rfc commands\n threaded_notify :topic_changed, msg.params[-2], msg.params[-1], nil\n when CMD_TOPIC\n threaded_notify :topic_changed, msg.params[0], msg.params[1], msg.user\n when RPL_NAMREPLY\n @state[:scratch] ||= {}\n @state[:scratch][msg.params[-2]] ||= []\n # strip out leading mode characters: @, +, ~, etc.\n @state[:scratch][msg.params[-2]] += msg.params[-1].split.map { |name| name.gsub(/^[^a-zA-Z\\[\\]\\\\`_\\^{}\\|]/,'') }\n when RPL_ENDOFNAMES\n if @state[:scratch]\n threaded_notify :channel_name_list, msg.params[-2], ( @state[:scratch][msg.params[-2]] || [] )\n @state[:scratch].delete(msg.params[-2])\n else\n threaded_notify :channel_name_list, []\n end\n \n # ----- messaging -----\n when CMD_PRIVMSG\n if private?(msg)\n threaded_notify :private_message, msg.params[0], msg.params[1], msg.user\n else\n threaded_notify :channel_message, msg.params[0], msg.params[1], msg.user\n end\n when CMD_NOTICE\n if private?(msg)\n threaded_notify :private_notice, msg.params[0], msg.params[1], msg.user\n else\n threaded_notify :channel_notice, msg.params[0], msg.params[1], msg.user\n end\n\n end\n end",
"def send_with_arg_register\n <<-CODE\n next_literal_into(msg.send_site);\n msg.recv = stack_pop();\n msg.block = stack_pop();\n msg.args = c->args;\n\n perform_send:\n\n msg.priv = c->call_flags;\n msg.klass = _real_class(state, msg.recv);\n\n c->call_flags = 0;\n\n cpu_send_message(state, c, &msg);\n CODE\n end",
"def command name\n @commands[name]\n end",
"def process!(cmd)\n inst, args = parse(cmd)\n # return registers[pc] = args[0] if inst.inst == 'call'\n return true if inst.inst == 'jmp' # believe the fetcher has handled jmp.\n sym = \"inst_#{inst.inst}\".to_sym\n send(sym, *args) != :fail\n end",
"def command_factory\n end",
"def handle_subscribe(command) # rubocop:todo Metrics/CyclomaticComplexity\n @ongoing_subscribe = true\n if @user_details[:chat_id].nil?\n @user_details = { chat_id: message.chat.id }\n @proceed = true\n @previous_command = command\n end\n if @user_details[:birthday].nil?\n @proceed = false\n prompt_user '/add_my_birthday', false, false, true\n elsif @sex.empty?\n add_sex\n elsif user_details[:birthdays].nil?\n send_message 'Please add at least one birthday to be reminded of'\n @proceed = false\n prompt_user '/add_birthday', true, false, false\n\n unless message.text.nil?\n @name = message.text\n @proceed = false\n prompt_user '/add_birthday', false, true, true\n end\n\n elsif user_details[:anniversaries].nil?\n send_message 'Please add at least one anniversary to be reminded of'\n\n prompt_user '/add_anniversary', true, false, false\n\n unless message.text.nil?\n @done = true\n @proceed = false\n @name = message.text\n @proceed = false\n prompt_user '/add_anniversary', false, true, true\n end\n\n else\n @proceed = false\n @previous_command = ''\n @name = ''\n @name_set = false\n @sex = ''\n @ongoing_subscribe = false\n subscribe_user\n end\n end",
"def run(command)\n @commands_to_run << command\n end",
"def process\n if command = AVAILABLE_COMMANDS.find { |command_class| command_class.new(@user, @message).should_start? }\n command.new(@user, @message).start\n else\n BotCommand::Undefined.new(@user, @message).start\n end\n end",
"def call(*args)\n if args.first.is_a?(Array) && args.size == 1\n command = args.first\n else\n command = args\n end\n\n @commands << command\n nil\n end",
"def set_command(slot, on_command, off_command)\n @on_commands[slot] = on_command\n @off_commands[slot] = off_command\n end",
"def set_command(slot, on_command, off_command)\n @on_commands[slot] = on_command\n @off_commands[slot] = off_command\n end",
"def send_cmd(command,check_command,check_value,sleep_time,timeout,tries)\n msg=''\n ret=tries\n success=nil\n if(not(ret))\n ret=1\n end\n $queue.synchronize do\n $rx_messages.clear()\n end\n while(ret>0 and (not(success)))\n ret=ret-1\n $serial_port.synchronize do\n $serialport.write(command)\n end\n sleep(sleep_time)\n if(check_command)\n $serial_port.synchronize do\n $serialport.write(check_command)\n end\n msg=''\n now=Time.now().to_f\n while((not(success)) and Time.now().to_f-now<=timeout)\n $queue.synchronize do\n if($rx_messages.length>0)\n msg=$rx_messages.pop()\n if(msg==check_value)\n success=true\n end\n end\n end\n sleep(0.1)\n end\n else\n return(true)\n end\n end\n if(success)\n return(msg)\n else\n return(nil)\n end\nend",
"def has_command!(name, referer = self.class)\n name.split(':').inject(referer){|cur,look|\n cur.const_get(command2module(look))\n }\n rescue NameError => ex\n raise NoSuchCommand, \"No such command #{name}\", ex.backtrace\n end",
"def command *args, &block\n bind :PRESS, *args, &block\n end",
"def dispatch(type, msg, bot)\n $log.debug \"Received a message of type #{type}\"\n\n type = type.to_s\n if(msg and msg.message =~ COMMAND_RX) then\n dispatch_command(msg, type, bot)\n else\n dispatch_hooks(msg, type, bot)\n end\n end",
"def call_without_reply(command)\n @commands.push command\n nil\n end",
"def xsend (name, *args, &block)\n @messages << [name, args, block]\n end",
"def command *args, &block\n if event? :PRESS\n bind_event :PRESS, *args, &block\n else\n bind_event :CHANGED, *args, &block\n end\n end",
"def run(command)\n # install class and instance methods\n class_modules.each{|mod|\n command.extend(mod)\n }\n instance_modules.each{|mod|\n command.instance_eval{ include mod } \n }\n \n # install documentation\n self.doc_extractor ||= lambda{|cmd, opts| \"no documentation available for #{cmd}\" }\n command.doc_extractor = doc_extractor\n\n # install hierarchy\n self.super_command ||= RubyTools::parent_module(command)\n if super_command && super_command.ancestors.include?(Command)\n command.super_command = super_command\n super_command.subcommands << command\n end\n \n # execute callbacks\n Array(@callbacks).each do |blk|\n blk.call(command)\n end if defined?(@callbacks)\n \n command\n end",
"def add_command(process_info)\n m, s = PTY.open\n s.raw! # disable newline conversion.\n\n pid = run_command(process_info, s)\n\n s.close()\n\n worker = Invoker::CommandWorker.new(process_info.label, m, pid, select_color())\n\n add_worker(worker)\n wait_on_pid(process_info.label,pid)\n end",
"def cmd!(command)\n self << command\n end",
"def process!(cmd)\n inst, args = parse(cmd)\n # return registers[pc] = args[0] if inst.inst == 'call'\n return true if inst.inst == 'jmp' # believe the fetcher has handled jmp.\n\n sym = \"inst_#{inst.inst}\".to_sym\n __send__(sym, *args) != :fail\n end",
"def add_command_to_queue(cmd)\n\n if cmd.respond_to?(:has_command?)\n cmd.each do |c|\n enqueue_command(c)\n end\n elsif cmd.respond_to?(:execute) && cmd.respond_to?(:refresh_view) # define some sort of contract\n enqueue_command(cmd)\n end\n end",
"def command(name)\n commands[name]\n end",
"def command(name)\n commands[name]\n end",
"def command(name)\n commands[name]\n end",
"def take_cmd(pool, line, jid = nil)\n command, args = line.split(' ', 2) unless line.nil? \n if command\t\n unless pool[command.to_sym] == nil\n action = lambda { pool[command.to_sym].execute(args, jid) }\n else\n if pool == @cli_cmds\n action = lambda{ cli_fallback(command, args, jid) }\n else\n action = lambda{ xmpp_fallback(command, args, jid) }\n end\n end\n else\n action = proc {}\n end\n action\n end",
"def take_cmd(pool, line, jid = nil)\n command, args = line.split(' ', 2) unless line.nil? \n if command\t\n unless pool[command.to_sym] == nil\n action = lambda { pool[command.to_sym].execute(args, jid) }\n else\n if pool == @cli_cmds\n action = lambda{ cli_fallback(command, args, jid) }\n else\n action = lambda{ xmpp_fallback(command, args, jid) }\n end\n end\n else\n action = proc {}\n end\n action\n end",
"def ask(command, params = {})\n msg_id = Random.new.rand(2**16)\n promise = Concurrent::Promises.resolvable_future\n\n @listeners[msg_id] = promise\n\n @connection.write({ method: command, params: params, id: msg_id }.to_json)\n promise.wait(Capybara.default_max_wait_time)\n\n @listeners.delete(msg_id)\n promise.value!\n end",
"def register(method, regex, options = {})\n options[:method] = method\n options[:regex] = regex\n registered << options\n end",
"def check_command(command)\n @command_array.each do |method| # For every item inside the command_array (from require function)\n if command == method # If we get a match for a command\n if @locked == true and @full_user != @admin\n chan_send(\"Sorry, #{@user_name_first}, I am currently locked (Probably for maintenance)\")\n else\n if check_ban == true # If the user is banned\n chan_send(\"Sorry, #{@user_name_first} I don't listen to idiots.\") # Give an error message, and don't execute the command\n else # If the user is not banned\n command.gsub!(/[:()]/, '') #command.slice!(0..1).chomp # Remove the :! from the command variable \n send(command) # Call command variable as a function\n end\n end\n end\n end\n \n @mod_command_array.each do |method|\n if command == method\n if @locked == true and @full_user != @admin\n chan_send(\"Sorry, #{@user_name_first}, I am currently locked (Probably for maintenance)\")\n else\n if check_ban == true\n chan_send(\"Sorry, #{@user_name_first} I don't listen to idiots.\")\n else\n mod = check_mod\n if @full_user == @admin or mod == true\n command.gsub!(/[:.\\/]/,'') #command.slice!(0..1)\n send(command)\n else\n chan_send(\"Sorry, #{@user_name_first} you are not authorized to use this command.\")\n end\n end\n end\n end\n end\n \n @admin_command_array.each do |method|\n if command == method\n if @locked == true and @full_user != @admin\n chan_send(\"Sorry, #{@user_name_first}, I am currently locked (Probably for maintenance)\")\n else\n if check_ban == true\n chan_send(\"Sorry, #{@user_name_first}, I don't listen to idiots.\")\n else\n if @full_user == @admin\n command.gsub!(/[:.\\/]/,'') #command.slice!(0..1)\n send(command)\n else\n chan_send(\"Sorry, #{@user_name_first} only the administrator is authorized for this command.\")\n end\n end\n end\n end\n end\nend",
"def reexecute_command_module\n \n # get params\n command_id = @params['command_id'] || nil\n (print_error \"Command id is nil\";return) if command_id.nil?\n command = BeEF::Core::Models::Command.first(:id => command_id.to_i) || nil\n (print_error \"Command is nil\";return) if command.nil?\n # validate nonce\n nonce = @params['nonce'] || nil\n (print_error \"nonce is nil\";return) if nonce.nil?\n (print_error \"nonce incorrect\";return) if @session.get_nonce != nonce\n \n command.instructions_sent = false\n command.save\n \n @body = '{success : true}'\n end",
"def initialize command\n @command = command\n end",
"def add_and_start(command)\n name = add(command)\n start(name)\n end",
"def define_command name, opts = nil, &blk\n opts = _take_doc(opts)\n # $stderr.puts \"@target = #{@target.inspect}\"\n # $stderr.puts \"define_command #{name.inspect}, #{opts.inspect}\"\n\n cmd = _command_manager.define_command(name, opts, &blk)\n\n cmd._defined_in = @plugin\n\n @plugin.commands << cmd\n\n cmd\n end"
] |
[
"0.6438206",
"0.6047119",
"0.6015615",
"0.58937085",
"0.5891112",
"0.5639508",
"0.5610444",
"0.55031943",
"0.54022527",
"0.5361733",
"0.53507745",
"0.5316901",
"0.5295533",
"0.5295533",
"0.5277333",
"0.52728903",
"0.52683675",
"0.52515525",
"0.5175824",
"0.516278",
"0.5160571",
"0.5155005",
"0.51513",
"0.51450604",
"0.51437336",
"0.51312",
"0.51211447",
"0.5095718",
"0.50836164",
"0.5065211",
"0.5056352",
"0.50398725",
"0.4996331",
"0.4979994",
"0.49644268",
"0.49641743",
"0.49519238",
"0.49458867",
"0.49369225",
"0.4934161",
"0.49333507",
"0.4926805",
"0.49200627",
"0.49166965",
"0.49038002",
"0.49027938",
"0.48939592",
"0.4886874",
"0.48768932",
"0.48743713",
"0.48678002",
"0.48581228",
"0.48508605",
"0.4850728",
"0.4846757",
"0.4844576",
"0.48419875",
"0.4839813",
"0.48395166",
"0.48334545",
"0.48332658",
"0.48315638",
"0.4823281",
"0.48043725",
"0.4798628",
"0.47985584",
"0.47926766",
"0.4773943",
"0.47693896",
"0.47658908",
"0.47539783",
"0.4753022",
"0.47523892",
"0.47364748",
"0.47333872",
"0.47333872",
"0.473208",
"0.47307223",
"0.47301066",
"0.4729053",
"0.4727461",
"0.47270343",
"0.4725137",
"0.47245368",
"0.47239363",
"0.47228593",
"0.4722575",
"0.47224784",
"0.4720713",
"0.4720713",
"0.4720713",
"0.47190726",
"0.47190726",
"0.4715736",
"0.47104642",
"0.4709462",
"0.4707582",
"0.47072965",
"0.47016534",
"0.4699433"
] |
0.7320989
|
0
|
Register a hook to be run on any message. mod A link to the module object, used in tracking threads name A name for this hook, for unregistering later trigger A procedure to run. If this returns true, it will cause the callback to fire. types The types of message to respond to. p A procedure to run when all the checks work out
|
def register_hook(mod, name, trigger = nil, types = /channel/, &p)
raise "Please define a block" if not block_given?
raise "That command is already hooked." if @hooks[name]
raise "The module given is not a module" if not mod.is_a?(HookService)
trigger ||= lambda{|*| return true} # set trigger if someone has allowed it to be default
raise "Cannot call the trigger expression (type: #{trigger.class})! Ensure it responds to call()" if not trigger.respond_to?(:call)
# Ensure types is an array and is full of regex
types = [types] if not types.is_a?(Array)
types.map!{|x| (x.is_a? Regexp) ? x : Regexp.new(x.to_s)} # convert to rx if not already
@hooks_mutex.synchronize{
# Ensure defaults and register
@hooks[name] ||= {}
@hooks[name] = {:types => types, :trigger => trigger, :proc => p, :module => mod}
# Register a given hook or command for a give module
@modules[mod] ||= {:hooks => [], :cmds => [], :threads => [], :threaded => mod.threaded?}
@modules[mod][:hooks] << name
}
$log.debug "Registered hook '#{name}'"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def dispatch_hooks(msg, type, bot)\n return if @hooks.length == 0\n\n @hooks_mutex.synchronize{\n @hooks.each{|name, hook|\n types, trigger, p, mod, mod_info = hook[:types], hook[:trigger], hook[:proc], hook[:module], @modules[hook[:module]]\n\n # Go through and kill any old threads,\n purge_module_threads(mod)\n\n # If the module is not threaded, we must find the current\n # thread in order to let it finish before starting a new one\n thread_to_await = mod_info[:threads][0] if not mod_info[:threaded]\n\n # Check types match the rx\n types.each{|type_trigger|\n if type_trigger.match(type) then\n\n $log.debug \"Inspecting hook '#{name}' for module #{mod.class} (threaded? #{mod_info[:threaded]}) [#{trigger.call(msg)}]\"\n begin\n # Check the hook trigger works if it's of the right type\n if(trigger.call(msg)) then\n # Then invoke\n raise \"Too many active threads for module: #{mod_info[:name]}.\" if mod_info[:threads].length > MAX_MODULE_THREADS\n $log.debug \"Dispatching hook '#{name}'...\"\n mod_info[:threads] << invoke(prepare_vars(bot, msg, name), p, [], thread_to_await)\n $log.debug \"Running hook #{name}: #{mod_info[:threads].length}/#{MAX_MODULE_THREADS} threads.\"\n end\n rescue Exception => e\n $log.error \"Error in callback '#{name}' => #{e}\"\n $log.debug \"Backtrace: #{e.backtrace.join(\"\\n\")}\"\n end\n end\n } # /types.each\n } # /@hooks.each\n } # /synchronize\n end",
"def register_command(mod, name, trigger, types = /channel/, &p)\n raise \"Please define a block\" if not block_given?\n raise \"That command is already hooked.\" if @cmds[name]\n raise \"The module given is not a module\" if not mod.is_a?(HookService)\n\n # Ensure types is an array and is full of regex\n types = [types] if not types.is_a?(Array)\n types.map!{|x| (x.is_a? Regexp) ? x : Regexp.new(x.to_s)} # convert to rx if not already\n\n @hooks_mutex.synchronize{\n # Ensure default and register \n @cmds[name] ||= {}\n @cmds[name] = {:types => types, :trigger => trigger, :proc => p, :module => mod}\n\n # register hook or command for a given module\n @modules[mod] ||= {:hooks => [], :cmds => [], :threads => [], :threaded => mod.threaded?}\n @modules[mod][:cmds] << name\n }\n\n $log.debug \"Registered command '#{name}'\"\n end",
"def hook(type, priority = 99, &block)\n hooks[type] ||= []\n name = \"HOOK #{type.to_s} #{hooks[type].size}\"\n define_method(name, &block)\n hooks[type] << [priority, name]\n end",
"def hook(type, options = {})\n options = { for: %i[match listen_to ctcp], method: :hook, group: nil }.merge(options)\n hook = Hook.new(type, options[:for], options[:method], options[:group])\n __hooks(type) << hook\n\n hook\n end",
"def hook(type, options = {})\n options = {:for => [:match, :listen_to, :ctcp], :method => :hook}.merge(options)\n __hooks(type) << Hook.new(type, options[:for], options[:method])\n end",
"def hook(type, options = {})\n options = {:for => [:match, :listen_to, :ctcp], :method => :hook}.merge(options)\n __hooks(type) << Hook.new(type, options[:for], options[:method])\n end",
"def define_hook(name, *params)\n hooks << make_hook(name, nil, params)\n\n # We must use string evaluation in order to define a method that can\n # receive a block.\n instance_eval(<<-END)\n def #{name}(handle_or_method=nil, &block)\n add_callback(:#{name}, handle_or_method, &block)\n end\n END\n module_eval(<<-END)\n def #{name}(handle=nil, &block)\n add_external_callback(:#{name}, handle, block)\n end\n END\n end",
"def define_hook(name, *params)\n fetch_or_create_hooks << make_hook(name, nil, params)\n\n # We must use string evaluation in order to define a method that can\n # receive a block.\n instance_eval(<<-END)\n def #{name}(handle_or_method=nil, &block)\n add_callback(:#{name}, handle_or_method, &block)\n end\n END\n module_eval(<<-END)\n def #{name}(handle=nil, &block)\n add_external_callback(:#{name}, handle, block)\n end\n END\n end",
"def add_hook(name, &block)\n hooks[name.to_sym] ||= []\n hooks[name.to_sym] << block\n end",
"def execute_hooks_for(type, name)\n model.hooks[name][type].each { |hook| hook.call(self) }\n end",
"def supported_hook_types; end",
"def on(type, &block)\n callbacks[type.to_sym] ||= []\n callbacks[type.to_sym] << block\n end",
"def input_hook(incoming_type, method_name = nil, &block)\n @input_hook ||= {}\n\n if block_given?\n # set the hook.\n @input_hook[incoming_type] = block\n elsif method_name\n @input_hook[incoming_type] = Proc.new { |dev, type, data| dev.send(method_name, dev, type, data) }\n else\n # get the hook\n @input_hook[incoming_type] ||= Proc.new { |dev, type, data| HIDAPI.debug \"no input hook for #{type} message type with #{data.length} bytes of data\" }\n end\n end",
"def hook_type_name; end",
"def validate_hook_type(type)\n if not possible_hook_types.include?(type)\n error \"The type of the script needs to be one of: #{possible_hook_types.join(', ')}.\"\n end\n end",
"def fregister(message_type, message_subtype = nil, &listener)\n _register(message_type, message_subtype , Funnel.wrap(listener))\n end",
"def callback(type, message)\n synchronize do\n @callbacks[type].call(message) if @callbacks[type]\n end\n end",
"def configure_hooks(hook_type, service)\n unless VALID_HOOKS.include?(hook_type)\n raise ArgumentError, \"unknown twirp hook type received: #{hook_type}\"\n end\n\n existing_hooks = instance_variable_get(\"@#{hook_type}_hooks\")\n return if existing_hooks.nil?\n\n existing_hooks.values.each do |hook|\n service.send(hook_type, &hook)\n end\n end",
"def hook *which, &hook_block\n which.each do |w|\n @hooks[w.to_sym] ||= []\n @hooks[w.to_sym] << hook_block\n end\n end",
"def hook *which, &hook_block\n which.each do |w|\n @hooks[w.to_sym] ||= []\n @hooks[w.to_sym] << hook_block\n end\n end",
"def on_module_load(mod, type, name, modinfo)\n\t\t# Payload modules require custom loading as the individual files\n\t\t# may not directly contain a logical payload that a user would \n\t\t# reference, such as would be the case with a payload stager or \n\t\t# stage. As such, when payload modules are loaded they are handed\n\t\t# off to a special payload set. The payload set, in turn, will\n\t\t# automatically create all the permutations after all the payload\n\t\t# modules have been loaded.\n\t\tif (type != MODULE_PAYLOAD)\n\t\t\t# Add the module class to the list of modules and add it to the\n\t\t\t# type separated set of module classes\n\t\t\tadd_module(mod, name, modinfo)\n\t\tend\n\n\t\tmodule_sets[type].add_module(mod, name, modinfo)\n\tend",
"def hook(&block)\n @hooks << block\n end",
"def on(hook_type, state_or_event_name = nil, async = nil, &callback)\n sync_exclusive do\n if state_or_event_name.nil?\n state_or_event_name = HookEvent.any_state_or_event(hook_type)\n end\n async = false if async.nil?\n ensure_valid_callback_name!(hook_type, state_or_event_name)\n callback.extend(Async) if async == :async\n hooks.register(hook_type, state_or_event_name, callback)\n end\n end",
"def for_hook(hook, hook_type = T.unsafe(nil)); end",
"def hook(name, &blk)\n @hooks[name.to_sym] ||= []\n @hooks[name.to_sym] << blk\n self\n end",
"def hook1; end",
"def install_hook(side, event, callback)\n self.hooks[:\"#{ side }_#{ event }\"].push(callback)\n end",
"def pre_hook_send(handler); end",
"def notifications_modules_hook!\n yield\n end",
"def add_hook(payload_class, hook_arg = nil, &hook_block)\n hook = block_given? ? hook_block : hook_arg\n if !hook || !hook.is_a?(Proc)\n raise \"Must pass a proc either as an argument or a block\"\n end\n @message_hooks[payload_class] << hook\n end",
"def run_hook(name, *args, &block)\n if callbacks = hooks[name.to_sym]\n callbacks.each{ |c| c.call(*args, &block) }\n else\n yield if block\n end\n end",
"def on(event_type = ANY_EVENT, name = ANY_STATE, &callback)\n sync_exclusive do\n ensure_valid_callback_name!(name)\n hooks.register event_type, name, callback\n end\n end",
"def on(name,&callback)\n bot.on(name){|*args| callback.call(*args) if enabled}\n end",
"def hook(name, *args)\n name = ('hook_' + name.to_s).to_sym\n send name, *args if respond_to? name\n end",
"def run_em_hooks type\n @example_group_instance.class.em_hooks[type].each do |hook|\n if @example_group_instance.respond_to? :instance_eval_without_event_loop\n @example_group_instance.instance_eval_without_event_loop(&hook)\n else\n @example_group_instance.instance_eval(&hook) #_with_rescue(&hook)\n end\n end\n end",
"def dispatch(type, msg, bot)\n $log.debug \"Received a message of type #{type}\"\n\n type = type.to_s\n if(msg and msg.message =~ COMMAND_RX) then\n dispatch_command(msg, type, bot)\n else\n dispatch_hooks(msg, type, bot)\n end\n end",
"def trigger_callbacks_for(msg)\n case msg.message_type\n\n # ----- server messages\n when RPL_WELCOME\n notify :registered_with_server\n when CMD_PING\n notify :server_ping, msg.params[0] # server wants the params back\n when CMD_ERROR\n notify :server_error\n\n # ----- nick-related -----\n when CMD_NICK\n @state[:nick] = msg.params[0] if msg.prefix[:nick] == @state[:nick]\n threaded_notify :nick_changed, msg.prefix[:nick], msg.params[0]\n when ERR_NICKNAMEINUSE\n # nickname errors are deterministic, that is, the client keeps track of the \n # state of attempted nick changes in @state, and the server responds to them\n # in order, so no additional info needs to be sent in the callback.\n # (this is tested)\n notify :nick_in_use\n when ERR_ERRONEUSNICKNAME\n notify :nick_invalid\n\n # ----- channel-related -----\n when CMD_JOIN\n threaded_notify :joined_channel, msg.user, msg.params[0]\n when CMD_PART\n threaded_notify :left_channel, msg.user, msg.params[0], msg.params[1]\n when CMD_QUIT\n threaded_notify :quit_server, msg.user, msg.params[0]\n when RPL_TOPIC # negative indices handle rfc and non-rfc commands\n threaded_notify :topic_changed, msg.params[-2], msg.params[-1], nil\n when CMD_TOPIC\n threaded_notify :topic_changed, msg.params[0], msg.params[1], msg.user\n when RPL_NAMREPLY\n @state[:scratch] ||= {}\n @state[:scratch][msg.params[-2]] ||= []\n # strip out leading mode characters: @, +, ~, etc.\n @state[:scratch][msg.params[-2]] += msg.params[-1].split.map { |name| name.gsub(/^[^a-zA-Z\\[\\]\\\\`_\\^{}\\|]/,'') }\n when RPL_ENDOFNAMES\n if @state[:scratch]\n threaded_notify :channel_name_list, msg.params[-2], ( @state[:scratch][msg.params[-2]] || [] )\n @state[:scratch].delete(msg.params[-2])\n else\n threaded_notify :channel_name_list, []\n end\n \n # ----- messaging -----\n when CMD_PRIVMSG\n if private?(msg)\n threaded_notify :private_message, msg.params[0], msg.params[1], msg.user\n else\n threaded_notify :channel_message, msg.params[0], msg.params[1], msg.user\n end\n when CMD_NOTICE\n if private?(msg)\n threaded_notify :private_notice, msg.params[0], msg.params[1], msg.user\n else\n threaded_notify :channel_notice, msg.params[0], msg.params[1], msg.user\n end\n\n end\n end",
"def register_hook(name, hook)\n hooks[name.to_s.downcase.strip.to_sym] << hook\n end",
"def define_hook(hooks, method, options)\n hook_name = options[:name] || method\n if hook_name.is_a?(Proc)\n raise ArgumentError, \"name option required when using proc for method\"\n end\n\n hooks[hook_name] = lambda do |*args|\n env = args.find { |arg| arg.is_a?(Hash) && arg.key?(:input) }\n return if CallbackHelpers.skip?(env, options)\n instance_exec(&CallbackHelpers.make_execute_lambda(method, env[:handler], *args))\n end\n end",
"def add_handler(type, callable=nil, &b)\n callable = callable(callable, b)\n regex = regex_for(type)\n sync do\n id = @handler_serial+=1\n handlers << [id, regex, callable]\n id\n end\n end",
"def add_hook_context( context )\n\n case context\n when :before_include, :before_extend, :after_include, :after_extend\n case @cluster.instance\n when ::Class\n unless @cluster.instance <= ::Module\n raise ::RuntimeError, 'Include/Extend execution hooks cannot be created for classes.'\n end\n end\n when :subclass\n case @cluster.instance\n when ::Class\n when ::Module\n raise ::RuntimeError, 'Subclass execution hooks cannot be created for modules.'\n end\n end\n \n @hook_contexts[ context ] = true\n \n return self\n \n end",
"def register(plugin_name, hook_name, &block)\n @registrations ||= {}\n @registrations[hook_name] ||= []\n @registrations[hook_name] << Hook.new(hook_name, plugin_name, block)\n end",
"def register(interface, mod, status, &block)\n\t\tmod_sym = mod.class == String ? mod.to_sym : mod\t# remember the symbol used by the interface to reference this module\n\t\tstatus = status.to_sym if status.class == String\n\t\t\n\t\tif @system.modules[mod_sym].present?\n\t\t\tmod = @system.modules[mod_sym].instance\t# most efficient\n\t\n\t\t\ttheVal = nil\n\t\t\t@status_lock.synchronize {\n\t\t\t\t@status_register[mod] ||= {}\n\t\t\t\t@status_register[mod][status] ||= {}\n\t\t\t\t@status_register[mod][status][interface] = mod_sym\n\t\t\t\t@connected_interfaces[interface] << @status_register[mod][status] unless @connected_interfaces[interface].nil?\n\t\t\t\ttheVal = mod[status]\n\t\t\t}\n\t\t\t\n\t\t\tmod.add_observer(self)\n\t\t\tlogger.debug \"-- Interface #{interface.class} registered #{mod_sym}:#{status}\"\n\t\t\t\n\t\t\t#\n\t\t\t# Send the status to this requestor!\n\t\t\t#\tThis is the same as in update\n\t\t\t#\n\t\t\tif !theVal.nil?\n\t\t\t\tbegin\n\t\t\t\t\tfunction = \"#{mod_sym.to_s.downcase}_#{status}_changed\".to_sym\n\t\t\t\t\t\n\t\t\t\t\tif interface.respond_to?(function)\n\t\t\t\t\t\tinterface.__send__(function, theVal)\n\t\t\t\t\telse\n\t\t\t\t\t\tinterface.notify(mod_sym, status, theVal)\n\t\t\t\t\tend\n\t\t\t\trescue => e\n\t\t\t\t\tControl.print_error(logger, e, {\n\t\t\t\t\t\t:message => \"in communicator.rb, register : bad interface or user module code\",\n\t\t\t\t\t\t:level => Logger::ERROR\n\t\t\t\t\t})\n\t\t\t\tend\n\t\t\tend\n\t\telse\n\t\t\tlogger.warn \"in communicator.rb, register : #{interface.class} called register on a bad module name\"\n\t\t\tblock.call() unless block.nil?\t# Block will inform of any errors\n\t\tend\n\trescue => e\n\t\tbegin\n\t\t\tControl.print_error(logger, e, {\n\t\t\t\t:message => \"in communicator.rb, register : #{interface.class} failed to register #{mod.inspect}.#{status.inspect}\",\n\t\t\t\t:level => Logger::ERROR\n\t\t\t})\n\t\t\tblock.call() unless block.nil?\t# Block will inform of any errors\n\t\trescue => x\n\t\t\tControl.print_error(logger, x, {\n\t\t\t\t:message => \"in communicator.rb, register : #{interface.class} provided a bad block\",\n\t\t\t\t:level => Logger::WARN\n\t\t\t})\n\t\tend\n\tensure\n\t\tActiveRecord::Base.clear_active_connections!\n\tend",
"def add_callback(type, options, &block); end",
"def hook_object!(object, hooked_methods, hooks)\n hooked_methods = [hooked_methods] if hooked_methods.is_a? Symbol\n\n validate_hooks(hooks) # Validate hooks\n\n hooked_methods.each do |hooked_method| # Validate methods defined\n validate_has_method_defined(object.metaclass, hooked_method)\n end\n\n hooked_methods.each do |hooked_method|\n SINGLETON_METHOD_HOOKS[object] ||= {}\n hooked_method_name = \"#{SINGLETON_HOOK_METHOD_PREFIX}#{hooked_method}\"\n\n if SINGLETON_METHOD_HOOKS[object].has_key?(hooked_method)\n raise AlreadyDefinedHookException.new(\"Hook signature present for #{hooked_method} in #{object.metaclass}\")\n end\n if object.metaclass.method_defined?(hooked_method_name)\n raise AlreadyDefinedHookException.new(\"Method #{hooked_method_name} hook already defined for #{hooked_method} in #{where_to_eval}\")\n end\n\n SINGLETON_METHOD_HOOKS[object][hooked_method] = {}\n\n hooks.each do |where, callback|\n SINGLETON_METHOD_HOOKS[object][hooked_method][where] = callback\n end\n\n hook_key = 'self'\n before_hook_call = <<-BEFORE_HOOK_CALL\n\n before_hook_callback = ((Peeping::Peep.hooked_singleton_methods_for(#{hook_key})||{})[:\"#{hooked_method}\"] || {})[:before]\n instance_before_hook_callback = ((Peeping::Peep.hooked_instance_methods_for(self.class) || {})[:\"#{hooked_method}\"] || {})[:before]\n\n before_hook_callback ||= instance_before_hook_callback \n before_hook_callback.call(self, *args) if before_hook_callback\n BEFORE_HOOK_CALL\n\n after_hook_call = <<-AFTER_HOOK_CALL\n after_hook_callback = ((Peeping::Peep.hooked_singleton_methods_for(#{hook_key})||{})[:\"#{hooked_method}\"] || {})[:after]\n instance_after_hook_callback = ((Peeping::Peep.hooked_instance_methods_for(self.class) || {})[:\"#{hooked_method}\"] || {})[:after]\n\n after_hook_callback ||= instance_after_hook_callback \n after_hook_callback.call(self, proxied_result) if after_hook_callback\n AFTER_HOOK_CALL\n\n should_override_instance_call = true # TODO: Optionalize\n class_eval_call = Proc.new do\n eval <<-REDEF\n if #{should_override_instance_call} and method_defined?(:\"#{INSTANCE_HOOK_METHOD_PREFIX}#{hooked_method}\")\n alias :\"#{hooked_method_name}\" :\"#{INSTANCE_HOOK_METHOD_PREFIX}#{hooked_method}\"\n else\n alias :\"#{hooked_method_name}\" :\"#{hooked_method}\"\n end\n def #{hooked_method}(*args, &block)\n #{before_hook_call}\n proxied_result = if block_given?\n __send__(\"#{hooked_method_name}\", *args, &block)\n else\n __send__(\"#{hooked_method_name}\", *args)\n end\n #{after_hook_call}\n proxied_result\n end\n REDEF\n end\n object.metaclass.class_eval(&class_eval_call)\n end\n end",
"def add_custom_handlers\n # Set up hooks\n @irc.on_msg self.method(:_in_msg)\n @irc.on_act self.method(:_in_act)\n @irc.on_invite self.method(:_in_invited)\n @irc.on_kick self.method(:_in_kick)\n @irc.saying_join self.method(:_out_join)\n end",
"def fire(hook, *args); end",
"def on(what, *, &block)\n if STATES.include?(what) || %w[success failure].include?(what) || Integer === what\n @callbacks[what] << block\n else\n super\n end\n end",
"def register_fulfillment_processor mod\n uniq_code = mod.name\n return unless verify_uniq_fulfillment_processor(uniq_code)\n return unless verify_fulfillment_module(mod)\n install_fulfillment_processor(uniq_code, mod)\n end",
"def make_hooks(*args)\r\n make :hook, *args\r\n end",
"def register_hook(hook_name, block)\n hooks_for(hook_name).each do |blk|\n # Simple but effective proc compartion\n return nil if blk.source_location == block.source_location\n end\n hooks_for(hook_name) << block\n end",
"def on(update_type, &_)\n handler = ->(update) do\n return unless update['@type'] == update_type\n yield update\n end\n @update_manager.add_handler(handler)\n end",
"def register_module(mod)\n $log.debug \"Registering module: #{mod.class}...\"\n mod.hook_thyself\n end",
"def add_postplay_hook(name, &f) \n @postplay_hooks_ordered_names << name\n @postplay_hooks[name] = f \n self\n end",
"def add_module_irc_behavior(type)\n define_add_behaviour type\n define_del_behaviour type\n end",
"def supported_hook_type_classes; end",
"def run_hook(name, *args)\n # return unless hooks = Resque.send(name)\n return unless hook = APN::QueueManager.send(name)\n msg = \"Running #{name} hook\"\n msg << \" with #{args.inspect}\" if args.any?\n log msg\n\n # Newer resque versions allow for multiple hooks rather than just one.\n # APN sender may still just return a single hook so massage the value\n # to always be inside an Array.\n hooks = hook.is_a?(Array) ? hook : Array[hook]\n hooks.each do |hook|\n args.any? ? hook.call(*args) : hook.call\n end\n end",
"def hook_name; end",
"def hook(&block)\n @hook = block if block_given?\n @hook\nend",
"def register(name, &block)\n\n # Create the message decoder and register it to the handler.\n decoder = ProcMessageDecoder.new block\n @handler.register_decoder name, decoder\n end",
"def enable(hook, *more_hooks)\n ([hook] + more_hooks).each { |h| @callbacks[h] ||= nil }\n end",
"def hook_thyself\n me = self\n\n\n\n # Add something to tell someone\n register_command(:tweet_cmd, /^tweet$/, [/channel/, /private/]){|*args| \n me.tweet(bot, nick, args.join(\" \"))\n }\n\n\n \n # Hook for when we have successfully joined\n @config[:channels].each do |chan|\n register_hook(\"twitter_join_#{chan}\".to_sym, lambda{|m| m.channel == chan}, /join/){\n me.join_channel( chan, bot ) if nick == bot_nick # Ensure we only fire if the bot has joined, not other people\n }\n end\n\n end",
"def on name, &block\n (callbacks[name] ||= []) << block\n end",
"def before(name,&callback)\n bot.before(name){|*args| callback.call(*args) if enabled}\n end",
"def before_hook(method_name)\n hooks << method_name\n end",
"def callback_actions_for(method, type)\n if self.callback_actions[method].nil?\n callback_actions = []\n else\n callback_actions = self.callback_actions[method][type] ||= []\n end\n \n#Removed this because this didn't work\n#callback_actions_for is called four times with every callback method:\n# before, before metaclass, after, after metaclass\n# And a class and metaclass both now the #{type}_#{method} method\n# So it got called twice\n# if self.instance_methods.include?(\"#{type}_#{method}\")\n# if not callback_actions.include? \"#{type}_#{method}\".to_sym\n# callback = self.add_callback_action(type, method, \"#{type}_#{method}\".to_sym)\n# callback_actions << callback\n# end\n# end\n\n #TODO: order by options[:priority]\n return callback_actions \n end",
"def add_hook(name, hook_function_name, callable=nil, &block)\n @hooks[name] ||= {}\n\n if block\n @hooks[name][hook_function_name] = block\n elsif callable\n @hooks[name][hook_function_name] = callable\n else\n raise ArgumentError, \"Must provide a block or callable.\"\n end\n\n self\n end",
"def register(count, regex, reply)\n register_hook(\"autoreply_msg#{count}\".to_sym, lambda{|raw| raw.message =~ regex}, /channel/){\n bot.say( reply )\n }\n end",
"def define_hook(id, &block)\n\t\t\t\t\th = Hook.new id, &block\n\t\t\t\t\t@hooks[id] = [] unless @hooks[id]\n\t\t\t\t\t@hooks[id] << h\n\t\t\t\tend",
"def add(*hooks)\n @hooks.push(*hooks)\n\n hooks.map(&:object).uniq.each do |object|\n @original_callbacks[object] = proceed(object) unless proceeded?(object)\n end\n\n self\n end",
"def create_hook(repository, callback_url)\n return unless self.class.enable_hook?\n hook = client.create_hook(repository.full_name, 'web',\n {url: callback_url, content_type: 'json'},\n events: ['push'], active: true)\n yield hook if block_given?\n hook\n rescue Octokit::UnprocessableEntity => e\n if e.message.include? 'Hook already exists'\n true\n else\n raise\n end\n end",
"def run_hook!(name)\n return unless hooks[name.to_sym]\n hooks[name.to_sym].each { |blk| config.instance_exec(&blk) }\n end",
"def attach_hook(hook, method)\n if @hook_register[hook] != nil\n @hook_register[hook].push method\n else\n @hook_register[hook] = [method]\n end\n end",
"def call_hook(hook_name, context, *params)\n context.send(hook_name, *params) if context.respond_to? hook_name\n end",
"def add_hook(event_name, hook_name, callable=nil, &block)\n @hooks[event_name] ||= []\n\n # do not allow duplicates\n raise ArgumentError, \"Hook with name '#{hook_name}' already defined!\" if hook_exists?(event_name, hook_name)\n\n if block\n @hooks[event_name] << [hook_name, block]\n elsif callable\n @hooks[event_name] << [hook_name, callable]\n else\n raise ArgumentError, \"Must provide a block or callable.\"\n end\n\n self\n end",
"def on(event_type = Event, *args, &callback)\n sync_exclusive do\n name, async, _ = args\n name = ANY_EVENT if name.nil?\n async = false if async.nil?\n ensure_valid_callback_name!(name)\n callback.extend(Async) if async == :async\n hooks.register event_type.to_s, name, callback\n end\n end",
"def process_hooks(user, actual_targets)\n exec_hooks(Move, :process_hooks, binding)\n return true\n end",
"def hook_class!(klass, hooked_methods, hooks)\n\n hooked_methods = [hooked_methods] if hooked_methods.is_a? Symbol\n\n validate_hooks(hooks) # Validate hooks\n validate_is_class(klass) # Validate class\n\n hooked_methods.each do |hooked_method| # Validate methods defined\n validate_has_method_defined(klass.metaclass, hooked_method)\n end\n\n hooked_methods.each do |hooked_method|\n CLASS_METHOD_HOOKS[klass] ||= {}\n new_hooked_method_name = \"#{CLASS_HOOK_METHOD_PREFIX}#{hooked_method}\"\n\n if CLASS_METHOD_HOOKS[klass].has_key?(hooked_method)\n raise AlreadyDefinedHookException.new(\"Hook signature present for #{hooked_method} in #{klass.metaclass}\")\n end\n if klass.metaclass.method_defined?(new_hooked_method_name)\n raise AlreadyDefinedHookException.new(\"Method #{new_hooked_method_name} hook already defined for #{hooked_method} in #{klass.metaclass}\")\n end\n\n CLASS_METHOD_HOOKS[klass][hooked_method] = {}\n\n hooks.each do |where, callback|\n CLASS_METHOD_HOOKS[klass][hooked_method][where] = callback\n end\n\n hook_key = klass.name\n before_hook_call = <<-BEFORE_HOOK_CALL\n before_hook_callback = Peeping::Peep.hooked_class_methods_for(#{hook_key})[:\"#{hooked_method}\"][:before]\n before_hook_callback.call(self, *args) if before_hook_callback\n BEFORE_HOOK_CALL\n\n after_hook_call = <<-AFTER_HOOK_CALL\n after_hook_callback = Peeping::Peep.hooked_class_methods_for(#{hook_key})[:\"#{hooked_method}\"][:after]\n after_hook_callback.call(self, proxied_result) if after_hook_callback\n AFTER_HOOK_CALL\n\n class_eval_call = Proc.new do\n eval <<-REDEF\n alias :\"#{new_hooked_method_name}\" :\"#{hooked_method}\"\n def #{hooked_method}(*args, &block)\n #{before_hook_call}\n proxied_result = if block_given?\n __send__(\"#{new_hooked_method_name}\", *args, &block)\n else\n __send__(\"#{new_hooked_method_name}\", *args)\n end\n #{after_hook_call}\n proxied_result\n end\n REDEF\n end\n klass.metaclass.class_eval(&class_eval_call)\n end\n end",
"def hook_result(messages); end",
"def insert_hook(label)\n # aby se to mohlo korektne rozbalit pri resolve\n # je potreba udavat, kolikaty byte si to ma \n # z kotvy brat\n # write_opcode(S_POINTER)\n @temp_bytecode << Hook.new(label,@hooks,3)\n @temp_bytecode << Hook.new(label,@hooks,2)\n @temp_bytecode << Hook.new(label,@hooks,1)\n @temp_bytecode << Hook.new(label,@hooks,0)\n @current_byte += 4 # adresa se vyhodnocuje jako 4B\n end",
"def process_hooks(timing, args={})\n Rails.application.config.sparkle[:builder][:hooks][action_name][timing].each do |callback|\n callback.call(args)\n end\n end",
"def register(handler)\n conf = @config\n bot = self\n isaac = @bot\n\n @bot.register{|type, msg|\n begin\n $log.debug \"Received message: #{type} #{msg}\"\n handler.dispatch(type, msg, bot.clone_state(msg)) # TODO: send a binding?\n rescue Exception => e\n $log.warn e.to_s\n $log.debug e.backtrace.join(\"\\n\")\n end\n }\n end",
"def register(hook, obj = T.unsafe(nil), &blk); end",
"def raise_hook_failure(type=nil)\n msg = case type\n when String\n type\n when Symbol\n \"the #{type} hook failed\"\n else\n \"a hook failed\"\n end\n\n raise HookFailed.new(msg, self)\n end",
"def raise_hook_failure(type=nil)\n msg = case type\n when String\n type\n when Symbol\n \"the #{type} hook failed\"\n else\n \"a hook failed\"\n end\n\n raise HookFailed.new(msg, self)\n end",
"def hook\n if Bot.exists?(params[:id])\n JobDaemon.enqueue(JobDaemons::BotJob.new(params[:id].to_i, 'onHook', [request.method, hook_params]))\n render json: {status: 'ok'}, status: :ok\n else\n render json: {status: 'ng'}, status: :not_found\n end\n end",
"def note_cb(type)\n __debug_line(\"*** SHRINE CALLBACK #{type} *** | #{file_data.inspect}\")\n end",
"def fixture_hook?(text)\n HOOK_HANDLERS.key?(text)\n end",
"def subscribe_response_hook(name = SecureRandom.hex.to_sym, &block)\n EasyPost::Hooks.subscribe(:response, name, block)\n end",
"def notify_by_server_type server_type, module_id, msg\n return if @state != :state_started\n servers = @servers_map[server_type]\n if !servers || servers.empty?\n return false\n end\n broadcast_notify_msg servers, module_id, msg\n return true\n end",
"def register(msg, callback)\n key = msg.kind_of?(Numeric) \\\n ? (\"%03d\" % msg) \\\n : msg.to_s.upcase\n @callbacks.add(key, callback)\n end",
"def expect_message(type); end",
"def emit name, *args\n # Trigger callbacks in scripts before triggering events in the client.\n notify_scripts name, *args\n\n matching_callbacks = callbacks[name]\n return false unless matching_callbacks&.any?\n\n matching_callbacks.each { |callback| callback.call *args }\n end",
"def post(name, &commands)\n @commands_to_run = []\n commands.call\n @to_perform << Hook.new({\n :type => :post,\n :name => name,\n :commands => commands_to_run\n })\n end",
"def _register(mtype, msubtype, listener)\n @listeners[mtype] = {} unless @listeners.has_key? mtype\n @listeners[mtype][msubtype] = [] unless @listeners[mtype].has_key? msubtype\n @listeners[mtype][msubtype].push(listener)\n end",
"def exec_hook(name, *args, &block)\n @hooks[name] ||= {}\n Hash[@hooks[name].each.map { |k, v| [k, v.call(*args, &block)] }]\n end",
"def method_added(name)\n if name.to_s =~ /^on_(.*)/\n event_hooks[$1.intern] = name\n end\n end",
"def run_hook hook, *data\n\t\t\tr = [@delegates, @hero, current_encounter, @weapons, @brags].flatten.compact.map do |obj| \n\t\t\t\tobj.call_hook(hook, self, current_encounter, *data)\n\t\t\tend.flatten.select { |v| v }\n\n\t\t\tr.each { |v| must_decide(v) if v.is_a?(Decision) }\n\n\t\t\tr\n\t\tend",
"def add_hook(event, hook = nil, &block)\r\n hook = block if block #block has precedence\r\n raise ArgumentError, 'no hook was passed' unless hook\r\n hook = hook.to_s unless hook.respond_to?(:call)\r\n hooks[event.to_s].unshift(hook)\r\n hook\r\n end",
"def add_hook(event_name, hook_name, callable = nil, &block)\n event_name = event_name.to_s\n\n # do not allow duplicates, but allow multiple `nil` hooks\n # (anonymous hooks)\n raise ArgumentError, \"Hook with name '#{hook_name}' already defined!\" if hook_exists?(event_name, hook_name) && !hook_name.nil?\n\n raise ArgumentError, 'Must provide a block or callable.' if !block && !callable\n\n # ensure we only have one anonymous hook\n @hooks[event_name].delete_if { |h, _k| h.nil? } if hook_name.nil?\n\n if block\n @hooks[event_name] << [hook_name, block]\n elsif callable\n @hooks[event_name] << [hook_name, callable]\n end\n\n self\n end"
] |
[
"0.6690939",
"0.6446525",
"0.60287565",
"0.6013262",
"0.59964734",
"0.59964734",
"0.5715657",
"0.56536424",
"0.56026316",
"0.5518584",
"0.54847103",
"0.54602575",
"0.54424983",
"0.5437172",
"0.5415499",
"0.53846705",
"0.53805155",
"0.5349809",
"0.533685",
"0.533685",
"0.5311995",
"0.53051925",
"0.5302702",
"0.5286423",
"0.52484304",
"0.52148384",
"0.5209396",
"0.5194407",
"0.513592",
"0.5112454",
"0.51089066",
"0.50758356",
"0.503904",
"0.5022254",
"0.50055075",
"0.5005174",
"0.5001393",
"0.49779648",
"0.49477762",
"0.49453464",
"0.49403277",
"0.4936076",
"0.49314648",
"0.4912466",
"0.4905218",
"0.49033168",
"0.49005923",
"0.4891507",
"0.4890824",
"0.4869616",
"0.48476785",
"0.48406613",
"0.48345068",
"0.48217088",
"0.48205617",
"0.48191148",
"0.48167837",
"0.48154432",
"0.48019296",
"0.47879016",
"0.47813255",
"0.47699967",
"0.474646",
"0.47331864",
"0.47321728",
"0.47276562",
"0.4721",
"0.4720398",
"0.47010994",
"0.46913257",
"0.46899796",
"0.46818072",
"0.46616358",
"0.46569294",
"0.46561915",
"0.46480784",
"0.46455505",
"0.46410713",
"0.46304876",
"0.4628758",
"0.4612782",
"0.46125415",
"0.46046993",
"0.45962286",
"0.45962286",
"0.4595041",
"0.45937157",
"0.4589836",
"0.4586624",
"0.45852834",
"0.4580227",
"0.45794517",
"0.45750725",
"0.45744243",
"0.45680118",
"0.4566584",
"0.4559539",
"0.45568213",
"0.45567986",
"0.45551145"
] |
0.7221015
|
0
|
Remove a selection of hooks by name If the first argument is a number, it will be used as the timeout when waiting for any threads to end. If no timeout is given, it will wait indefinitely for threads to end.
|
def unregister_hooks(*names)
# Load a timeout if one is given
names.delete(nil)
timeout = nil
if names and names[0].is_a?(Numeric) then
timeout = names[0].to_f
names = names[1..-1]
end
# Then unhook things
@hooks_mutex.synchronize{
names.each{|name|
$log.debug "Unregistering hook: #{name}..."
hook = @hooks.delete(name)
mod = hook[:module]
@modules[mod][:hooks].delete(name)
cleanup_module(mod, timeout)
}
}
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def remove(name)\n if hook = by_name(name)\n hook.destroy!\n end\n end",
"def unregister_commands(*names)\n # Load a timeout if one is given\n names.delete(nil)\n timeout = nil\n if names and names[0].is_a?(Numeric) then\n timeout = names[0].to_f\n names = names[1..-1]\n end\n\n # And then unhook things\n @hooks_mutex.synchronize{\n names.each{|name|\n $log.debug \"Unregistering command: #{name}...\"\n cmd = @cmds.delete(name)\n \n mod = cmd[:module]\n @modules[mod][:cmds].delete(name) \n cleanup_module(mod, timeout)\n }\n }\n end",
"def remove_hook_at(method_name, hook_index)\n hooks[method_name].delete_at(hook_index)\n end",
"def unset_timer(id, name=nil)\n @timer_list_mutex.synchronize do\n if name.nil?\n timer_list.delete_if {|ti| ti.id == id }\n else\n timer_list.delete_if {|ti| ti.id == id && ti.name == name }\n end\n end\n end",
"def delete_hook(name, hook_function_name)\n @hooks[name] ||= {}\n @hooks[name].delete(hook_function_name)\n end",
"def remove_hook(method_name, hook)\n hooks[method_name].delete(hook)\n end",
"def clear_hooks(event = nil)\r\n if event\r\n hooks.delete(event.to_s) if hooks.has_key?(event.to_s)\r\n return\r\n end\r\n\r\n hooks.clear\r\n nil\r\n end",
"def off(hook_type, name = ANY_STATE, &callback)\n sync_exclusive do\n hooks.unregister hook_type, name, callback\n end\n end",
"def delete_hook(event_name, hook_name)\n @hooks[event_name] ||= []\n deleted_callable = nil\n\n @hooks[event_name].delete_if do |current_hook_name, callable|\n if current_hook_name == hook_name\n deleted_callable = callable\n true\n else\n false\n end\n end\n deleted_callable\n end",
"def delete_hooks(event_name)\n @hooks[event_name] = []\n end",
"def clear(name)\n @hooks[name] = {}\n end",
"def no_wait_poll\n remove if can_remove_no_wait?\n end",
"def unregister_modules(timeout=nil, *mods)\n mods.each{|mod|\n raise \"no modules registed.\" if not @modules[mod]\n\n $log.debug \"Unregistering module: #{mod.class}...\"\n \n unregister_hooks(timeout, *@modules[mod][:hooks]) #if @modules[mod] \n # At this point @modules[mod] may have been caught in the cleanup system\n unregister_commands(timeout, *@modules[mod][:cmds]) if @modules[mod] \n }\n end",
"def no_wait_poll\n remove if can_remove_no_wait?\n end",
"def no_wait_poll\n remove if can_remove_no_wait?\n end",
"def remove(*a)\n # event is namespaced to not accidently trigger closing the dialog box\n select(*a).trigger('clockwork.remove')\n select(*a).remove()\n end",
"def remove_hook(event, hook)\r\n return unless hooks.has_key?(event.to_s)\r\n hook = hook.to_s unless hook.respond_to?(:call)\r\n hooks[event.to_s].delete(hook)\r\n end",
"def remove name, type = nil, &block\n debug \"Runner#remove name:#{name}, type:#{type}\" \n \n batch \"#{name}.#{type}\", \"kill\", true\n batch \"#{name}.#{type}\", \"rm\", true \n unregister_all(/#{name}\\.#{type}\\./)\n end",
"def delete_polling_thread(key)\n Thread.kill(@pool[key]) if threads_key?(key)\n @pool.delete(key)\n end",
"def remove_hooks(repo, hook_id)\n api.remove_hook(repo, hook_id)\n end",
"def shutdown(timeout = T.unsafe(nil)); end",
"def clear_event_hooks(event_name)\n @hooks[event_name.to_s] = []\n end",
"def delete_polling_thread(key); end",
"def unregister_all(timeout = nil)\n $log.debug \"Unregistering all modules...\"\n # clone to avoid editing whilst iterating\n unregister_modules(timeout, *@modules.keys.clone) \n end",
"def remove_timer_state(entry)\n timer = entry[1]\n @timers.delete entry\n @timers_time.delete timer\n\n state = remove_state(timer, State::STATE_TIMER)\n deregister_state timer if state == 0\n nil\n end",
"def remove_hook!\n client.remove_hook(full_name, github_hook_id)\n\n self.github_hook_id = nil\n end",
"def shutdown_after(timeout); end",
"def cancel(timer)\n @timers.delete timer\n end",
"def process_remove_wait(waititem)\n @process_builder_waits.to_a.each do |builder, waits|\n if waits.include?(waititem)\n waits.delete(waititem)\n end\n if waits.empty?\n @process_builder_waits.delete(builder)\n @process_builders_to_run << builder\n end\n end\n end",
"def shutdown(timeout=10)\n @pool.close(timeout)\n end",
"def clear_hooks\n @hook_objects = []\n end",
"def clear_timeout(timeout)\n `clearTimeout(timeout)` if timeout\n end",
"def stop! timeout = nil\n stop\n wait! timeout\n end",
"def wait_until_without_failing(timeout=UI_UPDATE_DELAY)\n start = Time.now\n while ((Time.now - start) <= timeout)\n break if yield\n sleep(WaitHelpers::LOOP_DELAY)\n end\nend",
"def stop_timer(timer_name)\n @_timers.reject! { |name, start_time, end_time, block| timer_name == name }\n @_repeating_timers.reject! { |name, start_time, end_time, block| timer_name == name }\n end",
"def remove_callback(callback_name)\n callbacks.delete(callback_name)\n callbacks_queue.delete(callback_name)\n end",
"def untilTimeout()\n return Timer.timeRemaining(@name)\n end",
"def timeout_manager(action_name, token)\n if @token_pool.has_key?(token)\n action = action_name.to_sym\n @token_pool.delete(token)\n @token_callback.delete(token)\n @logger.warn(\"The #{action_name} request with the token #{token} has timed out!\\n\") if logger?\n @task_count_mutex.synchronize {\n @topic_subscribed_task_count[action] -= 1\n unless @topic_subscribed_task_count[action] <= 0\n @topic_subscribed_task_count[action] = 0\n unless @persistent_subscribe\n @topic_manager.shadow_topic_unsubscribe(action)\n @is_subscribed[action.to_sym] = false\n end\n end\n }\n end\n end",
"def delete_hook(id)\n delete(\"/hooks/#{id}\")\n end",
"def remove_timeout! i_ids\n Logging.log \"Remove timeout for #{i_ids.join(', ')}\".colorize(:yellow)\n i_ids.each { |i_id| @instances[i_id].delete 'timeout' }\n File.write @source, @instances.to_json\n end",
"def remove_delayed_selection(klass = nil)\n raise ArgumentError, 'Please supply a block' unless block_given?\n\n found_jobs = find_delayed_selection(klass) { |args| yield(args) }\n found_jobs.reduce(0) do |sum, encoded_job|\n sum + remove_delayed_job(encoded_job)\n end\n end",
"def remove_response_waiter(waiter)\n\t\tself.waiters.delete(waiter)\n\tend",
"def close_hooks(active_hook)\n\t\t[\"signs\",\"symptoms\",\"treatment\",\"workup\"].reject{|c| c == active_hook}.each do |hook|\n\t\t\tself.send(\"#{hook}_started=\",false)\n\t\tend\n\tend",
"def removeKitten(name, type)\n @kittencfg_semaphore.synchronize {\n _shortclass, _cfg_name, cfg_plural, _classname = MU::Cloud.getResourceNames(type)\n deletia = nil\n if @kittens[cfg_plural]\n @kittens[cfg_plural].each { |kitten|\n if kitten['name'] == name\n deletia = kitten\n break\n end\n }\n @kittens[type].delete(deletia) if !deletia.nil?\n end\n }\n end",
"def cancel_timers\n @timers.each{ |t| t.cancel }\n end",
"def kill_gracefully(waiter, timeout: 1.0)\n Process.kill(\"TERM\", waiter.pid)\n return waiter unless waiter.join(timeout).nil?\n\n Process.kill(\"KILL\", waiter.pid)\n waiter.join\nend",
"def undefine_throttle(method_name)\n rocket_job_throttles.delete_if { |throttle| throttle.method_name == method_name }\n end",
"def delete_webhooks_by_name room_name, hook_name\n # We can't delete webhooks by name; we have to use IDs. First we look up\n # the IDs, then we use them to delete the hooks.\n webhooks_response = self.get_webhooks room_name\n webhooks = webhooks_response.parsed_response['items']\n webhooks_to_delete = webhooks.find_all { |wh| wh['name'] == hook_name }\n webhooks_to_delete.each do |webhook|\n self.delete_webhook_by_id room_name, webhook['id']\n end\n end",
"def worker_shutdown_timeout(timeout); end",
"def remove_by_name(name)\n fw = get_by_name(name)\n if (fw != nil)\n return remove(fw)\n end \n end",
"def off(event_type = ANY_EVENT, name = ANY_STATE, &callback)\n sync_exclusive do\n hooks.unregister event_type, name, callback\n end\n end",
"def off(event_type = ANY_EVENT, name = ANY_STATE, &callback)\n sync_exclusive do\n hooks.unregister event_type, name, callback\n end\n end",
"def clear_threads thread_pool, clean_array = true\n thread_pool.each{ |thread| thread.exit }\n thread_pool.clear if clean_array\nend",
"def stop_dispatch_thread!(timeout=2)\n logger.debug { \"#{self.class}##{__method__}\" }\n\n if @dispatcher\n if @dispatcher.join(0)\n @dispatcher = nil\n return\n end\n\n @mutex.synchronize do\n event_queue.graceful_close!\n\n # we now release the mutex so that dispatch_next_callback can grab it\n # to do what it needs to do while delivering events\n #\n @dispatch_shutdown_cond.wait\n\n # wait for another timeout sec for the thread to join\n until @dispatcher.join(timeout)\n logger.error { \"Dispatch thread did not join cleanly, waiting\" }\n end\n @dispatcher = nil\n end\n end\n end",
"def unsubscribe_request_hook(name)\n EasyPost::Hooks.unsubscribe(:request, name)\n end",
"def remove(name)\n gladiators.reject! { |g| g.name == name }\n end",
"def cleanup()\n @threads.each do |name, thread| \n @threads.delete name if thread.state == :dead\n end\n end",
"def off(uid, target_class)\n target_repository = @repository[@type][target_class]\n result = uid\n\n target_repository.global_hooks_data.each do |on|\n global_hooks = target_repository.global_hooks_data[on]\n index = global_hooks.find_index { |hook| hook.uid == uid }\n\n if index\n global_hooks.delete_if { |hook| hook.uid == uid }\n else\n result = nil\n end\n end\n\n result\n end",
"def stop(timeout=nil)\n timeout ||= @timeout +1\n @shutting_down = true\n @thread.join timeout\n @running = false\n end",
"def remove_by_name(name)\n p = get_by_name(name)\n if (p != nil)\n return remove(p)\n end \n end",
"def unregister(name)\n resource = resources.delete(name)\n if resource\n resource.bulkhead&.unregister_worker\n consumers_for_resource = consumers.delete(name) || []\n consumers_for_resource.each do |consumer|\n if consumer.weakref_alive?\n consumer.clear_semian_resource\n end\n rescue WeakRef::RefError\n next\n end\n end\n end",
"def remove_invocation(*names)\n names.each do |name|\n remove_command(name)\n remove_class_option(name)\n invocations.delete(name)\n invocation_blocks.delete(name)\n end\n end",
"def remove()\n CCProcess.start(\"sdk-manage --target --remove '#{@name}'\", (_ :removing_target) + \" #{@name}\", 60*15)\n @@targets.delete(@name)\n end",
"def timeout_after(time); end",
"def remove_plugin_hooks(id)\n Hooks::Menu.remove_plugin_hooks(id)\n Hooks::View.remove_plugin_hooks(id)\n end",
"def stop_polling!\n @pool.each { |_, t| Thread.kill(t) }\n @pool = {}\n end",
"def forget(window, *windows)\n execute_only(:forget, window, *windows)\n end",
"def select_without_hooks!( & block )\n \n @without_hooks = true\n\n select!( & block )\n \n @without_hooks = false\n \n return self\n \n end",
"def remove_listener(name)\n @listeners.delete name\n end",
"def unhook(method_name)\n hooks[method_name].clear\n old_method_name = \"__#{method_name}__hooked__\"\n if private_instance_methods.include?(old_method_name)\n # Remove the block that iterates over the hooks\n remove_method method_name\n # Redirect the alias so the method points to the original method\n alias_method method_name, old_method_name\n end\n end",
"def cancel(timer)\n @timers.delete(timer)\n end",
"def rm(key)\n options.values.collect do |option| \n if option.key == key \n unregister(option)\n else\n nil\n end\n end.compact\n end",
"def remove(*names)\n extract_and_apply_options!(names)\n delete_if { |name| names.include?(name) }\n self\n end",
"def end_hook(hook, status, output); end",
"def shutdown(timeout: nil)\n lock do\n @keep_running = false\n @condition.signal\n end\n\n @thread.join\n force_flush\n @exporter.shutdown\n end",
"def stop\n self.polling_timers.each do |polling_timer|\n polling_timer.shutdown\n end\n self.polling_timers = []\n end",
"def cant_do(func_name)\n logger.debug \"Unregistering #{func_name}\"\n worker_queue.cant_do(func_name, self)\n @capabilities.delete(func_name)\n end",
"def remove(*names)\r\n extract_and_apply_options!(names)\r\n delete_if { |name| names.include?(name) }\r\n self\r\n end",
"def wait_until_element_disappears(type, name, timeout: 5)\n \t\twait = Selenium::WebDriver::Wait.new(timeout: timeout)\n \t\twait.until { !@selenium_driver.find_element(type, name).visible? }\n\tend",
"def clear_without_hooks\n\n @without_hooks = true\n\n clear\n \n @without_hooks = false\n \n return self\n \n end",
"def unsubscribe_all_request_hooks\n EasyPost::Hooks.unsubscribe_all(:request)\n end",
"def kill\n @queue_mutex.synchronize do\n if @wait_thread\n @wait_thread.kill\n @wait_thread = nil\n end\n self.delete_if { |item| true }\n end\n end",
"def delete_if_without_hooks( & block )\n\n @without_hooks = true\n\n delete_if( & block )\n \n @without_hooks = false\n\n return self\n\n end",
"def delayed_exit delay=300\n log \"Exiting in #{delay} seconds\"\n sleep delay\n quit_all\nend",
"def undefine_batch_throttle(method_name)\n rocket_job_batch_throttles.delete_if { |throttle| throttle.method_name == method_name }\n end",
"def off(callback_name)\n raise(ArgumentError, \"Argument 'callback_name' must be a String.\") unless callback_name.is_a?(String)\n @procs_callback.delete(callback_name)\n return self\nend",
"def spc_stop_bouncing_animation\n @parallel_animations[Battle::Visual::IdlePokemonAnimation]&.remove\n end",
"def deselectplugin(browser)\n browser.checkbox(:id,\"plugins-select-all\").clear\nend",
"def remove!(filename, &callback)\n wait_for(remove(filename, &callback))\n end",
"def shutdown(timeout = 300)\n @running = false\n @thread.join(timeout) if @thread and @thread.alive?\n end",
"def clearTimer(id)\n [@timers__, @firingTimers__].each {|timers| timers.delete id}\n nil\n end",
"def force_shutdown_after(val = T.unsafe(nil)); end",
"def pop_blocking\n tag[:blocking_list].rpop\n end",
"def timeout_stop(timeout)\n model.timeout_stop(timeout)\n end",
"def cancel\n @timers.cancel self\n end",
"def process_hooks(timing, args={})\n Rails.application.config.sparkle[:builder][:hooks][action_name][timing].each do |callback|\n callback.call(args)\n end\n end",
"def forget; opt('forget'); end",
"def cancel\n @active = false\n\t\t\t@timers.remove_sorted self\n end",
"def cleanup_hook; end",
"def delete_notifier(name)\n @notifiers.delete(name) if defined? @notifiers\n end"
] |
[
"0.60684276",
"0.60297287",
"0.5662722",
"0.5517949",
"0.546",
"0.54435277",
"0.53744686",
"0.53689307",
"0.53615576",
"0.53613186",
"0.535067",
"0.5311134",
"0.52910626",
"0.5247928",
"0.5224371",
"0.5220938",
"0.5214941",
"0.5199518",
"0.5158245",
"0.51174766",
"0.5105547",
"0.5066452",
"0.49955142",
"0.4989814",
"0.49147016",
"0.49090993",
"0.49060422",
"0.48616493",
"0.48508042",
"0.4797623",
"0.47877347",
"0.47859257",
"0.4762205",
"0.4752005",
"0.47227395",
"0.4704372",
"0.46912962",
"0.46709967",
"0.46652418",
"0.46612686",
"0.46593755",
"0.4656661",
"0.46543142",
"0.4640493",
"0.46337155",
"0.46255",
"0.46183795",
"0.460709",
"0.45781714",
"0.45655736",
"0.45618126",
"0.45618126",
"0.45612726",
"0.45560056",
"0.4547651",
"0.4527912",
"0.45212692",
"0.45181566",
"0.45157906",
"0.44974434",
"0.44911954",
"0.44830677",
"0.4480332",
"0.44786313",
"0.44587973",
"0.44474524",
"0.44307184",
"0.44289494",
"0.44267055",
"0.4419921",
"0.44171742",
"0.4413851",
"0.4410292",
"0.4409259",
"0.43989006",
"0.4395362",
"0.43821287",
"0.43807593",
"0.43789825",
"0.43758443",
"0.43747866",
"0.43651375",
"0.43599108",
"0.4354805",
"0.4349707",
"0.43220487",
"0.43218642",
"0.43002504",
"0.42994797",
"0.4294411",
"0.42938936",
"0.42938364",
"0.42932725",
"0.4291291",
"0.42893997",
"0.4289324",
"0.42846832",
"0.4284599",
"0.42816725",
"0.42774415"
] |
0.730544
|
0
|
Remove cmd by name If the first argument is a number, it will be used as the timeout when waiting for any threads to end. If no timeout is given, it will wait indefinitely for threads to end.
|
def unregister_commands(*names)
# Load a timeout if one is given
names.delete(nil)
timeout = nil
if names and names[0].is_a?(Numeric) then
timeout = names[0].to_f
names = names[1..-1]
end
# And then unhook things
@hooks_mutex.synchronize{
names.each{|name|
$log.debug "Unregistering command: #{name}..."
cmd = @cmds.delete(name)
mod = cmd[:module]
@modules[mod][:cmds].delete(name)
cleanup_module(mod, timeout)
}
}
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def remove name, type = nil, &block\n debug \"Runner#remove name:#{name}, type:#{type}\" \n \n batch \"#{name}.#{type}\", \"kill\", true\n batch \"#{name}.#{type}\", \"rm\", true \n unregister_all(/#{name}\\.#{type}\\./)\n end",
"def delete(name, _options = {})\n exec(\"delete\", c: name, p: port)\n end",
"def remove_command(name)\n @commands ||= {}\n @commands.delete name\n end",
"def remove_command(command_label, rest_args)\n worker = workers[command_label]\n return false unless worker\n signal_to_use = rest_args ? Array(rest_args).first : 'INT'\n\n Invoker::Logger.puts(\"Removing #{command_label} with signal #{signal_to_use}\".color(:red))\n kill_or_remove_process(worker.pid, signal_to_use, command_label)\n end",
"def delete_polling_thread(key)\n Thread.kill(@pool[key]) if threads_key?(key)\n @pool.delete(key)\n end",
"def remove(name=nil)\n if name.class == String && !block_given?\n @j_del.java_method(:remove, [Java::java.lang.String.java_class]).call(name)\n return self\n end\n raise ArgumentError, \"Invalid arguments when calling remove(name)\"\n end",
"def remove_worker(command_label)\n @worker_mutex.synchronize do\n worker = @workers[command_label]\n if worker\n @open_pipes.delete(worker.pipe_end.fileno)\n @reactor.remove_from_monitoring(worker.pipe_end)\n @workers.delete(command_label)\n end\n end\n end",
"def sub_remove _value=0\n send_cmd(\"sub_remove #{_value}\")\n end",
"def rm(path)\n cmd 'rm', path\nend",
"def delete_by!(params, request_options = {})\n res = delete_by(params, request_options)\n wait_task(res['taskID'], WAIT_TASK_DEFAULT_TIME_BEFORE_RETRY, request_options) if res\n res\n end",
"def remove()\n CCProcess.start(\"sdk-manage --target --remove '#{@name}'\", (_ :removing_target) + \" #{@name}\", 60*15)\n @@targets.delete(@name)\n end",
"def remove_by_name(name)\n p = get_by_name(name)\n if (p != nil)\n return remove(p)\n end \n end",
"def kind_kill pid, wait=1\n begin\n Process.kill 15, pid\n # Wait for process (or all group members) to\n # exit.\n Timeout.timeout wait do\n loop { Process.wait(pid) }\n end\n rescue Errno::ECHILD, Errno::ESRCH\n # Processes is dead or group has no members.\n return \n rescue Timeout::Error, StandardError\n # Process did not shutdown in time (or there\n # was an unexpected error).\n Process.kill(9, pid) rescue nil\n end\n end",
"def remove(*a)\n # event is namespaced to not accidently trigger closing the dialog box\n select(*a).trigger('clockwork.remove')\n select(*a).remove()\n end",
"def kill\n @queue_mutex.synchronize do\n if @wait_thread\n @wait_thread.kill\n @wait_thread = nil\n end\n self.delete_if { |item| true }\n end\n end",
"def delete_polling_thread(key); end",
"def remove_by_name(name)\n fw = get_by_name(name)\n if (fw != nil)\n return remove(fw)\n end \n end",
"def bring_down(typename, cmd)\n execute_with_fail(typename, cmd, 'to remove')\n end",
"def delete(*names)\n names.each { |name| commands.delete name }\n end",
"def remove!(filename, &callback)\n wait_for(remove(filename, &callback))\n end",
"def unset_timer(id, name=nil)\n @timer_list_mutex.synchronize do\n if name.nil?\n timer_list.delete_if {|ti| ti.id == id }\n else\n timer_list.delete_if {|ti| ti.id == id && ti.name == name }\n end\n end\n end",
"def kill_thread\n # TODO: ideally this would be unshift, but Queues don't have that. Come up with an alternative.\n @queue << Directive::SUICIDE_PILL\n end",
"def exec_with_timeout(cmd, timeout)\n begin\n # stdout, stderr pipes\n rout, wout = IO.pipe\n rerr, werr = IO.pipe\n stdout, stderr = nil\n status = false\n\n pid = Process.spawn(*cmd, pgroup: true, :out => wout, :err => werr)\n\n Timeout.timeout(timeout) do\n Process.waitpid(pid)\n # close write ends so we can read from them\n wout.close\n werr.close\n\n stdout = rout.readlines.join\n stderr = rerr.readlines.join\n status = true\n end\n\n rescue Timeout::Error\n # Try to determine why the kill does not tidy the chrome processes\n # Also whether a kill was actually issued!\n puts \"WARN: timeout scanning #{cmd[-1]} #{pid}\"\n $stderr.puts \"WARN: #{Time.now} timeout scanning #{cmd[-1]} #{pid}\"\n stderr = 'Timeout'\n # try using less drastic kill\n Process.kill(-2, pid) # INT\n Process.kill(-15, pid) # TERM\n Process.detach(pid)\n ensure\n wout.close unless wout.closed?\n werr.close unless werr.closed?\n # dispose the read ends of the pipes\n rout.close\n rerr.close\n end\n return stdout, stderr, status\nend",
"def delete(name, options = T.unsafe(nil)); end",
"def kill\n @queue << \"kill\"\n end",
"def remove_worker(command_label, trigger_event = true)\n worker = @workers[command_label]\n if worker\n @open_pipes.delete(worker.pipe_end.fileno)\n @workers.delete(command_label)\n end\n if trigger_event\n event_manager.trigger(command_label, :worker_removed)\n end\n end",
"def remove!(pid)\n kill_child pid\n @pids.delete(pid)\n procline\n end",
"def get_docker_node_destroy_command_for(node)\n \"docker kill #{node.id}; docker rm #{node.id}\"\nend",
"def delete(key)\n timeout_retry(3, 3){\n write \"DEL #{key}\\r\\n\"\n integer_reply == 1\n }\n end",
"def no_wait_poll\n remove if can_remove_no_wait?\n end",
"def process_remove_wait(waititem)\n @process_builder_waits.to_a.each do |builder, waits|\n if waits.include?(waititem)\n waits.delete(waititem)\n end\n if waits.empty?\n @process_builder_waits.delete(builder)\n @process_builders_to_run << builder\n end\n end\n end",
"def clear!(request_options = {})\n res = clear(request_options)\n wait_task(res['taskID'], WAIT_TASK_DEFAULT_TIME_BEFORE_RETRY, request_options)\n res\n end",
"def remove\n server = read.select_servers(cluster.servers).first\n Operation::Write::Delete.new(\n :deletes => [{ q: selector, limit: opts[:limit] || 0 }],\n :db_name => collection.database.name,\n :coll_name => collection.name,\n :write_concern => collection.write_concern\n ).execute(server.context)\n end",
"def kill\n @executor.shutdownNow\n nil\n end",
"def remove_command(command, resize=true)\n @commands.delete(command)\n @item_max = @commands.size\n refresh_command(resize)\n end",
"def delete(name)\n Win32::Service.delete(n(name))\n end",
"def kill( name )\n job = get( name )\n return true if job && job.kill\n false\n end",
"def edged(cmd)\n $lock.synchronize{ \n $network.remove_edge($hostname,cmd[0])\n\n if $rt.has_key? cmd[0]\n $rt.delete cmd[0] \n end\n\n }\nend",
"def no_wait_poll\n remove if can_remove_no_wait?\n end",
"def kill_gracefully(waiter, timeout: 1.0)\n Process.kill(\"TERM\", waiter.pid)\n return waiter unless waiter.join(timeout).nil?\n\n Process.kill(\"KILL\", waiter.pid)\n waiter.join\nend",
"def remove_port(port)\n @local_ports.delete(port.name)\n port.disconnect_all # don't wait for the port to be garbage collected by Ruby\n @local_task.do_remove_port(port.name)\n end",
"def remove_port(port)\n @local_ports.delete(port.name)\n port.disconnect_all # don't wait for the port to be garbage collected by Ruby\n @local_task.do_remove_port(port.name)\n end",
"def no_wait_poll\n remove if can_remove_no_wait?\n end",
"def create_timed_delete(timeout, port_entry)\n mtimer = EM.add_timer(timeout.to_i) do\n time_left = port_entry.lifetime_left\n if time_left > 0\n #puts \"object has #{time_left} seconds left, #{Time.now}\"\n create_timed_delete(time_left, port_entry)\n else\n #puts \"timed delete writer #{Time.now}\"\n @portentries.delete(@portentries.key(port_entry))\n end\n end\n port_entry.timer = mtimer\n end",
"def cmd_delete argv\n setup argv\n uuid = @hash['uuid']\n response = @api.delete(uuid)\n msg response\n return response\n end",
"def shutdown(timeout = T.unsafe(nil)); end",
"def rm_r(path)\n cmd 'rm', '-r', path\nend",
"def rspdel(params = nil)\n if @name_index\n @conf.insert(@name_index + @conf.length, \" \" + \"rspdel \" + params.to_s + \"\\n\")\n else\n puts \"no #{@proxy_type} name assigned\"\n return false\n end\n end",
"def run_command(command, timeout)\n Open3.popen2(command, :pgroup=>true) do |_, stdout, wait_thr|\n pid = wait_thr.pid\n pgid = Process.getpgid(pid)\n @omicli_pgids << pgid\n deadline = Time.now + timeout\n sleep 0.5 until Time.now > deadline or !wait_thr.status\n if wait_thr.status\n begin\n `pkill -TERM -g #{pgid}`\n sleep 1\n if wait_thr.status\n `pkill -KILL -g #{pgid}`\n end\n rescue => e\n log_error(\"Failed to kill process(es) for command '#{command}'. #{e}\")\n end\n OMS::Log.error_once(\"Telemetry failed with process timeout '#{command}'\")\n @omicli_pgids.pop\n return ''\n else\n @omicli_pgids.pop\n return stdout.read\n end\n end\n end",
"def delete(k, ignored_options = nil)\n handle_fork\n _delete k\n end",
"def remove name\n delete(name)\n end",
"def close command, timeout=cli_option(:default_timeout)\n assert_raise EOFError, \"#{cli_option(:name)} failed to close properly\" do\n self << command\n self.>>(//, timeout)\n self.>>(//, timeout)\n end\n super()\n end",
"def remove_host(hostname, port=nil)\n hostname, port = normalize_address(hostname, port)\n connection = nil\n @lock.synchronize do\n index = @hosts.index { |h, p, _| h == hostname && p == port }\n if index\n @hosts.delete_at(index)\n if (conn = @connections.find { |c| c.host == hostname && c.port == port })\n connection = conn\n end\n end\n end\n if connection\n connection.close\n end\n Future.resolved(self)\n end",
"def cmd_delete argv\n setup argv\n e = @hash['element']\n response = @api.delete(e)\n msg response\n return response\n end",
"def delete(opts = {}, &block)\n @channel.once_open do\n self.once_name_is_available do\n queue_delete(opts.fetch(:if_unused, false), opts.fetch(:if_empty, false), opts.fetch(:nowait, false), &block)\n end\n end\n\n # backwards compatibility\n nil\n end",
"def kill(n, c)\n @socket << \"KILL #{n} :#{c}\"\n end",
"def get_cmd(command,sleep_time,timeout,tries)\n msg=''\n ret=tries\n success=nil\n if(not(ret))\n ret=1\n end\n $queue.synchronize do\n $rx_messages.clear()\n end\n while(ret>0 and (not(success)))\n ret=ret-1\n $serial_port.synchronize do\n $serialport.write(command)\n end\n now=Time.now().to_f\n while((not(success)) and Time.now().to_f-now<=timeout)\n $queue.synchronize do\n if($rx_messages.length>0)\n msg=$rx_messages.pop()\n success=true\n end\n end\n sleep(0.1)\n end\n end\n if(success)\n sleep(sleep_time)\n return(msg)\n else\n return(nil)\n end\nend",
"def removeSimpleTask _obj, _args\n \"_obj removeSimpleTask _args;\" \n end",
"def delete_container(name, options={})\n query = { }\n query['timeout'] = options[:timeout].to_s if options[:timeout]\n\n call(:delete, container_uri(name, query))\n nil\n end",
"def remove! identifier\n connect do |connection|\n connection.remove( identifier )\n end\n end",
"def cleanup_after(cmd, text, bat)\n\t\tbegin\n\t\t\t# Try and do cleanup command\n\t\t\tcleanup = \"#{cmd} /C del C:#{text} & del #{bat}\"\n\t\t\tprint_status(\"#{peer} - Executing cleanup\")\n\t\t\tout = psexec(cleanup)\n\t\trescue StandardError => cleanuperror\n\t\t\tprint_error(\"#{peer} - Unable to processes cleanup commands: #{cleanuperror}\")\n\t\t\tprint_warning(\"#{peer} - Maybe C:#{text} must be deleted manually\")\n\t\t\tprint_warning(\"#{peer} - Maybe #{bat} must be deleted manually\")\n\t\t\treturn cleanuperror\n\t\tend\n\tend",
"def kill(pid)\n check_connection\n @protocol.kill_command pid\n self\n end",
"def remove_server( host, port )\n server = get_server( host, port )\n Penctl.update_server( @pen, server[:slot], :address => '0.0.0.0', :port => 0 )\n !server_in_pool? host, port\n end",
"def command!(name)\n found = command(name)\n\n if found.nil?\n raise CommandNotFound.new(name, self)\n end\n\n found\n end",
"def delete_job_by_digest\n call_script(:delete_job_by_digest,\n keys: [\"#{QUEUE}:#{queue}\", SCHEDULE, RETRY],\n argv: [lock_digest])\n end",
"def remove_runner(pid)\n klass = @index.delete(pid)\n @runners[klass].delete(pid)\n end",
"def delete_queue(queue_name, options = {})\n query = {}\n query[\"timeout\"] = options[:timeout].to_s if options[:timeout]\n\n uri = queue_uri(queue_name, query)\n\n call(:delete, uri, nil, {}, options)\n nil\n end",
"def removecmd(idx)\n {name: idx, type: :indexed}\n end",
"def removecmd(idx)\n {name: idx, type: :indexed}\n end",
"def fireNforget(command)\n pid = Process.fork\n if pid.nil?\n sleep(1)\n exec \"#{command}\"\n else\n Process.detach(pid)\n end\nend",
"def clear_timeout(timeout)\n `clearTimeout(timeout)` if timeout\n end",
"def rm(*str)\n r\"rm #{str.join(' ')}\"\nend",
"def fireNforget(command)\n pid = Process.fork\n if pid.nil?\n sleep(1)\n exec \"#{command}\" # This can now run in its own process thread and we dont have to wait for it\n else\n # In parent, detach the child process\n Process.detach(pid)\n end\nend",
"def remove_timeout! i_ids\n Logging.log \"Remove timeout for #{i_ids.join(', ')}\".colorize(:yellow)\n i_ids.each { |i_id| @instances[i_id].delete 'timeout' }\n File.write @source, @instances.to_json\n end",
"def del(opts)\n \"\"\n end",
"def ickdel(ick_key,unlink: false)\n if !ick_key.is_a?(String)\n raise ArgumentError, \"bogus non-String ick_key #{ick_key}\"\n end\n stats_prefix = unlink ? 'profile.ick.ickunlink' : 'profile.ick.ickdel'\n redis_cmd = unlink ? 'UNLINK' : 'DEL'\n _statsd_increment(\"#{stats_prefix}.calls\")\n _statsd_time(\"#{stats_prefix}.time\") do\n _eval(\n LUA_ICK_PREFIX +\n \"return redis.call('#{redis_cmd}',ick_key,ick_pset_key,ick_cset_key)\",\n ick_key\n )\n end\n end",
"def idle_trim!(timeout); end",
"def stop(wait = true)\n request('stopProcessGroup', @name, wait)\n end",
"def cancel(timer)\n @timers.delete timer\n end",
"def worker_shutdown_timeout(timeout); end",
"def execute_cmd!(cmd, timeout = new_resource.cmd_timeout)\n cmd = execute_cmd(cmd, timeout)\n cmd.error!\n cmd\n end",
"def execute_cmd!(cmd, timeout = new_resource.cmd_timeout)\n cmd = execute_cmd(cmd, timeout)\n cmd.error!\n cmd\n end",
"def remove_batched_job(id, *args)\n mutex(id) do |bid|\n removed_count = redis.lrem(bid, 1, Resque.encode(:class => self.name, :args => args))\n\n raise \"Failed to remove batched job, id: #{id}, args: #{args.join(', ')}\" if removed_count != 1\n\n redis.llen(bid)\n end\n end",
"def remove_invocation(*names)\n names.each do |name|\n remove_command(name)\n remove_class_option(name)\n invocations.delete(name)\n invocation_blocks.delete(name)\n end\n end",
"def remove(*names)\n extract_and_apply_options!(names)\n delete_if { |name| names.include?(name) }\n self\n end",
"def delete_worker(key)\n @mutex.synchronize {\n if @jobs[key]\n if @jobs[key].respond_to?(:thread) && @jobs[key].thread.alive?\n if @jobs[key].job_ctrl\n @jobs[key].thread[:kill] = true\n @jobs[key].thread[:safe_to_kill].wait(@mutex)\n end \n @jobs[key].thread.kill\n end\n @jobs.delete(key)\n end\n @timestamps.delete(key) if @timestamps.has_key?(key)\n }\n end",
"def delete(name); end",
"def delete(name); end",
"def unset(*args, **kwargs)\n queue UnsetCommand, args, kwargs\n end",
"def task_remove(task_name)\n return unless task_present? task_name\n tasks.delete prepare_key(task_name)\n reset\n end",
"def silent_delete(m, ind)\n found_attribs = get(:tasks, ind)\n m.reply \"task not found. please relist and try again\" && return unless found_attribs\n m.reply \"silently deleting the task. Bang!\"\n delete(:tasks, ind)\n end",
"def timeout(val = nil)\n if val\n @j_del.setTimeout(val)\n self\n else\n @j_del.getTimeout\n end\n end",
"def drop_task(name)\n task = self.cron_tasks.find_by_name(name)\n task.destroy if not task.nil?\n end",
"def kill \n remote_data = @repo.to_s\n deleter = Deleter.new S3_STORE\n deleter.delete remote_data, @threads, &REPORTER\n end",
"def delete\n rc = NetUseDel.call(nil, @name, USE_NOFORCE)\n if rc != NERR_Success\n raise ArgumentError, get_last_error(rc)\n end\n end",
"def reqdel(params = nil)\n if @name_index\n @conf.insert(@name_index + @conf.length, \" \" + \"reqdel \" + params.to_s + \"\\n\")\n else\n puts \"no #{@proxy_type} name assigned\"\n return false\n end\n end",
"def delete_machine(machine, pool)\n handle_action_exceptions(__method__) do\n cmd_line = [\"deletemachine '#{machine}' '#{pool}'\"]\n cmd_line << 'json' if @json\n\n handle_return(@toolshck_ether.cmd(cmd_line.join(' ')))\n end\n end",
"def remove(*names)\r\n extract_and_apply_options!(names)\r\n delete_if { |name| names.include?(name) }\r\n self\r\n end",
"def remove(pattern, dest, options)\n [:remove, pattern, dest, options]\nend",
"def removeTorrentEntry(infoHash)\n callData =\n [\n ['d.stop', infoHash],\n ['d.close', infoHash],\n ['d.erase', infoHash],\n ]\n\n @rpc.multicall(*callData)\n\n return nil\n end"
] |
[
"0.574469",
"0.5506502",
"0.5496572",
"0.5301204",
"0.52708554",
"0.52347267",
"0.52190846",
"0.52145755",
"0.51994157",
"0.5180374",
"0.51475143",
"0.5128506",
"0.51164967",
"0.509563",
"0.5060454",
"0.50186694",
"0.5002888",
"0.4968418",
"0.4963091",
"0.49486768",
"0.49320254",
"0.49298313",
"0.49287203",
"0.49122325",
"0.49083912",
"0.48640332",
"0.48629647",
"0.48427886",
"0.48421237",
"0.48359823",
"0.48357913",
"0.48207074",
"0.4818973",
"0.4816",
"0.4815938",
"0.48134762",
"0.48054668",
"0.47856653",
"0.47772762",
"0.4771483",
"0.47657526",
"0.47657526",
"0.4758008",
"0.47475988",
"0.47474614",
"0.47370723",
"0.4736329",
"0.47210693",
"0.47190708",
"0.47098848",
"0.47048974",
"0.4704324",
"0.47041094",
"0.47001827",
"0.4696624",
"0.46943226",
"0.4673691",
"0.46646962",
"0.46503547",
"0.46474913",
"0.46357927",
"0.46341854",
"0.46224192",
"0.4616801",
"0.46096346",
"0.46087152",
"0.46078464",
"0.46002698",
"0.46002698",
"0.45994753",
"0.45992556",
"0.45979792",
"0.4596116",
"0.4589332",
"0.4588081",
"0.4587964",
"0.45798168",
"0.45797473",
"0.4573638",
"0.4572656",
"0.4570056",
"0.4570056",
"0.45676762",
"0.45612586",
"0.4557592",
"0.45558193",
"0.45546588",
"0.45546588",
"0.4540714",
"0.4539707",
"0.45384556",
"0.4528228",
"0.452549",
"0.45238787",
"0.4513951",
"0.45055455",
"0.4498014",
"0.4495372",
"0.44944423",
"0.44926295"
] |
0.58705926
|
0
|
Unregister everything by a given module
|
def unregister_modules(timeout=nil, *mods)
mods.each{|mod|
raise "no modules registed." if not @modules[mod]
$log.debug "Unregistering module: #{mod.class}..."
unregister_hooks(timeout, *@modules[mod][:hooks]) #if @modules[mod]
# At this point @modules[mod] may have been caught in the cleanup system
unregister_commands(timeout, *@modules[mod][:cmds]) if @modules[mod]
}
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def unregister_all(timeout = nil)\n $log.debug \"Unregistering all modules...\"\n # clone to avoid editing whilst iterating\n unregister_modules(timeout, *@modules.keys.clone) \n end",
"def deregister_all(session)\n namespace = session.namespace_const\n session.modules.each do |m|\n m.deregister\n end\n session.modules = []\n @initialized = false\n true\n end",
"def unregister(slice_module)\n if (slice = self[slice_module]) && self.paths.delete(module_name = slice.name)\n slice.loadable_files.each { |file| Merb::Slices::Loader.remove_classes_in_file file }\n Object.send(:remove_const, module_name)\n unless Object.const_defined?(module_name)\n Merb.logger.info!(\"Unregistered slice #{module_name}\")\n Merb::Slices::Loader.reload_router!\n end\n end\n end",
"def unregister(symbol); end",
"def unregister_all\n registry.clear.default = nil\n end",
"def unregister(*extensions); end",
"def unsave_module(valid_uni_module)\n uni_modules.delete(valid_uni_module)\n end",
"def unregister_capabilities(methods); end",
"def unregister(const)\n @@extensions.delete(const)\n end",
"def unregister(path)\n\t\t\t\tpath = path.to_sym\n\t\t\t\tif @@registry[path]\n\t\t\t\t\t@@registry_count[path] -= 1\n\t\t\t\t\tif @@registry_count[path] <= 0\n\t\t\t\t\t\tsub = @@registry.delete(path)\n\t\t\t\t\t\tsub.unsubscribe\n\t\t\t\t\t\t@@registry_count.delete(path)\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend",
"def unregister(object)\n\t\t\t@registered.delete(object)\n\t\tend",
"def without_modules(*modules); end",
"def without_modules(*modules); end",
"def unregister\n @is_registered = false\n self\n end",
"def remove_stub(stub_module=nil)\n stub_module ||= @_stub\n obj = self\n mod = Module.new\n stub_module.__table__.each do |interface, result|\n meth = interface[0]\n mod.module_eval do\n define_method(meth, &obj.class.instance_method(meth).bind(obj))\n end\n end\n extend(mod)\n end",
"def unregister(name)\n resource = resources.delete(name)\n if resource\n resource.bulkhead&.unregister_worker\n consumers_for_resource = consumers.delete(name) || []\n consumers_for_resource.each do |consumer|\n if consumer.weakref_alive?\n consumer.clear_semian_resource\n end\n rescue WeakRef::RefError\n next\n end\n end\n end",
"def unregister_hooks(*names)\n # Load a timeout if one is given\n names.delete(nil)\n timeout = nil\n if names and names[0].is_a?(Numeric) then\n timeout = names[0].to_f\n names = names[1..-1]\n end\n\n # Then unhook things\n @hooks_mutex.synchronize{\n names.each{|name|\n $log.debug \"Unregistering hook: #{name}...\"\n hook = @hooks.delete(name)\n\n mod = hook[:module]\n @modules[mod][:hooks].delete(name) \n cleanup_module(mod, timeout)\n }\n }\n end",
"def removeMod(modName)\n @modules = @modules.delete_if {|mod| mod.destroy! if mod.name == modName}\n @authModule.delete modName\n end",
"def unRegisterAllService\n\t\tServiceModel.delete_all\n\tend",
"def del_reg(id)\n _registers.delete(id)\n end",
"def remove_all\n @registry = []\n sync\n end",
"def deactivate(slice_module)\n if slice = self[slice_module]\n slice.deactivate if slice.respond_to?(:deactivate) && slice.routed?\n unregister(slice)\n end\n end",
"def unregister\n exclusively do\n SendReceive::Tokens.free(send_log.token) if send_log\n end\n end",
"def stop(*)\n @module_started = false\n end",
"def unload_extensions(*exts)\r\n exts.each do |ext|\r\n sym = ext_sym(ext)\r\n obj = @extensions[sym]\r\n obj.ext_unload if obj.respond_to?(:ext_unload)\r\n obj.unload\r\n Object.send(:remove_const, sym)\r\n @extensions.delete sym\r\n end\r\n end",
"def purge_module_threads(mod)\n return if not @modules[mod]\n\n @modules[mod][:threads].delete_if{|t| \n not t.alive?\n } \n end",
"def unmodulize_modules(*mod_consts)\n mod_consts.each { |mod_const| unmodulize *(mod_const.instance_methods) }\n end",
"def unregister_type\n types_list.delete self\n end",
"def destroy\n info(\"Disabling Metricbeat module\")\n metricbeat(['modules','disable',@resource[:name]])\n end",
"def unregister_extension(const)\n @@extensions.delete(const)\n end",
"def unregister_extension(const)\n @@extensions.delete(const)\n end",
"def uninstall_module(inventory_hash, target_node_name, module_to_remove = nil, **opts)\n include ::BoltSpec::Run\n module_name = module_to_remove || metadata_module_name\n target_nodes = find_targets(inventory_hash, target_node_name)\n install_module_command = \"puppet module uninstall #{module_name}\"\n install_module_command += ' --force' if opts[:force]\n bolt_result = run_command(install_module_command, target_nodes, config: nil, inventory: inventory_hash)\n # `puppet module uninstall --force` fails if the module is not installed. Ignore errors when force is set\n raise_bolt_errors(bolt_result, \"uninstalling #{module_name} failed.\") unless opts[:force]\n bolt_result\n end",
"def shutdown\n @registry.clear\n end",
"def unregister_all!\n @@media_generators = []\n @@link_grabbers = []\n @@media_scrapers = []\n self\n end",
"def unregister(uuid)\n execute_prlctl('unregister', uuid)\n end",
"def unregister(mutex)\n locks.delete(mutex)\n end",
"def uninstall(packagename)\n\t\t\tend",
"def reset!\n @modules = []\n end",
"def remove_dispatch(mod)\n # THREAD CRITICAL BEGIN\n if @dispatch[mod]\n @dispatch[mod] = false\n # $stderr.puts \"Removing dispatch for #{mod.name}##{name}\"\n mod.class_eval(\"remove_method #{name.inspect}\")\n end\n # THREAD CRITICAL END\n end",
"def unregister\n puts \"APN::Device.unregister\"\n http_delete(\"/api/device_tokens/#{self.token}\")\n end",
"def unregister_commands(*names)\n # Load a timeout if one is given\n names.delete(nil)\n timeout = nil\n if names and names[0].is_a?(Numeric) then\n timeout = names[0].to_f\n names = names[1..-1]\n end\n\n # And then unhook things\n @hooks_mutex.synchronize{\n names.each{|name|\n $log.debug \"Unregistering command: #{name}...\"\n cmd = @cmds.delete(name)\n \n mod = cmd[:module]\n @modules[mod][:cmds].delete(name) \n cleanup_module(mod, timeout)\n }\n }\n end",
"def off(base_module, constant_name)\n spy = get(base_module, constant_name)\n raise NoSpyError, \"#{constant_name} was not spied on #{base_module}\" unless spy\n spy.unhook\n end",
"def stop_registering_extension\n @register_path = nil\n end",
"def clear_all\n clear_modules\n end",
"def clear_registration_as_constant\n # Deregister non-permanent models that are registered in the\n # constant hierarchy\n if Registration.accessible_by_name?(self)\n Registration.deregister_constant(self)\n end\n end",
"def unsubscribe\n unregister\n end",
"def remove_acts_as_resource_module(mod)\n write_inheritable_attribute(:acts_as_resource_modules, acts_as_resource_modules - [mod])\n acts_as_resource_modules\n end",
"def destroy\n removeCredits(@registered_for.module_code)\n @registered_for.destroy\n respond_to do |format|\n flash[:success] = \"Module successfully removed!\"\n format.html { redirect_to modules_url}\n format.json { head :no_content }\n end\n end",
"def remove_existing_instance_methods(mod)\n methods = Module === mod ?\n (mod.public_instance_methods(false) + mod.private_instance_methods(false) + mod.protected_instance_methods(false)) : Array(mod)\n\n methods.each do |m|\n remove_method(m) rescue nil\n end\n end",
"def unregister_capabilities methods\n @register_semaphore.synchronize do\n send_request 'client/unregisterCapability', {\n unregisterations: methods.select{|m| registered?(m)}.map{ |m|\n @registered_capabilities.delete m\n {\n id: m,\n method: m\n }\n }\n }\n end\n end",
"def uninclude(mod, recurse = false) end",
"def remove(modName,privMsg)\n begin\n unless has_key?(modName)\n answer(privMsg,\"Module not loaded\")\t\n else\n removeMod(modName)\n answer(privMsg,\"Module #{modName} unloaded!\")\n end\n rescue Exception\n answer(privMsg,\"Problem when deleting the module\")\n talk(privMsg.who,$!)\n end\n end",
"def unregister\n Registry.unregister_loader(self)\n ExplicitNamespace.unregister_loader(self)\n end",
"def unregister(*providers)\n providers.each do |provider|\n provider.urls.each do |url|\n if @@urls[url].is_a?(Array)\n @@urls[url].delete(provider)\n @@urls.delete(url) if @@urls[url].empty?\n end\n end\n end\n end",
"def clear\n @registry = {}\n end",
"def unobserve_all_observables\n registrations.values.dup.each do |registration|\n registration.deregister\n registrations.delete([registration.observable.object_id, registration.args])\n end\n end",
"def clear_registry(reg_, opts_={}, &condition_)\n @tasks << RegistryMiddleware::ClearRegistry.new(reg_, opts_, &condition_)\n self\n end",
"def unregisterTask _obj, _args\n \"_obj unregisterTask _args;\" \n end",
"def deregister_snippets\n # Loop through all registered snippets\n @@registered.keys.each do |id|\n # Deregister the snippet view\n Hooks::View.deregister_dynamic_view(id)\n # Remove the snippet from the registered array\n @@registered.delete(id)\n end\n end",
"def remove_module_path(path)\n\t\tmodule_paths.delete(path)\n\tend",
"def unregister_processor(*args)\n unregister_preprocessor(*args)\n end",
"def delete_all\n @loaded_constants.each do |const_name|\n if Object.const_defined?(const_name)\n Object.send(:remove_const, const_name)\n end\n end\n Ichiban::HTMLCompiler::Context.clear_user_defined_helpers\n end",
"def remove(plugin); end",
"def unregister_all\n @@urls = {}\n @@fallback = []\n end",
"def remove_all_spies\n @registry.remove_all.each(&:stop)\n end",
"def unregister_keybindings(section)\n command(\"disable-section\", section)\n command(\"define-section\", section, \"\")\n unregister_message_handler(section)\n end",
"def remove!(package)\n raise NotImplementedError\n end",
"def deregister_extension(name)\n self.ext.aliases.delete(name)\n end",
"def remove_classes_and_modules\n initialize_classes_and_modules\n end",
"def __reset\n @registry.clear\n end",
"def unregister(key_or_instance)\n proxy_across_keytypes(:delete, key_or_instance)\n end",
"def unRegisterChecker( id )\n @availableCheckers.delete_if{ |x| x.id == id}\n end",
"def uninstall(assets); end",
"def unregister_action(action, path=BASE_PATH)\n @instance.unregister_action action, path\n end",
"def destroy(sym)\n klass = get_plugin sym\n @klasses.delete klass\n remove_const canonize sym\n end",
"def deregister_application(app_name, namespace)\n end",
"def uninstall\n pacman \"--noconfirm\", \"--noprogressbar\", \"-R\", @resource[:name]\n end",
"def unregister(message_type, message_subtype = nil, &block)\n @listeners[message_type][message_subtype] -= [block] unless @listeners[message_type].nil? or @listeners[message_type][message_subtype].nil?\n purge_all\n end",
"def unsubscribe(key)\n @lock.synchronize do\n @handlers.clear\n @@name2inst.delete_if { |k, v| k == id.to_sym || k == address.to_sym}\n end\n end",
"def unregister_commands\n Bot::Commands.delete_for self\n end",
"def close\n unregister\n end",
"def unregister(*args, &block)\n h = Unobservable.handler_for(*args, &block)\n index = @handlers.index(h)\n if index\n @handlers.slice!(index)\n return h\n else\n return nil\n end\n end",
"def unload(inst)\n # If the reference count drops to zero, remove it from the list of\n # loaded plugins. This will indirectly call the cleanup method on the\n # plugin.\n if (inst.deref == true)\n delete(inst)\n end\n end",
"def rm_submods\n # rm git modules\n `rm -rf .gitmodules`\n\n puts colorBlue(\"removing submodule: #{self.submods}\")\n `rm -rf #{self.submods}/.git`\n\n `git rm --cached #{self.submods}`\n end",
"def remove_library(lib)\n lib = lib.to_s\n\n @libraries[:start].delete lib\n @libraries[:sub_session].delete lib\n @libraries[:autoload].reject!{|_,e,| e == lib }\n @libraries[:thread].each{ |_,libs| libs.delete lib }\n @libraries[:late].delete lib\n @libraries[:late_thread].each{ |_,libs| libs.delete lib }\n\n @lib_hooks.delete lib\n end",
"def remove_library(lib)\n lib = lib.to_s\n\n @libraries[:start].delete lib\n @libraries[:sub_session].delete lib\n @libraries[:autoload].reject!{|_,e,| e == lib }\n @libraries[:thread].each{ |_,libs| libs.delete lib }\n @libraries[:late].delete lib\n @libraries[:late_thread].each{ |_,libs| libs.delete lib }\n\n @lib_hooks.delete lib\n end",
"def delete_module(org_unit_id, module_id) # DELETE\n query_string = \"/d2l/api/le/#{$le_ver}/#{org_unit_id}/content/modules/#{module_id}\"\n _delete(query_string)\nend",
"def remove\n unrealize\n remove_from_dependencies\n remove_from_dependents\n end",
"def remove( *args )\n args.each { |name|\n name = name.to_s.delete('=')\n code = <<-__\n undef_method :#{name} rescue nil\n undef_method :#{name}= rescue nil\n __\n Loquacious::Configuration.module_eval code\n Loquacious::Configuration::DSL.module_eval code\n }\n end",
"def remove_const(sym) end",
"def release_all_registers\n @temp_registers.each do |reg|\n next if reg.end_point\n release_register reg\n end\n end",
"def unset(object)\n if object.is_a?(Array)\n object.each do |obj|\n unset(obj)\n end\n return nil\n end\n\n classname = object.class.name\n\n if @args[:module]\n classname = classname.gsub(@args[:module].name + \"::\", \"\")\n end\n\n classname = classname.to_sym\n @objects[classname].delete(object.id.to_i)\n end",
"def remove_registration\n reg = Iq.new_register\n reg.to = jid.domain\n reg.query.add(REXML::Element.new('remove'))\n send_with_id(reg)\n end",
"def destroy\n @uni_module = UniModule.find(params[:id])\n can_delete = true\n\n # check if being used\n Group.all.each do |group|\n if group.uni_modules.include?(@uni_module)\n can_delete = false\n break\n end\n end\n\n if can_delete\n @uni_module.comments.each do |comment|\n comment.destroy\n end\n logs = UniModuleLog.all.where(:uni_module_id => @uni_module.id)\n if logs.size >0\n logs.each do |log|\n log.destroy\n end\n end\n pflogs = PathwaySearchLog.all.where(:first_mod_id => @uni_module.id)\n if pflogs.size >0\n pflogs.each do |log|\n log.destroy\n end\n end \n pslogs = PathwaySearchLog.all.where(:second_mod_id => @uni_module.id)\n if pslogs.size >0\n pslogs.each do |log|\n log.destroy\n end\n end \n @uni_module.destroy\n tag_clean_up\n flash[:success] = \"Successfully deleted module\"\n redirect_to admin_uni_modules_path\n else\n flash[:error] = \"This module is linked to a course. You must first either unlink or delete those courses.\"\n redirect_to admin_uni_modules_path\n end\n\n end",
"def rm_installed_modules_from_hosts(beginning_hash, ending_hash)\n ending_hash.each do |host, mod_array|\n mod_array.each do |mod|\n if ! beginning_hash[host].include? mod\n on host, \"rm -rf '#{mod}'\"\n end\n end\n end\n end",
"def unload name\n raise \"Cannot unload: No such script #{name}\" unless @scripts.key? name\n\n @scripts[name].die if @scripts[name].respond_to? \"die\"\n\n Events.dispatch_for @scripts[name], :unloading\n\n Events.delete_for @scripts[name]\n URL.delete_for @scripts[name] if defined? MODULE_LOADED_URL_HANDLER\n RegexHandlerManager.delete_for @scripts[name] if defined? MODULE_LOADED_REGEX_HANDLER\n\n @scripts[name].unregister_script\n @scripts[name].unregister_commands\n @scripts[name].unregister_events\n\n @scripts.delete name\n end",
"def unregister_from_event_loop\n if @loop == :em\n @em_connection.unattach(false)\n else\n raise NotImplementedError.new(\"unregister_from_event_loop not implemented for #{@loop}\")\n end\n end",
"def unload\n @structures = []\n @controllers = []\n @helpers = @helpers.is_a?(Array) ? @helpers.select { |h| h.options[:unloadable] == false } : []\n @authenticators = {}\n @shared_actions = {}\n @default_access = nil\n end",
"def remove_method(sym) end",
"def remove_unloadable_constants!\n log(\"removing unloadable constants\")\n autoloaded_constants.each { |const| remove_constant const }\n autoloaded_constants.clear\n Reference.clear!\n explicitly_unloadable_constants.each { |const| remove_constant const }\n end"
] |
[
"0.74722874",
"0.74537235",
"0.72099257",
"0.6884662",
"0.68139005",
"0.67116714",
"0.6612138",
"0.64030534",
"0.6338498",
"0.6237953",
"0.6221447",
"0.6220193",
"0.6220193",
"0.62041533",
"0.6143791",
"0.6132789",
"0.61292493",
"0.611779",
"0.60821664",
"0.6080475",
"0.606557",
"0.60470766",
"0.60183734",
"0.6011302",
"0.5986756",
"0.5980491",
"0.59493446",
"0.59242696",
"0.5882037",
"0.5879672",
"0.5879672",
"0.5866144",
"0.5848342",
"0.58388174",
"0.5829358",
"0.58257216",
"0.5825255",
"0.5816495",
"0.57995164",
"0.5797848",
"0.57925093",
"0.57741374",
"0.57661986",
"0.5760405",
"0.5759845",
"0.57543445",
"0.5739752",
"0.5738574",
"0.57377315",
"0.57322013",
"0.5699017",
"0.5686753",
"0.56823593",
"0.56820875",
"0.56808203",
"0.56794256",
"0.5675276",
"0.5655964",
"0.5621997",
"0.5615482",
"0.5611731",
"0.56110084",
"0.5597879",
"0.5597047",
"0.5591592",
"0.55759007",
"0.5574827",
"0.5572057",
"0.5571568",
"0.5569354",
"0.55676633",
"0.5560445",
"0.5538068",
"0.5534487",
"0.5533082",
"0.5521227",
"0.55136776",
"0.550458",
"0.5494888",
"0.548505",
"0.54542774",
"0.54534626",
"0.54498404",
"0.5446903",
"0.5441907",
"0.54410094",
"0.54400605",
"0.5422423",
"0.5412102",
"0.54116154",
"0.54037327",
"0.5402817",
"0.54000473",
"0.5381088",
"0.5374453",
"0.53634095",
"0.53564095",
"0.5355459",
"0.5344691",
"0.5342272"
] |
0.7372883
|
2
|
Register a module by calling hook_thyself. Since modules should extend HookService, they should implement hook_thyself in order to make initial hooks.
|
def register_module(mod)
$log.debug "Registering module: #{mod.class}..."
mod.hook_thyself
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def register_hook(mod, name, trigger = nil, types = /channel/, &p)\n raise \"Please define a block\" if not block_given?\n raise \"That command is already hooked.\" if @hooks[name]\n raise \"The module given is not a module\" if not mod.is_a?(HookService)\n trigger ||= lambda{|*| return true} # set trigger if someone has allowed it to be default\n raise \"Cannot call the trigger expression (type: #{trigger.class})! Ensure it responds to call()\" if not trigger.respond_to?(:call)\n \n # Ensure types is an array and is full of regex\n types = [types] if not types.is_a?(Array)\n types.map!{|x| (x.is_a? Regexp) ? x : Regexp.new(x.to_s)} # convert to rx if not already\n \n @hooks_mutex.synchronize{\n # Ensure defaults and register \n @hooks[name] ||= {}\n @hooks[name] = {:types => types, :trigger => trigger, :proc => p, :module => mod}\n \n # Register a given hook or command for a give module\n @modules[mod] ||= {:hooks => [], :cmds => [], :threads => [], :threaded => mod.threaded?}\n @modules[mod][:hooks] << name\n }\n\n $log.debug \"Registered hook '#{name}'\"\n end",
"def register(plugin_name, hook_name, &block)\n @registrations ||= {}\n @registrations[hook_name] ||= []\n @registrations[hook_name] << Hook.new(hook_name, plugin_name, block)\n end",
"def add_hook_context( context )\n\n case context\n when :before_include, :before_extend, :after_include, :after_extend\n case @cluster.instance\n when ::Class\n unless @cluster.instance <= ::Module\n raise ::RuntimeError, 'Include/Extend execution hooks cannot be created for classes.'\n end\n end\n when :subclass\n case @cluster.instance\n when ::Class\n when ::Module\n raise ::RuntimeError, 'Subclass execution hooks cannot be created for modules.'\n end\n end\n \n @hook_contexts[ context ] = true\n \n return self\n \n end",
"def hook(&block)\n @hooks << block\n end",
"def register_module\n unless Object.const_defined? module_name\n Object.const_set module_name, Module.new\n end\n end",
"def register_fulfillment_processor mod\n uniq_code = mod.name\n return unless verify_uniq_fulfillment_processor(uniq_code)\n return unless verify_fulfillment_module(mod)\n install_fulfillment_processor(uniq_code, mod)\n end",
"def register(&block)\n extend Module.new(&block)\n end",
"def add_module(mod, name, file_paths)\n\t\t# Call the module set implementation of add_module\n\t\tdup = super\n\n\t\t# If the module cache is not being used, update the cache with\n\t\t# information about the files that are associated with this module.\n\t\tif (!using_cache)\n\t\t\tupdate_module_cache_info(dup.fullname, mod, file_paths)\n\t\tend\n\n\t\t# Automatically subscribe a wrapper around this module to the necessary\n\t\t# event providers based on whatever events it wishes to receive. We\n\t\t# only do this if we are the module manager instance, as individual\n\t\t# module sets need not subscribe.\n\t\tauto_subscribe_module(dup)\n\n\t\t# Notify the framework that a module was loaded\n\t\tframework.events.on_module_load(name, dup)\n\tend",
"def hook_require!\n hook_instance_require!\n hook_singleton_require!\n end",
"def add(hook)\n @hooks << hook\n self\n end",
"def register_module_function(object); end",
"def register_hook(name, hook)\n hooks[name.to_s.downcase.strip.to_sym] << hook\n end",
"def hook_require!\n @hooking_require = true\n\n # There are two independent require methods. Joy!\n ::Kernel.module_eval do\n class << self\n orig_public_require = Kernel.public_method(:require)\n define_method(:require) do |path, *args|\n ::Bumbler::Hooks.handle_require(path) do\n orig_public_require.call(path, *args)\n end\n end\n end\n\n orig_instance_require = self.instance_method(:require)\n define_method(:require) do |path, *args|\n ::Bumbler::Hooks.handle_require(path) do\n orig_instance_require.bind(self).call(path, *args)\n end\n end\n end\n\n @hooking_require = nil\n end",
"def notifications_modules_hook!\n yield\n end",
"def watch_require!\n ::Kernel.module_eval do\n # It isn't previously defined in Kernel. This could be a bit dangerous, though.\n def self.method_added(method_name, *_args) # rubocop:disable Lint/MissingSuper\n if method_name == :require && !Bumbler::Hooks.hooking_instance_require?\n ::Bumbler::Hooks.hook_instance_require!\n end\n end\n\n def self.singleton_method_added(method_name, *_args) # rubocop:disable Lint/MissingSuper\n if method_name == :require && !Bumbler::Hooks.hooking_singleton_require?\n ::Bumbler::Hooks.hook_singleton_require!\n end\n end\n end\n end",
"def hook(name, &blk)\n @hooks[name.to_sym] ||= []\n @hooks[name.to_sym] << blk\n self\n end",
"def register!\n # Register the plugin.\n @manager.register_plugin! self\n end",
"def on_module_load(mod, type, name, modinfo)\n\t\t# Payload modules require custom loading as the individual files\n\t\t# may not directly contain a logical payload that a user would \n\t\t# reference, such as would be the case with a payload stager or \n\t\t# stage. As such, when payload modules are loaded they are handed\n\t\t# off to a special payload set. The payload set, in turn, will\n\t\t# automatically create all the permutations after all the payload\n\t\t# modules have been loaded.\n\t\tif (type != MODULE_PAYLOAD)\n\t\t\t# Add the module class to the list of modules and add it to the\n\t\t\t# type separated set of module classes\n\t\t\tadd_module(mod, name, modinfo)\n\t\tend\n\n\t\tmodule_sets[type].add_module(mod, name, modinfo)\n\tend",
"def register(hook, obj = T.unsafe(nil), &blk); end",
"def rygsaek_modules_hook!\n yield\n end",
"def hook_require!\n @hooking_require = true\n\n # There are two independent require methods. Joy!\n ::Kernel.prepend RequireLogger\n (class << ::Kernel; self; end).prepend RequireLogger\n\n @hooking_require = nil\n end",
"def add_hook(name, &block)\n hooks[name.to_sym] ||= []\n hooks[name.to_sym] << block\n end",
"def hook_thyself\n me = self\n\n register_command(:fortune, /^[Ff]ortune$/, /channel/){ \n me.fortune(bot)\n }\n\n register_command(:eight_ball, /^8(ball)?$/, /channel/){|*msg|\n me.eight_ball(bot, msg.join(\" \"))\n }\n end",
"def before_hook(method_name)\n hooks << method_name\n end",
"def watch_require!\n ::Kernel.module_eval do\n # It isn't previously defined in Kernel. This could be a bit dangerous, though.\n def self.method_added(method_name, *_args)\n if method_name == :require && !::Bumbler::Hooks.hooking_require?\n # Fix those hooks.\n ::Bumbler::Hooks.hook_require!\n end\n end\n end\n end",
"def watch_require!\n ::Kernel.module_eval do\n # It isn't previously defined in Kernel. This could be a bit dangerous, though.\n def self.method_added(method_name, *args)\n if method_name == :require && !::Bumbler::Hooks.hooking_require?\n # Fix those hooks.\n ::Bumbler::Hooks.hook_require!\n end\n end\n end\n end",
"def hook(id, params={})\n\t\t\t\tparams[:self] = self\n\t\t\t\tself.class.hooks.execute id, params\n\t\t\tend",
"def make_hooks(*args)\r\n make :hook, *args\r\n end",
"def method_missing(method, *args)\n add_module(method, *args)\n end",
"def hook_thyself\n me = self\n\n\n\n # Add something to tell someone\n register_command(:tweet_cmd, /^tweet$/, [/channel/, /private/]){|*args| \n me.tweet(bot, nick, args.join(\" \"))\n }\n\n\n \n # Hook for when we have successfully joined\n @config[:channels].each do |chan|\n register_hook(\"twitter_join_#{chan}\".to_sym, lambda{|m| m.channel == chan}, /join/){\n me.join_channel( chan, bot ) if nick == bot_nick # Ensure we only fire if the bot has joined, not other people\n }\n end\n\n end",
"def hook(name, *args)\n name = ('hook_' + name.to_s).to_sym\n send name, *args if respond_to? name\n end",
"def add_module(name, outputter)\n assert_project_file(config.project)\n\n installer = Bolt::ModuleInstaller.new(outputter, pal)\n\n installer.add(name,\n config.project.modules,\n config.project.puppetfile,\n config.project.managed_moduledir,\n config.project.project_file,\n config.module_install)\n end",
"def define_hook(id, &block)\n\t\t\t\t\th = Hook.new id, &block\n\t\t\t\t\t@hooks[id] = [] unless @hooks[id]\n\t\t\t\t\t@hooks[id] << h\n\t\t\t\tend",
"def install_hook(side, event, callback)\n self.hooks[:\"#{ side }_#{ event }\"].push(callback)\n end",
"def add_module_by_normal_module(mod)\n add_class_or_module mod, @modules, @store.modules_hash\n end",
"def define_hook(name, *params)\n fetch_or_create_hooks << make_hook(name, nil, params)\n\n # We must use string evaluation in order to define a method that can\n # receive a block.\n instance_eval(<<-END)\n def #{name}(handle_or_method=nil, &block)\n add_callback(:#{name}, handle_or_method, &block)\n end\n END\n module_eval(<<-END)\n def #{name}(handle=nil, &block)\n add_external_callback(:#{name}, handle, block)\n end\n END\n end",
"def define_hook(name, *params)\n hooks << make_hook(name, nil, params)\n\n # We must use string evaluation in order to define a method that can\n # receive a block.\n instance_eval(<<-END)\n def #{name}(handle_or_method=nil, &block)\n add_callback(:#{name}, handle_or_method, &block)\n end\n END\n module_eval(<<-END)\n def #{name}(handle=nil, &block)\n add_external_callback(:#{name}, handle, block)\n end\n END\n end",
"def add_module(name)\n require name\n\n m = name.downcase.gsub(File::SEPARATOR, '_')\n method(\"dispatch_#{m}\".intern).call(self)\n\n self\n end",
"def rexval_modules_hook!\n yield\n end",
"def run_hook!(name)\n return unless hooks[name.to_sym]\n hooks[name.to_sym].each { |blk| config.instance_exec(&blk) }\n end",
"def hook_thyself\n me = self;\n\n # Show blacklist\n register_command(:omeg_blacklist_show, /^[Oo]megleBlacklist$/, /channel/){\n me.report_blacklist(bot, channel)\n }\n \n # Toggle use of blacklist for a user \n register_command(:omeg_blacklist, /^[Tt]oggleMe$/, /channel/){\n me.toggle_blacklist(bot, channel, nick)\n }\n\n # Toggle use of nick template\n register_command(:omeg_toggle, /^[Tt]oggleNick$/, /channel/){\n me.toggle_nick(bot, channel)\n }\n\n # Connect to a single stranger with <nickname> support\n register_command(:omeg_connect, /^[Oo]megle$/, /channel/){|*topics|\n me.ensure_not_blacklisted(channel, nick)\n me.summon_omegleite(bot, channel, topics)\n }\n \n # Connect to a single stranger with <nickname> support\n register_command(:omeg_ask, /^[Aa]skMe$/, /channel/){\n me.ensure_not_blacklisted(channel, nick)\n me.summon_omegleite(bot, channel, nil, true)\n }\n\n # Spy mode, ask a question and watch two people debate.\n register_command(:omeg_spy, /^[Aa]sk$/, /channel/){|*question|\n if(question.length < 0)\n bot.say(\"Please provide a question!\")\n else\n me.spy_mode(bot, channel, question.join(\" \"))\n end\n }\n\n end",
"def enabled_ad_hoc_hooks(hook_context); end",
"def hook\n self.class.hook\n end",
"def hook(&block)\n @hook = block if block_given?\n @hook\nend",
"def register_hook(hook_name, block)\n hooks_for(hook_name).each do |blk|\n # Simple but effective proc compartion\n return nil if blk.source_location == block.source_location\n end\n hooks_for(hook_name) << block\n end",
"def hook1; end",
"def on_module_reload(mod)\n end",
"def add_module(method_hash)\n method_hash.each do |k, v|\n methods.grep(/add_#{k.to_s}_behavior/) do |name|\n v.each do |behav|\n send name.to_sym, self, behav, behav.to_s\n end\n end\n end\n end",
"def install_post_hook\n end",
"def register_handler\n @register_handler ||= Justdi::RegisterHandler\n end",
"def register_command(mod, name, trigger, types = /channel/, &p)\n raise \"Please define a block\" if not block_given?\n raise \"That command is already hooked.\" if @cmds[name]\n raise \"The module given is not a module\" if not mod.is_a?(HookService)\n\n # Ensure types is an array and is full of regex\n types = [types] if not types.is_a?(Array)\n types.map!{|x| (x.is_a? Regexp) ? x : Regexp.new(x.to_s)} # convert to rx if not already\n\n @hooks_mutex.synchronize{\n # Ensure default and register \n @cmds[name] ||= {}\n @cmds[name] = {:types => types, :trigger => trigger, :proc => p, :module => mod}\n\n # register hook or command for a given module\n @modules[mod] ||= {:hooks => [], :cmds => [], :threads => [], :threaded => mod.threaded?}\n @modules[mod][:cmds] << name\n }\n\n $log.debug \"Registered command '#{name}'\"\n end",
"def attach_hook(hook, method)\n if @hook_register[hook] != nil\n @hook_register[hook].push method\n else\n @hook_register[hook] = [method]\n end\n end",
"def around_hook(hook)\n define_method hook do |&block|\n add_hook(hook, &block)\n end\n define_method \"run_#{hook}\" do |*args, &block|\n run_around_hook(hook, *args, &block)\n end\n end",
"def register( *objects )\n objects.each do |object|\n append_hook( :owner => object, \n :trigger => YesTrigger.new, \n :action => MethodAction.new(:handle) )\n end\n end",
"def method_missing(method_name, *arguments, &block)\n # Check to see if there is a outer_profile_dsl plugin activator hook with the method name\n registry = Inspec::Plugin::V2::Registry.instance\n hook = registry.find_activators(plugin_type: :outer_profile_dsl, activator_name: method_name).first\n if hook\n # OK, load the hook if it hasn't been already. We'll then know a module,\n # which we can then inject into the context\n hook.activate\n # Inject the module's methods into the context\n # implementation_class is the field name, but this is actually a module.\n self.class.include(hook.implementation_class)\n # Now that the module is loaded, it defined one or more methods\n # (presumably the one we were looking for.)\n # We still haven't called it, so do so now.\n send(method_name, *arguments, &block)\n else\n super\n end\n end",
"def register( *objects )\n objects.each do |object|\n append_hook( :owner => object,\n :trigger => YesTrigger.new,\n :action => MethodAction.new(:handle) )\n end\n end",
"def on_module_reload(mod)\n\tend",
"def register\n self.class.definitions[name] = self\n self\n end",
"def hook_name; end",
"def add_hooks(repo, endpoint)\n hook = api.create_hook(\n repo,\n 'web',\n {\n url: endpoint,\n secret: ENV['GITHUB_SECRET_TOKEN']\n },\n {\n events: %w(push pull_request), active: true,\n }\n )\n\n yield hook.id\n rescue Octokit::UnprocessableEntity => error\n raise unless error.message.include? 'Hook already exists'\n end",
"def install_pre_hook\n end",
"def hooks\n # ???\n end",
"def register(plugin, id); end",
"def append_to_world(module_name)\n return puts 'Using RSpec, skipping world injection' if rspec?\n\n if defined?(Cucumber)\n print \"We are running cucumber, mixing #{module_name} into the [World] object!\\n\" if debug?\n @world.World(module_name)\n else\n print \"We are not running cucumber, mixing #{module_name} into an empty [$world] object!\\n\" if debug?\n $world.extend(module_name)\n end\n end",
"def AddModuleToLoad(name)\n Builtins.y2milestone(\"Adding module to be loaded at boot: %1\", name)\n @kernel_modules_to_load = Builtins.add(\n @kernel_modules_to_load,\n { \"operation\" => \"add\", \"name\" => name }\n )\n\n nil\n end",
"def InitializeHooks\n end",
"def register_service( name, &block )\n EXTERNAL_SERVICES[ name ] = block\n end",
"def add_postplay_hook(name, &f) \n @postplay_hooks_ordered_names << name\n @postplay_hooks[name] = f \n self\n end",
"def configure_hooks(hook_type, service)\n unless VALID_HOOKS.include?(hook_type)\n raise ArgumentError, \"unknown twirp hook type received: #{hook_type}\"\n end\n\n existing_hooks = instance_variable_get(\"@#{hook_type}_hooks\")\n return if existing_hooks.nil?\n\n existing_hooks.values.each do |hook|\n service.send(hook_type, &hook)\n end\n end",
"def insert_hook(label)\n @codegen.insert_hook(label)\n end",
"def method_missing(method_name, *arguments, &block)\n # Check to see if there is a control_dsl plugin activator hook with the method name\n registry = Inspec::Plugin::V2::Registry.instance\n hook = registry.find_activators(plugin_type: :control_dsl, activator_name: method_name).first\n if hook\n # OK, load the hook if it hasn't been already. We'll then know a module,\n # which we can then inject into the context\n hook.activate\n\n # Inject the module's methods into the context.\n # implementation_class is the field name, but this is actually a module.\n self.class.include(hook.implementation_class)\n # Now that the module is loaded, it defined one or more methods\n # (presumably the one we were looking for.)\n # We still haven't called it, so do so now.\n send(method_name, *arguments, &block)\n else\n # If we couldn't find a plugin to match, maybe something up above has it,\n # or maybe it is just a unknown method error.\n super\n end\n end",
"def InstallPlugin(name: nil, &proc)\n Dsl.register_rb_hook('install_plugin', [], proc, name: name)\n end",
"def enable(hook, *more_hooks)\n ([hook] + more_hooks).each { |h| @callbacks[h] ||= nil }\n end",
"def hook(type, options = {})\n options = {:for => [:match, :listen_to, :ctcp], :method => :hook}.merge(options)\n __hooks(type) << Hook.new(type, options[:for], options[:method])\n end",
"def hook(type, options = {})\n options = {:for => [:match, :listen_to, :ctcp], :method => :hook}.merge(options)\n __hooks(type) << Hook.new(type, options[:for], options[:method])\n end",
"def hook_method(callback, on:, to:, with:)\n hook = Module.new\n hook.send(:define_method, callback) { |child|\n super child\n to.send with, child\n }\n\n on.extend hook\n nil\n end",
"def pre_hook_send(handler); end",
"def subscribe_response_hook(name = SecureRandom.hex.to_sym, &block)\n EasyPost::Hooks.subscribe(:response, name, block)\n end",
"def always(&blk)\n each(&blk)\n hook(:add, &blk)\n end",
"def hook_class_name; end",
"def register(&prc)\n @eff.perform prc\n end",
"def initialize\n @hook_register = Hash.new(nil)\n @lever_register = Hash.new(nil)\n end",
"def register\n @container = Common.container\n # layer @container.layer\n layer Layer.system.current\n Common.register( self )\n self\n end",
"def add_hook(event, hook = nil, &block)\r\n hook = block if block #block has precedence\r\n raise ArgumentError, 'no hook was passed' unless hook\r\n hook = hook.to_s unless hook.respond_to?(:call)\r\n hooks[event.to_s].unshift(hook)\r\n hook\r\n end",
"def register\n @is_registered = true\n self\n end",
"def add_module(mod, name, modinfo = nil)\n\n\n\t\t# Set the module's name so that it can be referenced when\n\t\t# instances are created.\n\t\tmod.framework = framework\n\t\tmod.refname = name\n\t\tmod.file_path = ((modinfo and modinfo['files']) ? modinfo['files'][0] : nil)\n\t\tmod.orig_cls = mod\n\n\t\tif (get_hash_val(name) and get_hash_val(name) != SymbolicModule)\n\t\t\tmod_ambiguous[name] = true\n\n\t\t\twlog(\"The module #{mod.refname} is ambiguous with #{self[name].refname}.\")\n\t\telse\n\t\t\tself[name] = mod\n\t\tend\n\n\t\t# Check to see if we should update info\n\t\tnoup = true if (modinfo and modinfo['noup'])\n\n\t\t# Add this module to the module cache for this type\n\t\tframework.modules.cache_module(mod) if (noup != true)\n\t\n\t\t# Invalidate the sorted array\n\t\tinvalidate_sorted_cache\n\n\t\t# Return the modlicated instance for use\n\t\tmod\n\tend",
"def add_improvising_hook(name, &f) \n @improvising_hooks_ordered_names << name\n @improvising_hooks[name] = f\n self\n end",
"def fire(hook, *args); end",
"def register\n end",
"def add_hook_object(hook_object)\n hook_objects << hook_object\n end",
"def create_hook(lesson)\n client = github_client lesson.user\n resp = client.repos.hooks.create(*hook_params(lesson.owner, lesson.name))\n lesson.hook = resp.id\n rescue Github::Error::ServiceError => e\n Rails.logger.error 'Unable to create hook. Error was %s' % e\n end",
"def register_for(id); end",
"def register(*args)\n registry.register(*args)\n end",
"def deploy!\n # Load all the module code files.\n Dir.glob('handlers/*.rb') { |mod| load mod }\n\n RubotHandlers.constants.each do |name|\n const = RubotHandlers.const_get name\n if const.is_a? Module\n $handlers[name.to_s.downcase] = const\n end\n end\nend",
"def install!\n @method_name ||= self.name.split('::').last.downcase.to_sym\n _cls = self # for self is obscured in define_method block's body\n ( class << Vendorificator::Config ; self ; end ).\n send(:define_method, @method_name ) do |name, *args, &block|\n mod = _cls.new(name.to_s, *args, &block)\n self[:modules] << mod\n mod\n end\n end",
"def add(name, options)\n fail ArgumentError, \"A view hook '#{name}' already exists\" if @hooks[name]\n context = options.delete(:context)\n hook = @hooks[name] = Hook.new(name, context, options)\n hook.apply! if @applied\n end",
"def devise_modules_hook!; end",
"def add_hook(event_name, hook_name, callable=nil, &block)\n @hooks[event_name] ||= []\n\n # do not allow duplicates\n raise ArgumentError, \"Hook with name '#{hook_name}' already defined!\" if hook_exists?(event_name, hook_name)\n\n if block\n @hooks[event_name] << [hook_name, block]\n elsif callable\n @hooks[event_name] << [hook_name, callable]\n else\n raise ArgumentError, \"Must provide a block or callable.\"\n end\n\n self\n end",
"def run_hook!(hook, scope, example)\n hooks[hook][scope].run_all!(example)\n end",
"def provide_lever(lever, method)\n if @lever_register[lever] != nil\n @lever_register[lever].push method\n else\n @lever_register[lever] = [method]\n end\n end"
] |
[
"0.62208337",
"0.61620885",
"0.5999698",
"0.59990335",
"0.59953105",
"0.59561485",
"0.59293103",
"0.5878872",
"0.57645583",
"0.5731485",
"0.57212275",
"0.5720117",
"0.5718751",
"0.57021195",
"0.56959605",
"0.5677144",
"0.56751263",
"0.5620916",
"0.56035733",
"0.55920416",
"0.55880696",
"0.5577659",
"0.5565642",
"0.555819",
"0.5516826",
"0.5513728",
"0.5505536",
"0.5487164",
"0.54735196",
"0.54649764",
"0.5421415",
"0.54187465",
"0.54046",
"0.5400628",
"0.5395247",
"0.538771",
"0.5385987",
"0.53859377",
"0.5383964",
"0.53685266",
"0.5367028",
"0.53572035",
"0.53556204",
"0.5352421",
"0.5342728",
"0.5333164",
"0.5325654",
"0.52658296",
"0.52530795",
"0.52415925",
"0.5240868",
"0.52260756",
"0.52243686",
"0.5217053",
"0.5213677",
"0.5205056",
"0.52032316",
"0.520256",
"0.5200583",
"0.51993513",
"0.5183591",
"0.51786137",
"0.5160343",
"0.51504266",
"0.5135761",
"0.5124608",
"0.51234436",
"0.5119167",
"0.50970864",
"0.50890875",
"0.50831944",
"0.5078146",
"0.50777316",
"0.50566906",
"0.50566906",
"0.50546557",
"0.5053674",
"0.50519514",
"0.50432575",
"0.5037656",
"0.5028201",
"0.5027805",
"0.501556",
"0.5009156",
"0.49905965",
"0.49891737",
"0.49886894",
"0.4982244",
"0.49806383",
"0.49702075",
"0.4967505",
"0.4959063",
"0.49568614",
"0.49446955",
"0.49441218",
"0.4939002",
"0.49378327",
"0.49278134",
"0.49248832",
"0.49195775"
] |
0.7623903
|
0
|
Unregister all hooks and commands by unloading all modules.
|
def unregister_all(timeout = nil)
$log.debug "Unregistering all modules..."
# clone to avoid editing whilst iterating
unregister_modules(timeout, *@modules.keys.clone)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def unregister_hooks(*names)\n # Load a timeout if one is given\n names.delete(nil)\n timeout = nil\n if names and names[0].is_a?(Numeric) then\n timeout = names[0].to_f\n names = names[1..-1]\n end\n\n # Then unhook things\n @hooks_mutex.synchronize{\n names.each{|name|\n $log.debug \"Unregistering hook: #{name}...\"\n hook = @hooks.delete(name)\n\n mod = hook[:module]\n @modules[mod][:hooks].delete(name) \n cleanup_module(mod, timeout)\n }\n }\n end",
"def unregister_modules(timeout=nil, *mods)\n mods.each{|mod|\n raise \"no modules registed.\" if not @modules[mod]\n\n $log.debug \"Unregistering module: #{mod.class}...\"\n \n unregister_hooks(timeout, *@modules[mod][:hooks]) #if @modules[mod] \n # At this point @modules[mod] may have been caught in the cleanup system\n unregister_commands(timeout, *@modules[mod][:cmds]) if @modules[mod] \n }\n end",
"def unload_all\n @last_unload = []\n loaded_safe.each do |plugin|\n unload_one plugin\n @last_unload << plugin\n end\n unload_one TWG::Core\n end",
"def deregister_all(session)\n namespace = session.namespace_const\n session.modules.each do |m|\n m.deregister\n end\n session.modules = []\n @initialized = false\n true\n end",
"def unregister_all\n registry.clear.default = nil\n end",
"def unload_extensions(*exts)\r\n exts.each do |ext|\r\n sym = ext_sym(ext)\r\n obj = @extensions[sym]\r\n obj.ext_unload if obj.respond_to?(:ext_unload)\r\n obj.unload\r\n Object.send(:remove_const, sym)\r\n @extensions.delete sym\r\n end\r\n end",
"def clear_hooks\n @hook_objects = []\n end",
"def reset_hooks\n @hooks = nil\n end",
"def delete_all\n @loaded_constants.each do |const_name|\n if Object.const_defined?(const_name)\n Object.send(:remove_const, const_name)\n end\n end\n Ichiban::HTMLCompiler::Context.clear_user_defined_helpers\n end",
"def unload\n @structures = []\n @controllers = []\n @helpers = @helpers.is_a?(Array) ? @helpers.select { |h| h.options[:unloadable] == false } : []\n @authenticators = {}\n @shared_actions = {}\n @default_access = nil\n end",
"def unregister_commands(*names)\n # Load a timeout if one is given\n names.delete(nil)\n timeout = nil\n if names and names[0].is_a?(Numeric) then\n timeout = names[0].to_f\n names = names[1..-1]\n end\n\n # And then unhook things\n @hooks_mutex.synchronize{\n names.each{|name|\n $log.debug \"Unregistering command: #{name}...\"\n cmd = @cmds.delete(name)\n \n mod = cmd[:module]\n @modules[mod][:cmds].delete(name) \n cleanup_module(mod, timeout)\n }\n }\n end",
"def clear_all\n clear_modules\n end",
"def destroy_all\n destroy(load_target).tap do\n reset\n loaded!\n end\n end",
"def unregister_commands\n Bot::Commands.delete_for self\n end",
"def unregister(*extensions); end",
"def clear\n @autoloaded_classes.to_a.reverse_each do |klass|\n RubyCodeAutoreloader::ClassLoader.remove_constant(klass)\n @autoloaded_classes.delete(klass)\n end\n\n @existing_modules_before_load.clear\n @autoloaded_files = []\n ActiveSupport::DescendantsTracker.clear\n ActiveSupport::Dependencies.clear\n end",
"def clear\n @hooks.clear\n define_callbacks(@original_callbacks).clear\n self\n end",
"def reset\n @stubbed_methods.each do |object, method|\n remove_hook(object, method) \n end\n @stubbed_methods = []\n end",
"def reset\n self.hooks = {}\n end",
"def unregister_all!\n @@media_generators = []\n @@link_grabbers = []\n @@media_scrapers = []\n self\n end",
"def unregister\n Registry.unregister_loader(self)\n ExplicitNamespace.unregister_loader(self)\n end",
"def unload_scripts!\n @scripts.each do |_name, script|\n script.__send__ :unloaded if script.respond_to? :unloaded\n end.clear\n\n Blur.reset_scripts!\n end",
"def remove_all\n @registry = []\n sync\n end",
"def reset!\n @modules = []\n end",
"def remove_all_spies\n @registry.remove_all.each(&:stop)\n end",
"def unload!\n unload_resources!\n reset_menu!\n end",
"def clear_registered_linters\n registered_linters.clear\n end",
"def shutdown\n @registry.clear\n end",
"def unsubscribe_all_response_hooks\n EasyPost::Hooks.unsubscribe_all(:response)\n end",
"def unregister_all\n @@urls = {}\n @@fallback = []\n end",
"def remove_unloadable_constants!\n log(\"removing unloadable constants\")\n autoloaded_constants.each { |const| remove_constant const }\n autoloaded_constants.clear\n Reference.clear!\n explicitly_unloadable_constants.each { |const| remove_constant const }\n end",
"def remove_plugin_hooks(id)\n Hooks::Menu.remove_plugin_hooks(id)\n Hooks::View.remove_plugin_hooks(id)\n end",
"def unsubscribe_all_request_hooks\n EasyPost::Hooks.unsubscribe_all(:request)\n end",
"def unstub_all!\n @stubs.each_value do |object_stubs|\n object_stubs.each_value do |stub|\n unstub_object(stub)\n end\n end\n @stubs.clear\n end",
"def reset!\n default_tags.clear\n adapters.clear\n groups.each_key { |group| singleton_class.send(:remove_method, group) if group && respond_to?(group) }\n @groups = nil\n metrics.each_key { |metric| singleton_class.send(:remove_method, metric) if respond_to?(metric) }\n @metrics = nil\n collectors.clear\n configurators.clear\n instance_variable_set(:@configured_by, nil)\n instance_variable_set(:@debug_was_enabled_by, nil)\n end",
"def unRegisterAllService\n\t\tServiceModel.delete_all\n\tend",
"def unload\n mutex.synchronize do\n # We are going to keep track of the files that were required by our\n # autoloads to later remove them from $LOADED_FEATURES, thus making them\n # loadable by Kernel#require again.\n #\n # Directories are not stored in $LOADED_FEATURES, keeping track of files\n # is enough.\n unloaded_files = Set.new\n\n autoloads.each do |abspath, (parent, cname)|\n if parent.autoload?(cname)\n unload_autoload(parent, cname)\n else\n # Could happen if loaded with require_relative. That is unsupported,\n # and the constant path would escape unloadable_cpath? This is just\n # defensive code to clean things up as much as we are able to.\n unload_cref(parent, cname)\n unloaded_files.add(abspath) if ruby?(abspath)\n end\n end\n\n to_unload.each do |cpath, (abspath, (parent, cname))|\n # We have to check cdef? in this condition. Reason is, constants whose\n # file does not define them have to be kept in to_unload as explained\n # in the implementation of on_file_autoloaded.\n #\n # If the constant is not defined, on_unload should not be triggered\n # for it.\n if !on_unload_callbacks.empty? && cdef?(parent, cname)\n value = parent.const_get(cname)\n run_on_unload_callbacks(cpath, value, abspath)\n end\n\n unload_cref(parent, cname)\n unloaded_files.add(abspath) if ruby?(abspath)\n end\n\n unless unloaded_files.empty?\n # Bootsnap decorates Kernel#require to speed it up using a cache and\n # this optimization does not check if $LOADED_FEATURES has the file.\n #\n # To make it aware of changes, the gem defines singleton methods in\n # $LOADED_FEATURES:\n #\n # https://github.com/Shopify/bootsnap/blob/master/lib/bootsnap/load_path_cache/core_ext/loaded_features.rb\n #\n # Rails applications may depend on bootsnap, so for unloading to work\n # in that setting it is preferable that we restrict our API choice to\n # one of those methods.\n $LOADED_FEATURES.reject! { |file| unloaded_files.member?(file) }\n end\n\n autoloads.clear\n autoloaded_dirs.clear\n to_unload.clear\n lazy_subdirs.clear\n\n Registry.on_unload(self)\n ExplicitNamespace.unregister_loader(self)\n\n @setup = false\n @eager_loaded = false\n end\n end",
"def unload name\n raise \"Cannot unload: No such script #{name}\" unless @scripts.key? name\n\n @scripts[name].die if @scripts[name].respond_to? \"die\"\n\n Events.dispatch_for @scripts[name], :unloading\n\n Events.delete_for @scripts[name]\n URL.delete_for @scripts[name] if defined? MODULE_LOADED_URL_HANDLER\n RegexHandlerManager.delete_for @scripts[name] if defined? MODULE_LOADED_REGEX_HANDLER\n\n @scripts[name].unregister_script\n @scripts[name].unregister_commands\n @scripts[name].unregister_events\n\n @scripts.delete name\n end",
"def unload_plugins\n en_ete_dw_up\n tool_menu.remove(@menu_item_extract_text)\n end",
"def clear_hooks(event = nil)\r\n if event\r\n hooks.delete(event.to_s) if hooks.has_key?(event.to_s)\r\n return\r\n end\r\n\r\n hooks.clear\r\n nil\r\n end",
"def clear\n LOCK.synchronize do\n @hooks = nil\n @applied = nil\n @logger = nil\n end\n end",
"def free_resources\n\t\tunset_vim_event_hooks\n\tend",
"def remove_classes_and_modules\n initialize_classes_and_modules\n end",
"def clear_event_hooks(event_name)\n @hooks[event_name.to_s] = []\n end",
"def unmodulize_modules(*mod_consts)\n mod_consts.each { |mod_const| unmodulize *(mod_const.instance_methods) }\n end",
"def unload_target!\n listeners_for(:before_load_target).each(&:before_load_target)\n clear_dynamic_resources\n clear_dynamic_resources(:static)\n Origen::Pins.clear_pin_aliases\n $dut = nil\n end",
"def plugins_unload\n @parr = []\n @plugins = {}\n self\n end",
"def clear_callbacks!\n _callback_names.each do |callback_name|\n instance_variable_set(:\"@#{callback_name}_callbacks\", nil)\n end\n end",
"def unregister_capabilities(methods); end",
"def unload name\n raise \"Cannot unload: No such script #{name}\" unless @scripts.has_key? name\n\n @scripts[name].die if @scripts[name].respond_to? \"die\"\n\n @scripts[name].unregister_script\n @scripts[name].unregister_commands\n @scripts[name].unregister_events\n\n @scripts.delete name\n end",
"def remove\n unrealize\n remove_from_dependencies\n remove_from_dependents\n end",
"def unwatch_all\n # Remove observers for all entity types.\n @observers.each{ |observed, observer|\n observed.remove_observer(observer)\n }\n @observers.clear\n end",
"def unload\n @all = nil\n end",
"def remove_all_methods!\n instance_methods.each do |method_name|\n # Important -- we use Class#remove_method, not Class#undef_method, which does something that's different in\n # some important ways.\n remove_method(method_name) if @methods_defined[method_name.to_sym]\n end\n end",
"def __reset\n @registry.clear\n end",
"def delete_hooks(event_name)\n @hooks[event_name] = []\n end",
"def reset!\n registered_keys.each { |key| ClassConstants.new(key).deconstantize }\n @registered_keys = []\n container._container.clear\n end",
"def rm_submods\n # rm git modules\n `rm -rf .gitmodules`\n\n puts colorBlue(\"removing submodule: #{self.submods}\")\n `rm -rf #{self.submods}/.git`\n\n `git rm --cached #{self.submods}`\n end",
"def off(hook_type, name = ANY_STATE, &callback)\n sync_exclusive do\n hooks.unregister hook_type, name, callback\n end\n end",
"def clear_listeners_instances\n @@listeners = nil\n @@hook_listeners = {}\n end",
"def reset_handlers\n @handlers = nil\n end",
"def close_hooks(active_hook)\n\t\t[\"signs\",\"symptoms\",\"treatment\",\"workup\"].reject{|c| c == active_hook}.each do |hook|\n\t\t\tself.send(\"#{hook}_started=\",false)\n\t\tend\n\tend",
"def remove_all_methods!\n instance_methods.each do |method_name|\n # Important -- we use Class#remove_method, not Class#undef_method, which does something that's different in\n # some important ways.\n remove_method(method_name) if @methods_defined[method_name.to_sym]\n end\n\n @class_methods_module.instance_methods.each do |method_name|\n @class_methods_module.send(:remove_method, method_name) if @class_methods_defined[method_name]\n end\n end",
"def shutdown_all\n # TODO: implement\n shutdown\n end",
"def cleanup_hook; end",
"def clear_listeners_instances\n @@listeners = nil\n @@hook_listeners = {}\n end",
"def reset_gem_specs!\n return unless Gem.loaded_specs.keys.include?('locomotivecms_wagon')\n\n core_gems = %w(did_you_mean).freeze\n\n Gem.loaded_specs.values.each do |spec|\n next if core_gems.include?(spec.name)\n spec.full_require_paths.each do |path|\n $LOAD_PATH.delete(path)\n end\n\n # Without this statement, bundler will raise the infamous \"You have already activated ...\"\n Gem.loaded_specs.delete(spec.name)\n end\nend",
"def unobserve_all_observables\n registrations.values.dup.each do |registration|\n registration.deregister\n registrations.delete([registration.observable.object_id, registration.args])\n end\n end",
"def unregister(symbol); end",
"def unsave_module(valid_uni_module)\n uni_modules.delete(valid_uni_module)\n end",
"def clear_without_hooks\n\n @without_hooks = true\n\n clear\n \n @without_hooks = false\n \n return self\n \n end",
"def clear(name)\n @hooks[name] = {}\n end",
"def cleanup\n\t\t# If we had previously registered a console dispatcher with the console,\n\t\t# deregister it now.\n\t\tremove_console_dispatcher('DbFun')\n\tend",
"def deregister_snippets\n # Loop through all registered snippets\n @@registered.keys.each do |id|\n # Deregister the snippet view\n Hooks::View.deregister_dynamic_view(id)\n # Remove the snippet from the registered array\n @@registered.delete(id)\n end\n end",
"def reset\n reset_adapters\n reset_config\n reset_handlers\n reset_hooks\n end",
"def unregister(const)\n @@extensions.delete(const)\n end",
"def deactivate\n (self.class.deactivate_hooks + deactivate_hooks).each do |block|\n block.call self\n end\n end",
"def clear_api_stubs\n set_api_stub\n @_stub_list = {}\n api_stub_configure(@_api_stub)\n end",
"def reset_all\n clear_commands\n reset_colors\n @app_info = nil\n @app_exe = nil\n @verbose_parameters = true\n @@default_method = nil\n @@class_cache = {}\n end",
"def unload(inst)\n # If the reference count drops to zero, remove it from the list of\n # loaded plugins. This will indirectly call the cleanup method on the\n # plugin.\n if (inst.deref == true)\n delete(inst)\n end\n end",
"def clear\n @registry = {}\n end",
"def unregister(slice_module)\n if (slice = self[slice_module]) && self.paths.delete(module_name = slice.name)\n slice.loadable_files.each { |file| Merb::Slices::Loader.remove_classes_in_file file }\n Object.send(:remove_const, module_name)\n unless Object.const_defined?(module_name)\n Merb.logger.info!(\"Unregistered slice #{module_name}\")\n Merb::Slices::Loader.reload_router!\n end\n end\n end",
"def reset_engine_registrations!\n @@registered_engine_confs = {}\n end",
"def clear\n @extensions_for.clear\n end",
"def remove\n uninstall_yri\n uninstall_yard\n end",
"def unload!\n @versions = nil\n @version_json = {}\n @last_update = {}\n @maps = {}\n @mappings = nil\n end",
"def uninstall(assets); end",
"def uninstall(executable_path, base_directory = base_directory_guess, &block)\n executable_file = Pathname.new(executable_path).expand_path\n executable_name = executable_file.basename.to_s\n\n used_hook_paths(base_directory).each do |hook_path|\n hook_executable_file = hook_path + executable_name\n block.call(hook_executable_file) if block\n hook_executable_file.unlink if hook_executable_file.symlink?\n end\n end",
"def clear\n @types = nil\n @explicit = nil\n extensions.each do |extension|\n extension.clear\n end\n end",
"def delete_all_modes\n @_modes = nil\n end",
"def remove\n remove_checkpoints\n remove_config\n remove_hiera_template\n end",
"def cli_uninstall(executable_path)\n puts \"Trying to remove hook symlinks…\"\n puts\n \n uninstall(executable_path) do |hook_executable_file|\n puts \"Removing `#{hook_executable_file}`\"\n end\n\n puts\n puts \"Plugin `#{name}` uninstalled.\"\n\n exit\n end",
"def cleanup_commands\n @cleanup_commands ||= []\n end",
"def unload_reactions\n @reactor.clear if @reactor\n @reaction_files.clear if @reaction_files\n end",
"def clear_all_callbacks!\n disconnect!\n clear_callbacks!\n end",
"def reset!\n #$LOAD_STACK = []\n\n if manager = lock_load\n $LOAD_MANAGER = manager\n else\n #$LOAD_MANAGER.prime(*lookup_paths, :expound=>true)\n manager = Manager.new\n manager.prime(*lookup_paths, :expound=>true)\n $LOAD_MANAGER = manager\n end\n\n $LOAD_MANAGER << RubyLibrary.instance\n\n #if development?\n # find project root\n # if root\n # $LOAD_MANAGER.isolate_project(root)\n # end\n #end\n end",
"def destroy_all\n repositories.each {|name, repo| repo.destroy}\n end",
"def unhook(method_name)\n hooks[method_name].clear\n old_method_name = \"__#{method_name}__hooked__\"\n if private_instance_methods.include?(old_method_name)\n # Remove the block that iterates over the hooks\n remove_method method_name\n # Redirect the alias so the method points to the original method\n alias_method method_name, old_method_name\n end\n end",
"def unhook_instances!(klass, methods = :all, hooks = :all)\n methods = (methods == :all) ? INSTANCE_METHOD_HOOKS[klass].keys : (methods.is_a?(Symbol) ? [methods] : methods)\n raise ArgumentError(\"Valid arguments: :before, :after or :all\") unless [:before, :after, :all].include?(hooks)\n\n # Validate all methods exist before doing anything\n methods.each do |method|\n raise UndefinedHookException.new(\"No hook defined for instance method #{method})\") unless INSTANCE_METHOD_HOOKS[klass][method]\n end\n\n methods.each do |method|\n if hooks == :all\n klass.class_eval <<-REDEF_OLD_METHOD\n alias :\"#{method}\" :\"#{INSTANCE_HOOK_METHOD_PREFIX}#{method}\"\n undef :\"#{INSTANCE_HOOK_METHOD_PREFIX}#{method}\"\n REDEF_OLD_METHOD\n INSTANCE_METHOD_HOOKS[klass].delete(method)\n else\n unless INSTANCE_METHOD_HOOKS[klass][method][hooks]\n raise UndefinedHookException.new(\"No hook defined for instance method #{method}) at #{hooks.inspect}\")\n end\n INSTANCE_METHOD_HOOKS[klass][method].delete(hooks)\n INSTANCE_METHOD_HOOKS[klass].delete(method) if INSTANCE_METHOD_HOOKS[klass][method].empty?\n end\n end\n\n INSTANCE_METHOD_HOOKS.delete(klass) if methods == :all or (INSTANCE_METHOD_HOOKS[klass] || {}).empty?\n\n end",
"def reset!\n logs.remove\n features.remove\n users.remove\n end"
] |
[
"0.7282198",
"0.7212914",
"0.71175766",
"0.7104871",
"0.7079972",
"0.7006872",
"0.68909824",
"0.6859601",
"0.6843821",
"0.6721234",
"0.66921777",
"0.66297454",
"0.6579977",
"0.65479416",
"0.64810187",
"0.6434752",
"0.6395531",
"0.63487756",
"0.6330146",
"0.6302321",
"0.62460554",
"0.62408376",
"0.6232787",
"0.6207515",
"0.6191628",
"0.6186952",
"0.61746615",
"0.6158627",
"0.6156747",
"0.6153946",
"0.61306405",
"0.6093117",
"0.60628104",
"0.60583997",
"0.60543275",
"0.60268074",
"0.60252357",
"0.600477",
"0.6003832",
"0.599585",
"0.5987557",
"0.5986168",
"0.598198",
"0.5975392",
"0.59401137",
"0.59281796",
"0.59163123",
"0.5902757",
"0.58858",
"0.5870789",
"0.58391565",
"0.5826411",
"0.5803525",
"0.57685083",
"0.57648486",
"0.5725152",
"0.57197565",
"0.57158107",
"0.57152784",
"0.5715129",
"0.5714796",
"0.57042754",
"0.5695697",
"0.5684006",
"0.5675234",
"0.5674794",
"0.5671959",
"0.56566274",
"0.56386644",
"0.56305903",
"0.5617265",
"0.5615598",
"0.5580196",
"0.5560175",
"0.5549969",
"0.5547002",
"0.5544731",
"0.55334455",
"0.55136156",
"0.551238",
"0.5504462",
"0.5504357",
"0.549906",
"0.54921305",
"0.54905796",
"0.549055",
"0.5484139",
"0.54835767",
"0.5468312",
"0.54532075",
"0.54473627",
"0.54450244",
"0.5434129",
"0.5427565",
"0.5427071",
"0.5424205",
"0.5423882",
"0.542333",
"0.54211915",
"0.5417492"
] |
0.74080807
|
0
|
Receive a message from the HookBot. The 'bot' argument is a custom class including defaults taken from msg.
|
def dispatch(type, msg, bot)
$log.debug "Received a message of type #{type}"
type = type.to_s
if(msg and msg.message =~ COMMAND_RX) then
dispatch_command(msg, type, bot)
else
dispatch_hooks(msg, type, bot)
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def receive_msg msg\n # stub, overwrite this in your handler\n end",
"def receive_message(message)\n # Check if user send text.\n if !message.text.nil?\n model_response = send_to_api_ai(message.text)\n # Save message text from client to bot\n Message.create(message: message.text, fb_message_id: message.mid, client_id: @customer, bot: false)\n command_response = model_response[:result][:action] # accion\n message_response = model_response[:result][:fulfillment][:speech] # respuesta\n clasify_messagin(command_response, message_response)\n end\n # Check if user send attachments.\n if message.attachments.nil?\n puts message.attachments\n end\n end",
"def receive_message(message)\n end",
"def message_received(client, msg)\n content = JSON.parse msg.data\n\n kind = content['type'] || 'empty message'\n\n OutputLogger.logger.info \"Received a message of the #{kind} type.\"\n OutputLogger.logger.debug content\n\n method = \"on_#{content['type']}\"\n\n send(method, content, client) if respond_to?(method)\n end",
"def handle(msg)\n message = Remote::Message.decode(msg)\n assert_type(message)\n call_route(message)\n end",
"def did_receive_channel_message(stem, sender, channel, msg)\n end",
"def handle(msg)\n to = msg['to']\n intent = msg['intent']\n if to && intent\n begin\n # !Note that the access isn't flexible as in py and js where dotpath can be use\n reply = Module.const_get(to).method(intent).call(msg)\n if reply['to']\n $client.emit(:pass, reply)\n end\n rescue\n puts 'rb handle fails'\n end\n end\nend",
"def receive_message(message)\n # message.id => 'mid.1457764197618:41d102a3e1ae206a38'\n # message.sender => { 'id' => '1008372609250235' }\n # message.seq => 73\n # message.sent_at => 2016-04-22 21:30:36 +0200\n # message.text => 'Hello, bot!'\n # message.attachments => [{ \n # 'type' => 'image', \n # 'payload' => { \n # 'url' => 'https://www.example.com/1.jpg' }}]\n Rails.logger.debug \"receive_message()\"\n Rails.logger.debug \"text = #{message.text.inspect}\"\n Rails.logger.debug \"attachments = #{message.attachments.inspect}\"\n Rails.logger.debug \"state = \" + state.to_s\n \n # Store reference to this message\n @last_message = message\n \n # handle response by state\n case state\n when :initial # greeting\n ask_for_title\n when :title_asked # received title, ask for message\n @title = message.text\n ask_for_message\n when :message_asked # received message, ask for link\n @message = message.text\n ask_for_link\n when :link_asked # ⚠️ exception (expecting postback)\n when :image_asked # received image, ask for budget\n @image = message.attachments[0]['payload']['url']\n ask_for_budget\n when :budget_asked # ⚠️ exception (expecting postback)\n end\n \n advance! # advance to next state\n end",
"def on_message(env, msg)\n log(\"received\", msg)\n Message.new(@connection, msg).dispath\n end",
"def receive_message(opts={})\n msg = pop(opts)\n password = opts[:password]\n if msg && password\n decrypted_message = decrypt_message(msg, password)\n decrypted_message\n end\n decrypted_message || msg\n end",
"def receive_message(msg)\n speakers = get_speakers(@resource[:name])\n answer = speakers.first.send(msg)\n Puppet.debug(\"#{resource[:name]} <= #{msg} <= #{answer}\")\n answer.to_s\n end",
"def on_msg(msg)\n\n on_message(false, msg)\n end",
"def handle(msg)\n msg_obj = Octo::Message::Message.new(msg)\n msg = msg_obj.to_h\n begin\n eventName = msg[:event_name]\n if (valid_events.include?eventName)\n call_hooks(eventName, msg)\n end\n rescue Exception => e \n puts e.message\n puts e.backtrace.inspect\n end\n end",
"def receive(*ignore_args)\n thread = Thread.current\n reply = nil\n \n client.add_message_callback(0, \"receive\") do |message|\n if message.type == :chat\n reply = message.body\n thread.run\n end\n end\n Thread.stop\n \n client.delete_message_callback(\"receive\")\n reply\n end",
"def receive_object message\n transition_on_recv message_name(message), message\n end",
"def receive(message)\n info(\"[Smartfocus] Receive -> #{message}\")\n end",
"def call\n TipBot.logger.info(\"Got message: #{subject.inspect}\")\n\n process_callback_query if subject.is_a?(Telegram::Bot::Types::CallbackQuery)\n dispatch if subject.is_a?(Telegram::Bot::Types::Message)\n end",
"def personal_message(msg, cl, state)\n respond(msg, cl, \"Hi. Your message was: #{msg.inspect}\")\n respond(msg, cl, \"Body: #{msg.body.to_s}\")\nend",
"def handle_chat(msg, message)\n @user = msg.actor\n #raise \"#{self.class.name} doesn't implement `handle_chat`!\"\n end",
"def trigger_on_message(msg); @app.on_message(msg); end",
"def receive\n\n # Communicate with #run by possibly raising exceptions here.\n case (message = @strategy.receive)\n when DeadActorError\n raise message unless options(:trap_exit)\n when Stop\n raise message\n end\n\n message # Return the message\n end",
"def on_message(m)\n end",
"def did_receive_private_message(stem, sender, msg)\n end",
"def message\n lambda do |data|\n return if public_conversation?(data.channel)\n response = resp(data)\n send_response(response, data)\n end\n end",
"def receive_object message\n message.exec self \n end",
"def on_message\n websocket_client.on(:message) do |event|\n websocket_response = websocket_response_data_class.new(\n data: event.data,\n bot_params_class: bot_params_class\n )\n\n bot.handle_data(websocket_response.bot_params) do |message|\n websocket_request = websocket_request_data_class.new(message: message, data: websocket_response.bot_params)\n websocket_client.send(websocket_request.data_to_send)\n end\n end\n end",
"def on_message(content, client)\n id = content['text'].split(' ').first\n\n id.gsub!(':', '')\n\n return unless id == \"<@#{@bot_id}>\"\n\n OutputLogger.logger.info 'Message to bot detected, redirecting to bot class...'\n\n reply = Bot.process(content, @bot_id)\n\n client.send reply\n\n OutputLogger.logger.info 'Bot message replied'\n end",
"def msg(message, options = {})\n defaults = { nickname: nickname, message: message, nicknames: nicknames }\n bot_answer = nil\n brain.message(defaults.merge(options)) do |answer|\n bot_answer = answer\n end\n bot_answer\n end",
"def message(user, message, virtual = false)\n dispatch :received_message, :user => user, :message => message, :target => self unless virtual\n end",
"def argue_with_slackbot(client)\n client.on :message do |data|\n if data.user == \"USLACKBOT\"\n client.web_client.chat_postMessage(\n channel: data.channel, \n text: \"slackbot... what a dweeb.\", \n as_user: true,\n unfurl_links: false,\n unfurl_media: false\n )\n end\n end\n end",
"def message(msg)\n\t\t@messager.message(msg)\n\tend",
"def on_receive(message)\n end",
"def receive(payload)\n ChatMessage.create(user: current_user, chat_room_id: payload[\"chat_room_id\"], body: payload[\"chat_message\"])\n end",
"def reply msg\n\t\t# get message from user\n\t\trep = @@client.message(msg)\n\t\t# handle the message\n\t\tputs handle_message(rep)\n\t\t\n\t\t# interactive Wit\n\t\t#@@client.interactive(method(:handle_message))\n\tend",
"def parseMessage(msg)\n \n #\n # get args\n #\n tmp=msg.sub(/^:/,\"\").sub(/ :/,\"\\n\").split(\"\\n\")\n cmdar=tmp[0].split(\" \")\n \n if(cmdar.size>3)\n @args=cmdar[3..-1]\n unless(tmp[1].nil?)\n @args.push(tmp[1])\n end\n else\n @args=[tmp[1]]\n end\n \n #\n # get spoken by whom\n #\n if(cmdar[0]=~/(.+?)!.*/)\n @fromNick=$1\n else\n @fromNick=cmdar[0]\n end\n \n if(@fromNick.nil?)\n @command=Event::RECV_MESSAGE_BROKEN\n return\n end\n \n @fromNick.strip!\n @from=cmdar[0].downcase.strip\n \n #\n # get command or reply code\n #\n cmnd=cmdar[1].upcase.strip\n @cmndstr=cmnd\n \n @to=cmdar[2]\n unless(@to.nil?)\n @to.strip!\n if(@to.empty?)\n @to=nil\n end\n end\n \n #\n # errors or system replys are seem non-0 integer\n #\n event=cmnd.to_i\n if(event==0)\n parseCommand(cmnd,@args)\n else\n @command=event\n end\n end",
"def create_message(data)\n message = Discordrb::Message.new(data, self)\n return message if message.from_bot? && !@should_parse_self\n return message if message.webhook? && !@attributes[:webhook_commands]\n\n unless message.author\n Discordrb::LOGGER.warn(\"Received a message (#{message.inspect}) with nil author! Ignoring, please report this if you can\")\n return\n end\n\n event = CommandEvent.new(message, self)\n\n chain = trigger?(message)\n return message unless chain\n\n # Don't allow spaces between the prefix and the command\n if chain.start_with?(' ') && !@attributes[:spaces_allowed]\n debug('Chain starts with a space')\n return message\n end\n\n if chain.strip.empty?\n debug('Chain is empty')\n return message\n end\n\n execute_chain(chain, event)\n\n # Return the message so it doesn't get parsed again during the rest of the dispatch handling\n message\n end",
"def receive_msg(msg)\n if msg.command == \"CONNECTED\"\n @log.debug(\"#{self} received CONNECTED : #{msg.inspect}\")\n @connected = true\n else\n @log.debug(\"got a message: #{msg.inspect}\")\n @log.debug(\"#{self} got a message\")\n @data_received << msg # accumulate messages\n end\n end",
"def event_incoming_chat(client, msg)\nend",
"def receive_message(params={}, *attrs)\n self.class.receive_message(queue_url, params, *attrs).map do |val|\n Message.new self, val\n end\n end",
"def on_mention(&block)\n on(:message) do |data|\n debug on_message: data, bot_message: bot_message?(data)\n if !bot_message?(data) &&\n (data.text =~ /\\A(#{mention_keywords.join('|')})[\\s\\:](.*)/i ||\n data.text =~ /\\A(<@#{bot_user_id}>)[\\s\\:](.*)/) &&\n user_message?(data)\n message = $2.strip\n @last_received_user_message.merge!(message: message)\n instance_exec(@last_received_user_message, &block)\n end\n end\n end",
"def on_newmessage(time, userid, username, msg)\n end",
"def receive(data)\n puts \"messages:#{params[:room]} received #{data} from #{current_user}\"\n # we can relay the received message without the model if we want.\n # ActionCable.server.broadcast(\"messages\", data)\n end",
"def _receive_message state\n state.message_payload = _read(state.in_stream, state)\n end",
"def receive_message(ambrogio, message)\n raise NotImplementedError.new(\"A plugin should implement the receive_message method\")\n end",
"def received(message)\n if message.respond_to?(:encoding) && message.encoding != 'UTF-8'\n message.force_encoding 'UTF-8'\n end\n data = JSON.parse message, :symbolize_names => true\n\n case data[:type]\n when 'text'\n return if @nonces.include?(data[:nonce])\n @nonces << data[:nonce]\n room.message @user, data[:text], name_color, data[:client_ts]\n when 'av-invite', 'av-accept', 'av-close'\n return if @nonces.include?(data[:nonce])\n @nonces << data[:nonce]\n av_message data\n when 'sync'\n @last_event_id = data[:last_event_id].to_i\n sync_events\n when 'ping'\n respond pong: { nonce: data[:nonce], client_ts: data[:client_ts] }\n when 'relay'\n return if @nonces.include?(data[:nonce])\n @nonces << data[:nonce]\n room.relay @user, data[:to], data[:body], data[:client_ts]\n end\n end",
"def got_MSG(message)\n @logger.info(\"got_MSG()\")\n @logger.info(\"got_MSG() - #{message['message']}\")\n self.fix_skiplist(message['channel'])\n @logger.info(\"got_MSG() - fix_skiplist()\")\n self.remove_from_skip_list(message['channel'], message['character'])\n @logger.info(\"got_MSG() - remove_from_skip_list()\")\n if message['message'] == '!skip'\n self.add_to_skip_list(message['channel'], message['character'])\n elsif message['message'] =~ /^!skip/\n person = message['message'].gsub(/^!skip/, '').strip\n self.add_to_skip_list(message['channel'], person)\n elsif message['message'] =~ /^!spin/\n @logger.info(\"got_MSG() - spinning the bottle\")\n players = self.spin_list(message['channel'], message['character'])\n @logger.info(\"got_MSG() - players: #{players}\")\n if players == []\n msg = \"/me can't find anyone to play with!\"\n else\n player = players.sample\n msg = \"/me spins around, and eventually lands on [b]#{player}[/b]\"\n end\n self.send('MSG',message['channel'],msg)\n else\n @logger.info(\"gotMSG() - parseFail\")\n end\n end",
"def on_message(event)\n message = JSON.parse(event.data)\n\n if message['id']\n message['command'] = 'response_received'\n elsif message['message']\n command, *args = *message['message']\n message = {'command' => command, 'args' => args}\n end\n\n logger.debug \"Message received: #{message.inspect}\"\n dispatch(message)\n end",
"def call\n begin\n @message.payload.constantize.new(@message, @user).call\n rescue\n ReadError.new().call\n end\n end",
"def message(nickname: nil, message: nil, nicknames: nil)\n answer = false\n\n msg = Message.new(\n text: message,\n nickname: nickname,\n botname: botname,\n nicknames: nicknames,\n previous_message: previous_message,\n previous_nickname: previous_nickname\n )\n\n # Do not act or remember \"!\" commands\n return if msg.text =~ /^(#{Regexp.escape(msg.botname)} )?(!|\\/)/\n\n plugins.each do |plugin|\n answer = plugin.answer(msg)\n if answer\n yield answer\n break\n end\n end\n\n # Remember what the person said\n if answer\n @previous_message = answer\n @previous_nickname = botname\n else\n @previous_message = message\n @previous_nickname = nickname\n end\n end",
"def triggered?(msg)\n if understood?(msg)\n return reply\n end\n nil\n end",
"def messenger_received_message(message_string)\n #puts \"receive|#{message_string}\"\n begin\n message = Messages.from_json(message_string)\n rescue ProtocolError\n @scheduler.receive(:invalid_message)\n return\n end\n case message\n when Messages::CallRequest then @scheduler.receive(:call_request_message, message)\n when Messages::CallResponse then @scheduler.receive(:call_response_message, message)\n when Messages::Compatibility then @scheduler.receive(:compatibility_message, message)\n when Messages::Forget then @scheduler.receive(:forget_message, message)\n when Messages::Initialization then @scheduler.receive(:initialization_message, message)\n when Messages::Shutdown then @scheduler.receive(:shutdown_message)\n end \n end",
"def send_message(msg); end",
"def message(message)\n # message can be also accessed via instance method\n message == self.payload # true\n # store_message(message['text'])\n end",
"def chat_message(message)\n r = Skype.send_command \"CHATMESSAGE #{id} #{message}\"\n ChatMessage.parse_from(r)\n end",
"def messenger\n @messenger ||= CLIUtils::Messenger.new\n end",
"def on_incoming_message(msg)\n type = msg.operation\n debug \"(#{id}) Deliver message '#{type}': #{msg.inspect}\"\n htypes = [type, :message]\n if type == :inform\n # TODO keep converting itype is painful, need to solve this.\n if (it = msg.itype(:ruby)) # format itype as lower case string\n case it\n when \"creation_ok\"\n htypes << :create_succeeded\n when 'status'\n htypes << :inform_status\n end\n\n htypes << it.to_sym\n end\n end\n\n debug \"(#{id}) Message type '#{htypes.inspect}' (#{msg.class}:#{msg.cid})\"\n hs = htypes.map { |ht| (@handlers[ht] || {}).values }.compact.flatten\n debug \"(#{id}) Distributing message to '#{hs.inspect}'\"\n hs.each do |block|\n block.call msg\n end\n if cbk = @context2cbk[msg.cid.to_s]\n debug \"(#{id}) Distributing message to '#{cbk.inspect}'\"\n cbk[:last_used] = Time.now\n cbk[:block].call(msg)\n end\n end",
"def recvmsg(*args, &block)\n inbox.recvmsg(*args, &block)\n end",
"def message(handler)\n if handler.bot.debug\n handler.messages.each do |line|\n puts \"> #{line.raw}\"\n end\n end\n\n handler.send_raw('PONG :tmi.twitch.tv') if handler.message.ping?\n end",
"def receive_message(message)\n Pantry.logger.debug(\"[#{identity}] Received message #{message.inspect}\")\n\n if message_meant_for_us?(message)\n @last_received_message = message\n results = @commands.process(message)\n\n if message.requires_response?\n Pantry.logger.debug(\"[#{identity}] Responding with #{results.inspect}\")\n send_results_back_to_requester(message, results)\n end\n else\n Pantry.logger.debug(\"[#{identity}] Message discarded, not for us\")\n end\n end",
"def respond msg\n say \"Override #{self.class.name}.respond to have your bot do something.\"\n nil\n end",
"def receive(sms)\n sms = connection.parse(sms)\n new.receive(sms)\n end",
"def message(message)\n handler = handler_for_context\n return unless handler\n if handler.respond_to?(:call)\n instance_exec(message, &handler)\n else\n process(handler, *message['text'].split)\n end\n end",
"def message\n process_mess\n end",
"def say(msg, recipient = nil)\n recipient ||= @msg.reply_to if @msg\n @bot.msg(recipient, msg)\n end",
"def webhook\n\t\t# 學說話\n\t\tbegin\n\t\t\treply_text = command_trigger(channel_id, received_text)\n\t\trescue\n\t\t\tnil\n\t\tend\n\t\t# 關鍵字回覆\n\t\treply_text = keyword_reply(channel_id, received_text) if reply_text.nil?\n\n\t\t# 傳送訊息到 line\n\t\tresponse = reply_to_line(reply_text)\n\n\t\t# 回應 200\n\t\thead :ok\n\tend",
"def get_message\n @reply['message']\n end",
"def on_hook_log_message(args)\n @messages << args[0]\n end",
"def receive_and_decrypt_message(opts={})\n msg = pop(opts)\n unless msg.nil?\n decrypted_message = decrypt_message(msg, opts[:password])\n decrypted_message\n end\n decrypted_message || msg\n end",
"def process_message(msg)\n @current_from = nil\n @current_to = nil\n @current_msg = nil\n \n case msg\n when /^:(.+?)!(.+?)@(\\S+) PRIVMSG (\\S+) :(.+)$/\n @current_from = $1\n @current_to = $4\n @current_msg = $5.strip\n\n self.check_command_plugins(@current_msg)\n \n when /^PING (.+)$/\n @current_server.write(\"PONG #{$1}\")\n end\n end",
"def receive(message)\n info(\"[Emailvision] Receive -> #{message}\")\n end",
"def handle_input(patch, json_message, &callback)\n message_hash = JSON.parse(json_message, :symbolize_names => true)\n message = Message.new(message_hash)\n @log.puts(\"Recieved message: #{message_hash.to_json}\") if @log\n yield(message) if block_given?\n message\n end",
"def my_bot\n Discordrb::Bot.new token: @token, application_id: @app_id\n end",
"def handle_channel_message(message)\n if (match = message.match(/^:(\\w+)!.*?:(.*)$/))\n captures = match.captures\n nickname = captures[0]\n message = captures[1].chomp\n\n if mentioned?(message) && message.downcase.include?('hello')\n send_channel_message(\"Why hello there, #{nickname}!\")\n elsif (match = message.match(/^!(\\w+) ?(.*)$/))\n captures = match.captures\n command = captures[0]\n arguments = captures[1]\n\n command_method_name = \"handle_command_#{command}\"\n\n if respond_to?(command_method_name, true)\n send(command_method_name, arguments)\n end\n else\n if @quiz_running\n process_quiz_guess(nickname, message)\n end\n end\n else\n # weird stuff is happening, we'll ignore this\n end\nend",
"def process_message(msg)\n if msg =~ /^<<</\n handle_commands(msg)\n elsif msg =~ /^@\\S+/\n handle_pm(msg)\n elsif msg =~ /^\\\\/\n @server.forward(msg, self)\n else\n handle_chat_msg(msg)\n end\n end",
"def message(type, *args)\n end",
"def get_message_from_messageinfo m\n return nil if m.fake?\n @messages[m.message_id] ||= begin\n message = @context.client.load_message m.message_id\n message.parse! @context\n message.chunks.each { |c| @chunk_layouts[c] = ChunkLayout.new c }\n\n if message.unread?\n message.state -= [\"unread\"]\n @context.client.async_set_state! message.message_id, message.state\n @context.ui.broadcast :message_state, message.message_id\n end\n\n message\n end\n end",
"def handle_item(msg)\n return nil unless @options['outgoing_token'].include? msg[:token] # ensure messages are for us from slack\n return nil if msg[:user_name] == 'slackbot' # do not reply to self\n return nil unless msg[:text].is_a?(String) # skip empty messages\n\n ## loop things to look for and collect immediate responses\n ## rescue everything here so the bot keeps running even with a broken script\n responses = @regexes.map do |regex, proc|\n if mdata = msg[:text].strip.match(regex)\n begin\n Slackbotsy::Message.new(self, msg).instance_exec(mdata, &proc)\n rescue => err\n err\n end\n end\n end\n\n ## format any replies for http response\n if responses\n { text: responses.compact.join(\"\\n\") }.to_json\n end\n end",
"def on_receive(message)\n update\n end",
"def speak_messenger_old(msg, url, options)\n url ||= RedmineMessenger.settings[:messenger_url]\n return if url.blank? #|| channels.blank?\n params = { text: msg, link_names: 1 }\n username = textfield_for_project(options[:project], :messenger_username)\n params[:username] = username if username.present?\n params[:attachments] = options[:attachment]&.any? ? [options[:attachment]] : []\n icon = textfield_for_project options[:project], :messenger_icon\n if icon.present?\n if icon.start_with? ':'\n params[:icon_emoji] = icon\n else\n params[:icon_url] = icon\n end\n end\n\n #channels.each do |channel|\n uri = URI(url)\n #params[:channel] = channel\n http_options = { use_ssl: uri.scheme == 'https' }\n http_options[:verify_mode] = OpenSSL::SSL::VERIFY_NONE unless RedmineMessenger.setting?(:messenger_verify_ssl)\n begin\n req = Net::HTTP::Post.new uri\n req.set_form_data payload: params.to_json\n Net::HTTP.start(uri.hostname, uri.port, http_options) do |http|\n response = http.request req\n Rails.logger.warn(response.inspect) unless [Net::HTTPSuccess, Net::HTTPRedirection, Net::HTTPOK].include? response\n end\n rescue StandardError => e\n Rails.logger.warn \"cannot connect to #{url}\"\n Rails.logger.warn e\n end\n end",
"def received\n @received ||= message.received\n end",
"def message_class\n return Scene_Battle::Message\n end",
"def message(msg, options={})\n (@messages ||= []) << options.merge({:message => msg})\n proc_with_message(messages.last, &@message_proc) if @message_proc\n end",
"def onmessage(msg)\n Slanger::Statsd.increment(\"messages\")\n Slanger::Statsd.gauge(\"message_size\", msg.bytesize)\n\n msg = Oj.load(msg)\n\n msg[\"data\"] = Oj.load(msg[\"data\"]) if msg[\"data\"].is_a? String\n\n case msg[\"event\"]\n when /\\Aclient-/\n msg[\"socket_id\"] = socket_id\n Channel.send_client_message(msg)\n when \"pusher:ping\"\n pusher_ping(msg)\n when \"pusher:pong\"\n pusher_pong(msg)\n when \"pusher:subscribe\"\n pusher_subscribe(msg)\n when \"pusher:unsubscribe\"\n pusher_unsubscribe(msg)\n end\n rescue JSON::ParserError, Oj::ParseError\n send_error({ code: 5001, message: \"Invalid JSON\" })\n rescue Exception => e\n puts \"Error: #{e.class.name}: #{e.message}\\n#{e.backtrace.join(\"\\n\")}\"\n send_error({ code: 500, message: \"Internal Error\" })\n end",
"def did_receive_notice(stem, sender, recipient, msg)\n end",
"def on_message_data_receiving_event(ctx) end",
"def getcommand(msg)\n msg.message =~ /#{$COMMAND}(\\w+)/\n commandused = $1\n case commandused\n when 'roll', 'nobotch', 'special'\n if msg.message =~ /#{commandused}\\s*help\\s*$/\n # show command help\n \"#{HELP_TEXT(commandused)}\"\n elsif msg.message =~ /#{commandused}\\s+(.*)\\s*$/\n begin\n \"<b>#{$names[msg.actor]}: </b>#{substitute($1,commandused)}\"\n rescue ArgumentError => e\n \"\\\"<b>Error</b>: #{e}</b>\\\",#{[msg.actor]}\"\n end\n end\n \n when 'help'\n \"<br>I'm here to make your V20 playing much more pleasureable!<br><br>\n Commands:<br>\n <b>#{$COMMAND}roll</b> <input> - Regular ol' dice rollin!<br>\n <b>#{$COMMAND}nobotch</b> <input> - Roll dice where 1s don't botch!<br>\n <b>#{$COMMAND}special</b> <input> - Make those 10s count DOUBLE!<br><br>\n\n use '<b>help</b>' as the input for more information on any command!\"\n else\n #wat r u doin dolan pls\n \"wat r u doin stahp\"\n end\nend",
"def on_message(message)\n if message.is_a?(Array) && message.first == :spawn\n spawn message[1], &message[2]\n else\n # ignore\n end\n end",
"def receive_message(message, socket)\n if message == \"READ\"\n process_outbox\n return\n end\n\n if message == \"GAME_SERVER\"\n destroy_socket(socket)\n return\n end\n\n socket_id = @sockets[socket]\n log_message(\"Received message from socket #{socket_id} : #{message}\")\n pass_message(message, socket)\n end",
"def handle_message(event)\n sender = @users[event['sender']]\n timestamp = event['origin_server_ts'] || Time.now.to_i\n content = event['content']\n message = Message.new sender, timestamp, content\n broadcast(:message, @room, message)\n Events.processed event\n end",
"def got_message network, message\n puts \"← #{message.command.to_s.ljust(8, ' ')} #{message.parameters.map(&:inspect).join ' '}\" if @verbose\n\n name = :\"got_#{message.command.downcase}\"\n\n __send__ name, network, message if respond_to? name\n end",
"def add_bot_message(message)\n messages.notification.create(sender_id: User.bot_id, body: message)\n end",
"def chatroom_message(msg, cl, state)\n body = msg.body.to_s\n \n # update room status every MSGS_UNTIL_REFRESH messages\n # Use a countdown and not mod to avoid skips happenning if multiple messages come at once\n if(state[:time_until_list] <= 0)\n respond(msg, cl, \"/list\")\n state[:time_until_list] = MSGS_UNTIL_REFRESH\n else\n state[:time_until_list] -= 1\n end\n\n # redo the /list whenever anybody changes their name or joins the room\n if(/^\\'(.*)\\' is now known as \\'(.*)\\'/.match(body) ||\n /^.* has joined the channel with the alias '.*'/.match(body) )\n out(\"sending /list because of user change\")\n respond(msg, cl, \"/list\")\n return\n end\n \n # handle /list result when it comes in\n if(/^Listing members of '#{ROOM_NAME}'\\n/.match(body))\n out(\"received a room listing.\")\n listing_refresh(state, body)\n return\n end \n \n # messages starting and ending with '_' are emotes \n if body[0].chr == '_' && body[body.length - 1].chr == '_'\n chatroom_emote(msg, cl, state)\n return\n end\n\n # If someone says [word]bomb search for [word] on Google image\n # search and post the first result to the room.\n # eg: pugbomb\n if /\\w+bomb/.match(body)\n q = /(\\w+)bomb/.match(body)[1]\n uri = 'http://www.google.com/search?num=1&hl=en&safe=off&site=imghp&tbm=isch&source=hp&biw=1060&bih=669&q=' + q\n response = Net::HTTP.get_response(URI.parse(uri)) # => #<Net::HTTPOK 200 OK readbody=true>\n arr = response.body.scan(/imgurl=([^&,]+)/)\n if arr.length < 1\n respond(msg, cl, \"No results for \" + q)\n elsif\n respond(msg, cl, arr[0][0])\n end\n end\n\n # getting here means the message was a regular comment from a user\n regular_user_chatroom_message(msg, cl, state)\nend",
"def handle_message(is_bot, channel, user, text, modes=[])\n puts \"Received message from IRC: #{channel} #{user} #{text}\"\n\n HTTParty.post \"#{$config['streaming_pub']}?id=#{channel.gsub('#','')}\", {\n body: {\n text: text,\n nick: user.nick\n }.to_json,\n verify: false\n }\nend",
"def read_message\n if (line = @sock.gets and msg = IRC.parse_message(line))\n case msg.command\n when IRC::RPL_WELCOME\n i = msg.params[-1].rindex(' ') || -1\n @prefix = msg.params[-1][i + 1..-1]\n when IRC::CMD_PING\n pong(msg)\n when IRC::CMD_NICK\n # check if our nick got changed by the server\n @nickname = msg.params[0] if msg.nick == @nickname\n end\n msg\n end\n end",
"def initialize(botname, body, webhook_url=nil)\n self.botname = botname\n self.webhook_url = webhook_url\n parsed = URI.decode_www_form(body)\n parsed.each do |p|\n # puts \"#{p[0]}=#{p[1]}\"\n if p[0] == \"command\"\n self.command = p[1]\n # puts \"command=#{self.command}\"\n end\n if p[0] == \"trigger_word\"\n # This is for trigger words, not slash commands\n self.trigger_word = p[1]\n end\n if p[0] == \"channel_name\"\n self.channel = p[1]\n end\n if p[0] == \"user_name\"\n self.username = \"@#{p[1]}\"\n # puts \"username #{username}\"\n end\n if p[0] == \"text\"\n self.text = p[1].strip\n # puts \"text=#{text}\"\n end\n if p[0] == \"response_url\" && !webhook_url \n # we get it in the post body with more recent slack apps\n self.webhook_url = p[1]\n end\n end\n if self.channel == \"directmessage\"\n self.channel = self.username\n else\n self.channel = \"\\##{self.channel}\" unless self.channel[0] == '#'\n end\n\n end",
"def message(type, *args)\n case type\n when :trainer_no_money\n puts \"Du hast ja gar nicht genug Geld!!\"\n end\n end",
"def message_received(type, from, text, time = nil)\n msg = message_db.add(\n type: type,\n to: type == :message ? username : nil,\n from: from,\n text: text,\n time: time\n )\n signal_change(type, msg)\n end",
"def message_received(jid,text)\n debug \"message received from #{jid}\"\n window = message_window_for(jid)\n window.window.show\n debug \"add msg\"\n window.add_message(text)\n end",
"def process_message(msg)\n if admin && authenticated?\n Socky::Message.process(self, msg)\n else\n self.send_message \"You are not authorized to post messages\"\n end\n end",
"def receives_messages\n Messenger.resolve(@@default_messenger).add_message_handler do |message|\n new.received(message)\n end\n end"
] |
[
"0.6636218",
"0.6195777",
"0.60778636",
"0.60042053",
"0.59741753",
"0.5926893",
"0.5863052",
"0.5844815",
"0.5825211",
"0.5750855",
"0.5741626",
"0.57260656",
"0.571037",
"0.5695213",
"0.56849235",
"0.56703174",
"0.56309474",
"0.56189674",
"0.5580634",
"0.55194515",
"0.54942334",
"0.5478",
"0.54513055",
"0.5440511",
"0.5433988",
"0.5427832",
"0.5418921",
"0.5417989",
"0.53999615",
"0.5390798",
"0.538851",
"0.5387921",
"0.5384639",
"0.53725725",
"0.5355655",
"0.5324604",
"0.5317374",
"0.5310435",
"0.5306297",
"0.52937186",
"0.52924085",
"0.5261949",
"0.5261221",
"0.52183753",
"0.52153486",
"0.5208482",
"0.5198739",
"0.5177838",
"0.5169266",
"0.5167808",
"0.5165426",
"0.51575243",
"0.51502514",
"0.5135854",
"0.5133499",
"0.51332027",
"0.5114305",
"0.51109624",
"0.5107695",
"0.5107463",
"0.5098986",
"0.5096929",
"0.5094034",
"0.5090619",
"0.50852466",
"0.5078336",
"0.50748664",
"0.5070425",
"0.5069887",
"0.5069217",
"0.5064007",
"0.50622046",
"0.50478834",
"0.5047",
"0.50397587",
"0.5028526",
"0.5027248",
"0.50188726",
"0.5017864",
"0.5011844",
"0.50067765",
"0.5005527",
"0.5004188",
"0.5003839",
"0.49988607",
"0.4996667",
"0.4993112",
"0.4978726",
"0.49767247",
"0.49760368",
"0.4972498",
"0.4971674",
"0.49643084",
"0.4963557",
"0.49629936",
"0.49586117",
"0.49527845",
"0.4951777",
"0.49486402",
"0.4945131"
] |
0.605383
|
3
|
Remove any threads from the thread listing if they are not alive.
|
def purge_module_threads(mod)
return if not @modules[mod]
@modules[mod][:threads].delete_if{|t|
not t.alive?
}
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def cleanup()\n @threads.each do |name, thread| \n @threads.delete name if thread.state == :dead\n end\n end",
"def exit_cleanup()\n\n threadRelease = false\n\n while not threadRelease\n # Poll each thread until there all dead\n if @localteams.empty?\n threadRelease = true\n end\n\n @localteams.delete_if{|evThread|\n not evThread[:thr].alive?\n }\n\n end\n\n # Cleanup network namespaces; Add a single namespace to supress error if none specified\n #system(\"ip netns list | awk '{print $0;}'| xargs -L 1 ip netns delete\")\n pid = spawn(\"ip netns add occp_cleanup\")\n Process.wait pid\n pid = spawn(\"ip netns list | grep occp_ | xargs -L 1 ip netns delete\")\n Process.wait pid\n\n $log.debug 'Team threads cleanup complete'\n\n end",
"def prune\n @lock.synchronize do\n @workers.delete_if { |w| !w.alive? }\n @size = @workers.size\n end\n end",
"def kill_threads\n threads.each{|thread| thread.terminate}\n self.threads = []\n end",
"def remove_stale_cached_threads!(cache, &block)\n stale = Set.new(cache.keys)\n\n Thread.list.each do |thread|\n stale.delete(thread.object_id) if thread.alive?\n end\n\n stale.each do |thread_id|\n clear_cache!(cache, thread_id, &block)\n end\n end",
"def delete_dead_task_workers\n @task_worker_lock.synchronize do\n @task_workers.delete_if do |worker|\n not(Util.ignore_exception {timeout(1) {worker.ping}})\n end\n end\n end",
"def teardown\n Thread.list.each do |thr|\n thr.join if (thr.alive? and thr != @mthread and thr != Thread.current)\n end\n end",
"def clear_threads thread_pool, clean_array = true\n thread_pool.each{ |thread| thread.exit }\n thread_pool.clear if clean_array\nend",
"def shutdown\n @threads.each { |thread| thread.kill if thread.respond_to?(:kill) }\n @threads.map! { nil }\n end",
"def prune_dead_workers\n Worker.all.each do |worker|\n host, pid, thread, queues = worker.id.split(':')\n next unless host.include?(hostname)\n next if worker_pids.include?(pid)\n log! \"Pruning dead worker: #{worker}\"\n worker.unregister_worker\n end\n end",
"def prune_dead_workers\n Worker.all.each do |worker|\n host, pid, thread, path, queues = worker.id.split(':')\n next unless host.include?(hostname)\n next if worker_pids.include?(pid)\n log! \"Pruning dead worker: #{worker}\"\n worker.unregister_worker\n end\n end",
"def thread_cleanup\n # do nothing, i think?\n end",
"def clear()\n @mutex.synchronize {\n each_object &destroy_block\n @idle_list = []\n @active_list = {}\n }\n end",
"def update_workers\n self.workers.delete_if do |worker| \n worker_complete_statuses.include?( Sidekiq::Status::status(worker[:id]) )\n end\n end",
"def prune_dead_workers\n all_workers = self.class.all\n return if all_workers.empty?\n known_workers = JRUBY ? worker_thread_ids : []\n pids = nil, hostname = self.hostname\n all_workers.each do |worker|\n host, pid, thread, queues = self.class.split_id(worker.id)\n next if host != hostname\n next if known_workers.include?(thread) && pid == self.pid.to_s\n # NOTE: allow flexibility of running workers :\n # 1. worker might run in another JVM instance\n # 2. worker might run as a process (with MRI)\n next if (pids ||= system_pids).include?(pid)\n log! \"Pruning dead worker: #{worker}\"\n if worker.respond_to?(:unregister_worker)\n worker.unregister_worker\n else # Resque 2.x\n Registry.for(worker).unregister\n end\n end\n end",
"def prune_pool\n if Garcon.monotonic_time - @gc_interval >= @last_gc_time\n @pool.delete_if { |worker| worker.dead? }\n # send :stop for each thread over idletime\n @pool.select { |worker| @idletime != 0 &&\n Garcon.monotonic_time - @idletime > worker.last_activity\n }.each { @queue << :stop }\n @last_gc_time = Garcon.monotonic_time\n end\n end",
"def stop_threads\n @worker_threads.each do |name, t|\n puts \"Stopping thread: #{name}\"\n t.exit\n end\n end",
"def alive?; @locker.synchronize { !! @threads }; end",
"def killall\n c = Thread.critical\n return nil if @killed\n Thread.critical = true\n (@threads - [Thread.current]).each{|t| t.kill rescue nil}\n @killed = true\n ensure\n Thread.critical = c\n end",
"def clear\n\t\tmust_be_in_synchronize_block\n\t\t@collection.each_value do |server|\n\t\t\tif server.started?\n\t\t\t\tserver.stop\n\t\t\tend\n\t\tend\n\t\t@collection.clear\n\t\t@next_cleaning_time = nil\n\tend",
"def cleanup_connections\n @connections.keep_if do |thread, conns|\n thread.alive?\n end\n end",
"def cleanup_old_containers\n thread_pool = []\n Docker::Container.all(all: true).select { |c| c.info['Status'] =~ /^Exited/ }.each do |container|\n thread_pool << Thread.new do\n logger.info msg \"Removing container: #{container.info.to_json}\"\n container.remove\n end\n end\n if thread_pool.empty?\n logger.info msg \"No containers need to be cleaned up\"\n else\n logger.info msg \"Waiting for old containers to be cleaned up\"\n ThreadsWait.all_waits(*thread_pool)\n end\n end",
"def remove_stale_cached_threads!(cache, &block)\n keys = Set.new(cache.keys)\n\n ActiveRecord::ConnectionAdapters.fiber_pools.each do |pool|\n pool.busy_fibers.each_pair do |object_id, fiber|\n keys.delete(object_id)\n end\n end\n\n keys.each do |key|\n next unless cache.has_key?(key)\n block.call(key, cache[key])\n cache.delete(key)\n end\n end",
"def clean_thread_locals(thread)\n thread.keys.each do |key|\n next if key == :celluloid_queue\n\n # Ruby seems to lack an API for deleting thread locals. WTF, Ruby?\n thread[key] = nil\n end\n end",
"def no_wait_poll\n remove if can_remove_no_wait?\n end",
"def initialize\n @threads = []\n end",
"def remove_all\n @jobs.each do |job|\n job.unschedule\n end\n @@instances.delete self\n end",
"def delete_polling_thread(key)\n Thread.kill(@pool[key]) if threads_key?(key)\n @pool.delete(key)\n end",
"def stop\n @running = false\n @threads.each do |thread|\n thread.kill(5)\n thread.join\n end\n @threads = []\n end",
"def check_workers\n if @terminate\n @worker_threads.each { |t| \n t.kill\n }\n @worker_threads = []\n\n elsif @timeout\n readd = []\n while @running_queue.size > 0 && work = @running_queue.pop\n # check expiration / killing expired threads must be atomic\n # and mutually exclusive with the process of marking a job completed above\n @thread_lock.synchronize{\n if work.expired?(@timeout)\n work.thread.kill\n @worker_threads.delete(work.thread)\n launch_worker\n\n elsif !work.completed?\n readd << work\n end\n }\n end\n readd.each { |work| @running_queue << work }\n end\n end",
"def terminate_user_threads\n # Terminate all threads, ignore exceptions.\n walk_user_threads do |user_id, user_thread|\n user_thread.terminate rescue nil\n end\n\n # Wait for all threads to finish.\n walk_user_threads do |user_id, user_thread|\n user_thread.join if user_thread.alive?\n end\n end",
"def no_wait_poll\n remove if can_remove_no_wait?\n end",
"def join\n @threads.each { |t| t.join }\n @threads.clear\n end",
"def shutdown\n workers.size.times{ trim(true) }\n workers.first.join && trim(true) until workers.empty?\n mutex.synchronize{ queue.clear }\n end",
"def purge_instances!\n @@instances = [] and true\n end",
"def no_wait_poll\n remove if can_remove_no_wait?\n end",
"def list_threads\n @client.call(\"core.thread_list\")\n end",
"def prune_unwatched_repos\n gitchen_ids, github_ids = watchings.map(&:id), github_watched.map(&:id)\n\n sidekiq_logger.info { \"[#{username}] Pruning watched repos...\" }\n\n (pruned = watchings.find(gitchen_ids - github_ids)).each do |repo|\n sidekiq_logger.info { \"[#{username}] stopped watching #{repo}\" }\n end\n\n watchings.delete pruned\n\n sidekiq_logger.info { \"[#{username}] Completed pruning watched repos\" }\n end",
"def purge_expired_workers\n @services.purge_expired_workers\n end",
"def cleanup\n if running?\n logger.info \"Cleaning up agent, queue size: #{@queue.size}, thread running: #{@thread.alive?}\"\n @allow_reconnect = false\n queue_metric('exit')\n begin\n with_timeout(EXIT_FLUSH_TIMEOUT) { @thread.join }\n rescue Timeout::Error\n if @queue.size > 0\n logger.error \"Timed out working agent thread on exit, dropping #{@queue.size} metrics\"\n else\n logger.error \"Timed out PirateMetrics Agent, exiting\"\n end\n end\n end\n @thread = nil\n end",
"def suspend_all; threads.each {|x| suspend(x)}; end",
"def killall\n begin\n\t @connections.each do |k,v| \n\t v[:thread].exit! unless v[:thread].nil?\n\t v.shutdown!\n\t end\n rescue Exception\n end\n initialize\n end",
"def check_workers\n if @terminate\n @pool_lock.synchronize { \n @worker_threads.each { |t| \n t.kill\n }\n @worker_threads = []\n }\n\n elsif @timeout\n readd = []\n while @running_queue.size > 0 && work = @running_queue.pop\n if @timeout && work.handle_timeout!(@timeout)\n @pool_lock.synchronize { \n @worker_threads.delete(work.thread)\n launch_worker\n }\n elsif !work.completed?\n readd << work\n end\n end\n readd.each { |work| @running_queue << work }\n end\n end",
"def stop_workers\n for worker in workers\n for child in worker.childs\n child.die!\n end\n end\n workers.clear\n end",
"def cleanup_concurrency\n return unless @_concurrency_teardown\n concurrently(threads: 1, &@_concurrency_teardown)\n end",
"def stop_all\n checklist = registry.checked_workers( policy )\n checklist.live.each { |key| reap(key) }\n checklist.late.each { |key| reap(key) }\n checklist.hung.each { |key| reap(key) }\n checklist.dead.each { |key| reap(key) }\n end",
"def delete\n @thread.__trim_stack_to_level(@index)\n end",
"def terminate\n @running=false\n @stopping=false\n @left=[]\n while self.size>0\n @left.push self.pop\n end\n self << lambda{}\n # Pass a blank function to unblock\n # the thread so it can die.\n @left\n end",
"def threads\n @rufus ? @rufus.threads : nil\n end",
"def cleaner_thread_proc\n while true\n delete_oldies(@diff_time)\n sleep(10)\n end\n end",
"def reap_dead_workers(reason='unknown')\n if @workers.list.length > 0\n logger.error \"#{Time.now}: Reaping #{@workers.list.length} threads for slow workers because of '#{reason}'\"\n error_msg = \"Leech timed out this thread: #{reason}\"\n mark = Time.now\n @workers.list.each do |worker|\n worker[:started_on] = Time.now if not worker[:started_on]\n if mark - worker[:started_on] > @timeout + @throttle\n logger.error \"Thread #{worker.inspect} is too old, killing.\"\n worker.raise(TimeoutError.new(error_msg))\n end\n end\n end\n return @workers.list.length\n end",
"def clear\n kill\n workers.dup.each do |w|\n if w != self_slave\n remove_slave(w)\n end\n end\n end",
"def drain_queue\n @queue_threads.each do |item|\n item.join unless item.nil? || !item.alive?\n end\n nil\n end",
"def graceful_shutdown\n while reap_dead_workers(\"shutdown\") > 0\n DTR.info \"Waiting for #{workers.list.length} threads to finish, could take #{timeout} seconds.\"\n sleep timeout / 60\n end\n end",
"def reap_dead_workers(reason='unknown')\n if workers.list.length > 0\n DTR.info \"Reaping #{workers.list.length} threads because of '#{reason}'\"\n error_msg = \"#{Time.now}: WorkerClub timed out this thread: #{reason}\"\n mark = Time.now\n workers.list.each do |worker|\n worker[:started_on] = Time.now if not worker[:started_on]\n\n if mark - worker[:started_on] > timeout\n DTR.info \"Thread #{worker.inspect} is too old, killing.\"\n worker.raise(TimeoutError.new(error_msg))\n end\n end\n end\n\n return workers.list.length\n end",
"def cleaner_thread()\n return if HotConfig::TEST_MODE\n \n @log.info 'Started cleaner thread'\n\n Thread.new {\n begin\n loop do\n #@log.info 'Cleaner cleaning'\n #find all timed out\n timed_out = @data.records.find_all { |r| r.time.isover? }\n\n #remove them\n timed_out.each { |r| \n if r.state.active?\n @tables.remove(r.mac)\n r.state = HotState::PENDING\n reset_pending(r)\n \n @log.info \"Reset #{r} to PENDING\"\n else \n @data.records.delete(r)\n \n @log.info \"Cleaned #{r}\" \n end\n }\n \n save_data() if timed_out.length > 0 \n \n @log.info 'Cleaner done'\n sleep(CLEAN_INTERVAL)\n end\n catch \n @log.error \"Exception in cleaner thread: #{$!}\"\n end\n }\n end",
"def destroy_unused_machines\n available_machines.select(&:deleteable?).each do |machine|\n retired_machines.push available_machines.delete(machine)\n machine.destroy!\n end\n end",
"def stop_listening\n # Kill all threads if they're really threads\n [@ioloop_thread, @input_processor, @privmsg_processor].each {|thread| thread.terminate if Thread === thread}\n\n # Just for safety, set everything to nil\n @ioloop_thread = nil\n @input_processor = nil\n @privmsg_processor = nil\n end",
"def remove_stale_files() = stale_files.each { |file| remove_file(file) }",
"def join\n threads=@threads.dup\n # Taking a copy here is really important!\n self.decrement @thread_count\n # Stop the threads or else suffer a deadlock.\n threads.each do |t|\n debug \"joining thread #{t}\" if @debug\n t.join\n end\n end",
"def any_waiting_threads?\n waiting_threads_count >= 1\n end",
"def can_remove_no_wait?\n @queue.size > @num_waiting\n end",
"def teardown\n evicting_thread.kill\n end",
"def clear\n synchronize do\n @locks.delete(Logging::Logger.thread_name)\n end\n end",
"def reap_workers\n # Don't try to find more dead workers than the process count\n @workers.length.times do\n # We use +waitpid+ to find any child process which has exited. It\n # immediately returns when there aren't any dead processes.\n if pid = Process.waitpid(-1, Process::WNOHANG)\n despawn_worker(pid)\n else\n return # Stop when we don't find any\n end\n end\n end",
"def ending_tasks\n each_task.reject do |task|\n task.dependency_forward_any?\n end\n end",
"def allowing_other_threads; end",
"def can_remove_no_wait?\n @queue.size > @num_waiting\n end",
"def delete_polling_thread(key); end",
"def remove_inactive_spider(mutex, scheduler)\n scheduler.every '20s', first_in: '15s' do\n if mutex.try_lock\n spider_folders = Dir.children(Rails.configuration.spider[:root]) - ['.git'] - Rails.configuration.spider[:black_list]\n begin\n Spider.each do |spider|\n Rails.logger.info spider.delete if (spider.status == 'Done') && !(spider_folders.include? spider.name)\n end\n ensure\n mutex.unlock\n end\n end\n end\n end",
"def can_remove_no_wait?\n @queue.size > @num_waiting\n end",
"def destroy\n WasabbiThread.transaction do\n @wasabbi_thread = WasabbiThread.find(params[:id])\n\n if @wasabbi_thread.posts.size == 1 || wasabbi_user.mod?(@wasabbi_thread.forum)\n @wasabbi_thread.thread_list_entries.each {|tle|tle.destroy}\n @wasabbi_thread.posts.destroy_all\n @wasabbi_thread.destroy\n\n respond_to do |format|\n format.html { redirect_to(wasabbi_threads_url) }\n format.xml { head :ok }\n end\n else\n flash[:error] = \"You can't delete threads that have been replied to.\"\n\n respond_to do |format|\n format.html { redirect_to(@wasabbi_thread) }\n format.xml { render :xml => \"Can't delete threads that have been replied to.\", :status => :unprocessable_entity }\n end\n end\n end\n end",
"def inactive_cleanup\n # Finds referenced micropost from user's map and deletes itself\n user = User.find_by(:id => self.user_id)\n user.current_tasks_map = user.current_tasks_map.delete_if {|h| h[\"micropost id\"] == self.id}\n user.save\n\n # Finds and removes all associated Delayed Jobs still lurking in the system\n garbage_jobs = Delayed::Job.where(:owner_type => \"Micropost\", \n :owner_id => self.id\n )\n garbage_jobs.each do |job|\n job.delete\n end\n end",
"def worker_threads\n @workers.synchronize { @workers.size }\n end",
"def stop\n @pool.delete_if do |thread|\n thread.kill\n true\n end\n end",
"def remove_all_contexts\n previous_size = @contexts.size\n @contexts = []\n previous_size\n end",
"def purge\n t = Time.now\n expired = []\n @queue.each do |identity,worker|\n expired << identity if t > worker.expiry\n end\n expired.each do |identity|\n @queue.delete identity\n end\n end",
"def wait_for_thread(threads)\n return nil if threads == []\n # Wait for thread to finish before returning thread\n loop {threads.map {|t| return t unless t.alive?}}\nend",
"def clean_thread_locals; end",
"def shutdown_workers\n # Each worker thread will receive this exactly once!\n @worker_threads.each do |t|\n @logger.debug(\"Pushing shutdown\", :thread => t.inspect)\n @signal_queue.push(SHUTDOWN)\n end\n\n @worker_threads.each do |t|\n @logger.debug(\"Shutdown waiting for worker thread #{t}\")\n t.join\n end\n\n @filters.each(&:do_close)\n @outputs.each(&:do_close)\n end",
"def kill\n @queue_mutex.synchronize do\n if @wait_thread\n @wait_thread.kill\n @wait_thread = nil\n end\n self.delete_if { |item| true }\n end\n end",
"def discovery_thread_runner\n while running?\n tags = ImapDaemonHeartbeat.where(\"updated_at >= ?\", 30.seconds.ago).map(&:tag)\n Log.info(\"There are #{tags.count} daemons running.\")\n\n self.server_rhash.site_tags = tags\n\n if server_rhash.size == 0\n light_sleep 1\n else\n light_sleep 10\n end\n end\n rescue Exception => e\n Log.exception(e)\n raise e\n ensure\n Log.info(\"Stopping discovery thread.\")\n end",
"def removeSuccesses!\n @pages.reject! { |page, entries| entries.length == 0 }\n end",
"def empty!\n @pool_mutex.synchronize do\n @pool.each(&:finish)\n @pool = []\n end\n end",
"def stop_workers\n @resurrection_thread.kill if @resurrection_thread\n @workers.values.each(&:stop)\n true\n end",
"def destroy_all\n proxy_target.each { |queue| queue.destroy }\n true\n end",
"def kill_zombie_users(users)\n @mutex.synchronize do\n (@users - users - Set.new([@thaum_user])).each do |user|\n @users.delete(user)\n end\n end\n end",
"def clear()\n shutdown()\n @tasks = {}\n _clear()\n end",
"def clear_conditions\n Thread.current[:geotab_conditions] = {}\n end",
"def join_threads\n @worker_threads.each do |name, t|\n puts \"Joining thread: #{name}\"\n t.join\n end\n @worker_threads = {}\n end",
"def stop\n daemon_workers.each do |pid, worker_threads|\n worker_threads.each(&:kill)\n worker_threads.clear\n end\n exit\n end",
"def remove_all\n synchronized { @hash = {} }\n end",
"def shutdown\n transition :shutdown\n kill_actors\n close_comm\n NodeCache.delete @id\n MailboxManager.delete Thread.mailbox\n instance_variables.each { |iv| remove_instance_variable iv }\n end",
"def remove_dead_actors\n for battler in tactics_all\n if (battler.actor? && battler.death_state? &&\n $game_party.all_members.include?(battler) &&\n !GTBS::Prevent_Actor_Leave_List.include?(battler.id))\n $game_party.remove_actor(battler.id) \n end\n end\n end",
"def thread_cleanup(th)\n tc = tconf(th)\n tc.connections.each { |conn| close_conn(conn) }\n tc.connections.clear\n tc.stack_size = 0\n tc.dbc = nil\n\n true\n end",
"def collect!\n @thread = Thread.new do\n log_path = File.join(PROXYFS_ROOT, \"tmp/log\")\n\n loop do\n synchronize do\n dir = Dir.entries log_path\n\n files = Task.all.collect(&:file).to_set\n\n dir.each do |file|\n full_path = File.join(log_path, file)\n\n File.delete(full_path) if file !~ /^\\./ && !files.include?(file)\n end\n end\n\n sleep @@timeout\n end\n end\n end",
"def clear_all\n @status_mutex.synchronize { @statuses = {} }\n end",
"def clear_all\n @status_mutex.synchronize { @statuses = {} }\n end",
"def cleanup \n # close the sockets \n @servers.each{ |server| server[:listner].stop }\n @monitor.close\n end",
"def safe_join(threads)\n threads.each_with_object([]) do |t, errors|\n begin\n t.join\n rescue Exception => thread_error\n errors << thread_error\n end\n end\n end"
] |
[
"0.76112205",
"0.6745489",
"0.67278695",
"0.6429435",
"0.6192859",
"0.61753416",
"0.6065739",
"0.6035887",
"0.6032581",
"0.60127836",
"0.5985929",
"0.5870762",
"0.5861252",
"0.58442265",
"0.583116",
"0.58232397",
"0.5758778",
"0.5741034",
"0.5722103",
"0.56800944",
"0.565563",
"0.56351596",
"0.56318283",
"0.56087327",
"0.5600098",
"0.55913097",
"0.5583219",
"0.55821997",
"0.5579097",
"0.55726403",
"0.5567905",
"0.552881",
"0.5510708",
"0.55097526",
"0.5445045",
"0.54365295",
"0.5435871",
"0.54267395",
"0.5407514",
"0.5402955",
"0.53915256",
"0.538938",
"0.53655165",
"0.5358646",
"0.5354167",
"0.5346214",
"0.53143746",
"0.5309094",
"0.52948487",
"0.5288893",
"0.52876186",
"0.5283935",
"0.5283037",
"0.5278024",
"0.52758956",
"0.52671504",
"0.5256524",
"0.5240961",
"0.5227206",
"0.51870334",
"0.5177793",
"0.5176863",
"0.5176697",
"0.51751864",
"0.516726",
"0.51661116",
"0.51647955",
"0.5161259",
"0.51481175",
"0.51423305",
"0.51395196",
"0.51281184",
"0.51105946",
"0.5110586",
"0.5101486",
"0.5075322",
"0.50733095",
"0.50732166",
"0.5068177",
"0.50624275",
"0.5059682",
"0.50531894",
"0.5035455",
"0.50344",
"0.5025256",
"0.5023727",
"0.50159276",
"0.50152904",
"0.5014564",
"0.50109154",
"0.5007537",
"0.5001058",
"0.4998021",
"0.49959686",
"0.49867094",
"0.49731505",
"0.496762",
"0.496762",
"0.49676025",
"0.49657604"
] |
0.6377801
|
4
|
Join all threads of a given module with an overall timeout
|
def join_module_threads(threads, timeout = nil)
return if not threads
threads.each{|t|
# Keep track of time
start = Time.now
# Allow the thread to close for up to timeout seconds
t.join(timeout)
# Then subtract how long it took for the next one
timeout -= (Time.now - start)
}
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def join(timeout)\n @thread.join timeout\n end",
"def join\n @threads.each { |t| t.join }\n @threads.clear\n end",
"def join_threads\n @worker_threads.each do |name, t|\n puts \"Joining thread: #{name}\"\n t.join\n end\n @worker_threads = {}\n end",
"def join\n require \"thwait\"\n ThreadsWait.new(@event_loop).join\n end",
"def join\n @threads.each { |aThread| aThread.join }\n end",
"def join\n threads=@threads.dup\n # Taking a copy here is really important!\n self.decrement @thread_count\n # Stop the threads or else suffer a deadlock.\n threads.each do |t|\n debug \"joining thread #{t}\" if @debug\n t.join\n end\n end",
"def joinall\n @connections.each do |k,v|\n\tv[:thread].join\n end\n end",
"def join(limit = INFINITE)\n limit = limit * 1000 unless limit == INFINITE\n WaitForSingleObject(@thread, limit)\n ReleaseMutex(@@mutex) \n end",
"def join_threads\n Threaded.new map { |x| x.join.value }\n end",
"def join(sleep_seconds_before_join: 1)\n # check already existing TCPServers\n return if @tcp_servers.empty?\n # wait some seconds before joininig the upcoming threads\n # and check that all TCPServers gots one thread\n while (@tcp_server_threads.length < @tcp_servers.length) && sleep_seconds_before_join.positive?\n sleep_seconds_before_join -= 1\n sleep 1\n end\n # try to join any thread\n begin\n @tcp_server_threads.each(&:join)\n\n # catch ctrl-c to stop service\n rescue Interrupt\n end\n end",
"def join\n @thread.join\n unset_thread_task\n end",
"def worker_timeout(timeout); end",
"def join\n @listen_thread.join if @listen_thread\n sleep 0.5\n raise @thread_error if @thread_error\n end",
"def join\n @worker.join(10)\n end",
"def join(timeout: nil)\n if timeout\n if !@server_thread.join(timeout)\n raise Timeout, \"timed out while waiting for the server to stop\"\n end\n else\n @server_thread.join\n end\n end",
"def join_until_no_more_jobs\n\n @exit_when_no_more_jobs = true\n join\n end",
"def join\n @thread.join\n end",
"def join\n complete\n @threads.size.times { @inqueue.push(nil) }\n @threads.each { |thr| thr.join }\n end",
"def join\n @worker.join(SHUTDOWN_TIMEOUT)\n end",
"def join_thread\n @thread&.join\n end",
"def join\n #@pool_lock.synchronize { @worker_threads.each { |t| t.join unless @terminate } }\n # TODO protect w/ pool_lock? (causes deadlock)\n @manager_thread.join if @manager_thread\n end",
"def grab_thread_results(threads)\n # TODO: this barrier might take arbitrarily long. Mostly needed\n # for merging pruposes, but we might consider instrumenting this\n # and doing something smarter if it's a bottleneck\n start_time = Time.now.to_i\n threads.each do |thread|\n remaining_time = (@max_thread_wait_time_minutes*60) - (Time.now.to_i-start_time)\n if remaining_time < 1 then remaining_time = 1 end\n @logger.debug{\"Thread #{thread}: Remaining time: #{remaining_time}\"}\n begin \n # thread.get will throw an exception if the underlying thread\n # threw an exception during execution\n if $executor\n java_import java.util.concurrent.TimeUnit\n thread.get(remaining_time*1000, TimeUnit::MILLISECONDS) \n else \n thread.join\n end\n rescue Exception => e\n if $executor\n # Two levels of nesting to get at the real exception!\n # jruby, sometimes you do weird things...\n begin\n e = e.cause if e.cause\n e = e.cause if e.cause\n rescue Exception # catch errors this generates...\n # What errors is it generating??? That might be good to\n # know ;-)\n end\n raise e\n else\n raise e\n end\n end\n if $executor then thread.cancel(true) end # should do nothing if done, but needs to happen to free up threads otherwise\n end\n end",
"def worker_boot_timeout(timeout); end",
"def wait\n @t.each{|t| t.join}\n end",
"def wait_to_spawn_thread\n # Never spawn more than the specified maximum number of threads.\n until Thread.list.select {|thread| thread.status == \"run\"}.count <\n (1 + @options[:max_threads]) do\n # Wait 5 milliseconds before trying again.\n sleep 0.005\n end\n end",
"def join\n @thread.join\n end",
"def join\n\n @scheduler_thread.join\n end",
"def join\n @running_processes.each { |x| x.wait }\n end",
"def join()\n @scheduler.join\n end",
"def worker_shutdown_timeout(timeout); end",
"def wait_for_agent_infinite_tracer_thread_to_close\n timeout_cap(3.0) do\n while Thread.list.select{|t| t.status == \"run\"}.size > 1\n sleep(0.01)\n end\n sleep(0.01)\n end\n end",
"def soft_timeout(timeout, &block)\n t = Thread.new(&block)\n t.join(timeout) or raise Timeout::Error\n t.value\n end",
"def join\n thread && thread.join\n end",
"def join(sleep_seconds_before_join = 1)\n # check already started server\n if @tcpServerThread\n begin\n # wait a second\n sleep sleep_seconds_before_join\n # join\n @tcpServerThread.join\n\n # catch ctrl-c to stop service\n rescue Interrupt\n end\n end\n end",
"def wait_until_finished()\n\t\t\t@threads.each do |t| \n\t\t\t\tif (t.status==\"run\")\n\t\t\t\t\tt.join; # wait to finish\n\n\t\t\t\t\t# log\n\t\t\t\t\tif @logger!=nil\n\t\t\t\t\t\t@logger.debug \"action=stop|name=thread\"\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\n\t\t\t# log\n\t\t\tif @logger!=nil\n\t\t\t\t@logger.debug \"transactions=#{@transactions}|threads=#{@num_threads}|failures=#{@failures}|duration=#{Time.now - @start_time}\"\n\t\t\tend\n\t\tend",
"def join_hegemon_auto_thread\n @_hegemon_auto_thread.join if @_hegemon_auto_thread\n end",
"def wait_for_thread_pool!\n @thread_pool.join_pool_threads!\n end",
"def join()\r\n @watchThread.join() if @watchThread\r\n end",
"def join\n @server_thread.join if @server_thread\n end",
"def join\n @rufus_scheduler.join\n end",
"def join\n return if not running?\n @thread.join\n end",
"def give_others_threads_a_chance_to_run\n sleep(1/(200*1e3))\n end",
"def suspend_all; threads.each {|x| suspend(x)}; end",
"def wait_for_shutdown\n @rufus.join\n end",
"def join()\n @watchThread.join() if @watchThread\n end",
"def lock_timeout_limit=(_arg0); end",
"def wait\n @timer_thread.join\n end",
"def join\n @server_thread.join if @server_thread\n end",
"def safe_join(threads)\n threads.each_with_object([]) do |t, errors|\n begin\n t.join\n rescue Exception => thread_error\n errors << thread_error\n end\n end\n end",
"def timeout_after(time); end",
"def jobwaiting(maxjobs, verbose, jtype)\n while (get_job_count(jtype) >= maxjobs)\n ::IO.select(nil, nil, nil, 2.5)\n if verbose\n print_status('waiting for modules to finish')\n end\n end\n end",
"def run\n @threads.each(&:join)\n end",
"def timeout(args = {}, &block)\n return Knjappserver::Threadding_timeout.new({\n :kas => self,\n :block => block,\n :args => []\n }.merge(args)).start\n end",
"def shutdown_after(timeout); end",
"def join\n @cond.wait if not finished?\n end",
"def wait(timeout=60)\n countdown = timeout.to_f\n\n while countdown > 0\n if @zmq_thread and @zmq_thread.alive?\n sleep 0.1\n countdown = countdown - 0.1\n else\n break\n end\n end\n\n super()\n end",
"def lock_timeout_retries; end",
"def timeout\n exception = nil\n self.thread = Thread.new do\n begin\n yield\n rescue Exception => e\n # save exception so it can be rethrown outside of the thread\n exception = e\n end\n end\n while self.thread.join(self.timeout_period) == nil do\n if self.last_ping < Time.now - self.timeout_period\n self.terminated = true\n break\n end\n end\n raise exception if exception\n end",
"def finalize_exec\n thread_mgr.threads.each(&:join)\n end",
"def lock_timeout; end",
"def lock_timeout=(_arg0); end",
"def lock_timeout_retry_delay; end",
"def join\n raise \"No http-server or http-server not running.\" if !@httpserv or !@httpserv.thread_accept\n \n begin\n @httpserv.thread_accept.join\n @httpserv.thread_restart.join if @httpserv and @httpserv.thread_restart\n rescue Interrupt => e\n self.stop\n end\n \n if @should_restart\n loop do\n if @should_restart_done\n STDOUT.print \"Ending join because the restart is done.\\n\"\n break\n end\n \n sleep 1\n end\n end\n end",
"def work_with_multithreading(interval = 5.0, &block)\n work_without_multithreading(interval, &block)\n loop do\n #hang onto the process until all threads are done\n break if all_workers_in_pid_working.blank?\n sleep interval.to_i\n end\n end",
"def close(timeout = false)\n # Return immediately if the server isn't listening\n return unless @ml.locked?\n \n # Ask the loop to close\n @close_in.putc 'x' # Tell select to close\n\n \n # Wait for loop to end\n elapsed_time = 0\n while @ml.locked? do\n sleep(0.05)\n elapsed_time += 0.05\n\n # If a timeout is given, try killing threads at this point\n if timeout && elapsed_time > timeout\n @clients.each {|id, thread| thread.kill() }\n end\n end\n end",
"def lock_timeout_retry_delay=(_arg0); end",
"def shutdown(timeout: nil)\n lock do\n @keep_running = false\n @condition.signal\n end\n\n @thread.join\n force_flush\n @exporter.shutdown\n end",
"def join_async_world\n ap4r_helper.wait_all_done\n end",
"def terminate_timeout\n workers.map(&:stop_timeout).compact.max.to_i + 10\n end",
"def lock_timeout(duration:)\n add option: \"-lock-timeout=#{duration}\"\n end",
"def purge_module_threads(mod)\n return if not @modules[mod]\n\n @modules[mod][:threads].delete_if{|t| \n not t.alive?\n } \n end",
"def run_pool(&block)\n (1..workers).map { Thread.new(&block) }.each(&:join)\n end",
"def close(timeout=10)\n # Prevent any new connections from being handed out\n self.pool_size = 0\n start_time = Time.now\n while (Time.now - start_time) < timeout\n sleep 1\n @mutex.synchronize do\n return if @connections.empty?\n @logger.info \"#{@name}: Waiting to close, #{@connections.size} connections are still in use\"\n end\n end\n @logger.warn \"#{@name}: Timed out while waiting to close, #{@connections.size} connections are still in use\"\n end",
"def graceful_shutdown\n while reap_dead_workers(\"shutdown\") > 0\n DTR.info \"Waiting for #{workers.list.length} threads to finish, could take #{timeout} seconds.\"\n sleep timeout / 60\n end\n end",
"def join\n wait_for_completion\n update_nodes\n end",
"def join_reading_thread\n @reading_thread.join \n end",
"def sleep(timeout = nil)\n unlock\n begin\n timeout ? Kernel.sleep(timeout) : Kernel.sleep\n ensure\n lock\n end\n end",
"def join\n @executions.each do |execution|\n execution.join\n end\n end",
"def checkTimeout_Flooding()\n\tsleep(2);\n\tputs \"time out!\";\n\n\nend",
"def timeout!(*args, &block)\n Timeout::timeout(*args, &block)\n end",
"def use_global_timeout(shutdown_time=60)\n main_thread = Thread.current\n main_thread.abort_on_exception = true\n timeout_thread = Thread.new do\n sleep_duration = ENV.fetch('TESTBRAIN_TIMEOUT', '600').to_i - shutdown_time\n begin\n sleep sleep_duration\n rescue => e\n # Main thread terminated or other unexpected exception\n main_thread.raise e\n else\n # Timeout reached\n puts \"\\e[0;1;31mGlobal timeout triggered at #{DateTime.now}\\e[0m\"\n main_thread.raise Timeout::Error, \"timeout reached after #{sleep_duration} seconds\"\n end\n end\n at_exit do\n begin\n timeout_thread.kill\n timeout_thread.join\n rescue => e\n # Ignore any errors trying to shut down the timeout thread\n end\n end\nend",
"def lock_timeout_retries=(_arg0); end",
"def finalize\n # if defined?( SystemTimer )\n # count = 0\n # begin\n # count += 1\n # SystemTimer.timeout_after( 30 ) do\n # multi_curb.perform\n # end\n # rescue Timeout::Error \n # retry unless count > 2\n # end\n # else\n multi_curb.perform\n # end\n end",
"def wait_for_thread(th_name)\n\n Thread.list.each {|t|\n if t[:thread_method_name].to_s == th_name\n $test_logger.log(\"Waiting for #{th_name} thread..\")\n #Wait for thread to exit\n t.join\n $test_logger.log(\"#{th_name} thread completed!\")\n end\n }\n end",
"def join\n @manager_thread.join if @manager_thread\n self\n end",
"def test_handles_multiple_threads\n threads = CW::Threads.new(self, [:a_thread, :sleep_thread])\n threads.start_threads\n assert threads.threads[0][:thread].is_a? Thread\n assert threads.threads[1][:thread].is_a? Thread\n assert_nil threads.threads[2]\n end",
"def safe_thread_join(threads)\n error = nil\n\n threads.each do |t|\n begin\n t.join\n rescue Exception => thread_error\n error = thread_error\n end\n end\n\n raise error if error\n end",
"def wait_for(interests, opts={})\n\n @waiting << [ Thread.current, interests ]\n\n Thread.current['__result__'] = nil\n start = Time.now\n\n to = opts[:timeout] || @timeout\n to = nil if to.nil? || to <= 0\n\n loop do\n\n raise(\n Ruote::LoggerTimeout.new(interests, to)\n ) if to && (Time.now - start) > to\n\n @mutex.synchronize { check_waiting }\n\n break if Thread.current['__result__']\n\n sleep 0.007\n end\n\n Thread.current['__result__']\n end",
"def stop(join_timeout: 10)\n EventMachine.next_tick { @server.stop! }\n if join_timeout != 0\n join(timeout: join_timeout)\n end\n end",
"def waitall\n block = false\n size = @mtx.synchronize {\n if @open\n @open = false\n block = true\n end\n @threads.size\n }\n if block\n yield size\n @threads.each { |t| t.join }\n #at this point, all threads are finished.\n if @failures.each { |f| $stderr.puts f }.size > 0\n raise \"There were failures\"\n end\n end\n size\n end",
"def threads\n raise CapabilitiesExceeded\n end",
"def join\n @poller.join if @poller\n end",
"def sleep_loop\n (1..30).each { |_| some_method }\n end",
"def shutdown(timeout = 300)\n @running = false\n @thread.join(timeout) if @thread and @thread.alive?\n end",
"def timeout!; end",
"def shutdown(timeout=10)\n @pool.close(timeout)\n end",
"def wait(timeout = nil)\n @threads.wait_for_termination(timeout)\n Disquo.logger.info \"Worker shutdown complete\"\n end",
"def initialize_timeout(thread)\n #Thread to stop the execution after timeout time\n Thread.start(thread) do |thr|\n sleep(VM_TIMEOUT + 3) #add a little because normaly vm triggers timeout\n if thr.alive?\n puts 'kill'\n thr.kill\n exit_simulation!('Ausführungszeit wurde überschritten.')\n @packet.send_packet\n end\n end\nend",
"def timeout(seconds, &block)\n Timeout.timeout seconds, Pinglish::TooLong, &block\n end",
"def wait_and_proceed\n Thread.new do\n sleep TIMEOUT\n proceed\n end\n end"
] |
[
"0.69774336",
"0.6723436",
"0.6447908",
"0.6335663",
"0.6331302",
"0.6317171",
"0.6242954",
"0.62136984",
"0.6190614",
"0.61132056",
"0.61046004",
"0.60708666",
"0.60655725",
"0.6061742",
"0.60146165",
"0.5878396",
"0.5857489",
"0.5849045",
"0.58001727",
"0.575175",
"0.57497483",
"0.5743777",
"0.57247794",
"0.57082295",
"0.5694575",
"0.56818324",
"0.5671887",
"0.5657068",
"0.5615234",
"0.5610823",
"0.5603948",
"0.5591873",
"0.55908084",
"0.5587959",
"0.552856",
"0.5528256",
"0.55233705",
"0.5502137",
"0.548175",
"0.5464502",
"0.5428134",
"0.53803825",
"0.53781986",
"0.5377406",
"0.5370414",
"0.5358911",
"0.53523713",
"0.53499967",
"0.5346269",
"0.5336827",
"0.5334372",
"0.53309727",
"0.53225774",
"0.5307465",
"0.5304608",
"0.52999806",
"0.52843654",
"0.5273541",
"0.5266126",
"0.52548313",
"0.5236877",
"0.5231798",
"0.52296025",
"0.5227846",
"0.52210784",
"0.52151304",
"0.5214484",
"0.52128696",
"0.52043587",
"0.51846546",
"0.5159751",
"0.5158178",
"0.5147631",
"0.51438904",
"0.51436216",
"0.51424384",
"0.51363933",
"0.5127913",
"0.5127302",
"0.51179653",
"0.5111818",
"0.5104573",
"0.50945306",
"0.5092748",
"0.5087838",
"0.5085563",
"0.5082558",
"0.5075887",
"0.50695634",
"0.5068421",
"0.5062363",
"0.5058927",
"0.5054513",
"0.50540805",
"0.50525504",
"0.50443137",
"0.503247",
"0.50245535",
"0.5017753",
"0.5015215"
] |
0.8145977
|
0
|
Dispatch things to hooks
|
def dispatch_hooks(msg, type, bot)
return if @hooks.length == 0
@hooks_mutex.synchronize{
@hooks.each{|name, hook|
types, trigger, p, mod, mod_info = hook[:types], hook[:trigger], hook[:proc], hook[:module], @modules[hook[:module]]
# Go through and kill any old threads,
purge_module_threads(mod)
# If the module is not threaded, we must find the current
# thread in order to let it finish before starting a new one
thread_to_await = mod_info[:threads][0] if not mod_info[:threaded]
# Check types match the rx
types.each{|type_trigger|
if type_trigger.match(type) then
$log.debug "Inspecting hook '#{name}' for module #{mod.class} (threaded? #{mod_info[:threaded]}) [#{trigger.call(msg)}]"
begin
# Check the hook trigger works if it's of the right type
if(trigger.call(msg)) then
# Then invoke
raise "Too many active threads for module: #{mod_info[:name]}." if mod_info[:threads].length > MAX_MODULE_THREADS
$log.debug "Dispatching hook '#{name}'..."
mod_info[:threads] << invoke(prepare_vars(bot, msg, name), p, [], thread_to_await)
$log.debug "Running hook #{name}: #{mod_info[:threads].length}/#{MAX_MODULE_THREADS} threads."
end
rescue Exception => e
$log.error "Error in callback '#{name}' => #{e}"
$log.debug "Backtrace: #{e.backtrace.join("\n")}"
end
end
} # /types.each
} # /@hooks.each
} # /synchronize
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def perform_hooks!\n @perform_hooks = true\n end",
"def hooks\n # ???\n end",
"def fire(hook, *args); end",
"def hook1; end",
"def pre_hook_send(handler); end",
"def action_hook; end",
"def around_hooks; end",
"def perform\n\n begin\n\n # acquire lock and fetch the locked hooks\n fetch_hooks_to_be_processed\n\n # Process these Hooks\n process_hooks\n\n # Mark Hooks as processed\n update_status_to_processed\n\n rescue StandardError => se\n\n @hooks_to_be_processed.each do |hook|\n hook_id = hook.id\n # Skip if we already know that his hook was processed or failed\n next if @success_responses[hook_id].present? ||\n @failed_hook_to_be_ignored[hook_id].present? ||\n @failed_hook_to_be_retried[hook_id].present?\n @failed_hook_to_be_retried[hook_id] = {\n exception: {message: se.message, trace: se.backtrace}\n }\n end\n\n ensure\n\n # For hooks which failed, mark them as failed\n release_lock_and_update_status_for_non_processed_hooks\n\n # Notify Devs in case on Errors\n notify_devs\n\n success_with_data(processor_response)\n\n end\n\n end",
"def run_hook hook, *data\n\t\t\tr = [@delegates, @hero, current_encounter, @weapons, @brags].flatten.compact.map do |obj| \n\t\t\t\tobj.call_hook(hook, self, current_encounter, *data)\n\t\t\tend.flatten.select { |v| v }\n\n\t\t\tr.each { |v| must_decide(v) if v.is_a?(Decision) }\n\n\t\t\tr\n\t\tend",
"def hook_run\n\trun_hook = {\n\t :return => :execute\n\t}\n\tmake_magic_hooks(run_hook)\n end",
"def perform_hook action, html\n\n # => Filter/Action\n # => This is designed to figure out whether it's a filter or action being declared\n method_name = __callee__\n\n # => Fire Hook\n # => These fire for whichever the user has defined\n case action.to_sym\n when :pre_render\n output = liquid html, layout: :application, locals: { app: AppDrop.new, user: (UserDrop.new(current_user) if current_user), flash: (FlashDrop.new(flash) if flash.keys.any?) }\n end\n\n # => Fire other hooks\n # => This allows us to iterate over the various hooks that exist\n if settings.hooks[action.to_s]\n settings.hooks[action.to_s].sort_by(&:priority).each do |hook|\n (method_name.to_s.include?('filter')) ? output = hook.function.call(output) : hook.function.call(output)\n end\n end\n\n # => Return\n # => This returns outputted data to the main script\n return output\n\n end",
"def apply_hooks\n\n @hooks.each do |hook|\n \n hook_output = nil\n\n if hook.is_a?(Proc)\n hook_output = hook.call\n elsif hook.is_a?(Symbol)\n hook_output = eval(hook.to_s) # run the symbol\n elsif hook.is_a?(Hash)\n hook_output = hook # hash already? assign to output\n end\n\n @output.merge!(hook_output) if hook_output && hook_output.is_a?(Hash)\n\n\n end unless @hooks.empty?\n\n end",
"def hook(id, params={})\n\t\t\t\tparams[:self] = self\n\t\t\t\tself.class.hooks.execute id, params\n\t\t\tend",
"def define_action_hook; end",
"def _dispatch(action=:to_s)\n hook :before_dispatch\n self.action_name = action\n \n caught = catch(:halt) do\n start = Time.now\n result = _call_filters(_before_filters.reverse)\n @_benchmarks[:before_filters_time] = Time.now - start if _before_filters\n result\n end\n \n @body = case caught\n when :filter_chain_completed then _call_action(action_name)\n when String then caught\n when nil then _filters_halted\n when Symbol then send(caught)\n when Proc then caught.call(self)\n else\n raise MerbControllerError, \"The before filter chain is broken dude. wtf?\"\n end\n start = Time.now\n _call_filters(_after_filters) \n @_benchmarks[:after_filters_time] = Time.now - start if _after_filters\n hook :after_dispatch\n end",
"def process_hooks(timing, args={})\n Rails.application.config.sparkle[:builder][:hooks][action_name][timing].each do |callback|\n callback.call(args)\n end\n end",
"def hooks\n EMPTY_HOOKS\n end",
"def run_actions; end",
"def _work(context)\n # pre step hook\n ret = work(context)\n # post step hook\n ret\n end",
"def process_hooks\n @hooks_to_be_processed.each do |hook|\n begin\n @hook = hook\n process_hook\n rescue StandardError => se\n @failed_hook_to_be_retried[@hook.id] = {\n exception: {\n message: se.message,\n trace: se.backtrace[0..10]\n }\n }\n end\n end\n end",
"def around_hooks(job)\n get_hook_names(job, 'around_perform')\n end",
"def InitializeHooks\n end",
"def hook(&block)\n @hooks << block\n end",
"def post_hooks\n @to_perform.map do |hook|\n next unless hook.type.eql? :post\n hook\n end.compact\n end",
"def call_with_hooks(*args)\n self.class.hooks[:before].each do |block|\n instance_exec(*args, &block)\n end\n\n ret = call(*args)\n\n self.class.hooks[:after].each do |block|\n ret = instance_exec(*args, &block)\n end\n\n ret\n end",
"def apply_hooks(hooks, tuples, *args)\n hooks.reduce(tuples) do |a, e|\n if e.is_a?(Hash)\n hook_meth, hook_args = e.to_a.flatten(1)\n __send__(hook_meth, a, *args, **hook_args)\n else\n __send__(e, a, *args)\n end\n end\n end",
"def run_after_instance_hooks(hook)\n instance_hooks(hook).each{|b| b.call}\n end",
"def def_hooks(*events)\r\n events.each { |event| def_hook(event) }\r\n end",
"def dispatched!\n update dispatched: true\n end",
"def run_hooks\n run_hook\n run_hook(Terraspace.env)\n end",
"def dispatch\n Engine.instance.dispatch([self])\n end",
"def execute_hooks_for(type, name)\n model.hooks[name][type].each { |hook| hook.call(self) }\n end",
"def hook\n self.class.hook\n end",
"def dispatch!\n \n # negotiates initial configuration\n @meta = self.negotiate!\n \n # dispatches hash set to the server\n self.dispatch_hashing!\n self.dispatch_hashset!\n \n # dispatches orders\n self.dispatch_orders!\n \n # dispatches messages\n self.handle_messages!\n \n end",
"def apply!\n @hooks.values.each(&:apply!)\n @applied = true\n end",
"def around_hook(hook)\n define_method hook do |&block|\n add_hook(hook, &block)\n end\n define_method \"run_#{hook}\" do |*args, &block|\n run_around_hook(hook, *args, &block)\n end\n end",
"def process_hook\n fail 'sub class to implement'\n end",
"def do_all_hook( *args )\n @nesting_level += 1\n# TODO continue\n#\t\t$this->iterations[ $nesting_level ] = array_keys( $this->callbacks );\n#\n#\t\tdo {\n#\t\t\t$priority = current( $this->iterations[ $nesting_level ] );\n#\t\t\tforeach ( $this->callbacks[ $priority ] as $the_ ) {\n#\t\t\t\tcall_user_func_array( $the_['function'], $args );\n#\t\t\t}\n#\t\t} while ( false !== next( $this->iterations[ $nesting_level ] ) );\n#\n#\t\tunset( $this->iterations[ $nesting_level ] );\n @nesting_level -= 1\n end",
"def trigger hook, *args\n return unless self.class.hooks[hook]\n self.class.hooks[hook].each do |block|\n instance_exec(*args, &block)\n end\n end",
"def _dispatch(action)\n _run_filters(:before, action)\n response = send(action)\n _run_filters(:after, action)\n response\n end",
"def proceed\n hook = hooks[@hook_index]\n # -- If no more hook was found, calls target procedure and return\n hook or return self.returned = target_proc.call(*args, &block)\n # -- Set hook pointer to next, then call next hook\n @hook_index += 1\n begin\n self.returned = hook.call(self)\n ensure\n @hook_index -= 1\n end\n end",
"def call\n hooks.run(self, :before, :all, it_scope)\n yield\n hooks.run(self, :after, :all, it_scope)\n end",
"def run!\n before_run\n\n HANDLER_CALLS.each { |c|\n if (h = @handlers[c])\n send(c, *(h.opts)) do |obj|\n h.call(obj)\n end\n end\n }\n\n after_run\n end",
"def run!\n before_run\n\n HANDLER_CALLS.each { |c|\n if (h = @handlers[c])\n send(c, *(h.opts)) do |obj|\n h.call(obj)\n end\n end\n }\n\n after_run\n end",
"def fetch_hooks_to_be_processed\n acquire_lock\n fetch_locked_hooks\n end",
"def run_hook(name, *args, &block)\n if callbacks = hooks[name.to_sym]\n callbacks.each{ |c| c.call(*args, &block) }\n else\n yield if block\n end\n end",
"def enabled_ad_hoc_hooks(hook_context); end",
"def dispatch(*_arg0); end",
"def nested_around_hooks\n final_hook = lambda { perform_job }\n hooks[:around].reverse.inject(final_hook) do |last_hook, hook|\n lambda { perform_hook(hook) { last_hook.call } }\n end\n end",
"def process_hooks(user, actual_targets)\n exec_hooks(Move, :process_hooks, binding)\n return true\n end",
"def call_hook(before, ok)\n logger.debug(\"call_hook: #{before} #{ok}\")\n end",
"def _perform(args); end",
"def post_perform!\n return unless perform_hooks?\n unless hooks.post_hooks.any?\n GitPusshuTen::Log.message \"No post deploy hooks to perform.\"\n return\n end\n \n ##\n # Connect to the remote environment and perform the post deploy hooks\n hooks.render_commands(hooks.post_hooks).each do |name, commands|\n adjusted_name = name.sub(/^\\d+\\)\\s/, '')\n \n GitPusshuTen::Log.message(\"Performing post deploy hook: #{y(adjusted_name)}\")\n standard environment.execute_as_user(\"cd '#{e.app_dir}'; #{commands}\")\n end\n end",
"def call_hook(hook, context={})\n template = context[:controller].instance_variable_get('@template')\n returning [] do |response|\n hls = hook_listeners(hook)\n if hls.any?\n hls.each {|listener| response << listener.send(hook, template)}\n end\n end\n end",
"def exec_hook(name, *args, &block)\n @hooks[name] ||= {}\n Hash[@hooks[name].each.map { |k, v| [k, v.call(*args, &block)] }]\n end",
"def hook_name; end",
"def dispatch(&block)\n @engine.dispatch(&block)\n end",
"def hooks\n @hooks ||= []\n end",
"def call_hook(hook, context={})\n [].tap do |response|\n hls = hook_listeners(hook)\n if hls.any?\n hls.each { |listener| response << listener.send(hook, context) }\n end\n end\n end",
"def process_action(...)\n send_action(...)\n end",
"def run_after_each_hooks( env, result )\n hooks = env[:hooks][:after_each]\n hooks += env[:hooks][:after_status][result.status].to_a # .to_a in case it's nil\n hooks.each { |hook| hook.call(result) }\n end",
"def call_dispatchers(payload)\n dispatchers.each do |dispatcher|\n dispatcher.call(payload)\n end\n end",
"def call_hook(hook_name, context, *params)\n context.send(hook_name, *params) if context.respond_to? hook_name\n end",
"def execute_hook(context, stack_frame, before, ok)\n logger.debug(\"execute_hook: #{before} #{ok}\")\n end",
"def dispatch(&block)\n @dispatch_block = block\n end",
"def before_dispatch(env); end",
"def run_after_all_hooks( env, results )\n env[:hooks][:after_all].each { |hook| hook.call(results) }\n end",
"def perform_action(data); end",
"def run_hook!(hook, scope, example)\n hooks[hook][scope].run_all!(example)\n end",
"def setup()\n \n # validates the hook token\n beef_hook = @data['beefhook'] || nil \n if beef_hook.nil?\n print_error \"[EVENTS] beef_hook is null\"\n return\n end\n\n # validates that a hooked browser with the beef_hook token exists in the db\n zombie = Z.first(:session => beef_hook) || nil\n if zombie.nil?\n print_error \"[EVENTS] Invalid beef hook id: the hooked browser cannot be found in the database\"\n return\n end\n \n events = @data['results']\n\n # push events to logger\n if (events.kind_of?(Array))\n logger = BeEF::Core::Logger.instance\n events.each{|e|\n logger.register('Event', parse(e), zombie.id)\n }\n end\n\n end",
"def pre_hooks\n @to_perform.map do |hook|\n next unless hook.type.eql? :pre\n hook\n end.compact\n end",
"def after_products\n logger.info 'Heyy!! This is a controller hook provided by sweeper'\n end",
"def hook(&block)\n @hook = block if block_given?\n @hook\nend",
"def handlers; end",
"def handlers; end",
"def handlers; end",
"def install_post_hook\n end",
"def post_process\n end",
"def before_processing_hook(msg, connection)\n original_action = request.action\n task = request[:task]\n\n begin\n if [\"run_and_wait\", \"run_no_wait\"].include?(original_action) && task\n request.action = task\n\n begin\n authorization_hook(request) if respond_to?(\"authorization_hook\")\n rescue\n raise(RPCAborted, \"You are not authorized to run Bolt Task %s\" % task)\n end\n\n audit_request(request, connection)\n end\n ensure\n request.action = original_action\n end\n end",
"def execute_hook(event_name, args)\n @hook_manager.exec_hook(event_name, args)\n end",
"def execute_hook(command); end",
"def run_hook_if_present(hook)\n return unless hook\n if hook.respond_to?(:call)\n hook.call(self)\n else\n self.send(hook)\n end\n end",
"def execute!\n @actions.each do |action|\n action.call\n end\n end",
"def hook(name, *args)\n name = ('hook_' + name.to_s).to_sym\n send name, *args if respond_to? name\n end",
"def process(action, *args); end",
"def after_processing_hook; end",
"def post_execute(&block)\n @hooks[:post_execute] = block\n end",
"def hook(name, &blk)\n @hooks[name.to_sym] ||= []\n @hooks[name.to_sym] << blk\n self\n end",
"def _dispatch\n case @options[:action]\n when :init\n _init\n when :add\n fail 'No url given (-u option)' if @options[:url].empty?\n fail 'No name given (-n option)' if @options[:name].empty?\n _add\n when :delete\n fail 'No id given (-i option)' if @options[:id].nil?\n _delete\n when :list\n _list\n else\n fail \"Unknown action #{@options[:action]}\"\n end\n end",
"def add(*hooks)\n @hooks.push(*hooks)\n\n hooks.map(&:object).uniq.each do |object|\n @original_callbacks[object] = proceed(object) unless proceeded?(object)\n end\n\n self\n end",
"def post_process; end",
"def process_hook\n fail 'child class to implement'\n end",
"def install_dispatch(mod)\n # THREAD CRITICAL BEGIN\n unless @dispatch[mod]\n @dispatch[mod] = true\n # $stderr.puts \"install_dispatch(#{name}) into #{mod}\\n\";\n mod.class_eval(body = <<-\"end_eval\", __FILE__, __LINE__)\ndef #{name}(*args)\n ::#{table.class.name}.instance.dispatch(#{name.inspect}, self, args)\nend\nend_eval\n# $stderr.puts \"install_dispatch = #{body}\"\n end\n # THREAD CRITICAL END\n end",
"def prepare_hooks(kind, command)\n hooks = callable_hooks(kind, command)\n return hooks unless kind == :around\n\n around_proc = hooks.reverse.reduce(command) do |callable, hook|\n -> { hook.call(callable) }\n end\n [around_proc]\n end",
"def hooks\n @hooks = Hook.all\n end",
"def process_action(method_name, *args); end",
"def hook_result(messages); end",
"def pre_perform!\n return unless perform_hooks?\n unless hooks.pre_hooks.any?\n GitPusshuTen::Log.message \"No pre deploy hooks to perform.\"\n return\n end\n \n ##\n # Connect to the remote environment and perform the pre deploy hooks\n hooks.render_commands(hooks.pre_hooks).each do |name, commands|\n adjusted_name = name.sub(/^\\d+\\)\\s/, '')\n \n GitPusshuTen::Log.message(\"Performing pre deploy hook: #{y(adjusted_name)}\")\n standard environment.execute_as_user(\"cd '#{e.app_dir}'; #{commands}\")\n end\n end",
"def run_hook(hook, scope, example=nil)\n hooks[hook][scope].run_all(example)\n end",
"def dispatch\n raise NotImplementedError\n end"
] |
[
"0.70549625",
"0.69858056",
"0.6834492",
"0.67891943",
"0.66985357",
"0.6669872",
"0.66516715",
"0.6519832",
"0.6518559",
"0.6513162",
"0.6478594",
"0.64385027",
"0.64381707",
"0.6407273",
"0.63715243",
"0.63507575",
"0.6339826",
"0.63356465",
"0.63339627",
"0.63265985",
"0.63077646",
"0.6251476",
"0.62448853",
"0.62221897",
"0.62218326",
"0.6221346",
"0.62171346",
"0.6205053",
"0.6195023",
"0.6193725",
"0.61920846",
"0.6186036",
"0.61657196",
"0.6148188",
"0.6146213",
"0.6133836",
"0.61203945",
"0.6099171",
"0.60892403",
"0.6084306",
"0.60679036",
"0.6037982",
"0.60314935",
"0.60314935",
"0.5975727",
"0.5925865",
"0.5912147",
"0.59083325",
"0.58915174",
"0.5890208",
"0.5888084",
"0.58849955",
"0.5866355",
"0.5852663",
"0.5852316",
"0.58377886",
"0.583496",
"0.5824328",
"0.5822779",
"0.58109075",
"0.5796363",
"0.579557",
"0.5793115",
"0.5776198",
"0.57718736",
"0.5762837",
"0.57447016",
"0.5740175",
"0.572789",
"0.5727234",
"0.5724976",
"0.57106495",
"0.5703759",
"0.5693723",
"0.5693723",
"0.5693723",
"0.56897414",
"0.5685674",
"0.56784356",
"0.5673536",
"0.5671943",
"0.5666983",
"0.5655832",
"0.5652839",
"0.56493384",
"0.56456935",
"0.5642331",
"0.56396586",
"0.5639258",
"0.56290674",
"0.5629054",
"0.56186366",
"0.5616636",
"0.5614065",
"0.5610128",
"0.5608565",
"0.56004137",
"0.55994034",
"0.5595741",
"0.55919325"
] |
0.6997882
|
1
|
Prepare values for callbacks This defines what variables callbacks can access without calling a method
|
def prepare_vars(bot, msg, name)
{
:callback_name => name,
:server => bot.server,
:bot_nick => bot.nick,
:hooks => @hooks,
:cmds => @cmds,
:modules => @modules,
:bot => bot,
# These don't always exist for all message types,
# but should be reliable if you subscribe to the
# right type of events
:nick => (msg)? msg.nick : nil,
:recipient => (msg)? msg.recipient : nil,
:reply_to => (msg)? msg.reply_to : nil,
:message => (msg)? msg.message : nil,
:user => (msg)? msg.user : nil,
:host => (msg)? msg.host : nil,
:channel => (msg)? msg.channel : nil,
:error => (msg)? msg.error : nil,
:raw_msg => (msg)? msg : nil # TODO: make this simply 'msg'
}
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def prep_variables\n end",
"def callback\n\t\tvars = self.instance_variables\n\t\tvars.collect do |v|\n\t\t\tif eligible(\"#{v}\")\n\t\t\t\tval = @old[\"#{v}\"]\n\t\t\t\teval(\"#{v} = #{val}\")\n\t\t\tend \n\t\tend\n\tend",
"def callback=(_arg0); end",
"def callbacks; end",
"def callbacks; end",
"def affect_prepared_values!\n (upper(:@@preparers) || []).each do |preparer|\n @params[preparer[:key]] = preparer[:lambda].try(:call, @params[preparer[:key]])\n end\n end",
"def set_callbacks\n Curl.set_option(:writefunction, body_write_callback, handle)\n Curl.set_option(:headerfunction, header_write_callback, handle)\n Curl.set_option(:debugfunction, debug_callback, handle)\n @response_body = String.new\n @response_headers = String.new\n @headers_called = false\n @debug_info = Ethon::Easy::DebugInfo.new\n end",
"def initialize values\n\n # => Vars\n DEFAULTS.deep_merge!(values || {}).each do |k,v|\n instance_variable_set(\"@#{k}\",v)\n end\n\n # => Validation\n raise ExceptionHandler::Error, \"Email Not Valid\" if @email && !@email.nil? && !@email.is_a?(String)\n raise ExceptionHandler::Error, \"Migration Required → \\\"#{db}\\\" doesn't exist\" if @db && !ActiveRecord::Base.connection.table_exists?(db) && (File.basename($0) != \"rake\" && !ARGV.include?(\"db:migrate\"))\n\n end",
"def extract_callback_variables(hash)\n @url_gen ||= JqGridRails::UrlGenerator.new\n args = hash.dup\n args[:ajax_args] = hash.delete(:ajax) || {}\n args[:method] = args[:ajax_args][:type] || args[:ajax_args].delete(:method) || hash.delete(:method) || 'get'\n if(hash[:url].is_a?(Symbol))\n url_args = hash[:args].is_a?(Array) ? hash[:args] : [hash[:args]]\n args[:url] = @url_gen.send(hash[:url], *(url_args.sort_by{|x,y| if(x.is_a?(Hash) && y.is_a?(Hash)) then 0 elsif(x.is_a?(Hash)) then 1 else -1 end}))\n else\n args[:url] = hash[:url]\n end\n if(hash[:args_replacements].present?)\n if(hash[:args_replacements].is_a?(Hash))\n args[:args_replacements] = hash[:args_replacements].map{|fake_id, js_id| \"replace(#{format_type_to_js(fake_id)}, #{format_type_to_js(js_id)})\" }.join('.')\n unless(args[:args_replacements].blank?)\n args[:args_replacements] = \".#{args[:args_replacements]}\"\n end\n else\n args[:args_replacements] = hash[:args_replacements]\n end\n end\n args[:ajax_args][:type] = args[:method] if hash[:remote]\n args\n end",
"def callbacks\n @callbacks ||= {}\n end",
"def pre_c(callback)\n return unless Moguro.enabled?\n contract_handler.contract_arguments(callback)\n end",
"def strict_variables=(_arg0); end",
"def callback\n @callback ||= :value.to_proc\n end",
"def local_variables() end",
"def parameters=(_); end",
"def variables; end",
"def variables; end",
"def params=(params = {})\n params.assert_valid_keys(:callback)\n @params = params\n end",
"def probers=(_arg0); end",
"def handlers=(_arg0); end",
"def set_caller_params\n end",
"def parameters=(_arg0); end",
"def extra=(_arg0); end",
"def build_vars\n\n end",
"def callback\n @on_declare\n end",
"def callback\n end",
"def binder=(_arg0); end",
"def callback\n\n end",
"def mess_with_vars(_one, _two, _three)\n one = 'two'\n two = 'three'\n three = 'one'\nend",
"def definecallback(&b)\r\n\t\t\t@callback = b\r\n\t\tend",
"def value=(_arg0); end",
"def value=(_arg0); end",
"def value=(_arg0); end",
"def value=(_arg0); end",
"def value=(_arg0); end",
"def value=(_arg0); end",
"def value=(_arg0); end",
"def value=(_arg0); end",
"def setup_battle_callbacks\n @default_battle_callbacks = {\n :on_escape => nil,\n :on_victory => nil,\n :on_battle_start => nil,\n :on_turn_end => nil,\n :on_self_hit => nil,\n :on_self_critical_state => nil,\n :on_self_critical_hit => nil,\n :on_self_knocked_out => nil,\n :on_ally_hit => nil,\n :on_ally_critical_state => nil,\n :on_ally_critical_hit => nil,\n :on_ally_knocked_out => nil,\n :on_miss => nil,\n :on_no_damage => nil,\n :on_critical_hit => nil,\n :on_killing_blow => nil\n }\n @default_battle_callbacks.merge!(Variables::ActorDefaultBattleCallbacks[@actor_id])\n end",
"def init_params(params)\n @params = params\n @client_id = params[:client_id].to_i\n @event_source = params[:event_source]\n @event_name = params[:event_name]\n @event_data = params[:event_data]\n @event_timestamp = params[:event_timestamp].to_i\n\n @filtered_webhook_settings = []\n @event_obj = {}\n @lock_id = nil\n end",
"def data=(_arg0); end",
"def data=(_arg0); end",
"def data=(_arg0); end",
"def data=(_arg0); end",
"def mess_with_vars1(one, two, three)\n one = two\n two = three\n three = one\nend",
"def params=(_); end",
"def prepare_data\n\t\t\tsuper\n\t\t\t@data[:tuneable_data] = @tuneable_data\n\t\t\t@data[:@lowest_old] = @lowest_old\n\t\tend",
"def callback\n\tend",
"def verify_callback=(verify_callback); end",
"def verify_callback=(verify_callback); end",
"def build_callbacks(options)\n callbacks = {}\n options.each do |callback, code|\n if CALLBACKS.include?(callback)\n name = 'on' + callback.to_s.capitalize\n callbacks[name] = \"function(request){#{code}}\"\n end\n end\n callbacks\n end",
"def notifier=(_arg0); end",
"def notifier=(_arg0); end",
"def global_variables() end",
"def mess_with_vars2(one, two, three)\n one = \"two\"\n two = \"three\"\n three = \"one\"\nend",
"def mess_with_vars2(one, two, three)\n one = \"two\"\n two = \"three\"\n three = \"one\"\nend",
"def restricted_map(callbacks); end",
"def whiny=(_arg0); end",
"def prepare\n options[:category] = options[:value] if options[:value] && !options[:category]\n raise \"No categorizer set up for category tracker #{self.inspect}\" unless options[:category]\n \n @categorizer = create_lambda(options[:category]) unless options[:multiple]\n \n # Initialize the categories. Use the list of category names to \n @categories = {}\n options[:all_categories].each { |cat| @categories[cat] = 0 } if options[:all_categories].kind_of?(Enumerable)\n end",
"def init_data\n end",
"def old_value=(_arg0); end",
"def mess_with_vars(one, two, three)\n one = two\n two = three\n three = one\nend",
"def mess_with_vars(one, two, three)\n one = two\n two = three\n three = one\nend",
"def mess_with_vars(one, two, three)\n one = two\n two = three\n three = one\nend",
"def mess_with_vars(one, two, three)\n one = two\n two = three\n three = one\nend",
"def mess_with_vars(one, two, three)\n one = two\n two = three\n three = one\nend",
"def mess_with_vars(one, two, three)\n one = two\n two = three\n three = one\nend",
"def mess_with_vars(one, two, three)\n one = two\n two = three\n three = one\nend",
"def mess_with_vars(one, two, three)\n one = two\n two = three\n three = one\nend",
"def mess_with_vars(one, two, three)\n one = two\n two = three\n three = one\nend",
"def mess_with_vars(one, two, three)\n one = two\n two = three\n three = one\nend",
"def initialize()\n @callbacks = {}\n end",
"def before_callbacks\n @before_callbacks ||= []\n end",
"def main_variable\r\n super\r\n main_battledata # Setup Battle Temp Data & Interpreter\r\n main_troopdata # Setup Troop Data\r\n # Initialize wait count\r\n @wait_count = 0\r\n end",
"def events=(_); end",
"def after_setting_value_callback; end",
"def store=(_arg0); end",
"def called_from=(_arg0); end",
"def called_from=(_arg0); end",
"def dependent=(_arg0); end",
"def dependent=(_arg0); end",
"def value_read=(_arg0); end",
"def get_callbacks\n {\n :config => Proc.new { |c| call_config(c) },\n :machine => Proc.new { |m| call_machine(m) },\n }\nend",
"def before=(_arg0); end",
"def params=(_arg0); end",
"def params=(_arg0); end",
"def isolated=(_arg0); end",
"def isolated=(_arg0); end",
"def value_written=(_arg0); end",
"def prepare(callback = nil, &blk)\n Prepare.new(@loop, callback || blk)\n end",
"def listener=(_arg0); end",
"def mess_with_vars(one, two, three)\n one = \"two\"\n two = \"three\"\n three = \"one\"\nend",
"def before_background_callbacks(*args)\n set_audit_user\n set_request_uuid\n set_remote_address\n end",
"def checks=(_arg0); end",
"def load_param_values_non_arduino\n\n p = get_param_by_name('MOVEMENT_STEPS_PER_UNIT_X')\n @axis_x_steps_per_unit = p['value_db']\n\n p = get_param_by_name('MOVEMENT_STEPS_PER_UNIT_Y')\n @axis_y_steps_per_unit = p['value_db']\n\n p = get_param_by_name('MOVEMENT_STEPS_PER_UNIT_Z')\n @axis_z_steps_per_unit = p['value_db']\n\n end",
"def load_param_values_non_arduino\n\n p = get_param_by_name('MOVEMENT_STEPS_PER_UNIT_X')\n @axis_x_steps_per_unit = p['value_db']\n\n p = get_param_by_name('MOVEMENT_STEPS_PER_UNIT_Y')\n @axis_y_steps_per_unit = p['value_db']\n\n p = get_param_by_name('MOVEMENT_STEPS_PER_UNIT_Z')\n @axis_z_steps_per_unit = p['value_db']\n\n end",
"def state=(_arg0); end",
"def state=(_arg0); end",
"def state=(_arg0); end",
"def callback_type; end"
] |
[
"0.6501131",
"0.63889474",
"0.61723524",
"0.5989991",
"0.5989991",
"0.5582395",
"0.55480546",
"0.55272174",
"0.5432736",
"0.54235876",
"0.5405034",
"0.53950524",
"0.5358864",
"0.5338389",
"0.53379947",
"0.5331397",
"0.5331397",
"0.5307122",
"0.52959067",
"0.52928996",
"0.5269583",
"0.5229845",
"0.5214356",
"0.5212891",
"0.5206874",
"0.52055496",
"0.5200179",
"0.5199001",
"0.5164976",
"0.51363397",
"0.51352584",
"0.51352584",
"0.51352584",
"0.51352584",
"0.51352584",
"0.51352584",
"0.51352584",
"0.51352584",
"0.5112911",
"0.5088211",
"0.50866276",
"0.50866276",
"0.50866276",
"0.50866276",
"0.5075959",
"0.50713646",
"0.50618434",
"0.505857",
"0.5056736",
"0.5056736",
"0.50478715",
"0.5041817",
"0.5041817",
"0.5030672",
"0.5015186",
"0.5015186",
"0.500294",
"0.4998502",
"0.4992955",
"0.49823576",
"0.4981285",
"0.49752352",
"0.49752352",
"0.49752352",
"0.49752352",
"0.49752352",
"0.49752352",
"0.49752352",
"0.49752352",
"0.49752352",
"0.49752352",
"0.49747813",
"0.49732658",
"0.49664924",
"0.49597684",
"0.49490425",
"0.4946704",
"0.49440268",
"0.49440268",
"0.49416694",
"0.49416694",
"0.4934981",
"0.49233508",
"0.49223492",
"0.49157178",
"0.49157178",
"0.4902669",
"0.4902669",
"0.48963833",
"0.48896366",
"0.48895526",
"0.48887515",
"0.4885289",
"0.48822904",
"0.488085",
"0.488085",
"0.4879583",
"0.4879583",
"0.4879583",
"0.48787102"
] |
0.6240231
|
2
|
Invoke something with certain vars set.
|
def invoke(vars, block, args=[], thread_to_await=nil)
# Construct a new class
cls = Class.new
# Set up pre-defined variables
vars.each{|n, v|
cls.send :define_method, n.to_sym, Proc.new{|| return v}
}
# and the call that runs the hook
cls.send :define_method, :__hookbot_invoke, block
# then call, in a thread, waiting for any old threads
# should we have been passed one
return Thread.new(thread_to_await, cls, args){ |thread_to_await, cls, args|
thread_to_await.join if thread_to_await and thread_to_await.is_a(Thread) and thread_to_await.alive?
begin
cls.new.__hookbot_invoke(*args)
rescue Exception => e
$log.error "Error in callback thread: #{e}"
$log.debug "#{e.backtrace.join("\n")}"
end
}
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def _perform(args); end",
"def call(*args)\n\t filtered_args, vm = prepare_call(args)\n\t perform_call(filtered_args, vm)\n\tend",
"def perform(*args); end",
"def method_missing(method_name, *args, &block)\n @variables[method_name.to_sym].call\n end",
"def invoke\n execute_only(:invoke)\n end",
"def invoke; end",
"def invoke *o,&b\n @invoker ||= create_invoker()\n invoker.invoke *o,&b\n end",
"def pass *args\n halt invoke *args\n end",
"def invoking\n end",
"def call(*args)\n self.exec(*args)\n end",
"def call(*args); end",
"def call(*args)\n @ctx.instance_exec(args, &action)\n end",
"def __invoke__ *args\n begin\n instance_exec *args, &__bl__\n rescue ::StandardError => err\n txt1 = \"When trying #{__txt__}\"\n thing, statements = __describe__\n txt2 = DECORATE.( thing, prefix: ' ' )\n txt3 = DECORATE.( statements.map { |verb, object|\n STATE[verb] % object\n }.join( ', ' ),\n prefix: ' (', postfix: ')' )\n txt4 = DECORATE.( __circumstances__, prefix: ', ' )\n txt5 = DECORATE.( \"#{err.class} occurred: #{err}\", prefix: ', ' )\n raise err, txt1 + txt2 + txt3 + txt4 + txt5\n end\n end",
"def exec _obj, _args\n \"_obj exec _args;\" \n end",
"def call(*args)\n __call__( args )\n end",
"def invoke(name, args)\n\t\tself.class.invoke_instance_method(self, name, args)\n\tend",
"def run(cmd, *args)\n dispatch(cmd, *args)\n end",
"def invoke( function, args, timeout=6 )\n send_question( {\n type: 'invocation',\n function: function,\n args: args\n }, timeout)\n end",
"def run(*args); end",
"def run(*args); end",
"def run(*args); end",
"def run(*args); end",
"def run(*args); end",
"def run(*args); end",
"def run(*args); end",
"def run(*args); end",
"def exec(options)\n self.params = options[:params]\n self.request = options[:request]\n self.caller = options[:caller]\n self.options = options.except(:params, :request, :caller)\n\n setup\n raise Lev.configuration.security_transgression_error, auth_error_details unless authorized?\n validate_paramified_params\n handle unless errors?\n end",
"def action (opt, arg, parms)\n @proc.call(opt, arg, parms)\n end",
"def value(vars=nil) @value_method.call(@pars_hash,vars); end",
"def invoke(op, param)\r\n m = @@OPS[op]\r\n self.send(m, param)\r\n end",
"def run(*args)\n @action.call(args)\n end",
"def run(*args)\n @action.call(args)\n end",
"def always_run=(_arg0); end",
"def method_missing(method, *args)\n if self.respond_to?(method)\n super\n else\n method_name = method.to_s\n \n #set a value for a variable\n if method_name =~ /=$/\n var_name = method_name.gsub('=', '')\n value = args.first\n self[var_name] = value\n \n #retrieve a value\n else\n self[method_name]\n end\n end\n end",
"def method_missing(name, *args)\n\t\t\tcall name, *args\n\t\tend",
"def eval(*args); end",
"def run(x, app, act, meth, args=[])\n if @runs[app.to_sym][act][meth.to_sym]\n begin\n @runs[app.to_sym][act][meth.to_sym][x, *args]\n rescue ArgumentError => e\n if Waxx['debug']['on_screen']\n error(x, status: 405, type: \"request\", title: \"Argument Error\", message: \"#{e.to_s}\\n\\n#{e.backtrace.join(\"\\n\")}\")\n else\n Waxx.debug e\n App.not_found(x)\n end\n end\n elsif @runs[app.to_sym][act][:run]\n begin\n @runs[app.to_sym][act][:run][x, *args]\n rescue ArgumentError => e\n if Waxx['debug']['on_screen']\n error(x, status: 405, type: \"request\", title: \"Argument Error\", message: \"#{e.to_s}\\n\\n#{e.backtrace.join(\"\\n\")}\")\n else\n Waxx.debug e\n App.not_found(x)\n end\n end\n else\n error(x, status: 405, type: \"request\", title: \"Method Not Implemented\", message: \"The HTTP method requested is not implemented for this interface.\")\n end\n end",
"def invoke(args)\n @call_back.call *args\n end",
"def invoke(*names, &block)\n options = names.last.is_a?(Hash) ? names.pop : {}\n verbose = options.fetch(:verbose, true)\n\n names.each do |name|\n invocations[name] = false\n invocation_blocks[name] = block if block_given?\n\n class_eval <<-METHOD, __FILE__, __LINE__\n def _invoke_#{name.to_s.gsub(/\\W/, '_')}\n klass, command = self.class.prepare_for_invocation(nil, #{name.inspect})\n\n if klass\n say_status :invoke, #{name.inspect}, #{verbose.inspect}\n block = self.class.invocation_blocks[#{name.inspect}]\n _invoke_for_class_method klass, command, &block\n else\n say_status :error, %(#{name.inspect} [not found]), :red\n end\n end\n METHOD\n end\n end",
"def fire(worker, vars)\r\n action.execute(worker, vars)\r\n end",
"def process_action(options, filter, vars)\n agent = rpcclient(options['agent'])\n set_filter(agent, options['filter'] || filter, vars)\n if options['parameters']\n parameters = options['parameters'].inject({}) do |result,(k,v)|\n result[k.to_sym] = v.is_a?(String) ? interpolate(v, vars) : v\n result\n end\n else\n parameters = nil\n end\n\n nodes = agent.discover\n printtitle(\"Running task: #{options['name']}\", nodes)\n printrpc agent.method_missing(options['action'], parameters)\n agent.disconnect\nend",
"def method_missing(name, *args)\n\t\t\tcall(name, *args)\n\t\tend",
"def invoke!\n _log { \"@facade=@#{@facade.object_id}\" }\n @result = @facade._active_target.__send__(@selector, *@arguments)\n @block.call(@result) if @block\n rescue Exception => exc\n @thread.raise(@exception = exc)\n end",
"def run\n\tprint_header\n\tfirst_num = get_num('first')\n\top = operator\n\tsecond_num = get_num('second')\n\tputs first_num.public_send(op, second_num)\nend",
"def act(others, _caller_context)\n context = @context.dup_in\n (0...@arguments.length).each do |index|\n variable = Variable.new(\n name: @arguments[index],\n value: others[index],\n scope: :local\n )\n context.variables += [variable]\n end\n executor = TreeExecutor.new @tree, context: context\n executor.act\n end",
"def exec (*args, &block)\n if @scope\n @scope.instance_variables.each do |name|\n instance_variable_set(name, @scope.instance_variable_get(name))\n end\n end\n\n @ivars.each do |name, value|\n instance_variable_set(name, value)\n end\n \n instance_exec(*args, &block)\n end",
"def op_invoke(method = nil)\n op_send(method, false)\n end",
"def invoke\n @proc.call\n end",
"def perform_action(*args)\n end",
"def call(env); end",
"def call(env); end",
"def call(env); end",
"def call(env); end",
"def call(env); end",
"def call(env); end",
"def call(env); end",
"def call(value)\n fn[value, *args]\n end",
"def invokeDefaultMethodWithArguments(args)\n eval(args[0])\n end",
"def running=(_arg0); end",
"def runs=(_arg0); end",
"def method_missing(method, params={})\n call(method, params)\n end",
"def invoke(fun, args, normal, exception, name = \"\")\n invoke2(nil, fun, args, normal, exception, name)\n end",
"def dispatch(*_arg0); end",
"def execute!\n action, item = arguments[0].to_s, arguments[1].to_s\n ui.info \"Running parameters action #{ui.color(action.to_s, :bold)}\"\n if respond_to?(\"run_action_#{action}\")\n send(\"run_action_#{action}\", item)\n else\n allowed_actions = public_methods.grep(/^run_action/).sort.map do |item|\n item.to_s.sub(\"run_action_\", \"\")\n end\n raise ArgumentError.new \"Unsupported action received `#{action}`. \" \\\n \"Allowed: #{allowed_actions.join(\", \")}\"\n end\n end",
"def run_in_context(o={}, &block)\n proc = Proc.new do\n set_vars_from_options(:name => o[:name]) if o.has_key?(:name) # Name MUST be set first\n set_vars_from_options(o)\n instance_eval &block if block\n end\n super(&proc)\n end",
"def process(action, *args); end",
"def execute( context )\n @instance_method.bind(context).call(*@args)\n end",
"def exec(vm, params)\n impl.call(vm, params)\n end",
"def take_actions (argv,hash)\n type,sub = parse_subject argv\n \n case type\n when :all\n return unless hash[:flow]\n Conf::flows.each do |flow|\n hash[:flow].call(flow)\n end\n else\n hash[type].call(sub) if hash[type]\n end\n end",
"def run_method\n send_method(method, @value)\n end",
"def method_missing(meth, *args, &block)\n if meth.to_s == \"to_ary\"\n raise NoMethodError\n end\n\n if args.empty? and rp = role_proxy(meth)\n rp\n elsif task = resolve_task(meth)\n task.run(self, *args, &block)\n else\n if args.last.kind_of? Hash\n opts = args.pop\n else\n opts = {}\n end\n str = ([meth] + args.map{|a| escape(a)}).join(' ')\n exec! str, opts, &block\n end\n end",
"def call(env)\n env[:op].execute\n end",
"def call(*) end",
"def call(*) end",
"def perform(*args)\n\tend",
"def call(bind_vars={}, &block)\n bind(bind_vars).run(&block)\n end",
"def vest _args\n \"vest _args;\" \n end",
"def method_missing(name, *args, &block)\n if name =~ /set_(.+)/\n configure($1, args[0], &block)\n else\n request(name, &block)\n end\n end",
"def do_the_numbers(x,y,z)\n x.send(y,z)\nend",
"def execFSM _obj, _args\n \"_obj execFSM _args;\" \n end",
"def call(args = {})\n check_call_definition!\n check_missing_arguments!(self.class.required_call_arguments, args)\n variables_for!(self.class.call_arguments, args)\n super()\n end",
"def perform(*args)\n # Do something\n puts \"perform successfully\"\n end",
"def run(argv)\n options = parse(argv)\n invoke!(options.to_h)\n end",
"def action _obj, _args\n \"_obj action _args;\" \n end",
"def invoke(name, *args, **keywords, &blk)\n window.send(name, *args, **keywords, &blk)\n end",
"def prepare_invoke!\n @prepared = true\n end",
"def method_missing name, *args\n bind do |v|\n begin\n v.send name, *args\n rescue NoMethodError\n v.instance_variable_get :\"@#{name}\"\n end\n end\n end",
"def execute_option_function(function, *args)\n args = args.first(function.parameters.length)\n controller.instance_exec(*args, &function)\n end",
"def k_invoke!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 41 )\n\n\n\n type = K_INVOKE\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 417:4: 'invoke'\n match( \"invoke\" )\n\n\n\n @state.type = type\n @state.channel = channel\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 41 )\n\n\n end",
"def example(hash_of_arguments)\n hash_of_arguments.each {|key,value| self.send(\"#{key}=\", value) }\nend",
"def execute_this(meth, *args)\n $log.debug \"app email got #{meth} \" if $log.debug?\n cc = @vim.current_component\n [cc, @lb2, @tv].each do |c|\n if c.respond_to?(meth, true)\n c.send(meth, *args)\n return true\n end\n end\n false\nend",
"def perform_execute_request(data = {})\n execute_recipe(version, data)\n end",
"def invokeAction(action, args, &b)\n\t\t\tarty = method(action).arity\n\t\t\tif args.length == arty or arty == -1\n\t\t\t\t__send__(action, *args, &b)\n\t\t\tend\n\t\tend",
"def process_action(method_name, *args); end",
"def call(method, args)\n send(method, *args)\n end",
"def method_missing(m, *args) #:nodoc:\r\n\t\tif @current_object.respond_to?(m)\r\n\t\t\t@current_object.send(m, *args)\r\n\t\telse\r\n\t\t\t_invokeMethod(m, *args)\r\n\t\tend\r\n\tend",
"def run_method\n send_method(method, value)\n end",
"def setVariable _obj, _args\n \"_obj setVariable _args;\" \n end",
"def exec_action_object(action)\n\t\t\taction.execute\n\t\tend",
"def fire _obj, _args\n \"_obj fire _args;\" \n end",
"def method_missing(m, *args, &block)\n\t\tbegin\n\t\t\tpieces = m.to_s.split(/\\_/)\n\n\t\t\t#If the question is of the format users_editing_(per|by|x)_[timeframe]\n\t\t\tif pieces[0]+pieces[1] == 'usersediting'\n\t\t\t\tinstance_eval \"user_time_frame(pieces[3],#{args.join(',')})\"\n\t\t\telse\n\t\t\t\t#Ultimately send it to the Analysis Window if it wasn't found here\n\t\t\t\tinstance_eval \"aw.#{m}(#{args.join(',')})\"\n\t\t\tend\n\t\trescue => e\n\t\t\tputs $!\n\t\t\tputs e.backtrace\n\t\t\tsuper(args)\n\t\tend\n\tend"
] |
[
"0.6603789",
"0.6291481",
"0.6198658",
"0.6034645",
"0.60200137",
"0.5961701",
"0.5930861",
"0.5917767",
"0.58554447",
"0.5802808",
"0.5783377",
"0.57720214",
"0.5748923",
"0.57003963",
"0.56816256",
"0.5584135",
"0.5580536",
"0.5580136",
"0.5573728",
"0.5573728",
"0.5573728",
"0.5573728",
"0.5573728",
"0.5573728",
"0.5573728",
"0.5573728",
"0.5570262",
"0.5565408",
"0.5553704",
"0.5530595",
"0.5501446",
"0.5501446",
"0.5482937",
"0.5479945",
"0.54704183",
"0.54697657",
"0.5459081",
"0.5439664",
"0.5424951",
"0.54204667",
"0.5419918",
"0.5405461",
"0.540289",
"0.54027146",
"0.5400055",
"0.53990096",
"0.53880996",
"0.5368774",
"0.53667754",
"0.5361732",
"0.5361732",
"0.5361732",
"0.5361732",
"0.5361732",
"0.5361732",
"0.5361732",
"0.53616804",
"0.53585565",
"0.5351399",
"0.53508717",
"0.53445274",
"0.53416914",
"0.53410625",
"0.5336581",
"0.5335296",
"0.53225154",
"0.5316008",
"0.5309749",
"0.53089386",
"0.52992254",
"0.5293274",
"0.5291397",
"0.52716386",
"0.52716386",
"0.5269246",
"0.5266766",
"0.5265739",
"0.52577794",
"0.52554846",
"0.5251564",
"0.52439547",
"0.5237982",
"0.52330256",
"0.52314556",
"0.52301663",
"0.5227165",
"0.5225145",
"0.52220213",
"0.5222018",
"0.5215447",
"0.5206004",
"0.52057856",
"0.52043515",
"0.5197106",
"0.51937205",
"0.51848334",
"0.51832074",
"0.5181922",
"0.517929",
"0.51786226",
"0.5177494"
] |
0.0
|
-1
|
converts amount in float or integer into Money object
|
def money(amount)
Money.new((amount * 100).to_i)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def money\n Money.from_amount(amount.to_f)\n end",
"def to_money amount\n\t\t\tamount.to_f.round(2) rescue 0.0\n\t\tend",
"def coerce_money(v)\n SpookAndPuff::Money.new(v.to_s)\n end",
"def to_currency(amount)\n\n decimal = BigDecimal.new(amount.to_s)\n\n full_integer = (decimal * 100)\n\n return currency = Money.new(full_integer)\n\n end",
"def instantiate amount, currency\n if amount.is_a?(BigDecimal)\n amount\n else\n BigDecimal(amount.to_s, precision_for(amount, currency))\n end\n end",
"def convert_to(convert_currency)\n Money::Converter.new(amount, currency, convert_currency).convert \n end",
"def money(amount)\n number_to_currency amount.to_s, {:unit => 'R ', :delimiter => ',', :seperator => '.'}\n end",
"def amount(money)\n return nil if money.nil?\n cents = money.respond_to?(:cents) ? money.cents : money \n\n if money.is_a?(String) or cents.to_i < 0\n raise ArgumentError, 'money amount must be either a Money object or a positive integer in cents.' \n end\n\n case self.money_format\n when :cents\n cents.to_s\n else\n sprintf(\"%.2f\", cents.to_f/100)\n end\n end",
"def convert_to(to_currency)\n Money.new(self.amount * exchange_rate(to_currency), to_currency)\n end",
"def money(amount, name)\n Currency::Money.new(amount, name)\n end",
"def convert_money(currency)\n return currency.to_f / 100\n # if currency.to_s.include?(\".\")\n # return currency\n # else\n # return currency.to_f / 100\n # end\n end",
"def convert(amount, currency_from, currency_to)\n return Money.new(amount, currency_from).exchange_to(currency_to).fractional\n end",
"def converted_amount(other)\n (currency == other.currency ? other : other.convert_to(currency)).amount.to_f\n end",
"def to_amount(value, currency)\n to_bigdecimal(value).round(precision(currency))\n end",
"def transaction_amount(currency_and_amount)\n currency = parse(currency_and_amount).first\n if currency == 'USD'\n amount = parse(currency_and_amount).last.to_f\n else\n amount = currency.to_f unless amount == 0.0\n end\n# self.amount = amount \n end",
"def prepare_amount amount\n BigDecimal.new(amount)/100\n end",
"def money\n Spree::Money.new(amount, { currency: currency })\n end",
"def to_currency(amount)\n number_to_currency amount, :precision => 0\n end",
"def get_value(value)\n value.instance_of?(HappyMoney::Money) ? value.convert_to(self.currency).amount : value\n end",
"def to_f\n amount.to_f\n end",
"def amount_to_currency(number)\n number_to_currency(number.to_f, { unit: '£' })\n end",
"def tobeamount(obj)\n\t\tif obj.to_s =~ /(\\d+)([.]\\d{1,2})?/\n\t\t\tamt = $1 + ($2 || '.00')\n\t\t\treturn amt.to_f\n\t\tend\n\t\treturn nil\n\tend",
"def real_amount()\n Bankjob.string_to_float(amount, @decimal)\n end",
"def money\n to_d.money.to_s\n end",
"def money\n to_d.money.to_s\n end",
"def amount(money, negative = false)\n return nil if money.nil?\n cents = if money.respond_to?(:cents)\n\n # TODO: Check with new version of gateway\n ActiveMerchant.deprecated \"Support for Money objects is deprecated and will be removed from a future release of ActiveMerchant. Please use an Integer value in cents\"\n money.cents\n else\n money\n end\n\n if negative\n # Negate it\n cents = -cents\n end\n\n if money.is_a?(String)\n raise ArgumentError, 'money amount must be an Integer in cents.'\n end\n\n if self.money_format == :cents\n cents.to_s\n else\n sprintf(\"%.2f\", cents.to_f / 100)\n end\n end",
"def convert_to(to_currency)\n\t\tfrom_currency = self.currency\n\t\trate = Money.getRate(from_currency, to_currency)\n\n\t\tconverted_amount = self.amount * rate\n\n\t\tMoney.new(converted_amount, to_currency)\n\tend",
"def to_bigdecimal(value)\n case value\n when Mint::Money\n value.value\n when Rational\n value.to_d(16)\n else\n value.respond_to?(:to_d) ? value.to_d : raise(WrongMoneyError, value)\n end\n end",
"def money_to_currency(money)\n if money && numeric?(money)\n #number_to_currency(money.to_d, unit: money.currency.symbol)\n number_to_currency(money.to_d, unit: current_tenant.default_currency.symbol)\n else\n number_to_currency(Monetize.parse(\"0\"))\n end\n end",
"def amount\n\n @amount_bigdecimal.to_f.round(2)\n\n end",
"def to_f\n @amount.to_f\n end",
"def convert_money(from_currency,to_currency)\n exchanger = Exchanger.new(find_wallet_account(from_currency),find_wallet_account(to_currency), find_exchange_rate(from_currency, to_currency))\n exchanger.exchange(:all)\n end",
"def currency(amount)\n number_to_currency amount.to_s, {:unit => \"\", :delimiter => ',', :seperator => '.'}\n end",
"def to_f\n @amount.to_f\n end",
"def amount_in_cents\n return 0 if amount.nil?\n (amount * 100).to_i\n end",
"def cents(amount)\n (amount * 100).to_i\n end",
"def prettymoney(amount)\n '$%.2f' % cents_to_dollars(amount).to_s\n end",
"def convertValue(theMoney)\n if theMoney == nil\n raise ArgumentError, \"theMoney is nil\"\n end\n intPart = theMoney.to_i\n fractPart = ((theMoney - intPart) * NUM100).round\n if @currency == Currency::PER1000.to_s\n fractPart = ((theMoney - intPart) * NUM1000).round\n end\n return convert(intPart, fractPart);\n end",
"def cents\n (amount * 100).to_i\n end",
"def to_ps_money\n return nil if self.nil?\n return \"00\" if self.to_f == 0\n \n value = self.to_s\n\n # obtem a parte fracionaria e transforma em string.\n frac = value.to_f - value.to_i\n frac = frac.to_s + \"0\" \n frac = frac[2..3]\n # Se tiver parte inteira, concatena com a parte fracionaria\n inteiro = \"\"\n inteiro = value.to_i.to_s if value.to_f.truncate > 0\n inteiro + frac\n end",
"def money(number)\n return number_to_currency(number, :format => \"%n\")\n end",
"def activemerchant_amount\n (amount * 100).to_i\n end",
"def convert_to(target_currency)\n raise Exception.new(\"'target_currency' must be different from the current currency!\") \\\n if target_currency == self.currency\n result = self.amount * conversion_rate(target_currency)\n DaMoney::Money.new(result, target_currency)\n end",
"def to_f\n return @amount.to_f\n end",
"def to_price(amount)\n amount.to_s.gsub(/[^\\d]/, \"\").gsub(/^(\\d+)(\\d{2})$/, '\\1.\\2').to_f\n end",
"def to_price(amount)\n amount.to_s.gsub(/[^\\d]/, \"\").gsub(/^(\\d+)(\\d{2})$/, '\\1.\\2').to_f\n end",
"def amount=(money)\n cents = money.respond_to?(:cents) ? money.cents : money\n if money.is_a?(String) or cents.to_i <= 0\n raise ArgumentError, 'money amount must be either a Money object or a positive integer in cents.'\n end\n add_field(mappings[:amount], sprintf(\"%.2f\", cents.to_f/100))\n end",
"def to_cents amount\n amount = amount.gsub(/[^0-9.]/, \"\")\n (amount.to_f * 100).to_i\n end",
"def amount_in_cents(amount)\n (100 * amount).to_i\n end",
"def convert_to_integer_amount(currency, amount)\n sub_unit = ::Revolut::Api::Constants::CRYPTOS.include?(currency) ? ::Revolut::Api::Constants::BASE_UNITS[:crypto] : ::Revolut::Api::Constants::BASE_UNITS[:fiat]\n (amount.to_f * sub_unit).round(0).to_i\n end",
"def donation_amount\n number_to_currency(self.value)\nend",
"def format_amount(amount)\n ActionController::Base.helpers.number_to_currency(amount.to_f / 100)\n end",
"def format_money(amount)\n amount = '%.2f' % amount.to_f\n return \"$#{amount}\"\nend",
"def convert_fuel_to_money(amount)\n val = MyPlayer.select(\"CONVERT_RESOURCE('FUEL', #{amount})\").where(:id => self.id).first.attributes\n\n # Update the player attributes after a successful conversion\n unless val[\"convert_resource\"].blank?\n self.fuel_reserve -= val[\"convert_resource\"].to_i\n self.balance += val[\"convert_resource\"].to_i\n end\n end",
"def to_dollar(amount)\n # round_to(@balance)\n format('%.2f', amount)\n end",
"def amount=(money)\n cents = convert_to_cents(money)\n add_field mappings[:amount], sprintf(\"%.2f\", BigDecimal.new(cents.to_s)/100)\n end",
"def *(number)\n (BigDecimal.new(self) * BigDecimal.new(number.to_s)).\n to_f.to_money(:currency => currency, :precision => self.precision)\n end",
"def amount_cents \n (self.amount.to_f * 100).round.to_i\n end",
"def payment\n number_with_precision(amount, :precision => 2 )\n end",
"def amount=(amount)\n self[:amount] =\n case amount\n when String\n separator = I18n.t('number.currency.format.separator')\n number = amount.delete(\"^0-9-#{separator}\\.\").tr(separator, '.')\n number.to_d if number.present?\n end || amount\n end",
"def to_btc(value)\n value.to_f\n end",
"def to_usd(amt, currency)\n unless currency == \"USD\"\n path = @xml_parser.find_conversion_path(currency, \"USD\")\n amount = @xml_parser.get_rates_from_xml(path[0])\n #pp path # print the path array (for debug if you need it)\n\n #conversion = find_conversion_amt(currency, \"USD\")\n else\n conversion = BigDecimal.new('1') \n end\n amt = BigDecimal(amt)\n amount = amt * conversion\n #puts \"amount is #{amount}\"\n round_banker_style(amount)\n end",
"def convert_price_to_dollar\n \tself.price = self.price.to_f/100\n end",
"def amount_in_cents\r\n read_attribute(:amount) \r\n end",
"def euro_from_cents(float_amount)\n if float_amount\n euro(float_amount / 100.0)\n else\n \"undefined\"\n end\n end",
"def amount=(part)\n unless part.is_a?(Money)\n part = Monetize.parse(part)\n raise(ArgumentError, \"Can't convert #{value.class} to Money\") unless part\n end\n mapping = [%w[amount_cents cents], %w[currency currency]]\n mapping.each { |pair| self[pair.first] = part.send(pair.last) }\n @aggregation_cache[:amount] = part.freeze\n end",
"def amount\n case mode\n when 'set', 'fixed' then money\n when 'percentage' then percentage\n end\n end",
"def convert(amount, from, to, opts={})\n amount * rate(from, to, opts)\n end",
"def money(m)\n \"#{m.format(symbol: false)} #{m.currency.to_s}\"\n end",
"def number_to_currency(amount)\n super(amount, unit: \"₹\")\n end",
"def format_money(num)\n if num == WebScraper::NOT_APPLICABLE\n num\n else\n num[num.length] = '0' if num.index('.') == num.length - 2 # add a 0 if only 1 decimal place given\n WebScraper::MONEY_UNITS + num.gsub(WebScraper::COMMAS_REG_EXP, '\\\\1,')\n end\n end",
"def to_amount(value, asset, chain)\n return Amount.new(value.to_s + \" \" + asset, chain)\n end",
"def convert_money_to_fuel(amount)\n val = self.class.select(\"CONVERT_RESOURCE('MONEY', #{amount})\").where(:id => self.id).first.attributes\n # Update the player attributes after a successful conversion\n unless val[\"convert_resource\"].blank?\n self.balance -= val[\"convert_resource\"].to_i\n self.fuel_reserve += val[\"convert_resource\"].to_i\n end\n end",
"def euro(float_amount)\n number_to_currency(float_amount, unit: \"Ƶ\")\n end",
"def dollars\n cents.to_f / 100\n end",
"def amount\n money.format(symbol: false)\n end",
"def amount\n data['amount'].to_f / 100\n end",
"def dollars\n to_f\n end",
"def dollars\n to_f\n end",
"def dollars\n to_f\n end",
"def pull_currency( amount, &block )\n amount_str = Float( amount ).to_s\n idx = amount_str.index( \".\" )\n currency = block.call( amount_str, idx )\n currency.to_i\n end",
"def currency\n number_to_currency(self)\n end",
"def to_base_currency(money)\n bank.exchange_with(money, price_currency)\n end",
"def parse_money_to_float(money)\n return -1 unless valid_money?(money)\n\n money_result = standardizes_money_input(money)\n\n return money_result.to_f unless part_decimal?(money_result)\n return money_result.tr('.', '').to_f if ends_with_thousand?(money_result)\n\n money_parts = money_result.split('.')\n integer_part = money_parts[0..-2].join('')\n decimal_part = money_parts[-1]\n\n [integer_part, decimal_part].join('.').to_f\n end",
"def convert_to_cents(amount_in_usd)\n (amount_in_usd) ? (amount_in_usd * 100).ceil : 0\n end",
"def initialize (amount, currency)\n\n #Amount is stored in BigDecimal for better precision in currency operations\n @amount_bigdecimal = BigDecimal.new(amount,0)\n\n @currency = currency\n\n end",
"def convert_to_usd(amount_in_cents)\n (amount_in_cents) ? BigDecimal.new(amount_in_cents.to_s) / 100 : 0\n end",
"def transfer_amount(amount)\n ((amount * from) / to.to_f).ceil_to(2)\n end",
"def to_currency(num)\n format(\"$%.2f\",num)\nend",
"def *(factor)\n if factor.is_a?(Numeric)\n Money.new(amount * factor, base_currency)\n else\n raise TypeError\n end\n end",
"def money\n end",
"def converter(integer)\n integer = integer.to_s\n cents = integer[-2..-1]\n dollars = integer[0..-3]\n return_statement = \"#{dollars}.#{cents}\"\n end",
"def converter(integer)\n integer = integer.to_s\n cents = integer[-2..-1]\n dollars = integer[0..-3]\n return_statement = \"#{dollars}.#{cents}\"\n end",
"def format_item_amount(item)\n Money.new(item.amount_cents, @invoice.currency).format(\n :no_cents_if_whole => false\n )\n end",
"def amount\n v = state[:amount] and BigDecimal(v.to_s)\n end",
"def format_money(number)\n \"$#{format('%.2f', number)}\"\n end",
"def format_amount_as_float(amount, currency)\n units = CURRENCY_SPECIAL_MINOR_UNITS[currency] || 2\n divisor = 10**units\n return ((amount || 0).to_d / divisor.to_d)\n end",
"def formated_in_provided_currency(amount_cents, currency_code, no_cents_if_whole = false)\n Money.new(amount_cents, currency_code).format(:no_cents_if_whole => no_cents_if_whole)\n end",
"def total_to_currency\n amount_to_currency(@invoice_json['total'])\n end",
"def normalize_amount( amount )\n\t\tamount = Money( amount )\n\t\treturn amount.exchange_to( 'ZMZ' ).fractional\n\tend"
] |
[
"0.8190561",
"0.77708507",
"0.7509132",
"0.7434018",
"0.73027354",
"0.7203289",
"0.7181826",
"0.71665597",
"0.713698",
"0.7114385",
"0.7096725",
"0.7091911",
"0.7039345",
"0.7034379",
"0.6992524",
"0.69801664",
"0.69664097",
"0.6963474",
"0.6931813",
"0.6844594",
"0.6834525",
"0.68147117",
"0.6747875",
"0.66664696",
"0.66664696",
"0.6660874",
"0.66506594",
"0.6647227",
"0.6629076",
"0.65800965",
"0.65066224",
"0.64794517",
"0.647573",
"0.646345",
"0.6434957",
"0.6387917",
"0.6386602",
"0.6375362",
"0.63649607",
"0.6360661",
"0.6337",
"0.63317484",
"0.6331008",
"0.6320554",
"0.62919354",
"0.62919354",
"0.6289028",
"0.62833476",
"0.6270394",
"0.6267435",
"0.62606263",
"0.6257728",
"0.624137",
"0.623984",
"0.6230903",
"0.62102413",
"0.619873",
"0.6186518",
"0.61764693",
"0.61684704",
"0.6153964",
"0.6153586",
"0.6150538",
"0.6143611",
"0.6139064",
"0.612304",
"0.6114853",
"0.61116666",
"0.6105248",
"0.6095629",
"0.6092744",
"0.6091498",
"0.6084253",
"0.606988",
"0.60649747",
"0.60629344",
"0.6058178",
"0.6046523",
"0.6046523",
"0.6046523",
"0.60462964",
"0.6040559",
"0.60327417",
"0.60292387",
"0.60258156",
"0.6020763",
"0.602068",
"0.59941995",
"0.59932786",
"0.59854364",
"0.5969495",
"0.59654987",
"0.59654987",
"0.5959674",
"0.59523046",
"0.5952286",
"0.59499365",
"0.5946718",
"0.59400946",
"0.59338"
] |
0.7804323
|
1
|
Given a hash with numeric values, return the key for the smallest value
|
def key_for_min_value(name_hash)
min_key = ""
min_value = ""
if name_hash == {}
return nil
else
name_hash.each do |name, value|
if min_value == "" || value < min_value
min_value = value
min_key = name
end
end
min_key
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = Float::INFINITY\n hash.each do |key, value|\n if value < lowest_value\n lowest_value = value\n lowest_key = key\n end\n end\n lowest_key\nend",
"def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = Float::INFINITY\n hash.each do |k, v|\n if v < lowest_value\n lowest_value = v\n lowest_key = k\n end\n end\n lowest_key\nend",
"def key_for_min_value(hash)\n smallest_value = nil\n smallest_key = nil\n hash.each do |name, num|\n if smallest_value == nil || num < smallest_value\n smallest_value = num\n smallest_key = name\n end\n end\n smallest_key\nend",
"def key_for_min_value(hash)\n min_val = Float::INFINITY\n min_key = nil\n hash.each do |key, value|\n if value < min_val\n min_val = value\n min_key = key\n end\n end\n min_key\nend",
"def key_for_min_value(hash)\n \n min_val = Float::INFINITY\n min_key = nil\n hash.each do |k, v|\n if min_val > v\n min_val = v\n min_key = k\n end\n end\n return min_key\nend",
"def key_for_min_value(hash)\n smallest_key = nil\n tiny_value = nil\n hash.each do |key, value|\n if tiny_value == nil || value < tiny_value\n tiny_value = value\n smallest_key = key\n end\n end\n smallest_key\nend",
"def key_for_min_value(hash)\n smallest = nil\n key = nil\n hash.collect do |name, val|\n if smallest == nil || val < smallest\n smallest = val\n key = name\n end\n end\n key\nend",
"def key_for_min_value(hash)\n int_hash = hash.select { |key, val| val.class == Fixnum }\n smallest = int_hash[int_hash.keys.sample]\n # debugger\n int_hash.each do |key, val|\n if val < smallest\n smallest = val \n end\n end\n int_hash.key(smallest)\nend",
"def key_for_min_value(hash)\r\n smallest_key = nil\r\n tiniest_value = nil\r\n hash.each do |key, value|\r\n if tiniest_value == nil || value < tiniest_value\r\n tiniest_value = value\r\n smallest_key = key\r\n end\r\n end\r\n smallest_key\r\nend",
"def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = 0\n\n\n hash.each do |key,value|\n if lowest_value == 0 || value < lowest_value\n lowest_value = value\n lowest_key = key\n end\n end\n lowest_key\nend",
"def key_for_min_value(hash)\n min = nil\n hash.each_pair do |key, value|\n min ||= value\n min = value if value < min\n end\n hash.key(min)\nend",
"def key_for_min_value(hash)\n smallest = nil\n hash.each do |key, value|\n if smallest == nil\n smallest = key\n end\n if hash[key] < hash[smallest]\n smallest = key\n end\n end\n smallest\nend",
"def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = nil\n hash.each do |k, v|\n if lowest_value == nil || v < lowest_value\n lowest_value = v\n lowest_key = k\n end\n end\n lowest_key\nend",
"def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = nil\n hash.each do |k, v|\n if lowest_value == nil || v < lowest_value\n lowest_value = v\n lowest_key = k\n end\n end\n lowest_key\nend",
"def key_for_min_value(hash)\n smallest_key = nil\n tiniest_value = nil\n hash.each do |key, value|\n if tiniest_value == nil || value < tiniest_value\n \n # this way, the smallest value in the hash so far always overwrites the existing tiniest value\n \n tiniest_value = value\n smallest_key = key\n end\n end\n smallest_key\nend",
"def key_for_min_value(hash)\n hash_key = nil\n hash_value = nil\n hash.each do |key, value|\n if hash_value == nil || value < hash_value\n hash_value = value\n hash_key = key\n end\n end\n hash_key\nend",
"def key_for_min_value(hash)\n min_key = nil\n hash.each do |key, value|\n if min_key.nil?\n min_key = key\n elsif value < hash[min_key]\n min_key = key\n else\n next\n end\n end\n min_key\nend",
"def key_for_min_value(hash)\n min_key = nil\n hash.each do |key, value|\n if min_key.nil?\n min_key = key\n elsif value < hash[min_key]\n min_key = key\n else\n next\n end\n end\n min_key\nend",
"def key_for_min_value(hash)\n min = 99999999\n min_key = nil\n hash.select do |key, value|\n if value < min\n min = value\n min_key = key\n end\n end\n min_key\nend",
"def key_for_min_value(hash)\n if hash.empty?\n return nil\n end\n ans = [hash.first[0],hash.first[1]]\n hash.each do |k,v|\n if v < ans[1]\n ans[1] = v\n ans[0] = k\n end\n end\n return ans[0]\nend",
"def key_for_min_value(hash)\n key = nil\n lowest_value = nil\n hash.each do |name, value|\n if lowest_value == nil || value < lowest_value\n lowest_value = value\n key = name\n end\nend\nkey\nend",
"def key_for_min_value(hash)\n hash_key = nil\n hash_value = nil\n hash.each do |a, b|\n if hash_value == nil || b < hash_value\n hash_value = b\n hash_key = a\n end\n end\n hash_key\nend",
"def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = nil \n hash.each do |key, value|\n if lowest_value == nil || value < lowest_value \n lowest_value = value \n lowest_key = key \n end\n end\n lowest_key\nend",
"def key_for_min_value(name_hash)\n lowestnum = 1000\n name_hash.each_value do |hashvalue|\n if hashvalue < lowestnum\n lowestnum = hashvalue\n end\n end\n name_hash.index(lowestnum)\nend",
"def key_for_min_value(name_hash)\n lowest_key = nil\n lowest_number = nil\n name_hash.each do |name, number|\n if lowest_number == nil || number < lowest_number\n lowest_number = number\n lowest_key = name\n end\n end\n lowest_key\nend",
"def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = nil\n hash.each do |k,v|\n # first iteration\n ## this creates a starting point for comparison\n if lowest_value == nil || lowest_value > v\n lowest_value = v\n lowest_key = k\n end\n end\n lowest_key\nend",
"def key_for_min_value(name_hash)\n low = Float::INFINITY\n name_hash.each do |k,v|\n if v < low\n low = v\n end\n end\n name_hash.key(low)\nend",
"def key_for_min_value(hash)\n small_key = nil\n small_value = nil\n \n hash.each do |key, value|\n if small_value == nil || value < small_value\n small_value = value\n small_key = key\n end\nend\nsmall_key\nend",
"def key_for_min_value(hash)\n low_min = 1000\n min_key = nil\n hash.each do |key, value|\n if(low_min > value)\n low_min = value\n min_key = key\n end\nend\n min_key\nend",
"def key_for_min_value(name_hash)\n lowest = nil\n key = nil\n if name_hash.length == 0\n return \n end\n \n name_hash.each do |name, number|\n if lowest == nil\n lowest = number\n end\n if key == nil\n key = name\n end\n if number < lowest\n lowest = number\n key = name\n end\n end\n key\nend",
"def key_for_min_value(hash)\n least_value = nil \n least_key = nil\n hash.each do |a, b|\n if least_value == nil || b < least_value\n least_value = b\n least_key = a\n end\n end\n least_key\nend",
"def key_for_min_value(name_hash)\n\tif name_hash == {}\n\t\tnil\n\tend\n\n\tsmallest_key = nil\n\tsmallest_value = nil\n\tname_hash.each do |key, value|\n\t\tif !smallest_value || value < smallest_value\n\t\t\tsmallest_key = key\n\t\t\tsmallest_value = value\n\t\tend\n\tend\n\tsmallest_key\nend",
"def key_for_min_value(hash)\n i = 0\n lowest1 = :key\n lowest = 0\n if hash.empty? == true \n return nil\n end\n hash.each do |name, value|\n if i == 0\n lowest1 = name\n lowest = value\n i =+ 1\n end\n if value < lowest\n lowest1 = name\n lowest = value\n end\n if hash.empty? == true \n lowest1 = nil\n end\n end\n lowest1\nend",
"def key_for_min_value(name_hash)\n lowest_key = nil\n lowest_value = Float::INFINITY\n name_hash.each do |name, amount|\n if amount < lowest_value\n lowest_value = amount\n lowest_key = name\n end\n end\n lowest_key\n end",
"def key_for_min_value(hash)\n lo_key = nil \n lo_value = nil \n hash.each do |k,v| \n if lo_key == nil || v < lo_value\n lo_key = k \n lo_value = v \n end \n end \n lo_key\n end",
"def key_for_min_value(hash)\n\n lowest_key = nil \n lowest_value = nil \n \n hash.each do |key,value|\n if lowest_value == nil || lowest_value > value\n\n lowest_key = key\n lowest_value = value \n end \n \n end \n lowest_key\nend",
"def key_for_min_value(name_hash)\n small_num = Float::INFINITY\n smallest_key = \"\"\n if name_hash.length == 0\n return nil\n end\n name_hash.each do |key, value|\n if value < small_num\n small_num = value\n smallest_key = key\n end\n end\nsmallest_key\nend",
"def key_for_min_value(hash)\n value_only_array = []\n hash.each_pair do |key, value|\n value_only_array << value\n end\n value_only_array.sort!\n hash.key(value_only_array[0])\nend",
"def key_for_min_value(hash)\n return nil if hash.empty?\n arr = hash.collect {|key, value| value}.sort\n hash.each {|key, value| return key if value == arr[0]}\nend",
"def key_for_min_value(hash)\n array = []\n hash.each do |key, value|\n array << value\n end\n array.sort!\n hash.key(array[0])\nend",
"def key_for_min_value(name_hash)\n lowest_key=nil\n lowest_value=Float::INFINITY\n name_hash.each{|key, value| \n if value<lowest_value\n lowest_value=value\n lowest_key=key\n end\n }\n lowest_key\nend",
"def key_for_min_value(name_hash)\n empty_hash = nil\n lowest_value = 10000000000000000000000\n name_hash.collect do |name, value|\n if value < lowest_value\n lowest_value = value\n empty_hash = name\n end\n end\n empty_hash\nend",
"def key_for_min_value(name_hash)\n lowest = \"\"\n lowest = nil if name_hash.empty?\n high_num = 100000000000000000\n name_hash.each do | key, value |\n lowest = key if value < high_num\n high_num = value if value < high_num\n end\n lowest\nend",
"def key_for_min_value(name_hash)\n lowest_key = nil\n lowest_value = nil\n name_hash.each do |name, num|\n if lowest_key == nil || num < lowest_value\n lowest_key = name\n lowest_value = num\n elsif name_hash == nil\n nil\n end\n end\n lowest_key\nend",
"def key_for_min_value(name_hash)\n num = nil\n name_hash.collect do |key, value|\n if value < num\n num = value\n end\n end \n name_hash.key(num)\nend",
"def key_for_min_value(name_hash)\n smallest_val = 0\n smallest_key = nil\n name_hash.each do|key, val|\n if smallest_val == 0 || val < smallest_val\n smallest_val = val\n smallest_key = key\n end\n end\n smallest_key\n\nend",
"def key_for_min_value(name_hash)\n smallest_hash_key = nil\n name_hash.each do |key, val|\n if smallest_hash_key == nil\n smallest_hash_key = key\n next\n elsif val < name_hash[smallest_hash_key]\n smallest_hash_key = key\n end\n end\n smallest_hash_key\nend",
"def key_for_min_value(hash)\n if hash.count < 2\n return hash[0]\n else \n num = 42\n hash.each do |key, value|\n if value <= num\n num = value\n end\n end\n hash.invert[num] \n end\nend",
"def key_for_min_value(name_hash)\n return nil if name_hash.empty?\n lowest_number = name_hash.first[1];\n key_value = \"\"\n name_hash.each do |key, value|\n if value <= lowest_number\n lowest_number = value\n key_value = key\n end\n end\n key_value\nend",
"def key_for_min_value(name_hash)\n current = 0\n lowest = 0\n lowest_key = nil\n name_hash.collect do |key, value|\n current = value\n if current < lowest || lowest == 0\n lowest = current\n lowest_key = key\n end\n\n end\n lowest_key\nend",
"def key_for_min_value(name_hash)\n lowest_key = nil\n lowestvalue = 1000\n name_hash.each do |name, value|\n if value < lowestvalue\n lowest_key = name\n lowestvalue = value\n end\n end\n lowest_key\nend",
"def key_for_min_value(name_hash)\n small_value = 10000000000\n small_key = nil\n name_hash.each do |k,v|\n if v < small_value\n small_value = v\n small_key = k\n end\n end\n small_key\nend",
"def key_for_min_value(name_hash)\n low_key = nil\n low_value = nil\n name_hash.each do |k, v|\n if low_value == nil || v < low_value\n low_value = v\n low_key = k\n end\n end\n low_key\n end",
"def key_for_min_value(hash)\n lowest_value = nil\n lowest_key = nil\n\n hash.each do |key, value|\n if lowest_value == nil # tell me if this makes sense\n lowest_value = value\n lowest_key = key\n elsif lowest_value > value\n lowest_value = value\n lowest_key = key\n end\n end\n lowest_key #you want to return the key for min\nend",
"def key_for_min_value(hash)\n \n if hash.empty?\n return nil\n end\n min_value=500\n min_key=:symbol\n \n hash.each do |key, value|\n if value<min_value\n min_value=value\n min_key=key\n end\n end\n return min_key\nend",
"def key_for_min_value(name_hash)\n lowestKey = nil\n lowestValue = Float::INFINITY\n name_hash.each do |k, v|\n if v < lowestValue\n lowestValue = v\n lowestKey = k\n end\n end\n lowestKey\n\nend",
"def key_for_min_value(name_hash)\n smallest_val = 0\n smallest_key = 0\n comp = nil\n name_hash.each do |key,val|\n comp = val\n if smallest_key == 0\n smallest_key = key\n smallest_val = val\n end \n if comp < smallest_val\n smallest_val = comp\n smallest_key = key\n end\n end\n if smallest_key == 0 \n return nil \n else\n return smallest_key\n end\nend",
"def key_for_min_value(name_hash)\n lowest_key=nil\n lowest_val=0\n name_hash.collect do |key,value|\n if value<lowest_val or lowest_val==0\n lowest_key=key\n lowest_val=value\n end\n end\n lowest_key\nend",
"def key_for_min_value(name_hash)\n smallest = nil\n this_num = 0\n previous_num = 1000000\n name_hash.collect { |item, qty|\n this_num = qty\n if this_num < previous_num\n smallest = item\n previous_num = this_num\n end\n }\n smallest\nend",
"def key_for_min_value(name_hash)\n rkey = nil\n rvalue = 10000000000000000\n name_hash.each do |key, value|\n if value < rvalue\n rkey = key\n rvalue = value\n end\n end\n rkey\nend",
"def key_for_min_value(name_hash)\n\tsmallest_value = nil\n\tassociated_key = nil \n\tname_hash.collect do |key, value|\n\t\tif smallest_value == nil || value < smallest_value\n\t\t\tsmallest_value = value \n\t\t\tassociated_key = key\n\t \tend\n\tend\n\tassociated_key\nend",
"def key_for_min_value(hash)\n # binding.pry\n lowest_key = nil\n lowest_value = 0\n # binding.pry\n hash.each do |key, value|\n if lowest_key == nil || value < lowest_value\n # binding.pry\n lowest_value = value\n lowest_key = key\n # binding.pry\n end\n end\n lowest_key\nend",
"def key_for_min_value(hash)\n hash.key(hash.values.min)\nend",
"def key_for_min_value(hash)\n hash.key(hash.values.min)\nend",
"def key_for_min_value(name_hash)\n smallest_value = 100\n name_hash.each do |key, value| \n if value < smallest_value\n smallest_value = value \n end \n end\n name_hash.key(smallest_value)\nend",
"def key_for_min_value(name_hash)\n lowest=\"\"\n lowest=nil if name_hash.empty?\n tracker=100000000\n name_hash.each do |key,value|\n lowest=key if value<tracker\n tracker=value if value<tracker\n # if value<tracker\n end\n lowest\nend",
"def key_for_min_value(name_hash)\n if name_hash.length == 0 \n nil\n else\n smallest_num = nil\n smallest_num_key = nil\n name_hash.collect do |key, value|\n if smallest_num == nil\n smallest_num = value\n smallest_num_key = key\n elsif smallest_num > value\n smallest_num = value\n smallest_num_key = key\n end\n end\n smallest_num_key\n end\n\nend",
"def key_for_min_value(name_hash)\n low_key = nil\n low_value = nil\n name_hash.each do |n, s|\n if low_value == nil\n low_value = s\n low_key = n\n elsif low_value > s\n low_value = s\n low_key = n\n end\n end\n low_key\nend",
"def key_for_min_value(name_hash)\n return nil if name_hash == nil || name_hash == {}\n number_array = name_hash.collect do |name, number|\n number\n end\n number_array.sort!\n name_hash.key(number_array[0])\nend",
"def key_for_min_value(name_hash)\n lowestId = nil\n lowestNum = 0\n name_hash.each{ |id, val|\n if lowestNum == 0 \n lowestNum = val\n end\n if val <= lowestNum\n lowestNum = val\n lowestId = id\n end\n }\n return lowestId\nend",
"def key_for_min_value(name_hash)\n lowest_v = nil\n lowest_k = nil\n name_hash.each do |name, value|\n if lowest_v == nil\n lowest_v = value\n lowest_k = name\n elsif value < lowest_v\n lowest_v = value\n lowest_k = name\n end\n end\n lowest_k\n end",
"def key_for_min_value(name_hash)\n smallest_key = nil\n smallest_value = nil\n name_hash.each do |j, r|\n if smallest_value == nil || r < smallest_value\n smallest_value = r\n smallest_key = j\n end\n end\n smallest_key\nend",
"def key_for_min_value(name_hash)\nlowest = 1000000\n low_key = nil\n name_hash.each {|key, value|\n if value < lowest\n lowest = value\n low_key = key\n end\n }\n low_key\nend",
"def key_for_min_value(name_hash)\n lowest_key = nil\n name_hash.each_key do |key|\n if lowest_key == nil\n lowest_key = key\n elsif name_hash[key] < name_hash[lowest_key]\n lowest_key = key\n end\n end\n lowest_key\nend",
"def key_for_min_value(name_hash)\n\n if name_hash.empty?\n return nil\n end\n lowest = Float::INFINITY\n name_hash.each_pair do |k, v|\n if v < lowest\n lowest = v\n end\n end\n name_hash.each_pair do |k, v|\n if v == lowest\n return k\n end\n end\nend",
"def key_for_min_value(name_hash)\n output = 0\n smallest = nil\n name_hash.map do |key, value|\n if value < output || output == 0\n output = value\n smallest = key\n end\n end\n\n smallest\nend",
"def key_for_min_value(my_hash)\n #what is my value?\n lowest_value = 500\n lowest_key = nil\n\n my_hash.collect do |key, value|\n # what is my value?\n if value < lowest_value\n lowest_value = value\n lowest_key = key\n end\n end\n lowest_key\nend",
"def key_for_min_value(name_hash)\n lowest_num = 1000000000\n lowest_num_key = \" \"\n if name_hash == {}\n return nil\n else\n name_hash.each do |name, num|\n if num < lowest_num\n lowest_num = num\n lowest_num_key = name\n end\n end\n return lowest_num_key\n end\nend",
"def key_for_min_value(name_hash)\n nums = name_hash.collect do |item, num|\n num\n end\n nums.sort!\n nums[0]\n \n min_key = nil\n name_hash.map do |item, num|\n if num == nums[0]\n min_key = item\n end\n end\n min_key\nend",
"def key_for_min_value(name_hash)\n vals = name_hash.collect { |key, value| value }\n keys = name_hash.collect { |key, value| key }\n low = vals[0]\n lowkey = keys[0]\n if name_hash.empty?\n nil\n else\n name_hash.collect do |key, value|\n if value < low\n low = value\n lowkey = key\n end\n end\n lowkey\n end\nend",
"def key_for_min_value(name_hash)\n value1 = 0\n lowestKey = nil\n name_hash.each do |key, value|\n if(value1 == 0)\n value1 = value\n lowestKey = key\n end\n if(value1 > value)\n value1 = value\n lowestKey = key\n elsif (value1 < value)\n lowestKey = lowestKey\n value1 = value1\n end\n end\n return lowestKey\nend",
"def key_for_min_value(hash)\n return nil if hash.empty?\n arr = hash.collect { |k, v| v }.sort\n hash.each { |k, v| return k if v == arr[0] }\nend",
"def key_for_min_value(name_hash)\n # saves the smaller value in memo, and takes the first elem of memo at the end (the key)\n smallest = name_hash.inject do|memo, (k, v)|\n memo = v < memo[1] ? [k,v] : memo\n end\n #handle the empty hash case...\n smallest ? smallest[0] : nil\nend",
"def key_for_min_value(name_hash)\n key = \"\"\n low_value = nil\n if name_hash.empty? == true\n return nil\n end\n name_hash.each do |name, number|\n if low_value == nil || number < low_value\n low_value = number\n key = name\n end\n end\n key\nend",
"def key_for_min_value(name_hash)\n answer = nil\n smallest = nil\n name_hash.each {|key, value|\n if smallest.nil?\n smallest = value\n end\n if value <= smallest\n smallest = value\n answer = key\n end\n }\n answer\nend",
"def smallest_key(q, hash)\n\t\ttemp = {}\n\t\tq.each do |v|\n\t\t\ttemp[v] = hash[v]\n\t\tend\n\t\treturn temp.key(temp.each_value.min)\n\tend",
"def key_for_min_value(name_hash)\n lowest_value = 0\n lowest_key = \"\"\n if name_hash.empty? == true\n nil\n else\n name_hash.each_with_index do |(key, value), i|\n if i == 0\n lowest_value = value\n lowest_key = key\n elsif value < lowest_value\n lowest_value = value\n lowest_key = key\n end\n end\n lowest_key\n end\nend",
"def key_for_min_value(name_hash)\n low=10000000000000000000\n return_key=nil\n name_hash.each do |key, value|\n if value<low\n low=value\n return_key=key\n end\n end\n return_key\nend",
"def key_for_min_value(hash)\n if hash.length == 0\n return nil\n else\n smallest = 1000\n printme = \"\"\n hash.each do |thing, number|\n if number < smallest\n smallest = number\n printme = thing\n end\n end\n printme\n end\nend",
"def key_for_min_value(name_hash)\n \n lowest_key = nil\n lowest_value = nil\n name_hash.each do |name_key, name_value|\n if lowest_value == nil || name_value < lowest_value\n lowest_value = name_value\n lowest_key = name_key\n end\n end\n lowest_key\n \n end",
"def key_for_min_value(name_hash)\n the_key = nil \n the_value = 1/0.0\n # Infinity...can also be expressed as FLOAT::Infinity\n name_hash.each do |id, num|\n if num <= the_value\n the_value = num\n the_key = id\n end\n end\n the_key\nend",
"def key_for_min_value(hash)\n array = []\n hash.each {|key,value| \n if array.empty? || value < array[1] \n array[0] = key \n array[1] = value \n end }\n if !array.empty? \n array.first \n else \n nil \n end\nend",
"def key_for_min_value(name_hash)\n lowest_key = nil\n lowest_value = Float::INFINITY\n name_hash.each do |k,v|\n if v < lowest_value\n lowest_value = v\n lowest_key = k\n end \nend\nlowest_key\nend",
"def key_for_min_value(name_hash)\n return nil if name_hash == {}\n smallest_key = name_hash.first[0]\n smallest_val = name_hash.first[1]\n\n name_hash.each do |pair|\n if pair[1] < smallest_val\n smallest_key = pair[0]\n end\n end\n smallest_key\nend",
"def key_for_min_value(name_hash)\n key_of_smallest_value = \"\"\n smallest_value = 99999\n name_hash.each do |key, value|\n if smallest_value > value\n smallest_value = value\n key_of_smallest_value = key\n end\n end\n if name_hash.size == 0\n key_of_smallest_value = nil\n end\n key_of_smallest_value\nend",
"def key_for_min_value(name_hash)\n smallest_value = Float::INFINITY\n key_for_smallest_val = nil\n name_hash.each do |key, value|\n if smallest_value > value\n smallest_value = value\n key_for_smallest_val = key\n end \n end \n key_for_smallest_val\nend",
"def key_for_min_value(name_hash)\n minKey = nil\n minVal = 2 ** (64 - 2) - 1\n name_hash.each {|key, value|\n if value < minVal\n minVal = value\n minKey = key\n end}\n minKey\nend",
"def key_for_min_value(name_hash)\n if name_hash == {}\n return nil\n end\n lowest_number = nil\n name_hash.collect do |name, value|\n if lowest_number == nil\n lowest_number = value\n elsif lowest_number > value\n lowest_number = value\n end\n end\n \n name_hash.each do |name, value|\n if lowest_number == value\n return name\n end\n end\nend",
"def key_for_min_value(hash)\n min_value = hash.values.min\n keys = hash.collect do |key, num|\n \tkey if num == min_value\n end\n keys\nend",
"def key_for_min_value(name_hash)\n lowest_value = nil\n key_value = nil\n name_hash.collect do |name, number|\n if lowest_value == nil || number < lowest_value\n lowest_value = number\n key_value = name\n end\n end\n key_value\nend",
"def key_for_min_value(name_hash)\n smallest_value = 1/0.0\n key_of_smallest_value = nil\n name_hash.each do |key, value|\n if smallest_value > value\n key_of_smallest_value = key\n smallest_value = value\n end\n end\n return key_of_smallest_value\nend"
] |
[
"0.8821222",
"0.8777674",
"0.87769854",
"0.8745862",
"0.8689437",
"0.86553806",
"0.865241",
"0.86165065",
"0.8587693",
"0.8572328",
"0.85674095",
"0.8550907",
"0.8529734",
"0.8529734",
"0.85182345",
"0.84936565",
"0.8475531",
"0.8475531",
"0.8466132",
"0.8449126",
"0.84490585",
"0.84359556",
"0.84328413",
"0.8430745",
"0.8428166",
"0.84090126",
"0.8388222",
"0.83684903",
"0.83568215",
"0.83524764",
"0.8345625",
"0.8343887",
"0.8328773",
"0.83284044",
"0.83269894",
"0.83253354",
"0.83201903",
"0.83164364",
"0.8312503",
"0.8312319",
"0.8304851",
"0.83014053",
"0.83008987",
"0.82917446",
"0.8288315",
"0.82870966",
"0.8274123",
"0.82674986",
"0.8267187",
"0.82527804",
"0.8250538",
"0.82443976",
"0.82439804",
"0.8243696",
"0.82416916",
"0.8240566",
"0.823854",
"0.82375354",
"0.82283455",
"0.82274485",
"0.82205135",
"0.82190055",
"0.82136935",
"0.82136935",
"0.82102376",
"0.82101446",
"0.82060164",
"0.8200657",
"0.81985617",
"0.81966525",
"0.81958514",
"0.81932545",
"0.81874573",
"0.8186549",
"0.8185174",
"0.8183619",
"0.8183068",
"0.8182941",
"0.8179895",
"0.8173536",
"0.81732464",
"0.8172825",
"0.81721044",
"0.8171692",
"0.81681263",
"0.8165602",
"0.81609225",
"0.8160289",
"0.81587887",
"0.815757",
"0.8154019",
"0.81534094",
"0.8152752",
"0.81524456",
"0.8151455",
"0.81511825",
"0.8151019",
"0.8146792",
"0.814368",
"0.8142542",
"0.81412685"
] |
0.0
|
-1
|
Caching index action as page caches_page :index GET /orgs/1/map.html HTML
|
def index
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n @maps = Map.order(name: :asc)\n @title = 'Maps'\n @page_class = 'maps'\n end",
"def index\n @maps = Map.all\n end",
"def index\n @organisations = Queries::Organisations.order_by_most_recent\n @markers = build_map_markers(@organisations)\n end",
"def render_index_mapview\n static_geojson_file_loc = \"#{Rails.root}/#{GEOJSON_STATIC_FILE['filepath']}\"\n if Rails.env.to_s == 'production' && params[:action] == 'map' && File.exist?(static_geojson_file_loc)\n geojson_for_map = File.open(static_geojson_file_loc).first\n else\n geojson_for_map = serialize_geojson(map_facet_values)\n end\n render partial: 'catalog/index_mapview',\n locals: { geojson_features: geojson_for_map }\n end",
"def index\n @map_nodes = Map::Node.paginate(:page => params[:page], :per_page => 64)\n\n respond_to do |format|\n format.html # index.html.erb\n end\n end",
"def index\n @maps = Map.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @maps }\n end\n end",
"def index\n # == show the source and destinations\n #OPTIMIZE\n @maps = Map.all\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @maps }\n end\n end",
"def index\n @maps = Map.all\n # gon.meta_data = @maps.last.meta_data\n end",
"def map\n render :template=>'edgarj/map', :layout=>false\n end",
"def index\n #Page.all is fine for small sets of data, for larger sets pagination would be best\n @pages = data_cache('pages', 10.minutes) do\n Page.all\n end\n respond_to do |format|\n format.json { render action: 'index', status: :ok, location: api_pages_url(@pages) }\n format.xml { render xml: @pages, location: api_pages_url(@pages) }\n end\n end",
"def index\n\n @pubs = policy_scope(Pub).where.not(latitude: nil, longitude: nil)\n\n @markers = @pubs.map do |pub|\n {\n lat: pub.latitude,\n lng: pub.longitude,\n icon: view_context.image_path(\"map-marker-black.png\"),\n infoWindow: { content: render_to_string(partial: \"/pubs/map_box\", locals: { pub: pub }) }\n }\n end\n end",
"def index\n @concept_maps = ConceptMap.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json:@concept_maps }\n end\n end",
"def index\n @content_mappings = ContentMapping.find(:all, :order => 'page_id ASC, section_id ASC')\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @content_mappings }\n end\n end",
"def index\n Page.first\n Rails.cache.write('status', true)\n head :ok\n end",
"def index\n #@world_maps = WorldMap.all\n\n respond_to do |format|\n format.html # index.erb.erb\n format.json { render json: @world_maps }\n end\n end",
"def map\n if params[:mapid] == 'index'\n map_data = []\n projects = Project.where(user_id: current_user.id)\n projects.each do |project|\n if project.coordinates\n project_hash = {\n path: project_path(project),\n title: project.title.titleize,\n date: DateCreator.stringify(project.date),\n coordinates: project.coordinates\n }\n map_data << project_hash\n end\n end\n respond_to do |format|\n format.json { render :json => map_data }\n end\n end\n end",
"def index\n if !params[:map_id]\n @nodes = Node.all\n render :master_index\n else\n @map = Map.find(params[:map_id])\n end\n end",
"def index\n #@usemap = true\n\n @stories = Story.editable_user(current_user.id) \n respond_to do |format|\n format.html #index.html.erb\n format.json { render json: @stories }\n end\n end",
"def index\n @map_bounds = [20, 20]\n @current_position = [0,0]\n @map = []\n @spots_around = [[-1, 0], [1, 0], [0, -1], [0, 1]]\n create_initial_map\n generate_map\n end",
"def index\n @estate_maps = EstateMap.all\n end",
"def index\n @maps = Map.order(\"id DESC\").all\n end",
"def index\n @organization_pages, @organizations = paginate :organizations, :per_page => 25, :order => \"position\"\n render :action => \"index\", :layout => false if request.xhr?\n end",
"def index\n @gmaps = Gmap.all\n end",
"def index\n @placa_casas = PlacaCasa.all\n @placa_casas = PlacaCasa.search(params[:search])\n @placa_casas = @placa_casas.paginate :page => params[:page], :order => 'created_at ASC', :per_page => 10\n\n @map = GMap.new(\"map_div\")\n @map.control_init(:large_map => true,:map_type => true)\n @map.set_map_type_init(GMapType::G_NORMAL_MAP)\n @map.center_zoom_init(@placa_casas.first.placa.fetch_coordinates,11)\n\n @placa_casas.each do |placa_casa|\n @map.overlay_init(GMarker.new([placa_casa.placa.latitude,placa_casa.placa.longitude], :title => \"Placa residencial\", :info_window => \"<b>Placa residencial</b><BR>\" + placa_casa.placa.endereco))\n @marker = GMarker.new(placa_casa.placa.fetch_coordinates,:title => \"Update\", :info_window => \"I have been placed through RJS\")\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @placa_casas }\n end\n end",
"def index\n @organisations = Queries::Organisations.order_by_most_recent\n @markers = build_map_markers(@organisations)\n @cat_name_ids = Category.name_and_id_for_what_who_and_how\n end",
"def index\n\n current_location = Image.nearby( 0.2, 121.52847610518472, 25.04476753094792).first\n @hash = Gmaps4rails.build_markers(current_location) do |location, marker|\n marker.lat 25.04476753094792\n marker.lng 121.52847610518472\n end\n\n end",
"def index\n @process_maps = ProcessMap.all\n end",
"def fetch_sitemap\n sitemap = Rails.cache.read('sitemap')\n \n if sitemap.nil?\n puts \"#> sitemap MISSED cache\"\n sitemap = generate_sitemap\n @view_state[:sitemap] = sitemap\n Rails.cache.write('sitemap', sitemap)\n else\n puts \"#> sitemap HIT cache\"\n @view_state[:sitemap] = sitemap\n end\n end",
"def map\n # expires_in 1.year, public: true\n set_metadata({ 'title' => translate('classes.map_title') })\n\n countries = {\n ru: 'RU',\n cs: 'CZ',\n it: 'IT',\n ko: 'SK',\n }\n\n config = params.permit(:q, :country)\n config[:locale] = I18n.locale unless I18n.locale == :en\n config[:theme] = 'wemeditate'\n config[:country] ||= countries[I18n.locale]\n @atlas_url = \"https://atlas.sydevelopers.com/map/embed.js?key=#{ENV.fetch('ATLAS_KEY')}&#{config.to_query}\"\n @atlas_enabled = ENV['ATLAS_LOCALES'].split(',').include?(I18n.locale.to_s)\n \n render layout: 'minimal'\n end",
"def index\n no_cache\n super\n end",
"def requests_on_map\n params[:listing_type] = \"request\"\n @to_render = {:action => :index}\n @listings = Listing.open.order(\"created_at DESC\").find_with(params, @current_user, @current_community)\n @listing_style = \"map\"\n load\n end",
"def index\n @locations = @organization.locations.all\n\n @map = Cartographer::Gmap.new( 'map' )\n @map.zoom = :bound\n @map.icons << Cartographer::Gicon.new\n \n @organization.locations.each do |location|\n @map.markers << \n Cartographer::Gmarker.new(\n :name => 'location_'+Digest::MD5.hexdigest(location.name),\n :marker_type => \"Building\",\n :position => [location.lat, location.lng],\n :info_window_url => \"fixme.org\"\n )\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @locations }\n end\n end",
"def index\n render_index\n end",
"def index\n render\n end",
"def index\n session[\"cur_job_type_id\"]=params[:job_type_id]\n @job_type_id = params[:job_type_id]\n @job_type_id ||= JobType.find(:first).id\n @post_results = Rails.cache.fetch(\"index_#{@class_name}_type#{@job_type_id}_#{@school}_year#{params[:year]}_department#{params[:department]}_over#{params[:over]}\") do\n PostJob.paginated_post_conditions_with_option(params, @school, @job_type_id)\n end\n @posts = @post_results.paginate({:page => params[:page], :per_page => 10})\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @posts }\n end\n end",
"def index\n if @campaign\n @maps = @campaign.maps\n render json: @maps\n else\n render json: @maps.errors, status: :unprocessable_entity\n end\n end",
"def index\n @services = SystemSiteMap.where(:system_site_map_id => 2)\n\n respond_to do |format|\n format.html # index.html.erb\n end\n end",
"def index\n @companies = Company.where(\"approved = true\")\n\n # Not used yet\n if params[:search]\n @display = Company.all.where(type_of: params[:search])\n else\n @display = Company.all\n end\n\n @hash = Gmaps4rails.build_markers(@companies) do |company, marker|\n icon_url = set_marker_image(company.type_of)\n marker.lat company.latitude\n marker.lng company.longitude\n # marker.infowindow gmaps4rails_infowindow(company)\n marker.infowindow render_to_string(:partial => \"/companies/infowindow\", :locals => {:company => company})\n marker.json({id: company.id, title: company.name, cat: company.type_of })\n marker.picture({ \n :url => view_context.image_path(icon_url),\n :width => 32,\n :height => 32\n })\n end\n end",
"def index\n @mapimages = Mapimage.all\n end",
"def index\n respond_to do |format|\n format.html { redirect_to \"/\" }\n format.xml { render :xml => @maps }\n end\n end",
"def index\n @tiles = Tile.published\n @secret_tiles = Tile.secret\n end",
"def index\n @places = Place\n .all\n .includes(:words)\n .order(:name)\n .paginate(page: params[:page], per_page: 50)\n .load\n\n # Set @map_places to a hash with data for the map with all places\n @map_places = map_places\n end",
"def index\n all_cities = City.all\n return json_response([]) unless newest_city = all_cities.sort_by(&:updated_at).last\n Rails.logger.info \"newest_city is #{newest_city.inspect}\"\n render_if_stale(all_cities, last_modified: newest_city.updated_at.utc, etag: newest_city) do |city_presenters|\n city_presenters.map(&:hash)\n end\n # explicitly setting the Cache-Control response header to public and max-age, to make the response cachable by proxy caches\n expires_in caching_time, public: true\n end",
"def process_index\n bindings = {\n :url => @definition.get_url,\n :name => @definition.get_name,\n :resources => @definition.resources,\n :description => @definition.get_description,\n :version => @definition.get_version\n }\n\n page = Calamum::DocGenerator.new(:index)\n page.save_template('index.html', bindings)\n end",
"def em_index\n prepare_proxy_eventmachine('heap', {})\n render :nothing => true\n end",
"def map\n # expires_in 1.year, public: true\n set_metadata({ 'title' => translate('classes.map_title') })\n @config = params.permit(:q, :latitude, :longitude, :type, :west, :east, :south, :north)\n @config[:theme] = 'wemeditate'\n render layout: 'minimal'\n end",
"def index(entry)\n @cache[entry]\n end",
"def index\n @artwork_image_maps = ArtworkImageMap.order(\"id ASC\").paginate(:page => params[:page], :per_page => 10)\n end",
"def map_observation\n pass_query_params\n obs = find_or_goto_index(Observation, params[:id].to_s)\n return unless obs\n\n @title = :map_observation_title.t(id: obs.id)\n @observations = [\n MinimalMapObservation.new(obs.id, obs.public_lat, obs.public_long,\n obs.location)\n ]\n render(template: \"observations/map\")\n end",
"def index\n render \"opt10081s/index\",:layout=>false\n end",
"def index\n @mappings = Mapping.find(:all)\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @mappings.to_xml }\n end\n end",
"def recall_map_view\n get :map_view\n end",
"def index\n @cavaletes = Cavalete.all\n @cavaletes = Cavalete.search(params[:search])\n @cavaletes = @cavaletes.paginate :page => params[:page], :order => 'placas.cep DESC', :per_page => 10\n \n @map = GMap.new(\"map_div\")\n @map.control_init(:large_map => true,:map_type => true)\n @map.set_map_type_init(GMapType::G_NORMAL_MAP)\n @map.center_zoom_init(@cavaletes.first.placa.fetch_coordinates,11)\n\n @cavaletes.each do |cavalete|\n @map.overlay_init(GMarker.new([cavalete.placa.latitude,cavalete.placa.longitude], :title => \"Cavalete\", :info_window => \"<b>Cavalete</b><BR>\" + cavalete.placa.endereco))\n @marker = GMarker.new(cavalete.placa.fetch_coordinates,:title => \"Update\", :info_window => \"I have been placed through RJS\")\n end\n \n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @cavaletes }\n end\n end",
"def index\n render\n end",
"def index\n @tiles = Tile.all\n end",
"def index\n @tiles = Tile.all\n end",
"def index\n @menu = \"articles\"\n @num_articles = num_articles\n @page_number = 1\n begin\n @page_number = params[:page].to_i unless params[:page].blank?\n last_page = (@num_articles / Ufo::MAX_PAGE_ITEMS) + 1\n if @page_number <= 0\n @page_number = 1\n elsif @page_number > last_page\n @page_number = last_page\n end\n rescue\n logger.error \"Page number not valid!\"\n end\n @articles = Rails.cache.fetch(\"articles/index/#{@page_number}\", :expires_in => 1.week) do\n Article.where(:status => 1).without(:article_helper_method, :article_type, :date_filter, :email, :partial_1).desc(:published_date).skip((@page_number-1) * Ufo::MAX_PAGE_ITEMS).limit(Ufo::MAX_PAGE_ITEMS).entries\n end\n @page_title = \"Articles\"\n @page_description = \"Latest Articles\"\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @articles }\n end\n end",
"def index\n @jobs = Job.all\n @hash = Gmaps4rails.build_markers(@jobs) do |job, marker|\n marker.lat job.latitude\n marker.lng job.longitude\n marker.infowindow job.company_name\n end\n end",
"def index\n authorize :user\n if @localmap=Localmap.get(@user,params[:localID])\n @message=\"Found\"\n else\n @message=\"Not found\"\n end\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @localmap,:template => 'localmaps/localmap.xml.builder' }\n end\n end",
"def mini_map_index\n @mini_maps = MiniMap.find_all_by_houdd_user_id(params[:user_id])\n\n respond_to do |format|\n format.html # mini_map_index.html.erb\n end\n end",
"def show\n @title = \"#{@map.name} | Maps\"\n @page_class = \"maps-#{@map.name}\"\n end",
"def index\n @game_mappings = GameMapping.all\n end",
"def index\n @map_layers = MapLayer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @map_layers }\n end\n end",
"def index; end",
"def index\n render \"opt10059s/index\",:layout=>false\n end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index\n # binding.pry\n respond_to do |format|\n format.html do\n render :index,\n locals: {\n memoes: @memoes.jsonize(context),\n total: @memoes.total_size,\n cloud: @calendary_cloud.jsonize\n }\n end\n format.json do\n render plain: {\n list: @memoes.jsonize(context),\n page: @page,\n total: @memoes.total_size\n }.to_json(context)\n end\n end\n end",
"def index\n load_county or raise \"county not found\"\n\n breadcrumbs.add(:url=>@state.to_url, :title=>@state.name)\n breadcrumbs.add(:url=>@county.to_url, :title=>@county.name)\n self.page_title = \"#{@county.fancy_name_with_state} Cemetery Map\"\n\n @graveyards = @county.graveyards.includes(:main_photo).includes(:county)\n\n respond_to do |fmt|\n @visits=UserVisitsCollection.new(current_user)\n @visits.add_graveyards(@graveyards)\n fmt.json do\n render :json => {\n status: :success,\n locations: @graveyards.sort_by(&:name).map(&:map_data).map { |g|\n if v = @visits.visit_for(g[:id])\n g[:visit] = v.as_json(:only=> [\n :id, :status, :visited_on,\n :expedition_id, :ordinal, :quality\n ])\n end\n g\n },\n # visits: @visits\n }\n end\n fmt.html { render :action=>:index }\n end\n end",
"def index\n @clusters = []\n @project = Project.where(:key => params[:project_key]).first\n\n get_cluster_data() \n render :partial => 'index'\n end",
"def index\n @reports = Report.valid_reports\n @hash = Gmaps4rails.build_markers(@reports) do |report, marker|\n marker.lat report.latitude\n marker.lng report.longitude\n marker.infowindow report.post\n end\n end"
] |
[
"0.69520056",
"0.6661119",
"0.6482857",
"0.6466864",
"0.64429617",
"0.64428544",
"0.63820994",
"0.6355083",
"0.6286354",
"0.627518",
"0.62417454",
"0.6201808",
"0.6199001",
"0.619711",
"0.619149",
"0.61901766",
"0.6164313",
"0.6159369",
"0.61497134",
"0.61031294",
"0.6076383",
"0.60616213",
"0.6045427",
"0.5980777",
"0.5980596",
"0.59719133",
"0.5961767",
"0.5938311",
"0.5926478",
"0.59040326",
"0.5901576",
"0.58693224",
"0.58607763",
"0.5857198",
"0.58518887",
"0.5851472",
"0.5843615",
"0.5838884",
"0.5826759",
"0.58154684",
"0.58085996",
"0.580325",
"0.58022696",
"0.580081",
"0.5799036",
"0.5795483",
"0.5779685",
"0.57787025",
"0.5763266",
"0.57516855",
"0.57458776",
"0.5732768",
"0.572971",
"0.5726725",
"0.5718958",
"0.5718958",
"0.571176",
"0.57107484",
"0.5710535",
"0.56986576",
"0.56985873",
"0.5690276",
"0.5674543",
"0.5662901",
"0.566264",
"0.56624675",
"0.56624675",
"0.56624675",
"0.56624675",
"0.56624675",
"0.56624675",
"0.56624675",
"0.56624675",
"0.56624675",
"0.56624675",
"0.56624675",
"0.56624675",
"0.56624675",
"0.56624675",
"0.56624675",
"0.56624675",
"0.56624675",
"0.56624675",
"0.56624675",
"0.56624675",
"0.56624675",
"0.56624675",
"0.56624675",
"0.56624675",
"0.56624675",
"0.56624675",
"0.56624675",
"0.56624675",
"0.56624675",
"0.56624675",
"0.56624675",
"0.56624675",
"0.56595004",
"0.5658642",
"0.5657658",
"0.56530577"
] |
0.0
|
-1
|
POST /orgs/1/map.html HTMl POST /orgs/1/map/create.html HTML /for passenger/
|
def create
raise Marker::NoRequiredFields if params[:markers].blank?
# params[:markers].each do |marker|
# @org.markers.create!(marker)
# end
Request.add( params[:org_id], current_user, "marker", "add", { :markers => params[:markers][0..2] })
respond_success "Спасибо, Ваш запрос отправлен"
rescue ActiveRecord::RecordInvalid, ActiveRecord::RecordNotSaved => e
respond_error
rescue Marker::NoRequiredFields => e
respond_error e.message
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create\n #FIXME check\n @map = Map.new(params[:map])\n\n respond_to do |format|\n if @map.save\n format.html { redirect_to(@map, :notice => 'Map was successfully created.') }\n format.xml { render :xml => @map, :status => :created, :location => @map }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @map.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @map = Map.new(params[:map])\n @map.user = current_user\n\n\n respond_to do |format|\n if @map.save\n format.html { redirect_to request.env[\"HTTP_REFERER\"] || @map.mapable, notice: 'Map added!' }\n format.json { render json: @map, status: :created, location: @map }\n else\n format.html { redirect_to request.env[\"HTTP_REFERER\"] }\n format.json { render json: @map.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @map = Map.new(map_params)\n\n respond_to do |format|\n if @map.save\n format.html { redirect_to maps_url }\n format.json { head :no_content }\n else\n format.html { redirect_to maps_url }\n format.json { render json: @map.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @map = Map.new(map_params)\n\n respond_to do |format|\n if @map.save\n format.html { redirect_to @map, notice: 'Map was successfully created.' }\n format.json { render action: 'show', status: :created, location: @map }\n else\n format.html { render action: 'new' }\n format.json { render json: @map.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @map = current_user.maps.new(params[:map])\n\n respond_to do |format|\n if @map.save\n format.html { redirect_to @map, notice: 'Map was successfully created.' }\n format.json { render json: @map, status: :created, location: @map }\n else\n format.html { render action: \"new\" }\n format.json { render json: @map.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n map = Map.new;\n map.user_id = session[:user]['id']\n map.name = params['name']\n map.map_json = params['map_json']\n\n if map.save\n render json: {save: true, message: 'zapisano poprawnie mapę', callback: 'map'}\n else\n render json: {save: false, message: 'błąd podczas zapisu mapy', callback: 'map'}\n end\n end",
"def create\n @map = Map.new(map_params)\n\n respond_to do |format|\n if @map.save\n format.html { redirect_to @map, notice: 'Map was successfully created.' }\n format.json { render :show, status: :created, location: @map }\n else\n format.html { render :new }\n format.json { render json: @map.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @map = Map.new(params[:map])\n @map.user = current_user\n\n respond_to do |format|\n if @map.save\n format.html { redirect_to @map, notice: 'Map was successfully created.' }\n format.json { render json: @map, status: :created, location: @map }\n else\n format.html { render action: \"new\" }\n format.json { render json: @map.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @gmap = Gmap.new(params[:gmap])\n\n respond_to do |format|\n if @gmap.save\n format.html { redirect_to @gmap, notice: 'Gmap was successfully created.' }\n format.json { render json: @gmap, status: :created, location: @gmap }\n else\n format.html { render action: \"new\" }\n format.json { render json: @gmap.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @world_map = WorldMap.new(params[:world_map])\n\n respond_to do |format|\n if @world_map.save\n\n format.html { redirect_to @world_map, notice: 'World map was successfully created.' }\n format.json { render json: @world_map, status: :created, location: @world_map }\n else\n format.html { render action: \"new\" }\n format.json { render json: @world_map.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @map = CampaignMap.new(map_params)\n if is_dungeon_master?\n @map.campaign = @campaign\n if @map.save\n render json: @map, status: :created\n else\n render json: @map.errors, status: :unprocessable_entity\n end\n else\n render json: @map.errors, status: :forbidden\n end\n end",
"def create\n @tinymap = Tinymap.new(params[:tinymap])\n\n respond_to do |format|\n if @tinymap.save\n format.html { redirect_to @tinymap, notice: 'Tinymap was successfully created.' }\n format.json { render json: @tinymap, status: :created, location: @tinymap }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tinymap.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @gmap = Gmap.new(gmap_params)\n\n respond_to do |format|\n if @gmap.save\n format.html { redirect_to @gmap, notice: 'Gmap was successfully created.' }\n format.json { render :show, status: :created, location: @gmap }\n else\n format.html { render :new }\n format.json { render json: @gmap.errors, status: :unprocessable_entity }\n end\n end\n end",
"def map\n render :template=>'edgarj/map', :layout=>false\n end",
"def create\n @google_map = GoogleMap.new(params[:google_map])\n\n respond_to do |format|\n if @google_map.save\n format.html { redirect_to(@google_map, :notice => 'Google map was successfully created.') }\n format.xml { render :xml => @google_map, :status => :created, :location => @google_map }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @google_map.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @system_site_map = SystemSiteMap.new(params[:system_site_map])\n\n respond_to do |format|\n if @system_site_map.save\n format.html { redirect_to @system_site_map, notice: 'System site map was successfully created.' }\n format.json { render json: @system_site_map, status: :created, location: @system_site_map }\n else\n format.html { render action: \"new\" }\n format.json { render json: @system_site_map.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @moretinymap = Moretinymap.new(params[:moretinymap])\n\n respond_to do |format|\n if @moretinymap.save\n format.html { redirect_to @moretinymap, notice: 'Moretinymap was successfully created.' }\n format.json { render json: @moretinymap, status: :created, location: @moretinymap }\n else\n format.html { render action: \"new\" }\n format.json { render json: @moretinymap.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n if params[:domain_map][:domain].blank?\n @req_error = \"req_error\"\n end\n if params[:domain_map][:map_type] == \"organisation\" \n params[:domain_map][:organisation_id] = current_organisation.id\n params[:domain_map][:program_id] = nil\n elsif\n params[:domain_map][:organisation_id] = nil\n end\n @domain_map = current_user.domain_maps.new(params[:domain_map])\n\n respond_to do |format|\n if @domain_map.save\n format.html { redirect_to domain_maps_url, notice: 'Domain map was successfully created.' }\n format.json { render json: domain_maps_url, status: :created, location: domain_maps_url }\n else\n format.html { render action: \"new\" }\n format.json { render json: @domain_map.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @estate_map = EstateMap.new(estate_map_params)\n\n respond_to do |format|\n if @estate_map.save\n format.html { redirect_to @estate_map, notice: 'Estate map was successfully created.' }\n format.json { render :show, status: :created, location: @estate_map }\n else\n format.html { render :new }\n format.json { render json: @estate_map.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post_code_electorate_map = PostCodeElectorateMap.new(post_code_electorate_map_params)\n\n respond_to do |format|\n if @post_code_electorate_map.save\n format.html { redirect_to @post_code_electorate_map, notice: 'Post code electorate map was successfully created.' }\n format.json { render :show, status: :created, location: @post_code_electorate_map }\n else\n format.html { render :new }\n format.json { render json: @post_code_electorate_map.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @map = @kanzume.maps.new(map_params)\n\n respond_to do |format|\n if @map.save\n format.html { redirect_to kanzume_map_path(kanzume_id: @map.kanzume_id,id: @map.id), notice: 'Map was successfully created.' }\n format.json { render :show, status: :created, location: kanzume_map_path(kanzume_id: @map.kanzume_id,id: @map.id) }\n else\n format.html { render :new }\n format.json { render json: @map.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @roadmap = Roadmap.new(params[:roadmap])\n\t\t@roadmap.user_id = current_user.id\n\n respond_to do |format|\n if @roadmap.save\n flash[:notice] = 'Roteiro criado com sucesso.'\n format.html { redirect_to(@roadmap) }\n format.xml { render :xml => @roadmap, :status => :created, :location => @roadmap }\n else\n\t\t\t\n\t\t\t\t# Recarrega os estados e as cidades se possivel\n\t\t\t\tload_states_and_cities(@roadmap)\n\n format.html { render :action => \"new\" }\n format.xml { render :xml => @roadmap.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n if current_user && current_user.role == \"admin\" \n saved,@node,@revision = DrupalNode.new_node({\n :uid => current_user.uid,\n :title => params[:title],\n :body => params[:body],\n :type => \"map\",\n :main_image => params[:main_image]\n })\n\n if saved\n if params[:tags]\n params[:tags].split(',').each do |tagname|\n @node.add_tag(tagname,current_user)\n end\n end\n \n # save main image\n if params[:main_image] && params[:main_image] != \"\"\n img = Image.find params[:main_image]\n unless img.nil?\n img.nid = @node.id\n img.save\n end\n end\n\n @node.add_tag('lat:'+params[:lat],current_user)\n @node.add_tag('lon:'+params[:lon],current_user)\n \n map = DrupalContentTypeMap.new\n map.nid = @node.nid\n map.vid = @node.nid\n\n map.field_publication_date_value = params[:map][:field_publication_date_value]\n map.field_capture_date_value = params[:map][:field_capture_date_value]\n map.field_geotiff_url_value = params[:map][:field_geotiff_url_value]\n map.field_google_maps_url_value = params[:map][:field_google_maps_url_value]\n map.field_openlayers_url_value = params[:map][:field_openlayers_url_value]\n map.field_tms_url_value = params[:map][:field_tms_url_value]\n map.field_jpg_url_value = params[:map][:field_jpg_url_value]\n map.field_license_value = params[:map][:field_license_value]\n map.field_raw_images_value = params[:map][:field_raw_images_value]\n map.field_cartographer_notes_value = params[:map][:field_cartographer_notes_value]\n map.field_notes_value = params[:map][:field_notes_value]\n map.field_mbtiles_url_value = params[:map][:field_mbtiles_url_value]\n map.field_zoom_min_value = params[:map][:field_zoom_min_value]\n map.field_zoom_min_value ||= 17\n map.field_ground_resolution_value = params[:map][:field_ground_resolution_value]\n map.field_geotiff_filesize_value = params[:map][:field_geotiff_filesize_value]\n map.field_jpg_filesize_value = params[:map][:field_jpg_filesize_value]\n map.field_raw_images_filesize_value = params[:map][:field_raw_images_filesize_value]\n map.field_tms_tile_type_value = params[:map][:field_tms_tile_type_value]\n map.field_zoom_max_value = params[:map][:field_zoom_max_value]\n\n # need to create/delete these. Maybe best just make a new field, no need to store individual records\n #@node.drupal_content_field_map_editor\n #@node.drupal_content_field_mappers.collect(&:field_mappers_value).uniq.join(', ')\n \n ActiveRecord::Base.transaction do # in case only part of this completes\n if @node.save && @revision.save && map.save\n flash[:notice] = \"Edits saved.\"\n redirect_to @node.path\n else\n flash[:error] = \"Your edit could not be saved.\"\n render :action => :edit\n end\n end\n else\n flash[:error] = \"Your edit could not be saved.\"\n render :template => \"map/edit\"\n end\n else\n prompt_login \"Only admins can publish maps at this time.\"\n end\n end",
"def create\n @usermap = Usermap.new(usermap_params)\n\n respond_to do |format|\n if @usermap.save\n format.html { redirect_to @usermap, notice: 'Usermap was successfully created.' }\n format.json { render :show, status: :created, location: @usermap }\n else\n format.html { render :new }\n format.json { render json: @usermap.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @requirement_map = RequirementMap.new(params[:requirement_map])\n\n respond_to do |format|\n if @requirement_map.save\n format.html { redirect_to(@requirement_map, :notice => 'Requirement map was successfully created.') }\n format.xml { render :xml => @requirement_map, :status => :created, :location => @requirement_map }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @requirement_map.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @role_map = RoleMap.new(params[:role_map])\n\n respond_to do |format|\n if @role_map.save\n format.html { redirect_to @role_map, notice: 'Role map was successfully created.' }\n format.json { render json: @role_map, status: :created, location: @role_map }\n else\n format.html { render action: \"new\" }\n format.json { render json: @role_map.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @location_url_map = LocationUrlMap.new(params[:location_url_map])\n\n respond_to do |format|\n if @location_url_map.save\n format.html { redirect_to @location_url_map, notice: 'Location url map was successfully created.' }\n format.json { render json: @location_url_map, status: :created, location: @location_url_map }\n else\n format.html { render action: \"new\" }\n format.json { render json: @location_url_map.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @roadmap = Roadmap.new(roadmap_params)\n\n respond_to do |format|\n if @roadmap.save\n format.html { redirect_to @roadmap, notice: 'Roadmap wurde erfolgreich angelegt' }\n format.json { render :show, status: :created, location: @roadmap }\n else\n format.html { render :new }\n format.json { render json: @roadmap.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @locationmap = Locationmap.new(params[:locationmap])\n\n respond_to do |format|\n if @locationmap.save\n format.html { redirect_to @locationmap, notice: 'Locationmap was successfully created.' }\n format.json { render json: @locationmap, status: :created, location: @locationmap }\n else\n format.html { render action: \"new\" }\n format.json { render json: @locationmap.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @map = Map.new(params[:map])\n @map.name = \"Map Created #{Time.now.strftime('at %I:%M%p')}\" if @map.name.blank?\n @map.description = \"No Description Provided\" if @map.description.blank?\n if points = params['markers']\n points.each do |marker_identifier, point|\n @map.points.build(:lat => point['lat'].to_f,:lng => point['lng'].to_f,:description =>point['description'], :marker_identifier => marker_identifier)\n end\n end\n respond_to do |format|\n if @map.save\n format.html { redirect_to(@map, :notice => 'Map was successfully created.') }\n else\n format.html { render :action => \"new\" }\n end\n end\n end",
"def create\n @mosttinymap = Mosttinymap.new(params[:mosttinymap])\n\n respond_to do |format|\n if @mosttinymap.save\n format.html { redirect_to @mosttinymap, notice: 'Mosttinymap was successfully created.' }\n format.json { render json: @mosttinymap, status: :created, location: @mosttinymap }\n else\n format.html { render action: \"new\" }\n format.json { render json: @mosttinymap.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @empathy_map = EmpathyMap.find_or_create_by(id: empathy_map_record_params[:empathy_map_id])\n @empathy_map_record = EmpathyMapRecord.new(empathy_map_record_params.merge(empathy_map_id: @empathy_map.id))\n\n respond_to do |format|\n if @empathy_map_record.save\n format.html { redirect_to @empathy_map_record, notice: 'Empathy map record was successfully created.' }\n format.json { render :show, status: :created, location: @empathy_map_record }\n else\n format.html { render :new }\n format.json { render json: @empathy_map_record.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @process_map = ProcessMap.new(process_map_params)\n\n respond_to do |format|\n if @process_map.save\n format.html { redirect_to process_maps_path, notice: 'Process map was successfully created.' }\n format.json { render :show, status: :created, location: @process_map }\n else\n format.html { render :new }\n format.json { render json: @process_map.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @entity_mapping = EntityMapping.new(params[:tapir_entity_mapping])\n\n respond_to do |format|\n if @entity_mapping.save\n format.html { redirect_to @entity_mapping, notice: 'Entity mapping was successfully created.' }\n format.json { render json: @entity_mapping, status: :created, location: @entity_mapping }\n else\n format.html { render action: \"new\" }\n format.json { render json: @entity_mapping.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @smallmap = Smallmap.new(params[:smallmap])\n\n respond_to do |format|\n if @smallmap.save\n format.html { redirect_to @smallmap, notice: 'Smallmap was successfully created.' }\n format.json { render json: @smallmap, status: :created, location: @smallmap }\n else\n format.html { render action: \"new\" }\n format.json { render json: @smallmap.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @indication_generic_map = IndicationGenericMap.new(indication_generic_map_params)\n\n respond_to do |format|\n if @indication_generic_map.save\n format.html { redirect_to @indication_generic_map, notice: 'Indication generic map was successfully created.' }\n format.json { render :show, status: :created, location: @indication_generic_map }\n else\n format.html { render :new }\n format.json { render json: @indication_generic_map.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_map_type(map_type_body, options = {})\n path = base_uri\n request(path, options.merge(method: :post), map_type_body).to_s\n end",
"def create\n @map_node = Map::Node.new(params[:map_node])\n\n respond_to do |format|\n if @map_node.save\n format.html { redirect_to @map_node, notice: 'Node was successfully created.' }\n format.json { render json: @map_node, status: :created, location: @map_node }\n else\n format.html { render action: \"new\" }\n format.json { render json: @map_node.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @land_use_mapping = LandUseMapping.new(params[:land_use_mapping])\n @title = \"land use mapping\"\n\n respond_to do |format|\n if @land_use_mapping.save\n format.html { redirect_to(@land_use_mapping, :notice => 'LandUseMapping was successfully created.') }\n format.xml { render :xml => @land_use_mapping, :status => :created, :location => @land_use_mapping }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @land_use_mapping.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n #@map = Map.new(params[:map])\n if !params[:type].nil?\n #update the map info: height and width\n @map = Map.find(params[:map_id])\n height_scale = (params[:height]).to_f/@map.height\n width_scale = (params[:width]).to_f/@map.width\n respond_to do |format|\n if @map.update_attributes(height: params[:height], width: params[:width])\n format.html { redirect_to @map, notice: 'Node was successfull y updated.' }\n format.json { render json: @map, status: :created, location: @map }\n #update the node info when the map info changed...\n @map.nodes.each do |node|\n new_x = node.x * width_scale\n new_y = node.y * height_scale\n node.update_attributes(x: new_x, y:new_y)\n end\n else\n format.html { render action: \"edit\" }\n format.json { render json: @map.errors, status: :unprocessable_entity }\n end\n end\n else\n @map = Map.new(params[:map])\n\n respond_to do |format|\n if @map.save\n format.html { redirect_to @map, notice: 'Map was successfully created.' }\n format.json { render json: @map, status: :created, location: @map }\n else\n format.html { render action: \"new\" }\n format.json { render json: @map.errors, status: :unprocessable_entity }\n end\n end\n end\n end",
"def create\n @shiftmap = Shiftmap.new(params[:shiftmap])\n\n respond_to do |format|\n if @shiftmap.save\n format.html { redirect_to @shiftmap, notice: 'Shiftmap was successfully created.' }\n format.json { render json: @shiftmap, status: :created, location: @shiftmap }\n else\n format.html { render action: \"new\" }\n format.json { render json: @shiftmap.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @group_map = GroupMap.new(params[:group_map])\n @group_map.owner == current_user\n @group_map.users << current_user\n\n respond_to do |format|\n if @group_map.save\n format.html { redirect_to @group_map, notice: 'Group map was successfully created.' }\n format.json { render json: @group_map, status: :created, location: @group_map }\n else\n format.html { render action: \"new\" }\n format.json { render json: @group_map.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @mapping = Mapping.new(params[:mapping])\n respond_to do |format|\n if @mapping.save\n flash[:notice] = 'Mapping was successfully created.'\n format.html { redirect_to mappings_url }\n format.xml { head :created, :location => mappings_url }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @mapping.errors.to_xml }\n end\n end\n end",
"def create\n @abstractnmap = Abstractnmap.new(params[:abstractnmap])\n\n respond_to do |format|\n if @abstractnmap.save\n format.html { redirect_to(@abstractnmap, :notice => 'Abstractnmap was successfully created.') }\n format.xml { render :xml => @abstractnmap, :status => :created, :location => @abstractnmap }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @abstractnmap.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @view_mapping = ViewMapping.new(params[:view_mapping])\n\n respond_to do |format|\n if @view_mapping.save\n format.html { redirect_to @view_mapping, notice: 'View mapping was successfully created.' }\n format.json { render json: @view_mapping, status: :created, location: @view_mapping }\n else\n format.html { render action: \"new\" }\n format.json { render json: @view_mapping.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @map = Map.new(map_params)\n @file = @map.meta_data\n # binding.pry\n\n @meta_data = []\n @kind = @map.kind\n fips_to_hc_key\n @map.meta_data = @meta_data\n respond_to do |format|\n if @map.save\n format.html { redirect_to @map, notice: 'Map was successfully created.' }\n format.json { render :show, status: :created, location: @map }\n else\n format.html { render :new }\n format.json { render json: @map.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @concept_map = ConceptMap.new(params[:concept_map])\n respond_to do |format|\n if@concept_map.save\n #if@concept_map.rb.status == 1\n Content.send_message_to_est(false,current_user,@concept_map)\n #end\n format.html { redirect_to@concept_map, notice: 'ConceptMap was successfully created.' }\n format.json { render json:@concept_map, status: :created, location:@concept_map }\n else\n format.html { render action: \"new\" }\n format.json { render json:@concept_map.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @mapping = Mapping.new(params[:mapping])\n\n respond_to do |format|\n if @mapping.save\n flash[:notice] = 'Mapping was successfully created.'\n format.html { redirect_to(@mapping) }\n format.xml { render :xml => @mapping, :status => :created, :location => @mapping }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @mapping.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n #TODO\n @map = Map.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @map }\n end\n end",
"def create\n @openmapa = Openmapa.new(params[:openmapa])\n\n respond_to do |format|\n if @openmapa.save\n flash[:notice] = 'Openmapa was successfully created.'\n format.html { redirect_to(@openmapa) }\n format.xml { render :xml => @openmapa, :status => :created, :location => @openmapa }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @openmapa.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def map\n # expires_in 1.year, public: true\n set_metadata({ 'title' => translate('classes.map_title') })\n @config = params.permit(:q, :latitude, :longitude, :type, :west, :east, :south, :north)\n @config[:theme] = 'wemeditate'\n render layout: 'minimal'\n end",
"def create\n @my_map = current_my_map\n place = Place.find(params[:place_id])\n @way_point = @my_map.add_place(place.id)\n\n respond_to do |format|\n if @way_point.save\n format.html { redirect_to @way_point.my_map, notice: 'マイマップに追加しました。' }\n format.json { render action: 'show', status: :created, location: @way_point }\n else\n format.html { render action: 'new' }\n format.json { render json: @way_point.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @sasmap = Sasmap.new(params[:sasmap])\n\n respond_to do |format|\n if @sasmap.save\n format.html { redirect_to @sasmap, notice: 'Sasmap was successfully created.' }\n format.json { render json: @sasmap, status: :created, location: @sasmap }\n else\n format.html { render action: \"new\" }\n format.json { render json: @sasmap.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @map_image = MapImage.new(params[:map_image])\n\n respond_to do |format|\n if @map_image.save\n format.html { redirect_to(@map_image, :notice => 'Map image was successfully created.') }\n format.xml { render :xml => @map_image, :status => :created, :location => @map_image }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @map_image.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @map = Map.new\n\n puts @saved_locations\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @map }\n end\n end",
"def create\n @map_author = MapAuthor.new(params[:map_author])\n\n respond_to do |format|\n if @map_author.save\n format.html { redirect_to([:admin, @map_author], :notice => 'Map author was successfully created.') }\n format.xml { render :xml => @map_author, :status => :created, :location => @map_author }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @map_author.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @domain_mapping = DomainMapping.new(params[:domain_mapping])\n\n respond_to do |format|\n if @domain_mapping.save\n format.html { redirect_to(@domain_mapping, :notice => 'Domain mapping was successfully created.') }\n format.xml { render :xml => @domain_mapping, :status => :created, :location => @domain_mapping }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @domain_mapping.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @sessionmap = Sessionmap.new(params[:sessionmap])\n\n respond_to do |format|\n if @sessionmap.save\n format.html { redirect_to(@sessionmap, :notice => 'Sessionmap was successfully created.') }\n format.xml { render :xml => @sessionmap, :status => :created, :location => @sessionmap }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @sessionmap.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @map = Map.find(params[:map_id])\n\n #@node = Node.new\n @node = @map.nodes.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @node }\n end\n end",
"def create\n @url_mapper = UrlMapper.new(url_mapper_params)\n\n respond_to do |format|\n if @url_mapper.save\n format.html { redirect_to @url_mapper, notice: 'Url mapper was successfully created.' }\n format.json { render :show, status: :created, location: @url_mapper }\n else\n format.html { render :new }\n format.json { render json: @url_mapper.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @mind_map = MindMap.new(mind_map_params)\n @mind_map.user_id = current_user.id \n if @mind_map.save\n render :show, status: :created\n else\n render json: @mind_map.errors, status: :unprocessable_entity\n end\n end",
"def new\n @map = Map.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @map }\n end\n end",
"def save(params)\n @map = params[:id] ? Map.find(params[:id]) : Map.new(params[:map])\n \n if params[:id]\n expire_page :action=>'show', :id=>params[:id], :format=>'json'\n end\n\n respond_to do |format|\n if @map.update_attributes(params[:map])\n format.json { render :json => @map }\n else\n format.json { render :json => @map.errors }\n end\n end\n end",
"def create\n @map_state = MapState.new(params[:map_state])\n\n respond_to do |format|\n if @map_state.save\n format.html { redirect_to @map_state, :notice => 'Map state was successfully created.' }\n format.json { render :json => @map_state, :status => :created, :location => @map_state }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @map_state.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @roadmap = Roadmap.find(params[:roadmap_id])\n @roadmap_step = @roadmap.roadmap_steps.create(roadmap_step_params)\n #@roadmap_step = RoadmapStep.new(roadmap_step_params)\n\n respond_to do |format|\n if @roadmap_step.save\n format.html { redirect_to @roadmap, notice: 'Roadmap step was successfully created.' }\n format.json { render :show, status: :created, location: @roadmap_step }\n else\n format.html { render :new }\n format.json { render json: @roadmap_step.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\r\n \"new GMap2(document.getElementById(\\\"#{@container}\\\"))\"\r\n end",
"def create_world_map\n @world_map = World_Minimap.new(@viewport2)\n open_world_map\n end",
"def create\n @game_mapping = GameMapping.new(game_mapping_params)\n\n respond_to do |format|\n if @game_mapping.save\n format.html { redirect_to @game_mapping, notice: 'Game mapping was successfully created.' }\n format.json { render :show, status: :created, location: @game_mapping }\n else\n format.html { render :new }\n format.json { render json: @game_mapping.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @position_mapper = PositionMapper.new(params[:position_mapper])\n\n respond_to do |format|\n if @position_mapper.save\n format.html { redirect_to @position_mapper, notice: 'Position mapper was successfully created.' }\n format.json { render json: @position_mapper, status: :created, location: @position_mapper }\n else\n format.html { render action: \"new\" }\n format.json { render json: @position_mapper.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n params[:page].except!(:map_info) unless params[:page][:map_info].present?\n @page = current_user.pages.new(params[:page])\n respond_to do |format|\n if @page.save\n format.html { redirect_to @page, notice: 'Page was successfully created.' }\n format.json { render json: @page, status: :created, location: @page }\n else\n @business = Business.select('id, title')\n format.html { render action: \"new\" }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @map = current_user.maps.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @map }\n end\n end",
"def create\n @mini_map_road = MiniMapRoad.new(params[:mini_map_road])\n\n respond_to do |format|\n if @mini_map_road.save\n format.html { redirect_to @mini_map_road, notice: 'Mini map road was successfully created.' }\n format.json { render json: @mini_map_road, status: :created, location: @mini_map_road }\n else\n format.html { render action: \"new\" }\n format.json { render json: @mini_map_road.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @artwork_image_map = ArtworkImageMap.new(artwork_image_map_params)\n\n respond_to do |format|\n if @artwork_image_map.save\n format.html { redirect_to @artwork_image_map, notice: 'Artwork image map was successfully created.' }\n format.json { render :show, status: :created, location: @artwork_image_map }\n else\n format.html { render :new }\n format.json { render json: @artwork_image_map.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @outcome_mapping = OutcomeMapping.new(params[:outcome_mapping])\n\n respond_to do |format|\n if @outcome_mapping.save\n format.html { redirect_to @outcome_mapping, notice: 'Outcome mapping was successfully created.' }\n format.json { render json: @outcome_mapping, status: :created, location: @outcome_mapping }\n else\n format.html { render action: \"new\" }\n format.json { render json: @outcome_mapping.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n #puts item_mapping_params.to_yaml\n @item_mapping = ItemMapping.new(item_mapping_params)\n\n respond_to do |format|\n if @item_mapping.save\n format.html { redirect_to @item_mapping, notice: 'Item mapping was successfully created.' }\n format.json { render action: 'show', status: :created, location: @item_mapping }\n else\n format.html { render action: 'new' }\n format.json { render json: {error: @item_mapping.errors}, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @fw_baidu_map = current_user.baidu_maps.new(params[:fw_baidu_map])\n\n respond_to do |format|\n if current_user.save\n format.html { redirect_to @fw_baidu_map, notice: 'Baidu map was successfully created.' }\n format.json { render json: @fw_baidu_map, status: :created, location: @fw_baidu_map }\n else\n format.html { render action: \"new\" }\n format.json { render json: @fw_baidu_map.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @medium_map_cell = MediumMapCell.new(params[:medium_map_cell])\n\n respond_to do |format|\n if @medium_map_cell.save\n format.html { redirect_to @medium_map_cell, notice: 'Medium map cell was successfully created.' }\n format.json { render json: @medium_map_cell, status: :created, location: @medium_map_cell }\n else\n format.html { render action: \"new\" }\n format.json { render json: @medium_map_cell.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @map_layer = MapLayer.new(params[:map_layer])\n\n respond_to do |format|\n if @map_layer.save\n flash[:notice] = 'Map Layer was successfully created.'\n format.html { redirect_to(@map_layer) }\n format.xml { render :xml => @map_layer, :status => :created, :location => @map_layer }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @map_layer.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @category_map = CategoryMap.new(category_map_params)\n\n respond_to do |format|\n if @category_map.save\n format.html { redirect_to @category_map, notice: 'Category map was successfully created.' }\n format.json { render :show, status: :created, location: @category_map }\n else\n format.html { render :new }\n format.json { render json: @category_map.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @maplocation = Maplocation.new(maplocation_params)\n\n respond_to do |format|\n if @maplocation.save\n format.html { redirect_to @maplocation, notice: 'Maplocation was successfully created.' }\n format.json { render :show, status: :created, location: @maplocation }\n else\n format.html { render :new }\n format.json { render json: @maplocation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @game = Game.new(game_params)\n\n @game.save\n\n old_map = Map.find(params[:game][:map_id]) \n @game.map = old_map.dup\n old_map.spaces.each do |old_space|\n new_space = old_space.dup\n @game.map.spaces << new_space\n end\n @game.map.save\n\n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render action: 'show', status: :created, location: @game }\n else\n format.html { render action: 'new' }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n \n if current_user\n @map = Map.create\n current_user.memberships.create(:map => @map, :level => 'owner')\n else\n self.unsaved_map = Map.create unless unsaved_map\n @map = unsaved_map\n end\n redirect_to [:edit, @map]\n end",
"def map_view\n respond_to do |format|\n format.html \n format.json \n end\n end",
"def create_traffic_jam_object(mq_id, mq_msg, lat, lng)\n mq_reverse_geocode_url = \"http://www.mapquestapi.com/geocoding/v1/reverse?key=\"+ENV[\"MAPQUEST_KEY\"]+\"&lat=#{lat}&lng=#{lng}\"\n response = RestClient.get mq_reverse_geocode_url\n response = JSON.parse(response)\n response = response['results'][0]['locations'][0]\n location = response['street'];\n # Add city\n if location.nil?\n location = response['adminArea5']\n elsif !response['adminArea5'].nil?\n location = location + ', ' + response['adminArea5']\n end\n # Add state\n if location.nil?\n location = response['adminArea3']\n elsif !response['adminArea3'].nil?\n location = location + ', ' + response['adminArea3']\n end\n # Add country\n if location.nil?\n location = response['adminArea1']\n elsif !response['adminArea1'].nil?\n location = location + ', ' + response['adminArea1']\n end\n \n relative_path = \"/og/traffic_jam_#{mq_id}.html\"\n absolute_path = \"#{File.dirname(__FILE__)}/public#{relative_path}\"\n public_path = \"#{url('')}#{relative_path}\"\n\n template =\n \"<head prefix=\\\"og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# #{ENV['FACEBOOK_NAMESPACE']}: http://ogp.me/ns/fb/#{ENV['FACEBOOK_NAMESPACE']}#\\\">\\n\" +\n \"<meta property=\\\"fb:app_id\\\" content=\\\"#{ENV['FACEBOOK_APP_ID']}\\\" />\\n\" +\n \"<meta property=\\\"og:type\\\" content=\\\"#{ENV['FACEBOOK_NAMESPACE']}:traffic_jam\\\" />\\n\" +\n \"<meta property=\\\"og:url\\\" content=\\\"#{public_path}\\\" />\\n\" +\n \"<meta property=\\\"og:title\\\" content=\\\"#{location}\\\" />\\n\" +\n \"<meta property=\\\"og:image\\\" content=\\\"#{url('')}/images/traffic-jam-delay.jpg\\\" />\\n\" +\n \"<meta property=\\\"#{ENV['FACEBOOK_NAMESPACE']}:location:latitude\\\" content=\\\"#{lat}\\\" />\\n\" +\n \"<meta property=\\\"#{ENV['FACEBOOK_NAMESPACE']}:location:longitude\\\" content=\\\"#{lng}\\\" />\\n\" +\n \"</head>\\n\" +\n \"<body>\\n\" +\n \"<h1>#{location}</h1>\\n\" +\n \"</body>\\n\"\n page = File.new(absolute_path, \"w\")\n page.write(template)\n page.close()\n public_path \n end",
"def add_mapping\n @renderer = Renderer.find params[:id]\n @mapping = @renderer.add_mapping\n # La posizione la calcolo in tempo reale\n @position = @renderer.mappings.size - 1\n render :partial => 'mapping'\n end",
"def create\n @control_point = ControlPoint.new(params[:control_point])\n @control_point.user = current_user\n @control_point.map = Map.find(params[:map_id])\n @map = @control_point.map # we have to do this so the form is correctly displayed on error\n respond_to do |format|\n if @control_point.save\n format.html { redirect_to(@control_point, :notice => 'Control Point was successfully created.') }\n format.xml { render :xml => @control_point, :status => :created, :location => @control_point }\n format.js { }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @control_point.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def map\n # expires_in 1.year, public: true\n set_metadata({ 'title' => translate('classes.map_title') })\n\n countries = {\n ru: 'RU',\n cs: 'CZ',\n it: 'IT',\n ko: 'SK',\n }\n\n config = params.permit(:q, :country)\n config[:locale] = I18n.locale unless I18n.locale == :en\n config[:theme] = 'wemeditate'\n config[:country] ||= countries[I18n.locale]\n @atlas_url = \"https://atlas.sydevelopers.com/map/embed.js?key=#{ENV.fetch('ATLAS_KEY')}&#{config.to_query}\"\n @atlas_enabled = ENV['ATLAS_LOCALES'].split(',').include?(I18n.locale.to_s)\n \n render layout: 'minimal'\n end",
"def create\n @location_mapping = LocationMapping.new(location_mapping_params)\n\n respond_to do |format|\n if @location_mapping.save\n format.html { redirect_to @location_mapping, notice: 'Location mapping was successfully created.' }\n format.json { render :show, status: :created, location: @location_mapping }\n else\n format.html { render :new }\n format.json { render json: @location_mapping.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @curpg = :admintools\n @location = Location.new(params[:location])\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to :controller => \"locations\", :action => \"index\" }\n format.json { render json: @location, status: :created, location: @location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @mapimage = Mapimage.new(mapimage_params)\n\n respond_to do |format|\n if @mapimage.save\n format.html { redirect_to @mapimage, notice: 'Mapimage was successfully created.' }\n format.json { render :show, status: :created, location: @mapimage }\n else\n format.html { render :new }\n format.json { render json: @mapimage.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @map = GMap.new(\"map_div\")\n @map.control_init(:large_map => true,:map_type => true)\n @map.center_zoom_init([30.7645,120.7248],15)\n @map.event_init(@map, :click, \"function(marker, point) {\n if(marker == null)\n {\n map.clearOverlays();\n map.addOverlay( new GMarker(point,{title : ''}) );\n $('house_lng').value=point.y;\n $('house_lat').value=point.x;\n }\n }\")\n \n @house = House.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @house }\n end\n end",
"def create\n source_ontology = LinkedData::Client::Models::Ontology.find_by_acronym(params[:map_from_bioportal_ontology_id]).first\n target_ontology = LinkedData::Client::Models::Ontology.find_by_acronym(params[:map_to_bioportal_ontology_id]).first\n source = source_ontology.explore.single_class(params[:map_from_bioportal_full_id])\n target = target_ontology.explore.single_class(params[:map_to_bioportal_full_id])\n values = {\n classes: {\n source.id => source_ontology.id,\n target.id => target_ontology.id\n },\n creator: session[:user].id,\n relation: params[:mapping_relation],\n comment: params[:mapping_comment]\n }\n @mapping = LinkedData::Client::Models::Mapping.new(values: values)\n @mapping_saved = @mapping.save\n if @mapping_saved.errors\n raise Exception, @mapping_saved.errors\n else\n @delete_mapping_permission = check_delete_mapping_permission(@mapping_saved)\n render json: @mapping_saved\n end\n end",
"def new\n @map_node = Map::Node.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @map_node }\n end\n end",
"def create\n @route = Route.new(route_params)\n @route.save\n\n redirect_to '/routes/map/'+@route.map_id.to_s\n end",
"def create_worldmap\n @pokemon_worldmap = GamePlay::WorldMap.new(:pokedex, $env.get_worldmap)\n @pokemon_worldmap.create_graphics\n end",
"def map_div_html\n %{<div style=\"#{style}\" id=\"#{name}\" > [Map]</div>}\n end",
"def new\n @gmap = Gmap.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gmap }\n end\n end",
"def create\n @mapuser = Mapuser.new(mapuser_params)\n\n respond_to do |format|\n if @mapuser.save\n format.html { redirect_to @mapuser, notice: 'Mapuser was successfully created.' }\n format.json { render :show, status: :created, location: @mapuser }\n else\n format.html { render :new }\n format.json { render json: @mapuser.errors, status: :unprocessable_entity }\n end\n end\n end",
"def generate_source_map_page(source_map)\n return if associate_page_failed?\n\n source_map_page.source_map(source_map)\n site.pages << source_map_page\n end",
"def create\n @content_mapping = ContentMapping.new(params[:content_mapping])\n\n respond_to do |format|\n if @content_mapping.save\n flash[:notice] = \"Content (#{@content_mapping.asset_type.humanize}) was successfully added to page.\"\n format.html { redirect_to(\"/pages/#{@content_mapping.page.id}/edit#page_content\") }\n format.xml { render :xml => @content_mapping, :status => :created, :location => @content_mapping }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @content_mapping.errors, :status => :unprocessable_entity }\n end\n end\n end"
] |
[
"0.696807",
"0.67800295",
"0.6774688",
"0.66232926",
"0.6618976",
"0.6596585",
"0.65922004",
"0.6589328",
"0.65365005",
"0.64882874",
"0.64482844",
"0.64244074",
"0.6401308",
"0.63497764",
"0.6334888",
"0.6326622",
"0.630105",
"0.62724584",
"0.62549067",
"0.62375546",
"0.6208619",
"0.61316997",
"0.6124432",
"0.61190474",
"0.6105998",
"0.60919106",
"0.6091019",
"0.6087736",
"0.60826725",
"0.6062027",
"0.6038377",
"0.6031809",
"0.60292906",
"0.6023369",
"0.59947747",
"0.59918386",
"0.5982213",
"0.59706897",
"0.5930379",
"0.59101826",
"0.5909263",
"0.5902646",
"0.58683246",
"0.58643293",
"0.5861197",
"0.5855379",
"0.5839466",
"0.58032733",
"0.57991576",
"0.5794692",
"0.578406",
"0.5773448",
"0.57397324",
"0.5727258",
"0.5726686",
"0.5712898",
"0.5712641",
"0.5704678",
"0.57038313",
"0.57023555",
"0.5701558",
"0.56867087",
"0.5683422",
"0.56735164",
"0.56674844",
"0.56556207",
"0.5650638",
"0.5631771",
"0.56127954",
"0.56082094",
"0.56076807",
"0.55942523",
"0.55872226",
"0.55740154",
"0.55684036",
"0.55635864",
"0.55624306",
"0.55610085",
"0.55501753",
"0.5543509",
"0.55318487",
"0.5526627",
"0.55239445",
"0.551914",
"0.551261",
"0.55105245",
"0.5505325",
"0.5499381",
"0.5486582",
"0.54798114",
"0.5476377",
"0.54724866",
"0.5468512",
"0.54642487",
"0.54625636",
"0.54596794",
"0.54545623",
"0.54420084",
"0.5424512",
"0.5423912"
] |
0.54740477
|
91
|
Private: helper method to check if authorization parameters match the set environment variables Returns true or false
|
def authorized?
@auth ||= Rack::Auth::Basic::Request.new(request.env)
user = ENV["HTTP_USER"]
pass = ENV["HTTP_PASS"]
@auth.provided? && @auth.basic? && @auth.credentials && @auth.credentials == [user, pass]
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def authorized(authorization)\n if (ENV['SECRET_NAME'])\n creds = get_secret(ENV['SECRET_NAME'])\n calculated = \"Basic \" + Base64.encode64(\"#{creds['a2user'] || creds['A2USER']}:#{creds['a2pass'] || creds['A2PASS']}\")\n return (authorization || \"\").strip == (calculated || \"\").strip\n end\n if (ENV['A2USER'] && ENV['A2PASS'])\n calculated = \"Basic \" + Base64.encode64(\"#{ENV['A2USER']}:#{ENV['A2PASS']}\")\n return (authorization || \"\").strip == (calculated || \"\").strip\n end\n return false\nend",
"def valid_environment?\n env['USER'] == config.user && env['HOME'] == config.home_path\n end",
"def authorized?\n @auth ||= Rack::Auth::Basic::Request.new(request.env)\n\n @auth.provided? &&\n @auth.basic? &&\n @auth.credentials &&\n @auth.credentials == [ENV['RUMBLELOG_ADMIN_USERNAME'],\n ENV['RUMBLELOG_ADMIN_PASSWORD']]\n end",
"def authorized?\n user = ENV['ADMIN_USER'] || 'admin'\n pass = ENV['ADMIN_PASSWORD'] || 'ch0p'\n\n @auth ||= Rack::Auth::Basic::Request.new(request.env)\n @auth.provided? && @auth.basic? && @auth.credentials && @auth.credentials == [user, pass]\n end",
"def authorized?\n auth_config = settings.config['authentication']\n @auth ||= Rack::Auth::Basic::Request.new(request.env)\n @auth.provided? and @auth.basic? and @auth.credentials and @auth.credentials == [auth_config['username'], auth_config['password']]\n end",
"def authorized?\n @auth ||= Rack::Auth::Basic::Request.new(request.env)\n \n # read credentials from file\n credentials = open(\"credentials.txt\").read.split(\"\\n\").map{|c| c !~ /^#/ ? c : nil}.compact\n \n @auth.provided? && @auth.basic? && @auth.credentials && @auth.credentials == credentials\n end",
"def authorized?\n @auth ||= Rack::Auth::Basic::Request.new(request.env)\n @auth.provided? &&\n @auth.basic? &&\n @auth.credentials &&\n check(@auth.credentials)\n end",
"def authorized?\n @auth ||= Rack::Auth::Basic::Request.new(request.env)\n\n @auth.provided? && @auth.basic? && @auth.credentials && @auth.credentials == [\n ENV[\"HTTP_USER\"],\n ENV[\"HTTP_PASS\"]\n ]\n end",
"def auth_provided?\n !username.nil? && !password.nil?\n end",
"def should_authenticate?(env)\n @config['should_authenticate_check'] ? @config['should_authenticate_check'].call(env) : true\n end",
"def validate_envs?()\n\t\tenv = @options[:env]\n\n\t\tres = subset?([env], @envs_list)\n\t\tif ! res\n\t\t\tputs \"Environment #{env}, is not valid\"\n\t\tend\n\n\t return res\t\n\tend",
"def valid?(env)\n request = Rack::Request.new(env)\n unless (access_id = request.params['AccessKeyID'])\n #puts \"AccessKeyID not found in Params\"\n return false\n end\n unless (secret_key = @accounts[access_id])\n #puts \"No SecretKey found for AccessKeyID #{access_id.inspect}\"\n return false\n end\n AuthenticatedApi::Server.valid_signature?(request, secret_key)\n end",
"def allowed?\n if params[:environment]\n Ability.allowed?(current_user, :read_environment, project)\n elsif params[:cluster]\n true # Authorization handled at controller level\n else\n false\n end\n end",
"def authorized?\n @auth ||= Rack::Auth::Basic::Request.new(request.env)\n return @auth.provided? && @auth.basic? && @auth.credentials && @auth.credentials == [@@username, @@password]\n end",
"def authorized?(rack_env)\n Env.new(rack_env).authorized?\n end",
"def check_auth(configuration)\n configuration.each do |c|\n if \"#{c[\"name\"]}\".match(/^Authentication\\ \\-.*$/) && \"#{c[\"value\"]}\".to_bool\n return true\n end\n end\n false\n end",
"def authorize(username, password)\np username\np password\n username == settings.username && password == settings.password\n end",
"def authorized?\n @authorized ||= User.get(@env).present?\n end",
"def correct_credentials?\n correct_username = 'admin'\n correct_password = 'admin'\n input_username = @request.params['username']\n input_password = @request.params['password']\n correct_username == input_username && correct_password == input_password\n end",
"def authentication?\n @capabilities and @capabilities.include? 'auth'\n end",
"def authorization_header?\n return true if request.headers['Authorization'] && request.headers['Authorization'] != 'null'\n\n false\n end",
"def env_set?(*vars)\n vars.map{ |v| ENV.has_key?(v) }.all?\n end",
"def auth_present?\n !!request.headers['HTTP_AUTHORIZATION'].present?\n end",
"def exec_granted?(controler, xllave)\n\t\tauth = Execremotekey.where(\"controler= '#{controler}' AND llave = '#{xllave}' \").first\n\t\tif auth == nil\n\t\t\tredirect_to noautorizado_url, notice: \"No esta autorizado a entrar a esta opcion\"\n\t\t\tfalse\n\t\telse\n\t\t\tauth.delete #para que no se reutilice la misma validacion\n\t\t\ttrue\n\t\tend\n\tend",
"def has_oauth_credentials?\n return false if @configuration.nil?\n RightSignature2013::Connection.oauth_keys.each do |key| \n return false if @configuration[key].nil? || @configuration[key].match(/^\\s*$/)\n end\n\n return true\n end",
"def verify\n response = script_mode do \n query(\"configshow | grep RBAC\")\n end \n response.data.match(/#{Replies::RBAC_DENIED}/) ? false : true\n end",
"def environment_valid?\n %w(test production development).include?(@environment)\n end",
"def authorization\r\n@env['HTTP_AUTHORIZATION'] ||\r\n@env['X-HTTP_AUTHORIZATION'] ||\r\n@env['X_HTTP_AUTHORIZATION'] ||\r\n@env['REDIRECT_X_HTTP_AUTHORIZATION']\r\nend",
"def checkPrivilegedHdr\n hdr = request.env['HTTP_PRIVILEGED'] or return false\n privKey = ENV['ESCHOL_PRIV_API_KEY'] or raise(\"missing env ESCHOL_PRIV_API_KEY\")\n hdr.strip == privKey or halt(403, \"Incorrect API key\")\n return true\n end",
"def api_accessible?\n oauth_token.present? && oauth_secret.present?\n end",
"def auth_params_exist\n auth.key?(:user_id) && auth.key?(:api_key)\n end",
"def valid?\n authorization_header.present? && authorization_header.match(BEARER_PATTERN) && authentication_token.present?\n end",
"def authorized?\n session[:password] == SETTINGS[\"password\"]\n end",
"def auth_enabled?\n if @auth_enabled.nil?\n @auth_enabled = begin\n basic_client.use(:admin).command(getCmdLineOpts: 1).first[\"argv\"].include?(\"--auth\")\n rescue => e\n e.message =~ /(not authorized)|(unauthorized)|(no users authenticated)|(requires authentication)/\n end\n end\n @auth_enabled\n end",
"def auth_enabled?\n if @auth_enabled.nil?\n @auth_enabled = begin\n basic_client.use(:admin).command(getCmdLineOpts: 1).first[\"argv\"].include?(\"--auth\")\n rescue => e\n e.message =~ /(not authorized)|(unauthorized)|(no users authenticated)|(requires authentication)/\n end\n end\n @auth_enabled\n end",
"def check_auth(request, response)\n # Get the value of the authorization header, and reject the request if it isn't present:\n authorization = request['Authorization']\n if authorization.nil?\n response.status = 401\n response.body = \"The 'Authorization' header is required\"\n return false\n end\n\n # Extract the authorization scheme and token from the authorization header:\n match = /^(?<scheme>Basic|Bearer)\\s+(?<token>.*)$/i.match(authorization)\n unless match\n response.status = 401\n response.body = \"The 'Authorization' doesn't match the expected regular expression\"\n return false\n end\n scheme = match[:scheme]\n token = match[:token]\n\n # Check the token:\n case scheme.downcase\n when 'basic'\n return false unless check_basic_token(response, token)\n when 'bearer'\n return false unless check_bearer_token(response, token)\n else\n response.status = 401\n response.body = \"The authentication scheme '#{scheme} isn't supported\"\n return false\n end\n\n # If we are here then authentication was successful:\n true\n end",
"def key_based?\n @username && !@username.empty? && @api_key && !@api_key.empty?\n end",
"def request_should_auth?( request )\n\t\tself.log.debug \"Checking to see if Auth(entication/orization) should be applied for app_path: %p\" %\n\t\t\t[ request.app_path ]\n\n\t\t# If there are positive criteria, return true if the request matches any of them,\n\t\t# or false if they don't\n\t\tif self.class.has_positive_auth_criteria?\n\t\t\tcriteria = self.class.positive_auth_criteria\n\t\t\tself.log.debug \" checking %d positive auth criteria\" % [ criteria.length ]\n\t\t\treturn criteria.any? do |pattern, block|\n\t\t\t\tself.request_matches_criteria( request, pattern, &block )\n\t\t\tend\n\t\t\treturn false\n\n\t\t# If there are negative criteria, return false if the request matches any of them,\n\t\t# or true if they don't\n\t\telsif self.class.has_negative_auth_criteria?\n\t\t\tcriteria = self.class.negative_auth_criteria\n\t\t\tself.log.debug \" checking %d negative auth criteria\" % [ criteria.length ]\n\t\t\treturn false if criteria.any? do |pattern, block|\n\t\t\t\trval = self.request_matches_criteria( request, pattern, &block )\n\t\t\t\tself.log.debug \" matched: %p -> %p\" % [ pattern, block ] if rval\n\t\t\t\trval\n\t\t\tend\n\t\t\treturn true\n\n\t\telse\n\t\t\tself.log.debug \" no auth criteria; default to requiring auth\"\n\t\t\treturn true\n\t\tend\n\tend",
"def user_authorizes_token?\n params[:authorize] == '1'\n end",
"def user_authorizes_token?\n params[:authorize] == '1'\n end",
"def user_authorizes_token?\n params[:authorize] == '1'\n end",
"def valid?\n env_keys.all? { |k| env.key?(k) }\n end",
"def environment_configured?\n Rails.env.test? || required_vars.empty? || required_vars.all?{|var_name| !ENV[var_name].nil? && !ENV[var_name].empty?}\n end",
"def authorized?(**args)\n true\n end",
"def authentication_set?\n !@username.nil? && !@password.nil?\n end",
"def check_vars\n req_env_vars = ['REDMINE_BASE_URL', 'REDMINE_API_KEY', 'SLACK_WEBHOOK_URL', 'DATABASE_URL']\n missing_env_vars = req_env_vars - ENV.keys\n unless missing_env_vars.empty?\n puts \"The following environment variables are required: #{missing_env_vars.join ', '}\"\n exit\n end\nend",
"def auth_enabled?\n if auth = ENV['AUTH']\n auth == 'auth'\n else\n $mongo_client ||= initialize_scanned_client!\n begin\n $mongo_client.use(:admin).command(getCmdLineOpts: 1).first[\"argv\"].include?(\"--auth\")\n rescue => e\n e.message =~ /(not authorized)|(unauthorized)|(no users authenticated)|(requires authentication)/\n end\n end\nend",
"def valid?\n\n auth_params = params[scope]\n return false if !auth_params\n\n (nimbus_auth(auth_params)&.code == 200) ? true : false\n end",
"def authorized?(env, app)\n auth = Rack::Auth::Basic::Request.new(env)\n auth.provided? && auth.basic? && auth.credentials && app.class.auth_callback.call(\n auth.credentials[0], auth.credentials[1], false\n )\nend",
"def command_is_authorized?(cmd)\n AUTHORIZED_COMMANDS.include?(cmd.downcase)\n end",
"def auth?\n true\n end",
"def running_protected_environment?\n protected_environments.collect(&:to_sym).include?(Rails.env.to_sym)\n end",
"def check(config)\n [ :host,\n :user,\n :pass,\n :name,\n ].all? {|key| config.has_key? key }\n end",
"def authenticated_end_user?(args) \n config = configuration.auth ? true : false\n arg = args[:auth]\n if ! arg.nil?\n arg ? true : false\n elsif ! config.nil?\n config ? true : false\n else\n false\n end\n end",
"def authorized?\n !!@req.env['REMOTE_USER']\n end",
"def check_environment\n # Also, your VMs require public ssh keys for the root user\n # to exist that match your CLOUD_KEY private key path\n #\n # You must also have the following values set in your environment:\n #\n # ENV[\"API_KEY\"] -- cloudstack api key\n # ENV[\"API_SECRET\"] -- cloudstack api secret\n # ENV[\"API_URL\"] -- cloudstack api endpoint\n # ENV[\"CLOUD_KEY\"] -- local file path to your private SSH key material\n #\n %w{API_KEY API_SECRET API_URL CLOUD_KEY}.each do |var|\n raise \"ERROR: you must set #{var} in you environment\" unless ENV[var]\n end\n end",
"def authenticated_end_user?(args)\n config = configuration.auth ? true : false\n arg = args[:auth]\n if ! arg.nil?\n arg ? true : false\n elsif ! config.nil?\n config ? true : false\n else\n false\n end\n end",
"def authenticated_end_user?(args)\n config = configuration.auth ? true : false\n arg = args[:auth]\n if ! arg.nil?\n arg ? true : false\n elsif ! config.nil?\n config ? true : false\n else\n false\n end\n end",
"def check_authorization\n return head :unauthorized if request.env['HTTP_CAPKEY'].nil?\n\n head :forbidden unless request.env['HTTP_CAPKEY'] == Settings.API_KEY\n end",
"def check_params #:doc:\n if params[:username] !~ /.{1,}/ or params[:password] !~ /.{1,}/ or\n params[:devicename] !~ /.{1,}/ or params[:dev_type] !~ /.{1,}/ or\n (params[:port] != nil and params[:port] !~ /\\d{1,10}/)\n return false\n else\n return true\n end\n end",
"def is_env?(name, value)\n ENV[name] and ENV[name].downcase == value.downcase\nend",
"def check_permissions\n require_privilege(Privilege::USE, @environment)\n end",
"def valid_request?\n if env.include_all?(['SSH_CLIENT', 'SSH_CONNECTION', 'SSH_ORIGINAL_COMMAND'])\n if valid_command?(env['SSH_ORIGINAL_COMMAND'])\n return true\n end\n end\n false\n end",
"def is_app_authorizer?\n if is_admin_realm_authenticated?\n session[:rights].include?('EDORG_APP_AUTHZ')\n elsif !session[:edOrgRights].blank?\n session[:edOrgRights].any? { |edorg, rights| rights.include?('APP_AUTHORIZE') }\n else\n false\n end\n end",
"def authorized?(resource)\n return false unless self.active\n # return true if role_authorized?('superuser') \n #OPTIMIZE: DO WE WANT THIS? It causes you to have access to all departments in all controllers, no matter what your permissions are.\n \n # return permission_strings.include?(resource) #reduced performance\n return permission_strings_cached.include?(resource) #causes caching bug\n end",
"def has_auth_criteria?\n\t\t\treturn self.has_positive_auth_criteria? || self.has_negative_auth_criteria?\n\t\tend",
"def credentials?\n oauth.values.all? || basic_auth.values.all?\n end",
"def authorized?\n !auth.nil?\n end",
"def valid_app_access_token?\n app_access_token = request.headers['X-App-Access-Token']\n\n app_access_token.present? &&\n app_access_token == Rails.application.secrets.app_access_token\n end",
"def valid_api_key?(api_header_val, api_key_lookup_val, env)\n !api_header_val.nil? && api_header_val != '' &&\n !api_key_lookup_val.nil? && api_key_lookup_val != ''\n end",
"def validate_env\n validate_keys :rock_key, :rock_username, :rock_password\n end",
"def authorized?\n user_account.authorized?(app_keypair)\n end",
"def user_authorizes_token?\n return true if params[:authorize]\n\n end",
"def can_grant_api_to_orgs?\n perms.include? Perm.grant_api\n end",
"def can_grant_api_to_orgs?\n perms.include? Perm.grant_api\n end",
"def authorize(login, password)\n return true unless CloudCrowd.config[:use_http_authentication]\n return CloudCrowd.config[:login] == login &&\n CloudCrowd.config[:password] == password\n end",
"def valid_app_access_token?\n token = request.headers['X-App-Access-Token']\n\n token.present? && token == Rails.application.secrets.app_access_token\n end",
"def requesting_auth?(authorization_header)\n authorization_header || !authorization_cookie.blank?\n end",
"def env?(*keys)\n if keys.respond_to?(:all?)\n !keys.all? { |k| ENV[k].blank? }\n else\n !ENV[keys].blank?\n end\n end",
"def authorized_artsy_token?(token)\n ArtsyAdminAuth.valid?(token)\n end",
"def is_api?\n current_user\n @env[API_KEY]\n end",
"def google_oauth_enabled?\n ENV.has_key?('GOOGLE_CLIENT_ID') and ENV.has_key?('GOOGLE_CLIENT_SECRET')\nend",
"def admin?\n self.credentials[:master] or self.credentials[:admin]\n end",
"def app_env?(env_name)\n APP_ENV.casecmp(env_name.to_s).zero?\nend",
"def test_env\n if ENVIRONMENT.is_a?(String) && ENVIRONMENT == \"test\"\n true\n else\n false\n end\n end",
"def authorized?(data=nil)\n auth = Rack::Auth::Basic::Request.new(request.env)\n\n auth.provided? && auth.basic? && auth.credentials &&\n (conf.auth[:logic] || ->(data, u, p) {\n %w(admin password) == [u, p]\n }).(data, *auth.credentials)\n end",
"def client_has_valid_token?\n request.headers[\"Authorization\"] == Rails.application.credentials.guessing_access_token\n end",
"def valid_for_http_auth?\n http_authenticatable? && request.authorization && with_authentication_hash(:http_auth, http_auth_hash)\n end",
"def valid_for_http_auth?\n http_authenticatable? && request.authorization && with_authentication_hash(:http_auth, http_auth_hash)\n end",
"def ready?\n config and\n config.authorization_url and\n tokens and\n tokens.access_token and\n tokens.refresh_token\n end",
"def application_credentials?\n !!application_credentials\n end",
"def authorize?\n @root.attributes[\"ath\"].to_i == 1\n end",
"def authok?\n @authok\n end",
"def authok?\n @authok\n end",
"def authok?\n @authok\n end",
"def authok?\n @authok\n end",
"def valid_for_params_auth?\n params_authenticatable? && valid_params_request? &&\n valid_params? && with_authentication_hash(:params_auth, params_auth_hash)\n end",
"def valid?(request_env)\n\t\t\treturn false unless valid_fields?(request_env)\n\t\t\ttrue\n\t\tend",
"def valid_http_auth?\n controller.authenticate_with_http_basic do |login, password|\n if !login.blank? && !password.blank?\n send(\"#{login_field}=\", login)\n send(\"#{password_field}=\", password)\n return valid?\n end\n end\n \n false\n end",
"def authorized?\n !!request.env['REMOTE_USER']\n end"
] |
[
"0.7383269",
"0.709127",
"0.7014855",
"0.6940197",
"0.68365604",
"0.6814474",
"0.6773212",
"0.67322725",
"0.6712682",
"0.6698364",
"0.668633",
"0.66711974",
"0.66477764",
"0.6636364",
"0.6578134",
"0.65577257",
"0.65548086",
"0.6539311",
"0.65208304",
"0.6485632",
"0.6425355",
"0.6420223",
"0.64022315",
"0.63949746",
"0.63940334",
"0.63822323",
"0.6369722",
"0.6366113",
"0.63654095",
"0.635485",
"0.635401",
"0.6335998",
"0.6315653",
"0.6310395",
"0.6310395",
"0.6295566",
"0.62869525",
"0.6281121",
"0.6263686",
"0.6263686",
"0.6263686",
"0.62614006",
"0.6252352",
"0.6245676",
"0.6243941",
"0.62342197",
"0.62316686",
"0.6224587",
"0.62078255",
"0.6207304",
"0.6198393",
"0.61905104",
"0.61877865",
"0.61854607",
"0.6176309",
"0.61698985",
"0.614831",
"0.614831",
"0.6138497",
"0.61315984",
"0.6116697",
"0.6114116",
"0.61121166",
"0.6110584",
"0.61055285",
"0.60999715",
"0.6098966",
"0.60917497",
"0.60895944",
"0.6088407",
"0.60738206",
"0.6067842",
"0.60638005",
"0.6063246",
"0.6063246",
"0.60619986",
"0.60558623",
"0.60536236",
"0.6049184",
"0.60383785",
"0.6032251",
"0.6024459",
"0.6022833",
"0.6016219",
"0.6016031",
"0.60094905",
"0.6005592",
"0.59989506",
"0.59989506",
"0.59974754",
"0.599607",
"0.5994326",
"0.5989643",
"0.5989643",
"0.5989643",
"0.5989643",
"0.5985891",
"0.5984756",
"0.59796536",
"0.59755695"
] |
0.7017645
|
2
|
Returns a unique, deterministically reproducible index into an array We are hashing based on strings, let's use the ascii value of each string as a starting point.
|
def index(key, size)
sum = 0
place = 1
key.each_byte do |c|
sum = sum + c*place
place += 1
end
sum%size
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def find_unique(array)\n unique_id = 0\n\n array.each do |num|\n unique_id ^= num\n end\n\n unique_id\nend",
"def generateKey(string)\r\n key = {}\r\n stringIterator = 0\r\n\r\n (string.length).times do\r\n charactersIterator = string[stringIterator] - 1\r\n divisorsIterator = 0\r\n divisors = {} # Possible divisors of the array's numbers\r\n\r\n # Check which numbers are possible divisors\r\n while charactersIterator > 0\r\n\r\n if string[stringIterator] % charactersIterator == 0\r\n divisors[divisorsIterator] = charactersIterator\r\n divisorsIterator += 1\r\n end\r\n charactersIterator -= 1\r\n end\r\n key[stringIterator] = divisors[rand(divisors.length)] # Choosing random divisor to be the primary key\r\n stringIterator += 1\r\n end\r\n\r\n return key\r\nend",
"def dupe_indices(array)\n hash = Hash.new{ |k, v| k[v] = [] }\n\n array.each_with_index do |char, i|\n hash[char] << i\n end\n\n return hash.select { |k, v| v.length > 1 }\n\nend",
"def index(key, size)\n MurmurHash3::V32.str_hash(key.to_s, size) % size\n end",
"def index(key, size)\n hash_code = 0\n array_of_characters = key.split('')\n array_of_characters.each do |letter|\n hash_code += letter.ord\n end\n hash_code % size\n end",
"def test_array_hash\r\n # a = %w(brendan baird billy)\r\n # assert_equal(1047868961, a.hash)\r\n end",
"def hash_offset(array, offset)\r\n hash = {}\r\n \r\n i = 0\r\n while i < array.length \r\n if i >= (array.length - offset) #if i >= 22, in this case. So this condition applies for the last 4 elements of the array\r\n hash[array[i-array.length + offset]] = array[i] # hash[array[22-26+4]] --> hash[array[0]] --> hash[\"a\"]=array[22] --> hash[\"a\"]=\"w\"\r\n else\r\n hash[(array[i].ord + offset).chr] = array[i] #otherwise do the normal offset by 4\r\n end\r\n i += 1\r\n end\r\n return hash\r\nend",
"def find_uniq_int(array)\n\tuniq_id = 0\n\n\tarray.each do |element|\n\t\tuniq_id ^= element\n\tend \n\n\treturn uniq_id\nend",
"def first_non_repeating(input)\n input_array = input.chars\n index = 0\n input_hash = {}\n for char in input_array do\n # If it's not in the hash already\n if input_hash.key?(char)\n # add char as key to input_hash\n # increment 1 to value of the char key in input_hash\n input_hash[char] += 1\n else\n # create a new key in input_hash and assign value as one\n input_hash[char] = 1\n end\n end\n p input_hash.key(1)\nend",
"def find_unique_integer(id_array)\n unique_id = 0 \n id_array.each do |id|\n unique_id ^= id\n end\n\n return unique_id\nend",
"def generate_random_array \n big_array = []\n i = set_array_size.to_i\n \n while i >= 1 \n big_string = (0...50).map { ('a'..'z').to_a[rand(26)] }.join\n big_array << big_string\n i = i - 1 \n end\n big_array \n end",
"def lookuptable\n res = Hash.new\n (0..255).each do |c|\n res[c] = unscramble(c)\n end\n res\n end",
"def index(key, size)\n ascii_value = 0\n hash_key = 0\n\n key.split(\"\").each do |letter|\n ascii_value += letter.ord #Method to retrieve ascii\n end\n\n hash_key = ascii_value % size\n\n return hash_key\n end",
"def random_hash(size)\n characters = ('A'..'Z').to_a + (2..9).to_a - [ 'I', 'O' ]\n Array.new(size) { characters[ rand(characters.size) ] }.join\n end",
"def inject_evil_symbols(array)\n array.insert(\n rand(0..array.length),\n [rand(9999), 9999]\n ).flatten!\nend",
"def unoptimized_find_unique_integer(id_array)\n histogram = Hash.new(0)\n id_array.each do |id|\n histogram[id] += 1\n end\n histogram.keys.each do |key|\n return key if histogram[key] == 1\n end\n return nil\nend",
"def index(key, size)\n #sums up the ascii values of each char in a string\n code = key.sum\n return code % size\n end",
"def array_to_indices_hash(array)\n array.inject({}) {|hash,e| hash[hash.size] = e; hash }\n end",
"def index(key, size)\n #true_index = hash(key) % k\n code = 0\n key.split(%r{\\s*}).each do |letter|\n code += letter.ord \n end\n puts code\n return code % size\n\n end",
"def random_string_in(arr)\n return nil if arr.empty?\n index = random_number(0, arr.length-1)\n arr[index]\n end",
"def where_to_put_secret(index)\n (0...48).each do |b|\n if index[b] == 1\n return b\n end\n end\n # I = 0, this is the seed.\n 48\n end",
"def dupe_indices(array)\n #ht = Hash.new {|h,k| h[k]=[]}\n #ht[\"cats\"] << \"Jellicle\"\n #ht[\"cats\"] << \"Mr. Mistoffelees\"\n hash = Hash.new { |h,k| h[k]=[] }\n array.each_with_index do |char, i|\n hash[char] << i\n end\n \n # puts \"Hash b select form : #{b.select{|key, value| value < 200}}\\n\\n\n hash.select{ |k,v| v.length > 1}\n\n\nend",
"def my_uniq(arr)\n answer = Hash.new\n arr.each_with_index do |el, i|\n answer[el] = 1\n end\n answer.keys\nend",
"def to_indices_hash(arr)\n #::Hash[*(0..arr.length - 1).to_a.zip(arr).flatten]\n arr.inject({}) {|hash,e| hash[hash.size] = e; hash }\n end",
"def hashify(key)\n array = key.split('')\n count = array.count\n index = array.inject(0) do |object,char|\n object += char.ord ** count\n count -= 1\n object\n end\n index % 89\n end",
"def index(key, size)\n # Takes the string 'key', creates an array of individual characters (split), maps to an array of ascii values (map), and then sums them (reduce)\n # Reaminder from dividing above amount by array size produces the array index\n (key.split(//).map { |char| char.ord }.reduce(:+)) % size\n end",
"def test_hash_correct\n\t\n\t\tString test_array1 = '2|abb2|George>Amina(16):Henry>James(4):Henry>Cyrus(17):Henry>Kublai(4):George>Rana(1):SYSTEM>Wu(100)|1518892051.753197000|c72d'.split('|').map(&:chomp)\n\n\t\tx = test_array1[0].unpack('U*') + test_array1[1].unpack('U*') + test_array1[2].unpack('U*') + test_array1[3].unpack('U*')\n\t\tsum = 0\n\t\t# x.each { |i| puts x[i] }\n\t\t# x.delete(\"\")\n\t\tx.each { |i| sum += ((x[i].to_i ** 2000) * ((x[i].to_i + 2) ** 21) - ((x[i].to_i + 5) ** 3)) }\n\t\thash = (sum % 65536)\n\t\tputs hash.to_s(16)\n\t\t\n\t\ttest_array2 = '3|c72d|SYSTEM>Henry(100)|1518892051.764563000|7419'.split('|').map(&:chomp)\n\t\t\n\t\t# assert_equal test_str[2,2], '0|'\t\n\tend",
"def random_index(len)\n rand(1..len) - 1\nend",
"def uniqueness_dictionary\n [*(:A..:Z), *(:a..:z), *(0..9)].map(&:to_s)\n end",
"def hashit\n n = 0\t \n (\"A\"..\"Z\").each do |x|\n @rotor_hash[x] = @rotor_array[n]\n n += 1\n end \n return @rotor_hash\n end",
"def uniques(array)\n hash = Hash[array.map {|x| [x, nil]}]\n print hash.keys\nend",
"def from_index\n Indexer.index[probably_unique_id]\n end",
"def weighted_random_index(array)\n idx = rand(array.length)\nend",
"def my_uniq(arr)\n hashed = arr.map {|value| [value, arr.count(value)]}.flatten\n return Hash[*hashed].keys\nend",
"def hash()\n #This is a stub, used for indexing\nend",
"def create_key_a\n @key_chars[0..1].join.to_i\n end",
"def my_uniq(arr)\n hash = Hash.new(0)\n arr.each {|el| hash[el] = 1} #value doesnt matter this case\n hash.keys\nend",
"def hash()\n #This is a stub, used for indexing\n end",
"def hashit\n n = 0\n Chars.split(\"\").each do |x|\n @rotor_hash[x] = @rotor_array[n]\n n += 1\n end \n @rotor_hash\n end",
"def my_uniq(arr)\n hsh = Hash.new(0)\n arr.each do |el|\n hsh[el] += 1\n end\n hsh.keys\nend",
"def generate_unique_key\n # not doing uppercase as url is case insensitive\n charset = ::Shortener.key_chars\n (0...::Shortener.unique_key_length).map{ charset[rand(charset.size)] }.join\n end",
"def rand_index\n SecureRandom.random_number(size)\n end",
"def unique_elements(array)\n hash = Hash.new(0)\n array.each { |ele| hash[ele] += 1 }\n\n hash.keys\nend",
"def uniq_integer(input_array)\n unique = 0\n input_array.each do |num|\n unique = unique ^ num\n end\n\n unique\nend",
"def ifind_magic(arr)\n return false if arr.size == 0\n s = arr[0]\n e = arr[-1]\n magic_arr = []\n i = 0\n while s < e\n return magic_arr if arr[i] != i\n if arr[i] == i\n magic_arr[i] = i\n end\n i += 1\n end\nend",
"def gen_first_path(path_length)\n # we will now generate an array with path_length number of elements\n # the elements will be randomly selected numbers from (1.. path_length ^ 2)\n # to avoid duplicate numbers we will kepp track of which ones have already been used\n # in another local array\n\n used = []\n\n path = {}\n\n path_length.times do |k, v|\n random = gen_uniq_rand(path_length ** 2, used)\n used << random\n path[random] = 0\n end\n\n path\nend",
"def create_index1(word)\n word.chars.sort!.join\n end",
"def random_entry(arr)\n arr[rand(arr.size)]\n end",
"def first_unique_char(s)\n\n hash = Hash.new(0)\n\n s.each_char.with_index(0) {|char, i|\n if hash[char] != nil\n hash[char] = hash[char] + 1\n else\n hash[char] = 1\n end\n\n # p hash\n }\n\n s.each_char.with_index(0) {|char, i|\n if hash[char] == 1\n return i\n end\n }\n return -1\n\nend",
"def generate_unique_id\n Digest::SHA256.hexdigest unique_id_elements.join\n end",
"def get_auto_hash\n hash = get_hash(Time.now.to_s)\n zeros = rand(5)\n (0..zeros).each do |z|\n hash[z] = \"0\"\n end\n\n return hash\nend",
"def dupe_indices(arr)\n idxs = Hash.new { |h, k| h[k] = [] }\n \n arr.each_with_index do |ele, i|\n idxs[ele] << i\n end\n\n return idxs.select { |ele, arr| arr.length > 1 }\nend",
"def initialize(seed)\n @index = 0\n @mt = []\n @mt[0] = seed\n (1...ARRAY_LENGTH).each do |i|\n @mt[i] = (2 **32 -1) & (INIT_CONST * (@mt[i-1] ^ (@mt[i-1] >> 30)) + i)\n end\n end",
"def make_artist unique_index\n artist_name = (0...8).map{ 65.+(rand(26)).chr }.join\n return \"INSERT INTO artists VALUES (#{rand(500)}, '#{artist_name}');\"\nend",
"def SHA256 arr\n Digest::SHA256.digest(arr.map(&:chr).join).bytes\nend",
"def unique_in_order(string)\n string.each_char.with_index.reduce([]) do |arr, (el, i)|\n if el == string.chars[i+1]\n arr\n else\n arr << el\n end\n end\nend",
"def array_to_hash(array) \n count=0\n\n hash = Hash.new\n (array.length).times do \n hash[count+1] = array[count]\n count += 1\n end\n return hash\n end",
"def magic_slow(arr)\n arr.each_with_index do |val, index|\n return index if val === index\n end\nend",
"def array_gen(hash)\n array = []\n hash.each do |key, value|\n value.times do\n array << key.to_s\n end\n end\n return array\nend",
"def index(key, size)\n ascii = 0\n \n key.each_byte do |x|\n ascii += x\n end\n \n return ascii % size\n end",
"def unique_elements(arr)\n hash = Hash.new(0)\n arr.each {|el| hash[el] += 1}\n return hash.keys\n\nend",
"def weighted_random_index(array)\n\nend",
"def unique_in_order(iterable) \n# create an empty array\ncontent = []\n\n # check each letter/number of `iterable` \n for e in (0..iterable.length()-1) \n\n# compare current element to previous element\n# if array is empty\n if e == 0 or \n# \n# if current element is not the same with previous element, push current index to content array\n iterable[e] != iterable[e-1] \n content.push(iterable[e])\n end\n end\n# return new content array\n return content\nend",
"def unique_index\n @unique_index\n end",
"def get_first_recurring_char(arr)\n hash = {}\n\n arr.each do |ele|\n key = ele.is_a?(Integer) ? ele.to_s : ele.to_sym\n return ele if hash[key]\n\n hash[key] = 'e'\n end\n 'The array is unique. No recurring character!!!'\nend",
"def index(key, size)\n char_value = 0\n # Adds together all of the ASCII values for each character into char_value.\n for letter in key.chars do\n char_value += letter.ord\n end\n # Increments char_value until its length equals desired size.\n until char_value.to_s.length == 7\n char_value*=11\n end\n\n return char_value%size\n end",
"def tiles_array_to_hash(array)\n tiles = Hash.new\n i = 0\n until i == array.length\n tiles[array[i]] = i\n i += 1\n end\n tiles\nend",
"def index(key, size)\n hash_code = 0\n key.each_byte do |c|\n hash_code += c\n end\n hash_code % @size\n end",
"def unique_elements(arr)\n hash = Hash.new(0)\n arr.each { |ele| hash[ele] += 1}\n hash.keys\nend",
"def my_uniq(arr)\n counter = Hash.new(0)\n arr.each do |x|\n counter[x] += 1\n end\n counter.keys\nend",
"def Unique(string)\n\n # assumes alphabet of size 128\n return false if string.length > 128\n \n hash={}\n \n for i in 0..string.length-1\n return false if hash[string[i]] \n hash[string[i]]=true\n end\n \n \nreturn true\n\nend",
"def hashing(i)\n \n return ALPHABET[0] if i == 0\n hash = ''\n base = ALPHABET.length\n while i > 0\n hash<< ALPHABET[i.modulo(base)]\n i /= base\n end\n hash.reverse\n end",
"def index_of(item)\n hash_value = 0\n item.each_byte { |byte| hash_value += byte }\n hash_value % @table.size\n end",
"def index(key, size)\n ascii_sum = 0\n key.split(\"\").each do |word|\n ascii_sum += word.ord\n end\n ascii_sum % size\n end",
"def index(key, size)\n sum = 0\n\n key.split(\"\").each do |char|\n if char.ord == 0\n next\n end\n\n sum = sum + char.ord\n end\n\n\n sum % size\n\n end",
"def magic_slow(arr)\n arr.each_with_index do |val, index|\n if val === index\n return index\n end\n end\nend",
"def using_uniq(array)\n\n \nend",
"def initialize(seed=42)\n @arr = []\n @size = 0\n r = Random.new(seed)\n @cardinality = 1000\n @hash_a = ((r.rand(PRIME_NUMBER-1)+1)%PRIME_NUMBER) % @cardinality\n @hash_b = r.rand(PRIME_NUMBER)\n end",
"def make_hash\n chars = (\"a\"..\"z\").to_a + (\"A\"..\"Z\").to_a + (\"0\"..\"9\").to_a\n string = \"\"\n 20.times do\n string << chars[rand(chars.size-1)]\n end\n hash = Digest::SHA2.hexdigest(string)\n end",
"def hash\n value = 0\n my_rows = @rows\n r_size = my_rows.size\n for i in 0..r_size-1 do\n a_row = my_rows[i]\n a_size = a_row.size\n for j in 0..a_size-1 do\n value ^= a_row[j].hash\n end\n end\n return value\n end",
"def index(key, size)\n sum = 0\n\n key.split(\"\").each do |char|\n if char.ord == 0\n next\n end\n\n sum = sum + char.ord\n end\n\n\n sum % size\n end",
"def index(key, size)\n sum = 0\n\n key.split(\"\").each do |char|\n if char.ord == 0\n next\n end\n\n sum = sum + char.ord\n end\n\n\n sum % size\n end",
"def yale_row_as_hash i\n h = yale_nd_row(i, :hash)\n return h if i >= self.shape[1] || self[i,i].nil? || self[i,i] == 0\n h[i] = self[i,i]\n end",
"def Hash_Func( str )\n hash = 0\n i = 0\n while i < str.length\n c = str[i]\n hash = hash * 31 + c.ord\n i = i + 1\n end\n hash = hash.abs\n return PaddGUID( hash )\n end",
"def non_repeating_char_index(string) \n hash = {}\n\n string.length.times do |i|\n if !hash.has_key?(string[i])\n hash[string[i]] = 1\n else\n hash[string[i]] += 1\n end\n end\n\n char = hash.select { |char, occurence| occurence == 1}\n .map { |char, occurence| char }[0]\n\n return string.index(char) \nend",
"def test_index_one_repeated_word\n #assert false # bogus assert -- remove or comment out\n @concordance.index!(['zero','zero','zero'])\n assert_equal({'zero'=>[1]},@concordance.hash)\n end",
"def hard(string)\n hasher = KnotHash.new(256, string.bytes + [17, 31, 73, 47, 23])\n 64.times { hasher.round }\n hasher.hash\nend",
"def test_index_array\r\n\t\tarr = [\"a\", \"b\", \"c\", \"a\", \"b\", \"d\", \"c\"]\r\n\t\tassert_equal({\"a\"=>[0,3], \"b\"=>[1,4], \"c\"=>[2,6], \"d\"=>[5]}, arr.find_values_index())\r\n\tend",
"def first_uniq_char(s)\n hash_table = {}\n (0..s.length-1).each do |i|\n if hash_table.include? (s[i])\n hash_table[s[i]] = hash_table[s[i]] + 1\n else\n hash_table[s[i]] = 1\n end\n end\n\n (0..s.length-1).each do |i|\n if hash_table[s[i]] == 1\n return i\n end\n end\n return -1\nend",
"def key_for_string str\n Digest::MD5.hexdigest(str).to_i(16) & KEY_MAX\n end",
"def generate_unique_key\n\n # @TODO:need to update the algo. Right now it's very simple algo\n length = self.url.length\n rand(36**length).to_s(36)\n end",
"def index(key, size)\n sum = 0\n\n key.split(\"\").each do |char|\n if char.ord == 0\n next\n end\n\n sum = sum + char.ord\n end\n\n sum % size\n end",
"def random_key\n o = [('a'..'z'), ('A'..'Z')].map(&:to_a).flatten\n (0...8).map { o[rand(o.length)] }.join\n end",
"def my_uniq(arr)\n \n output = []\n hash = Hash.new(false)\n \n arr.each do |x|\n output << x if !hash[x]\n hash[x] = true\n end\n output\n end",
"def index(key, size)\n value = ascii_value(key) % size\n return value\n end",
"def unique(arr)\n uniq = Hash.new(0)\n arr.each { |x| uniq[x] += 1 }\n uniq.select { |k, v| v == 1 }.keys\nend",
"def find_unique_elements (arr)\n n = Hash.new(0)\n return_array = []\n arr.each do |element|\n n[element] += 1\n end\n n.each_pair { |k,v| \n if v == 1\n return_array << k\n end\n }\n \n return return_array\nend",
"def generate_key(size = 6)\n charset = %w{ 2 3 4 6 7 9 A C D E F G H J K L M N P Q R T V W X Y Z}\n (0...size).map{ charset.to_a[rand(charset.size)] }.join\nend",
"def gimme(input_array)\n input_array.index(input_array.sort[1])\nend",
"def unique_elements(arr)\n my_hash = Hash.new(0)\n arr.each do |element|\n my_hash[element] += 1\n end\n return my_hash.keys\nend",
"def index\n @array = [45, 6, 32, 0]\n end"
] |
[
"0.63834584",
"0.62408745",
"0.6144398",
"0.60990644",
"0.60592127",
"0.6046242",
"0.6042425",
"0.60280126",
"0.5992942",
"0.5906817",
"0.5871855",
"0.5838909",
"0.58250093",
"0.5816861",
"0.57664907",
"0.57522625",
"0.5751663",
"0.57400036",
"0.5729892",
"0.57130796",
"0.5708408",
"0.5702879",
"0.5701204",
"0.5680978",
"0.5671231",
"0.56584144",
"0.5617152",
"0.5611801",
"0.5610672",
"0.561063",
"0.55887157",
"0.55598044",
"0.55557996",
"0.55414414",
"0.5535717",
"0.5534053",
"0.5521148",
"0.55131483",
"0.55084664",
"0.5503477",
"0.54947627",
"0.54916143",
"0.54911286",
"0.548662",
"0.5466709",
"0.5454102",
"0.5448943",
"0.5443764",
"0.5438011",
"0.5430865",
"0.5430254",
"0.5429421",
"0.5427968",
"0.54235995",
"0.5419781",
"0.54174817",
"0.54173523",
"0.5416028",
"0.54103553",
"0.5406169",
"0.5406004",
"0.5404584",
"0.53965044",
"0.53905773",
"0.5390543",
"0.53884065",
"0.53835976",
"0.53773254",
"0.5368964",
"0.53638625",
"0.53603643",
"0.53570557",
"0.5352038",
"0.53505045",
"0.5349038",
"0.5315847",
"0.53112984",
"0.53011656",
"0.52983326",
"0.5293961",
"0.5293099",
"0.5293099",
"0.52866644",
"0.5285471",
"0.528464",
"0.52834845",
"0.5269769",
"0.5268261",
"0.5268076",
"0.526779",
"0.5267541",
"0.5266755",
"0.52570695",
"0.5256897",
"0.5252947",
"0.5251492",
"0.52492195",
"0.5247806",
"0.52443707",
"0.5239008",
"0.5237722"
] |
0.0
|
-1
|
Calculate the current load factor
|
def load_factor
@items*1.0/size
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def load_factor\n puts \"Load Factor: #{new_load_factor = @item_count / @size.to_f}\"\n return new_load_factor\n end",
"def load_factor\n puts \"load_factor: #{@values} / #{@size}\"\n (@values + 0.0) / @size\n end",
"def load_factor\n max_pax / capacity.to_f\n end",
"def load_factor\n @count.to_f / size.to_f\n end",
"def load_factor\n @count.fdiv(size)\n end",
"def load_factor\n @entry_count / @size\n end",
"def load_factor\n Float(@num_items) / size\n end",
"def load_factor\n @item_count / size.to_f\n end",
"def load_factor\n @item_count/ size\n end",
"def load_factor\n return (@total_items.fdiv(size))\n end",
"def load_factor\n @item_count / size\n end",
"def load_factor\n @item_count / size\n end",
"def load_factor\n @item_count / self.size.to_f\n end",
"def load_factor\n @item_count / @items.length\n end",
"def load_factor\n # This calculates the load factor of the hash.\n # We take the size then add a decimal behind the last number.\n size = size() + 0.0\n # We divide entries by size\n lf = @entries / size\n # Return load factor\n return lf\n end",
"def load_factor\n total = 0.0\n @items.each do |item|\n if item.is_a? Node\n total = total + 1\n elsif item.is_a? LinkedList\n total = total + item.length\n end\n end\n total.to_f / @size.to_f\n end",
"def load_factor\n @items / self.get_size\n end",
"def load_factor\n sum = 0\n @hash_array.each do |llist|\n sum += llist.size\n end\n lf = sum / size.to_f\n\n while lf > @max_load_factor\n resize\n sum = 0\n @hash_array.each do |llist|\n sum += llist.size\n end\n lf = sum / size.to_f\n end\n lf\n end",
"def load_factor\n count = 0.0\n\n @items.each do |bucket|\n if !bucket.nil?\n count += bucket.size\n end\n end\n\n count / self.size\n end",
"def load_per_cpu(_)\n cpu_per_source = {}\n @client.query(\n '(count(node_cpu{mode=\"system\"})by(instance))'\n ).each do |result|\n source = result['metric']['instance']\n cpu_per_source[source] = result['value'][1]\n end\n\n metrics = []\n @client.query('node_load5').each do |result|\n source = result['metric']['instance']\n value = result['value'][1].to_f.round(2)\n load_on_cpu = value / cpu_per_source[source].to_f\n log.debug(\n \"[load_per_cpu] value: '#{load_on_cpu}', source: '#{source}'\"\n )\n metrics << {\n 'source' => source,\n 'value' => load_on_cpu\n }\n end\n metrics\n end",
"def load_factor\n total_nodes = 0.0\n index = -1\n @items.each do |item|\n index = index + 1\n if item != nil\n total_nodes = total_nodes + item.count\n end\n end\n factor = total_nodes / size\n if factor > 0.7\n resize\n end\n return factor\n end",
"def load_factor\n total_size = 0\n @items.each do |list|\n unless list == nil\n node = list.head\n while node != nil\n total_size += 1\n node = node.next\n end\n end\n end\n total_size.to_f / @items.count\n end",
"def load_factor\n count = 0.0\n @items.each{ |ele|\n next unless ele\n count += 1\n until ele.next == nil\n ele = ele.next\n count += 1\n end\n }\n count/size\n end",
"def startup_performance_score\n return @startup_performance_score\n end",
"def load_factor\n node_count = 0.0\n \n @items.each do |item|\n if item != nil\n current_node = item.head\n while current_node != nil\n node_count += 1\n current_node = current_node.next\n end\n end\n end\n @max_load_factor = (node_count / @items.size)\n if @max_load_factor > 0.70\n self.resize\n self.load_factor\n else\n @max_load_factor\n end\n end",
"def model_startup_performance_score\n return @model_startup_performance_score\n end",
"def loadcpu( num1, num2 )\n res = 0.0\n (1..1000000).each do |i|\n res += num1 / num2 * i\n end\n res\nend",
"def res_vs_comm_planning_load\n res = find_by_class('triplex_node').inject(0.0) { |total, tn| total + tn[:power_12].to_f } / 1e6\n comm = find_by_class('load').inject(0.0) { |total, l| total + l.total_real_constant_power } / 1e6\n total = res + comm\n puts \"#{File.basename(@infilename, EXT)}: #{'%0.2f' % total} = #{'%0.2f' % res} (#{'%0.0f' % (res / total * 100)}%) + #{'%0.2f' % comm} (#{'%0.0f' % (comm / total * 100)}%)\"\n end",
"def load_factor\n counter = 0\n @items.each do |item|\n if item != nil && item.kind_of?(LinkedList) == false\n counter += 1\n elsif item != nil && item.kind_of?(LinkedList) == true\n temp_node = item.head\n while temp_node != nil\n counter += 1\n temp_node = temp_node.next\n end\n else\n next\n end\n end\n return counter.to_f / size\n end",
"def spare_load_curve\n max_load_curve - load_curve\n end",
"def average_load\n load_curve.sum / load_curve.length\n end",
"def total_workload\n @graders.map(&:workload).reduce(:+)\n end",
"def calculate_session_load\n self.session_load = self.duration * self.difficulty\n end",
"def load(extended: false)\n (used(extended: extended) / total(extended: extended).to_f).round(2) * 100\n end",
"def processor_percents\n reply = `sar -P ALL #{@sleep} 1`\n lines = reply.split(\"\\n\")\n header = lines.shift\n num_cpus = header[/\\((\\d+) CPU\\)$/, 1].to_i\n # read a cycle\n 3.times { lines.shift }\n @cpus = num_cpus.times.map do\n line = lines.shift\n line.chomp!\n # the total usage (100% - idle)\n 100.0 - line[/\\s+([\\d\\.]+)$/,1].to_f\n end\n end",
"def current_annual_load\n (current_daily_load * 365.2425 / 1000).to_i\n end",
"def cpu_loadavg\n `cat /proc/loadavg`.split\n end",
"def current_daily_load\n data_streams_by_status.map { |x| x.averaged_daily_load.to_i }\n .inject(0, :+)\n end",
"def requests_per_second\n requests / horizon_time\n end",
"def percent_cpu\n (metrics['CPU'] / 12).round\n end",
"def output_node_hit_rate\n cache_controller = @bmconfig.sp_controller.instance_variable_get(:@hash_tree_controller)\n node_to_load = cache_controller.total_node_to_load\n node_needed = cache_controller.total_node_needed\n puts \"node cache hit rate = 1 - #{node_to_load}/#{node_needed} = #{(1-node_to_load.to_f/node_needed)*100}%\"\n cache_controller.reset_hit_info\n end",
"def number_of_units\n return 0.0 if demand.zero?\n return super unless full_load_hours&.positive?\n\n if input_capacity&.positive?\n demand / (input_capacity * full_load_hours)\n elsif output_capacity&.positive?\n (demand - output_of_loss) / (output_capacity * full_load_hours)\n else\n super\n end\n end",
"def speedFactor\n Integer((@energy + @health) / (MAX_HEALTH + MAX_ENERGY)) * 10\n end",
"def cpu_metrics\n super\n end",
"def effective_rate; end",
"def load_time\n \"#{(Time.now-@start_time).round(4)}s\"\n end",
"def rate_scale; end",
"def available_capacity(point)\n local_producers(point, @abroad.price_curve.get(point))\n .reduce(0.0) do |sum, prod|\n sum + (prod.max_load_at(point) - prod.load_curve.get(point))\n end\n end",
"def load_time\n @time_counter = Time.new.to_i\n end",
"def active_percent\n (active_jobs.to_f / available_jobs.to_f) * 100\n end",
"def boot_score\n return @boot_score\n end",
"def progress_rate\n 1\n end",
"def load_between(start, finish)\n if @load_profile\n @load_profile.values[start..finish].sum * max_production\n else\n available_output_capacity * (1 + (finish - start))\n end\n end",
"def accuracy(path)\n if @@overhead\n over=@@overhead[:time].total+@@overhead[:time].real\n if over>0\n m=get_measurement(path)\n return ((m.time.total+m.time.real)*@@overhead[:count] / (over*m.count)) if m.count>0\n end\n end\n -1.0\n end",
"def other_runtime\n @total_runtime - @db_runtime - @view_runtime\n end",
"def boost\n 1.0\n end",
"def fast_ready_bonus\n [100, features_sum(:fast_ready)].min / 100.0\n end",
"def get_cpu_price(workstation_id) # ...\n 120\n end",
"def accuracy\n\t\tnumber_of_documents > 0 ? number_of_right_classifications.fdiv(number_of_documents) : 0\n\tend",
"def factor\n @factor if valid?\n end",
"def GetScaleFactor()\n\t\treturn @k;\n\tend",
"def capacity_to_demand_multiplier\n 1.0\n end",
"def load_per_cluster(cfg)\n cluster = cfg['cluster']\n query = format(\n 'sum(node_load5{job=\"%s\"})/count(node_cpu{mode=\"system\",job=\"%s\"})',\n cluster,\n cluster\n )\n\n result = @client.query(query).first\n source = cfg['source']\n value = result['value'][1].to_f.round(2)\n log.debug(\n \"[load_per_cluster] value: '#{value}', source: '#{source}'\"\n )\n\n [{ 'source' => source, 'value' => value }]\n end",
"def compaction_weight(region_load)\n (region_load.getStorefiles() - 1) * region_load.getStorefileSizeMB()\nend",
"def current_power_usage\n begin\n power_being_used = 0.0\n\n (1..3).each do |ipdp|\n (1..4).each do |ap|\n power_reading = @xml.xpath(\"//XMLdata//info8_IPDP#{ipdp}_ap#{ap}\")[0].content.to_f\n power_being_used += power_reading #in Watts\n end\n end\n \n return power_being_used/1000.0 #in KW\n\n rescue #If something is wrong with the data\n return 0.0\n end\n end",
"def running_average; end",
"def frame_rate\n return (1 / DT).to_i\n end",
"def max_train_speed\n 50\n end",
"def max_load_at(point_in_time)\n if @load_profile\n @load_profile[point_in_time] * (@max_production || max_production)\n else\n @available_output_capacity || available_output_capacity\n end\n end",
"def import_progress\n import_done.to_f / ( import_total || 999999999 )\n end",
"def calculate\n # Percentage of understanding is calculated by following\n self.progress_rate = ((sum_of_point.to_f / total_count.to_f) * 100.00).round(2)\n end",
"def moving_fuel_efficiency\n if predecessor\n logger.debug(\"[#{self.class}.moving_fuel_efficiency] Calculating for #{description}: #{running_total_mileage} / #{running_total_liter} = #{(running_total_mileage.to_f / running_total_liter).round(1)}\")\n (running_total_mileage.to_f / running_total_liter).round(1)\n end\n end",
"def get_active_capacity\n rpc_get_fact_direct('active_capacity').to_f\n end",
"def get_scale\n runs = []\n 10.times do\n runs << measure(1, &@options[:fn])\n end\n runs.inject(:+) / 10\n end",
"def loadcpu2( num1, num2 )\n res = 0.0\n (1..1000000).each do |i|\n res = c_mul_add_add(res, num1, num2,i)\n end\n res\nend",
"def processor_count; end",
"def processor_count; end",
"def calculate_base_cost(numTokens)\r\n return numTokens * Rails.application.config.cost_of_token\r\n end",
"def profile_completeness_percent\n Cache.get(['profile_c', self], nil, true){\n total = completed = 0.0\n self.profile_elements.each do |element, is_completed|\n total += 1.0\n completed += 1.0 if is_completed\n end\n (completed / total).round(2)\n }.to_f\n end",
"def step_divisor\n 10 + features_sum(:anger_mantain)\n end",
"def score\n return self.progress - self.budget_ratio\n end",
"def ratio\n HireFire.configuration.job_worker_ratio.reverse\n end",
"def framerate\n\t\t\t\t# below is same as: return @ticks / (lifetime / 1000.0)\n\t\t\t\treturn 1000.0 * @ticks / lifetime()\n\t\t\trescue ZeroDivisionError\n\t\t\t\treturn 0\n\t\t\tend",
"def init_counters\n calculate_ratio_sum\n calculate_proxies_needed\n end",
"def startup_performance_score=(value)\n @startup_performance_score = value\n end",
"def learning_curve factor\n @learning_curve = []\n current_week_data = current_user.reports.where(exam_date:(Time.now.all_week())).map {|x| x.send(:\"#{factor}\")}\n prev_week_data = current_user.reports.where(exam_date:((Time.now-1.week).all_week())).map {|x| x.send(:\"#{factor}\")}\n @learning_curve << (average(current_week_data) - average(prev_week_data)).round(2)\n current_month_data = current_user.reports.where(exam_date:(Time.now.all_month())).map {|x| x.send(:\"#{factor}\")}\n prev_month_data = current_user.reports.where(exam_date:((Time.now-1.month).all_month())).map {|x| x.send(:\"#{factor}\")}\n @learning_curve << (average(current_month_data) - average(prev_month_data)).round(2)\n @learning_curve = [0,0] if @learning_curve.empty?\n end",
"def factor\n @factor ||= reference_factor * reference_units.inject(Rational(1,1)){|f, (ru, exp)| f * (ru.factor**exp)}\n end",
"def model_startup_performance_score=(value)\n @model_startup_performance_score = value\n end",
"def processor_core_count_check_failed_percentage\n return @processor_core_count_check_failed_percentage\n end",
"def set_a_c_ratio\n # divide by zero possibility => must check what to do with this edge case\n if @chronic_load == 0\n return 0\n else\n a_c_ratio = @acute_load / @chronic_load\n return a_c_ratio\n end\n end",
"def cpu_time\n @cpu_time_finish - @cpu_time_start\n end",
"def nodes_percent\n (nodes_used.to_f / nodes_avail.to_f) * 100\n end",
"def processor_speed_check_failed_percentage\n return @processor_speed_check_failed_percentage\n end",
"def processor_count\n @processor_count.value\n end",
"def get_cpu\n return @m_cpu\n end",
"def default_latency\n 1.0\n end",
"def cloud_provisioning_score\n return @cloud_provisioning_score\n end",
"def compute_fullcnpswage\n ( full_caissebase + full_process_bonuses ).ceil\n end",
"def travel_ratio\n travel_ratio = actual_travel * 100 / budget_flight\n end",
"def calories_per_liter\n 672\n end"
] |
[
"0.8291456",
"0.80895066",
"0.80326515",
"0.7949917",
"0.77805996",
"0.7604256",
"0.7575579",
"0.7466798",
"0.7421441",
"0.7403656",
"0.7399935",
"0.7399935",
"0.73053604",
"0.7291829",
"0.71660674",
"0.70975053",
"0.7044498",
"0.70077485",
"0.69255835",
"0.68608534",
"0.67615736",
"0.65408915",
"0.6512344",
"0.6499879",
"0.63928026",
"0.6351376",
"0.6341498",
"0.6318808",
"0.62886304",
"0.62731504",
"0.6204007",
"0.61624396",
"0.6130686",
"0.6124384",
"0.61074585",
"0.60999405",
"0.6098406",
"0.60726005",
"0.6036973",
"0.6024627",
"0.59546983",
"0.59518534",
"0.5934211",
"0.58395",
"0.58132076",
"0.58069277",
"0.5740925",
"0.57378423",
"0.5735507",
"0.5734569",
"0.57196987",
"0.5687561",
"0.56828785",
"0.56705743",
"0.56463516",
"0.5637466",
"0.5634684",
"0.56318575",
"0.5619314",
"0.5607393",
"0.5589638",
"0.55743587",
"0.5561865",
"0.55562377",
"0.5553779",
"0.5530526",
"0.5523477",
"0.5512437",
"0.55106694",
"0.5510486",
"0.55074656",
"0.5502518",
"0.5497971",
"0.54957193",
"0.5495712",
"0.54935634",
"0.54935634",
"0.5477675",
"0.54771954",
"0.5473124",
"0.54731166",
"0.54689974",
"0.54641753",
"0.5460117",
"0.5459294",
"0.5459131",
"0.54483044",
"0.54461896",
"0.5437622",
"0.5425164",
"0.54250664",
"0.5423462",
"0.5417758",
"0.54120827",
"0.5398815",
"0.5395925",
"0.5393164",
"0.5391427",
"0.5389059",
"0.5388248"
] |
0.7146284
|
15
|
Simple method to return the number of items in the hash
|
def size
@array.length
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def size\n return @hash.length\n end",
"def length\n hash.keys.length\n end",
"def size\n @hash.size\n end",
"def size\n @hash.size\n end",
"def size\n @hash.size\n end",
"def size\n @hash_array.length\n end",
"def size\n @hash_array.length\n end",
"def size\n @hash_table.keys.length\n end",
"def size\n keys.size\n end",
"def length\n @internal_hash.length\n end",
"def count\n @hash_tags.count\n end",
"def count(list)\n list.each do |hash|\n total += 1\n end\n return total\n end",
"def length()\n return self.keys.get_length()\n end",
"def size\n @keys.size\n end",
"def hlen(key); end",
"def hlen(key); end",
"def length()\n return @i_keys.get_length()\n end",
"def length\n keys.length\n end",
"def num_keys\n end",
"def length\n return @ghash.length\n end",
"def value_count(hash, value)\n hash.select { |_k, v| v == value }.length\nend",
"def test_Hash_InstanceMethods_size\n\t\th={1=>'a', 2=>'b', 3=>'c'}\n\t\tassert_equal(3, h.size)\n\tend",
"def count\r\n items.size\r\n end",
"def size\n @hash.size + @converted.size\n end",
"def hash_size\n hashref_size * num_hashes\n end",
"def length\n @driver_instance.count_list_value(@key)\n end",
"def nitems() end",
"def count_objects\n count = 0\n @objects.keys.each do |key|\n count += @objects[key].length\n end\n\n return count\n end",
"def size\n @redis.llen @key\n end",
"def item_count\n item_values.values.compact.sum { |v| v.is_a?(Array) ? v.size : 1 }\n end",
"def size\n @buckets.length\n end",
"def get_size\n @buckets.length\n end",
"def count_items\n @items.size\n end",
"def item_count\n @items.length \n end",
"def size\n self.data.keys.size\n end",
"def size\n @index.keys.uniq.count\n end",
"def length\n @results.keys.length\n end",
"def item_count\n @items.length\n end",
"def count\n redis { |conn| conn.llen(key) }\n end",
"def count; @value.size; end",
"def size\n @store.keys.count { |k| Time.now - @store[k].stamp < @lifetime }\n end",
"def count\n @item_list.size\n end",
"def count\n values.inject(0){|m, v| m + v.length}\n end",
"def size\n @keys.length - 1\n end",
"def size(hash1=self.orderJSON)\n sum = 0\n unless hash1.class == Hash\n hash1 = eval(hash1)\n end\n hash1.each do |k1,v1|\n v1.each do |k2,v2|\n sum += v2.to_i\n end\n end\n return sum \n end",
"def length\n stash.length\n end",
"def value_count(hash, value)\n count = 0\n hash.each { |elem| count += 1 if elem[1]==value }\n count\nend",
"def key_count\n $capitals.keys.length\nend",
"def size\n @items.count\n end",
"def size\n @items.count\n end",
"def count\n each.size\n end",
"def count(data)\n return data.length\n end",
"def size\n return @items.size\n end",
"def counts\n count = Hash.new(0)\n self.each{|ele| count[ele] += 1}\n count\n end",
"def size\n return @items.length\n end",
"def size\n return @items.length\n end",
"def size\n return @items.length\n end",
"def size\n return @items.length\n end",
"def size\n return @items.length\n end",
"def size\n return @items.length\n end",
"def size\n return @items.length\n end",
"def size\n entries.length\n end",
"def hit_count\n item_hash.deep_find(:hit_count, 0)\n end",
"def hashref_size\n hashptr_size + length_size\n end",
"def size\n\t\treturn @items.size\n end",
"def size\n return @items.size\n end",
"def size\n entries.size\n end",
"def size\n @references_to_keys_map.count do |_, ref|\n ref.object\n end\n end",
"def count_items(name)\n @items[name].size\n end",
"def size\n counter = 0\n @items.each do |item|\n if item.nil?\n counter += 1\n else\n counter += item.length - 1\n end\n end\n counter\n end",
"def size\n return @items.length\n end",
"def print_counts(hash)\n hash.each { |key, count| puts \"#{key} -- #{count}\\n---------\\n\" }\nend",
"def occurences_count\n\t\t\t\t\t\tHash.new(0).tap do |result|\n\t\t\t\t\t\t each { |item| result[item] += 1 }\n\t\t\t\t\t\tend\n\t\t\t\tend",
"def count\n @data.size\n end",
"def item_count()\n @names.count\n end",
"def size\n @count\n end",
"def size\n @count\n end",
"def customer_pet_count(customer_hash)\n return customer_hash[:pets].length\nend",
"def num_buckets\n @store.length\n end",
"def size\n data.values.inject(0){|m,v| m+=v.size}\n end",
"def length\n each.count\n end",
"def count\n to_a.size\n end",
"def count\n to_a.size\n end",
"def size\n items.size\n end",
"def size\n items.size\n end",
"def item_count\n collection.length\n end",
"def size\n @clients.keys.length\n end",
"def my_count\n if block_given?\n num = 0\n self.my_each{|item| num += 1 if yield(item)}\n num\n else\n # if no block given return size of array\n self.length\n end\n end",
"def size\n\n @items.size\n end",
"def count\n @map.count\n end",
"def size\n entries.length\n end",
"def count\n items.compact.count.to_d\n end",
"def item_count\n @collection.length\n end",
"def size\n @size ||= (@key_map || @row || []).size\n end",
"def count\n @obj['count'].to_i\n end",
"def size\n entries.size\n end",
"def size\n entries.size\n end",
"def cardinality\n redis.hget(bucket_key, RedisBackend::COUNT_FIELD).to_i\n end",
"def size\n @items.length\n end",
"def size\n @items.length \n end",
"def size\n count = 0\n @properties.each do |gid, values|\n if ! values.empty?\n count += 1\n end\n end\n return count\n end"
] |
[
"0.82830465",
"0.82106954",
"0.8109915",
"0.8109915",
"0.8109915",
"0.79695594",
"0.79695594",
"0.78124315",
"0.77486163",
"0.76849425",
"0.7678069",
"0.7656559",
"0.7636084",
"0.76298493",
"0.761464",
"0.761464",
"0.7574793",
"0.7569945",
"0.7478816",
"0.7444118",
"0.7398974",
"0.7347107",
"0.7325141",
"0.73046833",
"0.7278303",
"0.7254247",
"0.72418344",
"0.72181946",
"0.7218174",
"0.7212672",
"0.7163285",
"0.7155209",
"0.71543235",
"0.7141862",
"0.7141228",
"0.7114565",
"0.7113586",
"0.70941246",
"0.70929605",
"0.7078681",
"0.7075524",
"0.70673853",
"0.704924",
"0.7045759",
"0.7036195",
"0.7036063",
"0.70260674",
"0.7013333",
"0.7007178",
"0.7007178",
"0.6999955",
"0.69869804",
"0.69839865",
"0.69832903",
"0.6981746",
"0.6981746",
"0.6981746",
"0.6981746",
"0.6981746",
"0.6981746",
"0.6981746",
"0.698101",
"0.6957832",
"0.69537604",
"0.6951404",
"0.69499755",
"0.6942363",
"0.69395435",
"0.6938698",
"0.6935908",
"0.6935669",
"0.6932399",
"0.6930644",
"0.69240755",
"0.69203275",
"0.6903333",
"0.6903333",
"0.6896567",
"0.68949735",
"0.6894421",
"0.68883306",
"0.6887863",
"0.6887863",
"0.6878182",
"0.6878182",
"0.687759",
"0.6873718",
"0.6871754",
"0.6845873",
"0.6842765",
"0.683874",
"0.68387157",
"0.68368727",
"0.6836297",
"0.6833241",
"0.68303066",
"0.68303066",
"0.68206984",
"0.68202174",
"0.68190515",
"0.6816045"
] |
0.0
|
-1
|
letters that appear more than once in the string. You may assume the string contains only lowercase letters. Count the number of letters that repeat, not the number of times they repeat in the string. Difficulty: hard.
|
def num_repeats(string)
count = {}
string.each_char {|x| count[x] = string.count(x)}
count.select! {|k, v| v > 1}
count.length
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def num_repeats(string)\n i = 0 \n count = 0\n check = nil\n \n while i < string.length\n letter = string[i]\n i2 = 1 \n while i2 < string.length\n letter2 = string[i2]\n \n if i < i2\n if letter == letter2\n if check == nil\n check = letter\n count += 1\n elsif letter != check\n count += 1\n check = letter\n end\n end\n end\n \n i2 += 1\n end\n i += 1\n end\n return(count)\nend",
"def num_repeats(string)\n string = string.gsub(\" \", \"\") \n # Get rid of spaces. Also if this contained numbers, symbols, etc would need to delete those too or they will be counted\n letters = string.split(\"\")\n holder = []\n\n i = 0\n count = 0\n while i < letters.length\n j = i+1\n while j < letters.length\n if letters[i] == letters[j] && !holder.include?(letters[i])\n count += 1\n holder << letters[i]\n end\n j += 1\n end\n i += 1\n end\ncount\nend",
"def num_repeats(string)\r\n idx_str = 0\r\n idx2 = idx_str+1\r\n counter = 0\r\n repeated_letter = \"\"\r\n while idx_str < string.length\r\n if !repeated_letter.include? string[idx_str]\r\n while idx2 < string.length\r\n if string[idx_str] == string[idx2]\r\n repeated_letter += string[idx_str]\r\n counter +=1\r\n break\r\n end\r\n idx2 +=1\r\n end\r\n end\r\n idx_str += 1\r\n idx2 = idx_str+1\r\n end\r\n return counter\r\nend",
"def duplicate_count(str)\n str.downcase.each_char.find_all { |c| str.downcase.count(c) > 1 }.uniq.size\nend",
"def num_repeats(string)\n\tcount = 0\n\tdix = 0\n\tnew = \"\"\n\twhile dix < string.length\n\t\tletter = string[dix]\n\t\tunless new.include?(letter)\n\t\t\tnew = new + letter\n\t\telse\n\t\t #...\n\t\tend\n\t\tdix2 = dix + 1\n\t\twhile dix2 < string.length\n\t\t\tif letter == string[dix2]\n\t\t\t\tcount +=1\n\t\t\t\tbreak\n\t\t\tend\n\t\t\tdix2 +=1\n\t\tend\n\t\tdix += 1\n\tend\n\tputs(count.to_s)\n\treturn count\n\n\nend",
"def double_letter_count(string)\n repeating_letters = 0\n string.each_char.with_index do |char, i|\n if string[i] == string[i + 1]\n repeating_letters += 1\n end\n end\n return repeating_letters\nend",
"def double_letter_count(string)\r\n repeats = 0\r\n oldChar = ''\r\n string.each_char do |char|\r\n if oldChar == char\r\n repeats += 1\r\n end\r\n oldChar = char\r\n end\r\n return repeats\r\nend",
"def num_repeats(string)\n # Keep track of letters\n lettercount = []\n num_rpt_letters=0 \n \n # Walk through string\n i=0\n while i<string.length\n \n # Check whether letter has already been counted\n letterfound = false\n j=0\n \n while j<lettercount.length\n # If letter has already appeared, increment the count\n if string[i]==lettercount[j][0]\n lettercount[j][1]+=1\n letterfound = true\n break\n end\n j+=1\n end\n \n # Letter is not in lettercount, add it\n if !letterfound\n lettercount.push([string[i], 1])\n end\n \n i+=1\n end\n \n # Go through lettercount, and see how many appeared in our string more than once\n i=0\n while i<lettercount.length\n puts(lettercount[i][0] + lettercount[i][1].to_s)\n if lettercount[i][1] > 1\n num_rpt_letters += 1\n end\n i += 1\n end\n \n \n return num_rpt_letters\n \nend",
"def num_repeats(string)\n found_letters = []\n idx1 = 0\n while idx1 < string.length\n idx2 = idx1 + 1\n while idx2 < string.length\n if string[idx1] == string[idx2] && !found_letters.include?(string[idx1])\n found_letters.push(string[idx1])\n end\n idx2 += 1\n end\n idx1 += 1\n end \n return found_letters.length\nend",
"def num_repeats(string)\n\tio = 0\n\ti = io + 1\n\tyo = 0\n\ty = yo + 1\n\tletters = []\n\tcounter = 0\n\n\twhile io < string.length\n\t\twhile i <= string.length\n\t\t\tif string[io] == string[i]\n\t\t\t\tletters.push(string[io])\n\t\t\t\tio += 1\n\t\t\t\ti = io + 1\n\t\t\t\twhile yo < letters.length\n\t\t\t\t\t\tif string[io] == letters[yo]\n\t\t\t\t\t\t\tio += 1\n\t\t\t\t\t\t\ti = io + 1\n\t\t\t\t\t\t\tyo = 1\n\t\t\t\t\t\telse yo += 1\n\t\t\t\t\t\tend\n\t\t\t\tend\n\n\t\t\tcounter += 1\n\t\t\tend\n\n\t\ti += 1\n\t\tend\n\t\tio += 1\n\t\ti = io + 1\n\tend\n\treturn counter\n\nend",
"def num_repeats(string)\n\ti = 0\n\tanswer = 0\n\tfreq = 0\n\n\twhile i < string.length\n\t\tletter = string[i]\n\t\tif string[i] == letter\n\t\t\tfreq += 1\n\t\tend\n\t\tif freq > 1\n\t\t\tanswer += 1\n\t\tend\n\tend\nend",
"def num_repeats(string)\n\n # number of repeating characters\n n = 0\n # tracks the character frequency\n repeats = Hash.new(0)\n\n string.each_char do |c|\n repeats[c] += 1\n if repeats[c] == 2\n n += 1\n end\n end\n n\nend",
"def double_letter_count(string)\n\tcount = 0\t\n \t(0...string.length).each do |i|\n \tif string[i] == string[i-1]\n \t\tcount += 1\n end\n end\n \treturn count\nend",
"def num_repeats(string)\n\t#Counter to track the number of numbers greater than 1\n\tcounter = 0\n\tletter_count = {}\n\t#Remove spaces by splitting the string into an array and then back again\n\tinput_line = string.scan(/[a-zA-Z]/).join.downcase\n\tfor x in 0...input_line.length do\n\t\tif letter_count.has_key?(input_line[x])\n\t\t\tletter_count[input_line[x]] += 1\n\t\telse\n\t\t\tletter_count[input_line[x]] = 1\n\t\tend\n\tend\n\tletter_count.each do |letter, count|\n\t\tif count > 1\n\t\t\tcounter += 1\n\t\t\tputs \"Test num_repeats: adding #{letter} to list\"\n\t\tend\n\tend\n\treturn counter\nend",
"def duplicate_count(text)\n characters = text.downcase.chars.each_with_object(Hash.new(0)) do |chr, hash|\n hash[chr] += 1\n end\n\n characters.values.select{|count| count > 1}.size\nend",
"def num_repeats(string)\nnums = Hash.new(0)\ncount = 0\n\nstring.each_char do |letter| nums[letter] += 1 end\n\nnums.keys.each do |key|\n\tif nums[key] > 1\n\t\tcount += 1\n\tend\nend\ncount\n\nend",
"def num_repeats(string)\n\trepeats = 0\n\tletters = []\n\n\tcurrentCount = 0\n\tcurrentLetter = \"\"\n\n\ti = 0\n\twhile i < string.length\n\tcurrentLetter = string[i]\n\n\tj = 0\n\twhile j < string.length\n\n\t\tif string[j] == currentLetter\n\t\t\tcurrentCount += 1\n\t\tend\n\t\tj += 1\n\tend\n\n\tif currentCount > 1\n\t\tif letters.include? (currentLetter)\n\t\telse\n\t\t\trepeats += 1\n\t\t\tletters.push(currentLetter)\n\t\tend\n\tend\n\n\tcurrentCount = 0\n\ti += 1\nend\n\nputs \"Repeat Count: #{repeats} \\nRepeated Letters: #{letters}\"\nreturn repeats\n\n\nend",
"def duplicate_count(text)\n characters = {}\n\n text.downcase.each_char do |chr|\n characters[chr] ? characters[chr] += 1 : characters[chr] = 1\n end\n\n characters.values.select{|count| count > 1}.size\nend",
"def repeating_letters?(str)\n # your code goes here\n # new_str = str.downcase\n # hash = Hash.new(0)\n\n # new_str.each_char do |char|\n # hash[char] += 1\n # end\n\n # hash.each do |k,v|\n # if v > 1\n # return true\n # end\n # end\n # false\n\n str.downcase.chars.uniq.length != str.length\nend",
"def duplicate_count(text)\n count = 0\n text.downcase.chars.uniq.each do |char|\n count += 1 if text.downcase.chars.count(char) > 1\n end\n count\nend",
"def double_letter_count(string)\n\tcount = 0\n \tval = 0\n \twhile count < string.length\n if string[count] == string[count + 1]\n val +=1\n end\n count +=1\n end\n\treturn val\n end",
"def duplicate_count(text)\n text = text.downcase\n // ('a'..'z').count { |c| text.downcase.count(c) > 1 }\n return text.chars.uniq.count { |char| text.count(char) > 1 }\nend",
"def duplicate_count(str)\n arr = str.downcase.chars\n counts = {}\n arr.each do |char|\n if counts.include?(char)\n counts[char] += 1\n else\n counts[char] = 1\n end\n end\n output = 0\n counts.each_value do |num|\n output += 1 if num > 1\n end\n output\nend",
"def duplicate_count(text)\n text.downcase.chars.sort.join.scan(/(\\w)\\1{1,}/).size\nend",
"def double_letter_count(string)\n\tcount = 0\n \tprev = \"\"\n \tstring.each_char do |c|\n \tif prev == c\n count += 1\n end\n \tprev = c\n end\n \treturn count\nend",
"def duplicate_count(text)\n ('a'..'z').count { |c| text.downcase.count(c) > 1 }\nend",
"def double_letter_count(string)\ncount = 0\narr = string.split(\"\")\n\ni = 0\nwhile i < arr.length\n\tif arr[i] == arr[i + 1]\n\t\tcount += 1\n\tend\n\ti += 1\nend\n\n\n\nreturn count\n\nend",
"def duplicate_count(text)\n text.downcase.chars.find_all{|char| text.downcase.count(char.downcase) > 1}.uniq.size\nend",
"def count_repeated_letters(word)\n # character: # of occurences\n occurences = Hash.new(0)\n count = 0\n\n word.each_char do |c|\n occurences[c] += 1\n if occurences[c] == 2\n count+=1\n end\n end\n count\nend",
"def num_repeats(string)\n h = Hash.new(0)\n string.each_char do |c| \n h[c] = h[c] ? h[c]+1 : 1\n end \n repeated = h.values.select {|n| n > 1 }\n return repeated.length\n \n \n # I'm just going to leave this right here so you remember how much time you wasted trying to write javascript in ruby. There's a method for everything!\n #\n # repeated = 0\n # i = 0\n # count = 0\n # while i < string.length\n # #count up the times a letter occurs in a string\n # j = 0\n # while j < string.length\n # if string[i] == string[j]\n # count += 1\n # end\n # j += 1 \n # #if the answer is greater than 1, increment repeated\n # if count > 1\n # repeated += 1\n # end\n # count = 0\n # i += 1\n # end \n \n # #split string into array\n # strArray = string.split(\"\")\n # #iterate over array\n # i = 0\n # while i < strArray.length\n # #for each letter the first letter matches, update counter\n # for j in strArray\n # if strArray[i] == j\n # counter += 1\n # end \n # #if counter > 1 \n # end\n # if counter > 1\n # #update repeated variable\n # repeated += 1\n # end \n # counter = 0\n # i += 1\n \n # puts repeated\n # return repeated\nend",
"def num_repeats(string)\n tallies = {}\n\n (0..string.length - 1).each do |idx|\n letter = string[idx]\n tallies[letter] ||= 0\n tallies[letter] += 1\n end\n\n count_tallies_greater_than_two(tallies)\nend",
"def duplicate_count(text)\n return 0 if text.empty?\n\n hash = Hash.new { 0 }\n text.split('').map(&:downcase).map(&:to_sym).each do |char|\n hash[char] += 1\n end\n\n hash.count { |_, v| v >= 2 }\nend",
"def LetterCountI(str)\n\n str = str.split\n repeating_letters = []\n str.each do |word| \n word = word.split(\"\")\n letters = Hash.new(0)\n word.each { |letter| letters[letter] += 1 }\n selected_letters = letters.select { |key, value| value > 1 }\n repeating_letters << selected_letters.keys.length\n end\n if (repeating_letters.select {|l| l >= 1}).empty?\n return -1\n else\n max = repeating_letters.max\n return str[repeating_letters.index(max)]\n end\nend",
"def duplicate_count(text)\n letters = text.downcase.chars\n count = letters.each_with_object(Hash.new(0)) { |let, hash| hash[let] += 1 }\n count.select { |k, v| v > 1}.size\n \n # text.downcase\n # .chars\n # .each_with_object(Hash.new(0)) { |let, hash| hash[let] += 1 }\n # .values\n # .count { |v| v > 1 }\n \n # count = Hash.new(0)\n # text.downcase.chars.each { |let| count[let] += 1 }\n # count.values.count { |v| v > 1 }\nend",
"def num_repeats(string)\n \nidx1 = 0 #Made a counter for first loop\nidx2 = 0 #Made another counter for the second loop\nrepeat_count = 0 #Assigned a variable to tally the number of letters that had repeated in the string\ncurrent_repeat_count= []\nidx3 = 0\n while idx1 < string.length #The characters in the string will be scanned over and over again until it reaches the string.length\n idx2 = idx1 + 1 #the the second loop will always be 1 element ahead of the idx1 to scan them properly\n \n while idx2 < string.length #Same logic with the first loop\n unless current_repeat_count[idx3] == string[idx2]\n if string[idx1] == string[idx2] #if the current element of idx1 is the same with the current element of idx2, \n current_repeat_count << string[idx2]\n repeat_count = repeat_count + 1# repeat_count will increase by 1 each time\n end\n end\n \n idx2 = idx2 + 1 #idx2 will increase by 1 to go to the next element\n end\n idx1 = idx1 + 1 #after the first round of the first element pairs up with the rest of the elements, 1 will be added \n end #to go the next element to be compared with the rest\n \n return repeat_count #once it's done, the code returns the tally of repeated letters. \n\nend",
"def count_letters(string)\n i = 0\n \n length = string.length\n count = 1\n \n summary_string = \"\"\n \n while i < length\n if string[i] == string[i+1]\n count += 1\n else\n summary_string << \"#{string[i]}#{count}\"\n count = 1\n end\n i += 1\n end\n \n if summary_string.length < length\n return summary_string\n else\n return string\n end\nend",
"def duplicate_count(text)\n return 0 if text == \"\"\n arr = text.downcase.split('')\n return arr.select{|e| arr.count(e) > 1}.uniq.length\nend",
"def frequent_letters(string)\n hash = Hash.new(0)\n string.each_char do |char|\n hash[char] += 1\n end\n\n hash.keys.select { |k| hash[k] > 2 }\nend",
"def duplicate_count(text)\n # create an array with properly formatted elements\n letters = text.downcase.split('')\n\n # make the hash deafult to 0 so that += will work correctly\n stats = Hash.new(0)\n\n # iterate over the array and count number of times each letter occur\n letters.each {|letter| stats[letter] += 1}\n\n # delete key-value pairs from the hash which occur only once\n stats.delete_if {|key, value| value == 1}\n\n # return the number of remaining key-value pairs\n return stats.values.count\nend",
"def repetitionEncryption(letter)\n pattern = /(\\w+)[\\d\\W]+\\1\\b/i\n return letter.scan(pattern).size\nend",
"def duplicate_count(text)\n i = 0\n newtext = text.downcase.each_char.to_a\n store = []\n\n while i < newtext.length\n char = newtext[i]\n pos = newtext.index(newtext[i])\n my_slice = newtext[(pos + 1)..(newtext.length - 1)]\n if my_slice.include?(char)\n store.push(char)\n end\n i += 1\n end\n return store.uniq.count\nend",
"def double_letter_count(string)\n count = 0\n lastChar = ''\n string.each_char do |char|\n if char == lastChar\n count += 1\n end\n lastChar = char\n end\n return count\nend",
"def double_letter_count(string)\n count = 0\n\n string.each_char.with_index do |char, idx|\n if char == string[idx + 1]\n count += 1\n end \n end\n\n return count\nend",
"def num_repeats(string)\n\n\tletters = string.split('')\n\tfrequencies = Hash.new(0)\n\n\tletters.each do |letter|\n \tfrequencies[letter] += 1\n\tend\n\n\t#puts frequencies\n\n\ttarget_count = 0\n\tfrequencies.values.select do |value|\n\t\tif value > 1\n\t\t\ttarget_count += 1\n\t\tend\n\tend\n\t\n\tputs target_count\n\treturn target_count\nend",
"def num_repeats(string)\n\n\ti = 0\n\tcount = 0\n\tcounted = []\n\t\n\twhile i < string.length - 1\n\t\tj = i + 1\n\t\twhile j < string.length\n\t\t\tif string[i] == string[j]\n\t\t\t\tk = 0\n\t\t\t\tis_counted = false\n\t\t\t\twhile k < counted.size\n\t\t\t\t\tif counted[k] == string[j]\n\t\t\t\t\t\tis_counted = true\n\t\t\t\t\tend\n\t\t\t\t\tk += 1\n\t\t\t\tend\n\n\t\t\t\tbreak if is_counted\n\t\t\t\t\n\t\t\t\tif !is_counted\n\t\t\t\t\tcount += 1\n\t\t\t\t\tcounted.push(string[i])\n\t\t\t\tend\n\t\t\tend\n\t\t\tj += 1\n\t\tend\n\n\t\ti += 1\n\tend\n\treturn count\nend",
"def repeating_letters?(str)\n # your code goes here\n str.each_char do |ch|\n if str.downcase.count(ch) > 1\n return true\n end\n end\n false\nend",
"def duplicate_count(text)\n arr = text.downcase.split(\"\")\n arr.uniq.count { |n| arr.count(n) > 1 }\nend",
"def unique_letters(str)\n # store a key/value pair of each letter in a word where\n # key = letter and value = nil or 0 or 1\n letter_count = {}\n has_unique_letters = true\n\n # iterate through each letter of a word\n str.chars.each do |letter|\n # check if the count of the letter has already been incremented\n # if no, add 1\n # if yes, return false\n if letter_count[letter].nil? || (letter_count[letter]).zero?\n letter_count[letter] = 1\n else\n has_unique_letters = false\n end\n end\n\n # return status of a\n has_unique_letters\n end",
"def frequent_letters(string)\n count_letters = Hash.new{0}\n frequent_letter = []\n string.each_char do |char|\n count_letters[char] += 1\n if count_letters[char] > 2 && frequent_letter.include?(char) == false\n frequent_letter << char\n end\n end\n return frequent_letter.reverse\nend",
"def frequent_letters(string)\n frequent = []\n letters_count = Hash.new(0)\n\n string.each_char { | char | letters_count[char] += 1 }\n letters_count.each do | k, v |\n if v > 2\n frequent << k\n end\n end\n\n return frequent\nend",
"def non_unique_letters(string)\n count_hash = Hash.new(0)\n string.chars.each do |letter|\n count_hash[letter] += 1 unless letter == \" \"\n end\n count_hash.select { |_letter, counts| counts > 1 }.keys.sort\nend",
"def repeating_letters?(str)\n # your code goes here\n str.downcase.chars.uniq.length != str.downcase.chars.length\nend",
"def matching_characters(str)\n matching_letters = Hash.new([])\n unique_chars_count = 0\n str.each_char.with_index do |letter, idx|\n matching_letters[letter] += [idx] if str.count(letter) > 1\n end\n matching_letters.each do |letter, indices|\n current_count = str[indices.first + 1...indices.last].chars.uniq.size\n unique_chars_count = current_count if current_count > unique_chars_count\n end\n unique_chars_count\nend",
"def solution(s)\n return 0 if s.empty?\n t = 0\n ('A'..'Z').to_a.each do |c|\n t += s.count(c)\n end\n t + 1\nend",
"def more_than_once(string)\n string.chars.find_all {|letter| string.count(letter) > 2}.uniq\nend",
"def repeating_letters?(str)\n # your code goes here\n str.downcase.chars.uniq.length != str.downcase.chars.length\n\n end",
"def duplicate_count(text)\n my_hash = {}\n result = 0\n text = text.downcase\n text.each_char { |char| my_hash[char] = text.count(char)}\n p my_hash\n my_hash.each_value { |value| result += 1 if value > 1 }\n return result\nend",
"def frequent_letters(string)\n output = []\n count_table = Hash.new(0)\n\n string.each_char do |char|\n count_table[char] += 1\n if count_table[char] == 3\n output.push(char)\n end\n end\n\n return output\nend",
"def frequent_letters(string)\n hash = Hash.new(0)\n results = []\n\n string.each_char do |char|\n hash[char] += 1\n end\n\n hash.each do |k, v|\n if v > 2\n results << k\n end\n end\n\n return results\nend",
"def repeating_letters?(str)\n str.downcase.chars.uniq.length != str.length\nend",
"def duplicate_count(text)\n duplicates = text.downcase.scan(/[a-z0-9]/)\n d2 = Hash.new(0)\n duplicates.each { |i| d2.store(i, d2[i] + 1) }\n d2.select { |k,v| v > 1 }.count\nend",
"def frequent_letters(string)\n hash = Hash.new(0)\n string.each_char { |char| hash[char] += 1 }\n\n frequent = []\n hash.each_key do |k|\n if hash[k] > 2\n frequent << k\n end\n end\n return frequent\nend",
"def chars_counter_1(string)\n unique_chars_hash = {}\n for char in string.chars.to_a.uniq\n unique_chars_hash[char] = string.count(char)\n string.delete(char)\n end\n unique_chars_hash\nend",
"def duplicate_count(text)\n text = text.downcase\n text.chars.sort.partition { |i| text.count(i) == 1 }[1].uniq.count\nend",
"def most_repeated_letter(string)\n letter = \"\"\n count = 0\n \n length = string.length\n i = 0\n current_count = 1\n \n while i < length \n if string[i] == string[i+1]\n current_count += 1\n else\n if current_count > count\n count = current_count\n letter = string[i]\n end\n current_count = 1\n end\n \n i += 1\n end\n \n return \"#{letter}#{count}\"\nend",
"def count_letters(str)\r\n index, result, equal_temp, temp = 0, [], [], str[0]\r\n str = str.downcase\r\n\r\n while index < str.length\r\n\r\n if temp == str[index + 1]\r\n equal_temp << temp\r\n else\r\n result << equal_temp\r\n equal_temp << temp\r\n equal_temp = []\r\n end\r\n\r\n temp = str[index + 1]\r\n index += 1\r\n end\r\n\r\n result\r\nend",
"def frequent_letters(string)\n array = []\n count = Hash.new(0)\n string.each_char { |c| count[c] += 1 }\n count.each { |k, v| array << k if v > 2}\n array\nend",
"def duplicate_count(text)\n result = text.split('')\n result.group_by { |elem| elem and elem.upcase }.select { |_key, val| val.length > 1 }.keys.count\nend",
"def non_unique_letters(string)\n hash = Hash.new(0)\n str_arr = string.split('')\n str_arr.each do |word|\n if word != ' '\n hash[word] += 1\n end\n end\n\n repeat_hash = hash.select do |k,v|\n v > 1\n end\n repeat_hash.map {|el| el[0]}\nend",
"def num_repeats(string)\n arr = string.split('')\n repeats = []\n arr.each_index { | i |\n if (string.index(arr[i]) < i) && !(repeats.include?(arr[i]))\n repeats << arr[i]\n end\n }\n \n repeats.count\n \nend",
"def num_repeats(string)\n count = []\n \n i = 0\n while i < string.length\n j = i + 1\n count [i] = 1\n while j < string.length\n if string[i] == string[j]\n count[i] = count[i] + 1\n h = j\n while h < string.length - 1\n string[h] = string[h+1]\n h = h + 1\n #puts(string) for testing earlier\n end\n string[string.length-1] = \"\"\n else\n j = j + 1\n end\n end\n if( string[i+1]!= '')\n i = i + 1 \n end\n end\n\n numRepeats = 0\n i = 0\n while i < count.length\n if count[i] > 1\n numRepeats += 1\n end \n i = i + 1 \n end\n \n return numRepeats\nend",
"def frequent_letters(str)\n letter_count = Hash.new(0)\n str.each_char { |char| letter_count[char] += 1 }\n\n frequent_chars = []\n letter_count.each do |char, num|\n if num > 2\n frequent_chars << char\n end\n end\n return frequent_chars\nend",
"def repeatedString(s, n)\n char_array = s.split('')\n count_of_a_in_string = 0\n char_array.each do |letter|\n if letter == \"a\"\n count_of_a_in_string += 1\n end\n end\n\n factor = n/s.length()\n reminder = n % s.length()\n count_of_a_in_final_string = factor * count_of_a_in_string\n\n reminder.times do |index|\n count_of_a_in_final_string += 1 unless s[index] != \"a\"\n end\n count_of_a_in_final_string\nend",
"def double_letter_count(string)\n count = 0\n string.split.each { |word| count += count(word) }\n count\nend",
"def first_non_repeating_letter(s) \n counts = Hash.new(0)\n s.split(\"\").reduce(counts) { |k, v| k[v] += 1; k}\n p counts\n counts.key(1).nil? ? \"\" : counts.key(1)\nend",
"def LetterCount(str)\n\n \n words = str.split(\" \")\n most = \"\"\n count = 0\n \n words.each do |word|\n hash = Hash.new(0)\n word.split(\"\").each {|letter| hash[letter] += 1} #must split word\n repeats = hash.select {|letter, count| count >= 2}.size\n if repeats > count\n count = repeats\n most = word\n end\n \n end\n \n return most\n \nend",
"def letterCountI(str)\n\t# count = 0\n\t# mostRepeatedLetters = ''\n\t# str = str.split('').each{|letter| \n\t# \tif(str.count(letter) > count)\n\t# \t\tcount = str.count(letter)\n\t# \t\tmostRepeatedLetters = str\n\t# \tend\n\t# }\n\t# return mostRepeatedLetters\n\n\tletterCount = 0\n\tletterMaxWord = ''\n\tstr = str.split(' ').each{|word| word.split('').each{|letter| \n\t\tif(word.downcase.count(letter) > letterCount)\n\t\t\tletterCount = word.downcase.count(letter)\n\t\t\tletterMaxWord = word\n\t\tend\n\t\t}}\n\tletterCount > 1 ? (return letterMaxWord) : (return -1)\n\t\nend",
"def frequent_letters(string)\n count = Hash.new(0)\n string.each_char { |char| count[char] += 1 }\n\n frequents = []\n count.each do |char, num|\n if num > 2\n frequents << char\n end\n end\n return frequents\nend",
"def how_many_times_is_repeated(str)\n #create hash to store key and value\n h={}\n #split up the string into individual characters and put it in an array\n arr = str.split(\"\")\n #for each character in the array, if it does not have a previous occurence in the 'h' hash, add it to the hash with a value of '1'\n arr.each do |n|\n if h.has_key?(n) == false\n h[n]=1\n #if it does have a previous occurence in the 'h' hash, add '1' to the previously occuring value of that key\n elsif h.has_key?(n) == true\n h[n]= h[n] +1\n end\n #return the completed hash\n end\n return h\nend",
"def get_char_count(string)\n string = string.downcase\n string.gsub!(/[^a-z0-9]/, '')\n chars = string.chars\n uniq_chars = chars.uniq\n final = Hash.new([])\n chars.count(chars[0])\n uniq_chars.each { |char| final[chars.count(char)] += [char] }\n final\nend",
"def LetterCountI(str)\n\n arr=str.split\n arr.each{|word|\n word.each_char{|char|\n return word if word.count(char)>1\n }\n \n }\n -1\nend",
"def letter_count(string)\n\tfrequency = Hash.new(0)\n\tstring.each_char do |i|\n\t\tfrequency[i] += 1 unless i == \" \"\n\tend\n\tfrequency\nend",
"def count_char(counts, string)\n (0...string.length).each do |i|\n if counts[string[i]]\n counts[string[i]] += 1\n else\n counts[string[i]] = 1\n end\n end\nend",
"def non_unique_letters(string)\n alpha = ('a'..'z').to_a\n our_new_letters = []\n counters = Hash.new(0)\n arr = string.downcase.split(\"\").select {|letter| string.count(letter) > 1}\n arr.each do |c|\n counters[c] += 1\n our_new_letters << c if counters[c] <= 1\n end\n our_new_letters.select {|x| alpha.include?(x)}\nend",
"def duos(str)\n count = 0\n str.each_char.with_index do |char, idx|\n count += 1 if char == str[idx+1]\n end\n count\nend",
"def letter_count(str)\nletters = Hash.new(0)\n\tstr.each_char do |letter| letters[letter] += 1 end\n\t\treturn letters\nend",
"def get_letter_count(string)\n letter_count = []\n \n i = 0\n while i < string.length\n letter = string[i]\n #check if letter has already been counted. If it has, add 1 to the count.\n #If it hasn't, add an entry for it\n j = 0\n letter_counted = false\n while j < letter_count.length\n if letter_count[j][0] == letter\n letter_count[j][1] += 1\n letter_counted = true\n break\n end\n j += 1\n end\n if !letter_counted\n letter_count.push([letter, 1])\n end\n \n i += 1\n end\n return letter_count\nend",
"def letter_freq(string)\n length = string.length\n i = 0\n \n max_letter = \"\"\n max_count = 0\n \n count = 1\n \n while i < length\n if string[i] == string[i+1]\n count += 1\n else\n if count > max_count\n max_count = count\n max_letter = string[i]\n end\n count = 1\n end\n i += 1\n end\n \n return \"#{max_letter}#{max_count}\"\nend",
"def custom_count(string, search_characters)\r\n i = 0\r\n checked = \"\"\r\n #for every character that must be searched, name the character \"fetcher\"\r\n search_characters.each_char do |fetcher|\r\n #if checked list contains the letter we want,\r\n #then we already looked for it,\r\n #so jump to the next iteration (aka, duplicates shall not pass!)\r\n if checked.include?(fetcher)\r\n next\r\n end\r\n #for each character in the string we're counting,\r\n #add 1 to the counter if the \"char\" is what we want\r\n string.each_char { |char| i += 1 if char == fetcher}\r\n checked << fetcher\r\n end\r\n i\r\n\r\nend",
"def count_string(string, characters)\n i = 0\n size = characters.length\n hits = 0\n while i < string.length - size + 1\n if string[i,size] == characters\n hits += 1\n end\n i += 1\n end\n return hits\nend",
"def character_count(str)\n letters = Hash.new(0)\n str.downcase.each_char {|char| letters[char] += 1}\n letters\nend",
"def uniq_chars(str)\n # O(n) with hashmap\n tally = Hash.new(0)\n str.each_char { |chr| tally[chr] += 1 }\n tally.none? { |_, v| v > 1 }\nend",
"def custom_count(string, search_characters)\n total_chars = 0\n #\n search_characters.each_char do |sc|\n # split the string and review letter & sc\n letters = string.each_char { |letter| letter == sc ? total_chars += 1 : next }\n\n end # end of do (search chars)\n\n total_chars\nend",
"def count_as(string)\n string_array = string.split(\"\")\n count = 0\n\n string_array.each do |letter|\n if letter == \"a\"\n count += 1\n end\n end\n\n count\nend",
"def letter_count(str)\n\tr = Hash.new\nstr.delete(' ').split('').each {|letter| r[letter] == nil ? r[letter] = 1 : r[letter] += 1}\nr\nend",
"def char_count(string)\n\tchar_count = Hash.new\n\t\"abcdefghijklmnopqrstuvwxyz\".chars.each {|char| char_count[char] = 0}\n\tstring.chars.each {|char| char_count[char] += 1}\n\tchar_count\nend",
"def step_through_with(s)i\n # It doesn't solve the kata because it returns true even if same chars are met in diffrent part of the word. Like \"ThaT\"\n s.chars.count == s.chars.uniq.count\nend",
"def repeatedString(s, n)\n count = s.count(\"a\")\n rep = (n / s.length)\n if n % s.length != 0\n short_s = s.slice(0, n % s.length)\n return (count * rep) + short_s.count(\"a\")\n else\n return (count * rep)\n end\n \nend",
"def repeatedString(s, n)\r\n # Write your code here\r\n numOfA = 0\r\n index = 0\r\n \r\n if s.length == 1 && s[0] == 'a'\r\n return n\r\n elsif s.length == 1 && s[0] != 'a'\r\n return 0\r\n \r\n else\r\n firstRoundUpperLimit = n < s.length ? n : s.length\r\n \r\n for i in 0 ... firstRoundUpperLimit\r\n if s[i] === 'a'\r\n numOfA = numOfA + 1\r\n end\r\n end\r\n\r\n if (numOfA > 0 && n > s.length) \r\n repeatingOccurrences = (n / s.length) - 1\r\n remainingOccurrences = n % s.length\r\n\r\n\r\n\r\n numOfA = numOfA + (numOfA * repeatingOccurrences)\r\n\r\n for j in 0 ... remainingOccurrences\r\n if s[j] === 'a'\r\n numOfA = numOfA + 1\r\n end\r\n end\r\n end\r\n\r\n \r\n end\r\n return numOfA\r\nend",
"def LetterCountI(str)\n g_word, g_count = '', 0\n str.split.each do |word|\n word.chars.each do |char|\n if word.downcase.count(char) > g_count\n g_count = word.downcase.count(char)\n g_word = word\n end\n end\n end\n\n g_count <= 1 ? -1 : g_word\nend"
] |
[
"0.84525627",
"0.84508854",
"0.8428997",
"0.840122",
"0.8345946",
"0.83324635",
"0.8319042",
"0.8304465",
"0.825565",
"0.82428324",
"0.8176287",
"0.81723094",
"0.8164172",
"0.8147924",
"0.81423587",
"0.81220293",
"0.81118584",
"0.8094156",
"0.8070209",
"0.80575156",
"0.80505437",
"0.80271935",
"0.8024803",
"0.79809505",
"0.7979488",
"0.79691863",
"0.79458916",
"0.7937081",
"0.79300296",
"0.7910158",
"0.7896118",
"0.78956693",
"0.7895052",
"0.78847086",
"0.7867898",
"0.7854934",
"0.78241885",
"0.78205705",
"0.7814151",
"0.7777824",
"0.7775636",
"0.7751442",
"0.77347815",
"0.7728612",
"0.76945186",
"0.76726216",
"0.7660254",
"0.7657461",
"0.76467985",
"0.76465386",
"0.76030314",
"0.76026124",
"0.76007354",
"0.7585983",
"0.75806475",
"0.7573256",
"0.7548209",
"0.7533397",
"0.7531651",
"0.75284886",
"0.75169283",
"0.75044733",
"0.7499949",
"0.7497966",
"0.7485352",
"0.74837404",
"0.7463183",
"0.74600154",
"0.74577296",
"0.74557674",
"0.744799",
"0.744466",
"0.744352",
"0.7438355",
"0.74285465",
"0.74234354",
"0.7422479",
"0.74221396",
"0.74000525",
"0.7396052",
"0.7377514",
"0.7352346",
"0.7347995",
"0.7344805",
"0.7325592",
"0.7319035",
"0.73093534",
"0.7308766",
"0.7306803",
"0.73060703",
"0.72984284",
"0.7285356",
"0.7276744",
"0.7275668",
"0.7256412",
"0.7241328",
"0.7216014",
"0.7204712",
"0.7173417",
"0.71533835"
] |
0.7980196
|
24
|
UNIT TESTS FOR METHOD connect_angels_with_other(cities)
|
def test_angel_camp_connections
map = Map.new
# checking if Angel camp on index @cities[1]
# is connected with......
#
# First: with Nevada, it should be on index 0 of array connections
# checking Angel camp is connected with Nevada
# checking by name
assert_equal 'Nevada City', map.cities[1].connections[0].name
#
# checking by ID
assert_equal 0, map.cities[1].connections[0].id
#
# Second:
# Checking Angel camp is connected with Sutter Creek
assert_equal 'Sutter Creek', map.cities[1].connections[1].name
# checking by id
assert_equal 2, map.cities[1].connections[1].id
#
# Third:
# checking Angel camp is connected with Virgina City
# checking by name
assert_equal 'Virginia City', map.cities[1].connections[2].name
# checking by id
assert_equal 3, map.cities[1].connections[2].id
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def test_validate_cities\n skip('this is a helper method for validating location names')\n # ignored cities are ones for which I don't know the location code\n # that the API accepts\n ignored_cities = %w(chongqing koln cologne dusseldorf eugene honolulu\n milan southbay)\n cities = %w(amsterdam austin berlin calgary columbus denver firenze\n frankfurt hamburg miami montreal muenchen\n newyorkcity portland rheinland roma sandiego seattle stockholm\n stuttgart torino toronto twincities vancouver washingtondc\n wien)\n\n cities.each do |city|\n @caruby2go = Caruby2go.new(ENV['CONSUMER_KEY'], city)\n puts \"#{city}\"\n payload = @caruby2go.gasstations\n puts \"#{city}:\\n#{payload}\"\n end\n puts \"Done with valid cities (#{cities.size})\"\n puts 'Did not look for the following cities as they have previously failed validation:'\n ignored_cities.each do |city|\n puts city\n end\n end",
"def test_all_locations\r\n\t\toakland = City::new\r\n\t\tfour_locations = [\"Museum\", \"Cathedral\", \"Hospital\", \"Hillman\"]\r\n\t\tassert_includes four_locations, oakland.all_locations[0], oakland.all_locations[1]\r\n\t\tassert_includes four_locations, oakland.all_locations[2], oakland.all_locations[3]\r\n\tend",
"def test_connect_sutter\n map = Map.new\n # testing connect with Coloma\n assert_equal 4, map.cities[2].connections[1].id\n # testing connect angel camp\n assert_equal 1, map.cities[2].connections[0].id\n end",
"def test_fun_city_locs\n\t@city = GoldRush::new\n\tassert_equal \"El Dorado Canyon\", @city.dorado.location\n\tassert_equal \"Midas\", @city.midas.location\n\tassert_equal \"Virginia City\", @city.virginia.location\n\tassert_equal \"Nevada City\", @city.nevada.location\n\tassert_equal \"Coloma\", @city.coloma.location\n\tassert_equal \"Angels Camp\", @city.angels.location\n\tassert_equal \"Sutter Creek\", @city.sutter.location\n end",
"def test_link_neighbors_valid\n\t prng = Minitest::Mock.new\n\t def prng.rand(num); 1; end\n\t\tcity = City.new(\"Fake City\", 7, 0, prng)\n\t\tcity1 = City.new(\"Fake City 1\", 7, 0, prng)\n\t\tcity2 = City.new(\"Fake City 2\", 7, 0, prng)\n\t\tArray cities = [city1, city2]\n\t\tcity.link_neighbors cities\n\t\tassert_equal cities, city.cities\n\tend",
"def cities opt, graph\n\n\tp opt, graph\n\t#first try all cities spread over USA, should be easy to figure out if the correct tour was picked\n\tcities = 'd,DC,77.01,38.90;l,Los_Angeles,118.25,34.05;c,Chicago,87.68,41.83;m,Memphis,89.97,35.11;h,Houston,95.36,29.76;\n\t\t\t\t L,Las_Vegas,115.17,36.12;k,Kansas_city,94.57,39.09;M,Miami,80.20,25.77;s,San_Fran,122.41,37.78;a,Dallas,96.79,32.77;\n\t\t\t \t n,Nashville,86.78,36.16;e,Detroit,83.04,42.33;p,Phoneix,112.06,33.45;D,Denver,104.99,39.73'\n\n\tloop_over cities: cities, pool_size: 30, graph: graph, vmirror: true, hmirror: true if opt == '1'\n\n\t#Now add sort of a loop in California\n\tcities += ';S,Sacramento,121.46,38.55;f,Fresno,119.76,36.75;A,San_jose,121.88,37.33;C,Carson_city,119.75,39.16'\n\tloop_over cities: cities, pool_size: 30, graph: graph, vmirror: true, hmirror: true if opt == '2'\n\n\t#Now try with randomly generated cities\n\tif opt == '3' or opt.nil?\n\t\tcities = nil\n\t\tloop_over cities: cities, pool_size: 30, graph: graph\n\tend\n\nend",
"def test_get_another_id_for_angel\n # testing nevada has 4 connections [0--3]\n seed = 10\n prng = Random.new seed\n id = 1\n pros = Prospector.new id, prng\n map = Map.new\n pros.current_city = map.cities[1]\n\n 200.times do\n actual = pros.get_another_id prng, pros.current_city.connections.length\n assert_operator 2, :>=, actual\n assert_operator 0, :<=, actual\n end\n end",
"def fetch_trips(origin_city)\r\n return if origin_city.nil?\r\n\r\n airport_type = AIRPORT_TYPE_MEDIUM_KEY\r\n\r\n case\r\n when origin_city.downcase == 'helsinki'\r\n # Helsinki-Vantaa on ainoa poikkeus!\r\n airport_type = AIRPORT_TYPE_LARGE_KEY\r\n end\r\n\r\n # Suomesta tapahtuvien lähtöjen lentokentät ovat pääsääntöisesti medium-luokkaa.\r\n journey_airports = AIRPORTS.find({MUNICIPALITY_KEY => origin_city.capitalize, AIRPORT_TYPE_KEY => airport_type})\r\n unless journey_airports.nil?\r\n journey_airports.each do |airport|\r\n\r\n fetch_origin_country(airport)\r\n\r\n @trips = TRIPS.find({AIRPORT_ORIGIN_CITY => airport[MUNICIPALITY_KEY]})\r\n end\r\n end\r\n\r\n #@wikipedia_link = COUNTRIES.find(\r\n\r\nend",
"def test_location_other_connect\n @loc1.add_neighbor @loc2\n assert @loc2.connected? @loc1\n end",
"def seed_locations\n\t\t\tOrganization.find_each do |organization|\n\t\t\t\tadd_two_locations(organization)\n\t\t\tend\n\t\tend",
"def test_random_neighbor_many_connections\n neighbor_list = [@loc2, @loc3, @loc4]\n\n @loc1.add_neighbor @loc2\n @loc1.add_neighbor @loc3\n @loc1.add_neighbor @loc4\n\n assert_includes neighbor_list, @loc1.random_neighbor\n end",
"def test_possible_location_from_cathedral_if_rand_is_one\r\n\t\toakland = City::new\r\n\t\trand_val = 1\r\n\t\tmuseum = oakland.generate_cathedral_locs(oakland, rand_val)\r\n\r\n\t\tassert_equal museum[0], \"Museum\"\r\n\t\tassert_equal museum[1][0], \"Bar St.\"\r\n\tend",
"def test_street_used_to_go_to_monroeville\r\n\t\toakland = City::new\r\n\t\tfourth = Minitest::Mock::new\r\n\t\tdef fourth.street; \"Fourth Ave.\"; end\r\n\t\tassert_includes oakland.generate_cathedral_locs(oakland, 0)[1][0], fourth.street\r\n\tend",
"def test_get_all_cities\n \n test_map = ' { \"metros\" : [ {\n \"code\" : \"LON\" ,\n \"name\" : \"London\",\n \"country\" : \"X\" ,\n \"continent\" : \"X\" ,\n \"timezone\" : 1 ,\n \"coordinates\" : {\"N\" : 1, \"E\" : 1} ,\n \"population\" : 1,\n \"region\" : 1\n } , {\n \"code\" : \"PAR\" ,\n \"name\" : \"Paris\" ,\n \"country\" : \"X\" ,\n \"continent\" : \"X\" ,\n \"timezone\" : 1 ,\n \"coordinates\" : {\"N\" : 1, \"E\" : 1} ,\n \"population\" : 1,\n \"region\" : 1\n } , {\n \"code\" : \"LIM\" ,\n \"name\" : \"Lima\" ,\n \"country\" : \"X\" ,\n \"continent\" : \"X\" ,\n \"timezone\" : 1 ,\n \"coordinates\" : {\"N\" : 1, \"E\" : 1} ,\n \"population\" : 1,\n \"region\" : 1 \n } , {\n \"code\" : \"MOW\" ,\n \"name\" : \"Moscow\" ,\n \"country\" : \"X\" ,\n \"continent\" : \"X\" ,\n \"timezone\" : 1 ,\n \"coordinates\" : {\"N\" : 1, \"E\" : 1} ,\n \"population\" : 1,\n \"region\" : 1\n } ] ,\n \"routes\" : [ {\n \"ports\" : [\"LON\" , \"PAR\"] ,\n \"distance\" : 2410\n } , {\n \"ports\" : [\"LON\" , \"MOW\"] ,\n \"distance\" : 4323\n } , {\n \"ports\" : [\"LIM\" , \"PAR\"] ,\n \"distance\" : 4323\n } ] } '\n graph = Graph.new()\n graph.parse_json_string(test_map)\n \n result = graph.get_all_cities()\n \n assert_equal( result.scan(/[A-Z]*, [A-Z]{3}/).size, 4)\n assert_equal( result.include?(\"London, LON\"), true )\n assert_equal( result.include?(\"Moscow, MOW\"), true )\n assert_equal( result.include?(\"Lima, LIM\"), true )\n assert_equal( result.include?(\"Paris, PAR\"), true )\n \n end",
"def test_location_2\r\n\t\tdriver = Driver::new(\"Driver\")\r\n\t\t\r\n\t\thillman = Location.new(\"Hillman\", \"Foo St.\", \"Fifth Ave.\")\r\n\t\thospital = Location.new(\"Hospital\", \"Foo St.\", \"Fourth Ave.\")\r\n\t\tmuseum = Location.new(\"Museum\", \"Bar St.\", \"Fifth Ave.\")\r\n\t\tcathedral = Location.new(\"Cathedral\", \"Bar St.\", \"Fourth Ave.\")\r\n\t\t\r\n\t\tlocations = [hillman, hospital, cathedral, museum]\r\n\t\t\r\n\t\trandom_start_location(driver, 2, locations)\r\n\t\tassert_equal cathedral, driver.location\r\n\tend",
"def test_other_start_location_false\r\n\t\tmock_driver = Minitest::Mock::new\r\n\t\tdef mock_driver.get_start_location; 3; end\r\n\t\toakland = City::new\r\n\t\tstart_loc = oakland.all_locations[mock_driver.get_start_location]\r\n\t\trefute_includes start_loc, oakland.downtown[0]\r\n\t\trefute_includes start_loc, oakland.monro[0]\r\n\tend",
"def crossover(city_names2)\n # Copy 2 cities at a time thereby preserving the edge between them\n city_names_new = []\n max_index = city_names.size - 1\n index = 0\n while index <= max_index - 1\n parent = (rand > 0.5 ? @city_names : city_names2)\n city_names_new << parent[index] << parent[index + 1]\n index += 1\n end\n \n # Remove dup cities\n city_names_new.uniq!\n \n # Make a list of missing cities\n missing_cities = []\n city_names.each do |city| \n missing_cities << city unless city_names_new.include?(city)\n end\n \n city_names_new.concat(missing_cities)\n @city_names = city_names_new\n @type = \"Hybrid\"\n end",
"def test_possible_location_from_museum_if_rand_is_one\r\n\t\toakland = City::new\r\n\t\trand_val = 1\r\n\t\thillman = oakland.generate_museum_locs(oakland, rand_val)\r\n\r\n\t\tassert_equal hillman[0], \"Hillman\"\r\n\t\tassert_equal hillman[1][0], \"Fifth Ave.\"\r\n\tend",
"def cities_helper\n [\n ['基隆市', '基隆市'],\n ['台北市', '台北市'],\n ['新北市', '新北市'],\n ['桃園縣', '桃園縣'],\n ['新竹市', '新竹市'],\n ['新竹縣', '新竹縣'],\n ['苗栗縣', '苗栗縣'],\n ['台中市', '台中市'],\n ['彰化縣', '彰化縣'],\n ['南投縣', '南投縣'],\n ['雲林縣', '雲林縣'],\n ['嘉義市', '嘉義市'],\n ['嘉義縣', '嘉義縣'],\n ['台南市', '台南市'],\n ['高雄市', '高雄市'],\n ['屏東縣', '屏東縣'],\n ['台東縣', '台東縣'],\n ['花蓮縣', '花蓮縣'],\n ['宜蘭縣', '宜蘭縣'],\n ['澎湖縣', '澎湖縣'],\n ['金門縣', '金門縣'],\n ['連江縣', '連江縣']\n ]\n end",
"def roads_and_libraries(n, c_lib, c_road, cities)\n \nend",
"def test_location_3\r\n\t\tdriver = Driver::new(\"Driver\")\r\n\t\t\r\n\t\thillman = Location.new(\"Hillman\", \"Foo St.\", \"Fifth Ave.\")\r\n\t\thospital = Location.new(\"Hospital\", \"Foo St.\", \"Fourth Ave.\")\r\n\t\tmuseum = Location.new(\"Museum\", \"Bar St.\", \"Fifth Ave.\")\r\n\t\tcathedral = Location.new(\"Cathedral\", \"Bar St.\", \"Fourth Ave.\")\r\n\t\t\r\n\t\tlocations = [hillman, hospital, cathedral, museum]\r\n\t\t\r\n\t\trandom_start_location(driver, 3, locations)\r\n\t\tassert_equal museum, driver.location\r\n\tend",
"def get_list_cities\n City.get_all_cities\n end",
"def test_get_another_id_for_coloma\n seed = 10\n prng = Random.new seed\n id = 1\n pros = Prospector.new id, prng\n map = Map.new\n pros.current_city = map.cities[4]\n\n 200.times do\n actual = pros.get_another_id prng, pros.current_city.connections.length\n assert_operator 1, :>=, actual\n assert_operator 0, :<=, actual\n end\n end",
"def set_states_cities data\n states_hash = Hash.new { |h,k| h[k] = [] }\n cities_hash = Hash.new { |h,k| h[k] = [] }\n data.each do |row|\n if !states_hash[row[\"country_name\"]].include?(row[\"province_name\"])\n states_hash[row[\"country_name\"]] << row[\"province_name\"]\n end\n if !cities_hash[row[\"province_name\"]].include?(row[\"city_name\"])\n cities_hash[row[\"province_name\"]] << row[\"city_name\"]\n end\n end\n @@all_cities = cities_hash\n @@all_states = states_hash\n build_result(@distributor_name, @include_regions, @exclude_regions)\n end",
"def test_cathedral_start_location\r\n\t\trand_val = Minitest::Mock::new\r\n\t\toakland = City::new\r\n\t\tdef rand_val.get_start_location; 2; end\r\n\t\tstart_loc = oakland.all_locations[rand_val.get_start_location]\r\n\t\tassert_equal start_loc, \"Hillman\"\r\n\tend",
"def basic_test_data\n sf = FactoryGirl.create(:city, name: \"San Francisco\")\n ch = FactoryGirl.create(:city, name: \"Chicago\")\n FactoryGirl.create(:business_type)\n\n # Admin user\n FactoryGirl.create(:user, admin: true, city_id: sf.id)\n\n # Need some businesses in each city\n 3.times do\n FactoryGirl.create(:business, city: sf.name, state: \"CA\")\n FactoryGirl.create(:business, city: ch.name, state: \"IL\")\n end\n\n %w(a b c d e f g h i j k).each do |tag|\n FactoryGirl.create(:tag, name: tag)\n end\n end",
"def test_map\n node = create(:node, :lat => 7, :lon => 7)\n tag = create(:node_tag, :node => node)\n way1 = create(:way_node, :node => node).way\n way2 = create(:way_node, :node => node).way\n relation = create(:relation_member, :member => node).relation\n\n # Need to split the min/max lat/lon out into their own variables here\n # so that we can test they are returned later.\n minlon = node.lon - 0.1\n minlat = node.lat - 0.1\n maxlon = node.lon + 0.1\n maxlat = node.lat + 0.1\n bbox = \"#{minlon},#{minlat},#{maxlon},#{maxlat}\"\n get :map, :params => { :bbox => bbox }\n if $VERBOSE\n print @request.to_yaml\n print @response.body\n end\n assert_response :success, \"Expected scucess with the map call\"\n assert_select \"osm[version='#{API_VERSION}'][generator='#{GENERATOR}']\", :count => 1 do\n assert_select \"bounds[minlon='#{format('%.7f', minlon)}'][minlat='#{format('%.7f', minlat)}'][maxlon='#{format('%.7f', maxlon)}'][maxlat='#{format('%.7f', maxlat)}']\", :count => 1\n assert_select \"node[id='#{node.id}'][lat='#{format('%.7f', node.lat)}'][lon='#{format('%.7f', node.lon)}'][version='#{node.version}'][changeset='#{node.changeset_id}'][visible='#{node.visible}'][timestamp='#{node.timestamp.xmlschema}']\", :count => 1 do\n # This should really be more generic\n assert_select \"tag[k='#{tag.k}'][v='#{tag.v}']\"\n end\n assert_select \"way\", :count => 2\n assert_select \"way[id='#{way1.id}']\", :count => 1\n assert_select \"way[id='#{way2.id}']\", :count => 1\n assert_select \"relation\", :count => 1\n assert_select \"relation[id='#{relation.id}']\", :count => 1\n end\n end",
"def test_location_connections_length\n @loc1.add_neighbor @loc2\n @loc1.add_neighbor @loc3\n @loc1.add_neighbor @loc4\n\n assert_equal 3, @loc1.neighbors.length\n end",
"def add_city_to_linked(linked_cities, code, distance)\n linked_cities.each{ |tuple|\n if(tuple.city == code)\n puts \"This route already exists.\"\n return false\n end\n }\n tuple = OpenStruct.new\n tuple.distance = distance\n tuple.city = code\n linked_cities << tuple\n return true\n end",
"def test_enumerable_canyon_neighbors\n loc = Locations.new\n assert_equal ({ 'neighbors' =>\n ['Duck Type Beach', 'Monkey Patch City'],\n 'maxRubes' => 1,\n 'maxFakes' => 1 }), loc.enumerable_canyon\n end",
"def test_create_all_locations\n\t\ttest_main = Main.new(3, 4, 6)\n\t\ttest_graph = Graph.new(10)\n\t\ttest_main.create_all_locations(test_graph)\n\t\tassert_equal test_main.num_locations(test_graph), 7\n\tend",
"def test_location_1\r\n\t\tdriver = Driver::new(\"Driver\")\r\n\t\t\r\n\t\thillman = Location.new(\"Hillman\", \"Foo St.\", \"Fifth Ave.\")\r\n\t\thospital = Location.new(\"Hospital\", \"Foo St.\", \"Fourth Ave.\")\r\n\t\tmuseum = Location.new(\"Museum\", \"Bar St.\", \"Fifth Ave.\")\r\n\t\tcathedral = Location.new(\"Cathedral\", \"Bar St.\", \"Fourth Ave.\")\r\n\t\t\r\n\t\tlocations = [hillman, hospital, cathedral, museum]\r\n\t\t\r\n\t\trandom_start_location(driver, 1, locations)\r\n\t\tassert_equal hospital, driver.location\r\n\tend",
"def test_all\n coords = all_combos\n coords.each do |c|\n find_route(c[0], c[1])\n end\nend",
"def test_location_is_connected\n @loc1.add_neighbor @loc2\n assert @loc1.connected? @loc2\n end",
"def test_next_valid\n\t prng = Minitest::Mock.new\n\t def prng.rand(num); 1; end\n\t\tcity = City.new(\"Fake City\", 7, 0, prng)\n\t\tcity1 = City.new(\"Fake City 1\", 7, 0, prng)\n\t\tcity2 = City.new(\"Fake City 2\", 7, 0, prng)\n\t\tcity.link_neighbors [city1, city2]\n\t\tcity = city.next\n\t\tassert_includes [city1, city2], city\n\tend",
"def test_random_neighbor_one_connection\n @loc1.add_neighbor @loc2\n assert_equal @loc2, @loc1.random_neighbor\n end",
"def test_sitemap_geos_and_queries\n geos = ['ca', 'co', 'il', 'ny']\n\n geos.each do |loc|\n # Step 1\n params = {\n 'g' => loc,\n 'h_geos' => 0,\n 'h_queries' => 0\n }\n\n get '/site_map/geos_and_queries', params\n assert_response(@response, :success)\n assert_equal(0, @parsed_response['Geos']['NumFound'], @parsed_response)\n assert_equal(0, @parsed_response['Queries']['NumFound'], @parsed_response)\n\n # Step 2\n params = {\n 'g' => loc,\n 'h_geos' => 10,\n 'h_queries' => 30\n }\n\n get '/site_map/geos_and_queries', params\n assert_response(@response, :success)\n assert_equal(10, @parsed_response['Geos']['NumFound'], @parsed_response)\n assert_equal(30, @parsed_response['Queries']['NumFound'], @parsed_response)\n\n # Step 3\n params = {\n 'g' => loc,\n 'h_geos' => 50,\n 'h_queries' => 100\n }\n\n get '/site_map/geos_and_queries', params\n assert_response(@response, :success)\n assert_equal(50, @parsed_response['Geos']['NumFound'], @parsed_response)\n assert_equal(100, @parsed_response['Queries']['NumFound'], @parsed_response)\n\n # Step 4\n params = {\n 'g' => loc\n }\n\n get '/site_map/geos_and_queries', params\n assert_response(@response, :success)\n assert_equal(50, @parsed_response['Geos']['NumFound'], @parsed_response)\n assert_equal(50, @parsed_response['Queries']['NumFound'], @parsed_response)\n\n # Step 5\n params = {\n 'g' => loc,\n 'h_geos' => 100,\n 'h_queries' => 1000\n }\n\n get '/site_map/geos_and_queries', params\n assert_response(@response, :success)\n assert_equal(50, @parsed_response['Geos']['NumFound'], @parsed_response)\n assert_equal(100, @parsed_response['Queries']['NumFound'], @parsed_response)\n end\n end",
"def test_possible_location_from_museum_if_rand_is_zero\r\n\t\toakland = City::new\r\n\t\trand_val = 0\r\n\t\tcathedral = oakland.generate_museum_locs(oakland, rand_val)\r\n\r\n\t\tassert_equal cathedral[0], \"Cathedral\"\r\n\t\tassert_equal cathedral[1][0], \"Bar St.\"\r\n\tend",
"def test_link_neighbors_nil\n\t\tprng = Minitest::Mock.new\n\t def prng.rand(num); 1; end\n\t\tcity = City.new(\"Fake City\", 7, 0, prng)\n\t\tassert_nil city.cities\n\tend",
"def test_location_connections_empty\n assert @loc1.neighbors.empty?\n end",
"def test_monroeville_from_cathedral_if_rand_is_zero\r\n\t\toakland = City::new\r\n\t\trand_val = 0\r\n\t\tmonro = oakland.generate_cathedral_locs(oakland, rand_val)\r\n\r\n\t\tassert_equal monro[0], \"Monroeville\"\r\n\t\tassert_equal monro[1][0], \"Fourth Ave.\"\r\n\tend",
"def city_scraper\n #Id,Id2,Geography,Target Geo Id,Target Geo Id2,Geographical Area,Geographical Area,,,Total area,Water area,Land area,Population,Housing units\n #0400000US01,01,Alabama,1600000US0107000,0107000,\"Alabama - PLACE - Birmingham city, Alabama\",\"Birmingham city, Alabama\",242820,111927,151.95,2.04,149.92,1619.7,746.6\n # 0 1 2 3 4 5 6 7 8 9 10 11 12 13 \n @states = Array.new\n @cities = Array.new\n \n count = 0\n state_name = \"\"\n CSV.foreach(\"data/DEC_10_SF1_GCTPH1.ST13.csv\") do |row|\n count = count + 1\n city_name = \"\"\n population = 0\n elevation = 0\n lat_dir = \"\"\n lat_deg = 0\n lat_min = 0\n lat_sec = 0\n lon_dir = \"\"\n lon_deg = 0\n lon_min = 0\n lon_sec = 0\n if(row[2] == row[5])\n #its a state\n puts \"State: #{row[2]}\"\n state_name = row[2]\n state = State.new(:name => row[2])\n if(@states.length == 51)\n break\n end\n @states << state\n next\n end\n \n geographical_area = CSV.parse(row[6])\n city_name = geographical_area[0][0]\n if(city_name.match(/(part)/))\n #puts \"skipping #{city_name}\"\n next\n end\n \n city_name = city_name.downcase.gsub(/ city/,'').gsub(/ town/,'').gsub(/ village/,'').gsub(/ cdp/,'').gsub(/ borough/,'').gsub(/ municipality/,'').gsub(/ and/,'')\n city_name.strip.capitalize!\n city_name = city_name.capitalize\n #puts \"#{city_name} #{count}\"\n \n city_name_uri = URI.escape(city_name, Regexp.new(\"[^#{URI::PATTERN::UNRESERVED}]\"))\n state_name_uri = URI.escape(state_name, Regexp.new(\"[^#{URI::PATTERN::UNRESERVED}]\"))\n city_html = Net::HTTP.get(URI.parse(\"http://www.geonames.org/search.html?q=#{city_name_uri}%2C+#{state_name_uri}&country=US\"))\n #puts \"http://www.geonames.org/search.html?q=#{city_name}%2C+#{state_name}&country=US\"\n @city_doc = Hpricot(city_html)\n \n @city_doc.search(\"//table[@class='restable']\") do |table|\n tr_count = 0\n table.search(\"//tr\") do |tr|\n #puts \"in tr search\"\n tr_count = tr_count + 1\n if(tr_count < 3)\n next\n end\n #puts \"in tr search 2\"\n td_count = 0\n tr.search(\"//td\") do |td|\n #puts \"in td search\"\n td_count = td_count + 1\n if(td_count < 4)\n next\n end\n if(td_count == 4)\n td.search(\"//small\") do |small|\n #population = \"#{small.match(/\\\\d+/)[1]}\"\n #puts \"!!!!!!!!!!!!!!!!!!\"\n #puts td_count\n #puts \"#{small.inner_html}\"\n #puts \"!!!!!!!!!!!!!!!!!!\"\n pop_elev = small.inner_html\n #population = \"#{pop_elev.match(/\\d+,\\d*/)}\".gsub(/,/,'')\n elevation = \"#{pop_elev.match(/\\d+m/)}\".gsub(/m/,'')\n #puts population\n #puts elevation\n end\n end\n if(td_count == 5)\n lat_dir = td.inner_html[0]\n matches = td.inner_html.scan(/(\\d+)/)\n lat_deg = matches[0][0]\n lat_min = matches[1][0]\n lat_sec = matches[2][0]\n end\n if(td_count == 6)\n lon_dir = td.inner_html[0]\n matches = td.inner_html.scan(/(\\d+)/)\n lon_deg = matches[0][0]\n lon_min = matches[1][0]\n lon_sec = matches[2][0]\n end\n end\n break\n \n end \n end\n city = City.new(\n :name => city_name,\n :states_id => @states.length,\n :total_area => row[9],\n :water_area => row[10],\n :land_area => row[11],\n :population => row[7],\n :population_density => row[12],\n :lat_deg => lat_deg,\n :lat_min => lat_min,\n :lat_sec => lat_sec,\n :lat_dir => lat_dir,\n :lon_deg => lon_deg, \n :lon_min => lon_min,\n :lon_sec => lon_sec,\n :lon_dir => lon_dir,\n :elevation => elevation)\n \n @cities << city\n if(count % 10 == 0)\n puts count\n end\n end\n \n @states.each do |state|\n state.save\n end\n \n @cities.each do |state|\n state.save\n end\n \n end",
"def test_monkey_patch_city_neighbors\n assert_equal ['Nil Town', 'Enumerable Canyon', 'Matzburg'], @l.monkey_patch_city['neighbors']\n end",
"def test_location_self_connect\n @loc1.add_neighbor @loc2\n assert @loc1.connected? @loc2\n end",
"def enter_city_pair\n\n end",
"def test_game_loop_change_city\n\t\tg = Game.new(0,0,0)\n\t\tmocked_miner = Minitest::Mock.new(\"mocked miner\")\n\t\tdef mocked_miner.current_city; 0; end\n\t\tdef mocked_miner.increase_rubies(x,y); nil; end\n\t\tdef mocked_miner.change_city(x); nil; end\n\n\t\tmocked_city = Minitest::Mock.new(\"mocked city\")\n\t\tdef mocked_city.get_rubies(x); [0,0]; end\n\t\tdef mocked_city.name; 'Town'; end\n\t\tdef mocked_city.get_neighboring_city(x); 0; end\n\n\t\tmocked_printer = Minitest::Mock.new(\"mocked printer\")\n\t\tdef mocked_printer.print_day(x,y); nil; end\t\n\t\t\n\t\tassert_output(\"Heading from Town to Town.\\n\") {g.game_loop(mocked_miner, 2, mocked_printer, [mocked_city])}\n\tend",
"def test_address_auth \n c = customers(:bob)\n assert_equal(addresses(:address1), c.find_address(1))\n assert_equal(addresses(:address2), c.find_address(2))\n assert_nil(c.find_address(3))\n assert_nil(c.find_address(100000))\n end",
"def cities\n gallaries.map{|place| place.city}\n\n end",
"def test_connections\n @doors.all? do |k, v|\n v[-1] ? v[-1].leads_to?(self.class, k): true\n end\n end",
"def test_map_inclusive\n node = create(:node, :lat => 7, :lon => 7)\n tag = create(:node_tag, :node => node)\n way1 = create(:way_node, :node => node).way\n way2 = create(:way_node, :node => node).way\n relation = create(:relation_member, :member => node).relation\n\n bbox = \"#{node.lon},#{node.lat},#{node.lon},#{node.lat}\"\n get :map, :params => { :bbox => bbox }\n assert_response :success, \"The map call should have succeeded\"\n assert_select \"osm[version='#{API_VERSION}'][generator='#{GENERATOR}']\", :count => 1 do\n assert_select \"bounds[minlon='#{node.lon}'][minlat='#{node.lat}'][maxlon='#{node.lon}'][maxlat='#{node.lat}']\", :count => 1\n assert_select \"node[id='#{node.id}'][lat='#{format('%.7f', node.lat)}'][lon='#{format('%.7f', node.lon)}'][version='#{node.version}'][changeset='#{node.changeset_id}'][visible='#{node.visible}'][timestamp='#{node.timestamp.xmlschema}']\", :count => 1 do\n # This should really be more generic\n assert_select \"tag[k='#{tag.k}'][v='#{tag.v}']\"\n end\n assert_select \"way\", :count => 2\n assert_select \"way[id='#{way1.id}']\", :count => 1\n assert_select \"way[id='#{way2.id}']\", :count => 1\n assert_select \"relation\", :count => 1\n assert_select \"relation[id='#{relation.id}']\", :count => 1\n end\n end",
"def connectedCities(code)\r\n puts \"Connected Cities are\"\r\n results = connectedRoutes(code)\r\n results.sort{ |i,j| i[1].distance <=> j[1].distance}.each do |route|\r\n city = @vertex[route[1].ports.join.gsub(code,'')]\r\n puts \"#{city.name} (#{city.code}) : #{route[1].distance}\"\r\n end\r\n end",
"def cities\n CS.get :us, :ca\n end",
"def test_street_used_to_go_to_downtown\r\n\t\toakland = City::new\r\n\t\tfifth = Minitest::Mock::new\r\n\t\tdef fifth.street; \"Fifth Ave.\"; end\r\n\t\tassert_includes oakland.generate_hillman_locs(oakland, 0)[1][0], fifth.street\r\n\tend",
"def test_state_and_country\n a = Address.find(1)\n assert_equal('AL', a.state_code)\n assert_equal('Alabama', a.state_name)\n assert_equal('United States', a.country_name)\n end",
"def test_connect_mines\n @g.connect_mines\n\n assert [@g.ruby_mines['Enumerable Canyon'].neighbors[0]], ['Duck Type Beach']\n assert [@g.ruby_mines['Enumerable Canyon'].neighbors[1]], ['Monkey Patch City']\n end",
"def city_openings(start_date, end_date)\n openings(start_date, end_date)\n end",
"def test_street_connection\r\n\t\thillman = Location::new(\"Hillman\", \"Foo St.\", nil)\r\n\t\tassert_equal \"Foo St.\", hillman.street\r\n\tend",
"def add_latlon_cities(country_name, state_code, cities)\n country = Country.new(country_name)\n return cities if country.nil?\n\n state_name = country.states[state_code]['name'] unless country.nil?\n city_names = cities.map { |r| r[0] }\n locations = Hash[\n Place.where('\\'political\\' = ANY (types)')\n .where(state: state_name, country: country_name, name: city_names).map do |place|\n [place.name, [place.latitude, place.longitude, place.name]]\n end\n ]\n\n cities.map do |city|\n if locations.key?(city[0]) # If the city was found on the database\n locations[city[0]] + [city[1]]\n else\n points = Place.latlon_for_city(city[0], state_code, country_name)\n points + [city[0], city[1]] if points\n end\n end.compact\n end",
"def city_loop\n\t#loop through cities\n\t@cities.each do |t|\n\t\tputs \"#{t} is a town in Scotland\"\n\tend\n\nend",
"def get_cities\n cities = {}\n doc = nil\n retry_if_exception do\n doc = Nokogiri::HTML( easy_curl(@host_url) )\n end\n return [] if not doc\n a_cities = doc.css(\"ul[class='s-dropdown afh-dd-city'] li a\")\n a_cities.each do |city|\n city_name = city.text\n city_code = city['href'].scan(/\\w+(?=\\/changecity)/).pop\n next if not city_code\n cities[city_code] = city_name\n end\n cities\nend",
"def test_location_has_neighbors\n @l1.add_neighbors([@l2, @l3])\n assert_equal @l1.neighbors, [@l2, @l3] # pass\n end",
"def test_location_not_connected\n refute @loc1.connected? @loc2\n end",
"def test_possible_location_from_hospital_if_rand_is_one\r\n\t\toakland = City::new\r\n\t\trand_val = 1\r\n\t\thillman = oakland.generate_hospital_locs(oakland, rand_val)\r\n\r\n\t\tassert_equal hillman[0], \"Hillman\"\r\n\t\tassert_equal hillman[1][0], \"Foo St.\"\r\n\tend",
"def mutate\n i, j = rand(City.cities.size), rand(City.cities.size)\n if i > j\n @offspring_a.cities[i], @offspring_a.cities[j] = @offspring_a.cities[j], @offspring_a.cities[i]\n end\n\n i, j = rand(City.cities.size), rand(City.cities.size)\n if i > j\n @offspring_b.cities[i], @offspring_b.cities[j] = @offspring_b.cities[j], @offspring_b.cities[i]\n end\n end",
"def test_choose_next_town\n map = create_towns\n t = Town::new 'Enumerable Canyon', ['Duck Type Beach'], 1, 1\n p1 = Prospector::new t\n test_i = p1.choose_next_town map\n assert_equal test_i, 1\n end",
"def import_cities(options)\n import_places PlaceType::City, options\n end",
"def test_cayman_islands\n end",
"def test_find_nearby_cab_when_all_assigned\n \tminicab = cabs(:one)\n \tlat = minicab.current_latitude\n \tlong = minicab.current_longitude\n \tminicab.assign!\n \tcabs(:two).assign!\n \tcabs(:three).assign!\n \tassert_not Cab.find_near_by_cabs(lat,long).present?\n end",
"def get_city_names(cityName)\n dial_book.each do |dbkey, dbval|\n if dial_book[dbkey] == dial_book[cityName]\n get_area_code(dial_book, )\n end\n end\nend",
"def get_area_codes(input_city, list_of_cities)\n list_of_cities.each do |city, postcode|\n if input_city == city\n return \"The area code for #{city} is #{postcode}\"\n end \n end\n \"City is not in the list\"\nend",
"def test_driver_drive_many_choices\n\t\tloc1 = Location::new(\"Location\", [\"Hogwarts\",\"Narnia\",\"Middle Earth\"])\n\t\tdriv = Driver::new(1, loc1)\n\t\tassert_includes driv.get_place.get_neighbors, driv.drive\n\tend",
"def test_location_already_connected\n @loc1.add_neighbor @loc2\n @loc1.add_neighbor @loc2\n assert_equal 1, @loc1.neighbors.count\n end",
"def city_openings(start_date, end_date)\n self.listings.each do |listing|\n listing.reservations.each do |res|\n start_date <= res.checkout.to_s && end_date <= res.checkin.to_s\n end\n end\n end",
"def test_link_neighbors_invalid\n\t prng = Minitest::Mock.new\n\t def prng.rand(num); 1; end\n\t\tcity = City.new(\"Fake City\", 7, 0, prng)\n\t\tcity.link_neighbors 'here'\n\t\tassert_nil city.cities\n\tend",
"def test_monkey_patch_city\n initialize_map\n monkey_patch_city = @locations.get_location 'Monkey Patch City'\n assert_equal 'Monkey Patch City', monkey_patch_city.name_reader\n\n assert_equal 1, monkey_patch_city.max_real_reader\n assert_equal 1, monkey_patch_city.max_fake_reader\n\n assert_equal 'Enumerable Canyon', monkey_patch_city.neighbors_reader[0].name_reader\n assert_equal 'Matzburg', monkey_patch_city.neighbors_reader[1].name_reader\n assert_equal 'Nil Town', monkey_patch_city.neighbors_reader[2].name_reader\n end",
"def test_address_validation\n response = nil\n assert_nothing_raised do\n #response = @carrier_prod.validate_addresses({'address_from' => @locations[:ottawa], 'address_to' => @locations[:beverly_hills]}, :test=>false)\n @carrier_prod.validate_addresses({'address_from' => Location.new(\n :country => 'US',\n :state => 'TX',\n :city => 'Houston',\n :address1 => '11811 North Freeway',\n :address2 => 'suite 500',\n :zip => '77060'), \n 'address_to' => Location.new(:country => 'US',\n :state => 'NY',\n :city => 'Brooklyn',\n :address1 => '7 Balfour pl',\n :address2 => 'Apt E3',\n :zip => '11225')})\n end\n end",
"def test_museum_start_location\r\n\t\trand_val = Minitest::Mock::new\r\n\t\toakland = City::new\r\n\t\tdef rand_val.get_start_location; 1; end\r\n\t\tstart_loc = oakland.all_locations[rand_val.get_start_location]\r\n\t\tassert_equal start_loc, \"Cathedral\"\r\n\tend",
"def hometown_generator\n city = @hometown_options.sample\n end",
"def test_connect_increments_neighbor_count\n @test_loc.connect @test_neighbor_list[0]\n assert_equal 1, @test_loc.neighbors.count\n end",
"def test_possible_location_from_hospital_if_rand_is_zero\r\n\t\toakland = City::new\r\n\t\trand_val = 0\r\n\t\tcathedral = oakland.generate_hospital_locs(oakland, rand_val)\r\n\r\n\t\tassert_equal cathedral[0], \"Cathedral\"\r\n\t\tassert_equal cathedral[1][0], \"Fourth Ave.\"\r\n\tend",
"def afficeur\n @city_link.map do |element|\n villes = get_city_names(element)\n email = get_townhall_email(element)\n @result = []\n @result << {villes => email}\n end\n end",
"def test_success_multiple_results\n return unless prepare_response(:success_multiple_results)\n\n location = Location.new(\n :street => \"Queen St W\",\n :locality => \"Toronto\",\n :region => \"ON\",\n :postal_code => nil,\n :country => \"CA\",\n :longitude => -79.4125590,\n :latitude => 43.6455030,\n :precision => :street\n )\n assert_equal location, @geocoder.locate('Queen St West, Toronto, ON CA')\n end",
"def test_location_0\r\n\t\tdriver = Driver::new(\"Driver\")\r\n\t\t\r\n\t\thillman = Location.new(\"Hillman\", \"Foo St.\", \"Fifth Ave.\")\r\n\t\thospital = Location.new(\"Hospital\", \"Foo St.\", \"Fourth Ave.\")\r\n\t\tmuseum = Location.new(\"Museum\", \"Bar St.\", \"Fifth Ave.\")\r\n\t\tcathedral = Location.new(\"Cathedral\", \"Bar St.\", \"Fourth Ave.\")\r\n\t\t\r\n\t\tlocations = [hillman, hospital, cathedral, museum]\r\n\t\t\r\n\t\trandom_start_location(driver, 0, locations)\r\n\t\tassert_equal hillman, driver.location\r\n\tend",
"def get_townhall_urls\n city = []\n town.xpath('//p/a').each do |node|\n city << node.text.downcase #l'array city, est l'ensemble des villes du 95\n end\n array_url = city\n final = []\n array_url.each do |town|\n return array_url2 = Nokogiri::HTML(URI.open(\"http://annuaire-des-mairies.com/95/#{town.gsub(\" \", \"-\" )}.html\"))\n end\nend",
"def cities()\n sql = \"SELECT cities.* FROM cities WHERE country_id = $1\"\n values = [@id]\n cities = SqlRunner.run(sql, values)\n result = City.map_items(cities)\n return result\n end",
"def init_city\n\n @city = City.new(5900, 70)\n\n house = Seitch.new()\n init_building(house,34,24)\n init_building(house,35,24)\n init_building(house,34,25)\n init_building(house,33,36)\n init_building(house,34,37)\n init_building(house,35,37)\n init_building(house,36,37)\n init_building(house,37,34)\n\n starport = Starport.new()\n init_building(starport ,30,30)\n\n farm = FarmA.new()\n init_building(farm ,37,24)\n\n atmo = AtmoGen.new()\n init_building(atmo ,34,30)\n end",
"def test_multiple_parameter3\n @cl.url = 'http://craigslist.com?city=${city}&item=${city}'\n @cl.save\n \n assert_equal \"http://craigslist.com?city=san+francisco&item=san+francisco\",\n Parser.get_url('cl -city san francisco')\n \n end",
"def test_fun_five_prospectors\n\t@city = GoldRush::new\n\tcity.initiliaze(1,5)\n\tassert_equal 5, @city.prospectors.length\n end",
"def city_openings(start_date, end_date)\n Listing.find_openings(listings, Date.parse(start_date), Date.parse(end_date))\n end",
"def test_invalid_city_name\n answer = MapGraph.new\n assert_nil answer.get_index_and_city_name('Pittsburgh')\n end",
"def test_basic\n city_obj = {\n code: \"SCL\",\n name: \"Santiago\",\n country: \"CL\",\n continent: \"South America\",\n timezone: -4 ,\n coordinates: {S: 33, W: 71} ,\n population: 6000000 ,\n region: 1\n }\n\n city = City.new(JSON.parse(city_obj.to_json))\n location = city.location\n\n assert_match(\"CL\", location.country)\n assert_match(\"South America\", location.continent)\n assert_equal(1, location.region)\n end",
"def test_querry\n assert_equal(get_city_info('TY', @my_graph), 'noCity', 'output wrong')\n assert_not_equal(get_city_info('TYO', @my_graph), 'noCity', 'output wrong')\n end",
"def test_valid_city_name\n answer = MapGraph.new\n assert_equal 6, answer.get_index_and_city_name('Dynamic Palisades')\n end",
"def default_test\n seed = 10\n prng = Random.new seed\n id = 1\n pros = Prospector.new id, prng\n # Mock an array of connections\n city = Minitest::Mock.new('Mock Map')\n def city.connection\n ['mock city 1', 'mock city 2', 'mock city 3']\n end\n 200.times do\n actual = pros.get_another_id prng, city.connection.length\n assert_operator 3, :>=, actual\n assert_operator 0, :<=, actual\n end\n end",
"def test_assign_town\n map = create_towns\n p1 = Prospector::new map[0]\n n_town = map[1] # pick the next town to set\n p1.assign_town n_town\n s_town = p1.return_town\n t = Town::new 'Duck Type Beach', ['Enumerable Canyon', 'Matzburg'], 2, 2\n assert_equal s_town.return_name, t.return_name\n end",
"def load_cities(row)\n\n # setting the name of the city, state and county\n city = row[0]\n state = row[1]\n county = row[2]\n\n attrs = {\n :name => city,\n :status => 'active',\n :site_type_code => 'city'\n }\n # add site\n unless site = Site.where(:name => city).first\n new_site = Site.new(attrs)\n\n # setting location/contact attributes\n loc_attrs = {\n :city => city,\n :county => county,\n :state => state\n }\n\n # add contact info for site\n new_site.contacts.build(loc_attrs)\n\n # save site\n if new_site.save\n puts \"Saved site #{attrs.inspect}\"\n else\n puts \"Error: #{new_site.errors.full_messages.first}\\nCity: #{city}\"\n end\n end\nend",
"def test_possible_location_from_hillman_if_rand_is_zero\r\n\t\toakland = City::new\r\n\t\trand_val = 0\r\n\t\tdowntown = oakland.generate_hillman_locs(oakland, rand_val)\r\n\r\n\t\tassert_equal downtown[0], \"Downtown\"\r\n\t\tassert_equal downtown[1][0], \"Fifth Ave.\"\r\n\tend",
"def test_via_museum_hillman\r\n assert_equal 'Fifth Ave', @driver.via('Museum', 'Hillman')\r\n end",
"def test_nodes_of_museum\n\t\tassert_equal @location, @location2.nodes[0]\n\tend",
"def test_location_disconnect_connections_length_0\n @loc1.add_neighbor @loc2\n @loc1.disconnect @loc2\n assert_equal 0, @loc1.neighbors.length\n end"
] |
[
"0.67130727",
"0.65000224",
"0.64120615",
"0.62656534",
"0.60036236",
"0.5957624",
"0.5855112",
"0.5818224",
"0.5816393",
"0.5793313",
"0.576407",
"0.5761168",
"0.57517266",
"0.57243514",
"0.57153165",
"0.56975263",
"0.5655579",
"0.5648212",
"0.5623234",
"0.56030244",
"0.55502546",
"0.5549999",
"0.55486465",
"0.5541052",
"0.5533046",
"0.5530526",
"0.5529984",
"0.5523982",
"0.5494985",
"0.54815036",
"0.5475175",
"0.5464023",
"0.5463559",
"0.54304856",
"0.54263765",
"0.54247487",
"0.5417491",
"0.5409829",
"0.5400816",
"0.5392097",
"0.5387279",
"0.5381683",
"0.5379555",
"0.53636724",
"0.5363397",
"0.5361686",
"0.53600025",
"0.53516656",
"0.5345397",
"0.53417945",
"0.53410393",
"0.5329008",
"0.5326695",
"0.53215575",
"0.53171027",
"0.52939343",
"0.52936214",
"0.52885765",
"0.5284494",
"0.5282246",
"0.5275563",
"0.5275012",
"0.5274549",
"0.5268468",
"0.5251017",
"0.52483904",
"0.5239529",
"0.52322805",
"0.5218598",
"0.5216868",
"0.518298",
"0.5176732",
"0.5164433",
"0.5158508",
"0.5155133",
"0.5149326",
"0.51486766",
"0.51475596",
"0.51406497",
"0.5135164",
"0.5134544",
"0.51303273",
"0.5115129",
"0.51128083",
"0.51054084",
"0.51047814",
"0.51028436",
"0.5101415",
"0.51005864",
"0.5100535",
"0.51002127",
"0.50930786",
"0.5089535",
"0.5082326",
"0.50818914",
"0.5073671",
"0.5072348",
"0.50705314",
"0.5070447",
"0.50678205"
] |
0.7062134
|
0
|
UNIT TESTS FOR METHOD connect_sutter_with_other(cities)
|
def test_connect_sutter
map = Map.new
# testing connect with Coloma
assert_equal 4, map.cities[2].connections[1].id
# testing connect angel camp
assert_equal 1, map.cities[2].connections[0].id
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def test_validate_cities\n skip('this is a helper method for validating location names')\n # ignored cities are ones for which I don't know the location code\n # that the API accepts\n ignored_cities = %w(chongqing koln cologne dusseldorf eugene honolulu\n milan southbay)\n cities = %w(amsterdam austin berlin calgary columbus denver firenze\n frankfurt hamburg miami montreal muenchen\n newyorkcity portland rheinland roma sandiego seattle stockholm\n stuttgart torino toronto twincities vancouver washingtondc\n wien)\n\n cities.each do |city|\n @caruby2go = Caruby2go.new(ENV['CONSUMER_KEY'], city)\n puts \"#{city}\"\n payload = @caruby2go.gasstations\n puts \"#{city}:\\n#{payload}\"\n end\n puts \"Done with valid cities (#{cities.size})\"\n puts 'Did not look for the following cities as they have previously failed validation:'\n ignored_cities.each do |city|\n puts city\n end\n end",
"def test_fun_city_locs\n\t@city = GoldRush::new\n\tassert_equal \"El Dorado Canyon\", @city.dorado.location\n\tassert_equal \"Midas\", @city.midas.location\n\tassert_equal \"Virginia City\", @city.virginia.location\n\tassert_equal \"Nevada City\", @city.nevada.location\n\tassert_equal \"Coloma\", @city.coloma.location\n\tassert_equal \"Angels Camp\", @city.angels.location\n\tassert_equal \"Sutter Creek\", @city.sutter.location\n end",
"def test_angel_camp_connections\n map = Map.new\n # checking if Angel camp on index @cities[1]\n # is connected with......\n #\n # First: with Nevada, it should be on index 0 of array connections\n # checking Angel camp is connected with Nevada\n # checking by name\n assert_equal 'Nevada City', map.cities[1].connections[0].name\n #\n # checking by ID\n assert_equal 0, map.cities[1].connections[0].id\n #\n # Second:\n # Checking Angel camp is connected with Sutter Creek\n assert_equal 'Sutter Creek', map.cities[1].connections[1].name\n # checking by id\n assert_equal 2, map.cities[1].connections[1].id\n #\n # Third:\n # checking Angel camp is connected with Virgina City\n # checking by name\n assert_equal 'Virginia City', map.cities[1].connections[2].name\n # checking by id\n assert_equal 3, map.cities[1].connections[2].id\n end",
"def test_all_locations\r\n\t\toakland = City::new\r\n\t\tfour_locations = [\"Museum\", \"Cathedral\", \"Hospital\", \"Hillman\"]\r\n\t\tassert_includes four_locations, oakland.all_locations[0], oakland.all_locations[1]\r\n\t\tassert_includes four_locations, oakland.all_locations[2], oakland.all_locations[3]\r\n\tend",
"def fetch_trips(origin_city)\r\n return if origin_city.nil?\r\n\r\n airport_type = AIRPORT_TYPE_MEDIUM_KEY\r\n\r\n case\r\n when origin_city.downcase == 'helsinki'\r\n # Helsinki-Vantaa on ainoa poikkeus!\r\n airport_type = AIRPORT_TYPE_LARGE_KEY\r\n end\r\n\r\n # Suomesta tapahtuvien lähtöjen lentokentät ovat pääsääntöisesti medium-luokkaa.\r\n journey_airports = AIRPORTS.find({MUNICIPALITY_KEY => origin_city.capitalize, AIRPORT_TYPE_KEY => airport_type})\r\n unless journey_airports.nil?\r\n journey_airports.each do |airport|\r\n\r\n fetch_origin_country(airport)\r\n\r\n @trips = TRIPS.find({AIRPORT_ORIGIN_CITY => airport[MUNICIPALITY_KEY]})\r\n end\r\n end\r\n\r\n #@wikipedia_link = COUNTRIES.find(\r\n\r\nend",
"def test_location_other_connect\n @loc1.add_neighbor @loc2\n assert @loc2.connected? @loc1\n end",
"def test_street_used_to_go_to_monroeville\r\n\t\toakland = City::new\r\n\t\tfourth = Minitest::Mock::new\r\n\t\tdef fourth.street; \"Fourth Ave.\"; end\r\n\t\tassert_includes oakland.generate_cathedral_locs(oakland, 0)[1][0], fourth.street\r\n\tend",
"def crossover(city_names2)\n # Copy 2 cities at a time thereby preserving the edge between them\n city_names_new = []\n max_index = city_names.size - 1\n index = 0\n while index <= max_index - 1\n parent = (rand > 0.5 ? @city_names : city_names2)\n city_names_new << parent[index] << parent[index + 1]\n index += 1\n end\n \n # Remove dup cities\n city_names_new.uniq!\n \n # Make a list of missing cities\n missing_cities = []\n city_names.each do |city| \n missing_cities << city unless city_names_new.include?(city)\n end\n \n city_names_new.concat(missing_cities)\n @city_names = city_names_new\n @type = \"Hybrid\"\n end",
"def test_game_loop_change_city\n\t\tg = Game.new(0,0,0)\n\t\tmocked_miner = Minitest::Mock.new(\"mocked miner\")\n\t\tdef mocked_miner.current_city; 0; end\n\t\tdef mocked_miner.increase_rubies(x,y); nil; end\n\t\tdef mocked_miner.change_city(x); nil; end\n\n\t\tmocked_city = Minitest::Mock.new(\"mocked city\")\n\t\tdef mocked_city.get_rubies(x); [0,0]; end\n\t\tdef mocked_city.name; 'Town'; end\n\t\tdef mocked_city.get_neighboring_city(x); 0; end\n\n\t\tmocked_printer = Minitest::Mock.new(\"mocked printer\")\n\t\tdef mocked_printer.print_day(x,y); nil; end\t\n\t\t\n\t\tassert_output(\"Heading from Town to Town.\\n\") {g.game_loop(mocked_miner, 2, mocked_printer, [mocked_city])}\n\tend",
"def test_choose_next_town\n map = create_towns\n t = Town::new 'Enumerable Canyon', ['Duck Type Beach'], 1, 1\n p1 = Prospector::new t\n test_i = p1.choose_next_town map\n assert_equal test_i, 1\n end",
"def test_smallest_population_city\n lib = CSAirLib.new\n assert_equal(lib.smallest_population_city,'Essen')\n end",
"def cities opt, graph\n\n\tp opt, graph\n\t#first try all cities spread over USA, should be easy to figure out if the correct tour was picked\n\tcities = 'd,DC,77.01,38.90;l,Los_Angeles,118.25,34.05;c,Chicago,87.68,41.83;m,Memphis,89.97,35.11;h,Houston,95.36,29.76;\n\t\t\t\t L,Las_Vegas,115.17,36.12;k,Kansas_city,94.57,39.09;M,Miami,80.20,25.77;s,San_Fran,122.41,37.78;a,Dallas,96.79,32.77;\n\t\t\t \t n,Nashville,86.78,36.16;e,Detroit,83.04,42.33;p,Phoneix,112.06,33.45;D,Denver,104.99,39.73'\n\n\tloop_over cities: cities, pool_size: 30, graph: graph, vmirror: true, hmirror: true if opt == '1'\n\n\t#Now add sort of a loop in California\n\tcities += ';S,Sacramento,121.46,38.55;f,Fresno,119.76,36.75;A,San_jose,121.88,37.33;C,Carson_city,119.75,39.16'\n\tloop_over cities: cities, pool_size: 30, graph: graph, vmirror: true, hmirror: true if opt == '2'\n\n\t#Now try with randomly generated cities\n\tif opt == '3' or opt.nil?\n\t\tcities = nil\n\t\tloop_over cities: cities, pool_size: 30, graph: graph\n\tend\n\nend",
"def basic_test_data\n sf = FactoryGirl.create(:city, name: \"San Francisco\")\n ch = FactoryGirl.create(:city, name: \"Chicago\")\n FactoryGirl.create(:business_type)\n\n # Admin user\n FactoryGirl.create(:user, admin: true, city_id: sf.id)\n\n # Need some businesses in each city\n 3.times do\n FactoryGirl.create(:business, city: sf.name, state: \"CA\")\n FactoryGirl.create(:business, city: ch.name, state: \"IL\")\n end\n\n %w(a b c d e f g h i j k).each do |tag|\n FactoryGirl.create(:tag, name: tag)\n end\n end",
"def test_querry\n assert_equal(get_city_info('TY', @my_graph), 'noCity', 'output wrong')\n assert_not_equal(get_city_info('TYO', @my_graph), 'noCity', 'output wrong')\n end",
"def test_fun_five_prospectors\n\t@city = GoldRush::new\n\tcity.initiliaze(1,5)\n\tassert_equal 5, @city.prospectors.length\n end",
"def test_location_2\r\n\t\tdriver = Driver::new(\"Driver\")\r\n\t\t\r\n\t\thillman = Location.new(\"Hillman\", \"Foo St.\", \"Fifth Ave.\")\r\n\t\thospital = Location.new(\"Hospital\", \"Foo St.\", \"Fourth Ave.\")\r\n\t\tmuseum = Location.new(\"Museum\", \"Bar St.\", \"Fifth Ave.\")\r\n\t\tcathedral = Location.new(\"Cathedral\", \"Bar St.\", \"Fourth Ave.\")\r\n\t\t\r\n\t\tlocations = [hillman, hospital, cathedral, museum]\r\n\t\t\r\n\t\trandom_start_location(driver, 2, locations)\r\n\t\tassert_equal cathedral, driver.location\r\n\tend",
"def test_random_neighbor_many_connections\n neighbor_list = [@loc2, @loc3, @loc4]\n\n @loc1.add_neighbor @loc2\n @loc1.add_neighbor @loc3\n @loc1.add_neighbor @loc4\n\n assert_includes neighbor_list, @loc1.random_neighbor\n end",
"def test_link_neighbors_valid\n\t prng = Minitest::Mock.new\n\t def prng.rand(num); 1; end\n\t\tcity = City.new(\"Fake City\", 7, 0, prng)\n\t\tcity1 = City.new(\"Fake City 1\", 7, 0, prng)\n\t\tcity2 = City.new(\"Fake City 2\", 7, 0, prng)\n\t\tArray cities = [city1, city2]\n\t\tcity.link_neighbors cities\n\t\tassert_equal cities, city.cities\n\tend",
"def test_random_neighbor_one_connection\n @loc1.add_neighbor @loc2\n assert_equal @loc2, @loc1.random_neighbor\n end",
"def init_city\n\n @city = City.new(5900, 70)\n\n house = Seitch.new()\n init_building(house,34,24)\n init_building(house,35,24)\n init_building(house,34,25)\n init_building(house,33,36)\n init_building(house,34,37)\n init_building(house,35,37)\n init_building(house,36,37)\n init_building(house,37,34)\n\n starport = Starport.new()\n init_building(starport ,30,30)\n\n farm = FarmA.new()\n init_building(farm ,37,24)\n\n atmo = AtmoGen.new()\n init_building(atmo ,34,30)\n end",
"def test_street_used_to_go_to_downtown\r\n\t\toakland = City::new\r\n\t\tfifth = Minitest::Mock::new\r\n\t\tdef fifth.street; \"Fifth Ave.\"; end\r\n\t\tassert_includes oakland.generate_hillman_locs(oakland, 0)[1][0], fifth.street\r\n\tend",
"def test_assign_town\n map = create_towns\n p1 = Prospector::new map[0]\n n_town = map[1] # pick the next town to set\n p1.assign_town n_town\n s_town = p1.return_town\n t = Town::new 'Duck Type Beach', ['Enumerable Canyon', 'Matzburg'], 2, 2\n assert_equal s_town.return_name, t.return_name\n end",
"def test_location_self_connect\n @loc1.add_neighbor @loc2\n assert @loc1.connected? @loc2\n end",
"def test_travel_iteration_five\n fake_state = Minitest::Mock.new\n def fake_state.max_silver\n 0\n end\n\n def fake_state.max_gold\n 0\n end\n\n def fake_state.city_name\n 'test1'\n end\n\n def fake_state.edge_cities\n [Location.new('test1', 0, 0)]\n end\n\n assert_equal([6, 2], @game.travel(5, fake_state, 6, 2))\n end",
"def city_scraper\n #Id,Id2,Geography,Target Geo Id,Target Geo Id2,Geographical Area,Geographical Area,,,Total area,Water area,Land area,Population,Housing units\n #0400000US01,01,Alabama,1600000US0107000,0107000,\"Alabama - PLACE - Birmingham city, Alabama\",\"Birmingham city, Alabama\",242820,111927,151.95,2.04,149.92,1619.7,746.6\n # 0 1 2 3 4 5 6 7 8 9 10 11 12 13 \n @states = Array.new\n @cities = Array.new\n \n count = 0\n state_name = \"\"\n CSV.foreach(\"data/DEC_10_SF1_GCTPH1.ST13.csv\") do |row|\n count = count + 1\n city_name = \"\"\n population = 0\n elevation = 0\n lat_dir = \"\"\n lat_deg = 0\n lat_min = 0\n lat_sec = 0\n lon_dir = \"\"\n lon_deg = 0\n lon_min = 0\n lon_sec = 0\n if(row[2] == row[5])\n #its a state\n puts \"State: #{row[2]}\"\n state_name = row[2]\n state = State.new(:name => row[2])\n if(@states.length == 51)\n break\n end\n @states << state\n next\n end\n \n geographical_area = CSV.parse(row[6])\n city_name = geographical_area[0][0]\n if(city_name.match(/(part)/))\n #puts \"skipping #{city_name}\"\n next\n end\n \n city_name = city_name.downcase.gsub(/ city/,'').gsub(/ town/,'').gsub(/ village/,'').gsub(/ cdp/,'').gsub(/ borough/,'').gsub(/ municipality/,'').gsub(/ and/,'')\n city_name.strip.capitalize!\n city_name = city_name.capitalize\n #puts \"#{city_name} #{count}\"\n \n city_name_uri = URI.escape(city_name, Regexp.new(\"[^#{URI::PATTERN::UNRESERVED}]\"))\n state_name_uri = URI.escape(state_name, Regexp.new(\"[^#{URI::PATTERN::UNRESERVED}]\"))\n city_html = Net::HTTP.get(URI.parse(\"http://www.geonames.org/search.html?q=#{city_name_uri}%2C+#{state_name_uri}&country=US\"))\n #puts \"http://www.geonames.org/search.html?q=#{city_name}%2C+#{state_name}&country=US\"\n @city_doc = Hpricot(city_html)\n \n @city_doc.search(\"//table[@class='restable']\") do |table|\n tr_count = 0\n table.search(\"//tr\") do |tr|\n #puts \"in tr search\"\n tr_count = tr_count + 1\n if(tr_count < 3)\n next\n end\n #puts \"in tr search 2\"\n td_count = 0\n tr.search(\"//td\") do |td|\n #puts \"in td search\"\n td_count = td_count + 1\n if(td_count < 4)\n next\n end\n if(td_count == 4)\n td.search(\"//small\") do |small|\n #population = \"#{small.match(/\\\\d+/)[1]}\"\n #puts \"!!!!!!!!!!!!!!!!!!\"\n #puts td_count\n #puts \"#{small.inner_html}\"\n #puts \"!!!!!!!!!!!!!!!!!!\"\n pop_elev = small.inner_html\n #population = \"#{pop_elev.match(/\\d+,\\d*/)}\".gsub(/,/,'')\n elevation = \"#{pop_elev.match(/\\d+m/)}\".gsub(/m/,'')\n #puts population\n #puts elevation\n end\n end\n if(td_count == 5)\n lat_dir = td.inner_html[0]\n matches = td.inner_html.scan(/(\\d+)/)\n lat_deg = matches[0][0]\n lat_min = matches[1][0]\n lat_sec = matches[2][0]\n end\n if(td_count == 6)\n lon_dir = td.inner_html[0]\n matches = td.inner_html.scan(/(\\d+)/)\n lon_deg = matches[0][0]\n lon_min = matches[1][0]\n lon_sec = matches[2][0]\n end\n end\n break\n \n end \n end\n city = City.new(\n :name => city_name,\n :states_id => @states.length,\n :total_area => row[9],\n :water_area => row[10],\n :land_area => row[11],\n :population => row[7],\n :population_density => row[12],\n :lat_deg => lat_deg,\n :lat_min => lat_min,\n :lat_sec => lat_sec,\n :lat_dir => lat_dir,\n :lon_deg => lon_deg, \n :lon_min => lon_min,\n :lon_sec => lon_sec,\n :lon_dir => lon_dir,\n :elevation => elevation)\n \n @cities << city\n if(count % 10 == 0)\n puts count\n end\n end\n \n @states.each do |state|\n state.save\n end\n \n @cities.each do |state|\n state.save\n end\n \n end",
"def enter_city_pair\n\n end",
"def test_connect_mines\n @g.connect_mines\n\n assert [@g.ruby_mines['Enumerable Canyon'].neighbors[0]], ['Duck Type Beach']\n assert [@g.ruby_mines['Enumerable Canyon'].neighbors[1]], ['Monkey Patch City']\n end",
"def test_possible_location_from_cathedral_if_rand_is_one\r\n\t\toakland = City::new\r\n\t\trand_val = 1\r\n\t\tmuseum = oakland.generate_cathedral_locs(oakland, rand_val)\r\n\r\n\t\tassert_equal museum[0], \"Museum\"\r\n\t\tassert_equal museum[1][0], \"Bar St.\"\r\n\tend",
"def city_loop\n\t#loop through cities\n\t@cities.each do |t|\n\t\tputs \"#{t} is a town in Scotland\"\n\tend\n\nend",
"def set_states_cities data\n states_hash = Hash.new { |h,k| h[k] = [] }\n cities_hash = Hash.new { |h,k| h[k] = [] }\n data.each do |row|\n if !states_hash[row[\"country_name\"]].include?(row[\"province_name\"])\n states_hash[row[\"country_name\"]] << row[\"province_name\"]\n end\n if !cities_hash[row[\"province_name\"]].include?(row[\"city_name\"])\n cities_hash[row[\"province_name\"]] << row[\"city_name\"]\n end\n end\n @@all_cities = cities_hash\n @@all_states = states_hash\n build_result(@distributor_name, @include_regions, @exclude_regions)\n end",
"def test_possible_location_from_museum_if_rand_is_one\r\n\t\toakland = City::new\r\n\t\trand_val = 1\r\n\t\thillman = oakland.generate_museum_locs(oakland, rand_val)\r\n\r\n\t\tassert_equal hillman[0], \"Hillman\"\r\n\t\tassert_equal hillman[1][0], \"Fifth Ave.\"\r\n\tend",
"def test_location_3\r\n\t\tdriver = Driver::new(\"Driver\")\r\n\t\t\r\n\t\thillman = Location.new(\"Hillman\", \"Foo St.\", \"Fifth Ave.\")\r\n\t\thospital = Location.new(\"Hospital\", \"Foo St.\", \"Fourth Ave.\")\r\n\t\tmuseum = Location.new(\"Museum\", \"Bar St.\", \"Fifth Ave.\")\r\n\t\tcathedral = Location.new(\"Cathedral\", \"Bar St.\", \"Fourth Ave.\")\r\n\t\t\r\n\t\tlocations = [hillman, hospital, cathedral, museum]\r\n\t\t\r\n\t\trandom_start_location(driver, 3, locations)\r\n\t\tassert_equal museum, driver.location\r\n\tend",
"def test_cathedral_start_location\r\n\t\trand_val = Minitest::Mock::new\r\n\t\toakland = City::new\r\n\t\tdef rand_val.get_start_location; 2; end\r\n\t\tstart_loc = oakland.all_locations[rand_val.get_start_location]\r\n\t\tassert_equal start_loc, \"Hillman\"\r\n\tend",
"def test_location_is_connected\n @loc1.add_neighbor @loc2\n assert @loc1.connected? @loc2\n end",
"def test_create_towns\n t3 = Town::new 'Monkey Patch City', ['Nil Town', 'Enumerable Canyon', 'Matzburg'], 1, 1\n map = create_towns\n test_t = map[2]\n assert_equal t3.return_name, test_t.return_name\n end",
"def test_other_start_location_false\r\n\t\tmock_driver = Minitest::Mock::new\r\n\t\tdef mock_driver.get_start_location; 3; end\r\n\t\toakland = City::new\r\n\t\tstart_loc = oakland.all_locations[mock_driver.get_start_location]\r\n\t\trefute_includes start_loc, oakland.downtown[0]\r\n\t\trefute_includes start_loc, oakland.monro[0]\r\n\tend",
"def mutate\n i, j = rand(City.cities.size), rand(City.cities.size)\n if i > j\n @offspring_a.cities[i], @offspring_a.cities[j] = @offspring_a.cities[j], @offspring_a.cities[i]\n end\n\n i, j = rand(City.cities.size), rand(City.cities.size)\n if i > j\n @offspring_b.cities[i], @offspring_b.cities[j] = @offspring_b.cities[j], @offspring_b.cities[i]\n end\n end",
"def test_location_1\r\n\t\tdriver = Driver::new(\"Driver\")\r\n\t\t\r\n\t\thillman = Location.new(\"Hillman\", \"Foo St.\", \"Fifth Ave.\")\r\n\t\thospital = Location.new(\"Hospital\", \"Foo St.\", \"Fourth Ave.\")\r\n\t\tmuseum = Location.new(\"Museum\", \"Bar St.\", \"Fifth Ave.\")\r\n\t\tcathedral = Location.new(\"Cathedral\", \"Bar St.\", \"Fourth Ave.\")\r\n\t\t\r\n\t\tlocations = [hillman, hospital, cathedral, museum]\r\n\t\t\r\n\t\trandom_start_location(driver, 1, locations)\r\n\t\tassert_equal hospital, driver.location\r\n\tend",
"def test_link_neighbors_nil\n\t\tprng = Minitest::Mock.new\n\t def prng.rand(num); 1; end\n\t\tcity = City.new(\"Fake City\", 7, 0, prng)\n\t\tassert_nil city.cities\n\tend",
"def test_success_multiple_results\n return unless prepare_response(:success_multiple_results)\n\n location = Location.new(\n :street => \"Queen St W\",\n :locality => \"Toronto\",\n :region => \"ON\",\n :postal_code => nil,\n :country => \"CA\",\n :longitude => -79.4125590,\n :latitude => 43.6455030,\n :precision => :street\n )\n assert_equal location, @geocoder.locate('Queen St West, Toronto, ON CA')\n end",
"def test_driver_drive_many_choices\n\t\tloc1 = Location::new(\"Location\", [\"Hogwarts\",\"Narnia\",\"Middle Earth\"])\n\t\tdriv = Driver::new(1, loc1)\n\t\tassert_includes driv.get_place.get_neighbors, driv.drive\n\tend",
"def test_location_other_disconnect\n @loc1.add_neighbor @loc2\n @loc1.disconnect @loc2\n refute @loc2.connected? @loc1\n end",
"def test_return_town\n map = create_towns\n p1 = Prospector::new map[0]\n s_town = p1.return_town\n t = Town::new 'Enumerable Canyon', ['Duck Type Beach', 'Monkey Patch City'], 1, 1\n assert_equal s_town.return_name, t.return_name\n end",
"def test_biggest_population_city\n lib = CSAirLib.new\n assert_equal(lib.biggest_population_city,'Tokyo')\n end",
"def test_change_twice\n\t\tm = Miner.new(0)\n\t\tm.change_city(1)\n\t\tm.change_city(2)\n\t\tassert_equal(2,m.current_city)\n\tend",
"def test_monkey_patch_city_neighbors\n assert_equal ['Nil Town', 'Enumerable Canyon', 'Matzburg'], @l.monkey_patch_city['neighbors']\n end",
"def set_city\n end",
"def cities_helper\n [\n ['基隆市', '基隆市'],\n ['台北市', '台北市'],\n ['新北市', '新北市'],\n ['桃園縣', '桃園縣'],\n ['新竹市', '新竹市'],\n ['新竹縣', '新竹縣'],\n ['苗栗縣', '苗栗縣'],\n ['台中市', '台中市'],\n ['彰化縣', '彰化縣'],\n ['南投縣', '南投縣'],\n ['雲林縣', '雲林縣'],\n ['嘉義市', '嘉義市'],\n ['嘉義縣', '嘉義縣'],\n ['台南市', '台南市'],\n ['高雄市', '高雄市'],\n ['屏東縣', '屏東縣'],\n ['台東縣', '台東縣'],\n ['花蓮縣', '花蓮縣'],\n ['宜蘭縣', '宜蘭縣'],\n ['澎湖縣', '澎湖縣'],\n ['金門縣', '金門縣'],\n ['連江縣', '連江縣']\n ]\n end",
"def test_state_and_country\n a = Address.find(1)\n assert_equal('AL', a.state_code)\n assert_equal('Alabama', a.state_name)\n assert_equal('United States', a.country_name)\n end",
"def test_basic\n city_obj = {\n code: \"SCL\",\n name: \"Santiago\",\n country: \"CL\",\n continent: \"South America\",\n timezone: -4 ,\n coordinates: {S: 33, W: 71} ,\n population: 6000000 ,\n region: 1\n }\n\n city = City.new(JSON.parse(city_obj.to_json))\n location = city.location\n\n assert_match(\"CL\", location.country)\n assert_match(\"South America\", location.continent)\n assert_equal(1, location.region)\n end",
"def roads_and_libraries(n, c_lib, c_road, cities)\n \nend",
"def test_possible_location_from_museum_if_rand_is_zero\r\n\t\toakland = City::new\r\n\t\trand_val = 0\r\n\t\tcathedral = oakland.generate_museum_locs(oakland, rand_val)\r\n\r\n\t\tassert_equal cathedral[0], \"Cathedral\"\r\n\t\tassert_equal cathedral[1][0], \"Bar St.\"\r\n\tend",
"def test_multiple_parameter3\n @cl.url = 'http://craigslist.com?city=${city}&item=${city}'\n @cl.save\n \n assert_equal \"http://craigslist.com?city=san+francisco&item=san+francisco\",\n Parser.get_url('cl -city san francisco')\n \n end",
"def test_driver_setLocation_museum\n\t\td = Driver::new(\"Driver 1\",1)\n\t\td.setLocation 1 #cathedral to museum\n\t\tassert_equal d.getLocation, 3\n\tend",
"def get_list_cities\n City.get_all_cities\n end",
"def test_location_not_connected\n refute @loc1.connected? @loc2\n end",
"def test_next_valid\n\t prng = Minitest::Mock.new\n\t def prng.rand(num); 1; end\n\t\tcity = City.new(\"Fake City\", 7, 0, prng)\n\t\tcity1 = City.new(\"Fake City 1\", 7, 0, prng)\n\t\tcity2 = City.new(\"Fake City 2\", 7, 0, prng)\n\t\tcity.link_neighbors [city1, city2]\n\t\tcity = city.next\n\t\tassert_includes [city1, city2], city\n\tend",
"def test_get_all_cities\n \n test_map = ' { \"metros\" : [ {\n \"code\" : \"LON\" ,\n \"name\" : \"London\",\n \"country\" : \"X\" ,\n \"continent\" : \"X\" ,\n \"timezone\" : 1 ,\n \"coordinates\" : {\"N\" : 1, \"E\" : 1} ,\n \"population\" : 1,\n \"region\" : 1\n } , {\n \"code\" : \"PAR\" ,\n \"name\" : \"Paris\" ,\n \"country\" : \"X\" ,\n \"continent\" : \"X\" ,\n \"timezone\" : 1 ,\n \"coordinates\" : {\"N\" : 1, \"E\" : 1} ,\n \"population\" : 1,\n \"region\" : 1\n } , {\n \"code\" : \"LIM\" ,\n \"name\" : \"Lima\" ,\n \"country\" : \"X\" ,\n \"continent\" : \"X\" ,\n \"timezone\" : 1 ,\n \"coordinates\" : {\"N\" : 1, \"E\" : 1} ,\n \"population\" : 1,\n \"region\" : 1 \n } , {\n \"code\" : \"MOW\" ,\n \"name\" : \"Moscow\" ,\n \"country\" : \"X\" ,\n \"continent\" : \"X\" ,\n \"timezone\" : 1 ,\n \"coordinates\" : {\"N\" : 1, \"E\" : 1} ,\n \"population\" : 1,\n \"region\" : 1\n } ] ,\n \"routes\" : [ {\n \"ports\" : [\"LON\" , \"PAR\"] ,\n \"distance\" : 2410\n } , {\n \"ports\" : [\"LON\" , \"MOW\"] ,\n \"distance\" : 4323\n } , {\n \"ports\" : [\"LIM\" , \"PAR\"] ,\n \"distance\" : 4323\n } ] } '\n graph = Graph.new()\n graph.parse_json_string(test_map)\n \n result = graph.get_all_cities()\n \n assert_equal( result.scan(/[A-Z]*, [A-Z]{3}/).size, 4)\n assert_equal( result.include?(\"London, LON\"), true )\n assert_equal( result.include?(\"Moscow, MOW\"), true )\n assert_equal( result.include?(\"Lima, LIM\"), true )\n assert_equal( result.include?(\"Paris, PAR\"), true )\n \n end",
"def test_location_disconnect_other_connections_length_0\n @loc1.add_neighbor @loc2\n @loc1.disconnect @loc2\n assert_equal 0, @loc2.neighbors.length\n end",
"def test_location_disconnect_connections_length_0\n @loc1.add_neighbor @loc2\n @loc1.disconnect @loc2\n assert_equal 0, @loc1.neighbors.length\n end",
"def connect_nearby_herds\n\n end",
"def test_connectivity\n\t\t# Allow real requests.\n\t\tWebMock.allow_net_connect!\n\n\t\t# Initialize a new VLille service and load its status.\n\t\tvl = VLille.new\n\t\tvl.load()\n\n\t\t# Ensure there's something in the result.\n\t\tassert_not_nil vl.center_lat\n\t\tassert_not_nil vl.center_lng\n\t\tassert_not_nil vl.zoom_level\n\t\tassert vl.stations.size > 0\n\n\t\t# Load a station to check for emptiness.\n\t\tstation = vl.stations[0]\n\t\tassert_not_nil station.id\n\t\tassert_not_nil station.name\n\t\tassert_not_nil station.lat\n\t\tassert_not_nil station.lng\n\t\tassert_nil station.address\n\t\tassert_nil station.status\n\t\tassert_nil station.bikes\n\t\tassert_nil station.attachs\n\t\tassert_nil station.payment\n\t\tassert_nil station.last_update\n\n\t\t# Load the station and test we have some data now.\n\t\tstation.load\n\t\tassert_not_nil station.address\n\t\tassert_not_nil station.status\n\t\tassert_not_nil station.bikes\n\t\tassert_not_nil station.attachs\n\t\tassert_not_nil station.payment\n\t\tassert_not_nil station.last_update\n\n\t\t# Disallow real requests.\n\t\tWebMock.disable_net_connect!\n\tend",
"def test_monkey_patch_city\n initialize_map\n monkey_patch_city = @locations.get_location 'Monkey Patch City'\n assert_equal 'Monkey Patch City', monkey_patch_city.name_reader\n\n assert_equal 1, monkey_patch_city.max_real_reader\n assert_equal 1, monkey_patch_city.max_fake_reader\n\n assert_equal 'Enumerable Canyon', monkey_patch_city.neighbors_reader[0].name_reader\n assert_equal 'Matzburg', monkey_patch_city.neighbors_reader[1].name_reader\n assert_equal 'Nil Town', monkey_patch_city.neighbors_reader[2].name_reader\n end",
"def test_location_connections_length\n @loc1.add_neighbor @loc2\n @loc1.add_neighbor @loc3\n @loc1.add_neighbor @loc4\n\n assert_equal 3, @loc1.neighbors.length\n end",
"def test_street_connection\r\n\t\thillman = Location::new(\"Hillman\", \"Foo St.\", nil)\r\n\t\tassert_equal \"Foo St.\", hillman.street\r\n\tend",
"def test_connect_increments_neighbor_count\n @test_loc.connect @test_neighbor_list[0]\n assert_equal 1, @test_loc.neighbors.count\n end",
"def test_via_museum_hillman\r\n assert_equal 'Fifth Ave', @driver.via('Museum', 'Hillman')\r\n end",
"def test_get_another_id_for_angel\n # testing nevada has 4 connections [0--3]\n seed = 10\n prng = Random.new seed\n id = 1\n pros = Prospector.new id, prng\n map = Map.new\n pros.current_city = map.cities[1]\n\n 200.times do\n actual = pros.get_another_id prng, pros.current_city.connections.length\n assert_operator 2, :>=, actual\n assert_operator 0, :<=, actual\n end\n end",
"def test_location_already_connected\n @loc1.add_neighbor @loc2\n @loc1.add_neighbor @loc2\n assert_equal 1, @loc1.neighbors.count\n end",
"def test_can_change_siteurl\n @test1 = CinePassion.new()\n assert_equal(@test1.siteurl, \"http://scraper-cine-passion-demo.ledez.net\")\n @test2 = CinePassion.new(\"a-key\")\n assert_equal(@test2.siteurl, \"http://passion-xbmc.org\")\n @test2.defineOtherSiteURL(\"http://localhost:4567\")\n assert_equal(@test2.siteurl, \"http://localhost:4567\")\n @test2.defineOtherSiteURL()\n assert_equal(@test2.siteurl, \"http://passion-xbmc.org\")\n end",
"def city; end",
"def city; end",
"def cities\n CS.get :us, :ca\n end",
"def city; end",
"def city; end",
"def city; end",
"def city; end",
"def test_museum_start_location\r\n\t\trand_val = Minitest::Mock::new\r\n\t\toakland = City::new\r\n\t\tdef rand_val.get_start_location; 1; end\r\n\t\tstart_loc = oakland.all_locations[rand_val.get_start_location]\r\n\t\tassert_equal start_loc, \"Cathedral\"\r\n\tend",
"def find_state_for_city(cityName)\n @cities.each do |x, y|\n \ty.each do |z|\n\t\t\tif z == cityName\n\t\t\t\tputs \"That #{cityName} is part of a state called #{x}\"\n\t \tend\n\t end\n\tend\nend",
"def default_test\n seed = 10\n prng = Random.new seed\n id = 1\n pros = Prospector.new id, prng\n # Mock an array of connections\n city = Minitest::Mock.new('Mock Map')\n def city.connection\n ['mock city 1', 'mock city 2', 'mock city 3']\n end\n 200.times do\n actual = pros.get_another_id prng, city.connection.length\n assert_operator 3, :>=, actual\n assert_operator 0, :<=, actual\n end\n end",
"def add_latlon_cities(country_name, state_code, cities)\n country = Country.new(country_name)\n return cities if country.nil?\n\n state_name = country.states[state_code]['name'] unless country.nil?\n city_names = cities.map { |r| r[0] }\n locations = Hash[\n Place.where('\\'political\\' = ANY (types)')\n .where(state: state_name, country: country_name, name: city_names).map do |place|\n [place.name, [place.latitude, place.longitude, place.name]]\n end\n ]\n\n cities.map do |city|\n if locations.key?(city[0]) # If the city was found on the database\n locations[city[0]] + [city[1]]\n else\n points = Place.latlon_for_city(city[0], state_code, country_name)\n points + [city[0], city[1]] if points\n end\n end.compact\n end",
"def test_get_another_id_for_coloma\n seed = 10\n prng = Random.new seed\n id = 1\n pros = Prospector.new id, prng\n map = Map.new\n pros.current_city = map.cities[4]\n\n 200.times do\n actual = pros.get_another_id prng, pros.current_city.connections.length\n assert_operator 1, :>=, actual\n assert_operator 0, :<=, actual\n end\n end",
"def connectedCities(code)\r\n puts \"Connected Cities are\"\r\n results = connectedRoutes(code)\r\n results.sort{ |i,j| i[1].distance <=> j[1].distance}.each do |route|\r\n city = @vertex[route[1].ports.join.gsub(code,'')]\r\n puts \"#{city.name} (#{city.code}) : #{route[1].distance}\"\r\n end\r\n end",
"def test_location_self_disconnect\n @loc1.add_neighbor @loc2\n @loc1.disconnect @loc2\n refute @loc1.connected? @loc2\n end",
"def all_restaurants_in (city_name,&block)\n\t\tcount = 0\n\t\t@@memory[city_name] = {} if @@memory[city_name].nil?\n\t\t\n\t\treturn if (!has_city?(city_name)) || @@memory[city_name][:updated]\n\t\t\n\t\tzomato_city = city(city_name)\n\n\t\tsave_restaurant = -> restaurant {\n\t\t\tblock.call(restaurant)\n\t\t\tcount = count + 1\n\t\t}\n\t\t\n\t\trestaurants_in_locality = -> locality {\n\t\t\tlocality.restaurants.restaurants.each(&save_restaurant)\n\t\t}\n\t\t\n\t\tzomato_city.localities.each(&restaurants_in_locality)\n\t\tupdate_memory(city_name,count)\n\tend",
"def test_driver_setLocation_monroeville_downtown\n\t\t#testing downtown gives the same result as monroeville\n\t\td = Driver::new(\"Driver 1\",1)\n\t\td.setLocation 0\n\t\tassert_equal d.getLocation, -1\n\tend",
"def explore\n @center = Geocoder.coordinates(params[:city])\n @trips = Trip.nearest_with_index(@center) \n end",
"def test_location_connections_empty\n assert @loc1.neighbors.empty?\n end",
"def seed_locations\n\t\t\tOrganization.find_each do |organization|\n\t\t\t\tadd_two_locations(organization)\n\t\t\tend\n\t\tend",
"def test_fun_forward_path\n\t@city = GoldRush::new\n\tassert_equal nil, @city.angels.forward_path4\n\tassert_equal nil, @city.sutter.forward_path3\n\tassert_equal nil, @city.nevada.forward_path2\n end",
"def cities()\n sql = \"SELECT cities.* FROM cities WHERE country_id = $1\"\n values = [@id]\n cities = SqlRunner.run(sql, values)\n result = City.map_items(cities)\n return result\n end",
"def test_possible_location_from_hospital_if_rand_is_one\r\n\t\toakland = City::new\r\n\t\trand_val = 1\r\n\t\thillman = oakland.generate_hospital_locs(oakland, rand_val)\r\n\r\n\t\tassert_equal hillman[0], \"Hillman\"\r\n\t\tassert_equal hillman[1][0], \"Foo St.\"\r\n\tend",
"def test_location_creation\n location = Location.new({\"city\" => \"Omaha\"})\n location.insert(\"locations\") \n results = DATABASE.execute(\"SELECT city FROM locations WHERE id = #{location.id}\")\n \n added_location = results[0]\n \n assert_equal(1, results.length)\n assert_equal(\"Omaha\", added_location[\"city\"])\n end",
"def test_connections\n @doors.all? do |k, v|\n v[-1] ? v[-1].leads_to?(self.class, k): true\n end\n end",
"def test_disconnect_not_connected\n @loc1.add_neighbor @loc2\n @loc1.add_neighbor @loc3\n @loc1.disconnect @loc4\n\n assert_equal 2, @loc1.neighbors.length\n end",
"def test_driver_update_place\n\t\tloc1 = Location::new(\"Location\", [\"Place\"])\n\t\tdriv = Driver::new(1, loc1)\n\t\tloc2 = Location::new(\"Hogwarts\", [\"Place\"])\n\t\tdriv.update_place(loc2)\n\t\trefute_equal loc1, driv.get_place\n\tend",
"def hometown_generator\n city = @hometown_options.sample\n end",
"def test_valid_city_name\n answer = MapGraph.new\n assert_equal 6, answer.get_index_and_city_name('Dynamic Palisades')\n end",
"def multiple_places_in_city_from_beermapping(city)\n allow(BeermappingApi).to receive(:places_in).with(city).and_return(\n [ Place.new( name:\"Oljenkorsi\", id: 1),\n Place.new( name:\"Kello baari\", id: 2),\n Place.new( name:\"Hopeatuoppi\", id: 3)]\n )\nend",
"def test_move_turns_monkey_patch_city\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.turn=10\n ruby_rush.random(ruby_rush.seed)\n ruby_rush.move_turns_monkey_patch_city\n assert_includes ['Nil Town', 'Enumerable Canyon', 'Matzburg'], ruby_rush.city\n end"
] |
[
"0.6770048",
"0.65557903",
"0.64728314",
"0.62022567",
"0.6044166",
"0.5971957",
"0.59166145",
"0.5823278",
"0.57693213",
"0.5763808",
"0.57588565",
"0.57450837",
"0.5724179",
"0.57118154",
"0.5698426",
"0.56920874",
"0.5664725",
"0.5646683",
"0.56414545",
"0.5622036",
"0.56217444",
"0.5618745",
"0.5611563",
"0.56092685",
"0.5607598",
"0.557884",
"0.55762446",
"0.55630803",
"0.5554413",
"0.5538244",
"0.5534537",
"0.55250335",
"0.5524598",
"0.5522914",
"0.549479",
"0.54720986",
"0.546479",
"0.5463282",
"0.54631996",
"0.5453931",
"0.5448301",
"0.5440903",
"0.5437813",
"0.54360193",
"0.5433214",
"0.54283667",
"0.5421118",
"0.54200417",
"0.5414185",
"0.5409965",
"0.5401989",
"0.53874147",
"0.5377537",
"0.53592306",
"0.53570414",
"0.53543705",
"0.5351317",
"0.5342094",
"0.5341699",
"0.53378224",
"0.533478",
"0.5333989",
"0.5323837",
"0.53213984",
"0.53153557",
"0.5307753",
"0.5300742",
"0.5298527",
"0.52876204",
"0.5286097",
"0.52843076",
"0.52843076",
"0.5282838",
"0.5281856",
"0.5281856",
"0.5281856",
"0.5281856",
"0.5276091",
"0.5275317",
"0.52691245",
"0.52621776",
"0.52616763",
"0.5252343",
"0.52406406",
"0.52380973",
"0.5236346",
"0.52222717",
"0.52116627",
"0.5210068",
"0.51963276",
"0.5189211",
"0.5188607",
"0.5179085",
"0.51708853",
"0.5168185",
"0.51637125",
"0.51636267",
"0.5163047",
"0.51597655",
"0.515781"
] |
0.6878134
|
0
|
PUT /workout_templates/1 PUT /workout_templates/1.json
|
def update
@workout_template = WorkoutTemplate.find(params[:id])
respond_to do |format|
if @workout_template.update_attributes(params[:workout_template])
format.html { redirect_to @workout_template, notice: 'Workout template was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @workout_template.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_workout_template\n @workout_template = WorkoutTemplate.find(params[:id])\n end",
"def workout_template_params\n # params.require(:workout_template).permit(:title, :isTemplate, :boolean, :exerciseCount, :user_id,:id)\n params .permit(:title, :isTemplate, :boolean, :exerciseCount, :user_id,:id)\n end",
"def update\n @template_shift = TemplateShift.find(params[:id])\n\n respond_to do |format|\n if @template_shift.update_attributes(params[:template_shift])\n format.html { redirect_to @template_shift, notice: 'Template shift was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @template_shift.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @mytemplate = Mytemplate.get(params[:id])\n \n @mytemplate.name = params[:mytemplate][:name]\n @mytemplate.folder = params[:mytemplate][:folder]\n @mytemplate.description = params[:mytemplate][:description]\n \n respond_to do |format|\n if @mytemplate.save\n format.html { redirect_to mytemplates_path }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @mytemplate.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def destroy\n @workout_template = WorkoutTemplate.find(params[:id])\n @workout_template.destroy\n\n respond_to do |format|\n format.html { redirect_to workout_templates_url }\n format.json { head :no_content }\n end\n end",
"def update\n @exercise_template = ExerciseTemplate.find(params[:id])\n\n if @exercise_template.update(exercise_template_params)\n head :no_content\n else\n render json: @exercise_template.errors, status: :unprocessable_entity\n end\n end",
"def orgn_template_update\n @event.template_id = params[:template_id]\n\n if !params[:template_id]\n #redirect_to orgn_template_events_path, :flash => { :error => 'Select a template.' }\n flash[:alert] = 'Select a template.'\n render :action => :orgn_template\n return\n end\n \n @event.template_id = @event.template_id\n \n respond_to do |format|\n if @event.update(template_params)\n format.html { redirect_to event_invite_events_path }\n format.json { head :no_content }\n else\n format.html { redirect_to event_invite_events_path }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @my_template.update(my_template_params)\n format.html { redirect_to @my_template, notice: 'My template was successfully updated.' }\n format.json { render :show, status: :ok, location: @my_template }\n else\n format.html { render :edit }\n format.json { render json: @my_template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if cannot? :update, @workout\n redirect_to root_path,\n notice: 'Unauthorized to update workout' and return\n end\n\n workout_offering_id = create_or_update\n @workout.save!\n if workout_offering_id.nil?\n url = url_for(workout_path(id: @workout.id))\n else\n url = url_for(organization_workout_offering_path(\n organization_id: params[:organization_id],\n term_id: params[:term_id],\n course_id: params[:course_id],\n id: workout_offering_id\n )\n )\n end\n\n respond_to do |format|\n format.json { render json: { url: url } }\n end\n end",
"def update\n owner = @workout.owner\n unless owner == current_user or owner == temp_user\n redirect_to \"/\", alert: \"Permission Denied.\"\n end\n @workout.update(workout_params)\n @workout.exercises.destroy_all\n\n ex_params = exercise_params[:exercise].map do |e|\n e[:dur] = e[:dur][:minutes].to_i*60 + e[:dur][:seconds].to_i\n e[:workout_id] = @workout.id\n e\n end\n @exercises = @workout.exercises.create(ex_params)\n \n respond_to do |format|\n if @workout.save\n format.html { redirect_to @workout, notice: 'Workout was successfully updated.' }\n format.json { render json: {workoutId: @workout.id}, status: 200 }\n else\n format.html { render :edit }\n format.json { render json: @workout.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @project_template = ProjectTemplate.find(params[:id])\n\n respond_to do |format|\n if @project_template.update_attributes(params[:project_template])\n format.html { redirect_to @project_template, notice: 'Project template was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project_template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(name, html_url, zip_url, screenshot_url)\n options = { :body => { \n :Name => name,\n :HtmlPageURL => html_url,\n :ZipFileURL => zip_url,\n :ScreenshotURL => screenshot_url }.to_json }\n response = CreateSend.put \"/templates/#{template_id}.json\", options\n end",
"def update!(**args)\n @kind = args[:kind] if args.key?(:kind)\n @status = args[:status] if args.key?(:status)\n @template_content = args[:template_content] if args.key?(:template_content)\n @template_name = args[:template_name] if args.key?(:template_name)\n @template_type = args[:template_type] if args.key?(:template_type)\n end",
"def update\n params[:workout][:workout_date] = \"#{params[:workout][:workout_date]} #{params[:workout][:time]}\"\n params[:workout] = params[:workout].slice(:workout_date, :exercises_attributes)\n @lift_name = params[:workout][:exercises_attributes][\"0\"][:lift_id]\n params[:workout][:exercises_attributes][\"0\"][:lift_id] = Lift.find_by_lift_name(@lift_name).id\n @workout = Workout.find(params[:id])\n\n respond_to do |format|\n if @workout.update_attributes(params[:workout])\n format.html { redirect_to @workout, notice: 'Workout was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @workout.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n current_site.grid_templates.find(params[:id]).update(params.require(:grid_template).permit(:name, :description))\n index\n end",
"def update\n respond_to do |format|\n if @issue_template.update(issue_template_params)\n format.html { redirect_to issue_templates_path, notice: 'Issue template was successfully updated.' }\n else\n format.html { redirect_to issue_templates_path, alert: issue_template.errors }\n end\n end\n end",
"def update\n update_elements if elements_params.present?\n @template.update(name: template_params[:name]) if template_params[:name].present?\n\n if @template.errors.empty?\n render :show, status: :ok, location: @template\n else\n render json: @template.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @request_template.update(request_template_params)\n respond format, 'Request template was successfully updated.'\n else\n format.html { render :edit }\n format.json { render json: @request_template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @custom_template.update custom_template_params\n redirect_to @custom_template\n else\n render 'edit'\n end\n end",
"def update\n respond_to do |format|\n if @inspection_template.update(inspection_template_params)\n format.html { redirect_to @inspection_template, notice: 'Inspection template was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @inspection_template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @induction_template.update(induction_template_params)\n format.html { redirect_to @induction_template, notice: 'Induction template was successfully updated.' }\n format.json { render :show, status: :ok, location: @induction_template }\n else\n format.html { render :edit }\n format.json { render json: @induction_template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n puts template_params\n respond_to do |format|\n if @template.update(template_params)\n format.html { redirect_to @template, notice: 'Template was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_templates(name, templates)\n raise('wrong type: String required') unless name.is_a?(String)\n raise('wrong value: name must be valid') unless !name.nil? && !name.empty?\n raise('wrong type: String required') unless templates.is_a?(String)\n raise('wrong value: templates must be valid') unless !templates.nil? && !templates.empty?\n\n @client.post({\n 'action' => 'settemplate',\n 'object' => 'htpl',\n 'values' => '%s;%s' % [name, templates],\n }.to_json)\n end",
"def update\n respond_to do |format|\n if @event_template.update(event_template_params)\n format.html { redirect_to @event_template, notice: \"Event template was successfully updated.\" }\n format.json { render :show, status: :ok, location: @event_template }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @event_template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item_template.update(item_template_params)\n format.html { redirect_to @item_template, notice: 'Item template was successfully updated.' }\n format.json { render :show, status: :ok, location: @item_template }\n else\n format.html { render :edit }\n format.json { render json: @item_template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @_template = @site.templates.find(params[:id])\n @_template.updated_by = current_user\n\n respond_to do |format|\n if @_template.update_attributes(params[:template])\n flash[:notice] = \"Template was successfully updated.\"\n format.html { redirect_to([:admin, @site, @_template]) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @_template.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @widget_template = WidgetTemplate.find(params[:id]) \n @widget_template.classtype = params[:widget_template][:classtype]\n @widget_template.name = params[:widget_template][:name]\n respond_to do |format|\n \n if @widget_template.save\n format.html { redirect_to @widget_template, notice: 'widget_template was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @widget_template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @track_template.update(track_template_params)\n format.html { redirect_to @track_template, notice: 'Track template was successfully updated.' }\n format.json { render :show, status: :ok, location: @track_template }\n else\n format.html { render :edit }\n format.json { render json: @track_template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @survey_template.update(survey_template_params)\n format.html { redirect_to @survey_template, notice: 'Template was successfully updated.' }\n format.json { render :show, status: :ok, location: @survey_template }\n else\n @record = @survey_template\n format.html { render :edit }\n format.json { render json: @survey_template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @mail_template = MailTemplate.find_by_id(params[:id])\n if @mail_template.update_attributes(mail_template_params)\n flash[:success] = \"Workshop was successfully updated.\"\n redirect_to edit_workshop_path(@mail_template.workshop)\n else\n render action: 'edit'\n end\n end",
"def create\n @template_shift = TemplateShift.new(params[:template_shift])\n\n respond_to do |format|\n if @template_shift.save\n format.html { redirect_to @template_shift, notice: 'Template shift was successfully created.' }\n format.json { render json: @template_shift.to_json(:include=>[:shift_type]), status: :created, location: @template_shift }\n else\n format.html { render action: \"new\" }\n format.json { render json: @template_shift.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize! :manage, :all\n respond_to do |format|\n if @question_template.update(question_template_params)\n format.html do redirect_to question_template_path(@question_template),\n notice: 'Question template was successfully updated.'\n end\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @question_template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @survey_item_template.update(survey_item_template_params)\n format.html { redirect_to @survey_item_template.survey_item_category_template.survey_template, notice: 'Survey item template was successfully updated.' }\n format.json { render :show, status: :ok, location: @survey_item_template }\n else\n format.html { render :edit }\n format.json { render json: @survey_item_template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @wit.update(wit_params)\n format.html { redirect_to @wit, notice: 'Wit was successfully updated.' }\n format.json { render :show, status: :ok, location: @wit }\n else\n format.html { render :edit }\n format.json { render json: @wit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n \n if @question_template.update(question_template_params)\n format.html { redirect_to @question_template, notice: 'Question template was successfully updated.' }\n format.json { render :show, status: :ok, location: @question_template }\n else\n format.html { render :edit }\n format.json { render json: @question_template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @template.update(template_params)\n format.html { redirect_to email_templates_path, notice: 'template was successfully updated.' }\n format.json { render :show, status: :ok, location: @template }\n else\n format.html { render :edit }\n format.json { render json: @template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @questionnaire_template.update(questionnaire_template_params)\n format.html { redirect_to @questionnaire_template, notice: 'questionnaire template was successfully updated.' }\n format.json { render :show, status: :ok, location: @questionnaire_template }\n else\n format.html { render :edit }\n format.json { render json: @questionnaire_template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item_template.update(item_template_params)\n format.html { redirect_to @item_template, notice: 'Item Template was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @item_template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_template\n self.template = \"template 14231\"\n end",
"def update\n respond_to do |format|\n if meeting_template.save\n format.html { redirect_to( meeting_template, flash: { success: \"Meeting template updated.\" } ) }\n format.xml { head :ok }\n else\n format.html { render action: \"edit\" }\n format.xml { render xml: meeting_template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @quest_template = QuestTemplate.find(params[:id])\n\n respond_to do |format|\n if @quest_template.update_attributes(params[:quest_template])\n flash[:notice] = 'QuestTemplate was successfully updated.'\n format.html { redirect_to(@quest_template) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @quest_template.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @workout.update(workout_params)\n format.html { redirect_to @workout, notice: t('flash_message.notice.successfully_updated', model: Workout.model_name.human) }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @workout.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @template.update(template_params)\n format.html { redirect_to template_path(@template), notice: 'Template was successfully updated.' }\n format.json { render :show, status: :ok, location: @template }\n else\n format.html { render :edit }\n format.json { render json: @template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @script_template.update(script_template_params)\n format.html { redirect_to script_template_url(@script_template), notice: \"Script template was successfully updated.\" }\n format.json { render :show, status: :ok, location: @script_template }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @script_template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @node_template = NodeTemplate.find(params[:id])\n\n respond_to do |format|\n if @node_template.update_attributes(params[:node_template])\n format.html { redirect_to @node_template, notice: 'Node template was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @node_template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update \n respond_to do |format|\n if @template.update(template_params)\n format.html { redirect_to @template, notice: 'Template was successfully updated.' }\n format.json { render :show, status: :ok, location: @template }\n else\n format.html { render :edit }\n format.json { render json: @template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @user_workout.update(user_workout_params)\n format.html { redirect_to @user_workout, notice: 'User workout was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @user_workout.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_template_files(opts)\n template_id = opts.delete(:template_id)\n path = \"/template/update_files/#{template_id}\"\n prepare_files opts\n\n HelloSign::Resource::Template.new post(path, body: opts)\n end",
"def update\n respond_to do |format|\n if @template.update(template_params)\n format.html { redirect_to @template, notice: 'Template was successfully updated.' }\n format.json { render :show, status: :ok, location: @template }\n else\n format.html { render :edit }\n format.json { render json: @template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @template.update(template_params)\n format.html { redirect_to @template, notice: 'Template was successfully updated.' }\n format.json { render :show, status: :ok, location: @template }\n else\n format.html { render :edit }\n format.json { render json: @template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @template.update(template_params)\n format.html { redirect_to @template, notice: 'Template was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(name, html_url, zip_url)\n options = { :body => {\n :Name => name,\n :HtmlPageURL => html_url,\n :ZipFileURL => zip_url }.to_json }\n put \"/templates/#{template_id}.json\", options\n end",
"def update\n respond_to do |format|\n if @timetable_template.update(timetable_template_params)\n format.js { render nothing: true }\n format.html { redirect_to @timetable_template, notice: 'Timetable template was successfully updated.' }\n format.json { render :show, status: :ok, location: @timetable_template }\n else\n format.js { render inline: \"window.location.replace(\\\"<%= escape_javascript(edit_timetable_template_path(@timetable_template)) %>\\\");\", type: :js }\n format.html { render :edit }\n format.json { render json: @timetable_template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @doc_template.update(doc_template_params)\n format.html { redirect_to @doc_template, notice: 'Doc template was successfully updated.' }\n format.json { render :show, status: :ok, location: @doc_template }\n else\n format.html { render :edit }\n format.json { render json: @doc_template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @invitation_template.update(invitation_template_params)\n format.html { redirect_to @invitation_template, notice: 'Invitation template was successfully updated.' }\n format.json { render :show, status: :ok, location: @invitation_template }\n else\n format.html { render :edit }\n format.json { render json: @invitation_template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @workout_routine.update(workout_routine_params)\n format.html { redirect_to @workout_routine, notice: 'Workout routine was successfully updated.' }\n format.json { render :show, status: :ok, location: @workout_routine }\n else\n format.html { render :edit }\n format.json { render json: @workout_routine.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @myworkout = Myworkout.find(params[:id])\n\n respond_to do |format|\n if @myworkout.update_attributes(params[:myworkout])\n format.html { redirect_to @myworkout, :notice => 'Myworkout was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @myworkout.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update(id, values, update_published = false)\n @client.call(method: :put, path: \"templates/#{id}\", body_values: values, query_values: { update_published: update_published })\n end",
"def update\n if @template.update(template_params)\n handle_save_success @template, :ok, t('templates.update_success')\n else\n handle_save_error @template.errors, :edit\n end\n end",
"def update\n @template = Template.find(params[:id])\n\n respond_to do |format|\n if @template.update_attributes(params[:template])\n format.html { redirect_to @template, notice: 'Template was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_my_template\n @my_template = MyTemplate.find(params[:id])\n end",
"def set_template\n @template = Spree::Template.find(params[:id])\n # puts \"ddsfsfsdfsdf\",@template.inspect\n # puts \"ddsfsfsdfsdf\",@template.inspect\n # put\n end",
"def update\n respond_to do |format|\n if @workout.update(workout_params)\n format.html { redirect_to @workout, notice: 'Workout was successfully updated.' }\n format.json { render :show, status: :ok, location: @workout }\n else\n format.html { render :edit }\n format.json { render json: @workout.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @job_templates = args[:job_templates] if args.key?(:job_templates)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n @unreachable = args[:unreachable] if args.key?(:unreachable)\n end",
"def update\n @template = CustomTemplate.find(params[:id])\n\n respond_to do |format|\n if @template.update_attributes(params[:template])\n\t\tformat.html { redirect_to(\"/custom_templates/\" + @template.id.to_s + \"/edit\", :notice => 'CustomTemplate was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @template.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n # debugger\n # TODO: Clean up this params mess and make sure workouts#update allows multiple lift edit\n # TODO: Editing workouts should allow you to update workouts\n # TODO: Switch times to local time\n # set_workout_date(params)\n # remove_workout_time(params)\n # set_lift_ids(params)\n\n # user selects lift\n # JavaScript then uses lift name and gets lift ID\n # from JSON\n # send lift ID over to controller\n # http://railscasts.com/episodes/258-token-fields-revised?\n @workout = current_user.workouts.build(params[:workout])\n\n respond_to do |format|\n if @workout.save\n flash[:success] = \"Workout created\"\n format.html { redirect_to workouts_path, notice: \"Workout was successfully created.\" }\n format.json { render json: @workout, status: :created, location: @workout }\n else\n format.html { render action: \"new\" }\n format.json { render json: @workout.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_timetable_template\n @timetable_template = TimetableTemplate.find(params[:id])\n end",
"def update\n @goaltemplate = Goaltemplate.find(params[:id])\n\n respond_to do |format|\n if @goaltemplate.update_attributes(params[:goaltemplate])\n flash[:notice] = 'Goaltemplate was successfully updated.'\n format.html { redirect_to(@goaltemplate) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @goaltemplate.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @meal_template.update(meal_template_params)\n format.html { redirect_to @meal_template, notice: 'Meal template was successfully updated.' }\n format.json { render :show, status: :ok, location: @meal_template }\n else\n format.html { render :edit }\n format.json { render json: @meal_template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @workout.update(workout_params)\n format.html { redirect_to @workout, notice: \"Workout was successfully updated.\" }\n format.json { render :show, status: :ok, location: @workout }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @workout.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @template_task = TemplateTask.find(params[:id])\n\n respond_to do |format|\n if @template_task.update_attributes(permitted_params_for_template_task)\n format.html { redirect_to template_tasks_path, notice: 'TemplateTask was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @template_task.errors, status: :unprocessable_entity }\n end\n end\n end",
"def save_template(template_name, template_fields)\n data = template_fields\n data[:template] = template_name\n self.api_post(:template, data)\n end",
"def set_workout\n @workout = Workout.find(params[:id])\n end",
"def set_workout\n @workout = Workout.find(params[:id])\n end",
"def set_workout\n @workout = Workout.find(params[:id])\n end",
"def update\n @workout = Workout.find(params[:id])\n\n respond_to do |format|\n if @workout.update_attributes(params[:workout])\n flash[:alert] = 'Workout was successfully updated.'\n format.html { redirect_to @workout }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @workout.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @clientworkout.update(clientworkout_params)\n format.html { redirect_to @clientworkout, notice: 'Clientworkout was successfully updated.' }\n format.json { render :show, status: :ok, location: @clientworkout }\n else\n format.html { render :edit }\n format.json { render json: @clientworkout.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @page_template = PageTemplate.find(params[:id])\n\n respond_to do |format|\n if @page_template.update_attributes(params[:page_template])\n format.html { redirect_to @page_template, notice: 'Page template was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @page_template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @gift_template = GiftTemplate.find(params[:id])\n\n respond_to do |format|\n if @gift_template.update_attributes(params[:gift_template])\n format.html { redirect_to gift_templates_path, notice: 'Gift template was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @gift_template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @post_template.update(post_template_params)\n format.html { redirect_to @post_template, notice: 'Post template was successfully updated.' }\n format.json { render :show, status: :ok, location: @post_template }\n else\n format.html { render :edit }\n format.json { render json: @post_template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @invoice_template = InvoiceTemplate.find(params[:id])\n\n respond_to do |format|\n if @invoice_template.update_attributes(params[:invoice_template])\n format.html { redirect_to @invoice_template, notice: 'Invoice template was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @invoice_template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_course_template(org_unit_id, new_data)\n # Define a valid, empty payload and merge! with the new data.\n payload = {\n 'Name' => '', # String\n 'Code' => 'off_SEMESTERCODE_STARNUM', # String\n }.merge!(new_data)\n puts \"Updating course template #{org_unit_id}\"\n check_course_template_updated_data_validity(payload)\n # ap payload\n # requires: CourseTemplateInfo JSON block\n # Define a path referencing the courses path\n path = \"/d2l/api/lp/#{$lp_ver}/coursetemplates/\" + org_unit_id.to_s\n _put(path, payload)\n puts '[+] Course template update completed successfully'.green\nend",
"def update\n respond_to do |format|\n if @docu_template.update(docu_template_params)\n format.html { redirect_to @docu_template, notice: 'Docu sign was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @docu_template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @inventory_template = InventoryTemplate.find(params[:id])\n # @inventory_template.restaurant = current_owner.restaurant\n\n respond_to do |format|\n if @inventory_template.update_attributes(params[:inventory_template])\n format.html { redirect_to @inventory_template, notice: 'Inventory template was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @inventory_template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @admin_kpi_template = Admin::KpiTemplate.find(params[:id])\n\n respond_to do |format|\n if @admin_kpi_template.update_attributes(params[:admin_kpi_template])\n format.html { redirect_to @admin_kpi_template, notice: 'Kpi template was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @admin_kpi_template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @workout_set = WorkoutSet.find(params[:id])\n\n respond_to do |format|\n if @workout_set.update_attributes(params[:workout_set])\n format.html { redirect_to @workout_set, notice: 'Workout set was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @workout_set.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @newsletters_template = Newsletters::Template.find(params[:id])\n\n respond_to do |format|\n if @newsletters_template.update_attributes(params[:newsletters_template])\n format.html { redirect_to @newsletters_template, notice: 'Template was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @newsletters_template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_workflow_template request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_update_workflow_template_request request_pb\n query_string_params = if query_string_params.any?\n query_string_params.to_h { |p| p.split \"=\", 2 }\n else\n {}\n end\n\n response = @client_stub.make_http_request(\n verb,\n uri: uri,\n body: body || \"\",\n params: query_string_params,\n options: options\n )\n operation = ::Gapic::Rest::TransportOperation.new response\n result = ::Google::Cloud::Dataproc::V1::WorkflowTemplate.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end",
"def update\n\n respond_to do |format|\n if @email_template.update(email_template_params)\n format.html { redirect_to email_templates_path, notice: 'Email template was successfully updated.' }\n format.json { render :show, status: :ok, location: @email_template }\n else\n format.html { render :edit }\n format.json { render json: @email_template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize @service_template\n\n respond_to do |format|\n if @service_template.update(service_template_params)\n format.html { redirect_to service_template_path(@service_template), notice: 'Service template was successfully updated.' }\n format.json { render :show, status: :ok, location: @service_template }\n else\n format.html { render :edit }\n format.json { render json: @service_template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def template_update(id, type, filename)\n check_id_or_raise id\n check_template_type_or_raise type\n check_filename_or_raise filename\n response = http_request_multipart :put, @base_url + \"/templates/#{id}.xml\", 200,\n { :provider_key => @provider_key,\n :draft => File.read(filename), \n :multipart => true}\n puts 'at update call'\n _id, _updated_at = parse_response response, type\n response = http_request :put, \"#{@base_url}/templates/#{id}/publish\", 200,\n { :params => { :provider_key => @provider_key } }\n puts 'at publish call'\n parse_response response, 'page'\n end",
"def update\n respond_to do |format|\n \n #@template.creator = current_user.id\n if @template.update(template_params)\n @template.creator=current_user.id\n @template.save\n format.html { redirect_to @template, notice: 'Template was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @print_template.update(print_template_params)\n format.html { redirect_to print_templates_path(type: @print_template.template_type), notice: 'Print template was successfully updated.' }\n format.json { render :show, status: :ok, location: @print_template }\n else\n format.html { render :edit }\n format.json { render json: @print_template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_issue_template\n @issue_template = IssueTemplate.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @datatemplate.update(datatemplate_params)\n format.html { redirect_to [@company,@template], notice: 'Template was successfully updated.' }\n format.json { render :show, status: :ok, location: @template }\n else\n format.html { render :edit }\n format.json { render json: @datatemplate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @review_template.update(review_template_params)\n format.html { redirect_to @review_template, notice: 'Review template was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @review_template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @templates = @firm.templates\n @template = Template.new\n end",
"def update\n @client_workout = ClientWorkout.find(params[:id])\n\n respond_to do |format|\n if @client_workout.update_attributes(params[:client_workout])\n format.html { redirect_to @client_workout, notice: 'Client workout was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @client_workout.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n restricted\n respond_to do |format|\n if @template.update(template_params)\n format.html { redirect_to @template, notice: 'Template was successfully updated.' }\n format.json { render :show, status: :ok, location: @template }\n else\n format.html { render :edit }\n format.json { render json: @template.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @template_shift = TemplateShift.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @template_shift }\n end\n end"
] |
[
"0.7166186",
"0.62536865",
"0.62524974",
"0.62363636",
"0.6178014",
"0.6150158",
"0.5980344",
"0.59165096",
"0.5878204",
"0.5869198",
"0.5859482",
"0.5850555",
"0.5828405",
"0.58210343",
"0.578458",
"0.5782863",
"0.5777991",
"0.5773472",
"0.5736808",
"0.5723785",
"0.5718111",
"0.5699903",
"0.56893104",
"0.56889445",
"0.56754375",
"0.5675029",
"0.56730723",
"0.56668776",
"0.5653448",
"0.56518376",
"0.5647809",
"0.5646002",
"0.56445205",
"0.5632553",
"0.56263775",
"0.56259125",
"0.55892235",
"0.5588571",
"0.5577179",
"0.557637",
"0.5571132",
"0.5564081",
"0.5563617",
"0.5563601",
"0.55578774",
"0.55575395",
"0.55545473",
"0.5554337",
"0.5553887",
"0.5553887",
"0.5552948",
"0.5547563",
"0.5541507",
"0.55404496",
"0.5536864",
"0.5532364",
"0.5525458",
"0.5520602",
"0.55143213",
"0.55013525",
"0.5499117",
"0.54871494",
"0.5479524",
"0.5478491",
"0.54737616",
"0.5469949",
"0.5466012",
"0.54595125",
"0.54590267",
"0.5452189",
"0.5450505",
"0.5446446",
"0.54343146",
"0.54343146",
"0.54343146",
"0.54299945",
"0.54299223",
"0.54282886",
"0.54251635",
"0.5423458",
"0.5416683",
"0.54162127",
"0.54136664",
"0.5412023",
"0.5409681",
"0.5407521",
"0.54002964",
"0.5398345",
"0.5393492",
"0.53923225",
"0.5390271",
"0.5387479",
"0.53825235",
"0.53729445",
"0.5370895",
"0.5367599",
"0.5364385",
"0.5353853",
"0.5349307",
"0.53345066"
] |
0.7241972
|
0
|
DELETE /workout_templates/1 DELETE /workout_templates/1.json
|
def destroy
@workout_template = WorkoutTemplate.find(params[:id])
@workout_template.destroy
respond_to do |format|
format.html { redirect_to workout_templates_url }
format.json { head :no_content }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def delete\n super \"/templates/#{template_id}.json\", {}\n end",
"def destroy\n @inspection_template.destroy\n respond_to do |format|\n format.html { redirect_to inspection_templates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @template_shift = TemplateShift.find(params[:id])\n @template_shift.destroy\n\n respond_to do |format|\n format.html { redirect_to template_shifts_url }\n format.json { head :no_content }\n end\n end",
"def delete_course_template(org_unit_id)\n path = \"/d2l/api/lp/#{$lp_ver}/coursetemplates/#{org_unit_id}\"\n _delete(path)\n puts '[+] Course template data deleted successfully'.green\nend",
"def destroy\n @project_template = ProjectTemplate.find(params[:id])\n @project_template.destroy\n\n respond_to do |format|\n format.html { redirect_to project_templates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @survey_template.destroy\n respond_to do |format|\n format.html { redirect_to organization_survey_templates_url(@organization), notice: 'Survey was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @goaltemplate = Goaltemplate.find(params[:id])\n @goaltemplate.destroy\n\n respond_to do |format|\n format.html { redirect_to(goaltemplates_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @template.destroy\n respond_to do |format|\n format.html { redirect_to templates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @exercise_template.destroy\n\n head :no_content\n end",
"def destroy\n @docu_template.destroy\n respond_to do |format|\n format.html { redirect_to docu_templates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @my_template.destroy\n respond_to do |format|\n format.html { redirect_to my_templates_url, notice: 'My template was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @induction_template.destroy\n respond_to do |format|\n format.html { redirect_to induction_templates_url, notice: 'Induction template was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item_template.destroy\n respond_to do |format|\n format.html { redirect_to item_templates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @invoice_template = InvoiceTemplate.find(params[:id])\n @invoice_template.destroy\n\n respond_to do |format|\n format.html { redirect_to invoice_templates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @custom_template.destroy\n redirect_to custom_templates_url\n end",
"def destroy\n @meal_template.destroy\n respond_to do |format|\n format.html { redirect_to meal_templates_url, notice: 'Meal template was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete(options={})\n DNSimple::Client.delete \"templates/#{id}\", options\n end",
"def destroy\n @custom_pet_template.destroy\n respond_to do |format|\n format.html { redirect_to custom_pet_templates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @workout.destroy\n respond_to do |format|\n format.html { redirect_to workouts_url }\n format.json { head :no_content }\n end\n end",
"def delete\n response = CreateSend.delete \"/templates/#{template_id}.json\", {}\n end",
"def destroy\n @inventory_template = InventoryTemplate.find(params[:id])\n @inventory_template.destroy\n\n respond_to do |format|\n format.html { redirect_to inventory_templates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client_workout = ClientWorkout.find(params[:id])\n @client_workout.destroy\n\n respond_to do |format|\n format.html { redirect_to client_workouts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admin_kpi_template = Admin::KpiTemplate.find(params[:id])\n @admin_kpi_template.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_kpi_templates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @template = Template.find(params[:id])\n @template.destroy\n\n respond_to do |format|\n format.html { redirect_to templates_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @admin_template = Template.find(params[:id])\n @admin_template.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_templates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @gift_template = GiftTemplate.find(params[:id])\n @gift_template.destroy\n\n respond_to do |format|\n format.html { redirect_to gift_templates_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n @myworkout = Myworkout.find(params[:id])\n @myworkout.destroy\n\n respond_to do |format|\n format.html { redirect_to myworkouts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @crawler_template = CrawlerTemplate.find(params[:id])\n @crawler_template.destroy\n\n respond_to do |format|\n format.html { redirect_to crawler_templates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @questionnaire_template.destroy\n respond_to do |format|\n format.html { redirect_to questionnaire_templates_url, notice: 'questionnaire template was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @template = set_template\n @template.destroy\n respond_to do |format|\n format.html { redirect_to templates_url, notice: 'Template was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @page_template = PageTemplate.find(params[:id])\n @page_template.destroy\n\n respond_to do |format|\n format.html { redirect_to page_templates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @purchase_template = PurchaseTemplate.find(params[:id])\n @purchase_template.destroy\n\n respond_to do |format|\n format.html { redirect_to purchase_templates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @show_template.destroy\n respond_to do |format|\n format.html { redirect_back_to show_templates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @node_template = NodeTemplate.find(params[:id])\n @node_template.destroy\n\n respond_to do |format|\n format.html { redirect_to node_templates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @newsletters_template = Newsletters::Template.find(params[:id])\n @newsletters_template.destroy\n\n respond_to do |format|\n format.html { redirect_to newsletters_templates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @workout = Workout.find(params[:id])\n @workout.destroy\n\n respond_to do |format|\n format.html { redirect_to workouts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n authorize! :manage, :all\n @question_template.destroy\n respond_to do |format|\n format.html { redirect_to question_templates_url, notice: 'Question template was successfully removed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @template_task = TemplateTask.find(params[:id])\n @template_task.destroy\n\n respond_to do |format|\n format.html { redirect_to template_tasks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @_template = @site.templates.find(params[:id])\n @_template.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_site_templates_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @attr_template.destroy\n respond_to do |format|\n format.html { redirect_to attr_templates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n mytemplate = Mytemplate.get(params[:id])\n close_document(mytemplate)\n \n begin\n if mytemplate != nil\n if File.exist?(mytemplate.path) \n FileUtils.rm_rf mytemplate.path\n end\n \n if File.exist?(mytemplate.file_path+mytemplate.id.to_s) \n FileUtils.rm_rf mytemplate.file_path+mytemplate.id.to_s\n end\n\n end\n rescue\n puts_message \"Error! in progress of mytemplate file deletion.\"\n end\n\n mytemplate.destroy\n \n respond_to do |format|\n format.html { redirect_to(mytemplates_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @howitwork.destroy\n respond_to do |format|\n format.html { redirect_to admin_howitworks_url, notice: 'Howitwork was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item_template.destroy\n respond_to do |format|\n format.html { redirect_to item_templates_url, notice: 'Item template was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @issue_template.destroy\n respond_to do |format|\n format.html { redirect_to issue_templates_url, notice: 'Issue template was successfully destroyed.' }\n end\n end",
"def destroy\n @review_template.destroy\n respond_to do |format|\n format.html { redirect_to review_templates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @emailtemplate.destroy\n respond_to do |format|\n format.html { redirect_to email_templates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @clientworkout.destroy\n respond_to do |format|\n format.html { redirect_to clientworkouts_url, notice: 'Clientworkout was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @nagios_service_escalation_template = NagiosServiceEscalationTemplate.find(params[:id])\n @nagios_service_escalation_template.destroy\n\n respond_to do |format|\n format.html { redirect_to(nagios_service_escalation_templates_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @template = CustomTemplate.find(params[:id])\n\t @template_studies = StudyTemplate.where(:template_id => @template.id).all\n\t for ts in @template_studies\n\t \tts.destroy\n\t end\n\t\t@template_columns = OutcomeColumn.where(:template_id => @template.id).all\n\t\tfor tc in @template_columns\n\t\t\ttc.destroy\n\t\tend\n @template.destroy\n\n respond_to do |format|\n format.html { \n\t\t\t\tunless params[:from] == 'home'\t\n \t\trender :update do |page|\n\t\t\t\t\t\tpage.reload\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\tredirect_to root_url\n\t\t\t\tend\n\t \t}\n format.xml { head :ok }\n end\n end",
"def destroy\n @invitation_template.destroy\n respond_to do |format|\n format.html { redirect_to invitation_templates_url, notice: 'Invitation template was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @template.destroy\n respond_to do |format|\n format.html { redirect_to email_templates_path, notice: 'template was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @template.destroy\n respond_to do |format|\n format.html { redirect_to templates_url, notice: 'Template was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @template.destroy\n respond_to do |format|\n format.html { redirect_to templates_url, notice: 'Template was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @template.destroy\n respond_to do |format|\n format.html { redirect_to templates_url, notice: 'Template was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @quest_template = QuestTemplate.find(params[:id])\n \n begin\n @quest_template.quest_giver.destroy\n @quest_template.quest_involver.destroy\n rescue Exception => e\n end\n @quest_template.destroy\n\n respond_to do |format|\n format.html { redirect_to(quest_templates_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n survey_template = @survey_item_template.survey_item_category_template.survey_template\n @survey_item_template.destroy\n respond_to do |format|\n format.html { redirect_to polymorphic_path([survey_template.surveyable, survey_template]), notice: 'Survey item template was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @doc_template.destroy\n respond_to do |format|\n format.html { redirect_to doc_templates_url, notice: 'Doc template was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @coach_template = CoachTemplate.find(params[:id])\n @coach_template.destroy\n\n respond_to do |format|\n format.html { redirect_to(coach_templates_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @workout_routine.destroy\n respond_to do |format|\n format.html { redirect_to workout_routines_url, notice: 'Workout routine was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @question_template.destroy\n respond_to do |format|\n format.html { redirect_to question_templates_url, notice: 'Question template was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @email_template = EmailTemplate.find(params[:id])\n @email_template.destroy\n\n respond_to do |format|\n format.html { redirect_to email_templates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @email_template = EmailTemplate.find(params[:id])\n @email_template.destroy\n\n respond_to do |format|\n format.html { redirect_to email_templates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post_template.destroy\n respond_to do |format|\n format.html { redirect_to post_templates_url, notice: 'Post template was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @workout.destroy\n respond_to do |format|\n format.html { redirect_to workouts_url, notice: \"Workout was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n current_site.grid_templates.find(params[:id]).destroy\n index\n end",
"def destroy\n @template_package.destroy\n\n respond_to do |format|\n format.html { redirect_to templates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @script_template.destroy\n\n respond_to do |format|\n format.html { redirect_to script_templates_url, notice: \"Script template was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client_workout = ClientWorkout.find(params[:id])\n @client_workout.destroy\n\n respond_to do |format|\n format.html { redirect_to(client_workouts_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @workout_set = WorkoutSet.find(params[:id])\n @workout_set.destroy\n\n respond_to do |format|\n format.html { redirect_to workout_sets_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @track_template.destroy\n respond_to do |format|\n format.html { redirect_to track_templates_url, notice: 'Track template was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pending_work.destroy\n respond_to do |format|\n format.html { redirect_to pending_works_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @template_datum.destroy\n respond_to do |format|\n format.html { redirect_to template_data_url, notice: 'Template datum was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bulk_message_template = BulkMessageTemplate.find(params[:id])\n @bulk_message_template.destroy\n\n respond_to do |format|\n format.html { redirect_to bulk_message_templates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user_workout.destroy\n respond_to do |format|\n format.html { redirect_to user_workouts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event_template.destroy\n respond_to do |format|\n format.html { redirect_to event_templates_url, notice: \"Event template was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @template.destroy\n end",
"def destroy\n @work_item_type.destroy\n respond_to do |format|\n format.html { redirect_to work_item_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @print_template = PrintTemplate.find(params[:id])\n @print_template.destroy\n\n respond_to do |format|\n format.html { redirect_to print_templates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cf_template.destroy\n respond_to do |format|\n format.html { redirect_to cf_templates_url, notice: I18n.t('cf_templates.msg.deleted') }\n format.json { head :no_content }\n end\n end",
"def destroy\n @workout = Workout.find(params[:id])\n @workout.destroy\n\n respond_to do |format|\n format.html { redirect_to days_url }\n format.json { head :no_content }\n end\n \n end",
"def destroy\n @admin_template_software = TemplateSoftware.find(params[:id])\n @admin_template_software.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_template_software_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @wit.destroy\n respond_to do |format|\n format.html { redirect_to wits_url, notice: 'Wit was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n return if new_record?\n \n @api.delete \"/meetings/#{shortcode_url}.json\"\n end",
"def destroy\n @work.destroy\n\n respond_to do |format|\n format.html { redirect_to works_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @reqdifficulty.destroy\n respond_to do |format|\n format.html { redirect_to reqdifficulties_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @template.destroy\n\n respond_to do |format|\n format.html { redirect_to dashboard_path, notice: t('template_destroyed') }\n end\n\n end",
"def destroy\n @lcb_template.destroy\n respond_to do |format|\n format.html { redirect_to lcb_templates_url, notice: 'Lcb template was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @config_template = ConfigTemplate.find(params[:id])\n json=@config_template.to_json\n xml=@config_template.to_xml\n\n @config_template.destroy\n\n respond_to do |format|\n format.html { redirect_to(config_templates_url) }\n format.json { render :json => json }\n format.xml { render :xml => xml }\n end\n end",
"def destroy\n @question_template = QuestionTemplate.find(params[:id])\n @question_template.destroy\n\n respond_to do |format|\n format.html { redirect_to question_templates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @workobject = Workobject.find(params[:id])\n @workobject.destroy\n\n respond_to do |format|\n format.html { redirect_to workobjects_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @workhour.destroy\n respond_to do |format|\n format.html { redirect_to workhours_url, notice: 'Workhour was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @workout.destroy\n redirect_to root_path\n end",
"def destroy\n @admin_kpi_category_template = Admin::KpiCategoryTemplate.find(params[:id])\n @admin_kpi_category_template.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_kpi_category_templates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @work_time.destroy\n respond_to do |format|\n format.html { redirect_to work_times_url, notice: 'Work time was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @rcadmin_email_template.destroy\n respond_to do |format|\n\t flash[:notice] = 'Email template was successfully deleted.'\n format.html { redirect_to rcadmin_email_templates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @template = Template.find(params[:id])\n @template.destroy\n\n respond_to do |format|\n format.html { redirect_to templates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @work = Work.find(params[:id])\n @work.destroy\n\n respond_to do |format|\n format.html { redirect_to works_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @work = Work.find(params[:id])\n @work.destroy\n\n respond_to do |format|\n format.html { redirect_to works_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @work = Work.find(params[:id])\n @work.destroy\n\n respond_to do |format|\n format.html { redirect_to works_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @work = Work.find(params[:id])\n @work.destroy\n\n respond_to do |format|\n format.html { redirect_to works_url }\n format.json { head :no_content }\n end\n end"
] |
[
"0.7443243",
"0.71824217",
"0.7181598",
"0.7115013",
"0.7107723",
"0.70816416",
"0.70725995",
"0.7044704",
"0.70158654",
"0.7015127",
"0.7009052",
"0.6989359",
"0.69866323",
"0.6977606",
"0.6973286",
"0.69618255",
"0.695753",
"0.6954994",
"0.695063",
"0.694221",
"0.69258916",
"0.6916539",
"0.69144297",
"0.69009125",
"0.6896357",
"0.6895826",
"0.6895043",
"0.6866876",
"0.6863606",
"0.6859093",
"0.6857991",
"0.68517476",
"0.6851506",
"0.6850946",
"0.68448234",
"0.6824883",
"0.6822263",
"0.68183285",
"0.68163306",
"0.6812867",
"0.68007886",
"0.67959464",
"0.6792629",
"0.6790913",
"0.6788864",
"0.6786454",
"0.67693496",
"0.67631763",
"0.67488325",
"0.67484266",
"0.67482865",
"0.67461604",
"0.67461604",
"0.67461604",
"0.6739595",
"0.67345625",
"0.6732264",
"0.67292994",
"0.6722975",
"0.6721761",
"0.6720642",
"0.6720642",
"0.67201567",
"0.6718337",
"0.67126244",
"0.67095804",
"0.669607",
"0.6680204",
"0.6669847",
"0.6669362",
"0.66691554",
"0.6667954",
"0.66668886",
"0.6666599",
"0.66655153",
"0.6664008",
"0.66630715",
"0.6662653",
"0.6660747",
"0.66551274",
"0.6654471",
"0.6653749",
"0.6653385",
"0.6652782",
"0.6645927",
"0.6645851",
"0.6638666",
"0.6636429",
"0.6623248",
"0.6614846",
"0.6609524",
"0.6606828",
"0.6600549",
"0.6597548",
"0.6597464",
"0.6595747",
"0.65929884",
"0.65929884",
"0.65929884",
"0.65929884"
] |
0.7972006
|
0
|
this could be optimized a tiny bit by only calling superclass.build_xray but i am le tired
|
def build_xray
@build_xray ||= begin
retval = Hash.new { |hash,key| hash[key] = {} }
klasses = []
klass = self
while klass && klass <= UIView
klasses.unshift(klass)
klass = klass.superclass
end
klasses.each do |klass|
xray_props = klass.xray
xray_props && xray_props.each do |key,values|
values.keys.each do |check_unique|
retval.each do |section, editors|
editors.delete(check_unique)
end
end
retval[key].merge!(values)
end
end
# clean out nil-editors and empty sections
retval.each do |section, editors|
editors.each do |property, editor|
editors.delete(property) unless editor
end
retval.delete(section) if editors.length == 0
end
retval
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def build_xml\n raise NotImplementedError, \"Override build_xml in subclass\"\n end",
"def build_xml(builder)\n super(builder)\n builder.Type { |b| self.object_type.build_xml(b) } if object_type\n end",
"def initialize(arry = [])\n @base = arry.collect{|el| el } # poor man's clone\n @tree_hash = run_layers\n end",
"def initialize arr = []\n super arr\n end",
"def __array__; self; end",
"def marshal_load x\n @nested_class = x.first\n super x.last\n set_default_proc!\n end",
"def build=(_arg0); end",
"def my_controlled_flatten(n=1)\n #here\n return self if n < 1\n\n results = []\n self.each do |el|\n if el.class == Array\n #here\n results += el.my_controlled_flatten(n-1)\n else\n results << el\n end\n end\n\n results\n\n end",
"def build(**)\n raise NotImplementedError\n end",
"def build_tree(arr)\n\tend",
"def build_xml(builder)\n super(builder)\n builder.Asset {|b| self.logged_asset.build_xml(b)} if logged_asset && assets.blank?\n builder.Segment {|b| self.segment.build_basic_xml(b)} if segment\n assets.each do |asset|\n builder.Asset {|b| asset.build_xml(b)} if asset\n end\n end",
"def build\n return @entries.first.elements if @entries.length == 1\n @entries.each(&:restrict)\n\n @entries.flat_map do |entry|\n entry.restricted_elements.map do |element|\n next if (level_ids_in_grain - element.grain_level_ids).present?\n element.grain_hash\n end.compact\n end.uniq.map do |grain_hash|\n elm = VirtualElement.new grain_hash, @memory_slice, @entries.map(&:element_locator)\n elm.rollup(*@virtual_metrics)\n end\n end",
"def rebuild_weight_array\n end",
"def build_internal_nodes\n names.each do |tmp_geo_area|\n recurse_nodes(tmp_geo_area.parent_names, tmp_geo_area)\n end\n end",
"def flat; Flat.new(self); end",
"def build; end",
"def initialize(input_arr=[])\n @internal_arr = []\n input_arr.each do |x|\n self.add(x)\n end\n end",
"def initialize \n\t\tsuper(SIZE)\n\tend",
"def build_xml(builder)\n super(builder)\n builder.ValidNetwork {|b| segment_config_network.build_xml(b) } if segment_config_network\n asset_on_segment_historys.each do |aosh|\n builder.AssetOnSegmentHistory {|b| aosh.build_xml(b)} if aosh\n end\n meas_locations.each do |m|\n builder.MeasurementLocation do |b|\n m.build_xml(b)\n end\n end\n end",
"def build\n # Create the offsets, if they are not provided\n current_offset = 0\n fields.each do |field_def|\n field_def[2] ||= current_offset\n current_offset = field_def[2] + field_def[1].size\n end\n registry.do_create_compound(name, fields, size)\n end",
"def my_flatten\n # return self unless self.is_a?(Array)\n new_arr = []\n self.each do |el|\n if el.is_a?(Array)\n new_arr += el.my_flatten\n else\n new_arr << el\n end\n end\n new_arr\n end",
"def initialize(*args)\n super\n decorators(Nokogiri::XML::Node) << Nokogiri::Decorators::XBEL\n decorate!\n\n# self.root = '<xbel version=\"1.0\"></xbel>'\n end",
"def build(floor, overrides)\n @instance || super\n end",
"def init\n parent = ancestors[1]\n unless /^Objectify::(Xml|ElementParser|DocumentParser)$/ =~ parent.name\n @collections = parent.instance_variable_get('@collections').clone || []\n @attributes = parent.instance_variable_get('@attributes').clone || []\n @qualified_attributes = parent.instance_variable_get('@qualified_attributes').clone || {}\n @flatten = parent.instance_variable_get('@flatten').clone || []\n @namespaces = parent.instance_variable_get('@namespaces').clone || {}\n @types = parent.instance_variable_get('@types').clone || {}\n else\n @collections = []\n @attributes = []\n @qualified_attributes = {}\n @flatten = []\n @namespaces = {}\n @types = {}\n end\n end",
"def build_xml(builder)\n super(builder)\n object_data.each do |d|\n builder.Attribute do |b|\n d.build_xml(b)\n end\n end\n builder.DefaultUnitType { |b| default_eng_unit_type.build_xml(b) }\n end",
"def build\r\n end",
"def build\r\n end",
"def build(x, envelope)\n x.complex(nil, ['http://schemas.xmlsoap.org/soap/envelope/', 'Envelope'], []) do |x|\n build_header(x, envelope.header)\n build_body(x, envelope.body)\n end\n end",
"def method_missing(name, *args, &block)\n super unless respond_to? name\n @builder = Builder.new(builder.tree) do\n __send__(name, *args, &block)\n end\n end",
"def build\r\n raise \"Not implemented\"\r\n end",
"def marshal_load array\n initialize_visibility\n\n @dont_rename_initialize = nil\n @token_stream = nil\n @aliases = []\n @parent = nil\n @parent_name = nil\n @parent_class = nil\n @section = nil\n @file = nil\n\n version = array[0]\n @name = array[1]\n @full_name = array[2]\n @singleton = array[3]\n @visibility = array[4]\n @comment = array[5]\n @call_seq = array[6]\n @block_params = array[7]\n # 8 handled below\n @params = array[9]\n # 10 handled below\n @calls_super = array[11]\n @parent_name = array[12]\n @parent_title = array[13]\n @section_title = array[14]\n @is_alias_for = array[15]\n\n array[8].each do |new_name, comment|\n add_alias RDoc::Alias.new(nil, @name, new_name, comment, @singleton)\n end\n\n @parent_name ||= if @full_name =~ /#/ then\n $`\n else\n name = @full_name.split('::')\n name.pop\n name.join '::'\n end\n\n @file = RDoc::TopLevel.new array[10] if version > 0\n end",
"def base=(_arg0); end",
"def build\n from_branches + from_tags + from_refs\n end",
"def build_object(builder, property_name, object, child_ns)\n raise 'Objects must respond to each' unless object.respond_to?(:each)\n object_name = Zuora::Utils::Envelope.to_zuora_key property_name\n builder[:api].send(object_name) do\n build_nodes builder, object, child_ns\n end\n end",
"def initialize **values\n # Just to do the type check...\n self.class.level_for! **values\n super **values\n end",
"def build_array(node)\r\n return [] if node.nil?\r\n results = []\r\n results.concat build_array(node.left)\r\n results << node.payload\r\n results.concat build_array(node.right)\r\n results\r\nend",
"def method_missing(meth, *args, &blk) \n if meth.to_s =~ /^(.*)!$/\n self << XML.new($1.to_sym, *args, &blk)\n else\n real_method_missing(meth, *args, &blk)\n end\n end",
"def inherited(base); end",
"def initialize(x, y, width, height)\n super\n @data = []\n self.index = 0\n activate\n end",
"def from_xml\n @children = xml_doc.xpath('//base/*').collect{ |child_node|\n build_child_from_xml child_node\n }\n end",
"def initialize(array_size, _debug=false)\n @debug = !!_debug\n @id = (0..array_size).to_a\n @depth = @id.map{|e| 0 }\n # @root = @id.dup # double-the memory required\n true # avoid exposing private array\n end",
"def initialize(shelf, book)\n @shelf = shelf\n @book = book\n @@array << self\nend",
"def build\n nodes << element_klass.new\n\n yield(nodes.last) if block_given?\n\n nodes.last\n end",
"def buildingPos _obj, _args\n \"_obj buildingPos _args;\" \n end",
"def build\n method_proxy(:build)\n\n true\n end",
"def build\n yield self\n self\n end",
"def build\n type.size ||= current_size\n registry.register(type)\n end",
"def build\n end",
"def marshal_load array\n initialize array[1], nil, array[5]\n\n @full_name = array[2]\n @visibility = array[3] || :public\n @is_alias_for = array[4]\n # 5 handled above\n # 6 handled below\n @parent_name = array[7]\n @parent_class = array[8]\n @section_title = array[9]\n\n @file = RDoc::TopLevel.new array[6]\n end",
"def build_arel(*)\n arel = super\n arel.only if self.itself_only_value === true\n build_inheritances(arel)\n arel\n end",
"def my_controlled_flatten(n)\n flattened = []\n\n self.each do |el|\n depth = 0\n if el.is_a?(Array)\n depth += 1\n flattened += el.my_flatten\n else\n flattened << el\n end\n end\n flattened\n end",
"def build_array\n arr = []\n yield(arr)\n arr \n end",
"def build(params); end",
"def build_everything\n @defs.keys.each { |k| self[k] }\n end",
"def build(base, object, type = nil, selected_fields = nil)\n return [] if object.blank?\n return object if object.first.is_a?(Document)\n docs = []\n object.each do |attrs|\n if _loading? && base.persisted?\n docs.push(Factory.execute_from_db(klass, attrs, nil, selected_fields, execute_callbacks: false))\n else\n docs.push(Factory.build(klass, attrs))\n end\n end\n docs\n end",
"def mathtex(*)\n super\n end",
"def initialize(input_arr=[])\n @internal_arr = []\n input_arr.each {|elem| self.add(elem)}\n end",
"def inherited(subclass)\n super\n subclass.instance_variable_set(\"@collection\", {})\n subclass.instance_variable_set(\"@indexed_fields\", [])\n subclass.instance_variable_set(\"@indexes\", {})\n end",
"def create_fox_components use_as_base = nil\n if use_as_base.nil?\n self.inst = fx.() if self.inst.nil?\n self.as_tasks.map{ |a| a.() } unless self.as_tasks.nil?\n self.kinder.each{ |os|\n os.create_fox_components unless os.reusable?\n }\n else\n OpenStruct.new(klass: use_as_base.class,\n kinder: [self],\n fx: ->() {use_as_base}).create_fox_components\n end\n self\n end",
"def augment_children(child_base_nodes)\n if child_base_nodes.size < (sz = self.class.min_children)\n child_base_nodes = child_base_nodes.dup\n child_base_nodes[sz..-1] = [] # Fill with nil\n end\n child_base_nodes.map.with_index do |child, child_index|\n child_name = self.class.child_index_to_name(child_index, child_base_nodes.size)\n if (klass = remap_child(child, child_name))\n klass.new(child, parent: self, index: child_index)\n else\n child\n end\n end\n end",
"def flatten( level = 1 )\n\n load_parent_state\n \n return super\n\n end",
"def superclass() end",
"def build_single\n IconGenerator::TouchBuilder.new.build_single(@source, @destination)\n end",
"def base; self; end",
"def build_xml(builder)\n super(builder)\n builder.ValidNetwork { |b| valid_network.build_xml(b) } if valid_network\n builder.Model { |b| model.build_xml(b) } if model\n builder.Manufacturer { |b| manufacturer.build_xml(b) } if manufacturer\n end",
"def method_731(base); end",
"def build(*args)\n raise \"Method 'build' not implemented for #{self.class.name}\"\n end",
"def initialize(input_arr=[])\n @internal_arr = []\n # Fill in the rest of the initialize method here.\n # What should you do with each element of the incoming array?\n input_arr.each { |x|\n add(x)\n }\n end",
"def initialize(input_arr=[])\n @internal_arr = []\n input_arr.each {|ele| add ele}\n\n # Fill in the rest of the initialize method here.\n \n # What should you do with each element of the incoming array?\n end",
"def build_index!\n balanced_trees = Hash[\n @index_trees.map { |type, tree| [type, tree.balanced_copy] }\n ]\n return ZDSearch::BinaryTreeSearchIndex.new(\n sorted_index_trees: balanced_trees,\n tokeniser: @tokeniser,\n field_mapping: @field_mapping,\n )\n end",
"def Array(p0) end",
"def &(ary)\n self.class.new super\n end",
"def build_root(&block)\n @stack = []\n self.instance_eval(&block)\n\n build_root_from_stack\n end",
"def proxy\n super\n end",
"def initialize(input_arr=[])\n \n @internal_arr = []\n\n # Pass each element in input_arr to 'add' method (if it isn't empty)\n input_arr.each { | ele | add(ele) } \n\n end",
"def build_objects\n @object = @connection.objects.convert_reference_to_object(@object_reference)\n @arguments = @arguments_references.map { |arguments_reference| @connection.objects.convert_reference_to_object(arguments_reference) }\n end",
"def initialize_clone( hooked_array_clone )\n \n super\n \n hooked_array_clone.internal_array = hooked_array_clone.internal_array.clone\n \n end",
"def initialize(input_arr=[])\n @internal_arr = []\n input_arr.each { |x| add x }\n # Fill in the rest of the initialize method here.\n # What should you do with each element of the incoming array?\n end",
"def beer(arr, x, y)\n build = Array.new \n arr << x << y \nend",
"def build_indices\n @files, @classes = RDoc::Generator::Context.build_indices(@toplevels,\n @options)\n end",
"def build_indices\n @files, @classes = RDoc::Generator::Context.build_indices(@toplevels,\n @options)\n end",
"def initialize(root)\n @imported = []\n super(root)\n end",
"def marshal_load array\n initialize_visibility\n\n @aliases = []\n @parent = nil\n @parent_name = nil\n @parent_class = nil\n @section = nil\n @file = nil\n\n version = array[0]\n @name = array[1]\n @full_name = array[2]\n @rw = array[3]\n @visibility = array[4]\n @comment = array[5]\n @singleton = array[6] || false # MARSHAL_VERSION == 0\n # 7 handled below\n @parent_name = array[8]\n @parent_class = array[9]\n @section_title = array[10]\n\n @file = RDoc::TopLevel.new array[7] if version > 1\n\n @parent_name ||= @full_name.split('#', 2).first\n end",
"def __builders\n @builders ||= []\n end",
"def object_tree\n head, *rest = array_tree\n object_subtree(head,rest)\n end",
"def initialize(x, *c)\t#No childs means empty array.\r\n\t\t@value = x\r\n\t\t@childs = c\r\n\tend",
"def build\n raise \"Nodes must implement #build\"\n end",
"def my_controlled_flatten(n)\n return self if n == 0\n new_arr = []\n self.each do |el|\n if el.is_a? (Array)\n new_arr += el.my_controlled_flatten(n-1)\n else\n new_arr << el\n end\n end\n new_arr\n end",
"def initialize(*)\n super\n reduce(public, any)\n end",
"def initialize b\n @build = b\n end",
"def x() self[0]; end",
"def inspect\n return super unless has_size?\n\n to_ary.inspect\n end",
"def build!\n end",
"def _subclasses\n @_subclasses ||= []\n end",
"def ancestor_builder; end",
"def ancestor_builder; end",
"def build\n end",
"def sup \n SuperProxy.new(self) \n end",
"def build_move_tree\n self.root_node = PolyTreeNode.new(start_pos) #instance variable\n \n queue = [root_node]\n until queue.empty?\n #pop,queue\n cur_node = queue.shift\n move_list = new_move_positions(cur_node.value)\n move_list.each do |pos|\n child_node = PolyTreeNode.new(pos)\n cur_node.add_child(child_node)\n queue << child_node\n end\n end\n end",
"def initialize #everytie an instance of the class is initialized, we should push it into the @@all class variable\n @@all << self\n end"
] |
[
"0.5859437",
"0.5634151",
"0.55204886",
"0.551021",
"0.5495675",
"0.5474111",
"0.5443462",
"0.5440317",
"0.53660965",
"0.53269243",
"0.5323505",
"0.5304804",
"0.52597165",
"0.52544576",
"0.52079296",
"0.51994175",
"0.5156718",
"0.51438683",
"0.51424146",
"0.5129548",
"0.5117759",
"0.51089203",
"0.5093353",
"0.5080695",
"0.5065161",
"0.50641817",
"0.50641817",
"0.5055388",
"0.5051661",
"0.5038963",
"0.5031816",
"0.5024511",
"0.5023054",
"0.5003078",
"0.49993262",
"0.49942157",
"0.49918178",
"0.4987583",
"0.4986664",
"0.49805832",
"0.4976734",
"0.49767107",
"0.49706918",
"0.49691045",
"0.49661446",
"0.49628985",
"0.49425426",
"0.49363098",
"0.49323535",
"0.49322733",
"0.4926667",
"0.49186763",
"0.4911223",
"0.49075022",
"0.49035645",
"0.49027923",
"0.4897989",
"0.48964635",
"0.48943153",
"0.48838198",
"0.4862407",
"0.4860984",
"0.48523635",
"0.48502162",
"0.48484063",
"0.48400417",
"0.48378307",
"0.4837016",
"0.48362902",
"0.48341995",
"0.4832953",
"0.48281989",
"0.4821386",
"0.4819068",
"0.48085174",
"0.48059687",
"0.4804662",
"0.480422",
"0.4803415",
"0.48005524",
"0.48005524",
"0.4799593",
"0.47995636",
"0.4798524",
"0.4797155",
"0.47959825",
"0.47944668",
"0.4793918",
"0.478587",
"0.47844678",
"0.47778997",
"0.47757208",
"0.4774666",
"0.4771999",
"0.47715938",
"0.47715938",
"0.4771247",
"0.47701132",
"0.4767092",
"0.47657582"
] |
0.69425344
|
0
|
main method (num > arr)
|
def pull(group_number)
@form[INPUT_NAME] = group_number
button = @form.button_with(name: BUTTON_NAME)
schedule_page = @agent.submit(@form, button)
teachers_links = schedule_page.links.select { |t| TEACHER_NAME_REGEX === t.to_s }
teachers_links.uniq(&:text).map { |t| t.click.search(FIO_XPATH).first.text }
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def subarray(arr,num)\n\t#sort the array, use pointers\n\tj = 0\n\ti = 0\n\tsum = 0\n\twhile j < arr.length\n\t\tif sum < num\n\t\t\t#moving up the array if sum is less than number\n\t\t\tsum += arr[j]\n\t\t\tj += 1\n\t\telse\n\t\t\tminLen = [9000, j-i].min\n\t\t\tif i == (j-1)\n\t\t\t\treturn 1\n\t\t\tend\n\t\t\tsum -= arr[i]\n\t\t\ti += 1\n\t\tend\n\t\tputs sum, \"first\"\n\t\tputs minLen, \"minfirst\"\n\t\tputs i,\"i\", j, \"j\"\n\tend\n\t\n\twhile sum >= num\n\t\tminLen = [9000, j-i].min\n\t\ti += 1\n\t\tsum -= arr[i]\n\t\tputs sum, \"second\"\n\t\tputs minLen, \"minsecond\"\n\t\tputs i,\"i\", j, \"j\"\n\tend\n\tif minLen == 9000\n\t\tputs 0\n\telse\n\t\tputs minLen\n\tend\n\nend",
"def search_array(arr, num)\n\n\tarr.length.times do |x|\n\t\tif arr[x] == num\n\t\t\tputs x\n\t\tend\n\tend\n\n\nend",
"def g_num(arr)\n\nindex = 1\n\n arr.length.times do \n\n if arr[0] >= arr[index]\n index += 1\n else\n arr[0] = arr[index]\n end\n\n end\n\np arr[0]\n\nend",
"def do_something_with(arr)\n\tputs \"do something\"\n\tputs arr.length\n\tputs\nend",
"def arr_mult(arr, num)\n\n\tarr.each do |mini_arr|\n\t\t# p \"mini_arr is #{mini_arr}\"\n\t\tproduct1 = mini_arr[0]*mini_arr[1]*mini_arr[2]*mini_arr[3]\n\t\tproduct2 = (mini_arr[0]**2)*mini_arr[1]*mini_arr[2]*mini_arr[3]\n\t\tproduct3 = (mini_arr[1]**2)*mini_arr[0]*mini_arr[2]*mini_arr[3]\n\t\tproduct4 = (mini_arr[2]**2)*mini_arr[1]*mini_arr[0]*mini_arr[3]\n\t\tproduct5 = (mini_arr[3]**2)*mini_arr[1]*mini_arr[0]*mini_arr[2]\n\t\tif product1 == num\n\t\t\tp \"product1 is #{product1}\"\n\t\t\tp \"mini_arr is #{mini_arr}\"\n\t\t\treturn true\n\t\telsif product2 == num\n\t\t\t\"product2 is #{product2}\"\n\t\t\tp \"mini_arr is #{mini_arr}\"\n\t\t\treturn true\n\t\telsif product3 == num\n\t\t\t\"product3 is #{product3}\"\n\t\t\tp \"mini_arr is #{mini_arr}\"\n\t\t\treturn true\n\t\telsif product4 == num\n\t\t\t\"product4 is #{product4}\"\n\t\t\tp \"mini_arr is #{mini_arr}\"\n\t\t\treturn true\n\t\telsif product5 == num\n\t\t\t\"product5 is #{product5}\"\n\t\t\tp \"mini_arr is #{mini_arr}\"\n\t\t\treturn true\t\t\t\n\t\t\t\t\n\t\tend\n\tend\n\treturn false\nend",
"def basic_8 (array_iterate, eval_int)\n total = 0\n array_iterate.each { |n| total += 1 if n > eval_int}\n return total\nend",
"def count_num_of_arr_trees\n print 'Please enter the numbers in array separated by space :: '\n arr = gets.split(' ')\n arr.sort!\n sum = num_of_arr_trees_supp(arr, 0, arr.length-1)\n puts \"Possible different binary trees having unique structure :: #{sum}\"\n end",
"def render(num, array)\n puts\n puts \"Solution #{num+1}\"\n puts \" +---+ \"\n puts \" | #{array[0]} | \"\n puts \"+---+---+---+\"\n puts \"| #{array[1]} | #{array[2]} | #{array[3]} |\"\n puts \"+---+---+---+\"\n puts \"| #{array[4]} | #{array[5]} | #{array[6]} |\"\n puts \"+---+---+---+\"\n puts \" | #{array[7]} | \"\n puts \" +---+ \"\nend",
"def find_unsorted_subarray(nums)\n \nend",
"def mex(arr)\n 0.upto($n) do |nn|\n if arr.any? nn\n next\n else\n return nn\n end\n end\n $n\nend",
"def arr \n arr.gets.chomp \n arr.every other \nend",
"def print_array(arr) # define method with one parameter\n\ti = 0 # set starting index value\n\twhile i < arr.length\n\t\tputs arr[i] # Returns the value in the array at index value iteration\n\n\t\ti += 1\n\tend\nend",
"def namerisuminarray arr \n len = arr.length\n sum = 0\n sum = sum.to_i\n broqch = 0\n \n while broqch <= len - 1\n sum = sum + arr[broqch].to_i\n broqch = broqch + 1\n end\n \n return sum \nend",
"def rand_numbers(total_arr)\n\n num_arr = []\n while num_arr[1] == num_arr[6]\n 2.times do\n counter = 0\n 5.times do\n num = rand(1..total_arr[counter])\n num_arr << num\n counter = counter + 1\n end\n num_arr\n end\n num_arr\nend\nnum_arr\nend",
"def even_numbers_less_than num\n array=[]\n i = 0\n begin\n if (i % 2 == 0)\n array.push (i)\n end\n i+=1\n end while ( i < num)\n array\nend",
"def array_print_10\nend",
"def sum_array(array_num)\n\nend",
"def second_great_low(arr)\r\n\r\nend",
"def basic_5 (array_iterate)\n array_iterate.max\nend",
"def arr_search(arr, num)\r\n\tindex = 0\r\n\tarr.each do |search|\r\n\t\tif (index < arr.length && search == num)\r\n\t\t puts index\r\n\t\tend \r\n\t\tindex += 1\r\n\tend \r\nend",
"def multiply(num_arr, num)\n counter = 0\n new_arr = []\n loop do\n break if counter >= num_arr.length\n new_arr << num_arr[counter] * num\n counter += 1\n end\n\n new_arr\nend",
"def solution(x, a)\r\n # write your code in Ruby 2.2\r\n arr=[];\r\n i=0;\r\n l=a.count\r\n \r\n while(arr.count<=x)\r\n \r\n if(arr[i].nil?)\r\n arr << i\r\n end\r\n \r\n i+=1\r\n end\r\n i\r\nend",
"def findlargestdrop(arr)\n\n\n\nend",
"def print_arr_1(arr)\n arr.each do |idx|\n puts el\n end\nend",
"def arr_with_given(array, num)\n array.take(array.length - num)\nend",
"def check_array(nums)\n if(nums.length >= 2)\n\t\treturn (nums[0] + nums[1])\n\tend\n\tif(nums.length == 1)\n\t\treturn nums[0];\n\tend\n\treturn 0;\n\nend",
"def greater(num_array)\n num = num_array.sort.last\n puts num\nend",
"def check_array(array, num)\n if array.length > 2\n if num < array[0] or num > array[array.length-1]\n return false\n elsif num == array[0] \\\n or num == array[array.length-1] \\\n or num == array[((array.length-1)/2).floor]\n return true\n elsif num < array[((array.length-1)/2).floor]\n return check_array(array[0..((array.length-1)/2).floor-1], num)\n elsif num >= array[((array.length-1)/2).floor]\n return check_array(array[((array.length-1)/2).floor..array.length-1], num)\n end\n else\n return true if num == array[0] or num == array[1]\n return false\n end\nend",
"def get_num(arr)\n case rand(100) + 1\n when 1..5\n check_if_nil(arr,0)\n when 6..65\n check_if_nil(arr,1)\n when 66..100\n check_if_nil(arr,2)\n end\n end",
"def double_arr(nums)\n numb_arr = [] # create empty arr\n i = 0 # the indice counter start @ 0\n\n while i < nums.length # for the length of indices in array \n new_num = nums[i] * 2 # variable new_num = looped var i * 2\n numb_arr << new_num # shovel the value of new_num into empty arr\n i += 1 # iterate into next indice of passed array\n end\n return numb_arr # the new array\n puts numb_arr # display the result of the new array\nend",
"def puzzle4\n\tarr=[]\n\t(0..9).each {|i| arr[i]=Random.rand(55..100)}\n\tputs arr\n\tprint arr, \"\\n\"\nend",
"def take_number_iterate_array_print(number_input)\n # I have to set these up in here otherwise the method can't access them\n # Assign the starting number i.e. \"number_current\" to 0\n # Assign an empty array to \"numbers\"\n number_current = 0\n numbers = []\n while number_current < number_input \n puts \"Number top: #{number_current}\"\n numbers.push(number_current)\n\n # Take whatever number_current currently is and add 1 to it and save that back to number_current\n # If number_current is 0 we add 1 making it 1 and save that to number_current instead\n number_current += 1\n puts \"Array: #{numbers}\"\n puts \"Number bottom: #{number_current}\"\n end\n\n\tputs \"The numbers: \"\n\n # Iterate over each item in the array \"numbers\"\n # Pass each item to the \"num\" paramemter, or argument, in the anonymous function\n # puts \"num\", the currently iterated item from the array\n\tnumbers.each do |num|\n\t puts num\n\tend\nend",
"def array_looper(array)\n\tarray.each do |a|\n\t\tputs a\n\tend\nend",
"def sum_of_2\n array = Array.new\n puts \"Give me an array\"\n array = gets.chomp\n puts array\n length = array.length\n case length\n when 0\n puts \"Sum = 0\"\n when 1\n puts \"Sum = #{array[0]}\"\n else\n sum = array[0].to_i+array[1].to_i\n puts \"Sum = #{sum}\"\n end\nend",
"def primes_less_than (num)\n arr=[]\n for n in 2..(num-1)\n if is_prime?(n)\n arr.push(n)\n end\n end\n p arr\n return arr\nend",
"def multiples_of_three_and_five(limit)\n arr = []\n i = 1\n\n while i < limit do\n if i % 5 == 0 || i % 3 == 0\n arr << i\n i += 1\n else\n i += 1\n end\n # puts $arr.inspect\n end\n\n arr_size = arr.count\n # puts arr_size\n total = 0\n i = 0\n\n while i < arr_size do\n total += arr[i]\n i += 1\n end\n\n return total\nend",
"def num_array(num)\n arr = Array.new\n \n until num <= 0\n arr.push(num % 10)\n num = num / 10\n end\n\n until arr.length == 4\n arr.push(0)\n end\n arr\nend",
"def sum_arr(arr)\n\tif arr.empty?\n\t\tputs 0\n\telse \n\t\tarr[-1] + arr[-2] = new_num\n\t\tarr.pop(2)\n\t\tarr.push(new_num)\n\tend\n\tputs arr\nend",
"def run(arr)\n self.diagonals(arr)\n self.verticals(arr)\n self.horizontals(arr)\n puts \"Overall max is\"\n p @@maximums.max\n end",
"def make_array(size)\n\tnumbers = []\n\tfor i in (0..size)\n\t\tputs \"At the top, i is #{i}\"\n\t\tnumbers.push(i)\n\t\tputs \"Numbers now: #{numbers}\"\n\t\tputs \"At the bottom, i is #{i}\"\n\tend\n\n\tputs \"The numbers: \"\n\tfor num in numbers\n\t\tputs num\n\tend\nend",
"def up_array(arr)\n\n\treturn nil if arr.empty? == true\n\tarr.each do |number|\n\t\treturn nil if number < 0 == true || number > 9 == true\n\tend\n\tnum = arr.join.to_i + 1\n\tnum.to_s.split(//).map(&:to_i)\nend",
"def max_sub_array(nums)\n return 0 if nums.nil? \n return nil if nums.empty?\n \n max_so_far = nums[0]\n max_for_sub_array = 0\n\n nums.each do |num|\n max_for_sub_array = max_for_sub_array + num\n if num > max_for_sub_array\n max_for_sub_array = num\n end\n if max_for_sub_array > max_so_far\n max_so_far = max_for_sub_array\n end\n end\n return max_so_far\n\nend",
"def compute(array)\n\n index = 0\n while index < array.length\n code = array[index]\n instruction = code % 100\n case instruction\n when 1\n add(code, array, array[index + 1], array[index + 2], array[index + 3])\n index += 4\n when 2\n multiply(code, array, array[index + 1], array[index + 2], array[index + 3])\n index += 4\n when 3\n # Input\n consume_input(code, array, array[index + 1])\n index += 2\n when 4\n # Output\n write_to_output(code, array, array[index + 1])\n index += 2\n when 5\n bool, new_index = jump_if_true(code, array, array[index + 1], array[index + 2])\n\n index = bool ? new_index : index + 3\n when 6\n bool, new_index = jump_if_false(code, array, array[index + 1], array[index + 2])\n\n index = bool ? new_index : index + 3\n when 7\n less_than(code, array, array[index + 1], array[index + 2], array[index + 3])\n index += 4\n when 8\n equals(code, array, array[index + 1], array[index + 2], array[index + 3])\n index += 4\n when 9\n add_to_relative_base(code, array, array[index + 1])\n index += 2\n when 99\n break\n else\n break\n end\n end\nend",
"def printArr(arr)\n i = 0\n while i < arr.length\n puts arr[i]\n i += 1\n end\nend",
"def pop_from_array(arr)\n arr.size.times do\n puts arr.pop\n end\nend",
"def primos3(array3)\n array3.each do |x|\n if es_numero_primo?(x)\n puts \"El numero #{x} es primo\"\n end\n end\nend",
"def basic_12 (array_process)\n array_process.shift\n array_process.push(0)\nend",
"def non_comparison_sort(arr)\n result = []\n i = 1 \n while i <= arr.length \n result << i \n i+=1\n end \n p result \nend",
"def i\n\t\t\tprogram = pop\n\t\t\traise ArgumentError, \"I: first element is not an Array.\" unless program.is_a? Array\n\t\t\t~program\n\t\tend",
"def add_num(arr, num)\r\n\t# Your code here\r\nend",
"def biggest_number(num)\n numbers = []\n num.each do |array_num|\n biggest = 0\n array_num.each do |num|\n if num > biggest\n biggest = num\n end\n end\n numbers << biggest\n end\n p numbers\nend",
"def split_array(array, number)\n size = number\n \nend",
"def check_array(nums)\n sum = 0\n i = 0\n while i < nums.length\n \tif(nums[i] == 17)\n\t\t\ti= i + 1\n\t\telse\n\t\t \tsum = sum + nums[i]\n\t end\n\t i += 1\n end\n \treturn sum\nend",
"def explode arr\n arr2 = []\n \n if arr.grep(Integer).reduce(:+).nil?\n return 'Void!'\n else\n score = arr.grep(Integer).reduce(:+)\n score.times { arr2 << arr }\n return arr2\n end\nend",
"def get_index(arr, num)\n arr.sort.each_with_index do |arr_num, index| \n if arr_num > num\n return index\n else\n return arr.length\n end\n end\nend",
"def range(arr)\n\nend",
"def menu \n puts 'Highest and Lowest Arrays'\n puts 'Hello, Please enter a group of numbers press enter'\n rec_num \nend",
"def array_of_ints(arr)\n return arr[0] * arr[1] * arr[2] if arr.length == 3\n\n comp_arr = arr.pop(3).sort\n\n arr.each do |num|\n if num > comp_arr[2]\n comp_arr.push(num)\n comp_arr.shift\n elsif num > comp_arr[1]\n comp_arr[0] = comp_arr[1]\n comp_arr[1] = num\n elsif num > comp_arr[0]\n comp_arr[0] = num\n end\n end\n comp_arr[0] * comp_arr[1] * comp_arr[2]\n\nend",
"def count(arr)\n count = 0\n arr_length_half = arr.length / 2\n\n arr_length_half.times do |i|\n if arr [i] > arr[- i - 1]\n count += arr[i]\n else\n count += arr[-i - 1]\n end\n end\n count\nend",
"def output_array(array)\n counter = 0\n while counter < array.length do\n puts array\n counter += 1\n end\nend",
"def A1\n arr=[*1..100]\n arr2 = []\n\tif array.each.even?\n\t\t|x| puts x \n\telsif array.each.odd?\n\t \tarr2.push(|x|)\n\tend\nend",
"def find_unsorted_subarray(nums)\n l = 0\n r = nums.length - 1\n min = 10_001\n max = -10_001\n st = 0\n nd = -1\n\n while r >= 0\n nums[l] >= max ? max = nums[l] : nd = l\n nums[r] <= min ? min = nums[r] : st = r\n\n l += 1\n r -= 1\n end\n\n nd - st + 1\nend",
"def array_nums(arr)\n\n result = []\n count = 0\n\n arr.each { |num| num!=0 ? result << num : count += 1 }\n count.times { result.push(0) }\n result\n\nend",
"def sort_stuff(arr, num) # method takes two arguments. The array of integers and the integer to search.\r\n\tarr.each_index { |x| #iterate over the index of each integer\r\n\t\tif arr[x] ==num # compares each integer with variable num \r\n\t\t\tp x # prints integer if equal to variable num\r\n\t\telse\r\n\t\t\tnil\t\t\t# returns nil if variable num not equal to any of array integers\r\n\t\tend\r\n\t\t}\r\nend",
"def max_sub_array(nums)\n\tmax = count = nums.shift\n\n\tnums.each do |num|\n\t\tcount = num > count + num ? num : count + num\n\t\tmax = count if count > max\n\tend\n\n\tmax\nend",
"def ArrayAdditionI(arr)\n\n # code goes here\n arr.sort!\n largest = arr.last\n sum = 0\n for i in 0..arr.length-2\n sum += arr[i]\n if sum >= largest\n return true\n break\n end\n end\n return false \n \nend",
"def output_array(array)\n counter = 0 \n while counter < array.length do \n puts array[counter]\n counter += 1\n end \nend",
"def output_array(array)\n count = 0\n while count < array.length do\n puts array[count]\n count += 1\n end\nend",
"def find_max_num(numbers)\n if numbers.length == 0 \n \tputs \"No numbers were passed.\" \n elsif numbers.length > 0\n max_num = numbers[0]\n \tfor i in 1..numbers.length - 1 # So I don't over-run the array, and start at the 2nd position to compare against max at postion [0]\n if max_num < numbers[i] \n max_num = numbers[i] \n end\n i += 1\n \tend\n puts \"Looked through an array of lenght #{numbers.length}.\"\n puts \"The largest value is #{max_num}\"\n end\nend",
"def total(num_array)\n\n if num_array.empty? == true\n\n puts \"Array is empty add some values\"\n\n else\n\n index = 0\n\n add = 0\n\n\n while index < num_array.length\n\n add = add + num_array[index]\n\n index += 1\n\n end\n\n p add\n end\nend",
"def maxnumbers(numbers)\n new_numbers = 0\n index = 0\n while index < numbers.length\n if numbers[index] > new_numbers\n new_numbers = numbers[index]\n end\n index += 1\n end \n return new_numbers\nend",
"def pretentious_primes(arr, num)\nend",
"def sort(num_array)\n # Your code goes here\n (num_array.length).times do |i|\n while i > 0\n if num_array[i-1] > num_array[i] \n num_array[i-1], num_array[i] = num_array[i], num_array[i-1]\n else\n break\n end\n i-=1\n end\n \n end\n return num_array\n \nend",
"def fib(num) # 'num' is not an index here. It is just the number of Fibonacci elements that user want to get.\n\n arr = [0,1] #arr[0] and arr[1] are fixed. We need to add from arr[2] if needed.\n\n if num == 0 # I think this should be (num == 1) \n # Cause num is not an index, \n # it is just the number of element inside of array in this method\n # If you run p fib(1), it returns [0,1], but it was supposed to return [0]\n arr = [0]\n elsif num == 1 # Same reason as above, this sould be (num == 2)\n arr = [0,1]\n else\n # I think you might understand until this line-------------\n \n counter = 2 # The reason 'count' begins with 2 is that fib(1) and fib(2) are fixed as [0] and [0,1]\n while counter < num # If the input is neither 1 nor 2, we need to count up \n # For example, if the input was 4, array will have 4 elements.(but the last index is 3, not 6)\n \n arr[counter]= arr[counter - 2] + arr[counter -1]\n\n # Like I mentioned on the line 5 comment, we need to create(?) from arr[2] if a user wants more \n # first loop => arr[2] = arr[0] + arr[1], counter increases by 1, counter = 3 \n # second loop => arr[3] = arr[1] + arr[2], counter increases by 1, counter = 4\n # Since the counter is 4, it will stop the loop\n\n\n counter += 1\n end\n end\n\n return arr\n # Now our 'arr' have arr[2] and arr[3]\n # So if you print it out, it will show the whole array !\n\n\nend",
"def print_4(arr)\n\tarr.each do |i| \n\t\ti = (i - 1) * 4\n\t\tif i >= arr.size\n\t\t\tbreak\n\t\tend\n\t\tputs arr.slice(i,4) \n\t\tputs\n\tend\nend",
"def even_numbers_less_than num\n even_numbers_array = []\n i=0\nwhile i<num do\n even_numbers_array.push(i)\n i+=2\nend\n return even_numbers_array\nend",
"def range(limits)\r\n\tnumbers = []\r\n\tfor number in (0..limits)\r\n\t\tputs \"At the top numbers are : #{number}\"\r\n\t\tnumbers.push(number)\r\n\tend\r\n\r\n\tputs \"The numbers: \"\r\n\tfor number in numbers\r\n\t\tputs number\r\n\tend\r\nend",
"def add_num(num, arr = @numbers)\n @numbers << num if @numbers.empty?\n \n mid_idx = (arr.length-1)/2\n \n if num == arr[mid_idx]\n desired_idx = mid_idx\n elsif num < arr[mid_idx]\n desired_idx = self.add_num(num,arr[0...mid_idx])\n else\n right_search = self.add_num(num,arr[mid_idx+1..-1])\n desired_idx = right_search ? right_search + arr[0..mid_idx].length : 0\n end\n \n @numbers.insert(desired_idx,num)\n @length += 1\n end",
"def virus(array_input)\n new_array = [ ]\n number_of_loops = array_input.length\n index = 0 \n\n number_of_loops.times do \n if array_input[index] > 7\n\tnew_array << array_input[index]\n end \n index = index + 1 \n end \n output = new_array\n return output\n\nend",
"def arrayAdditionI(arr)\n\tarrSum = 0\n\tlargestNum = arr.sort.pop\n\tarr.each{|x| arrSum += x if(x < largestNum) }\n\tif(arrSum >= largestNum || arr.include?(arrSum - largestNum))\n\t\treturn true\n\telse \n\t\treturn false\n\tend\nend",
"def buuble_sort(arr)\n\tloop do\n\t\tloop_break = true\n\t\t(arr.length-1).times do |i|\n\t\tif arr[i]>arr[i+1]\n\t\t\tarr[i], arr[i+1] = arr[i+1], arr[i]\n\t\t\tloop_break = false\n\t\tend\n\t\tend\n\tbreak if loop_break\n\tend\n\tputs arr\nend",
"def eercicio\n\ta = Array.new(20)\n\tfor i in 0..20\n\t\ta[i] = rand(1..100)\n\tend\n\tputs \"#{a}\"\n\tb= a.select{|k| k%2 == 0}\n\tputs \"Pares #{b} \"\n\tc= a.select{|k| k%2 == 1}\n\tputs \"Impares #{c}\"\n\td = a.select{|k| k%2 == 0 && a.find_index(k)%2 == 0 && a.find_index(k)>0}\n\tputs \"Numeros PAR que corresponde con el indice #{d}\"\n\top\t =\"s\" \n\twhile op == \"s\" do\n\t\tputs \"Array #{a}\"\n\t\tputs \"Introduzca numero a buscar\"\n\t\tnum = gets.chomp.to_i\n\t\tvar = a.select{|k| k==num}\n\t\tputs \"#{var}\"\n\t\t#\tputs \"El numero existe\"\n\t\t#else\n\t\t#\tputs \"El numero no existe\"\n\t\t#end\n\tend\nend",
"def mtdarry\n 10.times do |num|\n puts num\n end\nend",
"def mtdarry\n 10.times do |num|\n puts num\n end\nend",
"def mtdarry\n 10.times do |num|\n puts num\n end\nend",
"def test2(array)\n\tputs \"Test2: Should return an array -> \"\n\tabg_maker(array).class == Array ? true : false\nend",
"def find_unsorted_subarray4(nums)\n min = Float::INFINITY\n max = -Float::INFINITY\n\n flag = false\n\n nums.each_cons(2) do |n1, n2|\n flag = true if n2 < n1\n min = [min, n2].min if flag\n end\n\n flag = false\n nums.reverse.each_cons(2) do |n1, n2|\n flag = true if n2 > n1\n max = [max, n2].max if flag\n end\n\n left = nums.length\n right = 0\n\n (0..nums.size - 1).each do |index|\n left = index\n break if nums[index] > min\n end\n\n (nums.size - 1).downto(0) do |index|\n right = index\n break if nums[index] < max\n end\n\n right > left ? right - left + 1 : 0\nend",
"def basic_9 (array_iterate)\n square_array = array_iterate.collect { |n| n * n}\n return square_array\nend",
"def printArray(arr) \n\tarr.each do |e|\n\t\tputs e\n\tend\nend",
"def problem_76a\n num = 100\n solve = lambda do |a,off,max|\n n = 0\n while a[off] < max && (a.length-off) >= 2 \n a[off] += a.pop\n n += 1\n n += solve.call(a.dup,off+1,a[off]) if a.length - off > 1\n end\n n\n end\n puts 1 + solve.call([1] * num, 0,num-1)\nend",
"def array_42(argument)\n\n\tresultat = false\n\ti=0\n\twhile i<=argument.length\n\t\tif argument[i]==42 then\n\t\t\tresultat= true\n\t\telse \n\t\t\t\tend\n\t\ti+=1\n\tend\n\t\n#\tputs resultat\n\t\treturn resultat\n\t\t\nend",
"def pretentious_primes(arr, ran)\n\n primes = list_of_primes(arr.max, ran )\n # print primes\n\n arr.map do |num|\n i = 0\n primes[0..-2].each_with_index do |p , idx|\n if num == p \n i = idx\n \n elsif (num > p && num < primes[idx + 1]) && ran > 0 \n i = idx\n elsif (num > p && num < primes[idx + 1]) && ran < 0 \n i = idx + 1\n \n end\n end\n # p i\n # p ran\n if (i + ran) < 0\n \n nil\n else\n primes[i + ran]\n end\n\n end\n \nend",
"def max(array)\n\tn = 0\n\tarray.each do |x|\n\t\tif x > n\n\t\t\t n = x\n\t\tend\n\tend\n\t puts n\nend",
"def take_a_number arr, str\n arr.push(str)\n puts \"Welcome, #{str}. You are number #{arr.length} in line.\"\nend",
"def numbers(n)\n\nend",
"def mtdarray\n\t10.times do |num|\n\t\tsquare = num + num\n\t\treturn num, square if num > 5\n\tend\nend",
"def printarr\n\t\t@arr.each_with_index do |element, index|\n\t\t\tprint element.empty? ? \".\t\" : \"#{element}\t\"\n\t\t\tputs \"\" if (index == 2)||(index == 5)\n\t\tend\n\t\tputs \"\"\n\tend",
"def print_array(array)\n length(array).times do |index|\n puts array[index]\n end\n # raise NotImplementedError\nend",
"def printArray(anArray, size)\n puts \"The values inside the array are: \"\n #resulting array values\n for i in 0..size\n puts anArray[i]\n end\nend",
"def workbook(n, k, arr)\r\n # Write your code here\r\n sp = 0\r\n count = 0\r\n arr.each do |range|\r\n remainingArray = Array(1..range)\r\n until (remainingArray.empty?)\r\n count += 1\r\n x = remainingArray.slice!(0,k)\r\n sp +=1 if (x.include?count)\r\n end\r\n end\r\n return sp\r\nend",
"def largest(array)\n index = 0 #1\n greatest_num = array[index] #5 \n while index < array.length #0 < 5 1 < 5\n if array[index] > greatest_num #if 5 > 5 17 > 5\n greatest_num = array[index] # 17 \n end\n index += 1\n end\n greatest_num\nend"
] |
[
"0.6257693",
"0.62250674",
"0.61015284",
"0.60349137",
"0.59681964",
"0.5947764",
"0.5939012",
"0.59074765",
"0.58770305",
"0.5870524",
"0.58109397",
"0.57808965",
"0.57603765",
"0.5711973",
"0.57119614",
"0.5695944",
"0.5691354",
"0.5688366",
"0.5664739",
"0.5662924",
"0.56374127",
"0.56338274",
"0.5626959",
"0.5621998",
"0.56217146",
"0.55994284",
"0.55860096",
"0.5585856",
"0.5581464",
"0.55797374",
"0.5556893",
"0.55523515",
"0.5550688",
"0.5542597",
"0.55316365",
"0.55226874",
"0.55204165",
"0.5520031",
"0.5517771",
"0.5514124",
"0.55130816",
"0.55127823",
"0.5504588",
"0.55005366",
"0.5496915",
"0.5494285",
"0.54942465",
"0.54708606",
"0.54490614",
"0.5432617",
"0.54312545",
"0.5427582",
"0.5423365",
"0.5418499",
"0.5417109",
"0.5398211",
"0.53932744",
"0.5391283",
"0.53877926",
"0.5386251",
"0.5373726",
"0.5370665",
"0.5368006",
"0.53626674",
"0.536123",
"0.5359898",
"0.5357491",
"0.53561455",
"0.5353197",
"0.5352233",
"0.5351802",
"0.5345971",
"0.53449494",
"0.5342117",
"0.53394",
"0.53393304",
"0.53377604",
"0.53374445",
"0.533287",
"0.533229",
"0.5318729",
"0.53152966",
"0.53120327",
"0.53120327",
"0.53120327",
"0.53109413",
"0.530288",
"0.52975786",
"0.5294606",
"0.5294454",
"0.5293541",
"0.52907896",
"0.5287653",
"0.5285714",
"0.52822673",
"0.52819645",
"0.5281756",
"0.5273259",
"0.52728766",
"0.5270052",
"0.5269027"
] |
0.0
|
-1
|
can slug the username
|
def slug
self.username.downcase.gsub(" ", "-")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def slug\n username.strip.downcase.gsub(\" \",\"-\")\n end",
"def slug\n username.downcase.gsub(\" \", \"-\")\n end",
"def slug \n sloog = self.username.gsub(\" \", \"-\").downcase\n end",
"def slug\n self.username.split(\" \").join(\"-\").downcase\n end",
"def slug\n self.username.split(\" \").join(\"-\").downcase\n end",
"def slug\n self.username.downcase.gsub(/\\W+/, '-')\n end",
"def slug\n self.username.gsub(\" \", \"-\").downcase\n end",
"def slug\n @input = self.username.gsub(/\\s|\\W/,'-').downcase\n end",
"def generate_slug\n self.slug = username.to_slug\n end",
"def create_slug\n self.username = self.email.split('@').first\n end",
"def slug\n self.name.downcase.gsub(/[!@%&\"]/,'').tr(\" \", \"-\")\n end",
"def slug\n #it strips out special characters, and replaces all spaces with -\n name.split.join(\"-\").downcase\n end",
"def slugify\n self.slug = self.name.downcase.strip.gsub(' ', '-').gsub(/[^\\w-]/, '')\n end",
"def slug\n name.downcase.gsub(\" \",\"-\")\n end",
"def slug_candidates\n [\n :username,\n [:username, :id]\n ]\n end",
"def slugify\n self.slug = name.parameterize \n end",
"def slug; end",
"def slug; end",
"def clean_username(username)\n\n my_username = username\n #remove all non- alphanumeric character (expect dashes '-')\n my_username = my_username.gsub(/[^0-9a-z -]/i, '')\n\n #remplace dashes() for empty space because if the user add dash mean that it want separate the username\n my_username = my_username.gsub(/[-]/i, ' ')\n\n #remplace the empty space for one dash by word\n my_username.downcase!\n my_username.strip!\n username_split = my_username.split(' ').join('-')\n\n end",
"def slug\n name.gsub(\" \", \"-\").downcase\n end",
"def to_slug\n\t\t# login ?\t\"/u/#{login}\" : \"/users/#{id}\"\n\t\t\"/users/#{id}\"\n\tend",
"def slug\n self.name.strip.gsub(\" \", \"-\").downcase\n end",
"def slug\n self.name.strip.gsub(\" \", \"-\").downcase\n end",
"def slug\n #s = self.name\n #s.downcase.gsub(\" \",\"-\")\n self.name.gsub(\" \", \"-\").downcase\n end",
"def slug\n self.name.downcase.gsub(\" \", \"-\") unless self.name.nil?\n end",
"def slug\n self.name.downcase.gsub(\" \", \"-\") unless self.name.nil?\n end",
"def slugify\n self.slug = name.parameterize\n end",
"def slug\n name.downcase.gsub(\" \", \"-\")\n end",
"def check_username\n if /[a-zA-Z0-9_-]/.match(params[:username])\n user = User.username(params[:username])\n if user.blank?\n render :json => [\"free\", \":)\"]\n else\n render :json => [\"taken\", \"Sorry, username exists!\"]\n end\n else\n render :json => [\"Letters, numbers, dashes and underscores only please :)\"]\n end\n end",
"def slug\n name.downcase.gsub(' ', '-')\n end",
"def slug\n self.name.gsub(\" \", \"-\").downcase\n end",
"def slug\n self.name.downcase.gsub(/[^a-z0-9]/, '-').squeeze('-')\n end",
"def manage_slug\n \tself.slug = self.title.parameterize if self.slug.blank?\n end",
"def slug\n name.downcase.tr(' ', '-').delete('.')\n end",
"def slug\n name.downcase.tr(' ', '-').delete('.')\n end",
"def slug\n name.split(' ').join('-')\n end",
"def slug\n name.chomp.downcase.split('').reject{|l| l.match(/[^\\p{L}\\d\\s]/u)}.join.gsub(\" \", \"-\")\n end",
"def slug\n self.name.downcase.gsub(' ', '-')\n end",
"def slug\n self.name.downcase.gsub(' ', '-')\n end",
"def slug\n\t\tunless name.nil?\n\t\t\tname.downcase.gsub(\" \", \"-\")\t\t\t\n\t\tend\n\tend",
"def titleize_slug(slug); end",
"def slugfy\n# self.slug = title.gsub(/\\W/, '-').downcase\n self.slug = title.parameterize.to_s\n end",
"def slugged_name\n name.gsub(' ', '-').delete(\"?/#\")\n end",
"def set_slug\n self.slug = full_name.parameterize\n end",
"def generate_slug\n self.slug = name.parameterize if name.present?\n end",
"def slug\n @data['user']['slug']\n end",
"def username\n params[:username].downcase\n end",
"def generate_slug\n self.slug = self.name.parameterize\n end",
"def post_slug(other); end",
"def slug\n self.title.downcase.gsub(\" \", \"-\") unless self.title.nil?\n end",
"def username\n params[:username].downcase\n end",
"def slug\n self.name.split(/\\W/).map {|word| word.downcase unless word.empty?}.compact.join('-')\n end",
"def check_and_set_slug\n self.slug ||= self.host&.parameterize\n end",
"def slug\n title.downcase.gsub(\" \", \"_\")\n title.gsub(\".\",\"\")\n end",
"def slug\n self.title.downcase.gsub(/\\s+/, '-').gsub(/[^a-z0-9_-]/, '').squeeze('-')\n end",
"def slug\n self.title.downcase.gsub(/\\s+/, '-').gsub(/[^a-z0-9_-]/, '').squeeze('-')\n end",
"def set_slug\n \t \tself.slug = name.to_slug unless name.blank?\n\tend",
"def safe_slug(spliter = '-')\n @slug = self\n if @slug.blank?\n @slug = Time.now.to_i.to_s\n end\n @slug.gsub(/[^a-zA-Z\\-0-9]/,spliter).downcase \n end",
"def generate_slug\n self.slug = self.title[0..47].parameterize\n end",
"def generate_slug\n self.slug = self.title[0..47].parameterize\n end",
"def slug\n self.downcase.gsub(\" \", \"-\").gsub(/[^0-9a-z\\-]/, '')\nend",
"def slug_string\n self.name\n end",
"def slugify\n # this is the correct way to sets the value to the attribute\n # parameterize(\"Donald E. Knuth\") # => \"donald-e-knuth\"\n self.slug = name.parameterize\n end",
"def slug_candidates\n [:name]\n end",
"def generate_slug\n \tself.slug = title.parameterize\n end",
"def skip_slug_validation?\n true\n end",
"def parameterize_slug\n self.slug = self.title if self.slug.empty?\n self.slug = self.slug.downcase.parameterize\n end",
"def slug_candidates\n [:name]\n end",
"def slugando\n\t\tself.slug = summary.parameterize.to_s\n\tend",
"def slug=(_arg0); end",
"def as_slug\n Swift::Transliteration.slugize self\n end",
"def generate_slug_from_title\n self.slug = self.title.downcase.gsub(' ','-')\n end",
"def set_slug\n self.slug = title.parameterize\n end",
"def normalize_slug\n self.slug = normalize_friendly_id(slug)\n end",
"def slug\n Inflector.parameterize(@title, \"_\")\n end",
"def set_slug\n if self.slug.blank?\n self.slug = self.name.parameterize.downcase unless self.name.nil?\n end\n end",
"def add_slug\n loop do\n initials = user.first_name[0, 2].downcase <<\n user.last_name[0, 2].downcase\n year = Time.current.strftime(\"%y\")\n self.slug = \"#{initials}#{year}-#{rand(100..9999)}\"\n break unless self.class.exists?(slug: slug)\n end\n end",
"def set_slug\n self.slug = title.downcase.tr(\" \", \"_\") if slug.blank?\n slug\n end",
"def normalize_slug\n self.slug = normalize_friendly_id(slug)\n end",
"def downcase_username\n self.username.downcase!\n end",
"def slug\n path\n end",
"def slug_candidates\n [ :name ]\n end",
"def clean_slug!\n blank = \"\"\n separator = \"-\"\n self.slug = slug.downcase\n .gsub(/\\(|\\)|\\[|\\]\\./, blank)\n .gsub(/&/, blank)\n .gsub(/\\W|_|\\s|-+/, separator)\n .gsub(/^-+/, blank)\n .gsub(/-+$/, blank)\n .gsub(/--*/, separator)\n end",
"def slug_from_name(name)\n name.gsub(' ', '_').downcase\n end",
"def slug\n attributes['name'].gsub(/\\s/, '-').gsub(/[^\\w\\-]/, '').downcase\n end",
"def generate_slug\n self.slug = title.parameterize if title\n end",
"def make_slugged_title\n return true unless self.published?\n return true unless self.slug.to_s.blank?\n self.slug = self.title.to_slug\n end",
"def downcase_username()\n self.username = username.downcase\n end",
"def username=(value)\n if value\n value.downcase!\n value.squish!\n end\n super(value)\n end",
"def normalize_slug\n self.slug = normalize_friendly_id(slug)\n end",
"def slug(name)\n name.gsub(/\\s+/, '-')\n end",
"def downcase_username\n self.username = self.username.downcase if self.username?\n end",
"def to_slug\n self.title.parameterize\n end",
"def escape_slug(string)\n string.gsub(/[^\\w]/,'_').gsub(/^_+|_+$/,'').downcase\nend",
"def set_slug\n self.slug = self.title.parameterize\n end",
"def slug\n (self[:headline] || '').parameterize\n end",
"def slug\n @attributes[:slug] = @attributes[:name] && PublicEarth::Db::Collection.create_slug(@attributes[:name]) unless @attributes[:slug] \n @attributes[:slug]\n end",
"def set_slug\n self.slug = title.downcase.gsub(\" \", \"_\") if slug.blank?\n slug\n end",
"def slug\n urlname.to_s.split('/').last\n end",
"def to_param\n # there was a problem when someone set the username to http://shop.soletron.com/..., so\n # if there is an error with the username, the username will not be rendered in the url\n if username and self.errors['username'].blank?\n \"#{username}\"\n else\n super\n end\n end"
] |
[
"0.8435804",
"0.8367536",
"0.83382463",
"0.832017",
"0.832017",
"0.8291674",
"0.8223764",
"0.8178415",
"0.7684794",
"0.7222219",
"0.7099",
"0.6982988",
"0.6962085",
"0.6920815",
"0.6908066",
"0.6907833",
"0.6907679",
"0.6907679",
"0.68866897",
"0.68746984",
"0.68727815",
"0.68426615",
"0.68426615",
"0.6836065",
"0.68319255",
"0.68319255",
"0.68255806",
"0.68233776",
"0.6801684",
"0.67954814",
"0.6789678",
"0.67774796",
"0.6751795",
"0.6747936",
"0.6747936",
"0.674778",
"0.6723427",
"0.67190325",
"0.67190325",
"0.6700591",
"0.6628482",
"0.6584861",
"0.6562254",
"0.6561077",
"0.654822",
"0.6548152",
"0.6541857",
"0.65207464",
"0.6499854",
"0.6478597",
"0.6473682",
"0.6455807",
"0.6441956",
"0.643112",
"0.64304274",
"0.64304274",
"0.6429124",
"0.64246744",
"0.6423726",
"0.6423726",
"0.6414709",
"0.6407682",
"0.640591",
"0.64027196",
"0.64017695",
"0.63980997",
"0.6394393",
"0.6387851",
"0.63645816",
"0.63545805",
"0.63265103",
"0.6317212",
"0.6316319",
"0.63064826",
"0.63024867",
"0.6297939",
"0.6296089",
"0.6293466",
"0.6291447",
"0.6290981",
"0.6281794",
"0.6277174",
"0.62727123",
"0.6261556",
"0.6260904",
"0.62570333",
"0.6243052",
"0.6239904",
"0.6239012",
"0.62382823",
"0.6231764",
"0.62312174",
"0.620914",
"0.6186372",
"0.6186157",
"0.6171479",
"0.61599565",
"0.6152036",
"0.61485547",
"0.61389536"
] |
0.81962353
|
7
|
receive the name in a method downcase the name split the name into an array of words "first last".split(' ') swap the first and last name .reverse change the vowels aeiou to the next vowel in the sequence split the word into an array run method to shuffle vowel letters over if its an edge case change the consonants to the next consonant in the alphabet run method to shuffle consonant letters over capitailize again Felicia Torres This downcases the name, splits it and reverses it.
|
def spy_name(real_name) ####Still in progress...######
new_name = real_name.downcase
adjust = new_name.split(' ')
first_n = adjust[0].split('')
last_n = adjust[1].split('')
index = 0
until index == first_n.last
vowels = ["a", "e", "i", "o", "u"]
if first_n[index] == ["a", "e", "i", "o"]
first_n[index] = vowels.next
elsif first_n[index] == "u"
first_n[index] = "a"
elsif first_n[index] == "z"
first_n[index] = "b"
else first_n[index].next
first_n[index] = first_n[index].next
end
index += 1
end
#don't forget to return the method
index = 0
until index == last_n.last
vowels = ["a", "e", "i", "o", "u"]
if last_n[index] == ["a", "e", "i", "o"]
last_n[index] = vowels.next
elsif last_n[index] == "u"
last_n[index] = "a"
elsif last_n[index] == "z"
last_n[index] = "b"
else last_n[index].next
last_n[index] = last_n[index].next
end
index += 1
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def scrambler (name)\n\tswapped = name.split.rotate.join(\" \") # Take name and flip it.\n\tswapped.downcase! # Make string lowercase.\n\tname1 = swapped.tr(\"aeiou\", \"eioua\") # Shift all vowels by 1 place.\n\tname2 = name1.tr(\"bcdfghjklmnpqrstvwxyz\", \"cdfghjklmnpqrstvwxyzb\") # Shift all conconants by 1 place.\n\tname3 = name2.split.map(&:capitalize).join(\" \") # Make string into substrings capitalize and join back.\nend",
"def fake_name(name)\n\n name_array = name.split('')\n\n name_array.map! do |letter|\n vowels = ['a','e','i','o','u', 'a']\n i = 0\n until i>vowels.length\n if i == 5\n letter = letter.next\n if vowels.include?(letter.downcase)\n letter = letter.next\n end\n break\n elsif letter.downcase == vowels[i]\n letter = vowels[i+1]\n break\n elsif letter.downcase == \" \"\n break\n else\n i += 1 \n end \n end\n letter\n end\n\n p name_array \n\n final_name = name_array.join.split(' ')\n\n final_name.map! do |letter|\n letter.capitalize\n end\n\n final_name2 = final_name.rotate.join(' ')\n\n return final_name2\n\nend",
"def name_swapper(full_name)\n full_name = full_name.downcase\n vowel_array = ['a','e','i','o','u']\n consenant_array = \"bcdfghjklmnpqrstvwxyz\".split('')\n name_array = full_name.split(\" \")\n reversed_name= \"#{name_array[1]} #{name_array[0]}\"\n secret_name = reversed_name.split('').map! do |letter|\n if vowel_array.include?(letter)\n vowel_array[vowel_array.index(letter)+1]\n elsif consenant_array.include?(letter)\n consenant_array[consenant_array.index(letter)+1]\n elsif letter == \" \"\n \" \"\n end\n\n end\n puts \"Your name USED to be #{full_name.upcase}...but now your name is #{secret_name.join.upcase}!\"\n secret_name.join.upcase\nend",
"def aliass(full_name)\n\talphabet = \"bcdfghjklmnpqrstvwxyz\"\n\tvowels = \"aeiou\"\n\tnew_string = \"\"\n\n full_name.split('').each do |letter|\n \t\tif vowels.include?(letter)\n \t\t\tnew_string += vowel(letter)\n \t\telsif alphabet.include?(letter)\n \t\t\tnew_string += consonant(letter)\n \t\telse\n \t\t\tnew_string += letter\n \t\tend\nend\n#Transform this new string into an array\n#Swap first and second word in array\n#Turn new word into string\n#Create empty array outside of loop\nnew_word = new_string.split(' ')\n new_word.reverse!\n\nnew_word.map {|names| names.capitalize!}\nnew_string = new_word.join(\" \")\nend",
"def name_shuffler(s)\n s.split.reverse.join(' ')\nend",
"def name_shuffle(str)\n\t#creates an array with each word as an element\n\tstr = str.split\n\t#reverse the order of the array, last being first\n\t#first being last\n\tstr = str.reverse()\n\t#creates a string from the array, joining the words\n\t#with a space\n\tstr = str.join(\" \")\n\t#returns the string\n\treturn str\nend",
"def make_up_name(name)\nchanged_name = [] #empty array to push letters from name into when it goes through iteration\nvowels = \"aeiou\"\n\nconsonant = \"bcdfghjklmnpqrstvwxyz\"\n\n\n#if the index of the name provided is a consonant then change it to the next letter.\n\nindex = 0 #start at 0\n \n while index < name.length\n \t\tletter = name[index] #takes every index of every letter in name and stores it in a variable\n \t\tif vowels.include?(letter) #deals with edge case\n \t\t\tif letter == \"u\"\n \t\t\t\tchanged_name.push(\"a\")\n \t\t\telse #need to make it so every other vowel changes to next vowel letter.next\n \t\t\tend\n \t\telsif consonant.inlcude?(letter)\n \t\t\tif letter == \"z\" #deals with edge case\n \t\t\t\tchanged_name.push(\"b\")\n \t\t\telse #everything else will need to be next letter using letter.next \t\t \t\t\n \t\t\tend\n \t\telsif letter == \" \"\n \t\t\t\tchanged_name.push(\" \")\n \t\t\tend\n \t\t \t index += 1\n \tend\nnew_name_array = changed_name.join('') #takes all the letters in the array above and puts it in a new array\nnew_name_array.each {|name| p name.capitalize}\nend",
"def swap(name)\r\n\tname.downcase.split.reverse\r\nend",
"def name_shuffler(str)\n str.split.reverse.join(' ')\nend",
"def name_shuffler(str)\n str.split.reverse.join(' ')\nend",
"def fake_name (full_name)\n words_array = full_name.split (\" \")\n swap_name_array = words_array.reverse\n swap_name = swap_name_array.join(\" \")\n letters = swap_name.chars\n fake_letters = []\n letters.each do |letter|\n vowel = %w[a A e E i I o O u U]\n if vowel.include?(letter)\n fake_letters << next_vowel(letter)\n elsif letter == \" \"\n fake_letters << \" \"\n else\n fake_letters << next_unvowel(letter)\n end\nend\n return fake_letters.join (\"\")\nend",
"def nameSwitch(name)\n vowels = 'aeiou'\n new_name = ''\n newname = name.split(' ').reverse.join(' ')\nend",
"def change_name(name)\n\t\t# create alphabet range\n\t\tvowels = 'aeiou'\n\t\tvowel_change = vowels.split('').reverse\n\t\tconsonants = 'abcdefghijklmnopqrstuvwxyz'\n\t\tconsonant_change = consonants.delete('aeiou').split('').reverse\n\n\t\toriginal_name = name\n\t\tname_reverse = original_name.downcase.split.reverse.join('').split('')\n\n\n\t\tnew_name = name_reverse.map do |letter|\n\t\t\tif vowels.include?(letter)\n\t\t\t\tvowel_change[vowel_change.index(letter)-1]\n\t\t\telsif consonants.include?(letter)\n\t\t\t\tconsonant_change[consonant_change.index(letter)-1]\n\t\t\telse\n\t\t\t\tletter\n\t\t\tend\nend\n\nfinal_name = new_name.join.split.map { |name| name.capitalize}.join('')\nend",
"def name_handler(name)\n name = name.downcase.chars #takes the input and makes it downcase and breaks it into an array to increment through\n name_new = name.map do |letter| #create a new array called name_new and start block to increment through each array\n letter_change(letter)\n end\n #Code addressing capitalization and swapping first / last\n namearr = name_new.join('').split #join the new_name array back into a string\n p namearr\n first_name = namearr[0] #assign first name to a new variable based on index\n last_name = namearr[1] #assign first name to a new variable based on index\n name_new = last_name.capitalize! + \" \" + first_name.capitalize! #capitalize and swap first for last\nend",
"def spy_name(str)\n #CREATE VARIABLES FOR VOWELS AND CONSONANTS\n vowels = [\"a\", \"e\", \"i\", \"o\", \"u\"]\n consonants = [\"b\", \"c\", \"d\", \"f\", \"g\", \"h\", \"j\", \"k\", \"l\", \"m\", \"n\", \"p\", \"q\", \"r\", \"s\", \"t\", \"v\", \"w\", \"x\", \"y\", \"z\"]\n #CHANGE STRING FIRST INTO ARRAY THAT MAKES EACH WORD A VALUE THEN REVERSE THEM. \n #THEN TURN ARRAY BACK INTO STRING AND DOWNCASE ANY LETTER.\n #THEN TURN STRING BACK INTO ARRAY THAT TAKES EACH INDIVIDUAL CHARACATER AS A VALUE.\n str = str.split(' ').reverse.join.downcase\n str = str.split('')\n #CREATE TEMPORARY VARIABLE STR_NEW TO EQUEL STR THEN CHANGE BUMP EACH \n #VOWEL AND CONSONANT TO THE NEXT ONE IN LINE. \n str_new = str.map do |char|\n if vowels.include?(char)\n vowels.rotate(1)[vowels.index(char)]\n elsif consonants.include?(char)\n consonants.rotate(1)[consonants.index(char)]\n else\n char\n end\n end\n #TURN ARRAY BACK INTO STRING.\n str_new.join\nend",
"def split_flip_name\n p \"what is your first and last name? (type 'print' to quit)\"\n name = gets.chomp.downcase\n old_name_array = []\n old_name_array << name\n p old_name_array\n split_name = name.split(' ')\n #more elegant to use reverse method\n flip_name = split_name[1], split_name[0]\n #p flip_name\n join_name = flip_name.join(' ').chars\n #p join_name\nend",
"def name_rotate(name)\r\n consonants = %w[b c d f g h j k l m n p q r s t v w x y z]\r\n vowels = ['a', 'e', 'i', 'o', 'u']\r\n \r\n name = name.downcase.split('')\r\n \r\n name_rotate = name.map { |char|\r\n if vowels.include?(char)\r\n vowels.rotate(1)[vowels.index(char)]\r\n elsif consonants.include?(char)\r\n consonants.rotate(1)[consonants.index(char)]\r\n else\r\n char\r\n end\r\n }\r\n \r\n name_rotate.join.split(' ').reverse.map { |x| x.capitalize }.join(' ')\r\nend",
"def name_scramble(str)\n\tarr = str.downcase.split(\"\")\n\tvowels = [\"a\", \"e\", \"i\", \"o\", \"u\"]\n\tconsonant = [\"b\", \"c\", \"d\", \"f\", \"g\", \"h\", \"j\", \"k\", \"l\", \"m\", \"n\", \"p\", \"q\", \"r\", \"s\", \"t\", \"v\", \"w\", \"x\", \"y\", \"z\"]\n\tstr_new = arr.map do |char|\n\t\tif vowels.include?(char) \n\t\t\tvowels.rotate[vowels.index(char)];\n\t\telsif consonant.include?(char)\n\t\t\tconsonant.rotate[consonant.index(char)]\n\t\tend\n\tend\n\tstr_new.join.capitalize\nend",
"def name_shuffler(str)\n\tp str.split.reverse.join(\" \")\nend",
"def fake_name(name)\n name = name.split.rotate\n name.map! do |n|\n n.downcase!\n vowels = 'aeiou'\n vowels_shifted = vowels.split('').rotate.join\n consonants = 'bcdfghjklmnpqrstvwxyz'\n consonants_shifted = consonants.split('').rotate.join\n\n n.tr!(vowels, vowels_shifted)\n n.tr!(consonants, consonants_shifted)\n\n n = n.split('')\n n[0] = n[0].upcase\n n = n.join\n end\n name = name.join(' ')\nend",
"def translate_name(name)\nreversed_name = name.split(' ').reverse\nnew_first = reversed_name[0].chars.map {|x|\n x.next\n }\nnew_last = reversed_name[1].chars.map {|x|\n x.next\n }\nnew_name = \"#{new_first.join} #{new_last.join}\"\nend",
"def change_name(name)\n # swapes names\n name = name.split(' ').reverse.join(' ')\n\n #change all consonant's\n name = name.downcase.split('').map do |l|\n if l.match(/[a,e,i,o,u,\\s]/)\n l = l\n #account for edge case\n elsif l == \"z\"\n l = \"b\"\n else\n l = l.next\n #fixes consonant's that changed into vowels\n if l.match(/[a,e,i,o,u]/)\n l.next\n else\n l = l\n end\n end\n end\n#Loop through vowles\n for i in 0..name.length()-1\n case name[i]\n when \"a\"\n name[i] = \"e\"\n when \"e\"\n name[i] = \"i\"\n when \"i\"\n name[i] = \"o\"\n when \"o\"\n name[i] = \"u\"\n when \"u\"\n name[i] = \"a\"\n end\n end\nname = name.join()\nname = name.split.map(&:capitalize).join(' ')\nputs name\nname\nend",
"def name_converter(first_name, last_name)\n #1. swap the order names\n swapped_names = fake_name(first_name, last_name)\n #2 break swappedNames into array\n character_array = swapped_names.split('')\n #3. iterate through array\n vowel = [\"a\",\"e\",\"i\",\"o\",\"u\"]\n consonant = [\"b\", \"c\", \"d\", \"f\", \"g\", \"h\", \"j\", \"k\", \"l\", \"m\", \"n\", \"p\", \"q\", \"r\", \"s\", \"t\", \"v\", \"w\", \"x\",\"y\",\"z\"]\n\n result = ''\n character_array.each do |character|\n if vowel.include?(character)\n #move forward next vowel in vowel array\n if character == 'u'\n result += 'a'\n next\n end \n \n current_index = vowel.index (character)\n new_index = current_index + 1\n #3. go to vowel array with new_index and retrieve that letter\n # next_letter = 'i'\n # add next_letter to result\n result += vowel[new_index]\n\n #follow same steps for moving forward next vowel for consonant \n\n elsif consonant.include?(character)\n if character == \"z\"\n result += 'b'\n next\n end\n\n current_index = consonant.index (character)\n new_index = current_index + 1\n\n result += consonant [new_index]\n\n result += character \n # add new letter to result\n end\n end\n #4. if the character is a vowel do a vowel swap\n #5. elsif the character is a consonant do a consonant swap\n \n result\nend",
"def reverberate(sent)\n new_arr = []\n words_arr = sent.split(\" \")\n vowels = \"aeiouAEIOU\"\n words_arr.each do |word|\n capt = false\n if word.capitalize == word\n capt = true\n end\n if word.length < 3\n new_arr << capt ? word.capitalize : word #new_arr << capt ? word.capitalize : word\n elsif vowels.include?(word[-1])\n new_arr << (capt ? (word * 2).capitalize : word * 2)\n elsif !vowels.include?(word[-1])\n rev_index = word.chars.reverse.index { |char| vowels.include?(char) }\n i = word.length - 1 - rev_index\n new_arr << (capt ? (word + word[i..-1]).capitalize : word + word[i..-1])\n end\n end\n new_arr.join(\" \")\nend",
"def alias_generator(name)\n\nname = name.downcase\n\nvowels_lowcase = %w(a e i o u)\nvowels = vowels_lowcase\nconsonants_lowcase = (\"a\"..\"z\").to_a - vowels\nconsonants = consonants_lowcase\n\n# original = (vowels + consonants)\n# new_letters = (vowels.rotate + consonants.rotate)\n\nname_array = name.split\nname_reverse = name_array.reverse\n\nname_reverse.map! do |word|\n word_split = word.split(\"\")\n # name_reverse[1].split(\"\")\n\n word_split.map! do |letter|\n if vowels.include? letter\n index = vowels.index(letter)\n if letter == vowels.last\n letter = vowels.first\n else\n letter = vowels[index + 1]\n end\n else\n index = consonants.index(letter)\n if letter == consonants.last\n letter = consonants.first\n else\n letter = consonants[index + 1]\n end\n end\n end\n\n word_split[0] = word_split[0].upcase\n word_split.join('')\nend\n\nname_reverse.join(' ')\n# # p name_reverse.tr(original,new_letters)\n\n\n\nend",
"def next_vowel(str)\n\t# Need to identify the vowels in the English alphabet in a new variable\n\tvowels = [\"a\",\"e\",\"i\",\"o\",\"u\"]\n\t# Need to also identify the consonants in the English alphabet in a new variable\n\tconsonants = [\"b\",\"c\",\"d\",\"f\",\"g\",\"h\",\"j\",\"k\",\"l\",\"m\",\"n\",\"p\",\"q\",\"r\",\n\t\t\"s\",\"t\",\"v\",\"w\",\"x\",\"y\",\"z\"]\n\twords = str.split # Splitting the name into words based on space (' ')\n\t\n\t## Loop into each name\n\ti = 0 # Setting an index to zero\n\tnew_word = [] # Setting up an empty array for our new scrambled word\n\tmod_word = [] # Setting up an empty array to hold the capitalized scrambled word\n\n\twhile i < words.length # Looping into each word\n\t\tchars = words[i].split('') # Split each word into characters\n\t\tnew_chars = chars.map{|char| # Mapping into each character\n\t\t\tif vowels.include?(char) # If the character is included in the vowels variable\n\t\t\t\tvowels.rotate(1)[vowels.index(char)] # Reassign it to the next vowel\n\t\t\telsif consonants.include?(char) # If the character is included in the consonants variable\n\t\t\t\tconsonants.rotate(1)[consonants.index(char)] # Reassign it to the next consonet\n\t\t\telse\n\t\t\t\tchar # Otherwise don't do anything (In case there are odd characters)\n\t\t\tend\n\t\t}\n\t\tnew_word.push(new_chars.join) # rejoin the word\n\t\t# This bit of code capitalizes the first character of the name\n\t\tmod_word.push(new_word[i].slice(0,1).capitalize + new_word[i].slice(1..-1))\n\t\ti += 1 # increment counter\n\tend\n\treturn mod_word.join(' ') # return the rejoined words\nend",
"def spyname(real_name)\n spy_array = []\n split_name = real_name.reverse.split('')\n split_name.join.chars\n split_name.map! do|name|\n name.tr!(\"aeiouAEIUO\",\"eiouaEIOUA\")\n name.tr!(\"bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ\",\"cdfghjklmnpqrstvwxyzbCDFGHJKLMNPQRSTVWXYZB\")\n spy_array << name.to_str\nend\n p spy_array.join\nend",
"def aliass(full_name)\n alphabet = \"bcdfghjklmnpqrstvwxyz\"\n vowels = \"aeiou\"\n new_string = \"\"\n \n #break input word into array and iterate through each letter\n #if the letter is a vowel, take it and change it to next_vowel\n #if the letter is a consonant, take it and change it to consonant\n #else just add with no modification\n full_name.split('').each do |letter|\n if vowels.include?(letter)\n new_string += vowel(letter)\n elsif alphabet.include?(letter)\n new_string += consonant(letter)\n else\n new_string += letter\n end\n end\n #transform this new string into an array\n new_word = new_string.split(' ')\n #swap first and second word in array\n new_word.reverse!\n #turn new word into string\n new_word.map {|names| names.capitalize!}\n new_string = new_word.join(\" \")\n end",
"def alias_creator(name)\n name.downcase!\n name_array = name.split(' ')\n name_array.reverse!\n # insert method for changing vowels here\n post_vowels = next_vowel(name_array)\n # insert method for changing consonants here#\n new_name = next_consonant(post_vowels)\n # re-capitalize the first letter of each name\n new_name.map! {|word| word.capitalize}\n # take our array and turn it into a string\n puts \"Your automatically generated alias is:\"\n p new_name * \" \"\nend",
"def make_fake_name(name)\n # downcase to avoid issues due to capitalization\n # convert name to an array of characters\n # for each letter,\n name = name.downcase.chars.map! do |letter|\n # if it is a vowel, change it to the next vowel\n if 'aeiou'.include?(letter)\n next_vowel(letter)\n # elsif it is a letter, change it to the next consonant\n elsif ('a'..'z').include?(letter)\n next_consonant(letter)\n # otherwise, nil it\n end\n end\n # convert name back to a string and re-capitalize it\n name = name.join.capitalize\nend",
"def spy_name(realname)\n\tvowels = ['a','e','i','o','u']\n\tconsonants = ['b','c','d','f','g','h','j','k','l','m','n','p','q','r','s','t','v','w','x','y','z']\n\treverseName = realname.downcase.split(\" \").reverse!\n\tfullName = reverseName[0] + \" \" + reverseName[1]\n\tletteredName = fullName.split('')\n \tletteredName.map! do |letter|\n \t if vowels.include?(letter)\n \t vowels.rotate(1)[vowels.index(letter)]\n \t elsif consonants.include?(letter)\n \t consonants.rotate(1)[consonants.index(letter)]\n \t end\n \tend\nfullName = letteredName.join('').insert(reverseName[0].length,' ')\nfullName.capitalize!\ntwoNames = fullName.split(\" \")\ntwoNames[1].capitalize!\nfullName = twoNames[0] + \" \" + twoNames[1]\np fullName\nend",
"def make_fake_name (name)\n\t# Swap first & last name\n\tswap_name = name.split(' ').reverse.join(' ')\n\n\t# Swap characters - change all vowels to next vowel,\n\t# and all consonants to next consonant\n\n\t# Initialize fake_name & index (counter) variables \n\tfake_name = ''\n\tindex = 0\n\twhile index < swap_name.length\n\t\tchar = swap_name[index]\n\n\t\t# For each character\n\t\tif char == ' '\n\t\t\t# If space, add space\n\t\t\tfake_name += ' '\n\t\telse\n\t\t\t# Handle lower & uppercase properly\n\t\t\tif char == char.downcase\n\t\t\t\tfake_name += get_swapped_char(char)\n\t\t\telse\n\t\t\t\tfake_name += get_swapped_char(char.downcase).upcase\n\t\t\tend\n\t\tend\n\n\t\t# Increment counter\n\t\tindex += 1\n\tend\n\n\tfake_name\nend",
"def name_swap(name)\n reverse_name = name.downcase.split.reverse.join(' ')\n vowel_swap = reverse_name.tr!('aeiou', 'eioua')\n consonant_swap = vowel_swap.tr!('bcdfghjklmnpqrstvwxyz', 'cdfghjklmnpqrstvwxyz').split\n final_alias = consonant_swap.map(&:capitalize).join(' ')\nend",
"def preform\n length = @sentence.length - 1\n u = 1\n puts @sentence\n for i in (0..length) do\n u == 1 ? @sentence[i] = @sentence[i].upcase : @sentence[i] = @sentence[i].downcase\n u = u*(-1)\n end\n puts @sentence\n end",
"def scramble\n\tconsonants = ['b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'v', 'w', 'x', 'y', 'z', 'B', 'C', 'D', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'V', 'W', 'X', 'Y', 'Z']\n\tvowels = ['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U']\n\n\tputs \"What name would you like to use?\"\n# Get name and return a string\n\t\tspy_name = gets.chomp.to_str\n# Turn into an array to swap name places\n\t\trotate_name = spy_name.split(' ').rotate!\n\t\tp rotate_name\n# Change all of the vowels\n\t\tscramble_name = rotate_name.join(' ')\n\t\tnew_spy_name = scramble_name.split(' ')\n\t\tvowels.each do |vowel|\n\t\t\tnew_spy_name << vowel.next\n\t\tend\nend",
"def name_change(normal_name)\nvowels = \"aeiouAEIOU\".split(\"\")\nconsonants = \"bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ\".split(\"\")\n\nchanged_name = normal_name.split(\" \")\nchanged_name[0], changed_name[1] = changed_name[1], changed_name[0]\n split_name = changed_name.join(\" \")\nname = split_name.split(\"\")\n\nnew_name = \"\"\nname.each_with_index do |letter, letter_index|\n if vowels.include?(letter)\n vowels.each_with_index do |vowel, vowel_index|\n if letter === vowel\n if letter === \"u\"\n new_name << \"a\"\n elsif letter === \"U\"\n new_name << \"A\"\n else\n new_name << vowels[vowel_index+1]\n end\n end\n end\nend\n if consonants.include?(letter)\n consonants.each_with_index do |consonant, consonant_index|\n if letter === consonant\n if letter === \"z\"\n new_name << \"b\"\n elsif letter === \"Z\"\n new_name << \"B\"\n else\n new_name << consonants[consonant_index+1]\n end\n end\n end\nend\n if letter === \" \"\n new_name << \" \"\n end\n end\n new_name\nend",
"def change_name(name)\r\n\t#store new name in new variable, downcase, split in an array and reverse order\r\n\tnew_name = name.downcase.split(' ').reverse.join(' ')\r\n\t#return the array of all the letters\r\n\t#p new_name\r\n\t#puts new_name.length\r\n\t#p new_name\r\n\talias_and_real_name = []\r\n\tindex = 0\r\n\tvowel_list = \"aeiou\"\r\n\tconsonant_list = \"bcdfghjklmnpqrstvwxyz\"\r\n\twhile index < new_name.length\r\n\t\t#[index] takes and integer and retunrs char, .index takes a char\r\n\t\t#and returns integer**\r\n\t\t#Does the letter at the # index of new_name match the vowel_list string\r\n\t\tif vowel_list.include?(new_name[index])\r\n\t\t\t#next_vowel_index is a #\r\n\t\t\t#it equals the vowel string at the letter index \r\n\t\t\t#from new_name's # index\r\n\t\t\t#Then get the next number\r\n\t\t\tnext_vowel_index = vowel_list.index(new_name[index]).next\r\n\t\t\t#new_name at that index # now equal this new # \r\n\t\t\t#Equals the vowel list at index of the next #\r\n\t\t\tnew_name[index] = vowel_list[next_vowel_index]\r\n\t\t\t\t#Solve for edge cases\r\n\t\t\t\t#If the letter is the name is going to be the last letter \r\n\t\t\t\t#in the vowel string, change it automatically to \r\n\t\t\t\t#the first on\r\n\t\t\r\n\t\t\t\r\n\t\telsif consonant_list.include?(new_name[index])\r\n\t\t\tnext_consonant_index = consonant_list.index(new_name[index]).next\r\n\t\t\tnew_name[index] = consonant_list[next_consonant_index]\r\n\r\n\t\tend #End if statement\r\n\t\t#Incriment outside of if statment but inside while loop\r\n\t\tindex += 1\r\n\t\r\n\tend #End While loop\r\n\r\n\t#return the new alias name\r\n\tnew_name\r\n\t\r\n\t#Take the alias name and stoe it in an array, new name first and real \r\n\t#name second\r\n\talias_and_real_name << new_name << name\r\n\t\r\n#End method\t\t\r\nend",
"def next_vowcon(oldlet) #actually takes in the whole name (not just 1 letter), since it is only split to an array of [first_name, last_name]\r\n vowel = ['a','e','i','o','u']\r\n rot_vow = vowel.rotate #reverses vowel array\r\n consonant = 'bcdfghjklmnpqrstvwxzy'.split('')\r\n rot_cons= consonant.rotate #reverses consonant array\r\n i=0\r\n while i < oldlet.length\r\n if vow_index = vowel.index(oldlet[i])\r\n oldlet[i] = rot_vow[vow_index]\r\n else\r\n cons_index = consonant.index(oldlet[i])\r\n oldlet[i] = rot_cons[cons_index]\r\n end\r\n i +=1\r\n end\r\n return oldlet\r\nend",
"def fake_name(name)\n fake_name = name.chars.map! do |letter|\n if letter == \" \"\n letter = \" \"\n elsif \"aeiou\".include?(letter)\n letter = next_vowel(letter)\n elsif \"zdhnt\".include?(letter)\n letter = pre_vowel_scramble(letter)\n else\n letter.next\n end\n end\n fake_name = fake_name.join\n swap_name_order(fake_name)\nend",
"def letter_swap(agent_name)\n vowels = \"aeiou\"\n consonants = \"bcdfghjklmnpqrstvwxyz\"\n letter_swap = agent_name.split(\"\")\n secret_name = []\n letter_swap.map! do |ltr|\n if vowels.include?(ltr)\n secret_name << vowels[vowels.index(ltr)+1]\n elsif consonants.include?(ltr)\n secret_name << consonants [consonants.index(ltr)+1]\n else\n puts \" \"\n end\n end\n\n secret_name.join(\"\").split.map {|ltr| ltr.capitalize}.join(' ').capitalize\n\nend",
"def recombiner (array_of_char)\n new_name = array_of_char.join.split(' ').reverse\n new_name.map! do | words |\n words.capitalize\n end\n new_name.join(' ')\nend",
"def name_reverser(string)\r\n name_array = string.split(' ').reverse\r\n modified_name = name_array.join(' ')\r\nend",
"def your_name_reversed(x)\r\n x.to_str\r\n x.downcase! # Ensure all down-case for easier future coding\r\n x = x.split(' ')\r\n return x.reverse # Returns the swapped last and first name\r\nend",
"def swap_split_name(name)\n split_name = name.split(' ')\n split_name.shuffle!\n split_name.join(' ')\nend",
"def letter_change\n consonant = \"bcdfghjklmnpqrstvwxyz\"\n vowel = \"aeiou\"\n new_name = \"\"\n letter_new = \"\"\n\n split_flip_name.each do |letter|\n if consonant.index(letter) != nil\n letter_new = consonant[consonant.index(letter) + 1]\n elsif vowel.index(letter) != nil\n #addresses last vowel edge case\n if letter == \"u\"\n letter_new = \"a\"\n elsif\n letter_new = vowel[vowel.index(letter) + 1]\n end\n elsif letter == \" \"\n letter_new = letter\n end\n #.to_s addresses a nil edge case\n new_name += letter_new.to_s\n end\n p new_name\n\nend",
"def reverse(real_name)\r\n\treverse = real_name.split(' ').rotate\r\n\treverse_name = reverse.join(' ')\r\nend",
"def consenant_swap(name)\r\n name = name.downcase\r\n consenants = \"bcdfghjklmnpqrstvwxyz\"\r\n name_index = 0\r\n cons_index = 0\r\n while name_index < name.length\r\n if name[name_index] == \"a\" || name[name_index] == \"e\" ||name[name_index] == \"i\"|| name[name_index] == \"o\" || name[name_index] == \"u\" || name[name_index] == \" \"\r\n name_index += 1\r\n elsif name[name_index] == \"z\"\r\n name[name_index] = \"b\"\r\n name_index += 1\r\n else\r\n until name[name_index] == consenants[cons_index]\r\n cons_index += 1\r\n end\r\n name[name_index] = consenants[cons_index + 1]\r\n name_index += 1\r\n end\r\n cons_index = 0\r\n end\r\n name\r\nend",
"def fake_name(real_name)\n\treal_full_name = real_name.split(\" \")\n\treal_first_name = real_full_name[0].downcase \n\treal_last_name = real_full_name[1].downcase\n\talphabet = [\"a\",\"b\", \"c\", \"d\", \"e\",\"f\", \"g\", \"h\",\"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\"]\n\ti = 0\n\tfake_first_name = \"\"\n\tfake_last_name = \"\"\n\tlength_first = real_first_name.length\n\tlength_last = real_last_name.length \n\n\twhile i < length_first\n\t\tif real_first_name[i] == \"z\"\n\t\t\tfake_first_name += \"a\"\n\t\telsif real_first_name[i] == \"a\" || real_first_name[i] ==\"e\" || \n\t\t\t real_first_name[i] == \"i\" || real_first_name[i] == \"o\" || \n\t\t\t real_first_name[i] == \"u\"\n\t\t\tfake_first_name += real_first_name[i] \n\t\telsif \n\t\t\tind = alphabet.index(real_first_name[i])\n\t\t\tfake_first_name += alphabet[ind+1]\n\t\tend \n\t\ti+=1\n\t\t#fake_first_name[0] = fake_first_name[0].upcase\n\tend \n\tfake_first_name\nend",
"def name_swap(str)\n\tname_array = str.split(' ')\n\t\tname_array.reverse!\n\t\tname_array[0].insert(-1, \" \")\n\t\tname_array.join('').downcase!\nend",
"def rearranger(str)\nstr = str.split(' ')\nfinal = str.reverse.join(' ')\nfinal = final.downcase\nend",
"def alias\n puts \"Hello Agent, what is your name?\"\n original_name = gets.chomp.downcase\n\n# split first and last name into two arrays\n#swap first name and last name \n\n split_name = original_name.split\n reverse_name = split_name.reverse!\n \n #join back together in a string with a space\n new_name = reverse_name.join(\" \")\n \n\n# each character into it's own array\n\n letters = new_name.each_char.to_a\n#vowel logic\n#if a charcters = vowel then change to next vowel\n\n\n\n vowels = %w(a e i o u a)\n consonant = %w(b c d f g h j k l m n p q r s t v w x y z b)\n new_alias = letters.map do |letter|\n letter.next \n end\nputs new_alias.join('')\nend",
"def namecoder\n valid_input = false\n until valid_input\n secret_name_database = []\n \n puts \"Whats your first name?\"\n fname = gets.chomp.downcase.split('')\n puts \"What's your last name?\"\n lname = gets.chomp.downcase.split('')\n original_name = [fname,\" \", lname].join\n fullname = [fname,\" \", lname].reverse.flatten\n # p fullname\n \n fullalphabet = \"abcdefghijklmnopqrstuvwxyz\"\n consonants = ['b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'v', 'w', 'x', 'y', 'z']\n alpha = ['a', 'b', 'c', 'd', 'e', 'u', 'z']\n vowels = ['a', 'e', 'i', 'o', 'u']\n \n # vowel_code(original_name)\n vowels = ['a', 'e', 'i', 'o', 'u']\n fn_vowel = fullname.map do |vowel|\n if vowels.include?(vowel)\n vowels.rotate(1)[vowels.index(vowel)]\n else\n vowel\n end\n end\n # p fn_vowel \n # name_vowels_changed.join\n \n # def cons_code(name_vowels_changed)\n # name_vowels_changed = name_vowels_changed.split('')\n name_both_changed = fn_vowel.map do |cons|\n if consonants.include?(cons)\n consonants.rotate(1)[consonants.index(cons)]\n else\n cons\n end\n end\n # p name_both_changed\n secret_name = name_both_changed.join\n orig_fullname = fullname.join.capitalize\n secret_name_database << [original_name, secret_name]\n p original_name\n p secret_name\n \n puts \"Press enter if you'd like to do another name. Otherwise, type 'quit'.\"\n continue = gets.chomp\n if continue == \"quit\"\n puts \"Thank you for using the program. Here is your list of names:\"\n secret_name_database.each do |orig, secret|\n puts \"#{orig}'s secret name is #{secret}.\"\n end \n valid_input = true\n else\n puts \"Time to add another name...\"\n end \n end\nend",
"def swapping_names(name)\n names = name.split('')\n names.reverse!\n names.join('')\nend",
"def swap_name(real_name)\n swapped_name = real_name.split(/ /).reverse #split and swap first name and last name\n last_name = swapped_name[0].chars\n first_name = swapped_name[1].chars\n swapped_name = [last_name, first_name] #split characters of the first and last names\nend",
"def downcase!() end",
"def aliass(full_name)\n\talphabet = \"bcdfghjklmnpqrstvwxyz\"\n\tvowels = \"aeiou\"\n\tnew_string = \"\"\n\n\t#break input word into array and iterate through each letter\n\t#if the letter is a vowel, take it and change it to next_vowel\n\t#if the letter is a consonant, take it and change it to consonant\n\t#else just add with no modification\n\tfull_name.split('').each do |letter|\n\t\tif vowels.include?(letter)\n\t\t\tnew_string += vowel(letter)\n\t\telsif alphabet.include?(letter)\n\t\t\tnew_string += consonant(letter)\n\t\telse\n\t\t\tnew_string += letter\n\t\tend\n\tend\n\t#transform this new string into an array\n\tnew_word = new_string.split(' ')\n\t#swap first and second word in array\n\tnew_word.reverse!\n\t#turn new word into string\n\tnew_word.map {|names| names.capitalize!}\n\tnew_string = new_word.join(\" \")\nend",
"def vowel_swap (secret_name)\n\t#first separate string into an array of characters\n\t#the loop through looking for vowels\n\t#use each do loop to then go through each character\n\t#check to see if it is a vowel using gsub and replace with the next vowel\n\t#have to replace with an uppercase vowel, so when a becomes 'e' and then I check for 'e's, those 'a's don't become 'i's and etc\n\tsecret_name = secret_name.split('')\n\tsecret_name.each do |letters|\n\t\tletters.gsub!(/[a]/, \"E\")\n\t\tletters.gsub!(/[e]/, \"I\")\n\t\tletters.gsub!(/[i]/, \"O\")\n\t\tletters.gsub!(/[o]/, \"U\")\n\t\tletters.gsub!(/[u]/, \"A\")\n\tend\n\t#then downcase eveything\n\tsecret_name.map!{|letter| letter.downcase}\n\t\nend",
"def vowels_consonant_movement2(name)\n name = name.downcase.split(\" \")\nfirst_name = name[0]\nsecond_name = name[1]\n consonants = \"bcdfghjklmnpqrstvwxyz\"\n vowels = \"aeiou\"\n translated_name = []\n translated_name2 = []\n\n#adjust first name \n x = 0 \n while x < first_name.length\n if first_name[x] == \"z\"\n first_name[x] = \"b\"\n translated_name << first_name[x]\n elsif\n first_name[x] == \"u\"\n first_name[x] = \"a\"\n translated_name << first_name[x]\n \n elsif consonants.include?first_name[x]\n \n new_position = consonants.index(first_name[x]) + 1 \n \n first_name[x] = consonants[new_position]\n translated_name << first_name[x]\n \n elsif vowels.include?first_name[x]\n newer_position = vowels.index(first_name[x]) + 1\n first_name[x] = vowels[newer_position]\n translated_name << first_name[x]\n \n end\n \n x += 1\n end\n \n#adjust second name \n x = 0 \n while x < second_name.length\n if second_name[x] == \"z\"\n second_name[x] = \"b\"\n translated_name2 << second_name[x]\n elsif\n second_name[x] == \"u\"\n second_name[x] = \"a\"\n translated_name2 << second_name[x]\n \n elsif consonants.include?second_name[x]\n \n new_position = consonants.index(second_name[x]) + 1 \n \n second_name[x] = consonants[new_position]\n translated_name2 << second_name[x]\n \n elsif vowels.include?second_name[x]\n newer_position = vowels.index(second_name[x]) + 1\n second_name[x] = vowels[newer_position]\n translated_name2 << second_name[x]\n \n end\n \n x += 1\n end\n \n first_letter = translated_name[0].upcase\n translated_name.delete_at(0)\n translated_name.insert(0, first_letter)\n \n first_letter2 = translated_name2[0].upcase\n translated_name2.delete_at(0)\n translated_name2.insert(0, first_letter2)\n \n return translated_name2.join(\"\") + \" \" + translated_name.join(\"\")\n \n \nend",
"def swap_names(given_name) # WORKS!\n last_first_array = given_name.split(' ').reverse # returns array of [\"last name\", \"first name\"]\n\n last_first_array\nend",
"def swap_name_order(name)\n # Split input into first name and last name\n first_name = name.split(' ')[0].capitalize\n last_name = name.split(' ')[1].capitalize\n fake_name_1 = last_name + \" \" + first_name\nend",
"def name_swap(name)\n new_name = name.downcase.split(' ')\n spy_name = new_name[1] + ' ' + new_name[0]\n vowels = 'aeioua'\n consonants = 'bcdfghjklmnpqrstvwxyzb'\n new_letter = \"\"\n spy_name.chars.each do |letter|\n if vowels.include?(letter)\n new_letter += change_vowels(letter)\n #p new_letter\n elsif consonants.include?(letter)\n new_letter += change_consonant(letter)\n #p new_letter\n else\n new_letter += letter\n end\n end\n change_name = new_letter.split(' ')\n final_name = change_name.map{|name| name.capitalize}.join(' ')\n# Add a hash to store names and alias names\n alias_names = { name: name, encrypted_name: final_name}\n alias_names.store(:name, name)\n alias_names.store(:encrypted_name, final_name)\n return alias_names\n end",
"def alias_maker(name)\n \n consonants = \"bcdfghjklmnpqrstvwxz\"\n next_cons = \"cdfghjklmnpqrstvwxzb\"\n \n name.downcase.tr(consonants,next_cons)\n .tr('aeiouy', 'eiouya')\n .split.reverse.each {|word| word.capitalize!}\n .join(' ')\n\n # Separated methods on lines 24-27 for readability\n # First .tr changes all consonants to next\n # Second .tr changes all vowels to next vowel\n # Split names to reverse and capitalize them\n # Rejoin to a single string\n\nend",
"def alias_method (name)\r\n\tnew_first = []\r\n\tnew_last = []\r\n\tvowels_string = \"aeiou\"\r\n\tvowels = vowels_string.split('')\r\n\tconsonants_string = \"bcdfghjklmnpqrstvwxyz\"\r\n\tconsonants = consonants_string.split('')\r\n\ttwo_names = name.split(' ')\r\n\tfirst_name = two_names[0].split('')\r\n\tlast_name = two_names[1].split('')\r\n\tlast_name.each do |character|\r\n\t\tcharacter = character.downcase\r\n\t\tif vowels.include?(character)\r\n\t\t\tindex = vowels.index(character)\r\n\t\t\tnew_last.push(vowels[index + 1])\r\n\t\tend\r\n\t\tif consonants.include?(character)\r\n\t\t\tindex = consonants.index(character)\r\n\t\t\tnew_last.push(consonants[index + 1])\r\n\t\tend\r\n\t\tif character.downcase == 'z'\r\n\t\t\tnew_last.push('b')\r\n\t\tend\r\n\t\tif character.downcase == 'u'\r\n\t\t\tnew_last.push('a')\r\n\t\tend\r\n\tend\r\n\tfirst_name.each do |character|\r\n\t\tcharacter = character.downcase\r\n\t\tif vowels.include?(character)\r\n\t\t\tindex = vowels.index(character)\r\n\t\t\tnew_first.push(vowels[index + 1])\r\n\t\tend\r\n\t\tif consonants.include?(character)\r\n\t\t\tindex = consonants.index(character)\r\n\t\t\tnew_first.push(consonants[index + 1])\r\n\t\tend\r\n\t\tif character.downcase == 'z'\r\n\t\t\tnew_first.push('b')\r\n\t\tend\r\n\t\tif character.downcase == 'u'\r\n\t\t\tnew_first.push('a')\r\n\t\tend\r\n\tend\r\n\tnew_last.push(' ')\r\n\tnew_last = new_last.join('').capitalize\r\n\tnew_first = new_first.join('').capitalize\r\n\treturn_val = new_last + new_first\r\n\treturn_val\r\nend",
"def downcase(input); end",
"def reverse_each_word(sentence1)\n ## sentence1.split turns the string into an array, where each word is an element of the array. No spaces.\n sentence_array = sentence1.split\n sentence_array.collect { |word|\n \n ## .reverse! reverses each word \"in place\", not creating new\n word.reverse!\n }\n ## .join(\" \") takes the elements of the array, joins them as a string with a space between each \n sentence_array.join(\" \")\nend",
"def make_fake_name (name)\n\t# Swap first & last name\n\tswap_name = name.split(' ').reverse.join(' ')\n\n\tfake_name = ''\n\tindex = 0\n\twhile index < swap_name.length\n\t\tchar = swap_name[index]\n\t\tif char == ' '\n\t\t\tfake_name += ' '\n\t\telse\n\t\t\tif char == char.downcase\n\t\t\t\tfake_name += get_swapped_char(char)\n\t\t\telse\n\t\t\t\tfake_name += get_swapped_char(char.downcase).upcase\n\t\t\tend\n\t\tend\n\n\t\t# Increment counter\n\t\tindex += 1\n\tend\n\n\tfake_name\nend",
"def upcase!() end",
"def downcase() end",
"def reverse_each_word(sentence)\n sentence_array = sentence.split #convert to array\n reverse_sentence_array = sentence_array.collect do |word| #returns new array\n word.reverse #reverse order of returned argument\n end\n reverse_sentence = reverse_sentence_array.join(\" \") #returns the array to a string\n return reverse_sentence #run that puppy\nend",
"def reverser\nwords=yield.split(\" \")\noutpt=\"\"\nwords.map do\n |w|\noutpt= outpt + w.reverse + \" \"\n end\noutpt [0...-1]\nend",
"def reverse_each_word(s_input)\n a_input = s_input.split # convert scentance to array\n reversed = \"\" # string to hold reversed scentance\n # go through each word\n\n a_input.each_with_index { |word, index|\n characters = word.split \"\" # split the word into an array\n characters = characters.reverse # reverse the chars in array\n # puts \"#{characters} #{characters.is_a?(Array)}\"\n new_word = characters.join \"\" # join characters array into a word\n if index == 0\n reversed << \"#{new_word}\" # shovel the new_word into the string reversed without space if first word\n else\n reversed << \" #{new_word}\" # shovel the new_word into the string reversed\n end\n }\n reversed\nend",
"def swap_name(name)\n new_name = name.downcase.split.reverse\n new_name = new_name.join(\" \")\n new_name = new_name.chars\n new_name.map! do |letter|\n if letter == \" \"\n \" \"\n else\n letter_changer(letter)\n end\n end\n new_name = new_name.join('')\nend",
"def name_scrambler\r\n\t\r\n\r\n\tscrambled_names = {}\r\n\tputs \"What is your first and last name?\"\r\n\tuser_name = gets.chomp \r\n\twhile user_name != \"quit\" && user_name != \"\" \r\n\t\tnew_name = user_name.downcase.split(' ').reverse!.join(' ')\r\n\t\tname_to_array = new_name.chars\r\n\t\t# This takes the string version of the name and makes it into an \tarray, with each letter separated. \r\n\t\tconsonants = %w{b c d f g h j k l m n p q r s t v w x y z}\r\n\t\tvowels = %w{a e i o u}\r\n\t\t# Setting the new strings we want our conditions to match\r\n\t\tname_to_array.map! do |letter| \r\n\t\t\tif letter == \"u\"\r\n\t\t\t\tletter = \"a\"\r\n \t\t\telsif vowels.include?(letter)\r\n \t\t\t\t# if the letter returns a true value(is a vowel), re\t-assign a new index to that letter (advanced by 1)\r\n \t\t\t\tnew_vowel_index = vowels.index(letter) + 1\r\n \t\t\t\tnew_vowel = vowels[new_vowel_index]\r\n\t\t\telsif letter == \"z\"\r\n\t\t\t\tletter = \"b\"\r\n\t\t\telsif consonants.include?(letter)\r\n\t\t\t\tnew_consonant_index = consonants.index(letter) + 1\r\n\t\t\t\tnew_consonant = consonants[new_consonant_index]\r\n\t\t\telse \r\n\t\t\t\tletter # Accounts for spaces\r\n\t\t\tend\t\t\r\n\t\tend\r\n\t\t#re capitalize by joining the indiv. letters, splitting into first \tand last, capitalizing, and rejoining\r\n\t\tscrambled_name = name_to_array.join('').split(\" \").each{|i| i\t.capitalize!}.join(\" \")\r\n\t\tscrambled_names[user_name] = scrambled_name\r\n\t\tuser_name = gets.chomp #assigns new input to user_name to see if it should loop back to begining or quit\r\n\t\tend \r\nscrambled_names.each do |user_name, scrambled_name|\r\n\tputs \"#{scrambled_name} is more commonly known as #{user_name}\"\r\nend \r\nend",
"def name_swap(name_to_be_altered)\n\t#STEP \t1) Breaking it into a word array\n\n\tname_arrayed = name_to_be_altered.split(' ')\n\t# STEP\t2) Doing a method that switches the first and second elements in the array\n\tname_arrayed.insert(0, name_arrayed.delete_at(1))\nend",
"def reverser \n\twords = yield\n\twords.split.map {|word| word.reverse}.join(\" \") # figured out that map yield the result as an array.\nend",
"def fake_name_c2(real_name)\n\treal_full_name = real_name.split(\" \")\n\treal_first_name = real_full_name[0] \n\treal_last_name = real_full_name[1]\n\ti = 0\n\tfake_first_name = \"\"\n\tfake_last_name = \"\"\n\tvowel_index = \"\"\n\tlength_first = real_first_name.length\n\tlength_last = real_last_name.length \n\t\twhile i < length_last\n\t\tif real_last_name[i] == \"z\"\n\t\t\tfake_last_name += \"a\"\n\t\telsif real_last_name[i] == \"a\" || real_last_name[i] ==\"e\" || \n\t\t\t real_last_name[i] == \"i\" || real_last_name[i] == \"o\" || \n\t\t\t real_last_name[i] == \"u\"\n\t\t\tfake_last_name += real_last_name[i] \n\t\telse \n\t\t\tfake_last_name += real_last_name[i].next \n\t\tend \n\t\ti+=1\n\tend\n\tfake_last_name\nend",
"def consonant_swap (secret_name)\n\t\n\tsecret_name.map do |letters|\n\t\t\n\t\tif letters == \" \"\n\t\t\tletters\n\t\telsif letters == \"z\"\n\t\t\tletters.gsub!(/[z]/, \"a\")\n\t\telsif letters =~ /[aeiou]/\n\t\t\tletters\n\t\telse \n\t\t\tletters.next!\n\t\t\tif letters =~ /[aeiou]/\n\t\t\t\tletters.next!\n\t\t\tend\n\t\tend\n\n\tend\n\tsecret_name\nend",
"def alias_creator(nickname)\nvowels=\"aeiou\"\nconsonants=\"bcdfghjklmnpqrstvwxyz\"\n#consonants exclude all vowels\n\nnickname_split=nickname.split(\"\")\nnew_nickname=[]\n#The translated nickname will be saved in the new_nickname arrawy\n\nnickname_split.map! do |x|\n\tif vowels.include?(x)\n\t\tnew_nickname << vowels[vowels.index(x)+1]\n\telsif consonants.include?(x)\n\t\tnew_nickname << consonants[consonants.index(x)+1]\n\telsif x == \" \"\n\t\tnew_nickname << \" \"\n\tend\nend\nnew_nickname.join(\"\").split.map {|x| x.capitalize}.join(\" \")\n#We are doing this so that we capitalize the first letter of both words\nend",
"def reverberate(sentence)\n vowels = \"aeiou\"\n words = sentence.split(\" \")\n converted_sentence = []\n\n words.each do |word|\n if word.length < 3\n converted_sentence << word\n elsif vowels.include?(word[-1].downcase)\n converted_sentence << word + word[0].downcase + word[1..-1]\n else\n uppercase = word[0] == word[0].upcase ? true : false\n count = word.length - 1\n\n while count > 0\n if vowels.include?(word[count])\n new_word = word + word[count..-1]\n converted_sentence << new_word\n break\n end\n count -= 1\n end\n end\n end\n\n converted_sentence.join(\" \")\nend",
"def name_change(real_name)\r\n\tnew_name = real_name.downcase.split(' ')\r\n\tnew_name.map! { |real_name|\r\n\t\treal_name.split('').map! { |char|\r\n\t\t\tif \"aeiou\".index(char) != nil\r\n\t\t\t\tchange_char(char, \"aeiou\")\r\n\t\t\telse \r\n\t\t\t\tchange_char(char, \"bcdfghjklmnpqrstvwxyz\")\r\n\t\t\tend\r\n\t\t}\r\n\t}\r\n\tnew_first_name = new_name[1].join('')\r\n\tnew_last_name = new_name[0].join('')\r\n\treturn new_first_name.capitalize + \" \" + new_last_name.capitalize\r\nend",
"def next_letter(name)\r\n\t# Create master replacement list\r\n\t# We'll replace each letter with the next one in the list\r\n\t# Edge cases, upper case, etc. are handled within a single list\r\n\tswap_list = \"aeiouabcdfghjklmnpqrstvwxyzb\"\r\n\t# add upper case letters\r\n\tswap_list = swap_list + swap_list.upcase\r\n\t# divide name into array of characters\r\n\tletters = name.chars\r\n\t# swap each letter in array\r\n\tnew_letters = letters.map do |letter|\r\n\t\ti = swap_list.index(letter)\r\n\t\tif i\r\n\t\t\t# switch letter with next letter in list\r\n\t\t\tswap_list[i+1]\r\n\t\telse\r\n\t\t\t# keep as is\r\n\t\t\tletter\r\n\t\tend\r\n\tend\r\n\t# convert new array into string\r\n\tnew_name = new_letters.join\r\n\treturn new_name\r\nend",
"def fakeName(name)\r\n\tnameLen = name.length\r\n\tnameIndex = 0\r\n\tvowels = [\"a\", \"e\", \"i\", \"o\", \"u\"]\r\n\tcons = [\"b\", \"c\",\"d\", \"f\",\"g\", \"h\",\"j\", \"k\",\"l\", \"m\",\"n\", \"p\",\"q\", \"r\",\"s\", \"t\",\"v\", \"x\", \"z\",\"w\", \"y\"]\r\n\tnewName = \"\"\r\n\twhile nameIndex < nameLen\r\n\t\tvowelArrayIndex = 0\r\n\t\tvowels.each do |vow|\r\n\t\t\tif name[nameIndex] == vow\r\n\t\t\t\tnextchar = next_vowel(vowelArrayIndex)\r\n\t\t\t\tnewName = newName + nextchar\r\n\t\t\tend\r\n\t\t\tvowelArrayIndex += 1\r\n\t\tend\r\n\t\tvowelArrayIndex = 0\r\n\t\tconsArrayIndex = 0\r\n\t\tcons.each do |cons|\r\n\t\t\tif name[nameIndex] == cons\r\n\t\t\t\tnextchar = next_cons(consArrayIndex)\r\n\t\t\t\tnewName = newName + nextchar\r\n\t\t\tend\r\n\t\t\tconsArrayIndex += 1\r\n\t\tend\r\n\t\tnameIndex += 1\r\n\tend\r\n\treturn newName\r\nend",
"def case_fix(name)\r\n fixed_name = name.split(' ')\r\n fixed_name.each do |word|\r\n word.capitalize!\r\n end\r\n fixed_name.join(' ')\r\nend",
"def process_names(agent_name)\r\n agent_name.reverse!\r\n coded_name = []\r\n for\r\n name in agent_name\r\n coded_name << (name.chars.map {|letter| shift_char(letter)}).join(\"\")\r\n end\r\n coded_name.map! {|name| name.capitalize}\r\n return coded_name\r\nend",
"def swap (secret_name)\r\n\tswapped_name = secret_name.split.reverse\r\n\tswapped_name.map(&:capitalize).join (\" \")\r\nend",
"def change_me(string)\n result = []\n words = string.split\n iterator = 0\n loop do\n break if iterator == words.size\n word = words[iterator]\n if word.reverse == word\n result << word.upcase\n else\n result << word\n end\n iterator += 1\n end\n result.join(' ')\nend",
"def advance(string)\n\n vowels_str = 'aeioua'\n vowels_arr = vowels_str.split('')\n consonants_str = 'bcdfghjklmnpqrstvwxyzb'\n consonants_arr = consonants_str.split('')\n \n string0 = string.downcase.split[1] + \" \" + string.downcase.split[0]\n str1 = string0.split('')\n\n str_new = str1.map do |char|\n if vowels_arr.include?(char)\n vowels_arr.rotate(1)[vowels_arr.index(char)]\n elsif consonants_arr.include?(char)\n consonants_arr.rotate(1)[consonants_arr.index(char)]\n else\n char\n end\n end\n\n newname = str_new.join #joining the array into a string\n spyname = newname.split.map(&:capitalize).join(' ') #splitting that string to capitalize the first letter, then rejoining\n p spyname\n realname = string.split.map(&:capitalize).join(' ')\n $codenames << [spyname, realname]\nend",
"def next_vowel(name)\n\tvowels = %w( a e i o u )\n\tname = name.downcase!.split('')\n\tnew_name = name.map do |vowels_method|\n\t\tif vowels.include?(vowels_method)\n\t\t\tvowels.rotate(1)[vowels.index(vowels_method)]\n\t\telsif vowels == 'u'\n\t\t\tvowels.replace('a')\t\n\t\telse\n\t\t\tvowels_method\n\t\tend\n\tend\n\tnew_name.join.capitalize\nend",
"def swap_names(name)\n real_names = name.downcase.split(\" \")\n real_names[0], real_names[-1] = real_names[-1], real_names[0]\n real_names.join(\" \")\nend",
"def nameswap(name)\n name_reverse = []\n nameary = name.split(' ')\n counter = 1 \n loop do \n name_reverse << nameary[counter]\n counter -= 1\n break if counter < 0\n end\n \n name_reverse.join(', ')\nend",
"def swap(real_name)\n real_name.split(\" \").reverse.join(\" \")\nend",
"def vowel_changer(name)\n vowel_string = \"aeiou\"\n name_array = name.downcase.chars\n new_name = []\n name_array.each do |character|\n if character == \"u\"\n character = \"a\"\n new_name << character\n elsif vowel_string.include? character\n character = vowel_string[vowel_string.index(character) +1]\n new_name << character\n else\n new_name << character\n end\n end\n new_name.join(\"\").split(\" \").each {|word| word.capitalize!}.join(\" \")\nend",
"def undercover_name(name)\n name.downcase.split(' ').map!{|name| name.split('').map! {|letter| next_letter(letter)}.join('').capitalize}.reverse.join(\" \")\nend",
"def swap(string)\n\tswapper = string.split\n\tstring = swapper.reverse.join(\" \")\n\tstring.downcase!\n\tvowels = \"aeioua\"\n\tcon = \"bcdfghjklmnpqrstvwxyzb\"\n\tindex = 0\n\tfinal_string = \"\"\n\tstring.length.times do |index|\n\t\tif !con.include?(string[index]) && !vowels.include?(string[index])\n\t\t\tfinal_string.concat(\" \")\n\t\t\telsif vowels.include?(string[index])\n\t\t\tnext_vowel = vowels[vowels.index(string[index]) +1]\n\t\t\tfinal_string << next_vowel\n\t\t\telsif con.include?(string[index])\n\t\t\tnext_con = con[con.index(string[index]) +1]\n\t\t\tfinal_string << next_con\n\t\tend\n\t\tindex += 1\n\tend\n\tfinal_string = final_string.split.map! { |x| x.capitalize }.join(' ')\n\tfinal_string\nend",
"def upcase() end",
"def name_swap(name)\r\n new_name = name.split(' ')\r\n new_name.reverse.join(' ')\r\nend",
"def reverse_each_word(sentence1)\r\nnew_array = []\r\nsentence1.split.collect do |words| new_array << \"#{words}\".reverse\r\n end\r\nnew_array.join(\" \")\r\nend",
"def reverser\n words= yield.split\n for word in words\n word.reverse!\n end\n words.join(\" \")\nend",
"def letter_reverse(sentence)\n # sentence.split(\" \").map(&:reverse).join(\" \")\n # sentence.gsub(/\\w+/) { |word| word.reverse }\n sentence.gsub(/\\w+/, &:reverse)\nend",
"def shout(words)\n\twords.upcase\nend"
] |
[
"0.77351695",
"0.75496525",
"0.7407175",
"0.73109394",
"0.7303107",
"0.72255796",
"0.721326",
"0.7208969",
"0.720212",
"0.720212",
"0.7192026",
"0.7176667",
"0.7155657",
"0.7142886",
"0.71254236",
"0.7119707",
"0.71136874",
"0.7111007",
"0.7098042",
"0.7076834",
"0.7073612",
"0.706748",
"0.7054422",
"0.7049335",
"0.7022643",
"0.7021883",
"0.69393134",
"0.6930868",
"0.6914353",
"0.69094306",
"0.6907108",
"0.68965364",
"0.68830025",
"0.68754774",
"0.68467504",
"0.6826332",
"0.68237966",
"0.68127185",
"0.67981017",
"0.6786217",
"0.6784655",
"0.6777703",
"0.6774608",
"0.67689645",
"0.6736738",
"0.6708722",
"0.6691639",
"0.6681578",
"0.6677457",
"0.6676239",
"0.66744506",
"0.6662962",
"0.6654559",
"0.664831",
"0.6636078",
"0.66253054",
"0.6618427",
"0.6596903",
"0.6575173",
"0.6561758",
"0.6561261",
"0.65453947",
"0.6533102",
"0.6524918",
"0.6524413",
"0.6522181",
"0.6519994",
"0.65156657",
"0.65126806",
"0.65123034",
"0.6509193",
"0.6496274",
"0.64846563",
"0.6480717",
"0.6474266",
"0.64683276",
"0.6467744",
"0.64646816",
"0.6455931",
"0.6452136",
"0.64463925",
"0.6440312",
"0.6439306",
"0.64352995",
"0.6428232",
"0.6427459",
"0.6423213",
"0.6422558",
"0.64183986",
"0.640739",
"0.6403388",
"0.64019096",
"0.64000285",
"0.63923043",
"0.6390673",
"0.63878465",
"0.6382001",
"0.63801813",
"0.6379823",
"0.6376176"
] |
0.70827025
|
19
|
Eigenclass Return a new instance of Vedeu::Interfaces::Clear.
|
def initialize(name = Vedeu.focus)
@name = present?(name) ? name : Vedeu.focus
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def clear\n raise NotImplementedError\n end",
"def clear\n raise NotImplementedError\n end",
"def clear()\n\t\treturn Clear.new\n\tend",
"def clear\n raise \"not implemented\"\n end",
"def clear\n initialize\n end",
"def clear\n initialize\n end",
"def clear\n initialize\n self\n end",
"def clear\n # self\n end",
"def clear!; end",
"def clear!; end",
"def clear!; end",
"def clear\n self.class.empty\n end",
"def clear\n instance.clear\n end",
"def clear!\n end",
"def clear\n @registry.clear\n self\n end",
"def clear_model\n class_eval do\n # Remove event models\n events.each_key do |ev_symbol|\n remove_const ev_symbol.to_s.camelcase(:upper)\n end\n\n [@events, @signal_sets, @forwarding_sets, @causal_link_sets,\n @arguments, @handler_sets, @precondition_sets].each do |set|\n set&.clear\n end\n end\n super\n end",
"def clear; end",
"def clear; end",
"def clear; end",
"def clear; end",
"def clear; end",
"def clear; end",
"def clear; end",
"def clear\n namespace + '_clear'\n end",
"def clear() end",
"def clear() end",
"def clear\n end",
"def clear\n end",
"def clear\n end",
"def clear!\n @data = []\n return self\n end",
"def clear\n if block_given?\n return @j_del.java_method(:clear, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result : nil) }))\n end\n raise ArgumentError, \"Invalid arguments when calling clear()\"\n end",
"def clear_all\n NotImplementedError\n end",
"def clear\n end",
"def clear\n end",
"def clear\n end",
"def initialize()\n clear\n end",
"def clear\n @data.resize(0, 0)\n self\n end",
"def clear\n if block_given?\n return @j_del.java_method(:clear, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |ar| yield(ar.failed ? ar.cause : nil) }))\n end\n raise ArgumentError, \"Invalid arguments when calling clear()\"\n end",
"def clear\n return\n end",
"def clear() \n @obj.clear() \n end",
"def eigen\n class << self; self; end\n end",
"def clear\n reset_defaults\n self\n end",
"def clear\n @a.clear\n end",
"def initialize\n clear\n end",
"def initialize()\n clear()\n end",
"def initialize\n clear\n end",
"def initialize\n clear\n end",
"def initialize\n clear\n end",
"def clear(options = nil)\n raise NotImplementedError.new(\"#{self.class.name} does not support clear\")\n end",
"def clear\n @val = 0\n self\n end",
"def clear!\n @adapters = []\n end",
"def eigenclass\n class << self\n return self\n end\n end",
"def clear!\n @columns.clear\n @columns_hash.clear\n @primary_keys.clear\n @tables.clear\n @version = nil\n end",
"def clear\n do_clear\n end",
"def clear!\n @key_registry = {}\n self\n end",
"def clear\n @adapter.clear(collection)\n end",
"def clear\n\t\tend",
"def clear\n @hash.clear\n self\n end",
"def clear\n @components.clear\n end",
"def clear\n\n end",
"def clear\n Vedeu::Direct.write(value: clear_output, x: bx, y: by)\n end",
"def clear\n @mutex.synchronize do\n @tuples.clear\n @objects.clear\n @catdata.clear\n end\n self\n end",
"def eigenclass\n class << self\n self\n end\n end",
"def clear(options = T.unsafe(nil)); end",
"def eigenclass\n class << self; self; end\n end",
"def output\n Vedeu.timer(\"Clearing interface: '#{name}'\") do\n @_clear ||= Vedeu::Buffers::Clear.new(height: height,\n name: name,\n width: width).buffer\n end\n end",
"def clear\n @registry = {}\n end",
"def clear\n @store.fill(nil,0...@size)\n end",
"def clear\n raise ArgumentError.new(\"There is no image\") if self.data == []\n @data = Matrix.build(self.data.row_count, self.data.column_count) {\"O\"}\n end",
"def clear\n self.rows = nil\n end",
"def clear ; @data.clear ; end",
"def clear_changes\n not_implemented(__method__)\n end",
"def clear_version_instance\n @record.send(\"#{@record.class.version_association_name}=\", nil)\n end",
"def clear_version_instance\n @record.send(\"#{@record.class.version_association_name}=\", nil)\n end",
"def desist\n self.class.delete self\n end",
"def reset!\n registered_keys.each { |key| ClassConstants.new(key).deconstantize }\n @registered_keys = []\n container._container.clear\n end",
"def clear!\n @types.clear\n end",
"def clear\n # Remove all of the shortcut methods\n cell_names.each {|name| builder.undef_cell(name)}\n cells.clear\n end",
"def clear(id); end",
"def clear!(name)\n ivar_remove(name)\n end",
"def clear\n keys.each do |k|\n Jeapie.instance_variable_set(\"@#{k}\", nil)\n end\n end",
"def clear\n @genePool.clear\n @size = 0\n end",
"def clear\n @types = nil\n end",
"def clear\n @data = nil\n end",
"def clear\n @atlas.clear\n end",
"def clear\n @hash.del\n @index.del\n end",
"def clear_state\n @state.clear\n self\n end",
"def clear\n store.clear\n end",
"def clear!(klass)\n @cache.delete(klass)\n end",
"def clear!\n @active = false\n end",
"def clear\n eval \"def clear; print #{`clear`.inspect} end\"\n clear\nend",
"def clear_adapter!\n @_adapter = nil\n end",
"def clear(row, col)\n\n end",
"def clear_without_hooks\n\n @without_hooks = true\n\n clear\n \n @without_hooks = false\n \n return self\n \n end",
"def clear_all\n data.delete_all\n self\n end",
"def clear\n @values.clear\n end",
"def initialize\n clear\n end",
"def unquiesce \n raise NotImplementedError.new\n end",
"def clear\n with(keys: EMPTY_ARRAY)\n end",
"def clear\n @driver.clear\n end",
"def clear\n raise TypeError.new(\"#{self} is immutable\") if immutable?\n\n if respond_to?(:clear_statements)\n clear_statements\n else\n each_statement do |statement|\n delete_statement(statement)\n end\n end\n self\n end"
] |
[
"0.67737883",
"0.67737883",
"0.659532",
"0.654139",
"0.6377399",
"0.6377399",
"0.6368172",
"0.61095244",
"0.6105818",
"0.6105818",
"0.6105818",
"0.61013424",
"0.59717953",
"0.5964348",
"0.5950841",
"0.594352",
"0.59091365",
"0.59091365",
"0.59091365",
"0.59091365",
"0.59091365",
"0.59091365",
"0.59091365",
"0.59053105",
"0.5894169",
"0.5894169",
"0.589004",
"0.589004",
"0.5855338",
"0.585016",
"0.58496314",
"0.5846551",
"0.5808135",
"0.5808135",
"0.5808135",
"0.579945",
"0.5798536",
"0.5792402",
"0.5775516",
"0.57352823",
"0.57148665",
"0.56905746",
"0.56895214",
"0.5676377",
"0.56696403",
"0.5660168",
"0.5660168",
"0.5660168",
"0.56540805",
"0.565049",
"0.5643349",
"0.56370443",
"0.56261724",
"0.5625265",
"0.5616491",
"0.56087035",
"0.55930156",
"0.5580045",
"0.5569322",
"0.5568736",
"0.5566645",
"0.5559429",
"0.55561864",
"0.55543244",
"0.5517932",
"0.55159134",
"0.54972064",
"0.54894435",
"0.5478735",
"0.546229",
"0.54517865",
"0.54294086",
"0.54075897",
"0.54075897",
"0.5398505",
"0.5395507",
"0.53853726",
"0.5385189",
"0.5375352",
"0.53707767",
"0.5368582",
"0.5357412",
"0.53436655",
"0.5342992",
"0.53383106",
"0.53326255",
"0.5326705",
"0.5326042",
"0.5310389",
"0.53076255",
"0.52950114",
"0.52934986",
"0.52789277",
"0.5265811",
"0.5254388",
"0.525272",
"0.52505827",
"0.5238274",
"0.5237443",
"0.52367187",
"0.5235512"
] |
0.0
|
-1
|
For each visible line of the interface, set the foreground and background colours to those specified when the interface was defined, then starting write space characters over the area which the interface occupies.
|
def output
Vedeu.timer("Clearing interface: '#{name}'") do
@_clear ||= Vedeu::Buffers::Clear.new(height: height,
name: name,
width: width).buffer
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def draw_internal(text,align=0,replace=false,raw=false)\n if raw\n print_lines = [text]\n else\n text.gsub!('\\t',' ')\n print_lines = text.split('\\n',-1)\n # Check for highlights in the first line\n if print_lines[0].include?('\\\\h')\n print_lines[0].gsub!('\\\\h','')\n @lines.last.enable_highlight(align)\n end\n end\n # Write the first line\n if replace\n @lines.last.replace(print_lines[0],align)\n else\n @lines.last.write(print_lines[0],align)\n end\n return if print_lines.length < 2\n for i in 1...print_lines.length\n # Check for highlights for all other lines\n if !raw && print_lines[i].include?('\\\\h')\n print_lines[i].gsub!('\\\\h','')\n highlight = true\n else\n highlight = false\n end\n # Create new line sprites for all new lines\n @lines << ConsoleLineSprite.new(self,print_lines[i],align,highlight)\n end\n end",
"def draw\n calculateStartrow\n calculateStartcol\n\n theme_ui = Rim::Paint.theme[:ui]\n plain = Rim::Paint.theme[:plain]\n str = ''\n\n row = @row\n # lines array index in buffer\n line = @start_row\n buffer_size = @buffer.lines.size\n until row > endRow do\n str << T.default << theme_ui[:pane]\n # set the curser with the row\n str << T::cursor(row, @col)\n # fill gaps and reset for other\n # str << (@width < 5 ? '@' : ' ') * width\n str << ' ' * @width\n str << T::cursor(row, @col)\n # pane separator if\n str << theme_ui[:pane_sep] << theme_ui[:pane_sep_char]\\\n << T.default if @separator\n\n # paint the content only if there's room\n if @width >= 5\n # if more line in buffer and\n # save space for the bottom status line\n if line < buffer_size && row < endRow\n # if line numbers enabled\n if $numbers\n display_line = (line + 1).to_s\n str << T.default << theme_ui[:pane_numbers]\n\n str << ' ' * ($numbers_min_space +\n (buffer_size.to_s.length - display_line.length)) \\\n << display_line << ' ' # number and end space\n\n str << T.default\n end\n # == paint lines ==\n # calculate space left for content\n max_line_length = 0\n max_line_length += $numbers_min_space + 1 if $numbers # spaces\n max_line_length += buffer_size.to_s.length if $numbers# numbers\n max_line_length = @width - max_line_length + sep_width\n\n # we need :to_do syntax highlighting next\n # like add attributes at row:col in Buffer\n # process by colums\n str << plain[:line]\n str << plain[:current_line] if @buffer.row == line + 1\n # replace tabs with spaces virtually\n buffer_line = @buffer.lines[line][@start_col..10**10]\n if buffer_line == nil\n buffer_line = ''\n end\n buffer_line = buffer_line\n buffer_line[0..max_line_length].chars.each_with_index do |char, col|\n # insert syntax attributes here for a todo\n str << char\n end\n str << ' ' * (max_line_length - buffer_line.length) if buffer_line.size < max_line_length\n elsif row < endRow\n str << T.default << theme_ui[:pane]\n str << '~'\n elsif row == endRow\n str << Rim::Paint.theme[:status_line].call(self)\n end # line < buffer_size && row < endRow\n end # @width >= 5\n\n # next row\n row += 1\n line += 1\n end # until\n str << T.default\n if @focused && width >= 5\n # cursor row\n crow = @row + (@buffer.cursor_row - 1 - @start_row)\n ccol = @col - 1 + sep_width\n ccol += $numbers_min_space + buffer_size.to_s.length + 1 if $numbers\n ccol += @buffer.col + 1 - @start_col\n str << T.cursor(crow, ccol)\n elsif @focused && width < 5\n str << T.cursor(@row, @col)\n end\n return str\n end",
"def on_paint(dc)\n return unless @started\n dc.set_font(@font)\n first_row = row = get_first_visible_line\n last_row = get_last_visible_line+1\n y = 0\n hX = @hex0\n aX = @asc0\n idx = (row.zero?)? 0 : @columns * row\n\n hex_w = @hex_width + @asc_width\n h_off = @hex_width / 2\n\n # draw blank background\n dc.set_pen(Wx::TRANSPARENT_PEN)\n dc.set_brush(Wx::Brush.new(@bg_color))\n dc.draw_rectangle(0, 0, client_size.width, client_size.height)\n\n paint_row(dc, y, idx, row)\n\n while(c=@data[idx]) and row <= last_row\n if(hX >= @hexN)\n hX = @hex0\n aX = @asc0\n y += @txt_height\n row +=1\n paint_row(dc, y, idx, row)\n end\n\n # call byte colorization block if we have one\n text_color =\n if( @post_paint_proc and\n bret=@post_paint_proc.call(self,dc,idx,c,hX+h_off,aX,y) )\n bret\n else\n @dump_color\n end\n\n # selection stuff goes here\n if @selection and @selection.include?(idx)\n sbrushes = [\n @select_bgs[ @cursor.area ],\n @select_bgs[ (@cursor.area+1) % AREAS.size ]\n ]\n colorize_byte_bg(sbrushes, dc, hX+h_off, aX, y)\n end\n\n dc.set_text_foreground(text_color)\n dc.draw_text(\"#{disp_hex_byte(c)}\", hX+h_off, y)\n dc.draw_text(\"#{disp_ascii_byte(c)}\", aX, y)\n\n hX += hex_w\n aX += @asc_width\n idx += 1\n end\n\n paint_boundaries(dc)\n paint_cursor(dc)\n end",
"def prv_print_border_only row, col, height, width, color, att=Ncurses::A_NORMAL\n att ||= Ncurses::A_NORMAL\n case att.to_s.downcase\n when 'normal'\n att = Ncurses::A_NORMAL\n when 'underline'\n att = Ncurses::A_UNDERLINE\n when 'bold'\n att = Ncurses::A_BOLD\n when 'blink'\n att = Ncurses::A_BLINK # unlikely to work\n when 'reverse'\n att = Ncurses::A_REVERSE \n end\n attron(Ncurses.COLOR_PAIR(color) | att)\n mvwaddch row, col, ACS_ULCORNER\n mvwhline( row, col+1, ACS_HLINE, width-2)\n mvwaddch row, col+width-1, Ncurses::ACS_URCORNER\n mvwvline( row+1, col, ACS_VLINE, height-1)\n\n mvwaddch row+height-0, col, Ncurses::ACS_LLCORNER\n mvwhline(row+height-0, col+1, ACS_HLINE, width-2)\n mvwaddch row+height-0, col+width-1, Ncurses::ACS_LRCORNER\n mvwvline( row+1, col+width-1, ACS_VLINE, height-1)\n attroff(Ncurses.COLOR_PAIR(color) | att)\n end",
"def _write(text, fg = nil, bg = nil)\n if @status_displayed && self.width && self.width > 0\n _clear_line((@status.length / self.width) + 1)\n @status_displayed = false\n end\n if fg || bg\n reset = true\n if fg\n fg_code = FOREGROUND_COLORS[fg] || fg\n STDOUT.write \"\\e[#{fg_code}m\"\n end\n\n if bg\n bg_code = BACKGROUND_COLORS[bg] || bg\n STDOUT.write \"\\e[#{bg_code}m\"\n end\n end\n\n STDOUT.write text\n\n if reset\n STDOUT.write \"\\e[0m\"\n end\n end",
"def add_rest_interface(interface)\n @lines ||= []\n @lines.push \"! colspan='5' style='background:#ABE' | #{interface}\"\n @lines.push \"|-\"\n end",
"def color_table\n [0, 1, 4, 5, 7].each do |attr|\n puts '----------------------------------------------------------------'\n puts \"ESC[#{attr};Foreground;Background\"\n 30.upto(37) do |fg|\n 40.upto(47) do |bg|\n print \"\\033[#{attr};#{fg};#{bg}m #{fg};#{bg} \"\n end\n puts \"\\033[0m\"\n end\n end\n end",
"def draw(interface)\n output \" | | \"\n output \" #{@squares[interface[:top_left]]} | #{@squares[interface[:top]]} | #{@squares[interface[:top_right]]} \"\n output \" | | \"\n output \"-----+-----+-----\"\n output \" | | \"\n output \" #{@squares[interface[:left]]} | #{@squares[interface[:middle]]} | #{@squares[interface[:right]]} \"\n output \" | | \"\n output \"-----+-----+-----\"\n output \" | | \"\n output \" #{@squares[interface[:bottom_left]]} | #{@squares[interface[:bottom]]} | #{@squares[interface[:bottom_right]]} \"\n output \" | | \"\n end",
"def display(move = [])\n cls\n\n bg1 = COLORS[:light]\n bg2 = COLORS[:dark]\n border = COLORS[:border]\n\n top_bot_border = \" #{('A'..'Z').to_a.take(WIDTH).join(' ')} \"\n .colorize(:background => border)\n puts top_bot_border\n\n color = bg1\n\n @grid.each_with_index do |row, idx|\n print \"#{' ' if WIDTH - idx < 10}#{WIDTH - idx} \".\n colorize(:background => border)\n\n row.each_with_index do |space, space_idx|\n back = move.include?([idx, space_idx]) ? COLORS[:highlight] : color\n\n if space.nil?\n print \" \".colorize(:background => back)\n else\n print \" #{space.render} \".colorize(:background => back)\n end\n color = color == bg1 ? bg2 : bg1\n end\n color = color == bg1 ? bg2 : bg1 unless WIDTH.odd?\n print \" #{WIDTH - idx}#{' ' if WIDTH - idx < 10}\\n\".\n colorize(:background => border)\n end\n puts top_bot_border\n nil\n end",
"def draw\n return if @hidden\n cur_y = @cur_start_y\n @lines.each do |line|\n if cur_y >= (600 - START_Y - FONT_HEIGHT) then\n newline = find_line_length(@lines.shift)\n if newline.length > 1 then\n @lines.unshift(newline[1..-1].join(\" \"))\n else\n if @cur_start_y != START_Y then\n @cur_start_y = START_Y\n else\n @cur_start_y = START_Y + FONT_HEIGHT\n end\n end\n end\n \n line = line[0, @current_pos] if line == @lines.last and !@current\n width = @font.text_width(line)\n if width.to_i >= TEXT_WIDTH then\n # now break down each segment~\n # try to find a word break if possible\n new_lines = find_line_length(line)\n new_lines.each do |l|\n if cur_y >= (600 - START_Y - FONT_HEIGHT) then\n newline = find_line_length(@lines.shift)\n if newline.length > 1 then\n @lines.unshift(newline[1..-1].join(\" \"))\n else\n if @cur_start_y != START_Y then\n @cur_start_y = START_Y\n else\n @cur_start_y = START_Y + FONT_HEIGHT\n end\n end\n end\n \n @font.draw(l, START_X, cur_y, 9)\n cur_y += FONT_HEIGHT\n cur_y += FONT_HEIGHT if l == new_lines.last\n end\n else \n @font.draw(line, START_X, cur_y, 9)\n cur_y += FONT_HEIGHT * 2\n end\n end\n if @current then\n # draw CTC indicator\n img = @ctc[Gosu::milliseconds / 150 % @ctc.size];\n img.draw(720, 520, 10)\n end\n end",
"def print_border_mb row, col, height, width, color, attr\n # the next is for xterm-256 \n att = get_attrib attr\n len = width\n len = Ncurses.COLS-0 if len == 0\n # print a bar across the screen \n #attron(Ncurses.COLOR_PAIR(color) | att)\n # this works for newmessagebox but not for old one.\n # Even now in some cases some black shows through, if the widget is printing spaces\n # such as field or textview on a messagebox.\n # 2016-01-14 - replacing 1 with space since junk is showing up in some cases.\n space_char = \" \".codepoints.first\n (row-1).upto(row+height-1) do |r|\n # this loop clears the screen, printing spaces does not work since ncurses does not do anything\n mvwhline(r, col, space_char, len)\n end\n #attroff(Ncurses.COLOR_PAIR(color) | att)\n\n mvwaddch row, col, Ncurses::ACS_ULCORNER\n mvwhline( row, col+1, Ncurses::ACS_HLINE, width-6)\n mvwaddch row, col+width-5, Ncurses::ACS_URCORNER\n mvwvline( row+1, col, Ncurses::ACS_VLINE, height-4)\n\n mvwaddch row+height-3, col, Ncurses::ACS_LLCORNER\n mvwhline(row+height-3, col+1, Ncurses::ACS_HLINE, width-6)\n mvwaddch row+height-3, col+width-5, Ncurses::ACS_LRCORNER\n mvwvline( row+1, col+width-5, Ncurses::ACS_VLINE, height-4)\n end",
"def render pad, lineno, text\n if @hash\n dim = match_line text\n fg = dim.first\n bg = dim[1] || @default_colors[1]\n if dim.size == 3\n att = dim.last\n else\n att = @default_colors.last\n end\n cp = get_color($datacolor, fg, bg)\n else\n cp = @pair\n att = @default_colors[2]\n end\n\n FFI::NCurses.wattron(pad,FFI::NCurses.COLOR_PAIR(cp) | att)\n FFI::NCurses.mvwaddstr(pad, lineno, 0, text)\n FFI::NCurses.wattroff(pad,FFI::NCurses.COLOR_PAIR(cp) | att)\n end",
"def disp(text)\n FXDCWindow.new(@image) do |dc|\n text.split(' ').each do |cmd|\n cmd = cmd.split(',')\n if cmd.first == 'L'\n dc.foreground = @colors[cmd[1]].to_i\n dc.drawLine(cmd[2].to_i, cmd[3].to_i + 1, cmd[4].to_i, cmd[5].to_i + 1)\n end\n end\n end\n board_draw\n end",
"def draw_endpoints_with_hash positions\n positions.each { |line_idx, char_idx| @lines[line_idx][char_idx] = '#' }\n end",
"def draw\n\t\tputs \"\\n\"\n\t\tmid = (@height/2.0).ceil\n\t\tfor line in 1..@height\n\t\t\tspace0 = (mid - (mid-line).abs).abs\n\t\t\tspace1 = (mid - line).abs * 2 - 1\n\t\t\tputs space1 > 0 ?\n\t\t\t\t \" \" * space0 + \"X \" + \" \" * space1 + \"X\" :\n\t\t\t\t \" \" * space0 + \"X\"\n\t\tend\n\tend",
"def print_border_only row, col, height, width, color, att=Ncurses::A_NORMAL\n if att.nil? \n att = Ncurses::A_NORMAL\n else\n att = get_attrib att\n end\n wattron(Ncurses.COLOR_PAIR(color) | att)\n mvwaddch row, col, Ncurses::ACS_ULCORNER\n mvwhline( row, col+1, Ncurses::ACS_HLINE, width-2)\n mvwaddch row, col+width-1, Ncurses::ACS_URCORNER\n mvwvline( row+1, col, Ncurses::ACS_VLINE, height-1)\n\n mvwaddch row+height-0, col, Ncurses::ACS_LLCORNER\n mvwhline(row+height-0, col+1, Ncurses::ACS_HLINE, width-2)\n mvwaddch row+height-0, col+width-1, Ncurses::ACS_LRCORNER\n mvwvline( row+1, col+width-1, Ncurses::ACS_VLINE, height-1)\n wattroff(Ncurses.COLOR_PAIR(color) | att)\n end",
"def colorize!(fg, bg)\n set_colors(fg, bg)\n num = @cwin.maxx * @cwin.maxy\n self.home\n self.go(0, 0) { @cwin.addstr(' '*num) }\n @cwin.refresh\n end",
"def draw\n\t\tfield.each do |arr|\n\t\t\tarr.each { |i| print \" #{i} \".black.bg_cyan }\n\t\t\tputs\n\t\tend\n\tend",
"def draw\n puts \"*\" * (@cells.first.size + 2)\n @cells.each do |row|\n puts \"|\" + row.map { |column_value| column_value == 0 ? \" \" : \"#\" }.join + \"|\"\n end\n puts \"*\" * (@cells.first.size + 2)\n end",
"def print_border_mb row, col, height, width, color, attr\n mvwaddch row, col, ACS_ULCORNER\n mvwhline( row, col+1, ACS_HLINE, width-6)\n mvwaddch row, col+width-5, Ncurses::ACS_URCORNER\n mvwvline( row+1, col, ACS_VLINE, height-4)\n\n mvwaddch row+height-3, col, Ncurses::ACS_LLCORNER\n mvwhline(row+height-3, col+1, ACS_HLINE, width-6)\n mvwaddch row+height-3, col+width-5, Ncurses::ACS_LRCORNER\n mvwvline( row+1, col+width-5, ACS_VLINE, height-4)\n end",
"def drawBoard\n\t$firstRow.each do |i|\n\t\ti.printState\n\tend\n\tnewLine\n\t$secondRow.each do |i|\n\t\ti.printState\n\tend\n\tnewLine\n\t$thirdRow.each do |i|\n\t\ti.printState\n\tend\n\tnewLine\nend",
"def display\n system 'clear'\n @line_width = 60\n display_header\n display_board\n display_shield_row\n display_legend\n end",
"def draw\n lines = []\n\n indent = @height - 1\n draw_braches(lines, indent)\n\n lines\n end",
"def draw_multi(text, x, y, width, lines = -1, base_color = Color.new(255,255,255), shadow_color = nil,\n outline = false, y_line_diff = 24, allow_split_in_words = false)\n self.bmp.draw_multi(text, x, y, width, lines, base_color, shadow_color,\n outline, y_line_diff, allow_split_in_words)\n end",
"def format(win)\n win.win.attron(nc)\n yield\n win.win.attroff(nc)\n end",
"def window_update(oline)\n if oline != nil\n #text = \"\"\n @last_color = 0\n @contents_x = 0\n @contents_y = 0\n @biggest_text_height = 0\n @cControlsList.clear()\n for l in oline\n next if l == nil\n converted_line = convert_special_characters(l)\n generate_controls(converted_line)\n new_line\n end\n\n # Changes contents size for scrolling\n self.contents.dispose\n self.contents = Bitmap.new(self.width - 32, [self.height - 32, @contents_y].max)\n self.oy = 0\n end\n \n refresh()\n end",
"def draw\n $code.each { |color| print \"[ #{Rainbow(\"o\").background(color)} ] \" }\n puts \"\\n\\n\"\n end",
"def update_dimensions\n spacer=@hex_width # 3-char space between areas\n ui_width = @addr_width + (spacer*4) # addr sp sp hex sp ascii sp\n\n @columns = (client_size.width - ui_width) / (@hex_width + @asc_width*2)\n @columns = 1 if @columns < 1\n @rows = (@data.size / @columns)+1\n\n # calculate hex/ascii area boundaries\n @hex0 = @addr_width + spacer*2\n @hexN = @hex0 + (@columns * (@hex_width+@asc_width))\n @asc0 = @hexN + spacer\n @ascN = @asc0 + (@columns * @asc_width)\n @row_width = @ascN - @addr_width - @hex_width\n\n # update scroll-bar info\n old_pos=first_visible_line\n set_line_count(@rows)\n scroll_to_line(old_pos)\n end",
"def draw_text_field\n setpos(divider_line, 0)\n attron(color_pair(COLOR_WHITE) | A_NORMAL) {\n addstr(\"Current Room:#{@currentRoom} #{(@joinedRooms.delete(@currentRoom)).to_a}\" + \" \" * cols)\n }\n cursor_to_input_line\n clrtoeol\n end",
"def draw_lines\n @dim.times do |i|\n if @type.nil?\n draw_line(i+1)\n draw_edge\n puts\n elsif @type == \"allx\" || @type == \"alt\"\n draw_alt_line\n draw_edge\n puts\n end\n end\n end",
"def print_borders #:nodoc:\n width = @width\n height = @height-1 # 2010-01-04 15:30 BUFFERED HEIGHT\n window = @graphic # 2010-01-04 12:37 BUFFERED\n startcol = @col \n startrow = @row \n #@color_pair = get_color($datacolor)\n bordercolor = @border_color || $datacolor\n borderatt = @border_attrib || Ncurses::A_NORMAL\n\n window.print_border startrow, startcol, height, width, bordercolor, borderatt\n print_title\n end",
"def setlinecolorind(*)\n super\n end",
"def draw_internal(align)\n return if @text[align].empty?\n self.bitmap.font.color = @window.textColor\n if @highlight[align]\n text_rect = Rect.new(0,0,self.bitmap.text_size(@text[align]).width+2,\n self.bitmap.height)\n text_rect.x = self.viewport.rect.width/2-text_rect.width/2-2 if align == 1\n text_rect.x = self.viewport.rect.width-text_rect.width-2 if align == 2\n self.bitmap.fill_rect(text_rect,@window.textColor)\n self.bitmap.font.color = @window.bgColor\n end\n self.bitmap.draw_text(self.bitmap.rect,@text[align],align)\n end",
"def paint\n #$log.debug \"called paint t:#{@toprow} p:#{@prow} w:#{@winrow}\"\n list = get_content\n @content_rows = list.length # rows can be added at any time\n win = get_window\n maxlen = @maxlen ||= @width-2\n if @bgcolor.is_a? String and @color.is_a? String\n acolor = ColorMap.get_color(@color, @bgcolor)\n else\n acolor = $datacolor\n end\n @color_pair = acolor\n 0.upto(@height-2) {|r|\n if @toprow + r < @content_rows\n # this relates to selection of a row, as yet\n # check if any status of attribs for this row\n row_att = @list_attribs[@toprow+r] unless @list_attribs.nil?\n status = \" \"\n #bgcolor = $datacolor\n bgcolor = nil\n if !row_att.nil?\n status = row_att.fetch(:status, \" \")\n bgcolor = row_att[:bgcolor]\n end\n # sanitize\n content = list[@toprow+r].chomp # don't display newline\n content.gsub!(/\\t/, ' ') # don't display tab\n content.gsub!(/[^[:print:]]/, '') # don't display non print characters\n\n #content = content[0..maxlen-1] if !content.nil? && content.length > maxlen # only show maxlen\n if !content.nil? \n if content.length > maxlen # only show maxlen\n content = content[@pcol..@pcol+maxlen-1] \n else\n content = content[@pcol..-1]\n end\n end\n\n width = @width-(@left_margin+1)\n @form.window.printstring @row+r+1, @col+@left_margin-1, \"%s\" % status, acolor, @attr if @implements_selectable\n @form.window.printstring @row+r+1, @col+@left_margin, \"%-*s\" % [width,content], acolor, @attr\n win.mvchgat(y=r+@row+1, x=@col+@left_margin, max=width, Ncurses::A_NORMAL, bgcolor, nil) unless bgcolor.nil?\n dollar = \"|\"\n dollar = \"$\" if list[@toprow+r][-1,1]==\"\\r\"\n @form.window.printstring @row+r+1, @col+@width-1, dollar, acolor, @attr\n\n else\n # clear the displayed area\n @form.window.printstring @row+r+1, @col+@left_margin, \" \"*(@width-(@left_margin+1)), acolor\n dollar = \"|\"\n @form.window.printstring @row+r+1, @col+@width-1, dollar, acolor, @attr\n end\n }\n show_focus if @show_focus\n end",
"def visible\n lines.map { |line| line[ox...(ox + bordered_width)] || '' }\n end",
"def draw\n\t\t#\n\t\t# Draw the \"top\" line.\n\t\t#\n\t\tputs \" \" + \"_\" * (@width * 2 - 1)\n\t\n\t\t#\t\n\t\t# Draw each of the rows.\n\t\t#\n\t\t@height.times do |y|\n\t\t\tprint \"|\"\n\t\t\t@width.times do |x|\n\t\t\t\t# render \"bottom\" using \"S\" switch\n\t\t\t\tprint( (@grid[y][x] & @@S != 0) ? \" \" : \"_\" )\n\t\t\t\n\t\t\t\t# render \"side\" using \"E\" switch\t\n\t\t\t\tif @grid[y][x] & @@E != 0\n\t\t\t\t\tprint( ( ( @grid[y][x] | @grid[y][x+1] ) & @@S != 0 ) ? \" \" : \"_\" )\n\t\t\t\telse\n\t\t\t\t\tprint \"|\"\n\t\t\t\tend\n\t\t\tend\n\t\t\tputs\n\t\tend\n\n\t\t# \n\t\t# Output metadata\n\t\t#\n\t\tputs metadata\n\tend",
"def set_bg\n STDOUT.write \"\\033[48;5;#{to_xterm}m\"\n end",
"def highlight_lines(output, options)\n highlighted_lines(options).each do |i|\n if i > output.length - 1\n $stderr.puts \"Warning: Highlighted line #{i} out of range\" unless test?\n $stderr.puts output.inspect unless test?\n else\n output[i] = '\\setlength{\\fboxsep}{0pt}\\colorbox{hilightyellow}{' +\n output[i] + '}'\n end\n end\n end",
"def draw_line\n print H_SEP * columns\n end",
"def draw_item(index, color)\n self.contents.font.color = color\n rect = Rect.new(4, 32 * index, self.contents.width - 8, 32)\n self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))\n self.contents.draw_text(rect, @commands[index].name)\n end",
"def drawTop\n attron(color_pair(1))\n addstr(\"< \")\n attroff(color_pair(1))\n attron(color_pair(2))\n addstr(\"^ \")\n attroff(color_pair(2))\n attron(color_pair(3))\n addstr(\"> \")\n attroff(color_pair(3))\n attron(color_pair(4))\n addstr(\"v \")\n attroff(color_pair(4))\nend",
"def screen(header_inputs, background_inputs, footer_inputs)\r\n\t\t#24 lines\r\n\t\r\n \t\theader(header_inputs)\r\n \t\tbackground(background_inputs)\r\n \t\tfooter(footer_inputs)\r\n\tend",
"def paint_boundaries(dc)\n height = @rows * @txt_height\n\n # draw area boundaries\n dc.set_pen(@area_bounds_pen)\n dc.draw_line(x2=(@hex0)-2, 0, x2, height)\n dc.draw_line(x2=(@asc0-@asc_width), 0, x2, height)\n dc.draw_line(x2=(@hex0+@row_width), 0, x2, height)\n\n hex_w = @hex_width + @asc_width\n h_off = @hex_width /2\n l_off = @asc_width /2\n\n # draw WORD boundary indicator lines in the hex area\n divW = (hex_w << 2)\n divX = @hex0 + divW - 1\n dc.set_pen( @word_bounds_pen )\n while divX < @hexN-h_off\n dc.draw_line(x2=(divX+l_off), 0, x2, height)\n divX += divW\n end\n end",
"def write_line(row,colfeed,line)\n\n\t\tif line == nil || line == \"\"\n\t\t\treturn\n\t\tend\n\n\t\twrite_str(row,0,\" \"*@cols) # clear row\n\n\t\tsubstrings = line.split($color) # split at color escape\n\n\t\t# Write from colfeed to first color escape.\n\t\t# If colfeed is larger than the first substring,\n\t\t# this will naturally write nothing.\n\t\twrite_str(row,0,substrings[0][colfeed,@cols])\n\t\tpos = substrings[0].length\n\t\tsubstrings = substrings[1..-1]\n\t\treturn if substrings == nil\n\n\t\t# loop over remaining parts of the line\n\t\tsubstrings.each{|substring|\n\t\t\tcolorcode = substring[0].chr\n\t\t\tsubstring = substring[1..-1]\n\t\t\tnext if substring == nil\n\t\t\tcase colorcode\n\t\t\t\twhen $color_white then set_color(Curses::COLOR_WHITE)\n\t\t\t\twhen $color_red then set_color(Curses::COLOR_RED)\n\t\t\t\twhen $color_green then set_color(Curses::COLOR_GREEN)\n\t\t\t\twhen $color_yellow then set_color(Curses::COLOR_YELLOW)\n\t\t\t\twhen $color_blue then set_color(Curses::COLOR_BLUE)\n\t\t\t\twhen $color_magenta then set_color(Curses::COLOR_MAGENTA)\n\t\t\t\twhen $color_cyan then set_color(Curses::COLOR_CYAN)\n\t\t\t\twhen $color_reverse then @screen.attron(Curses::A_REVERSE)\n\t\t\t\twhen $color_normal then @screen.attroff(Curses::A_REVERSE)\n\t\t\tend\n\t\t\t# pos is position in the line.\n\t\t\tif pos < colfeed\n\t\t\t\t# We must chop off first part of the substring,\n\t\t\t\t# because we are writing off the left edge of the screen.\n\t\t\t\tstr_start = colfeed - pos\n\t\t\t\tcol = 0\n\t\t\telse\n\t\t\t\t# We write the entire string, but starting some number of\n\t\t\t\t# spaces in from the edge.\n\t\t\t\tcol = pos - colfeed\n\t\t\t\tstr_start = 0\n\t\t\tend\n\t\t\twrite_str(row,col,substring[str_start,(@cols-col)])\n\t\t\tpos += substring.length\n\t\t}\n\tend",
"def drawToSTDOUT\n for r in (0..6).step(3) do\n print \"+-----++-----++-----+\\n\"\n print \"| \\\\\"+@table[r].getTop.to_s+\"/ || \\\\\"+@table[r+1].getTop.to_s+\"/ || \\\\\"+@table[r+2].getTop.to_s+\"/ |\\n\"\n print \"|\"+@table[r].getLeft.to_s+\" × \"+@table[r+1].getRight.to_s+\"||\"+@table[r+2].getLeft.to_s+\" × \"+@table[r].getRight.to_s+\"||\"+@table[r+1].getLeft.to_s+\" × \"+@table[r+2].getRight.to_s+\"|\\n\"\n print \"| /\"+@table[r].getBottom.to_s+\"\\\\ || /\"+@table[r+1].getBottom.to_s+\"\\\\ || /\"+@table[r+2].getBottom.to_s+\"\\\\ |\\n\"\n print \"+-----++-----++-----+\\n\"\n end\n end",
"def refresh\n contents.clear\n for i in 0...(@cw_data.size / 2)\n draw_text_ex(0, line_height*i, \"\\\\c[16]\" + @cw_data[i*2])\n reset_font_settings\n draw_text(0, line_height*i, contents_width, line_height, value(@cw_data[i*2 + 1]), 2)\n end\n end",
"def _puts(text = nil, fg = nil, bg = nil)\n if @status_displayed && self.width && self.width > 0\n _clear_line((@status.length / self.width) + 1)\n @status_displayed = false\n end\n _write(\"#{text}\", fg, bg)\n STDOUT.write \"\\n\"\n if @status\n _write @status, @status_fg, @status_bg\n @status_displayed = true\n end\n end",
"def refresh\n contents.clear\n draw_header\n draw_face_area(line_height * 1.5)\n draw_attr_area(0, line_height * 2 + 104)\n draw_skill_area(240, line_height * 2 + 104)\n end",
"def draw\n print \" | |\\n\" \\\n \"#{board_line(0)}\\n\" \\\n \" | |\\n\" \\\n \"-----+-----+-----\\n\" \\\n \" | |\\n\" \\\n \"#{board_line(1)}\\n\" \\\n \" | |\\n\" \\\n \"-----+-----+-----\\n\" \\\n \" | |\\n\" \\\n \"#{board_line(2)}\\n\" \\\n \" | |\\n\"\n end",
"def repaint\n return unless @repaint_required\n \n # 2014-08-10 - 14:53 changing bgcolor or color resets color_pair, so this must be reset if nil\n @color_pair ||= get_color $bottomcolor, @color, @bgcolor\n #print_header(htext, posy = 0, posx = 0)\n att = get_attrib @attr\n len = @window.width\n len = Ncurses.COLS-0 if len == 0\n # print a bar across the screen \n @window.attron(Ncurses.COLOR_PAIR(@color_pair) | att)\n # 2016-01-13 - changed since \"1\" was giving problems in mvhline in some cases\n #@window.mvhline(@row, @col, 1, len)\n @window.mvhline(@row, @col, @space_char, len)\n @window.attroff(Ncurses.COLOR_PAIR(@color_pair) | att)\n #print_header(@text1 + \" %15s \" % @text2 + \" %20s\" % @text_center , posy=0, posx=0)\n\n # Now print the text in the correct positions with no padding, else some terminal\n # will blacken the text out.\n print_header(\"#{@text1} #{@text2}\") # + \" %20s\" % @text_center , posy=0, posx=0)\n print_center(\"#{@text_center}\") # + \" %20s\" % @text_center , posy=0, posx=0)\n print_top_right(@text_right)\n @repaint_required = false\n end",
"def lines(txt, border, filler)\n print border\n (txt.length + 2).times do\n print filler\n end\n print border\n print \"\\n\"\nend",
"def render_extend_interp_spokes(shiftx, shifty, color, ibegin, iend)\n \n\n iend.each_with_index do |p, i|\n#\tif p.size >= 4 and (p[3].is_a? Integer) and p[3] >= 0 and p[3] < 3 \n#\t @app.stroke $sreps[p[3]].color\n\n\tif p.size >=3 and (p[2].is_a? Integer) and p[2] >= 0 and p[2] < 3 \n\t @app.stroke $sreps[p[2]].color\n\telse \n @app.stroke color\n\tend\n @app.line(ibegin[i][0]+shiftx, ibegin[i][1]+shifty, p[0]+shiftx, p[1]+shifty)\n end\n end",
"def printstring r, c, text, color_pair=@color_pair\n create_window unless @win\n show unless @visible\n r = @h-1 if r > @h-1\n #@win.printstring r, c, ' '*@w, @color_pair\n # FIXME this padding overwrites the border and the offset means next line wiped\n # However, now it may now totally clear a long line.\n @win.printstring r+@row_offset, c+@col_offset, \"%-*s\" % [@w-(@col_offset*2)-c, text], color_pair\n @win.wrefresh\n end",
"def draw\n return if @type == Type[:EMPTY]\n\n @window.mvaddstr(@x, @y, @appearance)\n end",
"def draw_line(index)\n rect = Rect.new(0, 0, 0, 0)\n rect.x += 4\n rect.y += index * WLH\n rect.width = contents.width - 8\n rect.height = WLH\n self.contents.clear_rect(rect)\n self.contents.font.color = normal_color\n self.contents.draw_text(rect, @lines[index])\n end",
"def init_line_structures(minsize)\r\n if @invisible_line.nil? # initialize it\r\n if (@line_size < minsize)\r\n @line_size = minsize\r\n end\r\n @visible_line = 0.chr * @line_size\r\n @invisible_line = 0.chr * @line_size # 1.chr\r\n elsif (@line_size < minsize) # ensure it can hold MINSIZE chars\r\n @line_size *= 2\r\n if (@line_size < minsize)\r\n @line_size = minsize\r\n end\r\n @visible_line << 0.chr * (@line_size - @visible_line.length)\r\n @invisible_line << 1.chr * (@line_size - @invisible_line.length)\r\n end\r\n @visible_line[minsize,@line_size-minsize] = 0.chr * (@line_size-minsize)\r\n @invisible_line[minsize,@line_size-minsize] = 1.chr * (@line_size-minsize)\r\n\r\n if @vis_lbreaks.nil?\r\n @inv_lbreaks = []\r\n @vis_lbreaks = []\r\n @_rl_wrapped_line = []\r\n @inv_lbreaks[0] = @vis_lbreaks[0] = 0\r\n end\r\n end",
"def displayRect(length, width)\n #Line\n for i in 0...width\n #Col\n for j in 0...length\n #Draw 0 each coin\n if((i == 0 && j == 0) || (i == width - 1 && j == length - 1) || (i == 0 && j == length - 1) || (i == width - 1 && j == 0))\n print \"O\"\n else\n need_space = true\n #Draw | by see col\n if((j == 0) || (j == length - 1))\n print \"|\"\n need_space = false\n end\n #Draw - by see line\n if((i == 0) || (i == width - 1))\n print \"-\"\n need_space = false\n end\n\n if (need_space)\n print \" \"\n end\n end\n end\n puts \"\\n\"\n end\nend",
"def draw_alt_line\n @dim.times do |i|\n if i.even?\n print draw_x\n else\n if @type == \"allx\"\n print draw_x\n elsif @type == \"alt\"\n print draw_dot\n end\n end\n end\n end",
"def view\n\t\tcount = 0\n\t\tdark = \"\\u2591\"\n\t\tlight = \"\\u2593\"\n\t\tshade_line_2 = \" \" + (dark*6 + light*6)*4\n\t\tshade_line_1 = \" \" + (light*6 + dark*6)*4\n\t\tbase_letters = \" a b c d e f g h\\n\\n\"\n\t\t(0...@spots.length/8).reverse_each do |i|\n\t\t\tputs count % 2 == 0 ? shade_line_1 : shade_line_2\n\t\t\tprint (i+1).to_s + \" \"\n\t\t\tline = @spots[i*8...(i+1)*8]\n\t\t\tline.each do |spot|\n\t\t\t\tprint count % 2 == 0 ? light*2 : dark*2\n\t\t\t\tif spot[1].img == \" \"\n\t\t\t\t\tprint count % 2 == 0 ? light*2 : dark*2\n\t\t\t\telse\n\t\t\t\t\tprint spot[1].img + \" \"\n\t\t\t\tend\n\t\t\t\tprint count % 2 == 0 ? light*2 : dark*2\n\t\t\t\tcount += 1\n\t\t\tend\n\t\t\tputs \"\"\n\t\t\tputs count % 2 == 0 ? shade_line_1 : shade_line_2\n\t\t\tcount += 1\n\t\tend\n\t\tputs \"\\n\" + base_letters\n\tend",
"def render_all pad, arr\n pre_render\n @content_cols = @source.pad_cols\n @clearstring = \" \" * @content_cols\n @list = arr\n\n att = @attr || NORMAL\n FFI::NCurses.wattron(pad, @cp | att)\n\n arr.each_with_index { |line, ix|\n render pad, ix, line\n }\n FFI::NCurses.wattroff(pad, @cp | att)\n end",
"def draw_grid\n print_cap\n (0...@vertical).each do |vert_index|\n (0..@v_size).each do |block_height|\n (0...@horizontal).each do |horizontal_index|\n if block_height == (@v_size/2)\n print \"|\" + \" \"*(@h_size/2)\n \"#{print @contents[horizontal_index][vert_index]}|\"\n print \" \"*(@h_size/2-1)\n else\n print \"|\"; print \" \"*@h_size\n end\n end\n print \"|\\n\" \n \n end\n print_cap\n end\n end",
"def print_border row, col, height, width, color, att=Ncurses::A_NORMAL\n raise \"height needs to be supplied.\" if height.nil?\n raise \"width needs to be supplied.\" if width.nil?\n att ||= Ncurses::A_NORMAL\n\n $log.debug \" inside window print_border r #{row} c #{col} h #{height} w #{width} \"\n\n # 2009-11-02 00:45 made att nil for blanking out\n # FIXME - in tabbedpanes this clears one previous line ??? XXX when using a textarea/view\n # when using a pad this calls pads printstring which again reduces top and left !!! 2010-01-26 23:53 \n (row+1).upto(row+height-1) do |r|\n #printstring( r, col+1,\" \"*(width-2) , $datacolor, nil)\n prv_printstring( r, col+1,\" \"*(width-2) , $datacolor, nil)\n end\n prv_print_border_only row, col, height, width, color, att\n end",
"def draw_attributes\n draw_header\n \n change_color(system_color)\n #draw_text(5, 32, self.width, 24, \"Categoria:\")\n draw_text(5, 32, self.width, 24, \"Atributos:\")\n change_color(normal_color)\n \n 8.times do |i|\n draw_text(5, 56 + i * 24, 131, 24, Vocab.param(i))\n end\n\n 8.times do |i|\n change_color(normal_color)\n draw_text(self.width - 108, 54 + i * 24, 64, 24, \"#{@item.params[i].to_i}\")\n draw_text(self.width - 75, 54 + i * 24, 64, 24, \"→\")\n change_color(@enchant[:effects][i] > 0 ? power_up_color : normal_color)\n draw_text(self.width - 54, 54 + i * 24, 64, 24, \"#{(@item.params[i] + @enchant[:effects][i]).to_i}\")\n end\n end",
"def render_output(should_flood, start_line, text, color=:blue)\n if start_line\n text = Pry::Helpers::Text.with_line_numbers text, start_line, color\n end\n\n if should_flood\n output.puts text\n else\n stagger_output(text)\n end\n end",
"def chco\n (foreground || \"FFFFFF\") + \",\" + super\n end",
"def draw_blank\n puts \"[ o ] [ o ] [ o ] [ o ]\\n\\n\"\n end",
"def print_border row, col, height, width, color, att=Ncurses::A_NORMAL\n raise \"height needs to be supplied.\" if height.nil?\n raise \"width needs to be supplied.\" if width.nil?\n att ||= Ncurses::A_NORMAL\n\n #$log.debug \" inside window print_border r #{row} c #{col} h #{height} w #{width} \"\n\n # 2009-11-02 00:45 made att nil for blanking out\n # FIXME - in tabbedpanes this clears one previous line ??? XXX when using a textarea/view\n # when using a pad this calls pads printstring which again reduces top and left !!! 2010-01-26 23:53 \n ww=width-2\n clr = \" \"*ww\n (row+1).upto(row+height-1) do |r|\n printstring( r, col+1, clr, color, att)\n end\n print_border_only row, col, height, width, color, att\n end",
"def display(i,j)\n \t print \"\\e[H\"\n\t puts \" \" + \"_\" * (@width * 2 - 1)\n\t \n\t @grid.each_with_index do |row,y|\n\t print \"|\"\n\t\t row.each_with_index do |cell,x|\n\t\t # \n\t\t\t # Color gray if empty, red if \"current\" cursor\n\t\t\t #\n\t\t\t if cell == 0\n\t\t\t print \"\\e[47m\" \n\t\t\t elsif x == i and y == j\n \t\t\t print \"\\e[41m\"\n\t\t\t end\n\n\t\t\t # render \"bottom\" using \"S\" switch\n\t\t\t print( (@grid[y][x] & @@S != 0) ? \" \" : \"_\" )\n\t\t\t \n\t\t\t # render \"side\" using \"E\" switch\n\t\t\t if @grid[y][x] & @@E != 0\n\t\t\t print( ( ( @grid[y][x] | @grid[y][x+1] ) & @@S != 0 ) ? \" \" : \"_\" )\n\t\t\t else\n\t\t\t print \"|\"\n\t\t\t end\n\n\t\t\t # \n\t\t\t # Stop coloring\n\t\t\t #\n\t\t\t if cell == 0 or ( x == i and y == j )\n\t\t\t print \"\\e[m\" \n\t\t\t end\n\t\t end\n\t\t puts\n\t end\n\tend",
"def rect(wide, tall)\n tall.times do |row|\n wide.times do |col|\n @display[row][col] = '#'\n end\n end\n self\n end",
"def ctrlSetForegroundColor _obj, _args\n \"_obj ctrlSetForegroundColor _args;\" \n end",
"def draw_vertical(start_line, end_line, start_char)\n start_line.upto(end_line) do |line_idx| \n @lines[line_idx][start_char] = PATH_CHAR \n end\n end",
"def on_49(_) { fg: fg_color(9) } end",
"def print_lines(*lines)\n change_foreground_color nil\n\n lines.flatten.each do |line|\n print_next_line_segment line until line.empty?\n\n @position[0] += 1\n @position[1] = 0\n end\n end",
"def rl_on_new_line()\r\n if (@visible_line)\r\n @visible_line[0,1] = 0.chr\r\n end\r\n @_rl_last_c_pos = @_rl_last_v_pos = 0\r\n @_rl_vis_botlin = @last_lmargin = 0\r\n if (@vis_lbreaks)\r\n @vis_lbreaks[0] = @vis_lbreaks[1] = 0\r\n end\r\n @visible_wrap_offset = 0\r\n 0\r\n end",
"def line_divider \n puts @header.light_blue\n end",
"def draw_checkerboard(png, horizontalColor, verticalColor, spaceWidth = 5)\n\t(0...png.width).step(spaceWidth).each do |x|\n\t\tdraw_vertical_line(png, verticalColor, x)\n\tend\n\n\t(0...png.height).step(spaceWidth).each do |y|\n\t\tdraw_horizontal_line(png, horizontalColor, y)\n\tend\nend",
"def draw\n print \"\\n a b c d e f g h\\n 8\"\n i = 1\n while i <= 8\n (1..8).each do |j|\n if @spaces[((8 * j) - i)].class == Pawn\n if @spaces[((8 * j) - i)].side_id == 1\n print \" \\u{2659} \"\n else\n print \" \\u{265F} \"\n end\n\n elsif @spaces[((8 * j) - i)].class == Rook\n if @spaces[((8 * j) - i)].side_id == 1\n print \" \\u{2656} \"\n else\n print \" \\u{265C} \"\n end\n\n elsif @spaces[((8 * j) - i)].class == Knight\n if @spaces[((8 * j) - i)].side_id == 1\n print \" \\u{2658} \"\n else\n print \" \\u{265E} \"\n end\n\n elsif @spaces[((8 * j) - i)].class == Bishop\n if @spaces[((8 * j) - i)].side_id == 1\n print \" \\u{2657} \"\n else\n print \" \\u{265D} \"\n end\n\n elsif @spaces[((8 * j) - i)].class == Queen\n if @spaces[((8 * j) - i)].side_id == 1\n print \" \\u{2655} \"\n else\n print \" \\u{265B} \"\n end\n\n elsif @spaces[((8 * j) - i)].class == King\n if @spaces[((8 * j) - i)].side_id == 1\n print \" \\u{2654} \"\n else\n print \" \\u{265A} \"\n end\n\n else\n print \" - \"\n end \n end\n if i < 8\n print \"#{9 - i} \\n #{8 - i}\" \n else \n print \"#{9 - i} \\n a b c d e f g h\"\n end\n i += 1\n end\n true\n end",
"def box msgs, box_char=@box_char, box_size=@box_size\n self.liner box_char, box_size\n [msgs].flatten.each do |text|\n text.each_line do |line|\n self.<< '# ' + box_char + ' ' + line.chomp + \"\\n\"\n end\n end\n self.liner box_char, box_size\n end",
"def render\r\n # puts \"\\e[H\\e[2J\"\r\n\r\n values = @grid\r\n puts \" 0 1 2 3 4 5 6 7 8\".light_black\r\n puts \" +---+---+---+---+---+---+---+---+---+\".light_black\r\n values.each_with_index do |row, idx|\r\n print \" #{idx} |\".light_black\r\n row.each_with_index do |value, idx|\r\n if idx >= 1\r\n print \"|\".light_black\r\n end\r\n # color coding output to cells\r\n if \" #{value} \".match?(/[0]/) # no values printed for open spaces\r\n print \" \"\r\n elsif value.is_a? String # values changed by player are printed in yellow\r\n print \" #{value} \".yellow\r\n else\r\n print \" #{value} \".light_blue # OG values are printed in blue\r\n end\r\n end\r\n print \"|\\n\".light_black\r\n puts \" +---+---+---+---+---+---+---+---+---+\".light_black\r\n end\r\n puts # adds newline at end of board\r\n end",
"def draw_columns\n @sections[:body][:fields].each do |field, settings|\n settings = [settings[0], @posY, (@defaults.merge (settings[1] || { }).symbolize_keys!)]\n settings[2][:style] = settings[2][:style].to_sym\n set_options settings[2]\n draw_line(@posY + @sections[:body][:settings][:height]/2)\n field = settings[2][:column] || field.to_s.split('_').inject('') do |str, part|\n str << part.camelize << \" \"\n end\n draw_text field, settings\n end\n draw_line(@posY - @sections[:body][:settings][:height]/2)\n set_pos_y @sections[:body][:settings][:height]\n end",
"def line_style(data_set_index, options={})\n @line_styles[data_set_index] = \"#{options[:line_thickness]}\"\n @line_styles[data_set_index] += \",#{options[:length_segment]},#{options[:length_blank]}\" if options[:length_segment]\n end",
"def console_display\n print @grid.to_text { |s| Grid.color_to_char(s.color) }\n end",
"def repaint\n woffset = 2\n coffset = 1\n\n # 2016-01-14 - replacing 1 with space since junk is showing up in some cases (in mvvline/mvhline)\n space_char = \" \".codepoints.first\n\n if @parent\n woffset = 0 if @parent.suppress_borders\n @border_attrib ||= @parent.border_attrib\n case @side\n when :right\n @row = @parent.row+1\n @col = @parent.col + @parent.width - 0\n @length = @parent.height - woffset\n when :left\n @row = @parent.row+1\n @col = @parent.col+0 #+ @parent.width - 1\n @length = @parent.height - woffset\n when :top\n @row = @parent.row+0\n @col = @parent.col + @parent.col_offset #+ @parent.width - 1\n @length = @parent.width - woffset\n when :bottom\n @row = @parent.row+@parent.height-0 #1\n @col = @parent.col+@parent.col_offset #+ @parent.width - 1\n @length = @parent.width - woffset\n end\n else\n # row, col and length should be passed\n end\n my_win = @form ? @form.window : @target_window\n @graphic = my_win unless @graphic\n raise \"graphic is nil in divider, perhaps form was nil when creating\" unless @graphic\n return unless @repaint_required\n\n # first print a right side vertical line\n #bc = $bottomcolor # dark blue\n bc = get_color($datacolor, :cyan, :black)\n bordercolor = @border_color || bc\n borderatt = @border_attrib || Ncurses::A_REVERSE\n if @focussed \n bordercolor = $promptcolor || bordercolor\n end\n\n borderatt = convert_attrib_to_sym(borderatt) if borderatt.is_a? Symbol\n\n @graphic.attron(Ncurses.COLOR_PAIR(bordercolor) | borderatt)\n $log.debug \" XXX DIVIDER #{@row} #{@col} #{@length} \"\n case @side\n when :right, :left\n @graphic.mvvline(@row, @col, space_char, @length)\n when :top, :bottom\n @graphic.mvhline(@row, @col, space_char, @length)\n end\n @graphic.attroff(Ncurses.COLOR_PAIR(bordercolor) | borderatt)\n _paint_marker\n #alert \"divider repaint at #{row} #{col} \"\n\n @repaint_required = false\n end",
"def render\n (\"A\"..\"H\").each { |col| print \" #{col}\"}\n print \"\\n\\n\"\n\n (0...8).each do |row|\n # Start counting downwards - rows are upside down in ChessBoard\n row_idx = (7 - row) % @board.rows.count + 1\n print \"#{row_idx} \"\n\n (0...8).each do |col|\n pos = [row, col]\n render_piece(pos)\n end\n\n print \"\\n\\n\"\n end\n\n debug_info if @debug\n print_controls\n end",
"def print *textarray\n create_window unless @win\n show unless @visible\n c = 1\n textarray.each_with_index { |s, i| \n @win.printstring i+@row_offset, c+@col_offset, \"%-*s\" % [@w-(@col_offset*2)-c, s], @color_pair\n }\n @win.wrefresh\n end",
"def initialize\n @lines = 6\n @x = 0\n @y = Graphics.height - window.fitting_height(lines)\n @width = Graphics.width\n @height = window.fitting_height(lines)\n @opacity = 256\n end",
"def draw\n # clear the terminal\n system(\"clear\")\n # draw the top rail\n puts '-' * self.length\n # draw each horse in it's own lane\n self.horses.each do |horse|\n # draw .......all the way up to the position of the horse\n print '.' * horse.position + horse.print\n puts\n # draw the bottom rail\n puts '-' * self.length\n end\n end",
"def set_iline( string = \"\" )\n return if @testing\n Curses::curs_set 0\n @win_interaction.setpos( 0, 0 )\n @win_interaction.addstr( \"%-#{Curses::cols}s\" % string )\n @win_interaction.refresh\n Curses::curs_set 1\n string.length\n end",
"def draw\n @width = @image.columns\n @height = @image.rows\n gc = Magick::Draw.new\n gc.stroke(@color)\n \n #draw horizontal lines\n (0...@height).step(cell_height) do |i|\n gc.line(0,i,@width,i)\n i += cell_height\n end\n \n #draw vertical lines\n (0...@width).step(cell_width) do |i|\n gc.line(i,0,i,@height)\n \n end\n gc.draw(@image)\n end",
"def draw()\n if visible\n \n case self.align \n when 0 # Left\n x = self.rect.x\n when 1 # Middle\n x = self.rect.x + self.rect.width/2 - self.src_rect.width/2\n when 2 # Right\n x = self.rect.x + self.rect.width - self.src_rect.width\n else\n x = 0\n end\n \n case self.valign \n when 0 # Top\n y = self.rect.y\n when 1 # Middle\n y = self.rect.y + self.rect.height/2 - self.src_rect.height/2\n when 2 # Bottom\n y = self.rect.y + self.rect.height - self.src_rect.height\n else\n y = 0\n end\n\n if !active\n opacity = Font.inactive_alpha()\n else\n opacity = self.opacity\n end\n \n bitmap.blt(x, y, self.img_bitmap, self.src_rect, opacity)\n end\n end",
"def print_employee_graphics_box(box)\n\n # Horizontal lines (top to bottom, left to right).\n x = box[:x].in\n y = box[:y].in\n self.line_width = 0.01.in\n stroke_line([x, y], [x + 3.75.in, y])\n y -= 0.25.in\n self.line_width = 0.02.in\n stroke_line([x, y], [x + 3.75.in, y])\n y -= 0.25.in\n stroke_line([x + 1.25.in, y], [x + 3.75.in, y])\n y -= 0.125.in\n stroke_line([x, y], [x + 1.25.in, y])\n y -= 0.125.in\n self.line_width = 0.01.in\n stroke_line([x + 1.25.in, y], [x + 3.75.in, y])\n y -= 0.25.in\n stroke_line([x, y], [x + 3.75.in, y])\n y -= 0.75.in\n stroke_line([x, y], [x + 3.75.in, y])\n y -= 0.25.in\n stroke_line([x, y], [x + 3.75.in, y])\n y -= 0.75.in\n stroke_line([x, y], [x + 3.75.in, y])\n y -= 0.25.in\n stroke_line([x, y], [x + 3.75.in, y])\n y -= 0.25.in\n stroke_line([x, y], [x + 3.75.in, y])\n y -= 0.25.in\n stroke_line([x, y], [x + 1.in, y])\n stroke_line([x + 2.5.in, y], [x + 3.75.in, y])\n y -= 0.25.in\n stroke_line([x, y], [x + 1.in, y])\n stroke_line([x + 2.5.in, y], [x + 3.75.in, y])\n y -= 0.25.in\n stroke_line([x, y], [x + 3.75.in, y])\n y -= 0.375.in\n stroke_line([x, y], [x + 3.75.in, y])\n y -= 0.375.in\n stroke_line([x, y], [x + 3.75.in, y])\n\n # Vertical lines (top to bottom, left to right).\n x = box[:x].in\n y = box[:y].in\n stroke_line([x, y], [x, y - 4.75.in])\n stroke_line([x + 2.6.in, y], [x + 2.6.in, y - 0.25.in])\n stroke_line([x + 3.75.in, y], [x + 3.75.in, y - 4.75.in])\n self.line_width = 0.02.in\n y -= 0.25.in\n stroke_line([x, y], [x, y - 0.375.in])\n stroke_line([x + 1.25.in, y], [x + 1.25.in, y - 0.375.in])\n stroke_line([x + 2.5.in, y], [x + 2.5.in, y - 0.25.in])\n stroke_line([x + 3.75.in, y], [x + 3.75.in, y - 0.25.in])\n y -= 0.25.in\n self.line_width = 0.01.in\n stroke_line([x + 2.5.in, y], [x + 2.5.in, y - 0.25.in])\n y -= 0.125.in\n stroke_line([x + 1.25.in, y], [x + 1.25.in, y - 0.375.in])\n y -= 0.125.in\n stroke_line([x + 2.5.in, y], [x + 2.5.in, y - 0.25.in])\n y -= 2.in\n stroke_line([x + 1.25.in, y], [x + 1.25.in, y - 0.5.in])\n stroke_line([x + 2.5.in, y], [x + 2.5.in, y - 1.25.in])\n y -= 0.5.in\n stroke_line([x + 1.in, y], [x + 1.in, y - 0.75.in])\n y -= 0.75.in\n stroke_line([x + 0.3.in, y], [x + 0.3.in, y - 0.25.in])\n stroke_line([x + 1.4.in, y], [x + 1.4.in, y - 0.375.in])\n stroke_line([x + 2.6.in, y], [x + 2.6.in, y - 0.375.in])\n y -= 0.375.in\n stroke_line([x + 1.25.in, y], [x + 1.25.in, y - 0.375.in])\n stroke_line([x + 2.5.in, y], [x + 2.5.in, y - 0.375.in])\n\n # Text (top to bottom, left to right).\n x = box[:x]\n y = box[:y]\n self.vms_text_box(box[:title], x + 0.1, y, 2.4, 0.25, 7, :bold, :left, :center, nil, 'ff0000')\n self.vms_text_box(\"41-0852411\\nOMB No. 1545-0008\", x + 2.6, y, 1.15, 0.25, 6, :normal, :center, :center)\n y -= 0.25\n self.vms_text_box(\"<strong>a</strong> Employee's soc. sec. no.\", x + 0.05, y - 0.02, 1.15, _p(6), 6, :normal, :left, :top)\n self.vms_text_box(\"<strong>1</strong> Wages, tips, other comp.\", x + 1.3, y - 0.02, 1.15, _p(6), 6, :normal, :left, :top)\n self.vms_text_box(\"<strong>2</strong> Federal income tax withheld\", x + 2.55, y - 0.02, 1.15, _p(6), 6, :normal, :left, :top)\n y -= 0.25\n self.vms_text_box(\"<strong>3</strong> Social security wages\", x + 1.3, y - 0.02, 1.15, _p(6), 6, :normal, :left, :top)\n self.vms_text_box(\"<strong>4</strong> Social security tax withheld\", x + 2.55, y - 0.02, 1.15, _p(6), 6, :normal, :left, :top)\n y -= 0.125\n self.vms_text_box(\"<strong>b</strong> Employer ID number (EIN)\", x + 0.05, y - 0.02, 1.15, _p(6), 6, :normal, :left, :top)\n y -= 0.125\n self.vms_text_box(\"<strong>5</strong> Medicare wages and tips\", x + 1.3, y - 0.02, 1.15, _p(6), 6, :normal, :left, :top)\n self.vms_text_box(\"<strong>6</strong> Medicare tax withheld\", x + 2.55, y - 0.02, 1.15, _p(6), 6, :normal, :left, :top)\n y -= 0.25\n self.vms_text_box(\"<strong>c</strong> Employer's name, address, and ZIP code\", x + 0.05, y - 0.02, 3.65, _p(6), 6, :normal, :left, :top)\n y -= 0.75\n self.vms_text_box(\"<strong>d</strong> Control number\", x + 0.05, y - 0.02, 3.65, _p(6), 6, :normal, :left, :top)\n y -= 0.25\n self.vms_text_box(\"<strong>e</strong> Employee's name, address, and ZIP code\", x + 0.05, y - 0.02, 3.65, _p(6), 6, :normal, :left, :top)\n self.vms_text_box(\"Suff.\", x + 0.05, y - 0.02, 3.65, _p(6), 6, :normal, :right, :top)\n y -= 0.75\n self.vms_text_box(\"<strong>7</strong> Social security tips\", x + 0.05, y - 0.02, 1.15, _p(6), 6, :normal, :left, :top)\n self.vms_text_box(\"<strong>8</strong> Allocated tips\", x + 1.3, y - 0.02, 1.15, _p(6), 6, :normal, :left, :top)\n self.vms_text_box(\"<strong>9</strong> Verification code\", x + 2.55, y - 0.02, 1.15, _p(6), 6, :normal, :left, :top)\n y -= 0.25\n self.vms_text_box(\"<strong>10</strong> Dependent care benefits\", x + 0.05, y - 0.02, 1.15, _p(6), 6, :normal, :left, :top)\n self.vms_text_box(\"<strong>11</strong> Nonqualified plans\", x + 1.3, y - 0.02, 1.15, _p(6), 6, :normal, :left, :top)\n self.vms_text_box(\"<strong>12a</strong> Code (See inst. for box 12)\", x + 2.55, y - 0.02, 1.15, _p(6), 6, :normal, :left, :top)\n y -= 0.25\n self.vms_text_box(\"<strong>13</strong> Statutory employee\", x + 0.05, y - 0.02, 0.9, _p(6), 6, :normal, :left, :top)\n self.vms_text_box(\"<strong>14</strong> Other\", x + 1.05, y - 0.02, 1.4, _p(6), 6, :normal, :left, :top)\n self.vms_text_box(\"<strong>12b</strong> Code\", x + 2.55, y - 0.02, 1.15, _p(6), 6, :normal, :left, :top)\n y -= 0.25\n self.vms_text_box(\"Retirement plan\", x + 0.05, y - 0.02, 0.9, _p(6), 6, :normal, :center, :top)\n self.vms_text_box(\"<strong>12c</strong> Code\", x + 2.55, y - 0.02, 1.15, _p(6), 6, :normal, :left, :top)\n y -= 0.25\n self.vms_text_box(\"Third-party sick pay\", x + 0.05, y - 0.02, 0.9, _p(6), 6, :normal, :center, :top)\n self.vms_text_box(\"<strong>12d</strong> Code\", x + 2.55, y - 0.02, 1.15, _p(6), 6, :normal, :left, :top)\n y -= 0.5\n self.vms_text_box(\"<strong>15</strong> State Employer's ID Number\", x + 0.05, y - 0.02, 1.3, _p(6), 6, :normal, :left, :top)\n self.vms_text_box(\"<strong>16</strong> State wages, tips, etc.\", x + 1.45, y - 0.02, 1.1, _p(6), 6, :normal, :left, :top)\n self.vms_text_box(\"<strong>17</strong> State income tax\", x + 2.65, y - 0.02, 1.05, _p(6), 6, :normal, :left, :top)\n y -= 0.125\n self.vms_text_box(\"<strong>18</strong> Local wages, tips, etc.\", x + 0.05, y - 0.02, 1.15, _p(6), 6, :normal, :left, :top)\n self.vms_text_box(\"<strong>19</strong> Local income tax\", x + 1.3, y - 0.02, 1.15, _p(6), 6, :normal, :left, :top)\n self.vms_text_box(\"<strong>20</strong> Locality name\", x + 2.55, y - 0.02, 1.15, _p(6), 6, :normal, :left, :top)\n y -= 0.375\n self.vms_text_box(\"2018\", x, y - 0.02, 3.75, 0.25, 8, :bold, :center, :top, nil, 'ff0000')\n self.vms_text_box(\"Form W-2 Wage and Tax Statement\", x, y - 0.04, 3.75, 0.125, 6, :bold, :left, :top, nil, 'ff0000')\n self.vms_text_box(\"Dept. of the Treasury -- IRS\", x, y - 0.04, 3.75, 0.125, 6, :normal, :right, :top)\n y -= box[:bottom_left_offset]\n self.vms_text_box(box[:bottom_left], x, y - 0.04, 3.75, box[:bottom_left_height], 6, :normal, :left, :top)\n y -= box[:bottom_right_offset]\n self.vms_text_box(box[:bottom_right], x, y - 0.04, 3.75, 0.125, 6, :normal, :right, :top)\n\n end",
"def render\n system(\"clear\")\n board.each_with_index do |row,i1|\n complete_row = []\n row.each_with_index do |col,i2|\n pos = [i1, i2]\n # debugger\n if pos == cursor.cursor_pos\n complete_row << board[i1][i2].symbol.colorize(:color => :white, :background => :black)\n else\n complete_row << board[i1][i2].symbol.colorize(:color => :white, :background => :red)\n end\n end\n puts complete_row.join\n end\n end",
"def draw\n\t\t#\n\t\t# Draw the \"top\" line.\n\t\t#\n\t\tputs \" \" + \"_\" * (@width * 2 - 1)\n\t\n\t\t#\t\n\t\t# Draw each of the rows.\n\t\t#\n\t\t@height.times do |y|\n\t\t\tprint \"|\"\n\t\t\t@width.times do |x|\n\t\t\t\t# render \"bottom\" using \"S\" switch\n\t\t\t\tprint( (@grid[y][x] & @@S != 0) ? \" \" : \"_\" )\n\t\t\t\n\t\t\t\t# render \"side\" using \"E\" switch\t\n\t\t\t\tif @grid[y][x] & @@E != 0\n\t\t\t\t\tprint( ( (@grid[y][x] | @grid[y][x+1]) & @@S != 0 ) ? \" \" : \"_\" )\n\t\t\t\telse\n\t\t\t\t\tprint \"|\"\n\t\t\t\tend\n\t\t\tend\n\t\t\tputs\n\t\tend\n\n\t\t#\t\n\t\t# Output maze metadata.\n\t\t#\n\t\tputs metadata\n\tend",
"def draw_ascii(pattern, width)\n for i in 0...(pattern.size-width+1)\n puts pattern.slice(i, width).join\n end\nend",
"def paint(win, color)\r\n win.attron(Curses.color_pair(color))\r\n yield\r\n win.attroff(Curses.color_pair(color))\r\nend",
"def print_this(win, text, color, x, y)\n raise \"win nil in print_this\" unless win\n color=Ncurses.COLOR_PAIR(color);\n win.attron(color);\n #win.mvprintw(x, y, \"%-40s\" % text);\n win.mvprintw(x, y, \"%s\" % text);\n win.attroff(color);\n win.refresh\n end",
"def display_board(board)\n (0..board.length - 1).each do |i|\n (0..board[i].length - 1).each do |j|\n print \" \".colorize(:background => board[i][j])\n end\n puts\n end\nend",
"def write_text(text, i, newline_boundary, mode, twid, l_x, offset, len)\n cec, cc, x = /\\e(\\w)(\\[(\\w+)\\])?/, \"\", l_x\n text.each do |w|\n cc = ''\n w = convert_escape_characters(w).gsub(cec) { |s| cc += s and '' }\n wx = text_width(twid, i) / len - (len > 1 && offset < len - 1 ? 12 : 0)\n wid = x + text_size(w.rstrip).width\n if wid > wx\n i += 1 and x = l_x and w.insert(0, newline_boundary)\n wx = text_width(twid, i) / len - (len > 1 && offset < len - 1 ? 12 : 0)\n end\n rect = Rect.new(x + wx * offset, i * line_height + dy, wx,\n line_height)\n next if x == l_x && w =~ /^\\s+$/\n draw_text_ex(rect.x, rect.y, cc, false) if !cc.empty?\n draw_text(rect, w)\n x += text_size(w).width\n end\n return i\n end",
"def repaint graphic, r=@row,c=@col, row_index=-1,value=@text, focussed=false, selected=false\n\n select_colors focussed, selected \n\n value=value.to_s\n if !@display_length.nil?\n if value.length > @display_length\n value = value[0..@display_length-1]\n end\n end\n len = @display_length || value.length\n graphic.printstring r, c, \"%-*s\" % [len, value], @color_pair, @attr\n end",
"def draw_data(x, y, width, header, text)\n x += 5\n width -= 5\n draw_line(x, y + line_height - 1, width)\n #draw_bg_rect(x + 1 , y, width - 2, line_height)\n if header.is_a? String\n change_color(system_color)\n draw_text(x, y, width, line_height, header)\n else\n draw_icon(header, x, y)\n end\n change_color(normal_color)\n draw_text(x, y, width, line_height, text, 2)\n end",
"def draw\n margin = @border_width / 2.0\n \n if @background_color \n old_color = @document.fill_color || \"000000\"\n @document.fill_color(@background_color)\n h = borders.include?(:bottom) ? \n height - ( 2 * margin ) : height + margin\n @document.fill_rectangle [x, y ], width, h \n\n @document.fill_color(old_color)\n end\n\n if @border_width > 0\n @document.mask(:line_width) do\n @document.line_width = @border_width\n\n @document.mask(:stroke_color) do\n @document.stroke_color @border_color if @border_color\n\n if borders.include?(:left)\n @document.stroke_line [x, y + margin], \n [x, y - height - margin ]\n end\n\n if borders.include?(:right)\n @document.stroke_line( \n [x + width, y + margin],\n [x + width, y - height - margin] )\n end\n\n if borders.include?(:top)\n @document.stroke_line(\n [ x, y ], \n [ x + width, y ])\n end\n\n if borders.include?(:bottom)\n @document.stroke_line [x, y - height ],\n [x + width, y - height]\n end\n end\n\n end\n \n borders\n\n end\n\n @document.bounding_box( [x + @horizontal_padding, \n y - @vertical_padding], \n :width => text_area_width,\n :height => height - @vertical_padding) do\n @document.move_down((@document.font.line_gap +\n @document.font.descender) / 2)\n\n options = {:align => @align, :final_gap => false}\n\n options[:size] = @font_size if @font_size\n options[:style] = @font_style if @font_style\n\n old_color = @document.fill_color || \"000000\"\n @document.fill_color @text_color if @text_color \n @document.text @text, options\n @document.fill_color old_color\n end\n end"
] |
[
"0.61942387",
"0.60718477",
"0.5986297",
"0.59728473",
"0.59654534",
"0.59220773",
"0.58990914",
"0.5858564",
"0.5855485",
"0.5821235",
"0.58011276",
"0.5780415",
"0.5769211",
"0.57365894",
"0.5670238",
"0.56543183",
"0.56215304",
"0.5611865",
"0.56101644",
"0.5600343",
"0.5592142",
"0.55841804",
"0.55406415",
"0.55389744",
"0.55336314",
"0.5506705",
"0.5502275",
"0.54987025",
"0.54932106",
"0.547901",
"0.5466167",
"0.54625124",
"0.54389423",
"0.5432357",
"0.5427147",
"0.542641",
"0.5424656",
"0.54176325",
"0.54065543",
"0.5395765",
"0.53936785",
"0.5387618",
"0.5386641",
"0.53854394",
"0.5381096",
"0.5361154",
"0.53560036",
"0.5355718",
"0.5355242",
"0.5333392",
"0.53169364",
"0.5312799",
"0.53104347",
"0.53049046",
"0.53033113",
"0.5299072",
"0.5298642",
"0.529779",
"0.5296946",
"0.5287393",
"0.5281331",
"0.5256904",
"0.5248656",
"0.52399826",
"0.5239888",
"0.52360797",
"0.52355707",
"0.5234052",
"0.52336407",
"0.5232535",
"0.5221223",
"0.5219823",
"0.5197876",
"0.51844114",
"0.51809794",
"0.51793754",
"0.51778144",
"0.5172545",
"0.51700264",
"0.51671135",
"0.51659095",
"0.5161178",
"0.51578856",
"0.5155203",
"0.51541424",
"0.5142525",
"0.5141767",
"0.5141516",
"0.51387995",
"0.5131774",
"0.51255816",
"0.512546",
"0.5120296",
"0.5113471",
"0.5113386",
"0.511216",
"0.5109447",
"0.51093256",
"0.51078284",
"0.51045626",
"0.51014704"
] |
0.0
|
-1
|
Must be an admin to access dashboard
|
def verify_admin?
return if current_user.admin?
flash[:alert] = "Sorry, only admins allowed to view the dashboard."
redirect_to :root
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def ensure_admin!\n authorize! :read, :admin_dashboard\n end",
"def ensure_admin!\n authorize! :read, :admin_dashboard\n end",
"def ensure_admin_user\n redirect_to dashboard_index_path unless is_admin?\n end",
"def admin_only\n unless current_user.admin?\n redirect_to :back, :alert => \"Access denied.\"\n end\n end",
"def administrate!\r\n\tif !current_user.administrator\r\n\t\tredirect \"/dashboard\"\r\n\tend\r\nend",
"def admin_only\n return if admin_user?\n\n add_message 'Insufficient permission to view page'\n redirect_to '/'\n end",
"def admin_only\n unless current_user.admin\n redirect_to home_path, notice: \n \"You must be an admin to perform that function!\"\n end\n end",
"def admin_actions\n unless @current_admin.is_super_admin\n flash[:error]=\"You are not authorized to navigate to this page \"\n redirect_to admin_index_path\n return\n end\n end",
"def admin_only\n if !Volt.current_user.admin\n redirect_to '/login'\n end\n end",
"def admin_access_required\n access_denied unless admin?\n end",
"def admin_access_required\n access_denied unless admin?\n end",
"def admin_access_required\n access_denied unless admin?\n end",
"def check_permission\n redirect_to dashboard_path, notice: 'You are not authorised to perform this action.' unless current_user&.admin?\n end",
"def admin_in!\n access_denied! unless current_user.admin?\n end",
"def admin_only!\n\tif !current_user || !current_user.administrator\n\t\tredirect \"/\"\n\tend\nend",
"def admin\n self.sitemap\n self.follow('dtime:dashboard:admin')\n self.get\n self\n end",
"def require_admin\n unless admin?\n flash[:notice] = \"Sorry, only administrators can do that.\"\n redirect_to :controller => 'typus', :action => 'dashboard'\n end\n end",
"def check_admin\n return redirect_to user_dashboard_path unless current_user.is_admin?\n end",
"def admin_only\n deny_access(\"You must be signed in as an admin to access this page.\") unless signed_in_as_admin?\n end",
"def admin\n #TODO\n end",
"def admin_only\n deny_access(\"Necesitas tener privilegios de administrador para entrar.\") unless signed_in_as_admin?\n end",
"def i_am_admin\n unless current_user.is_admin?\n redirect_to :root \n flash[:error] = \"You haven't the rights to access the required page.\"\n end\n end",
"def administrate!\n\tif current_user.admin == false \n\t\tredirect \"/home\"\n\tend\nend",
"def show\n isadmin\n end",
"def dashboard\r\n end",
"def admin_only\n\t\t\tif logged_in?\n\t\t\t\tif User.find_by(id: current_user.id.to_i).admin != true\n\t\t\t\t\tredirect_to root_path, :alert => \"Odmowa dostępu musisz być adminem\"\n\t\t\t\tend\n\t\t\tend\n\t\tend",
"def dashboard\n end",
"def dashboard\n end",
"def dashboard\n end",
"def dashboard\n end",
"def dashboard\n end",
"def admin!\n redirect_to root_path, alert: \"Not authorized\" and return unless is_admin?\n end",
"def admin\n end",
"def admin\n end",
"def admin\n end",
"def admin\n end",
"def require_admin\n if !logged_in? or !current_user.admin?\n redirect_to login_path, :alert => \"Access denied.\"\n end\n end",
"def admin\n unless current_user.admin?\n redirect_to root_url\n flash[:danger] = \"You have no access here\"\n end\n end",
"def admin_user\n redirect_to root_url, notice: \"You do not have permission to view or edit this information.\" unless current_user.admin?\n end",
"def show\n is_admin?\n end",
"def authorize_admin\n redirect_to root_path, notice: \"You don't have access to admin pages.\" if !current_user.admin?\n end",
"def require_admin\n unless env['warden'].user.advisor? || env['warden'].user.resident?\n flash.error = \"You are not authorized to access that page.\"\n redirect '/'\n end\n end",
"def must_be_admin!\n access_denied! unless current_admin?\n end",
"def show\n is_admin?\n end",
"def dashboard\n\n end",
"def dashboard\n\n end",
"def show\n\t\trequire_admin!\n\tend",
"def admin\n unless current_user.admin?\n #if logged user is not admin display error message and redirect to application INDEX (store_path)\n flash[:error] = \"Authorisation is required to access this content.\"\n redirect_to store_path\n end\n end",
"def require_admin_permission\n redirect_to tables_path, notice: 'Necesita permisos de administrador para visualizar la configuracion' unless current_user_admin?\n end",
"def require_admin\n if logged_in? and !current_user.admin?\n #flash[:danger] = 'Only admin users can perform that action'\n redirect_to root_path\n end\n end",
"def admin_user\n unless current_user && current_user.admin?\n redirect_to login_url, notice: \"admin can only do this action.\" \n end\n end",
"def admin_required\n if not admin?\n redirect \"/login?#{env[\"REQUEST_PATH\"]}\"\n end\n end",
"def admin_required\n unless logged_in? && current_user.is_admin?\n gflash :error => 'You must be an admin to perform this action'\n redirect_to '/'\n end\n end",
"def check_admin\n redirect_to :root unless current_user.admin?\n end",
"def require_admin\n unless admin?\n flash[:warning] = \"Sorry, only administrators can do that.\"\n redirect_to Warnings_url\n end\n end",
"def admin_user\n\t\tunless admin? \n\t\t\tflash[:danger] = \"Only administrators have access to this page\"\n\t\t\tredirect_back_or(root_url) \n\t\tend\n\tend",
"def require_admin\n if logged_in? and !current_user\n flash[:danger] = \"Only admin users can perform that action.\"\n redirect_to root_path\n end\n end",
"def is_admin\n render status: :unauthorized unless current_user.admin\n end",
"def dashboard\n\tend",
"def admin\n\n end",
"def admin_access?\n admin?\n end",
"def admin_required\n current_user.is_admin? || access_denied\n end",
"def admin_only_view\n if !current_user.is_a? Admin and current_user.type != \"AdminAssistant\"\n flash[:error] = \"You are not authorized to view this page.\"\n redirect_to :root\n # Explictly tell the caller that this check failed\n return false\n else\n # Explictly tell the caller that this check was successful\n return true\n end\n end",
"def admin_member\n redirect_to root_path, notice: \"You are not authorized to do that\" if !current_member.admin?\n end",
"def guest\n can :read, ActiveAdmin::Page, name: \"Dashboard\"\n can [:read, :update], User, id: user.id\n end",
"def checkAdmin\n if !admin_signed_in?\n # if current user is not an admin then can't access the page like add teacher,department,college and new subject\n redirect_to root_path, notice: \"Only Admin Can Access This Page\"\n end\n end",
"def dashboard; end",
"def admin_user\n redirect_to(news_index_path) unless is_admin?\n end",
"def show\n @user = current_user\n @admin = @user.admin\n unless @admin\n redirect_to :root, :alert => t(\"notice.access\")\n end\n end",
"def check_admin_only\n\t\t# Check permissions\n\t\tif (not @current_user.is_administrator?)\n\t\t\tredirect_to root_path, notice: \"Access Denied\"\n\t\t\treturn\n\t\tend\n\tend",
"def authorize_admin\n return unless !current_admin\n redirect_to root_path, alert: 'Admins only!'\n end",
"def require_admin\n\t\tif !logged_in? || (logged_in? && !current_user.admin?)\n\t\t\tflash[:danger] = \"Only Admins can perform that action\"\n\t\t\tredirect_to root_path\n\t\tend\n\tend",
"def admin?; false end",
"def require_admin\n not_authorized(\"Invalid credentials.\") unless is_admin?\n end",
"def admin_required\n if current_user && current_user.admin\n return\n end\n redirect_to \"/login\", notice: 'Logga in som administratör.'\n end",
"def check_admin\n if !current_user.admin?\n flash[:error] = \"You dont have access to this Page!!!!!\"\n redirect_to root_path\n end\n end",
"def admin_user\n unless logged_in? && current_user.admin?\n redirect_to root_url\n end\n end",
"def admin_user\n #redirect_to(root_url) unless\n current_user.admin?\n end",
"def admin_user\n #redirect_to(root_url) unless\n current_user.admin?\n end",
"def admin_user\n render_forbidden unless current_user.admin?\n end",
"def is_admin\n \tif current_user != nil\n\t \t \tif !current_user.admin\n redirect_to root_path, :alert => \"Acceso denegado\"\n\t \tend\n\t\t else\n redirect_to root_path, :alert => \"Acceso denegado\"\n\t\t end\n \t\t\n\n end",
"def show\n checkadmin\n end",
"def is_admin\n if current_user && !((current_user.roles.first.name==\"Super Admin\" || current_user.roles.first.name==\"Department Admin\") && current_user.role_memberships.first.status==\"A\")\n redirect_to dashboard_index_path\n end\n end",
"def admin_authorize\n unless admin?\n unauthorized_access\n end\n end",
"def admin_user\n \t\tredirect_to(root_url) unless current_user.admin?\n \tend",
"def check_admin\n if !current_user.admin?\n return redirect_to '/messages/no_access'\n end\n end",
"def admin_use\n redirect_to(root_url) unless current_use.admin?\n end",
"def require_admin\n redirect_to(root_path) unless current_user.admin?\n end",
"def admin_only\n false\n end",
"def admin_required\n redirect_to(\"/\") unless admin?\n end",
"def check_if_admin\n unless current_user.admin\n redirect_to \"/login\"\n end\n end",
"def check_admin\n if not ensure_admin\n redirect_to root_url, alert: \"you are not authorized\"\n end # end if\n end",
"def user_is_admin\n unless current_user.admin?\n flash[:notice] = \"You may only view existing scenarios.\"\n redirect_to root_path\n end\n end",
"def logged_in_admin\n unless admin?\n # show a flash message on the page\n flash[:danger] = \"Non sei autorizzato a visitare questa pagina\"\n # redirect user to home page\n redirect_to root_path\n end\n end",
"def admin\n\t\tif !session[:admin]\n\t\t\tredirect_to root_url\n\t\tend\n\tend",
"def admin_member\n redirect_to(root_url) unless current_member.admin?\n end",
"def require_admin\n if user_signed_in?\n unless current_user.is_admin?\n redirect_to root_path\n end\n end\n end",
"def restrict_to_admin\n unless is_admin\n flash[:danger] = \"You are not an administrator.\"\n redirect_to root_url\n end\n end",
"def check_admin\n redirect_to root_path, alert: \"You do not have admin privileges.\" unless current_user.admin\n end",
"def check_admin\n redirect_to root_path, alert: \"You do not have admin privileges.\" unless current_user.admin\n end"
] |
[
"0.81276625",
"0.81276625",
"0.7951534",
"0.7830267",
"0.77779573",
"0.7712869",
"0.767829",
"0.7672848",
"0.7661495",
"0.764393",
"0.764393",
"0.764393",
"0.7610345",
"0.76047313",
"0.75939715",
"0.75939524",
"0.758793",
"0.75872076",
"0.75818545",
"0.7568248",
"0.75581044",
"0.75563735",
"0.75408417",
"0.75284564",
"0.752425",
"0.7517674",
"0.75087637",
"0.75087637",
"0.75087637",
"0.75087637",
"0.75087637",
"0.75058335",
"0.75042766",
"0.75042766",
"0.75042766",
"0.75042766",
"0.7492059",
"0.74800473",
"0.7475696",
"0.7465392",
"0.74616885",
"0.74586475",
"0.7449403",
"0.7448968",
"0.7447386",
"0.7447386",
"0.7437452",
"0.74297845",
"0.74142367",
"0.74083954",
"0.7405141",
"0.7400023",
"0.74000067",
"0.73984426",
"0.73978364",
"0.7395867",
"0.7391623",
"0.7389207",
"0.7387949",
"0.738607",
"0.73734933",
"0.7370942",
"0.73697466",
"0.7368509",
"0.73602927",
"0.7359835",
"0.7359007",
"0.73567086",
"0.7353542",
"0.7352258",
"0.73468363",
"0.734545",
"0.73399884",
"0.7339404",
"0.733656",
"0.7332672",
"0.7330841",
"0.7330566",
"0.7330566",
"0.73279786",
"0.7311887",
"0.7311088",
"0.73051775",
"0.73033386",
"0.72996116",
"0.729922",
"0.72989565",
"0.72969115",
"0.7290381",
"0.7287727",
"0.7282029",
"0.7281012",
"0.72794825",
"0.727883",
"0.7277441",
"0.72763896",
"0.72762406",
"0.72678554",
"0.7266741",
"0.7266741"
] |
0.74010396
|
51
|
Only allow a list of trusted parameters through.
|
def admin_dashboard_params
params.fetch(:admin_dashboard, {})
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def allowed_params\n ALLOWED_PARAMS\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def param_whitelist\n [:role, :title]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def allow_params_authentication!; end",
"def whitelisted_args\n args.select &:allowed\n end",
"def safe_list_sanitizer; end",
"def safe_list_sanitizer; end",
"def safe_list_sanitizer; end",
"def filtered_parameters; end",
"def sanitize_params_for user, params, allowed_params\n params.each do |key, val|\n #if allowed_params.include?(key)\n #sanitize!(user, params, key) if key =~ /_attributes|_ids$/\n #else\n #params.delete(key)\n #end\n params.delete(key) unless allowed_params.include?(key.to_sym)\n end\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def expected_permitted_parameter_names; end",
"def sanitize_parameters!(sanitizer, params)\n # replace :readwrite with :onlyif\n if params.has_key?(:readwrite)\n warn \":readwrite is deprecated. Replacing with :onlyif\"\n params[:onlyif] = params.delete(:readwrite)\n end\n\n # add default parameters\n bindata_default_parameters.each do |k,v|\n params[k] = v unless params.has_key?(k)\n end\n\n # ensure mandatory parameters exist\n bindata_mandatory_parameters.each do |prm|\n if not params.has_key?(prm)\n raise ArgumentError, \"parameter ':#{prm}' must be specified \" +\n \"in #{self}\"\n end\n end\n\n # ensure mutual exclusion\n bindata_mutually_exclusive_parameters.each do |param1, param2|\n if params.has_key?(param1) and params.has_key?(param2)\n raise ArgumentError, \"params #{param1} and #{param2} \" +\n \"are mutually exclusive\"\n end\n end\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def safe_list_sanitizer=(_arg0); end",
"def safe_list_sanitizer=(_arg0); end",
"def safe_list_sanitizer=(_arg0); end",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def check_params; true; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def allowed?(*_)\n true\n end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def allowed_params(parameters)\n parameters.select do |name, values|\n values.location != \"path\"\n end\n end",
"def secure_params\n return @secure_params if @secure_params\n\n defn = implementation_class.definition\n field_list = [:master_id] + defn.field_list_array\n\n res = params.require(controller_name.singularize.to_sym).permit(field_list)\n res[implementation_class.external_id_attribute.to_sym] = nil if implementation_class.allow_to_generate_ids?\n @secure_params = res\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permit( params, whitelist, name = nil )\n raise 'Parametrization not yet configured' unless @configured\n whitelist ||= []\n px = params.respond_to?( :permit ) ? params : ActionController::Parameters.new( params )\n px = dig(px, name)\n px.permit( *whitelist )\n end",
"def valid_params?; end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def url_allowlist=(_arg0); end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def list_params\n params.permit(:list_name)\n end",
"def valid_params_request?; end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def param_list(param_type, name, type, required, description = nil, allowed_values = [], hash = {})\n hash.merge!({allowable_values: {value_type: \"LIST\", values: allowed_values}})\n param(param_type, name, type, required, description, hash)\n end",
"def safelists; end",
"def authorize_own_lists\n authorize_lists current_user.lists\n end",
"def listed_params\n params.permit(:listed, :list_id, :listable_id, :listable_type, :campsite_id)\n end",
"def lists_params\n params.require(:list).permit(:name)\n\n end",
"def list_params\n params.require(:list).permit(:name, :user_id)\n end",
"def list_params\n params.require(:list).permit(:name, :description, :type, :privacy, :allow_edit, :rating, :votes_count, :user_id)\n end",
"def check_params\n true\n end",
"def authorize_own_or_shared_lists\n authorize_lists current_user.all_lists\n end",
"def user_pref_list_params\n\t\tparams.require(:user).permit(:preference_list)\n\tend",
"def may_contain!(*keys)\n self.allow_only_permitted = true\n self.permitted_keys = [*permitted_keys, *keys].uniq\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def whitelist; end",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def list_params\n params.permit(:name)\n end",
"def recipient_list_params\n params.require(:recipient_list).permit(:name, :list, :references)\n end",
"def cancan_parameter_sanitizer\n resource = controller_name.singularize.to_sym\n method = \"#{resource}_params\"\n params[resource] &&= send(method) if respond_to?(method, true)\n end",
"def list_params\n params.require(:list).permit(:name).merge(user_id: current_user.id)\n end",
"def whitelist_place_params\n params.require(:place).permit(:place_name, :unlock, :auth, :is_deep_checked, :parent_ADM4, :parent_ADM3, :parent_ADM2, :parent_ADM1, :parent_country, feature_code: [], same_as: [], related_authority: [], altlabel: [], note: []) # Note - arrays need to go at the end or an error occurs!\n end",
"def list_params\n params.fetch(:list, {}).permit(:user_id, :name, :active)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def secure_params(require_param, permit_keys)\n params.require(require_param).permit(*permit_keys)\n end",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def permitted_params\n []\n end",
"def price_list_params\n params.fetch(:price_list, {}).permit(:name, :valid_from, :valid_to, :active,\n :all_warehouses, :all_users, :all_contact_groups,\n warehouse_ids: [], price_lists_user_ids: [], contact_group_ids: [])\n end",
"def params(list)\n @declared_params = list\n end",
"def admin_review_params\n params.fetch(:review, {}).permit(whitelisted_params)\n end",
"def saved_list_params\n params.require(:saved_list).permit(:user_id)\n end",
"def allow(ids); end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def filter_params(param_set, **kwargs)\r\n begin\r\n key = kwargs[:key]\r\n params.require(key).permit(*param_set)\r\n rescue Exception\r\n params.permit(*param_set)\r\n end\r\n end",
"def valid_parameters\n sort_symbols(@interface.allowed_parameters)\n end",
"def validate_paramified_params\n self.class.paramify_methods.each do |method|\n params = send(method)\n transfer_errors_from(params, TermMapper.scope(params.group)) if !params.valid?\n end\n end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def secure_params\n return @secure_params if @secure_params\n\n @implementation_class = implementation_class\n resname = @implementation_class.name.ns_underscore.gsub('__', '_').singularize.to_sym\n @secure_params = params.require(resname).permit(*permitted_params)\n end",
"def refine_permitted_params(param_list)\n res = param_list.dup\n\n ms_keys = res.select { |a| columns_hash[a.to_s]&.array }\n ms_keys.each do |k|\n res.delete(k)\n res << { k => [] }\n end\n\n res\n end",
"def recipient_list_params\n params.require(:recipient_list).permit(:name, :description, recipient_id_array: [])\n end",
"def safelist; end",
"def sponsor_params\n params.require(:sponsor).permit(WHITE_LIST)\n end",
"def valid_for_params_auth?; end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def shopping_list_params\n params.require(:shopping_list).permit!\n end",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def permitters\n @_parametrizr_permitters || {}\n end",
"def allow_params(action, keys: nil, except: nil, &blk)\n keys &&= Array.wrap(keys)\n keys ||= User.field_names\n except &&= Array.wrap(except)\n except ||= %i[id email]\n devise_parameter_sanitizer.permit(action, keys: keys, except: except, &blk)\n end",
"def list_params\n if current_user && current_user.role == 'admin'\n params.require(:list).permit(:name, :url, :description, :user_id,\n ideas_attributes: [:id, :list_id, :body, :due_date, :completion_status, :_destroy])\n else\n params.require(:list).permit(:name, :description,\n ideas_attributes: [:body, :due_date, :completion_status]) \n end\n end",
"def whitelist(params)\n send_request_of_type(GlobalConstant::PrivateOpsApi.private_ops_api_type, 'post', '/token-sale/whitelist', params)\n end",
"def valid_access_params\n params.require(:valid_access).permit(:wish_list_id, :user_id)\n end",
"def url_allowlist; end",
"def ensure_redirected_params_are_safe!(passed_params)\n unless passed_params.is_a?(ActionController::Parameters) && passed_params.permitted?\n error_message = if passed_params.is_a?(ActionController::Parameters)\n unsafe_parameters = passed_params.send(:unpermitted_keys, params)\n \"[Rails::Prg] Error - Must use permitted strong parameters. Unsafe: #{unsafe_parameters.join(', ')}\"\n else\n \"[Rails::Prg] Error - Must pass strong parameters.\"\n end\n raise error_message\n end\n end",
"def data_collection_params\n allow = [:name,:description,:institution,:collection_name,:country_id,:province_id,:city_id]\n params.require(:data_collection).permit(allow)\n end",
"def quote_params\n params.permit!\n end"
] |
[
"0.69497335",
"0.6812623",
"0.6803639",
"0.6795365",
"0.67448795",
"0.67399913",
"0.6526815",
"0.6518771",
"0.64931697",
"0.6430388",
"0.6430388",
"0.6430388",
"0.63983387",
"0.6356042",
"0.63535863",
"0.63464934",
"0.63444513",
"0.6337208",
"0.6326454",
"0.6326454",
"0.6326454",
"0.63140553",
"0.6299814",
"0.62642586",
"0.626006",
"0.62578833",
"0.6236823",
"0.6227561",
"0.6221758",
"0.62200165",
"0.620879",
"0.61983657",
"0.6195055",
"0.6172993",
"0.6156856",
"0.61558664",
"0.61521494",
"0.6135789",
"0.6121145",
"0.61118174",
"0.60736513",
"0.6071645",
"0.60632104",
"0.60549796",
"0.6043906",
"0.6034662",
"0.60207325",
"0.6018568",
"0.6016575",
"0.60103434",
"0.60084206",
"0.600763",
"0.6007443",
"0.6003619",
"0.6003619",
"0.5995791",
"0.5993301",
"0.5993231",
"0.5984926",
"0.597122",
"0.5968121",
"0.5965808",
"0.59640145",
"0.59632224",
"0.59602356",
"0.59332967",
"0.5927556",
"0.5922805",
"0.5909745",
"0.5905083",
"0.5904304",
"0.5893434",
"0.58888215",
"0.58823985",
"0.58823985",
"0.58823985",
"0.5873434",
"0.58619875",
"0.58533794",
"0.5845531",
"0.58426666",
"0.58360124",
"0.583218",
"0.5828041",
"0.5827927",
"0.5816121",
"0.5814705",
"0.5812719",
"0.581121",
"0.5803423",
"0.5803423",
"0.57995003",
"0.5794207",
"0.5784923",
"0.5781365",
"0.5776385",
"0.5774859",
"0.57671493",
"0.5766998",
"0.57618684",
"0.5758038"
] |
0.0
|
-1
|
Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution, and you may not use the same element twice. Time: O(n) Space: O(n)
|
def two_sum(array, target)
num_hash = {}
array.each_with_index do |num, index|
difference = target - num
if num_hash[difference]
return [num_hash[difference], index]
else
num_hash[num] = index
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def two_sum(nums, target)\n target_indexes = []\n nums.each_with_index do |primary, index|\n nums.each_with_index do |num, i|\n if primary + num == target && index != i\n target_indexes << index\n target_indexes << i\n end\n end\n end\n return target_indexes.uniq\nend",
"def solve(nums, target)\n nums.each_with_index do |e, i|\n nums.each_with_index do |e_, i_|\n return [i, i_] if ((e + e_ == target) && (i != i_))\n end\n end\nend",
"def brute_force_two_sum(array, target)\n indexes = []\n array.each.with_index do |n1, index1|\n array.each.with_index do |n2, index2|\n indexes.push(index1) if target - n1 == n2 && index1 != index2\n end\n end\n indexes\nend",
"def two_sum(numbers, target)\n\n numbers.each_with_index do |num, index|\n \n looking_for = target - num\n answer_2 = binary_search(numbers, index + 1, numbers.length - 1, looking_for)\n if !!answer_2\n return [index + 1, answer_2 + 1] \n end\n end\nend",
"def two_sum(numbers, target)\n arr = numbers\n num = target\n index_array = []\n return_array = []\n current_index = 0\n\n loop do\n idx_counter = current_index\n current_element = arr[current_index]\n\n loop do\n break if idx_counter >= arr.length - 1\n next_index = idx_counter + 1\n next_element = arr[next_index]\n if current_element + next_element == num\n index_array << current_index << next_index\n end\n idx_counter += 1\n end\n\n if return_array == []\n current_index += 1\n end\n break if return_array.reduce(:+) == num\n end\n\n p index_array\nend",
"def two_sum(nums, target)\n hsh = Hash.new\n nums.each_with_index do |n, i|\n hsh[n] = i+1\n end\n \n nums.each_with_index do |val, ind|\n second = target - val\n if hsh.include?(second) && nums.index(second) != ind\n return [ind+1, nums.index(second)+1]\n end\n end\nend",
"def two_sum(nums, target)\n nums.each_with_index do |num1, idx1|\n nums.each_with_index do |num2, idx2|\n if (num1 + num2 == target) && (idx1 != idx2)\n return [idx1, idx2]\n end\n end\n end\nend",
"def two_sum(nums, target)\n results = []\n i = 1\n while i < nums.length\n diff = target - nums[i - 1]\n if nums[i..-1].include?(diff)\n idx = nums[i..-1].index(diff)\n results << i - 1 << idx + i\n end\n\n i += 1\n end\n\n results\nend",
"def two_sum(numbers, target)\n numbers.each_with_index do |num, idx|\n # why `idx + 1`? because we don't want to include the number in our search\n # so if we start at idx 0, we want to search from 1..end for the complement\n # also, so we don't re-search smaller numbers, since this array is sorted.\n low = idx + 1\n high = numbers.size - 1\n search = target - num\n\n while low <= high\n mid = (low + high) / 2\n\n if numbers[mid] == search\n return [idx + 1, mid + 1] # NOT zero-indexed!\n elsif numbers[mid] > search\n # note we ignore including `mid` on next search for both `high` and `low`\n # and our first condition already takes care of `mid`\n high = mid - 1\n else\n low = mid + 1\n end\n end\n end\nend",
"def map_then_iterate_two_sum(array, target)\n hash = {}\n array.each.with_index do |i, index|\n hash[i] = index\n end\n indexes = []\n array.each.with_index do |ii, index|\n complement = target - ii \n if hash.has_key?(complement) && hash.fetch(complement) != index\n indexes.push(index, hash.fetch(complement))\n return indexes\n end\n end\nend",
"def two_sum(nums, target)\n indices_array = []\n i = 0\n while i < nums.length\n j = i + 1\n while j < nums.length\n if nums[i] + nums[j] == target\n indices_array << i\n indices_array << j\n end\n j += 1\n end\n i += 1\n end\n return indices_array\nend",
"def two_sum_binary(numbers, target)\n numbers.each_with_index do |num, i|\n j = binary_search(numbers, target - num, i+1)\n\n # +1 because we do both index1 and index2 are not zero-based\n return [i+1, j+1] unless j == -1\n end\n\n raise ArgumentError.new(\"No two sum solution\")\nend",
"def two_sum(nums, target)\n nums.each_with_index do |ele, i|\n check = target - ele\n return i, nums.index(check) if nums.include?(check) && i != nums.index(check)\n end\nend",
"def twoSum(numbers, target)\n # solution\n result = []\n numbers.each do |i|\n y = numbers.length - 1\n while y > numbers.index(i) do \n if i + numbers[y] == target\n result << numbers.index(i) << y\n return result\n end\n y -= 1\n end\n end\nend",
"def two_sum_indices(arr, target_sum)\n complements = {}\n arr.each_with_index do |el, i|\n complement, j = complements[target_sum - el] # these will both be nil if the complement doesn't exist\n return [i, j] if complement\n\n complements[el] = [el, i]\n end\n nil\nend",
"def two_sum(integers, target)\n # O(n)\n integers_with_index = integers.each_with_index.to_a\n # O(n*log(n))\n integers_with_index = integers_with_index.sort_by { |(n, _)| n }\n\n front, back = 0, integers_with_index.count - 1\n\n until front == back\n sum = integers_with_index[front][0] + integers_with_index[back][0]\n if sum == target\n return [integers_with_index[front][1], integers_with_index[back][1]].sort\n elsif sum > target\n back -= 1\n else\n front += 1\n end\n end\nend",
"def twoSum(numbers, target)\n (0...(numbers.size - 1)).each do |ind1|\n ((ind1 + 1)...numbers.size).each do |ind2|\n return [ind1, ind2] if numbers[ind1] + numbers[ind2] == target\n end\n end\nend",
"def one_pass_two_sum(array, target)\n hash = {}\n array.each.with_index do |i, index|\n complement = target - i\n if hash.has_key?(complement)\n return [hash.fetch(complement), index]\n end\n hash[i] = index\n end\nend",
"def two_sum(nums, target)\n nums.each_with_index do |num1, idx1|\n nums.each_with_index do |num2, idx2|\n next if idx1 == idx2\n return [idx1, idx2] if num1 + num2 == target\n end\n end\n return \"Couldn't find target value\"\nend",
"def two_sum(nums, target)\n result = []\n nums.each_with_index do |num, idx|\n find_num = target - num\n result = [idx, nums.index(find_num)] if nums.include?(find_num) && nums.index(find_num) != idx\n return result if result.length > 0\n end\n\n if result.length == 0\n return \"Target sum not found in array\"\n end\nend",
"def two_sum(nums, target)\n sorted_nums = nums.sort\n\n last_index = sorted_nums.size - 1\n first_index = 0\n\n while true do\n if sorted_nums[last_index] + sorted_nums[first_index] > target\n last_index -= 1\n\n next\n end\n\n smaller_have_to_be = target - sorted_nums[last_index]\n\n while true do\n if sorted_nums[first_index] < smaller_have_to_be\n first_index += 1\n\n next\n end\n\n break\n end\n\n if sorted_nums[first_index] != smaller_have_to_be\n last_index -= 1\n next\n end\n\n break\n end\n\n # Find correct indexes ( because that indexs in sorted array )\n\n result = []\n nums.each_with_index do |number, index|\n if [sorted_nums[first_index], sorted_nums[last_index]].include?(number)\n result.push(index)\n end\n end\n\n result\nend",
"def two_sum(numbers, target)\n size = numbers.length\n i = 0\n j = size - 1\n\n while numbers[i] + numbers[j] != target\n i += 1 if (numbers[i] + numbers[j]) < target\n j -= 1 if (numbers[i] + numbers[j]) > target\n end\n\n [i + 1, j + 1]\nend",
"def two_sum_indices(arr, target_sum)\n complements = {}\n arr.each_with_index do |el, i|\n complement, j = complements[target_sum - el] # these will both be nil if the complement doesn't exist\n return [i, j] if complement\n \n complements[el] = [el, i]\n end\n nil\nend",
"def two_sum(nums, target)\n complements = Hash.new\n \n nums.each_with_index do |num, index|\n if complements.has_key? (target - num)\n return [complements[target - num], index]\n else\n complements[num] = index\n end\n end\n \n return []\nend",
"def two_sum(nums, target)\n # i,j = 0, nums.length-1\n i = 0\n j = nums.length-1\n output = []\n while i < nums.length-1\n while j > i\n if nums[i] + nums[j] == target\n output << i << j\n end\n j-=1\n end\n i+=1\nend\nreturn output #returning index\nend",
"def two_sum(nums, target)\n hash_idx_nums = {}\n index_result_array = []\n for index in (0...nums.length)\n hash_idx_nums[index] = nums[index]\n end\n\n # nums.each do |num|\n # result = target - num\n # if hash_idx_nums.value?(result)\n # index_result_array << hash_idx_nums.key(result)\n # end\n # end\n for index in (0...nums.length)\n result = target - nums[index]\n \n if hash_idx_nums.value?(result) && hash_idx_nums.key(result) != index\n index_result_array << hash_idx_nums.key(result)\n end\n end\n p index_result_array\n return index_result_array[0], index_result_array[1]\nend",
"def two_sum(numbers, target)\n numbers.each_with_index do |n1, i1|\n numbers.each_with_index do |n2, i2|\n return [i1, i2] if (n1 + n2) == target && i1 != i2\n end\n end\nend",
"def two_sum(nums, target)\n index_of_complement = {}\n (0...nums.size).each do |i|\n if index_of_complement.key?(nums[i]) \n return [index_of_complement[nums[i]], i] \n else\n index_of_complement[target - nums[i]] = i\n end\n end\nend",
"def two_sum(nums, target)\n nums_hash = {}\n nums.each_with_index do |val, i|\n nums_hash[val] = i\n end\n\n nums.each_with_index do |ival, i|\n complement = target - ival\n next if nums_hash[complement] == i\n if nums_hash.key?(complement)\n return [i, nums_hash[complement]]\n end\n end\n []\nend",
"def two_sum(nums, target)\n seen = {}\n nums.each_with_index do |num, idx|\n return [seen[num], idx] if seen[num]\n\n seen[target - num] = idx\n end\nend",
"def two_sum(nums, target)\n nums_hash = {}\n \n nums.each.with_index do |num, idx|\n nums_hash[num] = idx\n end\n \n nums.each.with_index do |num1, i|\n val = target - num1\n \n return [i, nums_hash[val]] if nums_hash[val] && nums_hash[val] != i\n end\nend",
"def two_sum(array, target)\n found = Hash.new(false)\n goal = nil\n\n array.each do |el|\n goal = (target - el).abs\n return true if found[goal] && goal + el == target\n found[el] = true\n end\n\n false\nend",
"def two_sum(numbers, target)\n n_index = {} \n (0...numbers.length).each do |i1|\n i2 = n_index[target - numbers[i1]]\n return [i1 + 1, i2 + 1].sort if i2 && i2 != i1 \n n_index[numbers[i1]] = i1\n end\nend",
"def two_sum(nums, target)\n map = {}\n\n (0...nums.size).each do |i|\n current_value = nums[i]\n\n if map[target - current_value]\n return [map[target - current_value] + 1, i + 1]\n else\n map[current_value] = i\n end\n end\nend",
"def two_sum(nums, target)\n hash = Hash.new\n nums.each_with_index do |num, index|\n findable = target - num\n if hash[findable]\n return [nums.index(findable), index]\n end\n hash[num] = findable\n end\n require 'pry'; binding.pry\nend",
"def two_sum(nums, target)\n nums.map do | i |\n x = nums.index(i)+1\n if nums[x] + i == target\n return [nums.index(i),x]\n end\n end\nend",
"def two_sum(nums, target)\n if target_match = nums.combination(2).find { |pair| pair.sum == target }\n index1 = nums.index(target_match[0])\n nums.delete_at(nums.index(target_match[0]))\n index2 = nums.index(target_match[1]) + 1\n [index1, index2]\n end\nend",
"def two_sum_indices?(arr, target_sum)\n summands = {}\n\n arr.each_with_index do |num, i|\n summand = target_sum - num\n return [target_sum[summand], i] if summands.key?(summand)\n\n summands[num] = i\n end\n\n false\nend",
"def two_sum(nums, target)\n diff = {}\n\n nums.each_with_index do |num, idx|\n if diff[num]\n return [diff[num], idx]\n else\n diff[target - num] = idx\n end\n end\nend",
"def two_sum(nums, target)\n hash = {}\n nums.each_with_index do |num, idx|\n other_num = target - num\n other_num_idx = hash[other_num]\n return [other_num_idx, idx] if other_num_idx\n\n hash[num] = idx\n end\n []\nend",
"def two_sum(nums, target)\n hash = {}\n nums.each_with_index do |val, index|\n ans = target - val\n return [hash[ans], index] if hash.include?(ans)\n\n hash[val] = index\n end\nend",
"def two_sum(nums, target)\n num_hash = Hash.new\n \n nums.each_with_index do |num, idx|\n diff = target - num\n if num_hash[diff]\n return idx < num_hash[diff] ? [idx, num_hash[diff]] : [num_hash[diff], idx]\n end\n num_hash[num] = idx\n end\n null\nend",
"def two_sum(nums, target)\n hash = {}\n\n nums.each_with_index do |n, idx|\n differential = target - n\n return [hash[differential], idx] if hash[differential]\n hash[n] = idx\n end\nend",
"def nums(target, *array)\n\tarray.each_with_index do |a, x|\n\t\tarray.each_with_index do |b, y|\n\t\t\tif x > y\n\t\t\t\tif a + b == target\n\t\t\t\t\treturn true\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend\n\treturn false\nend",
"def two_sum(numbers, target)\n i = 0\n j = numbers.length - 1\n\n while i < j\n sum = numbers[i] + numbers[j]\n\n if target < sum\n j -= 1\n elsif target > sum\n i += 1\n else\n return [i + 1, j + 1]\n end\n end\nend",
"def pair_sum(arr, target)\n # basic approach is nested loops scanning each element checking if its == to target\n result = []\n i = 0\n j = i + 1\n while i < arr.length\n while j < arr.length\n p i, j\n if i != j && arr[i] + arr[j] == target\n result << [i, j]\n end\n j += 1\n end\n i += 1\n j = i + 1\n end\n result\nend",
"def two_sum(integers, target) \n checked = {}\n integers.each.with_index do |num, idx|\n diff = target - num\n checked[diff] ? (return true) : (checked[num] = idx)\n end\n false\nend",
"def two_sum(nums, target)\n\tnum_len = nums.length\n\tdic = {}\n\ti = 0 \n while i < num_len\t\n \tnumber = nums[i]\n \tif number == target / 2 && dic[number]\n \t\treturn [dic[number],i]\n \tend\n \tdic[number] = i\n \tmaybe = dic[target-number]\n \tif maybe && maybe != i\n \t\treturn [maybe,i]\n \t\tbreak\n \tend\n i += 1\n end\nend",
"def adds_up(nums, target)\n\n i = 0\n while i < nums.length\n j = i + 1\n while j < nums.length\n if nums[i] == target - nums[j]\n return [i, j]\n end\n\n j += 1\n end\n\n i += 1\n end\n\n return []\nend",
"def two_sum(numbers, target)\n hash={}\n numbers.each_with_index do |num,index|\n if(hash[num])\n return [hash[num], index+1]\n else\n hash[target-num] = index+1\n end\n end\nend",
"def two_sum(nums, target)\n numbers_checked = {}\n\n nums.each do |num|\n other_part_of_pair = target - num\n if numbers_checked.has_key?(other_part_of_pair)\n return [nums.index(other_part_of_pair), nums.rindex(num)]\n else\n numbers_checked[num] = true\n end\n end\nend",
"def two_sum(arr, target) \n hash = {}\n \n i = 0\n for val in arr do\n val1 = arr[i]\n val2 = target - val1 \n if hash[val2] \n return [hash[val2], i]\n else\n hash[val1] = i \n end\n i += 1\n end\n\n nil \nend",
"def two_sum(numbers, target)\n ##set hash\n hash = {}\n ##set array\n arr = []\n\n numbers.each_with_index do |val, idx|\n if hash.key?(target - val)\n arr.push(hash[target - val])\n arr.push(idx + 1)\n break\n else\n hash[val] = idx + 1\n end\n end\n\n arr\nend",
"def two_sum_hash(numbers, target)\n n_index = {} \n (0...numbers.length).each do |i2|\n i1 = n_index[target - numbers[i2]] \n\n # We know that n[i2] > n[i1] because input array is sorted.\n return [i1 + 1, i2 + 1] if i1 && i1 != i2\n n_index[numbers[i2]] = i2\n end\nend",
"def two_sum(nums, target)\n table = {}\n i = 0\n while i < nums.length\n table[target - nums[i]] = i\n i += 1\n end\n \n j = 0\n while j < nums.length\n if table.key?(nums[j]) && j != table[nums[j]]\n return [j, table[nums[j]]] \n end\n j += 1\n end\nend",
"def two_sum(nums, target)\n h = {}\n nums.each_with_index do |a, i|\n n = target - a\n return [h[n], i] if h[n]\n h[a] = i\n end\nend",
"def two_sum(nums, target)\n map = {}\n len = nums.length\n len.times do |i|\n complement = target - nums[i]\n if map.include? complement\n return [i, map[complement]]\n end\n map[nums[i]] = i\n end\n raise \"No solution !\"\nend",
"def two_sum(array, target)\n\n !!array.uniq.combination(2).detect { |a, b| a + b == target }\nend",
"def sum_pair(list, target)\n list.each do |a|\n list.each do |b|\n if a + b == target and list.index(a) != list.index(b)\n return [a, b]\n end\n end\n end\nend",
"def find_triplets(target)\n @nums.each do |num, occ|\n pair = find_pairs(target - num)\n return num * pair if pair != -1\n end\n end",
"def two_sum(numbers, target)\n low = 0\n high = numbers.size - 1\n\n until low == high\n sum = numbers[low] + numbers[high]\n case sum <=> target\n when 0\n return [low + 1, high + 1] # NOT zero-indexed!\n when 1 # sum > target\n high -= 1\n when -1 # sum < target\n low += 1\n end\n end\nend",
"def two_sum?(arr, target)\n h = Hash.new\n arr.each_with_index do |val, i|\n h[val] = i\n end\n\n arr.each_index do |i|\n to_find = target - arr[i]\n return true if h[to_find] && h[to_find] != i\n end\n false\nend",
"def two_sum_ptr(nums, target)\n low, high = 0, nums.length - 1\n while( low < high)\n if(nums[low] + nums[high] == target)\n return [low + 1, high + 1]\n elsif nums[low] + nums[high] < target\n low += 1\n else\n high -= 1\n end\n end\nend",
"def two_sum(nums, target)\n low = 0\n high = nums.length - 1\n\n while low < high\n sum = nums[low] + nums[high]\n\n if sum < target\n low += 1\n elsif sum > target\n high -= 1\n else\n return[low, high]\n end\n end\nend",
"def find_target_sum_arrays(arr, target)\n helper(arr, target, arr.length - 1, [], 0)\nend",
"def two_sum?(array, target)\n #O(n)\n hash = Hash.new(0)\n i = 1\n array.each do |ele|\n hash[ele] = i \n i += 1\n end\n hash.each_key do |k|\n return true if hash.has_key?(target - k) && hash[k] != hash[target - k]\n end\n false \nend",
"def sorting_two_sum(array, target)\n arr = array.sort\n arr.each_with_index do |int, idx|\n search_array = array[0...idx] + array[(idx + 1)..-1]\n return true if search_array.bsearch { |x| x == target - int }\n end\n false\nend",
"def two_number_sum(array, target_sum)\n i = 0\n while i <= array.length - 1\n j = array.length - 1\n while j >= 0\n if array[i] + array[j] == target_sum && i != j\n return [array[i], array[j]]\n end\n j -= 1\n end\n i += 1\n end\n return []\nend",
"def two_sum_with_hash(nums, target)\n h = {}\n nums.each_with_index {|x, index| h[x] = index }\n nums.each_with_index do |row, index|\n diff = target - row\n if h.keys.include? diff and (not h[diff] == index)\n return index, h[diff]\n end\n end\nend",
"def bad_two_sum?(arr, target)\n sums = []\n arr.each_index do |i|\n (i+1...arr.length).each do |j|\n sums << arr[i] + arr[j]\n end\n end\n sums.include?(target)\nend",
"def find_complements1(numbers, target_sum: 2020)\n complements = numbers.map { |n| [n, target_sum - n] }.to_h\n complements.find { |_n, c| complements.key?(c) }\nend",
"def two_sum?(arr, target)\n s1 = Set.new \n arr.each_with_index do |el, idx|\n return true if s1.include?(target-el)\n s1.add(el)\n end\n false\nend",
"def sum_pairs(nums, target)\n results = []\n if nums.count < 2\n return results\n end\n nums.sort!\n (0..(nums.length - 2)).each do |first_index|\n second_index = first_index + 1\n until second_index == nums.length\n sum = nums[first_index] + nums[second_index]\n if sum == target\n results << [nums[first_index], nums[second_index]].sort\n end\n second_index += 1\n end\n end\n results.sort\nend",
"def two_sum_2_pointers(numbers, target)\n l_pointer = 0\n r_pointer = numbers.size - 1\n\n while l_pointer < r_pointer\n sum = numbers[l_pointer] + numbers[r_pointer]\n\n if sum < target\n l_pointer += 1\n elsif sum > target\n r_pointer -= 1\n else\n return [l_pointer + 1, r_pointer + 1]\n end\n end\n\n raise ArgumentError.new(\"No two sum solution\")\nend",
"def okay_two_sum(arr, target)\n #O(n)\n arr.sort!\n i = 0\n j = arr.length - 1\n while i < j\n sum = arr[i] + arr[j]\n return true if sum == target\n if sum < target\n i += 1\n else\n j -= 1\n end\n end\n false\nend",
"def okay_two_sum?(nums, target)\n output = []\n i = 0\n j = nums.length - 1\n \n while i != j\n sum = nums[i] + nums[j]\n\n if sum == target\n output << [i, j]\n end \n\n if sum <= target\n i += 1\n else\n j -= 1\n end\n end\n\n output\nend",
"def good_two_sum?(arr, target)\n input_hash = Hash.new\n \n arr.each.with_index do |el, i|\n input_hash[el]=i\n end\n arr.each.with_index do |el, i|\n var = input_hash[target - el]\n return true if var && var !=i\n end\n false\nend",
"def fast_hash_additive_find(arr, target)\n lookup_table = Hash.new\n\n arr.each do |element|\n return true if lookup_table[target - element]\n if lookup_table[element]\n lookup_table[element] += 1\n else\n lookup_table[element] = 1\n end\n end\n\n return false\n end",
"def okay_two_sum?(arr, target)\n arr = arr.sort\n arr.each_index do |i|\n to_find = target - arr[i]\n sub_arr = arr[0...i] + arr[i + 1..-1]\n return true if sub_arr.bsearch { |x| x == to_find }\n end\n false\nend",
"def two_sum(n, target)\n n.each_with_object({}).with_index do |(v,o),j|\n i = o[target - v]\n return [i,j] if i\n o[v] = j\n end\n raise \"Cannot Find Answer\"\nend",
"def okay_two_sum?(arr, target)\n arr.each_with_index do |el,idx|\n if bi_search(arr[idx+1..-1], target, el)\n return true\n end\n end\n false\nend",
"def okay_two_sum?(arr, target)\n\n arr.each do |ele1| # O(n)\n # debugger\n found = arr.bsearch do |ele2|\n # debugger\n (target - ele1) == ele2\n end\n return true unless found.nil? || arr.index(found) == arr.index(ele1)\n end\n false\nend",
"def bad_two_sum?(arr, target)\n\n arr.each.with_index do |x, idx|\n arr.each.with_index do |y, idy|\n if idx == idy\n next\n else\n if (x + y) == target\n return true\n end\n end\n end\n end\n\n return false\n\nend",
"def okay_two_sum?(arr, target)\n arr = arr.sort #n log n\n (0...arr.length).each do |i| #n\n search = bsearch(arr, target-arr[i]) # log n\n return true unless search.nil?\n end #n log n\n false\nend",
"def ok_two_sum(arr, target)\n sorted = quick_sort(arr)\n\n arr.each do |el|\n b_target = target - el\n return true if b_search(arr, b_target)\n end\n false\nend",
"def okay_two_sum?(arr, target)\n sorted = quick_sort(arr)\n\n arr.each_with_index do |el, idx|\n p current = target - el\n bruh = bsearch(arr, current)\n next if bruh == idx\n return true unless bruh.nil?\n end\n\n return false\nend",
"def okay_two_sum?(arr, target)\n sorted_arr = arr.sort\n sorted_arr.each.with_index do |el, idx|\n target_pair = target - el\n if sorted_arr[idx+1..-1].bsearch{|n| n >= target_pair } == target_pair\n p target_pair\n return true\n end\n end\n false\nend",
"def bad_two_sum?(arr, target)\n arr.each_with_index do |num1, idx1| #O(n)\n arr.each_with_index do |num2, idx2| #O(n)\n return true if idx2 > idx1 && num1 + num2 == target #O(1)\n end\n end\n false\nend",
"def okay_two_sum?(arr, target)\n arr.sort!\n\n arr.select! { |el| el < target }\n\n arr.each { |el| arr.include?(target - el) ? (return true) : next }\n false\nend",
"def okay_two_sum?(arr,target)\n ans = arr.sort #O(nlogn)\n\n ans.each do |ele|\n temp = ans.shift\n dif = target-temp\n return true if bsearch(arr,dif) == true\n end\n false\nend",
"def twosum(array, target)\n return [] if array.length<=1\n cache = {}\n array.each.with_index do |e,i|\n if cache.include? (target-e)\n return [i,cache[target-e]]\n else\n cache[e] = i\n end\n end\n return []\nend",
"def hash_two_sum(arr, target)\n h = Hash.new { |h, k| h[k] = [] }\n arr.each_with_index do |num, i|\n return true unless h[target - num].empty?\n h[num] << i\n end\n\n false\nend",
"def two_sum_2(nums, target)\n sorted_nums = merge_sort(nums)\n i, j = 0, sorted_nums.length-1\n while i < j\n sum = sorted_nums[i] + sorted_nums[j]\n if sum == target\n index1 = nums.index(sorted_nums[i])\n index2 = nums.index(sorted_nums[j])\n puts \"index1=#{index1+1}, index2=#{index2+1}\"\n return\n elsif sum < target\n i += 1\n else\n j -= 1\n end\n end\nend",
"def okay_two_sum?(arr, target)\n sorted = arr.sort # n log n => quicksort => is nlogn DOMINANT\n sorted.each_with_index do |num, i| # => O(n)\n # return true if sorted[i] + sorted[-1 - i] == target\n return true if sorted[i + 1 .. - 1].bsearch {|number| target - num <=> number} # => O(log(n))\n # ASK TA ABOUT BSEARCH\n # bsearch {|ele| pivot <=> ele}\n end\n false\nend",
"def two_sum_3(nums, target)\n len = nums.length\n hash = {}\n\n for i in (0...len)\n elt = nums[i]\n diff = target - elt\n # check to see if diff is in the hash; if so we found 2 numbers that add up to sum, that is diff and elt\n if hash[diff]\n index1 = nums.index(diff)\n puts \"index1=#{index1+1}, index2=#{i+1}\"\n return\n else\n hash[elt] = 1 # add the key elt to the hash\n end\n end\nend",
"def bad_two_sum?(array, target)\n array.each.with_index do |el1, idx1|\n array.each.with_index do |el2, idx2|\n if el1 + el2 == target && idx2 > idx1\n return true \n end\n end\n end\n false \nend",
"def pair_sum?(arr, target)\n freq_table = Hash.new(0)\n arr.each do |num|\n return true if freq_table[target - num] > 0\n freq_table[num] += 1\n end\n false\nend",
"def two_sum(array, target_sum)\n\tarray.sort!\n\tlow_pointer = 0\n\thigh_pointer = array.length - 1\n\n\twhile low_pointer < high_pointer\n\t\tcurrent_sum = array[low_pointer] + array[high_pointer]\n\t\tif current_sum == target_sum\n\t\t\treturn [array[low_pointer], array[high_pointer]]\n\t\telsif current_sum < target_sum\n\t\t\tlow_pointer += 1\n\t\telsif current_sum > target_sum\n\t\t\thigh_pointer -= 1\n\t\tend\n\tend\n[]\nend",
"def best_two_sum?(arr, target)\n fastest = {}\n arr.each_with_index {|ele, i| fastest[ele] = i }\n arr.each_with_index do |ele, i|\n return true if fastest.has_key?(target - ele) && fastest[target - ele] != i\n end\n false\nend",
"def arr_sum(arr, target)\n 0.upto(arr.size - 2) do |idx1|\n 1.upto(arr.size - 1) do |idx2|\n return true if arr[idx1] + arr[idx2] == target && idx2 > idx1\n end\n end\n false\nend"
] |
[
"0.8142612",
"0.80411804",
"0.8015824",
"0.79371834",
"0.7869232",
"0.77379245",
"0.7722962",
"0.7717175",
"0.7687424",
"0.76793766",
"0.7673087",
"0.76660806",
"0.7646365",
"0.7631855",
"0.7626491",
"0.7626396",
"0.76148856",
"0.75894606",
"0.75551647",
"0.75548625",
"0.7549441",
"0.7544834",
"0.7533502",
"0.7525925",
"0.7482111",
"0.7470373",
"0.7410467",
"0.73970675",
"0.7374023",
"0.7354539",
"0.73466456",
"0.7337029",
"0.7324827",
"0.7321054",
"0.73183596",
"0.7307717",
"0.7295088",
"0.72918034",
"0.72829664",
"0.72659063",
"0.7263603",
"0.72336084",
"0.72268856",
"0.718016",
"0.71763575",
"0.71717185",
"0.7141572",
"0.7140291",
"0.7129839",
"0.7126906",
"0.7108158",
"0.70981014",
"0.7093486",
"0.7078689",
"0.7078621",
"0.7077106",
"0.7075629",
"0.7070483",
"0.7059064",
"0.70570886",
"0.7051099",
"0.7036237",
"0.70194733",
"0.69973147",
"0.69873923",
"0.6974226",
"0.697133",
"0.69653875",
"0.6959696",
"0.6953101",
"0.69474673",
"0.6940758",
"0.69352657",
"0.6914454",
"0.6913053",
"0.69076735",
"0.6877908",
"0.6876375",
"0.68730366",
"0.68717235",
"0.6859266",
"0.68590105",
"0.68517125",
"0.6849191",
"0.684765",
"0.68416345",
"0.683733",
"0.68281627",
"0.68253255",
"0.68252534",
"0.68199474",
"0.6819728",
"0.68172336",
"0.6813072",
"0.6812155",
"0.6804428",
"0.67971766",
"0.67959815",
"0.6784579",
"0.6773572"
] |
0.7394598
|
28
|
fetch currency rates from application configuration file config/currency_rate.yml will return currency rates along with it's type
|
def currency_rates
@currency_rates = fetch_currency_rates
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def currency_rates\n response['rates'][currency.target_currency.to_s]\n end",
"def available_currencies\n set_default_rate\n currency_rates.keys\n end",
"def update_rates\n clear_rates\n add_currency_rate(\"EUR\", 1)\n add_currency_rates(config[\"exchange_rates\"]) # rates from bank.yml\n \n fetch_rates.each do |currency_rate|\n add_currency_rate(currency_rate[:currency], currency_rate[:rate].to_f)\n end\n @@config['exchange_rates']\n end",
"def exchange_rates\n Currency::Exchange.exchange_rates\n end",
"def rates_for_usd\n rates_for 'USD'\n end",
"def rates\n base_currency_rates.map(&:conversion_rate)\n end",
"def fetch_currency_rate(currency_type)\n if currency_type == \"EUR\"\n product_price_details\n else\n fetch_updated_currency_rate(currency_type)\n end\n end",
"def fetch_rates\n rates = {}\n begin\n if @force_expire\n Timeout.timeout(60) do\n doc = Hpricot.XML(open('http://themoneyconverter.com/USD/rss.xml'))\n (doc/:item).each do |item|\n country = (item/:title).inner_html.split('/')[0]\n conversion_match = (item/:description).inner_html[/=.?(\\d+\\.?\\d*)/]\n # 1 USD country rate 'in USD'\n rates[country] = 1.0 / $1.to_f\n end\n rates.update({'USD' => 1.0})\n persist_rates(rates)\n end\n else\n rates = fetch_persisted_rates\n end\n rescue Exception\n rates = fetch_persisted_rates\n end\n rates\n end",
"def currencies\n reload_currencies_cache if !self.currencies_cache?\n c = YAML.load(self.currencies_cache)\n c ||= {}\n end",
"def currencies(force = false)\n exchange_rates.currencies(force)\n end",
"def fetch_updated_currency_rate(currency_type)\n currency_rate = nil\n ApplicationController.new.fetch_currency_rates.select{ |currency| currency_rate = currency if currency[:currency] == currency_type }\n if currency_rate.present?\n actual_price = price.to_f * currency_rate[:rate].to_f\n currency_details = {:currency => currency_type, :price => actual_price.round(2)}\n else\n currency_details = product_price_details\n end\n currency_details\n end",
"def find_rate()\n uri_string = \"https://free.currconv.com/api/v7/convert?q=GBP_\"\\\n \"#{@currency}&compact=ultra&apiKey=2d46a9b5b650dca0dbb1\"\n uri = URI(uri_string)\n res = Net::HTTP.get_response(uri)\n return(JSON.parse(res.body)[\"GBP_#{@currency}\"]/100.0)\n end",
"def currencies\n @currencies ||= definitions.keys.sort_by(&:to_s)\n end",
"def rates_for(currency_code)\n # Retrieve the actual rates from the external source\n rates = all_rates\n\n adjusted_currency = currency_code.to_s.upcase.to_sym \n unless rates.include?(adjusted_currency)\n raise Errors::CurrencyNotAvailable, \"#{adjusted_currency.to_s} was not available in this Source (#{self.to_s}), please use a different Source\"\n end\n\n adjusted_rates = {}\n\n # Add the currency we are converting to...\n adjusted_rates[adjusted_currency] = 1.0\n\n # Work out the exchange from our desired currency to our base currency. So if our base was EUR and we wanted USD this would \n # be how many Euros are in one US dollar.\n adjustment_factor = 1.0 / rates[adjusted_currency]\n adjusted_rates[base_currency] = adjustment_factor\n\n # Now remove it, since we've already done it.\n rates.delete(base_currency)\n\n # Now convert the rest\n rates.each do |currency, rate|\n adjusted_rates[currency] = rate * adjustment_factor\n end\n\n adjusted_rates\n end",
"def fetch_rate(code)\n currency_rates[code]\n end",
"def fetch_currency_rates\n begin\n application_currency_rates\n rescue Exception => e\n render :file => \"#{Rails.root}/public/404.html\", :status => :not_found\n end\n end",
"def fetch_rates\n if self.class.superclass.eql?(Object)\n raise Exception.new(\"This method should be invoked from CurrencySpy::Scraper sub class\")\n else\n check_currency_code_validity\n rate_results = {}\n RATE_DATA.each do |rate|\n symbol = rate.to_sym\n if self.class.instance_methods.include?(symbol)\n value = self.send(symbol)\n rate_results[symbol] = value unless value.nil?\n end\n end\n rate_results\n end\n end",
"def get_exchange_rates\r\n begin\r\n @logger.info(\"get_exchange_rates called.\")\r\n\r\n # prepare query url\r\n @logger.info(\"Preparing query URL for get_exchange_rates.\")\r\n _query_builder = Configuration.get_base_uri().clone\r\n _query_builder << '/exchangerates'\r\n _query_url = APIHelper.clean_url _query_builder\r\n\r\n # prepare and execute HttpRequest\r\n @logger.info('Preparing and executing HttpRequest for get_exchange_rates.')\r\n _request = @http_client.get _query_url\r\n BasicAuth.apply(_request)\r\n _context = execute_request(_request, name: 'get_exchange_rates')\r\n validate_response(_context)\r\n\r\n # return appropriate response type\r\n @logger.info(\"Returning response for get_catalog.\")\r\n decoded = APIHelper.json_deserialize(_context.response.raw_body)\r\n return decoded['exchangeRates'].map do |rate|\r\n ExchangeRateModel.from_hash(rate)\r\n end\r\n rescue Exception => e\r\n @logger.error(e)\r\n raise e\r\n end\r\n end",
"def currencies\n raise NotImplementedError\n end",
"def currencies\n @currencies || []\n end",
"def prices (currency='TWD')\n get '/prices/' + currency\n end",
"def load_currencies\n currencies = parse_currency_file(\"currency.json\")\n currencies.merge! parse_currency_file(\"currency_bc.json\")\n end",
"def update_rates\n currencies(true).each_pair do |currency, data|\n rate = data[:middle_rate_for_commercial_transactions]\n add_rate(\"EUR\", currency, rate) if known_currencies.include?(currency)\n end\n rates\n end",
"def load_shipping_rates\n YAML.load_file(\"#{root_path}/config/rates.yml\")\n end",
"def convert_at_rates(converter, currency)\n rates_conversion = []\n converter.rates.each_key do |key|\n rates_conversion << converter.convert(currency, key)\n end\n return rates_conversion\n end",
"def rates; end",
"def rates; end",
"def fetch_application_currency_types\n application_currency_types\n end",
"def get_rate(currency_iso_from, currency_iso_to); end",
"def exchange_rates\n doc = JSON.parse(read_from_cache || read_from_url)\n if doc['error'] && ERROR_MAP.key?(doc['message'].to_sym)\n raise ERROR_MAP[doc['message'].to_sym]\n end\n\n self.rates_timestamp = doc[TIMESTAMP_KEY]\n @oer_rates = doc[RATES_KEY]\n end",
"def all\n endpoint = 'Currencies'\n response = JSON.parse(@client.get(endpoint).body)\n currencies = response.key?('Items') ? response['Items'] : []\n currencies.map { |attributes| Unleashed::Currency.new(@client, attributes) }\n end",
"def retrieve_rate(currency_a, currency_b, date)\n redis = Redis.new\n key = \"usd_rates:#{date.to_s}\"\n halt(404, 'No rates for given date') unless redis.exists key\n \n rate_a = redis.hget(key, currency_a.downcase)\n rate_b = redis.hget(key, currency_b.downcase)\n\n rate_b.to_f / rate_a.to_f # TODO: precision\nend",
"def rates(coin='Bitcoin', currencies: %w(EUR GBP))\r\n \r\n jeg = JustExchangeRates.new(base: 'USD', app_id: @exchangerate_key, \r\n debug: @debug)\r\n usd = self.price(coin).round(2)\r\n ([:USD] + currencies.map(&:to_sym)).zip(\r\n [usd, *currencies.map {|currency| (usd * jeg.rate(currency)).round(2) }]\r\n ).to_h\r\n \r\n end",
"def get_rates(source)\n\t\t\trequire 'money/bank/open_exchange_rates_bank'\n\t\t\toxr = Money::Bank::OpenExchangeRatesBank.new\n\t\t\toxr.app_id = Rails.application.credentials.openexchangerates[:api_key]\n\t oxr.source = source\n\t oxr.update_rates\n\n\t oxr.cache = '/tmp/cache/exchange_rates.json'\n\t oxr.ttl_in_seconds = 86400\n\n\t return oxr.rates\n\t\tend",
"def conv_exchange_rate\n currency_exchange.exchange_rate\n end",
"def get_consumer_rate(options={})\n post 'rates', options.merge(rate_filter: 'consumer')\n end",
"def fetch_rates(source)\n klass_name = \"#{source}\".downcase.capitalize\n Object.const_get(\"Fxer::Exchange::DataSource::#{klass_name}\").new(@options).rate_set\n end",
"def currency_types\n collection(\"currency_types\")\n end",
"def raw_exchange_rates\n table_rows = Oga.parse_html(response.body).css('#ratesContainer li')\n # ADIB porvide 5 currencies on the home page (and 4 rows of info)\n fail ResponseError, 'Unknown HTML' unless table_rows&.size == 5\n currencies(table_rows).zip(rates(table_rows))\n end",
"def load_currencies\n @iso_definitions = symbolize_keys(\n YAML.load_file(File.join(ROOT_PATH, 'iso4217.yml'))\n )\n\n @historical_definitions = symbolize_keys(\n YAML.load_file(File.join(ROOT_PATH, 'iso4217-historical.yml'))\n )\n\n @unofficial_definitions = symbolize_keys(\n YAML.load_file(File.join(ROOT_PATH, 'unofficial.yml'))\n )\n\n historical_keys = @historical_definitions.keys\n\n historical_keys.each do |key|\n replacement_currency = @historical_definitions[key][:replaced_by]\n if replacement_currency\n unless currencies.include?(replacement_currency)\n raise Exchange::NoCurrencyError,\n \"#{replacement_currency} is not matchable to a currency\"\n end\n end\n end\n end",
"def exchange_rates\n @exchange_rates ||= Nordea::ExchangeRates.new\n end",
"def currency\n params['list_currency']\n end",
"def currency_rate(date, currency)\n return 1 if currency == @base_currency\n\n @exchange_rates[date.strftime(\"%Y-%m-%d\")][currency]\n end",
"def rates(options)\n self.class.bridge.hotel_details(hotel_chain, hotel_code, options).try(:hotel_rate_details) || []\n end",
"def preferred_currency\n Reji.configuration.currency\n end",
"def get_currencies\n response_xml = http_get(@client, \"#{xero_url}/Currencies\")\n parse_response(response_xml, {}, {:request_signature => 'GET/currencies'})\n end",
"def get_exchange_rates(options = {})\n body = {\n cmd: \"rates\"\n }\n body[:short] = 1 if options[:short]\n body[:accepted] = 1 if options[:accepted]\n response = post body, openstruct: false\n if options[:accepted_only]\n response.to_h.delete_if { |_k, v| v[:accepted] == 0 }\n else\n response.to_h\n end\n end",
"def get(code)\n if rates[code]\n rates[code]\n else\n # Can't find a rate by that code\n raise CashHandler::Exception.new(\"'#{code}' is not a supported currency code\")\n end\n end",
"def query_jurisdiction_rates(options={})\n path = \"/api/v2/compliance/jurisdictionrates\"\n get(path, options)\n end",
"def refresh_rates\n read_from_url\n end",
"def supported_currencies\n get 'simple/supported_vs_currencies'\n end",
"def exchange_rate\n http = Net::HTTP.new('themoneyconverter.com', 443)\n http.use_ssl = true\n\n url = \"/CurrencyConverter.aspx?from=#{from_currency.to_s.upcase}&to=#{to_currency.to_s.upcase}\"\n response = http.get(url)\n\n doc = Nokogiri::HTML(response.body)\n result = doc.css('div.cc-rate div#cc-ratebox').first.text\n\n regexp = Regexp.new('(\\\\d+(?:\\\\.\\\\d+)?)')\n regexp.match result\n\n return $1\n rescue Timeout::Error\n raise StandardError, 'Please check your internet connection'\n end",
"def index\n @currency_converters = CurrencyConverter.all\n @rates_dates = ExchangeRate.all.filter_by_date(Date.today)\n end",
"def fetch_rate(from, to, args = {})\n from = Money::Currency.wrap(from)\n to = Money::Currency.wrap(to)\n uri = build_uri(from, to, args)\n\n data = JSON.parse(uri.read)\n\n rate = data.fetch(\"rates\").fetch(to.iso_code)\n rate = 1 / extract_rate(build_uri(to, from).read) if rate < 0.1\n rate\n end",
"def rate_source\n @rate_source ||= DatabaseBank::RateSource::EuCentralBank\n end",
"def currencies_array\n CURRENCIES\n end",
"def active_currencies\n @active_currencies ||= active_definitions.keys.sort_by(&:to_s)\n end",
"def refresh_exchange_rates\n CurrencyConverter.cache_current_exchange_rates!\n end",
"def rates(dimension = nil)\n unless dimension.blank?\n send(\"#{dimension}_rates\")\n else\n rates_without_dimension\n end\n end",
"def currency_list\n %w(USD EUR GBP JPY AUD INR)\n end",
"def get_date_rate(date, currency)\n api_data = get_api_data(date)\n api_data[\"rates\"][currency]\n end",
"def get_all_available_currencies\n [@currency].concat @cross_rate.keys\n end",
"def get_rates(options={})\n post 'rates/full', options\n end",
"def index\n @currency_m_excng_rates = CurrencyMExcngRate.all\n end",
"def known_currencies\n @known_currencies = money_currencies & exchange_rates.currencies.keys\n end",
"def currencies(&blk)\n if block_given?\n websocket.subscribe :getcurrencies, &blk\n else\n http.get :getcurrencies\n end\n end",
"def rate\n if(specific_rate?)\n if(rate_cents < 0)\n task_list.default_rate.to_money\n else\n specific_rate.to_money\n end\n else\n Money.new(0, \"USD\")\n end\n end",
"def fetch_rate(from, to)\n xe_client.fetch_rate(from.iso_code, to.iso_code)\n rescue StandardError => e\n raise XeCurrencyFetchError, e.message\n end",
"def list\r\n\t\t@current_area = 'currencies'\r\n\t\t@current_menu = 'settings'\r\n\r\n\t\tsort_order ||= get_sort_order(\"s-abbr\", \"abbreviation\")\r\n\t\tsort_order ||= get_sort_order(\"s-name\", \"name\")\r\n\t\tsort_order ||= get_sort_order(\"s-symbol\", \"symbol\")\r\n\t\tsort_order ||= get_sort_order(\"s-rate\", \"exchange_rate\")\r\n\t\tsort_order ||= \"is_default DESC, name ASC\"\r\n\r\n\t\tif params[:new] and params[:new_currency]\r\n\t\t\tparams[:new_currency][:symbol] = params[:new_currency][:symbol_prefix] + Currency.symbols[params[:new_currency][:symbol]]\r\n\t\t\tparams[:new_currency].delete('symbol_prefix')\r\n\t\t\tc = Currency.create(params[:new_currency])\r\n\t\t\tc.update_exchange_rate\r\n\t\telsif params[:delete] and params[:select]\r\n\t\t\tc = params[:select].keys.collect { |k| \"id=#{k}\" }.join(' OR ')\r\n\t\t\tCurrency.delete_all(c)\r\n\t\telsif params[:default] and params[:select]\r\n\t\t\tc = params[:select].keys.first.to_i\r\n\t\t\tCurrency.update_all('is_default = 0', 'is_default <> 0')\r\n\t\t\tCurrency.update_all('is_default = 1', \"id = #{c}\")\r\n\t\tend\r\n\r\n\t\t@currencies = Currency.find(:all, :order => sort_order)\r\n\tend",
"def show\r\n @exchange_rates = get_latest\r\n end",
"def rate(from, to)\n exchange = []\n exchange << (Currency.find(from) or raise ArgumentError.new(\"Unknown +from+ currency #{from.inspect}.\"))\n exchange << (Currency.find(to) or raise ArgumentError.new(\"Unknown +to+ currency #{to.inspect}.\"))\n return BigDecimal.new(1.to_s) if exchange.uniq.size == 1 || exchange.find{|c| c == Currency::XXX}\n\n id = exchange.map{|c| c.code}.join(':')\n if cache && rate = cache[id]\n return rate\n end\n\n service = @@services.reverse.find do |service|\n !!exchange.reject{|c| service.currencies.include?(c)}\n end\n\n service or raise ConversionError # TODO: Message?\n rate = BigDecimal.new(service.read_rate(*exchange).to_s)\n\n cache[id] = rate if cache\n rate\n end",
"def extract_rates parsed\n to_hash! parsed['rates'].keys.map{|k| k.downcase.to_sym }.zip(parsed['rates'].values.map{|v| BigDecimal.new(v.to_s) }).flatten\n end",
"def index\n @channel_rates = ChannelRate.all\n end",
"def report_currency_exchange_rate\n # If exchange reate has been locked use that\n if self.exchange_rate.present?\n self.exchange_rate\n else\n Currency.get_exchange_for(self.project.account.account_setting.default_currency, self.currency)\n end\n end",
"def currencies\n return moneys.keys.sort\n end",
"def get_currencies_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: CurrenciesApi.get_currencies ...\"\n end\n # resource path\n local_var_path = \"/currencies\"\n\n # query parameters\n query_params = {}\n query_params[:'filter_default'] = opts[:'filter_default'] if !opts[:'filter_default'].nil?\n query_params[:'filter_enabled_currencies'] = opts[:'filter_enabled_currencies'] if !opts[:'filter_enabled_currencies'].nil?\n query_params[:'filter_type'] = opts[:'filter_type'] if !opts[:'filter_type'].nil?\n query_params[:'size'] = opts[:'size'] if !opts[:'size'].nil?\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n query_params[:'order'] = opts[:'order'] if !opts[:'order'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['oauth2_client_credentials_grant', 'oauth2_password_grant']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'PageResourceCurrencyResource')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: CurrenciesApi#get_currencies\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def rates **_opts\n raise NotImplementedError\n end",
"def saw\n @rates = Rate.all\n end",
"def get_openexchangerates(currency_code,base_code,key)\n # this is tested as working and so far is seen as the best in the lot \n # this one when free will only do lookups compared to USD, also limits to 1000 lookup per month so only 1 per hour\n # at $12/month Hourly Updates, 10,000 api request/month\n # at $47/month 30-minute Updates, 100,000 api request/month\n # at $97/month 10-minute Updates, unlimited api request/month + currency conversion requests\n # does lookup more than one currency at a time\n #https://openexchangerates.org/api/latest.json?app_id=xxxxxxx\n # see: https://openexchangerates.org/\n # example usage:\n # result = get_openexchangerates(\"THB\",\"JPY\", openexchangerates_key)\n # puts \"rate: \" + result[\"rate\"].to_s ; rate: 2.935490234019467\n #\n # inputs: \n # currency_code: the currency code to lookup example THB\n # base_code: the currency base to use in calculating exchange example USD or THB or BTC\n # key: the api authentication key obtained from https://openexchangerates.org\n #\n # return results:\n # rate: the calculated rate of exchange\n # timestamp: time the rate was taken in seconds_since_epoch_integer format (not sure how accurate as the time is the same for all asset currency)\n # datetime: time in standard human readable format example: 2016-09-15T08:00:14+07:00\n # base: the base code of the currency being calculated example USD\n # example if 1 USD is selling for 34.46 THB then rate will return 34.46 for base USD\n # example#2 if 1 USD is selling for 101.19 KES then rate will return 101.19 for base of USD\n # example#3 with the same values above 1 THB is selling for 2.901 KES so rate will return 2.901 for base of KES \n puts \"get_openexchangerates started\"\n url_start = \"https://openexchangerates.org/api/latest.json?app_id=\"\n url_end = \"\"\n send = url_start + key\n #puts \"sending: #{send}\"\n begin\n #postdata = RestClient.get send , { :Accept => '*/*', 'accept-encoding' => \"gzip, deflate\", :user_agent => \"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:47.0) Gecko/20100101 Firefox/47.0\"}\n postdata = RestClient.get send , { :Accept => '*/*', 'accept-encoding' => \"gzip, deflate\"}\n rescue => e\n puts \"fail in get_openexchangerate at RestClient.get error: #{e}\"\n data_out = {}\n data_out[\"service\"] = \"openexchangerates.org\"\n data_out[\"status\"] = \"fail\"\n return data_out\n end\n #puts \"postdata: \" + postdata\n data = JSON.parse(postdata)\n data_out = {}\n data_out[\"status\"] = \"pass\"\n if (base_code == \"USD\")\n #defaults to USD\n data_out[\"currency_code\"] = currency_code\n data_out[\"base\"] = base_code\n data_out[\"datetime\"] = Time.at(data[\"timestamp\"]).to_datetime.to_s\n #date[\"rate\"] = data[\"rates\"][currency_code]\n data_out[\"rate\"] = (data[\"rates\"][currency_code]).to_s\n data_out[\"ask\"] = data_out[\"rate\"]\n data_out[\"bid\"] = data_out[\"rate\"]\n data_out[\"service\"] = \"openexchangerates.org\"\n puts \"data_out: #{data_out}\"\n return data_out\n end\n puts \"here??\"\n usd_base_rate = data[\"rates\"][currency_code]\n base_rate = data[\"rates\"][base_code]\n rate = base_rate / usd_base_rate\n data_out[\"currency_code\"] = currency_code\n #data_out[\"rate\"] = rate.to_s\n #data_out[\"ask\"] = data_out[\"rate\"]\n #data_out[\"bid\"] = data_out[\"rate\"]\n data_out[\"rate\"] = (1.0 / rate.to_f)\n data_out[\"ask\"] = data_out[\"rate\"].to_f\n data_out[\"bid\"] = data_out[\"rate\"].to_f\n data_out[\"base\"] = base_code\n data_out[\"datetime\"] = Time.at(data[\"timestamp\"]).to_datetime.to_s\n data_out[\"service\"] = \"openexchangerates.org\"\n puts \"data_out: #{data_out}\"\n return data_out\nend",
"def get_openexchangerates(currency_code,base_code,key)\n # this is tested as working and so far is seen as the best in the lot \n # this one when free will only do lookups compared to USD, also limits to 1000 lookup per month so only 1 per hour\n # at $12/month Hourly Updates, 10,000 api request/month\n # at $47/month 30-minute Updates, 100,000 api request/month\n # at $97/month 10-minute Updates, unlimited api request/month + currency conversion requests\n # does lookup more than one currency at a time\n #https://openexchangerates.org/api/latest.json?app_id=xxxxxxx\n # see: https://openexchangerates.org/\n # example usage:\n # result = get_openexchangerates(\"THB\",\"JPY\", openexchangerates_key)\n # puts \"rate: \" + result[\"rate\"].to_s ; rate: 2.935490234019467\n #\n # inputs: \n # currency_code: the currency code to lookup example THB\n # base_code: the currency base to use in calculating exchange example USD or THB or BTC\n # key: the api authentication key obtained from https://openexchangerates.org\n #\n # return results:\n # rate: the calculated rate of exchange\n # timestamp: time the rate was taken in seconds_since_epoch_integer format (not sure how accurate as the time is the same for all asset currency)\n # datetime: time in standard human readable format example: 2016-09-15T08:00:14+07:00\n # base: the base code of the currency being calculated example USD\n # example if 1 USD is selling for 34.46 THB then rate will return 34.46 for base USD\n # example#2 if 1 USD is selling for 101.19 KES then rate will return 101.19 for base of USD\n # example#3 with the same values above 1 THB is selling for 2.901 KES so rate will return 2.901 for base of KES \n puts \"get_openexchangerates started\"\n url_start = \"https://openexchangerates.org/api/latest.json?app_id=\"\n url_end = \"\"\n send = url_start + key\n #puts \"sending: #{send}\"\n begin\n #postdata = RestClient.get send , { :Accept => '*/*', 'accept-encoding' => \"gzip, deflate\", :user_agent => \"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:47.0) Gecko/20100101 Firefox/47.0\"}\n postdata = RestClient.get send , { :Accept => '*/*', 'accept-encoding' => \"gzip, deflate\"}\n rescue => e\n puts \"fail in get_openexchangerate at RestClient.get error: #{e}\"\n data_out = {}\n data_out[\"service\"] = \"openexchangerates.org\"\n data_out[\"status\"] = \"fail\"\n return data_out\n end\n #puts \"postdata: \" + postdata\n data = JSON.parse(postdata)\n data_out = {}\n data_out[\"status\"] = \"pass\"\n if (base_code == \"USD\")\n #defaults to USD\n data_out[\"currency_code\"] = currency_code\n data_out[\"base\"] = base_code\n data_out[\"datetime\"] = Time.at(data[\"timestamp\"]).to_datetime.to_s\n #date[\"rate\"] = data[\"rates\"][currency_code]\n data_out[\"rate\"] = (data[\"rates\"][currency_code]).to_s\n data_out[\"ask\"] = data_out[\"rate\"]\n data_out[\"bid\"] = data_out[\"rate\"]\n data_out[\"service\"] = \"openexchangerates.org\"\n puts \"data_out: #{data_out}\"\n return data_out\n end\n puts \"here??\"\n usd_base_rate = data[\"rates\"][currency_code]\n base_rate = data[\"rates\"][base_code]\n rate = base_rate / usd_base_rate\n data_out[\"currency_code\"] = currency_code\n #data_out[\"rate\"] = rate.to_s\n #data_out[\"ask\"] = data_out[\"rate\"]\n #data_out[\"bid\"] = data_out[\"rate\"]\n data_out[\"rate\"] = (1.0 / rate.to_f)\n data_out[\"ask\"] = data_out[\"rate\"].to_f\n data_out[\"bid\"] = data_out[\"rate\"].to_f\n data_out[\"base\"] = base_code\n data_out[\"datetime\"] = Time.at(data[\"timestamp\"]).to_datetime.to_s\n data_out[\"service\"] = \"openexchangerates.org\"\n puts \"data_out: #{data_out}\"\n return data_out\nend",
"def fetch_rates(package)\n zone = self.calculable.zones.match(package.order.ship_address)\n return nil if zone.nil?\n\n rates = { :ground => nil, :standard => nil }\n\n package.contents.each do |line_item|\n ship_rate = Spree::VariantShippingRate.where(:zone => zone, :variant => line_item.variant).take\n unless ship_rate.nil?\n rates[:standard] = rates[:standard].to_f + (ship_rate.standard_rate * line_item.quantity) if ship_rate.standard_rate\n rates[:ground] = rates[:ground].to_f + (ship_rate.ground_rate * line_item.quantity) if ship_rate.ground_rate\n end\n end\n\n rates\n end",
"def rates **filters\n ExchangeRate.where(process_filters(filters)).map { |er| er.attributes.symbolize_keys }\n end",
"def rates\n @rates + [rate]\n end",
"def currency\n params[\"Currency\"]\n end",
"def collection_currency\n card_prices = []\n current_user.cards.each do |card|\n price = remove_dot(card.usd_price)\n card_prices << Money.new(price) * card.quantity \n end\n # call `format`\n card_prices.inject(:+) \n end",
"def get_Currency()\n \t return @outputs[\"Currency\"]\n \tend",
"def currency\n params['currency']\n end",
"def rates_per_day\n @rates_per_day ||= raw_fx_rates['Cube'][0]['Cube']\n end",
"def index\n @currencies = Currency.all\n end",
"def index\n @currencies = Currency.all\n end",
"def currency_filters\n\t\t\t[\n\t\t\t\t[I18n.t('filters.currency.any'), 'any'],\n\t\t\t\t[I18n.t('filters.currency.eur'), 'EUR'],\n\t\t\t\t[I18n.t('filters.currency.gbp'), 'GBP'],\n\t\t\t\t[I18n.t('filters.currency.sek'), 'SEK']\n\t\t\t]\n\t\tend",
"def conversion_rate(target_currency)\n if DaMoney::Money.conversion_rates.key? self.currency\n if DaMoney::Money.conversion_rates[self.currency].key? target_currency\n DaMoney::Money.conversion_rates[self.currency][target_currency].to_f\n else\n raise Exception.new(\"Conversion rate from '#{self.currency}' to '#{target_currency}'\" +\n \" if not configured!\")\n end\n else\n raise Exception.new(\"Curreny '#{self.currency}' is not configured!\")\n end\n end",
"def index\r\n @currencies = Currency.all\r\n end",
"def get_currencies_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: CurrenciesApi#get_currencies ...\"\n end\n \n # resource path\n path = \"/Currencies\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n _header_accept = ['application/json']\n _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result\n\n # HTTP header 'Content-Type'\n _header_content_type = []\n header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n\n auth_names = []\n data, status_code, headers = @api_client.call_api(:GET, path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Array<APICurrency>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: CurrenciesApi#get_currencies\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def read_benchmark_rates\n benchmark_rates = {}\n framework_rates = {}\n all.each do |row|\n code_and_standard = \"#{row['code'].remove('.')}#{'-' + row['standard'].to_s if row['standard']}\"\n benchmark_rates[code_and_standard] = row['benchmark'].to_f\n framework_rates[code_and_standard] = row['framework'].to_f\n end\n {\n benchmark_rates: benchmark_rates,\n framework_rates: framework_rates\n }\n end",
"def load_data(date)\n doc = Yajl::Parser.parse(open(rates_source(date)).read)\n\n base_currency = doc['base'] || 'USD'\n\n doc['rates'].each do |currency, rate|\n # Don't use set_rate here, since this method can only be called from\n # get_rate, which already aquired a mutex.\n internal_set_rate(date, base_currency, currency, rate)\n\n end\n\n rescue OpenURI::HTTPError => e\n puts \"couldn't get rate from #{rates_source}\"\n end",
"def get_user_rate(currency, current_user)\n user_currency = User.get_currency(current_user)\n\n return 1 if user_currency.iso_code == currency\n\n return CurrencyRate.get_rate(currency, user_currency.iso_code)\n end",
"def raw_exchange_rates\n # BanqueMisr provide 18 currencies (17 Used and CYPRUS POUND)\n # But they have 2 <tr> for headers\n table_rows = Oga.parse_html(response.body).css('.exchangeRates tbody tr')\n fail ResponseError, 'Unknown HTML' unless table_rows&.size == 20\n # remove the first 2 headers of the array and the last element\n # which is CYPRUS POUND which is not used anymore\n table_rows.lazy.drop(2).take(17).map(&:children).map do |cell|\n cell.map(&:text)\n end\n end",
"def get_data(currency_type)\n # Will be overriden on Currency subclasses\n end",
"def show\n @currencies = CryptocurrenciesService.new.get_top\n end"
] |
[
"0.76544577",
"0.7239134",
"0.72228706",
"0.7119703",
"0.70455575",
"0.70168304",
"0.69450223",
"0.6929443",
"0.6825915",
"0.67561793",
"0.66868603",
"0.6650373",
"0.6592395",
"0.65588903",
"0.6504443",
"0.64992106",
"0.6494795",
"0.64883167",
"0.64810306",
"0.64431286",
"0.64348423",
"0.6425767",
"0.6384027",
"0.63599175",
"0.635005",
"0.63447446",
"0.63447446",
"0.63413906",
"0.632072",
"0.6319588",
"0.6311544",
"0.63102114",
"0.6288696",
"0.6268161",
"0.62453216",
"0.6233003",
"0.6231217",
"0.62218785",
"0.6194804",
"0.6145598",
"0.61342376",
"0.6123298",
"0.6113718",
"0.6098028",
"0.60947627",
"0.6082573",
"0.60690886",
"0.60655177",
"0.6065119",
"0.60263944",
"0.60087806",
"0.59993637",
"0.5983384",
"0.59426594",
"0.5941276",
"0.5934501",
"0.5933236",
"0.5925424",
"0.5922239",
"0.59211123",
"0.58883387",
"0.5888022",
"0.58744335",
"0.58729243",
"0.58718956",
"0.58453757",
"0.58356935",
"0.58312774",
"0.5815193",
"0.5795032",
"0.5794099",
"0.57889265",
"0.57827276",
"0.57825243",
"0.5762494",
"0.5753051",
"0.57525784",
"0.57498807",
"0.57473236",
"0.57473236",
"0.5723907",
"0.57055795",
"0.5704497",
"0.5698275",
"0.5672311",
"0.56698805",
"0.5669332",
"0.5659938",
"0.5658515",
"0.5658515",
"0.565542",
"0.56533515",
"0.56472826",
"0.56399405",
"0.5638486",
"0.5623907",
"0.5610233",
"0.5600422",
"0.55874044",
"0.5586556"
] |
0.74599874
|
1
|
GET /trust_moneys GET /trust_moneys.json
|
def index
@trust_moneys = TrustMoney.all
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def get_trust_objects_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: NsxComponentAdministrationApi.get_trust_objects ...\"\n end\n # resource path\n local_var_path = \"/trust-management\"\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'TrustManagementData')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: NsxComponentAdministrationApi#get_trust_objects\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def truststore\n RubyAem::Resources::Truststore.new(@client)\n end",
"def certificates\n http_path = \"http://localhost:8081/auth/realms/master/protocol/openid-connect/certs\"\n url = URI(http_path)\n http = Net::HTTP.new(url.host, url.port)\n # request = Net::HTTP::Post.new(url.to_s)\n request = Net::HTTP::Get.new(url.to_s)\n #request[\"authorization\"] = 'bearer ' + token\n #request[\"content-type\"] = 'application/json'\n #body = {}\n\n #request.body = body.to_json\n response = http.request(request)\n puts \"RESPONSE\", response.read_body\n response_json = parse_json(response.read_body)[0]\nend",
"def network_connections_trust_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: DefaultApi.network_connections_trust ...'\n end\n # resource path\n local_var_path = '/api/v1/network/connections/trust'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json', 'application/xml', ])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'Array<String>' \n\n # auth_names\n auth_names = opts[:auth_names] || []\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DefaultApi#network_connections_trust\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def get_trust_objects(opts = {})\n data, _status_code, _headers = get_trust_objects_with_http_info(opts)\n data\n end",
"def get_trust_objects(opts = {})\n data, _status_code, _headers = get_trust_objects_with_http_info(opts)\n return data\n end",
"def cert_chain\n service = Service.find(params[:id])\n response = service.certificate.full_chain(true)\n render json: response\n end",
"def trusts_to(selected_trustee)\n self.trusts.where(:trustee_id => selected_trustee.id)\n end",
"def get_trust_objects_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ManagementPlaneApiNsxComponentAdministrationTrustManagementCrlApi.get_trust_objects ...'\n end\n # resource path\n local_var_path = '/trust-management'\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'TrustManagementData')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ManagementPlaneApiNsxComponentAdministrationTrustManagementCrlApi#get_trust_objects\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def physicians\n physicians = User.physicians\n render json: { status: 200, data: physicians }\n end",
"def have_secret\n tmurl = params[:trustme]\n tmheader = request.headers[\"HTTP_X_TRUSTME\"]\n secret = Rails.application.config.admin_secret\n logger.info \"checking tmurl #{tmurl}, tmheader #{tmheader}, secret #{secret}\"\n if !(tmurl == secret or tmheader == secret)\n head :unauthorized\n end\n end",
"def system_management_network_securities_get_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: ManagementNetworksSecurityApi.system_management_network_securities_get ...\"\n end\n # resource path\n local_var_path = \"/system/managementNetworkSecurities\"\n\n # query parameters\n query_params = {}\n query_params[:'conditions'] = opts[:'conditions'] if !opts[:'conditions'].nil?\n query_params[:'orderBy'] = opts[:'order_by'] if !opts[:'order_by'].nil?\n query_params[:'childconditions'] = opts[:'childconditions'] if !opts[:'childconditions'].nil?\n query_params[:'customfieldconditions'] = opts[:'customfieldconditions'] if !opts[:'customfieldconditions'].nil?\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n query_params[:'pageSize'] = opts[:'page_size'] if !opts[:'page_size'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Array<ManagementNetworkSecurity>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ManagementNetworksSecurityApi#system_management_network_securities_get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def request_trust(trust_url = \"http://#{request.host}/\", *args)\n trust_url = url_for(trust_url.merge(:only_path => false)) if trust_url.kind_of?(Hash)\n javascript_tag \"CCPEVE.requestTrust(#{trust_url.inspect});\", *args\n end",
"def render_trust_request(query_string)\n required_fields.map!{ |f| current_user.properties.openid[f] }\n optional_fields.map!{ |f| current_user.properties.openid[f] }\n @openid_map = current_user.properties.openid\n @properties = current_user.properties.delete_if{ |p| !(required_fields + optional_fields).include?(p.property_type.short_name)}\n @trust_root = openid_request.trust_root\n @identity_url = openid_request.identity_url\n @query_string = query_string\n return render(:action => 'trust_request', :layout => 'application')\n end",
"def get_kubernetes_trusted_registries_policy_by_moid_with_http_info(moid, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: KubernetesApi.get_kubernetes_trusted_registries_policy_by_moid ...'\n end\n # verify the required parameter 'moid' is set\n if @api_client.config.client_side_validation && moid.nil?\n fail ArgumentError, \"Missing the required parameter 'moid' when calling KubernetesApi.get_kubernetes_trusted_registries_policy_by_moid\"\n end\n # resource path\n local_var_path = '/api/v1/kubernetes/TrustedRegistriesPolicies/{Moid}'.sub('{' + 'Moid' + '}', CGI.escape(moid.to_s))\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/csv', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body]\n\n # return_type\n return_type = opts[:debug_return_type] || 'KubernetesTrustedRegistriesPolicy'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['cookieAuth', 'http_signature', 'oAuth2', 'oAuth2']\n\n new_options = opts.merge(\n :operation => :\"KubernetesApi.get_kubernetes_trusted_registries_policy_by_moid\",\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: KubernetesApi#get_kubernetes_trusted_registries_policy_by_moid\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def things\n begin\n things = PermissionsManager.get_cluster_things(current_user, things_params[:cluster_group_id])\n rescue\n render json: {}, status: 403\n return\n end\n render json: { 'things': things }, status: 200\n end",
"def work_profile_password_block_trust_agents\n return @work_profile_password_block_trust_agents\n end",
"def trust_emr(&block)\n trust_service('elasticmapreduce', 'trust-emr', &block)\n end",
"def suscriber_wm\n\t\turi = URI(\"http://staging.benchprep.com/api/v1/test/fixtures.json\")\t\n\n\t\tres = Net::HTTP.post_form(uri, 'email' => 'integration-tester+1@benchprep.com&enrollments_persona=subscriber&devices_persona=web_and_mobile')\n\t\t# write this output to a file\n\t\toutput = File.open( \"spec/fixtures/sp_wm_persona.json\",'w' ){|f| \n\t\t\tf.flock(File::LOCK_EX)\n\t\t\tf.write(res.body)\n\t\t}\n\n\t\t# Now parse this string as json\n\t\tjson = File.read('spec/fixtures/sp_wm_persona.json')\n\t\templs = JSON.parse(json)\n\n\t\treturn empls #pretty printed output\n\tend",
"def certs\n request :get, '/certs'\n end",
"def simulation_manager_records\n begin\n facade = InfrastructureFacadeFactory.get_facade_for(params[:infrastructure_name])\n hash = facade.sm_record_hashes(current_user.id, params[:experiment_id], (params[:infrastructure_params] or {}))\n render json: hash\n rescue NoSuchInfrastructureError => e\n Rails.logger.error \"Try to fetch SM nodes, but requested infrastructure does not exist: #{e.to_s}\"\n render json: []\n rescue => e\n Rails.logger.error \"Exception on fetching SM nodes (#{params.to_s}): #{e.to_s}\\n#{e.backtrace.join(\"\\n\")}\"\n render json: []\n end\n end",
"def index\n symptoms = Symptom.where(user_id: params[:user_id])\n\n if current_user.id == params[:user_id].to_i\n render json: SymptomSerializer.new(symptoms)\n else\n render json: { error: '401 Unauthorized' }, status: 401\n end\n\n\n end",
"def get_trusted_keys\n response = nexus.get(nexus_url(\"service/local/smartproxy/trusted-keys\"), :header => DEFAULT_ACCEPT_HEADER)\n case response.status\n when 200\n return response.content\n else\n raise UnexpectedStatusCodeException.new(response.status)\n end\n end",
"def PerformRestrictedGet(uri)\n RefreshTokenIfNeeded()\n req = Net::HTTP::Get.new(uri)\n req['Authorization'] = \"Bearer #{@access_token}\"\n\n res = Net::HTTP.start(uri.hostname, uri.port,\n :use_ssl => uri.scheme == 'https') do |http|\n http.request(req)\n end\n\n return JSON.parse(res.body)\n end",
"def get_network_sm_softwares(options = {})\r\n # Validate required parameters.\r\n validate_parameters(\r\n 'network_id' => options['network_id'],\r\n 'device_id' => options['device_id']\r\n )\r\n # Prepare query url.\r\n _path_url = '/networks/{networkId}/sm/{deviceId}/softwares'\r\n _path_url = APIHelper.append_url_with_template_parameters(\r\n _path_url,\r\n 'networkId' => options['network_id'],\r\n 'deviceId' => options['device_id']\r\n )\r\n _query_builder = Configuration.base_uri.dup\r\n _query_builder << _path_url\r\n _query_url = APIHelper.clean_url _query_builder\r\n # Prepare headers.\r\n _headers = {\r\n 'accept' => 'application/json'\r\n }\r\n # Prepare and execute HttpRequest.\r\n _request = @http_client.get(\r\n _query_url,\r\n headers: _headers\r\n )\r\n CustomHeaderAuth.apply(_request)\r\n _context = execute_request(_request)\r\n validate_response(_context)\r\n # Return appropriate response type.\r\n decoded = APIHelper.json_deserialize(_context.response.raw_body) unless\r\n _context.response.raw_body.nil? ||\r\n _context.response.raw_body.to_s.strip.empty?\r\n decoded\r\n end",
"def create_trust_xml(xml) \n if current_user \n empty = REXML::Element.new('empty') \n trust = xml.root.get_elements('Trust').first \n \n return render(:text => \"<Response>bad xml</Response>\") unless trust \n trust_root = (trust.get_elements('TrustRoot').first || empty).text \n expires = (trust.get_elements('Expires').first || empty).text \n profile_name = (trust.get_elements('AccessProfile').first || empty).text \n profile_name = 'public' unless profile_name \n @profile = current_user.profiles.find_by_title(profile_name) \n \n return render(:text => \"<Response>bad profile</Response>\") unless @profile \n \n if ['-1', '0'].include? expires \n expires_at = nil \n else \n expires =~ %r[(\\d+)/(\\d+)/(\\d+)] \n expires_at = Time.utc($3.to_i, $2.to_i, $1.to_i) \n end \n \n if @trust = Trust.find_by_trust_root(trust_root) \n @trust.update_attributes(:profile => @profile, :expires_at => expires_at) \n else \n @trust = Trust.create(:profile => @profile, :expires_at => expires_at, :trust_root => trust_root) \n end \n @trust.update_attributes(:expires_at => Time.now.utc) if expires == '0' \n return render(:text => '<Response>success</Response>') \n end \n render :text => '<Response>could not create trust</Response>' \n end",
"def password_block_trust_agents\n return @password_block_trust_agents\n end",
"def password_block_trust_agents\n return @password_block_trust_agents\n end",
"def enterprise_app_block_trust\n return @enterprise_app_block_trust\n end",
"def set_trust_money\n @trust_money = TrustMoney.find(params[:id])\n end",
"def index\n authorize! :view_pharmacy, @pharmacys\n @pharmacys = Pharmacy.all\n end",
"def get_network_sm_user_softwares(options = {})\r\n # Validate required parameters.\r\n validate_parameters(\r\n 'network_id' => options['network_id'],\r\n 'user_id' => options['user_id']\r\n )\r\n # Prepare query url.\r\n _path_url = '/networks/{networkId}/sm/user/{userId}/softwares'\r\n _path_url = APIHelper.append_url_with_template_parameters(\r\n _path_url,\r\n 'networkId' => options['network_id'],\r\n 'userId' => options['user_id']\r\n )\r\n _query_builder = Configuration.base_uri.dup\r\n _query_builder << _path_url\r\n _query_url = APIHelper.clean_url _query_builder\r\n # Prepare headers.\r\n _headers = {\r\n 'accept' => 'application/json'\r\n }\r\n # Prepare and execute HttpRequest.\r\n _request = @http_client.get(\r\n _query_url,\r\n headers: _headers\r\n )\r\n CustomHeaderAuth.apply(_request)\r\n _context = execute_request(_request)\r\n validate_response(_context)\r\n # Return appropriate response type.\r\n decoded = APIHelper.json_deserialize(_context.response.raw_body) unless\r\n _context.response.raw_body.nil? ||\r\n _context.response.raw_body.to_s.strip.empty?\r\n decoded\r\n end",
"def show\n respond_to do |format|\n format.json {\n render json: @person, :include => [:roles => { include: [:privileges] } ]\n }\n end\n end",
"def postEntityUser_trust( entity_id, user_id, trust)\n params = Hash.new\n params['entity_id'] = entity_id\n params['user_id'] = user_id\n params['trust'] = trust\n return doCurl(\"post\",\"/entity/user_trust\",params)\n end",
"def index\n @priv_policies = PrivPolicy.all\n end",
"def show\n authenticate_user!\n authorize! :index, @user, :message => 'Not authorized as an administrator.'\n \n @key_policy_maker = KeyPolicyMaker.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @key_policy_maker }\n end\n end",
"def index\n @trust_transactions = TrustTransaction.all\n end",
"def index\n @people = Person.all\n respond_to do |format|\n format.json { \n render json: @people, :include => [:roles => { include: [:privileges] } ]\n }\n end\n end",
"def get_loyalty_programs_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ManagementApi.get_loyalty_programs ...'\n end\n # resource path\n local_var_path = '/v1/loyalty_programs'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'InlineResponse20011' \n\n # auth_names\n auth_names = opts[:auth_names] || ['management_key', 'manager_auth']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ManagementApi#get_loyalty_programs\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def show\n @moresmalltrial = Moresmalltrial.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @moresmalltrial }\n end\n end",
"def signed_get_request url\n token=jwt_get_signature url\n HTTParty.get('http://localhost:5000'+url,\n headers:{\n \"Authorization\"=>\"JWT token=\\\"#{token}\\\"\",\n \"Content-Type\"=> \"application/json;charset=utf-8\"\n }\n )\n end",
"def index\n\t\tauthorize! :read, Skill\n\t\t\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @skills }\n end\n end",
"def getTrustedParams(user, retcode=nil)\n token = getTrustedToken(user)\n return unless token\n token = %{<wst:RequestSecurityTokenResponse xmlns:wst=\"http://schemas.xmlsoap.org/ws/2005/02/trust\"><wst:RequestedSecurityToken><wsse:BinarySecurityToken xmlns:wsse=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\">#{token}</wsse:BinarySecurityToken></wst:RequestedSecurityToken><wsp:AppliesTo xmlns:wsp=\"http://schemas.xmlsoap.org/ws/2004/09/policy\"><wsa:EndpointReference xmlns:wsa=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\"><wsa:Address>uri:WindowsLiveID</wsa:Address></wsa:EndpointReference></wsp:AppliesTo></wst:RequestSecurityTokenResponse>}\n params = {}\n params['wa'] = securityalgorithm\n params['wresult'] = token\n params['wctx'] = retcode if retcode\n params\n end",
"def get_trusted_keys\n return [] unless File.file?(@trust_path)\n\n # no signature verification\n File.open(@trust_path, 'r').readlines.map(&:chomp).uniq.sort\nend",
"def mine(**params)\n path = File.join(plural_resource_path, \"mine\").to_s\n api_request(:get, path, params: params)\n end",
"def index\n users = policy_scope(User)\n render json: { users: users }\n end",
"def show\n @store_policies_information = Store::Policies::Information.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @store_policies_information }\n end\n end",
"def index\n @mx_assessments = MxAssessment.all\n authorize MxAssessment \n end",
"def system_management_network_securities_id_get_with_http_info(id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: ManagementNetworksSecurityApi.system_management_network_securities_id_get ...\"\n end\n # verify the required parameter 'id' is set\n if @api_client.config.client_side_validation && id.nil?\n fail ArgumentError, \"Missing the required parameter 'id' when calling ManagementNetworksSecurityApi.system_management_network_securities_id_get\"\n end\n # resource path\n local_var_path = \"/system/managementNetworkSecurities/{id}\".sub('{' + 'id' + '}', id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'ManagementNetworkSecurity')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ManagementNetworksSecurityApi#system_management_network_securities_id_get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def index\n if params\n @trustees = Trustee.search(params).page(params[:page])\n else\n @trustees = Trustee.all.page(params[:page])\n end\n end",
"def identities\n render json: current_user.identities\n end",
"def get_locks\n HTTParty.get(\"#{$base_url}/partners/#{$partner_id}/locks\", {headers: $headers}).parsed_response['locks']\nend",
"def get_server_properties\n http_get(:uri=>\"/server/properties\", :fields=>x_cookie)\n end",
"def trustee_params\n params.require(:trustee).permit(:access_id, :full_name, :trustee_type, :dates_of_service, :university_status, :first_year)\n end",
"def test_get_skills_route\n render :json => get_profile_skills_for_profile(\"https://www.linkedin.com/in/marissamayer\").to_json\n end",
"def index\n permits = Permit.select('id, permit_type, applicant_name, start_date, end_date, address, application_data, city_name, ST_AsGeoJSON(geometry) AS geojson')\n .where(\"city_name = ? AND geometry IS NOT NULL AND address IS NOT NULL\", params[:city].upcase.gsub(/-/, \" \"))\n if permits\n respond_to do |format|\n format.json { render json: permits }\n end\n else\n respond_to do |format|\n format.json { render json: [], status: :bad_request }\n end\n end\n end",
"def index\n @stresses = current_user.stresses.find(:all)\n @stress = current_user.stresses.build()\n\n respond_to do |format|\n format.html # index.html.erb\n end\n end",
"def index\n @identities = Identity.all\n\n render json: @identities\n end",
"def accept_token_wompi\n require 'uri'\n\t require 'net/http'\n \n url = URI(BASE_URL_WOMPI+'merchants/'+PUBLIC_KEY_WOMPI)\n\n\t http = Net::HTTP.new(url.host, url.port)\n\t http.use_ssl = true\n\t http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n\t request = Net::HTTP::Get.new(url)\n\n response = http.request(request)\n\n token = JSON.parse(response.read_body)\n token[\"data\"][\"presigned_acceptance\"][\"acceptance_token\"]\n end",
"def licenses\n publisher_id = current_user.id\n @licenses = PowerChip.where(:publisher_id=>publisher_id)\n respond_to do |format|\n format.html # licenses.html.erb\n format.json { render json: @licenses }\n end\n end",
"def set_trustee\n @trustee = Trustee.find(params[:id])\n end",
"def is_create_trust? \n request.env['RAW_POST_DATA'] =~ %r[<CreateTrust>] \n end",
"def show\n @systemadmin = Systemadmin.find(params[:id])\n @pSAdmins = Host.find_all_by_primary_sadmin_id(params[:id])\n @secSAdmins = Host.find_all_by_secondary_sadmin_id(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @systemadmin }\n end\n end",
"def get_softwarerepository_authorization_by_moid_with_http_info(moid, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: SoftwarerepositoryApi.get_softwarerepository_authorization_by_moid ...'\n end\n # verify the required parameter 'moid' is set\n if @api_client.config.client_side_validation && moid.nil?\n fail ArgumentError, \"Missing the required parameter 'moid' when calling SoftwarerepositoryApi.get_softwarerepository_authorization_by_moid\"\n end\n # resource path\n local_var_path = '/api/v1/softwarerepository/Authorizations/{Moid}'.sub('{' + 'Moid' + '}', CGI.escape(moid.to_s))\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/csv', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body]\n\n # return_type\n return_type = opts[:debug_return_type] || 'SoftwarerepositoryAuthorization'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['cookieAuth', 'http_signature', 'oAuth2', 'oAuth2']\n\n new_options = opts.merge(\n :operation => :\"SoftwarerepositoryApi.get_softwarerepository_authorization_by_moid\",\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: SoftwarerepositoryApi#get_softwarerepository_authorization_by_moid\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def show\n @store_manager_policy = Store::Manager::Policy.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @store_manager_policy }\n end\n end",
"def index\n @users = User.all\n binding.pry\n require 'net/http'\n result = Net::HTTP.get('makesys.net', '/')\n p result\n end",
"def index\n @physicians = Physician.all\n render json: @physicians, :include => [:patients => {:include => [:surveys]}]\n end",
"def installandlaunch(token, rid, filename , grant_all_permissions )\nuri = URI.parse(\"https://device.pcloudy.com/api/install_app\")\n@toSend = {\n \"token\"=>token, \"rid\"=>rid, \"filename\"=>filename, \"grant_all_permissions\"=>grant_all_permissions\n}.to_json\n\nhttps = Net::HTTP.new(uri.host,uri.port)\nhttps.use_ssl = true\nreq = Net::HTTP::Post.new(uri.path, initheader = {'Content-Type' =>'application/json'})\nreq.body = \"#{@toSend}\"\nres = https.request(req)\nputs \"Response #{res.code} #{res.message}: #{res.body}\"\ninstallresp = JSON.parse(res.body)\noutput = installresp[\"result\"][\"msg\"]\nputs output\nend",
"def mv_request(user, lp)\n\turl = lp + \"/mvs/\"\n\n\tidentifying_factors = {}\n\tauthenticating_factors = {}\n\n authenticating_factors = Hash.new.tap do |h|\n h['password'] = user['password'] if user['password']\n end\n\n identifying_factors = Hash.new.tap do |h|\n h[\"firstName\"] = user[\"firstName\"] if user[\"firstName\"]\n h[\"lastName\"] = user[\"lastName\"] if user[\"lastName\"]\n h[\"email\"] = user[\"email\"] if user[\"email\"]\n h[\"memberId\"] = user[\"memberId\"] if user[\"memberId\"]\n end\n\n\tbody = {\"identifyingFactors\" => identifying_factors}.to_json\n\n\trequest = {\"url\" => url, \"body\" => body}\n\n\treturn request\nend",
"def web_servers; machines_by_role('web'); end",
"def show\n @workskedpolicy = Workskedpolicy.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @workskedpolicy }\n end\n end",
"def index\n if current_user\n @certs = Cert.where(user_id: current_user.id)\n @smime_num = Cert.where(user_id: current_user.id, purpose_type: 7, state: Cert::State::NEW_GOT_SERIAL).count() # FIXME: rewrite to cover multiple states\n end\n end",
"def verify\n user_id = request.headers['HTTP_X_TRP_USER']\n custom_db = request.headers['X-CUSTOM-DB']\n puts \"USER ID: #{user_id}\"\n\n if custom_db\n url = URI.parse(\"http://localhost:3000/users/#{user_id}.json\")\n req = Net::HTTP::Get.new(url.path)\n res = Net::HTTP.start(url.host, url.port) {|http|\n http.request(req)\n }\n @output = JSON(res.body)\n puts @output\n @database = \"\"\n end\n end",
"def list_users_for_all_tenants(args = {}) \n get(\"/users.json/global\", args)\nend",
"def list_users_for_all_tenants(args = {}) \n get(\"/users.json/global\", args)\nend",
"def requestTrust(url=nil)\n url ||= \"#{@request.protocol}#{@request.env[\"HTTP_HOST\"]}\"\n if_active(\"requestTrust\", url)\n end",
"def index\n @demands = Demand.all\n authorize @demands\n end",
"def update!(**args)\n @trust_settings_for_client = args[:trust_settings_for_client] if args.key?(:trust_settings_for_client)\n end",
"def get_merchants\n uri = build_uri_for(@provider)\n p uri\n http = initialize_http(uri)\n\n request = Net::HTTP::Get.new(uri.request_uri)\n JSON( http.request(request).body )\n end",
"def network_connections_trust(opts = {})\n data, _status_code, _headers = network_connections_trust_with_http_info(opts)\n data\n end",
"def set_trust_transaction\n @trust_transaction = TrustTransaction.find(params[:id])\n end",
"def getToolsSyndicateYalwa( entity_id)\n params = Hash.new\n params['entity_id'] = entity_id\n return doCurl(\"get\",\"/tools/syndicate/yalwa\",params)\n end",
"def getmininginfo\n @api.request 'getmininginfo'\n end",
"def index\n getProfile\n @consents = TherapistConsent.where('therapist_id = ? ', @therapist.id)\n respond_to do |format|\n format.html { render action: 'index' }\n format.json { render :status => 200, :json => { action: 'index', consents: @consents }}\n end\n end",
"def index\n @admin_skills = Admin::Skill.all\n\n render json: @admin_skills\n end",
"def index\n @tenants = keystone.tenants\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @tenants }\n end\n end",
"def show\n @stress = current_user.stresses.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n end\n end",
"def index\n @users = User.all\n authorize @users\n\n render json: @users\n end",
"def resource\n set_cors_headers\n render :text => \"OK here is your restricted resource!\"\n end",
"def index\n shoutouts = Shoutout.where(user_ids: params[:id])\n shoutouts = policy_scope(shoutouts)\n render json: shoutouts\n end",
"def system_management_network_securities_post_with_http_info(management_network_security, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: ManagementNetworksSecurityApi.system_management_network_securities_post ...\"\n end\n # verify the required parameter 'management_network_security' is set\n if @api_client.config.client_side_validation && management_network_security.nil?\n fail ArgumentError, \"Missing the required parameter 'management_network_security' when calling ManagementNetworksSecurityApi.system_management_network_securities_post\"\n end\n # resource path\n local_var_path = \"/system/managementNetworkSecurities\"\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(management_network_security)\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'ManagementNetworkSecurity')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ManagementNetworksSecurityApi#system_management_network_securities_post\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def get_working_missions\n \t#get all missions of user with invitaion_status = pending and mission status = true\n user = User.exists?(params[:user_id])\n\tif user\n\t\tmissions = user.missions.references(:user_missions).select('missions.id, missions.title').where( user_missions:{ invitation_status: ACCEPTED_MESA_INVITATION}, missions: {is_authorized: true})\n\t\trespond_to do |format|\n\t\t format.json {render :json=> {:working_mesa=> missions, :status => true} }\n\t\tend\n else\n\t respond_to do |format|\n\t\t format.json {render :json=> {:error=>'No user exists with id' , :status => false} }\n\t end\n\tend\n end",
"def index\n hardware = Hardware.all\n render json: hardware.to_json(:except => [:id])\n end",
"def servers\n endpoint = 'https://pcs.baidu.com/rest/2.0/pcs/manage?method=listhost'\n @res = @api.request_json( endpoint )\n end",
"def get_own_system_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: SystemsApi.get_own_system ...'\n end\n # resource path\n local_var_path = '/s'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body]\n\n # return_type\n return_type = opts[:debug_return_type] || 'System'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['TokenAuth']\n\n new_options = opts.merge(\n :operation => :\"SystemsApi.get_own_system\",\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: SystemsApi#get_own_system\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def get_symptoms\n begin\n @desease = Desease.find(params[:id])\n\n @symptoms = @desease.symptoms\n render json: @symptoms\n rescue ActiveRecord::RecordNotFound => e\n render json: e, status: :unprocessable_entity\n end\n \n \n end",
"def index\n render json: { users: User.pluck(:email, :admin), password: 'PassworD@55' }\n end",
"def security_server_client\n end",
"def get (dir) #DIR is path to RES\r\n\tbegin\r\n\t\taddress=$server+dir\r\n\t\turi = URI.parse(address)\r\n\t\tdebugging \"Get URI: #{uri}\"\r\n\t\trequest = Net::HTTP.get_response(uri)\r\n\t\tdebugging \"Response #{request}\"\t\r\n\t\tbody=request.body\r\n\t\tdebugging \"Body: #{body}\"\t\r\n\t\tbody=JSON.parse (body)\r\n\t\tcode=request.code\r\n\t\tdebugging \"Response Code: #{code}\"\r\n\t\tresponse={'body'=>body,'code'=>code,'exception'=>false}\r\n\t\tdebugging \"Response content: #{response}\"\r\n\t\treturn response\r\n\trescue Exception =>msg\r\n\t\tresponse={'body'=>msg,'code'=>401, 'exception' =>true}\r\n\t\tdebugging \"Response content: #{response}\"\r\n\t\treturn response\r\n\tend\r\n\r\nend",
"def show\n id = params[:id]\n @physician = Physician.find(id)\n render json: @physician, :include => [:patients => {:include => [:surveys]}]\n end"
] |
[
"0.5751301",
"0.5500747",
"0.53771687",
"0.5355662",
"0.53144306",
"0.5300288",
"0.52667034",
"0.52211887",
"0.5193867",
"0.51418126",
"0.5121417",
"0.5094779",
"0.50687957",
"0.5034705",
"0.50021213",
"0.4988404",
"0.49769038",
"0.49628618",
"0.49396548",
"0.4939509",
"0.4872386",
"0.48632407",
"0.48608762",
"0.48568827",
"0.4836417",
"0.48232478",
"0.48183918",
"0.48183918",
"0.48049432",
"0.4804398",
"0.4803064",
"0.48027197",
"0.4788765",
"0.4784243",
"0.47787607",
"0.47692028",
"0.47532156",
"0.47440702",
"0.47344625",
"0.47268882",
"0.47090784",
"0.47087902",
"0.47073483",
"0.47032362",
"0.4701143",
"0.4688627",
"0.46766853",
"0.46708655",
"0.46691704",
"0.46688506",
"0.46655124",
"0.46550798",
"0.4653305",
"0.46497867",
"0.4647187",
"0.46406773",
"0.46358958",
"0.46342814",
"0.46201408",
"0.46175504",
"0.46104944",
"0.46076393",
"0.46061426",
"0.46053487",
"0.46005744",
"0.46001905",
"0.45965752",
"0.4593615",
"0.45915478",
"0.45896795",
"0.45886686",
"0.4575986",
"0.45736295",
"0.45720068",
"0.45720068",
"0.4561164",
"0.45526618",
"0.4543985",
"0.45357293",
"0.45333672",
"0.45303917",
"0.45221284",
"0.4513406",
"0.45115605",
"0.45108986",
"0.45041096",
"0.4502872",
"0.4492391",
"0.44811684",
"0.44759923",
"0.4472675",
"0.44707045",
"0.4469292",
"0.44685918",
"0.44667196",
"0.44613343",
"0.44583103",
"0.44575685",
"0.4452175",
"0.4446095"
] |
0.59640765
|
0
|
GET /trust_moneys/1 GET /trust_moneys/1.json
|
def show
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n @trust_moneys = TrustMoney.all\n end",
"def get_trust_objects_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: NsxComponentAdministrationApi.get_trust_objects ...\"\n end\n # resource path\n local_var_path = \"/trust-management\"\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'TrustManagementData')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: NsxComponentAdministrationApi#get_trust_objects\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def truststore\n RubyAem::Resources::Truststore.new(@client)\n end",
"def certificates\n http_path = \"http://localhost:8081/auth/realms/master/protocol/openid-connect/certs\"\n url = URI(http_path)\n http = Net::HTTP.new(url.host, url.port)\n # request = Net::HTTP::Post.new(url.to_s)\n request = Net::HTTP::Get.new(url.to_s)\n #request[\"authorization\"] = 'bearer ' + token\n #request[\"content-type\"] = 'application/json'\n #body = {}\n\n #request.body = body.to_json\n response = http.request(request)\n puts \"RESPONSE\", response.read_body\n response_json = parse_json(response.read_body)[0]\nend",
"def cert_chain\n service = Service.find(params[:id])\n response = service.certificate.full_chain(true)\n render json: response\n end",
"def network_connections_trust_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: DefaultApi.network_connections_trust ...'\n end\n # resource path\n local_var_path = '/api/v1/network/connections/trust'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json', 'application/xml', ])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'Array<String>' \n\n # auth_names\n auth_names = opts[:auth_names] || []\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DefaultApi#network_connections_trust\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def get_trust_objects_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ManagementPlaneApiNsxComponentAdministrationTrustManagementCrlApi.get_trust_objects ...'\n end\n # resource path\n local_var_path = '/trust-management'\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'TrustManagementData')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ManagementPlaneApiNsxComponentAdministrationTrustManagementCrlApi#get_trust_objects\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def show\n @moresmalltrial = Moresmalltrial.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @moresmalltrial }\n end\n end",
"def get_kubernetes_trusted_registries_policy_by_moid_with_http_info(moid, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: KubernetesApi.get_kubernetes_trusted_registries_policy_by_moid ...'\n end\n # verify the required parameter 'moid' is set\n if @api_client.config.client_side_validation && moid.nil?\n fail ArgumentError, \"Missing the required parameter 'moid' when calling KubernetesApi.get_kubernetes_trusted_registries_policy_by_moid\"\n end\n # resource path\n local_var_path = '/api/v1/kubernetes/TrustedRegistriesPolicies/{Moid}'.sub('{' + 'Moid' + '}', CGI.escape(moid.to_s))\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/csv', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body]\n\n # return_type\n return_type = opts[:debug_return_type] || 'KubernetesTrustedRegistriesPolicy'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['cookieAuth', 'http_signature', 'oAuth2', 'oAuth2']\n\n new_options = opts.merge(\n :operation => :\"KubernetesApi.get_kubernetes_trusted_registries_policy_by_moid\",\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: KubernetesApi#get_kubernetes_trusted_registries_policy_by_moid\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def physicians\n physicians = User.physicians\n render json: { status: 200, data: physicians }\n end",
"def suscriber_wm\n\t\turi = URI(\"http://staging.benchprep.com/api/v1/test/fixtures.json\")\t\n\n\t\tres = Net::HTTP.post_form(uri, 'email' => 'integration-tester+1@benchprep.com&enrollments_persona=subscriber&devices_persona=web_and_mobile')\n\t\t# write this output to a file\n\t\toutput = File.open( \"spec/fixtures/sp_wm_persona.json\",'w' ){|f| \n\t\t\tf.flock(File::LOCK_EX)\n\t\t\tf.write(res.body)\n\t\t}\n\n\t\t# Now parse this string as json\n\t\tjson = File.read('spec/fixtures/sp_wm_persona.json')\n\t\templs = JSON.parse(json)\n\n\t\treturn empls #pretty printed output\n\tend",
"def simulation_manager_records\n begin\n facade = InfrastructureFacadeFactory.get_facade_for(params[:infrastructure_name])\n hash = facade.sm_record_hashes(current_user.id, params[:experiment_id], (params[:infrastructure_params] or {}))\n render json: hash\n rescue NoSuchInfrastructureError => e\n Rails.logger.error \"Try to fetch SM nodes, but requested infrastructure does not exist: #{e.to_s}\"\n render json: []\n rescue => e\n Rails.logger.error \"Exception on fetching SM nodes (#{params.to_s}): #{e.to_s}\\n#{e.backtrace.join(\"\\n\")}\"\n render json: []\n end\n end",
"def trusts_to(selected_trustee)\n self.trusts.where(:trustee_id => selected_trustee.id)\n end",
"def set_trust_money\n @trust_money = TrustMoney.find(params[:id])\n end",
"def get_trust_objects(opts = {})\n data, _status_code, _headers = get_trust_objects_with_http_info(opts)\n data\n end",
"def get_trust_objects(opts = {})\n data, _status_code, _headers = get_trust_objects_with_http_info(opts)\n return data\n end",
"def mine(**params)\n path = File.join(plural_resource_path, \"mine\").to_s\n api_request(:get, path, params: params)\n end",
"def index\n symptoms = Symptom.where(user_id: params[:user_id])\n\n if current_user.id == params[:user_id].to_i\n render json: SymptomSerializer.new(symptoms)\n else\n render json: { error: '401 Unauthorized' }, status: 401\n end\n\n\n end",
"def system_management_network_securities_get_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: ManagementNetworksSecurityApi.system_management_network_securities_get ...\"\n end\n # resource path\n local_var_path = \"/system/managementNetworkSecurities\"\n\n # query parameters\n query_params = {}\n query_params[:'conditions'] = opts[:'conditions'] if !opts[:'conditions'].nil?\n query_params[:'orderBy'] = opts[:'order_by'] if !opts[:'order_by'].nil?\n query_params[:'childconditions'] = opts[:'childconditions'] if !opts[:'childconditions'].nil?\n query_params[:'customfieldconditions'] = opts[:'customfieldconditions'] if !opts[:'customfieldconditions'].nil?\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n query_params[:'pageSize'] = opts[:'page_size'] if !opts[:'page_size'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Array<ManagementNetworkSecurity>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ManagementNetworksSecurityApi#system_management_network_securities_get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def render_trust_request(query_string)\n required_fields.map!{ |f| current_user.properties.openid[f] }\n optional_fields.map!{ |f| current_user.properties.openid[f] }\n @openid_map = current_user.properties.openid\n @properties = current_user.properties.delete_if{ |p| !(required_fields + optional_fields).include?(p.property_type.short_name)}\n @trust_root = openid_request.trust_root\n @identity_url = openid_request.identity_url\n @query_string = query_string\n return render(:action => 'trust_request', :layout => 'application')\n end",
"def show\n authenticate_user!\n authorize! :index, @user, :message => 'Not authorized as an administrator.'\n \n @key_policy_maker = KeyPolicyMaker.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @key_policy_maker }\n end\n end",
"def show\n @store_manager_policy = Store::Manager::Policy.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @store_manager_policy }\n end\n end",
"def show\n @store_policies_information = Store::Policies::Information.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @store_policies_information }\n end\n end",
"def index\n @identities = Identity.all\n\n render json: @identities\n end",
"def index\n @trust_transactions = TrustTransaction.all\n end",
"def get_loyalty_programs_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ManagementApi.get_loyalty_programs ...'\n end\n # resource path\n local_var_path = '/v1/loyalty_programs'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'InlineResponse20011' \n\n # auth_names\n auth_names = opts[:auth_names] || ['management_key', 'manager_auth']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ManagementApi#get_loyalty_programs\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def show\n @workskedpolicy = Workskedpolicy.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @workskedpolicy }\n end\n end",
"def show\n respond_to do |format|\n format.json {\n render json: @person, :include => [:roles => { include: [:privileges] } ]\n }\n end\n end",
"def get\n\t\t\t result = Status.find_by(windmillid: params[:windmillid]) \n \t\t\trender json: [result.as_json(only: [:status,:power,:gen,:frequency,:rotor,:wind,:pitch])]\n\tend",
"def index\n if current_user\n @certs = Cert.where(user_id: current_user.id)\n @smime_num = Cert.where(user_id: current_user.id, purpose_type: 7, state: Cert::State::NEW_GOT_SERIAL).count() # FIXME: rewrite to cover multiple states\n end\n end",
"def index\n hardware = Hardware.all\n render json: hardware.to_json(:except => [:id])\n end",
"def index\n @physicians = Physician.all\n render json: @physicians, :include => [:patients => {:include => [:surveys]}]\n end",
"def get_network_sm_softwares(options = {})\r\n # Validate required parameters.\r\n validate_parameters(\r\n 'network_id' => options['network_id'],\r\n 'device_id' => options['device_id']\r\n )\r\n # Prepare query url.\r\n _path_url = '/networks/{networkId}/sm/{deviceId}/softwares'\r\n _path_url = APIHelper.append_url_with_template_parameters(\r\n _path_url,\r\n 'networkId' => options['network_id'],\r\n 'deviceId' => options['device_id']\r\n )\r\n _query_builder = Configuration.base_uri.dup\r\n _query_builder << _path_url\r\n _query_url = APIHelper.clean_url _query_builder\r\n # Prepare headers.\r\n _headers = {\r\n 'accept' => 'application/json'\r\n }\r\n # Prepare and execute HttpRequest.\r\n _request = @http_client.get(\r\n _query_url,\r\n headers: _headers\r\n )\r\n CustomHeaderAuth.apply(_request)\r\n _context = execute_request(_request)\r\n validate_response(_context)\r\n # Return appropriate response type.\r\n decoded = APIHelper.json_deserialize(_context.response.raw_body) unless\r\n _context.response.raw_body.nil? ||\r\n _context.response.raw_body.to_s.strip.empty?\r\n decoded\r\n end",
"def index\n\t\tauthorize! :read, Skill\n\t\t\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @skills }\n end\n end",
"def index\n getProfile\n @consents = TherapistConsent.where('therapist_id = ? ', @therapist.id)\n respond_to do |format|\n format.html { render action: 'index' }\n format.json { render :status => 200, :json => { action: 'index', consents: @consents }}\n end\n end",
"def show\n @systemadmin = Systemadmin.find(params[:id])\n @pSAdmins = Host.find_all_by_primary_sadmin_id(params[:id])\n @secSAdmins = Host.find_all_by_secondary_sadmin_id(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @systemadmin }\n end\n end",
"def index\n @stresses = current_user.stresses.find(:all)\n @stress = current_user.stresses.build()\n\n respond_to do |format|\n format.html # index.html.erb\n end\n end",
"def create_trust_xml(xml) \n if current_user \n empty = REXML::Element.new('empty') \n trust = xml.root.get_elements('Trust').first \n \n return render(:text => \"<Response>bad xml</Response>\") unless trust \n trust_root = (trust.get_elements('TrustRoot').first || empty).text \n expires = (trust.get_elements('Expires').first || empty).text \n profile_name = (trust.get_elements('AccessProfile').first || empty).text \n profile_name = 'public' unless profile_name \n @profile = current_user.profiles.find_by_title(profile_name) \n \n return render(:text => \"<Response>bad profile</Response>\") unless @profile \n \n if ['-1', '0'].include? expires \n expires_at = nil \n else \n expires =~ %r[(\\d+)/(\\d+)/(\\d+)] \n expires_at = Time.utc($3.to_i, $2.to_i, $1.to_i) \n end \n \n if @trust = Trust.find_by_trust_root(trust_root) \n @trust.update_attributes(:profile => @profile, :expires_at => expires_at) \n else \n @trust = Trust.create(:profile => @profile, :expires_at => expires_at, :trust_root => trust_root) \n end \n @trust.update_attributes(:expires_at => Time.now.utc) if expires == '0' \n return render(:text => '<Response>success</Response>') \n end \n render :text => '<Response>could not create trust</Response>' \n end",
"def index\n @admin_skills = Admin::Skill.all\n\n render json: @admin_skills\n end",
"def things\n begin\n things = PermissionsManager.get_cluster_things(current_user, things_params[:cluster_group_id])\n rescue\n render json: {}, status: 403\n return\n end\n render json: { 'things': things }, status: 200\n end",
"def set_trust_transaction\n @trust_transaction = TrustTransaction.find(params[:id])\n end",
"def set_trustee\n @trustee = Trustee.find(params[:id])\n end",
"def index\n @people = Person.all\n respond_to do |format|\n format.json { \n render json: @people, :include => [:roles => { include: [:privileges] } ]\n }\n end\n end",
"def get_symptoms\n begin\n @desease = Desease.find(params[:id])\n\n @symptoms = @desease.symptoms\n render json: @symptoms\n rescue ActiveRecord::RecordNotFound => e\n render json: e, status: :unprocessable_entity\n end\n \n \n end",
"def index\n @wms = WmsResult.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @wms }\n end\n end",
"def getToolsSyndicateYalwa( entity_id)\n params = Hash.new\n params['entity_id'] = entity_id\n return doCurl(\"get\",\"/tools/syndicate/yalwa\",params)\n end",
"def get_softwarerepository_authorization_by_moid_with_http_info(moid, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: SoftwarerepositoryApi.get_softwarerepository_authorization_by_moid ...'\n end\n # verify the required parameter 'moid' is set\n if @api_client.config.client_side_validation && moid.nil?\n fail ArgumentError, \"Missing the required parameter 'moid' when calling SoftwarerepositoryApi.get_softwarerepository_authorization_by_moid\"\n end\n # resource path\n local_var_path = '/api/v1/softwarerepository/Authorizations/{Moid}'.sub('{' + 'Moid' + '}', CGI.escape(moid.to_s))\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/csv', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body]\n\n # return_type\n return_type = opts[:debug_return_type] || 'SoftwarerepositoryAuthorization'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['cookieAuth', 'http_signature', 'oAuth2', 'oAuth2']\n\n new_options = opts.merge(\n :operation => :\"SoftwarerepositoryApi.get_softwarerepository_authorization_by_moid\",\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: SoftwarerepositoryApi#get_softwarerepository_authorization_by_moid\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def index\n if params\n @trustees = Trustee.search(params).page(params[:page])\n else\n @trustees = Trustee.all.page(params[:page])\n end\n end",
"def index\n authorize! :view_pharmacy, @pharmacys\n @pharmacys = Pharmacy.all\n end",
"def show\n id = params[:id]\n @physician = Physician.find(id)\n render json: @physician, :include => [:patients => {:include => [:surveys]}]\n end",
"def set_mystic\n @mystic = Mystic.find(params[:id])\n end",
"def show\n @infrastructure = Infrastructure.find(params[:id])\n checkaccountobject(\"infrastructures\",@infrastructure)\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @infrastructure }\n end\n end",
"def show\n @mattress = Mattress.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mattress }\n end\n end",
"def index\n users = policy_scope(User)\n render json: { users: users }\n end",
"def request_trust(trust_url = \"http://#{request.host}/\", *args)\n trust_url = url_for(trust_url.merge(:only_path => false)) if trust_url.kind_of?(Hash)\n javascript_tag \"CCPEVE.requestTrust(#{trust_url.inspect});\", *args\n end",
"def show\n render json: @admin_skill\n end",
"def PerformRestrictedGet(uri)\n RefreshTokenIfNeeded()\n req = Net::HTTP::Get.new(uri)\n req['Authorization'] = \"Bearer #{@access_token}\"\n\n res = Net::HTTP.start(uri.hostname, uri.port,\n :use_ssl => uri.scheme == 'https') do |http|\n http.request(req)\n end\n\n return JSON.parse(res.body)\n end",
"def get_server_properties\n http_get(:uri=>\"/server/properties\", :fields=>x_cookie)\n end",
"def show\n @stress = current_user.stresses.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n end\n end",
"def system_management_network_securities_id_get_with_http_info(id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: ManagementNetworksSecurityApi.system_management_network_securities_id_get ...\"\n end\n # verify the required parameter 'id' is set\n if @api_client.config.client_side_validation && id.nil?\n fail ArgumentError, \"Missing the required parameter 'id' when calling ManagementNetworksSecurityApi.system_management_network_securities_id_get\"\n end\n # resource path\n local_var_path = \"/system/managementNetworkSecurities/{id}\".sub('{' + 'id' + '}', id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'ManagementNetworkSecurity')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ManagementNetworksSecurityApi#system_management_network_securities_id_get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def show\n @physician = Physician.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @physician }\n end\n end",
"def index\n @symptoms = Symptom.all\n\n render json: @symptoms\n end",
"def show\n authenticate_user!\n @server = Server.find(params[:id])\n @checks = @server.checks.page(params[:page]).per(10)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @server }\n end\n end",
"def index\n @tenants = keystone.tenants\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @tenants }\n end\n end",
"def show\n @witness = Witness.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @witness }\n end\n end",
"def getmill\n\tformid = Windmill.where(windformid: params[:id])\n\tif formid.present?\n render json: formid.as_json(only:[:no])\n\telse\n\t\trender json: {massage: 'Windform not found'}\n\tend\nend",
"def certs\n request :get, '/certs'\n end",
"def identities\n render json: current_user.identities\n end",
"def show\n @user_requirement = UserRequirement.find(params[:id])\n render json: @user_requirement\n end",
"def trust_emr(&block)\n trust_service('elasticmapreduce', 'trust-emr', &block)\n end",
"def show\n @store_manager_policies_payment = Store::Manager::Policies::Payment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @store_manager_policies_payment }\n end\n end",
"def get_kubernetes_sys_config_policy_by_moid_with_http_info(moid, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: KubernetesApi.get_kubernetes_sys_config_policy_by_moid ...'\n end\n # verify the required parameter 'moid' is set\n if @api_client.config.client_side_validation && moid.nil?\n fail ArgumentError, \"Missing the required parameter 'moid' when calling KubernetesApi.get_kubernetes_sys_config_policy_by_moid\"\n end\n # resource path\n local_var_path = '/api/v1/kubernetes/SysConfigPolicies/{Moid}'.sub('{' + 'Moid' + '}', CGI.escape(moid.to_s))\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/csv', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body]\n\n # return_type\n return_type = opts[:debug_return_type] || 'KubernetesSysConfigPolicy'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['cookieAuth', 'http_signature', 'oAuth2', 'oAuth2']\n\n new_options = opts.merge(\n :operation => :\"KubernetesApi.get_kubernetes_sys_config_policy_by_moid\",\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: KubernetesApi#get_kubernetes_sys_config_policy_by_moid\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def index\n @physicians = Physician.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @physicians }\n end\n end",
"def getmininginfo\n @api.request 'getmininginfo'\n end",
"def get_network_sm_user_softwares(options = {})\r\n # Validate required parameters.\r\n validate_parameters(\r\n 'network_id' => options['network_id'],\r\n 'user_id' => options['user_id']\r\n )\r\n # Prepare query url.\r\n _path_url = '/networks/{networkId}/sm/user/{userId}/softwares'\r\n _path_url = APIHelper.append_url_with_template_parameters(\r\n _path_url,\r\n 'networkId' => options['network_id'],\r\n 'userId' => options['user_id']\r\n )\r\n _query_builder = Configuration.base_uri.dup\r\n _query_builder << _path_url\r\n _query_url = APIHelper.clean_url _query_builder\r\n # Prepare headers.\r\n _headers = {\r\n 'accept' => 'application/json'\r\n }\r\n # Prepare and execute HttpRequest.\r\n _request = @http_client.get(\r\n _query_url,\r\n headers: _headers\r\n )\r\n CustomHeaderAuth.apply(_request)\r\n _context = execute_request(_request)\r\n validate_response(_context)\r\n # Return appropriate response type.\r\n decoded = APIHelper.json_deserialize(_context.response.raw_body) unless\r\n _context.response.raw_body.nil? ||\r\n _context.response.raw_body.to_s.strip.empty?\r\n decoded\r\n end",
"def show\n @sys_check = SysCheck.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sys_check }\n end\n end",
"def index\n @mx_assessments = MxAssessment.all\n authorize MxAssessment \n end",
"def show\n @mosttinymobsetup = Mosttinymobsetup.find(params[:id], :include => [:mosttinytrial, {:mosttinymob => :mosttinymobinfo}])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mosttinymobsetup }\n end\n end",
"def index\n #authorize! :index, @login, :message => 'Not authorized as an administrator.'\n #É preciso ir buscar a clinica do gestor atual para carregar a informação\n manager = Manager.first(:conditions => \"login_id = #{current_login.id}\")\n @clinic = manager.clinic\n\n @managers = Manager.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @managers }\n end\n end",
"def get_locks\n HTTParty.get(\"#{$base_url}/partners/#{$partner_id}/locks\", {headers: $headers}).parsed_response['locks']\nend",
"def show\n @skill_set = SkillSet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @skill_set }\n end\n end",
"def test_get_skills_route\n render :json => get_profile_skills_for_profile(\"https://www.linkedin.com/in/marissamayer\").to_json\n end",
"def index\n @role_permisions = RolePermision.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @role_permisions }\n end\n end",
"def status\n power_of_attorney = ClaimsApi::PowerOfAttorney.find_using_identifier_and_source(id: params[:id],\n source_name: source_name)\n raise ::Common::Exceptions::ResourceNotFound.new(detail: 'Resource not found') unless power_of_attorney\n\n render json: power_of_attorney, serializer: ClaimsApi::PowerOfAttorneySerializer\n end",
"def index\n @properties = current_user.properties.order(:id => :desc)\n render \"index.json.jb\"\n end",
"def show\n @missionmaker = Missionmaker.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @missionmaker }\n end\n end",
"def index\n permits = Permit.select('id, permit_type, applicant_name, start_date, end_date, address, application_data, city_name, ST_AsGeoJSON(geometry) AS geojson')\n .where(\"city_name = ? AND geometry IS NOT NULL AND address IS NOT NULL\", params[:city].upcase.gsub(/-/, \" \"))\n if permits\n respond_to do |format|\n format.json { render json: permits }\n end\n else\n respond_to do |format|\n format.json { render json: [], status: :bad_request }\n end\n end\n end",
"def show\n @physician = Physician.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @physician }\n end\n end",
"def index\n @witnesses = Witness.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @witnesses }\n end\n end",
"def get_json()\n\n http = Net::HTTP.new(STATUS_URI.host, STATUS_URI.port)\n http.use_ssl = false\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n request = Net::HTTP::Get.new(\"/api/services.json\")\n\n response = http.request(request)\n JSON.parse(response.body)\nend",
"def index\n @users = User.all\n binding.pry\n require 'net/http'\n result = Net::HTTP.get('makesys.net', '/')\n p result\n end",
"def index\n @priv_policies = PrivPolicy.all\n end",
"def show\n @moresmallarmorinfo = Moresmallarmorinfo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @moresmallarmorinfo }\n end\n end",
"def verify\n user_id = request.headers['HTTP_X_TRP_USER']\n custom_db = request.headers['X-CUSTOM-DB']\n puts \"USER ID: #{user_id}\"\n\n if custom_db\n url = URI.parse(\"http://localhost:3000/users/#{user_id}.json\")\n req = Net::HTTP::Get.new(url.path)\n res = Net::HTTP.start(url.host, url.port) {|http|\n http.request(req)\n }\n @output = JSON(res.body)\n puts @output\n @database = \"\"\n end\n end",
"def index\n @skills = Skill.all\n\n render json: @skills\n end",
"def getmill\n\t\n \tformid = Userdet.where(usid: params[:userid]).all\n \t\nif formid.present?\n\t\t\n render json: formid.as_json(only: [:windmill])\nelse\nrender json: [{message: 'not found'}]\nend\nend",
"def new\n ## Intitializing the temple object\n @temple = Temple.new\n\n if params[:trust_id]\n @trust = Trust.find_by_id(params[:trust_id])\n @temple.trust = @trust\n end\n\n respond_to do |format|\n format.html { get_collections and render :index }\n format.json { render json: @temple }\n format.js {}\n end\n end",
"def have_secret\n tmurl = params[:trustme]\n tmheader = request.headers[\"HTTP_X_TRUSTME\"]\n secret = Rails.application.config.admin_secret\n logger.info \"checking tmurl #{tmurl}, tmheader #{tmheader}, secret #{secret}\"\n if !(tmurl == secret or tmheader == secret)\n head :unauthorized\n end\n end",
"def show\n @website = Website.find(params[:id])\n\n render json: @website\n end",
"def index\n render json: @authority.all\n end",
"def get_by_property\n @api_v1_reservation = current_api_v1_user.properties.find(params[:id]).reservations\n render template: '/api/v1/reservations/index', status: 200\n rescue Exception => errors\n render json: errors, status: :unprocessable_entity\n end"
] |
[
"0.6088963",
"0.5720106",
"0.541263",
"0.53974366",
"0.53008777",
"0.5203522",
"0.5193611",
"0.51872385",
"0.51235723",
"0.5114555",
"0.5101144",
"0.5039",
"0.5031927",
"0.4996512",
"0.49871236",
"0.49567235",
"0.49361736",
"0.49341616",
"0.49259254",
"0.49168906",
"0.49085012",
"0.48947936",
"0.48946655",
"0.4888968",
"0.4881384",
"0.48782778",
"0.48332024",
"0.48212385",
"0.48093453",
"0.4803768",
"0.47855803",
"0.4783319",
"0.47793335",
"0.47789264",
"0.4778046",
"0.4776155",
"0.47716644",
"0.47704282",
"0.47629938",
"0.4754492",
"0.47513112",
"0.4746679",
"0.47440043",
"0.4743503",
"0.4732195",
"0.47309026",
"0.47307733",
"0.4729578",
"0.47255847",
"0.472479",
"0.4717552",
"0.47147876",
"0.4712533",
"0.47009376",
"0.46999452",
"0.46989897",
"0.46956125",
"0.46941176",
"0.46937472",
"0.46905774",
"0.46800554",
"0.46775004",
"0.46715716",
"0.4670693",
"0.4659879",
"0.46551102",
"0.46549466",
"0.46545917",
"0.4652566",
"0.4651894",
"0.4649791",
"0.4644069",
"0.4643735",
"0.4643423",
"0.46429947",
"0.46425852",
"0.46400592",
"0.46400335",
"0.46399817",
"0.46358195",
"0.46311706",
"0.46308842",
"0.46307757",
"0.46291903",
"0.46233705",
"0.46221",
"0.46212596",
"0.46173438",
"0.4616616",
"0.46136376",
"0.46104917",
"0.46083736",
"0.46076927",
"0.46052584",
"0.46033308",
"0.46010807",
"0.4600291",
"0.45989236",
"0.45987323",
"0.45980442",
"0.45971066"
] |
0.0
|
-1
|
POST /trust_moneys POST /trust_moneys.json
|
def create
@trust_money = TrustMoney.new(trust_money_params)
respond_to do |format|
if @trust_money.save
format.html { redirect_to @trust_money, notice: 'Trust money was successfully created.' }
format.json { render :show, status: :created, location: @trust_money }
else
format.html { render :new }
format.json { render json: @trust_money.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def is_create_trust? \n request.env['RAW_POST_DATA'] =~ %r[<CreateTrust>] \n end",
"def postEntityUser_trust( entity_id, user_id, trust)\n params = Hash.new\n params['entity_id'] = entity_id\n params['user_id'] = user_id\n params['trust'] = trust\n return doCurl(\"post\",\"/entity/user_trust\",params)\n end",
"def create_trust_xml(xml) \n if current_user \n empty = REXML::Element.new('empty') \n trust = xml.root.get_elements('Trust').first \n \n return render(:text => \"<Response>bad xml</Response>\") unless trust \n trust_root = (trust.get_elements('TrustRoot').first || empty).text \n expires = (trust.get_elements('Expires').first || empty).text \n profile_name = (trust.get_elements('AccessProfile').first || empty).text \n profile_name = 'public' unless profile_name \n @profile = current_user.profiles.find_by_title(profile_name) \n \n return render(:text => \"<Response>bad profile</Response>\") unless @profile \n \n if ['-1', '0'].include? expires \n expires_at = nil \n else \n expires =~ %r[(\\d+)/(\\d+)/(\\d+)] \n expires_at = Time.utc($3.to_i, $2.to_i, $1.to_i) \n end \n \n if @trust = Trust.find_by_trust_root(trust_root) \n @trust.update_attributes(:profile => @profile, :expires_at => expires_at) \n else \n @trust = Trust.create(:profile => @profile, :expires_at => expires_at, :trust_root => trust_root) \n end \n @trust.update_attributes(:expires_at => Time.now.utc) if expires == '0' \n return render(:text => '<Response>success</Response>') \n end \n render :text => '<Response>could not create trust</Response>' \n end",
"def register_trust_service(params)\n params[:period] = params.delete :term\n params[:period] = 1 unless params[:period]\n params[:reg_type] = 'new' unless params[:reg_type]\n params[:handle] = 'process' unless params[:handle]\n params[:contact_set] = params.delete :contacts\n params[:key] = 'attributes'\n\n run_command :sw_register, :trust_service, params\n end",
"def trustee_params\n params.require(:trustee).permit(:access_id, :full_name, :trustee_type, :dates_of_service, :university_status, :first_year)\n end",
"def suscriber_wm\n\t\turi = URI(\"http://staging.benchprep.com/api/v1/test/fixtures.json\")\t\n\n\t\tres = Net::HTTP.post_form(uri, 'email' => 'integration-tester+1@benchprep.com&enrollments_persona=subscriber&devices_persona=web_and_mobile')\n\t\t# write this output to a file\n\t\toutput = File.open( \"spec/fixtures/sp_wm_persona.json\",'w' ){|f| \n\t\t\tf.flock(File::LOCK_EX)\n\t\t\tf.write(res.body)\n\t\t}\n\n\t\t# Now parse this string as json\n\t\tjson = File.read('spec/fixtures/sp_wm_persona.json')\n\t\templs = JSON.parse(json)\n\n\t\treturn empls #pretty printed output\n\tend",
"def create\n @trustee = Trustee.new(trustee_params)\n\n respond_to do |format|\n if @trustee.save\n format.html { redirect_to @trustee, notice: 'Trustee was successfully created.' }\n format.json { render action: 'show', status: :created, location: @trustee }\n else\n format.html { render action: 'new' }\n format.json { render json: @trustee.errors, status: :unprocessable_entity }\n end\n end\n end",
"def installandlaunch(token, rid, filename , grant_all_permissions )\nuri = URI.parse(\"https://device.pcloudy.com/api/install_app\")\n@toSend = {\n \"token\"=>token, \"rid\"=>rid, \"filename\"=>filename, \"grant_all_permissions\"=>grant_all_permissions\n}.to_json\n\nhttps = Net::HTTP.new(uri.host,uri.port)\nhttps.use_ssl = true\nreq = Net::HTTP::Post.new(uri.path, initheader = {'Content-Type' =>'application/json'})\nreq.body = \"#{@toSend}\"\nres = https.request(req)\nputs \"Response #{res.code} #{res.message}: #{res.body}\"\ninstallresp = JSON.parse(res.body)\noutput = installresp[\"result\"][\"msg\"]\nputs output\nend",
"def sendreq\n newReq = Joinrequest.new(:resolved => false, :manager_id => params[:id], :property_id => params[:pid], :tenant_id => session[:user_id])\n newReq.save\n redirect_to \"/tenants/show\"\n end",
"def trust_emr(&block)\n trust_service('elasticmapreduce', 'trust-emr', &block)\n end",
"def truststore\n RubyAem::Resources::Truststore.new(@client)\n end",
"def system_management_network_securities_post_with_http_info(management_network_security, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: ManagementNetworksSecurityApi.system_management_network_securities_post ...\"\n end\n # verify the required parameter 'management_network_security' is set\n if @api_client.config.client_side_validation && management_network_security.nil?\n fail ArgumentError, \"Missing the required parameter 'management_network_security' when calling ManagementNetworksSecurityApi.system_management_network_securities_post\"\n end\n # resource path\n local_var_path = \"/system/managementNetworkSecurities\"\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(management_network_security)\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'ManagementNetworkSecurity')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ManagementNetworksSecurityApi#system_management_network_securities_post\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def create\n @trust_transaction = TrustTransaction.new(trust_transaction_params)\n\n respond_to do |format|\n if @trust_transaction.save\n format.html { redirect_to @trust_transaction, notice: 'Trust transaction was successfully created.' }\n format.json { render action: 'show', status: :created, location: @trust_transaction }\n else\n format.html { render action: 'new' }\n format.json { render json: @trust_transaction.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_kubernetes_trusted_registries_policy_with_http_info(moid, kubernetes_trusted_registries_policy, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: KubernetesApi.update_kubernetes_trusted_registries_policy ...'\n end\n # verify the required parameter 'moid' is set\n if @api_client.config.client_side_validation && moid.nil?\n fail ArgumentError, \"Missing the required parameter 'moid' when calling KubernetesApi.update_kubernetes_trusted_registries_policy\"\n end\n # verify the required parameter 'kubernetes_trusted_registries_policy' is set\n if @api_client.config.client_side_validation && kubernetes_trusted_registries_policy.nil?\n fail ArgumentError, \"Missing the required parameter 'kubernetes_trusted_registries_policy' when calling KubernetesApi.update_kubernetes_trusted_registries_policy\"\n end\n # resource path\n local_var_path = '/api/v1/kubernetes/TrustedRegistriesPolicies/{Moid}'.sub('{' + 'Moid' + '}', CGI.escape(moid.to_s))\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n content_type = @api_client.select_header_content_type(['application/json', 'application/json-patch+json'])\n if !content_type.nil?\n header_params['Content-Type'] = content_type\n end\n header_params[:'If-Match'] = opts[:'if_match'] if !opts[:'if_match'].nil?\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body] || @api_client.object_to_http_body(kubernetes_trusted_registries_policy)\n\n # return_type\n return_type = opts[:debug_return_type] || 'KubernetesTrustedRegistriesPolicy'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['cookieAuth', 'http_signature', 'oAuth2', 'oAuth2']\n\n new_options = opts.merge(\n :operation => :\"KubernetesApi.update_kubernetes_trusted_registries_policy\",\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: KubernetesApi#update_kubernetes_trusted_registries_policy\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def reserveNode(node_ids,account_name,valid_from,valid_until)\n cert_path = APP_CONFIG['cert_path']\n # resernation_name: we set a random name for every reservation constructing by the name of the slice and a random number ex user1/12341234 \n resernation_name =account_name+ \"/\" + (1000 + Random.rand(10000000)).to_s\n puts resernation_name\n \n broker_url = APP_CONFIG['broker_ip'] + ':' + APP_CONFIG['broker_port'].to_s\n\n node_ids.map!{|r| {uuid: r}}\n\n header = {\"Content-Type\" => \"application/json\"}\n options ={\n name: resernation_name,\n valid_from: valid_from,\n valid_until: valid_until,\n account: \n { \n name: account_name\n },\n components: node_ids\n }\n\n #puts options.to_json \n uri = URI.parse(broker_url+\"/resources/leases\")\n pem = File.read(cert_path)\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n http.cert = OpenSSL::X509::Certificate.new(pem)\n http.key = OpenSSL::PKey::RSA.new(pem)\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n request = Net::HTTP::Post.new(uri.request_uri, header)\n request.body = options.to_json\n\n response = http.request(request)\n \n res = JSON.parse(response.body)\n \n if response.header.code != '200'\n puts \"Something went wrong\"\n puts response \n puts res[\"exception\"][\"reason\"]\n return res[\"exception\"][\"reason\"]\n else\n return \"OK\"\n end\n \n end",
"def get_kubernetes_trusted_registries_policy_by_moid_with_http_info(moid, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: KubernetesApi.get_kubernetes_trusted_registries_policy_by_moid ...'\n end\n # verify the required parameter 'moid' is set\n if @api_client.config.client_side_validation && moid.nil?\n fail ArgumentError, \"Missing the required parameter 'moid' when calling KubernetesApi.get_kubernetes_trusted_registries_policy_by_moid\"\n end\n # resource path\n local_var_path = '/api/v1/kubernetes/TrustedRegistriesPolicies/{Moid}'.sub('{' + 'Moid' + '}', CGI.escape(moid.to_s))\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/csv', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body]\n\n # return_type\n return_type = opts[:debug_return_type] || 'KubernetesTrustedRegistriesPolicy'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['cookieAuth', 'http_signature', 'oAuth2', 'oAuth2']\n\n new_options = opts.merge(\n :operation => :\"KubernetesApi.get_kubernetes_trusted_registries_policy_by_moid\",\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: KubernetesApi#get_kubernetes_trusted_registries_policy_by_moid\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def double_mattress_one_params\n params.require(:double_mattress_one).permit(:name, :gender, :age, :email, :weight,\n :length, :sleep_position, :body_shape, :warm_sleeping,\n :neck_or_back_pain, :session_id, :mattress_length,\n :mattress_width, :comfort, :chassis)\n end",
"def pharmacy_params\n params.require(:pharmacy).permit(:name,:region_id,:region,:pharmacy_web_id,:user_id)\n end",
"def patch_kubernetes_trusted_registries_policy_with_http_info(moid, kubernetes_trusted_registries_policy, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: KubernetesApi.patch_kubernetes_trusted_registries_policy ...'\n end\n # verify the required parameter 'moid' is set\n if @api_client.config.client_side_validation && moid.nil?\n fail ArgumentError, \"Missing the required parameter 'moid' when calling KubernetesApi.patch_kubernetes_trusted_registries_policy\"\n end\n # verify the required parameter 'kubernetes_trusted_registries_policy' is set\n if @api_client.config.client_side_validation && kubernetes_trusted_registries_policy.nil?\n fail ArgumentError, \"Missing the required parameter 'kubernetes_trusted_registries_policy' when calling KubernetesApi.patch_kubernetes_trusted_registries_policy\"\n end\n # resource path\n local_var_path = '/api/v1/kubernetes/TrustedRegistriesPolicies/{Moid}'.sub('{' + 'Moid' + '}', CGI.escape(moid.to_s))\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n content_type = @api_client.select_header_content_type(['application/json', 'application/json-patch+json'])\n if !content_type.nil?\n header_params['Content-Type'] = content_type\n end\n header_params[:'If-Match'] = opts[:'if_match'] if !opts[:'if_match'].nil?\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body] || @api_client.object_to_http_body(kubernetes_trusted_registries_policy)\n\n # return_type\n return_type = opts[:debug_return_type] || 'KubernetesTrustedRegistriesPolicy'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['cookieAuth', 'http_signature', 'oAuth2', 'oAuth2']\n\n new_options = opts.merge(\n :operation => :\"KubernetesApi.patch_kubernetes_trusted_registries_policy\",\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: KubernetesApi#patch_kubernetes_trusted_registries_policy\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def save_registration(params)\r\n random_pass = 4.times.map { (0..9).to_a.sample }.join\r\n stgu = Hash.new\r\n stgu['__c'] = 'stgu'\r\n stgu['__p'] = [\r\n nil,\r\n nil,\r\n nil, \r\n 1,\r\n params[:email],\r\n random_pass,\r\n nil,\r\n params[:first_name],\r\n params[:middle_name],\r\n params[:last_name],\r\n params[:phone],\r\n nil,\r\n Settings.register_location,\r\n params[:birth_date]\r\n ]\r\n\r\n address = [\r\n nil,\r\n nil,\r\n nil,\r\n params[:street_address],\r\n nil,\r\n params[:city],\r\n nil,\r\n params[:state],\r\n 'US',\r\n params[:zip_code]\r\n ]\r\n\r\n stgma = Hash.new\r\n stgma['__c'] = 'stgma'\r\n stgma['__p'] = address\r\n\r\n stgba = Hash.new\r\n stgba['__c'] = 'stgba'\r\n stgba['__p'] = address\r\n\r\n stgu_json = stgu.to_json\r\n stgma_json = stgma.to_json\r\n stgba_json = stgba.to_json\r\n\r\n register_path = 'https://catalog.tadl.org/osrf-gateway-v1?service=open-ils.actor&method=open-ils.actor.user.stage.create¶m='\r\n register_path << stgu_json.to_s\r\n register_path << '¶m=' + stgma_json.to_s\r\n register_path << '¶m=' + stgba_json.to_s\r\n\r\n if Settings.register_newsletter == true && params[:enews] == 'true'\r\n uri = URI(Settings.register_listapi_url)\r\n\r\n params = {\r\n 'check' => ENV[\"LISTAPI_KEY\"],\r\n 'email' => params[:email],\r\n 'firstname' => params[:first_name],\r\n 'lastname' => params[:last_name],\r\n 'city' => params[:city],\r\n 'state' => params[:state],\r\n 'zip' => params[:zip_code],\r\n }\r\n\r\n res = Net::HTTP.post_form(uri, params);\r\n # puts res.body if res.is_a?(Net::HTTPSuccess) # Uncomment for DEBUG\r\n\r\n end\r\n\r\n uri = URI.parse(register_path)\r\n response = Net::HTTP.get_response(uri)\r\n if response.code == '200'\r\n return JSON.parse(response.body)\r\n else\r\n return 'error'\r\n end\r\n\r\n end",
"def create\n begin\n @new_policy = @@stripper.hashData(params[:policy])\n @new_policy[:mypclient_id] = @@client_id\n @new_policy[:isactive] = 1\n @new_policy[:createdby] = session[:username]\n\n @@request_result[:data] = @new_policy\n\n @policy = Workskedpolicy.new(@new_policy)\n if @policy.save\n @@request_result[:success] = true\n @@request_result[:notice] = 'Policy was successfully created.'\n else\n @@request_result[:errormsg] = @policy.errors.full_messages[0]\n end\n rescue Exception => e \n @@request_result[:errormsg] = e.message\n end\n render json: @@request_result\n end",
"def mystic_params\n params[:mystic].permit(:email, :password, :first_name, :last_name)\n end",
"def update!(**args)\n @trust_prop = args[:trust_prop] if args.key?(:trust_prop)\n end",
"def update!(**args)\n @trust_settings_for_client = args[:trust_settings_for_client] if args.key?(:trust_settings_for_client)\n end",
"def create\n @moresmalltrial = Moresmalltrial.new(params[:moresmalltrial])\n\n respond_to do |format|\n if @moresmalltrial.save\n format.html { redirect_to @moresmalltrial, notice: 'Moresmalltrial was successfully created.' }\n format.json { render json: @moresmalltrial, status: :created, location: @moresmalltrial }\n else\n format.html { render action: \"new\" }\n format.json { render json: @moresmalltrial.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post()\n # construct arguments to fetch\n args = {\n method: 'post',\n credentials: 'include',\n headers: {'Content-Type' => 'application/json'},\n body: {\n project: @ppmc.id,\n ids: @ppmc.mentors.join(','),\n action: 'add',\n targets: ['ldap', 'ppmc', 'committer']\n }.inspect\n }\n\n @disabled = true\n Polyfill.require(%w(Promise fetch)) do\n @create_disabled = true\n fetch(\"actions/ppmc\", args).then {|response|\n content_type = response.headers.get('content-type') || ''\n if response.status == 200 and content_type.include? 'json'\n response.json().then do |json|\n self.update(json)\n end\n else\n alert \"#{response.status} #{response.statusText}\"\n end\n @create_disabled = false\n }.catch {|error|\n alert error\n @create_disabled = false\n }\n end\n end",
"def charity_trustee_params\n params.require(:charity_trustee).permit(:regno, :trustee)\n end",
"def create\n @priv_policy = PrivPolicy.new(priv_policy_params)\n\n respond_to do |format|\n if @priv_policy.save\n format.html { redirect_to @priv_policy, notice: 'Priv policy was successfully created.' }\n format.json { render :show, status: :created, location: @priv_policy }\n else\n format.html { render :new }\n format.json { render json: @priv_policy.errors, status: :unprocessable_entity }\n end\n end\n end",
"def tombstone_timehold_params_from_lomat\n params.permit(:tombstoneJSON, :permanent, :rating)\n end",
"def create_trust_if_necessary(xml) \n profile_name = xml.root.get_elements('Request').first.get_elements('AccessProfile').first.text \n profile_name = 'public' unless profile_name \n profile = current_user.profiles.find_by_title(profile_name) \n return unless profile \n hsh = {:profile => profile} \n params.merge!(get_params_from_xml(xml)) unless params['openid.mode'] \n if @trust = Trust.find_by_trust_root(params['openid.trust_root']) \n unless @trust.active? \n hsh.merge!(:expires_at => nil) \n just_once = true \n end \n @trust.update_attributes(hsh) \n else \n @trust = Trust.create :profile => profile, :expires_at => nil, :trust_root => params['openid.trust_root'] \n just_once = true \n end \n @trust.instance_eval \"def xml_expire?; #{just_once}; end\" \n end",
"def delete_kubernetes_trusted_registries_policy_with_http_info(moid, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: KubernetesApi.delete_kubernetes_trusted_registries_policy ...'\n end\n # verify the required parameter 'moid' is set\n if @api_client.config.client_side_validation && moid.nil?\n fail ArgumentError, \"Missing the required parameter 'moid' when calling KubernetesApi.delete_kubernetes_trusted_registries_policy\"\n end\n # resource path\n local_var_path = '/api/v1/kubernetes/TrustedRegistriesPolicies/{Moid}'.sub('{' + 'Moid' + '}', CGI.escape(moid.to_s))\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body]\n\n # return_type\n return_type = opts[:debug_return_type]\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['cookieAuth', 'http_signature', 'oAuth2', 'oAuth2']\n\n new_options = opts.merge(\n :operation => :\"KubernetesApi.delete_kubernetes_trusted_registries_policy\",\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: KubernetesApi#delete_kubernetes_trusted_registries_policy\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def create\n @physician = Physician.new(physician_params)\n\n if @physician.save\n render json: @physician, status: :created\n else\n render json: @physician.errors, status: :unprocessable_entity\n end\n end",
"def money_ins_trustly_init_post_with_http_info(parameters, authorization, psu_ip_address, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: MoneyInsApi.money_ins_trustly_init_post ...'\n end\n # verify the required parameter 'parameters' is set\n if @api_client.config.client_side_validation && parameters.nil?\n fail ArgumentError, \"Missing the required parameter 'parameters' when calling MoneyInsApi.money_ins_trustly_init_post\"\n end\n # verify the required parameter 'authorization' is set\n if @api_client.config.client_side_validation && authorization.nil?\n fail ArgumentError, \"Missing the required parameter 'authorization' when calling MoneyInsApi.money_ins_trustly_init_post\"\n end\n # verify the required parameter 'psu_ip_address' is set\n if @api_client.config.client_side_validation && psu_ip_address.nil?\n fail ArgumentError, \"Missing the required parameter 'psu_ip_address' when calling MoneyInsApi.money_ins_trustly_init_post\"\n end\n # resource path\n local_var_path = '/v2/moneyins/trustly/init'\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n header_params[:'Authorization'] = authorization\n header_params[:'PSU-IP-Address'] = psu_ip_address\n header_params[:'PSU-Accept-Language'] = opts[:'psu_accept_language'] if !opts[:'psu_accept_language'].nil?\n header_params[:'PSU-User-Agent'] = opts[:'psu_user_agent'] if !opts[:'psu_user_agent'].nil?\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(parameters)\n auth_names = []\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'MoneyInTrustlyInitOutput')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: MoneyInsApi#money_ins_trustly_init_post\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def sunsystem_params\n params.require(:sunsystem).permit(:y, :name)\n end",
"def post_gmo_with_create_member(user)\n uri = URI.parse('https://pt01.mul-pay.jp/payment/SaveMember.idPass')\n request = Net::HTTP::Post.new(uri)\n request.set_form_data(\n 'SiteID' => ENV['SITE_ID'],\n 'SitePass' => ENV['SITE_PASS'],\n 'MemberID' => user.member_id\n )\n\n req_options = {\n use_ssl: uri.scheme == 'https'\n }\n\n response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|\n http.request(request)\n end\n\n if response.code == '200'\n logger.info('GMO created member!(^ ^)!')\n else\n logger.info('GMO error!!!')\n end\n end",
"def certificates\n http_path = \"http://localhost:8081/auth/realms/master/protocol/openid-connect/certs\"\n url = URI(http_path)\n http = Net::HTTP.new(url.host, url.port)\n # request = Net::HTTP::Post.new(url.to_s)\n request = Net::HTTP::Get.new(url.to_s)\n #request[\"authorization\"] = 'bearer ' + token\n #request[\"content-type\"] = 'application/json'\n #body = {}\n\n #request.body = body.to_json\n response = http.request(request)\n puts \"RESPONSE\", response.read_body\n response_json = parse_json(response.read_body)[0]\nend",
"def matiawase_params\n params.require(:matiawase).permit(:groupname, :devid, :username, :iconSelect, :latitude, :longitude, :gpsAccuracy, :deviceToken)\n end",
"def request_post\n # purpose_type: profile ID of\n # https://certs.nii.ac.jp/archive/TSV_File_Format/client_tsv/\n\n # S/MIME-multiple-application guard (failsafe)\n smime_num = Cert.where(user_id: current_user.id, purpose_type: 7, state: Cert::State::NEW_GOT_SERIAL).count() # FIXME: rewrite to cover multiple states\n if (smime_num > 0)\n return # FIXME: need error message\n end\n\n ActiveRecord::Base.transaction do \n current_user.cert_serial_max += 1\n current_user.save # TODO: need error check\n end \n \n case params[:cert][\"purpose_type\"].to_i\n when Cert::PurposeType::CLIENT_AUTH_CERTIFICATE\n dn = \"CN=#{current_user.uid},OU=No #{current_user.cert_serial_max.to_s},\" + SHIBCERT_CONFIG[Rails.env]['base_dn']\n\n when Cert::PurposeType::SMIME_CERTIFICATE\n dn = \"CN=#{current_user.name},\" + SHIBCERT_CONFIG[Rails.env]['base_dn']\n else\n # something wrong. TODO: need error handling\n Rails.logger.info \"#{__method__}: unknown purpose_type #{params[:cert]['purpose_type']}\"\n dn = \"\"\n end\n \n request_params = params.require(:cert).permit(:purpose_type).merge(\n {user_id: current_user.id,\n state: Cert::State::NEW_REQUESTED_FROM_USER,\n dn: dn,\n req_seq: current_user.cert_serial_max})\n @cert = Cert.new(request_params)\n @cert.save\n\n Rails.logger.debug \"RaReq.request call: @cert = #{@cert.inspect}\"\n RaReq.request(@cert)\n \n redirect_to request_result_path(@cert.id)\n end",
"def trust_money_params\n params.require(:trust_money).permit(:source_type, :agency_id, :etc)\n end",
"def send_request_to_patron_creator_service\n # Sierra supporting pin as password\n query = {\n 'names' => [\"#{last_name.upcase}, #{first_name.upcase}\"],\n 'emails' => [email],\n 'pin' => password,\n 'patronType' => patron_type,\n 'patronCodes' => {\n 'pcode1' => '-',\n 'pcode2' => '-',\n 'pcode3' => pcode3,\n 'pcode4' => pcode4\n },\n 'barcodes' => [self.barcode.present? ? self.barcode : self.assign_barcode.to_s],\n addresses: [\n {\n lines: [\n \"#{school.address_line_1}\",\n \"#{school.address_line_2}\"\n ],\n type: 'a'\n }\n ],\n phones: [{\n number: school.phone_number,\n type: \"t\"\n }],\n varFields: [{\n fieldTag: \"o\",\n content: school.name\n }]\n }\n response = HTTParty.post(\n ENV.fetch('PATRON_MICROSERVICE_URL_V02', nil),\n body: query.to_json,\n headers:\n { 'Authorization' => \"Bearer #{Oauth.get_oauth_token}\",\n 'Content-Type' => 'application/json' },\n timeout: 10\n )\n case response.code\n when 201\n LogWrapper.log('DEBUG', {\n 'message' => \"The account with e-mail #{email} was\n successfully created from the micro-service!\",\n 'status' => response.code\n })\n when 400\n LogWrapper.log('ERROR', {\n 'message' => \"An error has occured when sending a request to the patron creator service\",\n 'status' => response.code,\n 'responseData' => response.body\n })\n raise Exceptions::InvalidResponse, response[\"message\"][\"description\"]\n else\n LogWrapper.log('ERROR', {\n 'message' => \"An error has occured when sending a request to the patron creator service\",\n 'status' => response.code,\n 'responseData' => response.body\n })\n raise Exceptions::InvalidResponse, \"Invalid status code of: #{response.code}\"\n end\n end",
"def make\n @email=params[:email]\n @name=params[:name]\n @password=params[:password]\n @sectionId = params[:sectionId]\n @departmentId = params[:departmentId]\n @password_confirmation=params[:password_confirmation]\n a=User.new\n a.email=@email\n a.name=@name\n a.password=@password\n a.password_confirmation=@password_confirmation\n a.sec_id = @sectionId\n a.dept_id = @departmentId \n a.save\n\n render json: a, status: 201\n authorize! :make, a\n end",
"def create\n @resource_group_machine = ResourceGroupMachine.new(resource_group_machine_params)\n #authorize(@resource_group_machine)\n respond_to do |format|\n if @resource_group_machine.save\n format.html { redirect_to @resource_group_machine, notice: 'Resource group machine was successfully created.' }\n format.json { render :show, status: :created, location: @resource_group_machine }\n else\n format.html { render :new }\n format.json { render json: @resource_group_machine.errors, status: :unprocessable_entity }\n end\n end\n end",
"def system_control\r\n\r\n params.require(:system_control).permit(*system_control_attributes)\r\n\r\n end",
"def create\n @mobilesetting = Mobilesetting.new(mobilesetting_params)\n @mobilesetting.user_id = current_user.id\n @mobilesetting.securephrase = SecureRandom.hex(8)\n respond_to do |format|\n if @mobilesetting.save\n format.html { redirect_to @mobilesetting, notice: 'Mobilesetting was successfully created.' }\n format.json { render :show, status: :created, location: @mobilesetting }\n else\n format.html { render :new }\n format.json { render json: @mobilesetting.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @trust_moneys = TrustMoney.all\n end",
"def create\n @membership = @website.memberships.new(membership_params)\n @membership.user.no_password = true\n\n respond_to do |format|\n if @membership.save\n format.html { redirect_to @membership, notice: 'Membership was successfully created.' }\n format.json { render action: 'show', status: :created, location: @membership }\n else\n format.html { render action: 'new' }\n format.json { render json: @membership.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @trustees_minute = TrusteesMinute.new(trustees_minute_params)\n\n respond_to do |format|\n if @trustees_minute.save\n format.html { redirect_to @trustees_minute, notice: 'Trustees minute was successfully created.' }\n format.json { render action: 'show', status: :created, location: @trustees_minute }\n else\n format.html { render action: 'new' }\n format.json { render json: @trustees_minute.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @privacy_policy = PrivacyPolicy.new(privacy_policies_params)\n\n respond_to do |format|\n if @privacy_policy.save\n format.html { redirect_to admin_privacy_policies_path, notice: 'Privacy Policy was succesfully created.' }\n format.json { render :show, status: :created, location: @privacy_policy }\n else\n format.html { render :new }\n format.json { render json: @privacy_policy.errors, status: :unprocesable_entity }\n end\n end\n end",
"def create\n authenticate_user!\n authorize! :index, @user, :message => 'Not authorized as an administrator.'\n \n @key_policy_maker = KeyPolicyMaker.new(params[:key_policy_maker])\n\n respond_to do |format|\n if @key_policy_maker.save\n format.html { redirect_to :back, notice: 'Key policy maker successfully created.' }\n format.json { render json: @key_policy_maker, status: :created, location: @key_policy_maker }\n else\n format.html { render action: \"new\" }\n format.json { render json: @key_policy_maker.errors, status: :unprocessable_entity }\n end\n end\n end",
"def validator_captive_portal(args = {}) \n post(\"/profiles.json/captiveportal/\", args)\nend",
"def create\n @site_mst = SiteMst.new(site_mst_params)\n\n respond_to do |format|\n if @site_mst.save\n format.html { redirect_to @site_mst, notice: 'Site mst was successfully created.' }\n format.json { render :show, status: :created, location: @site_mst }\n else\n format.html { render :new }\n format.json { render json: @site_mst.errors, status: :unprocessable_entity }\n end\n end\n end",
"def setPolicies\n=begin\n Util.modifyPolicy(ncaEnclave, '', '\nPolicy DamlBootPolicyNCAServletForRearPolicyAdmin = [\n A user in role RearPolicyAdministration can access a servlet named NCAServlets\n]\n')\n=end\n end",
"def create\n @legal_spouse = LegalSpouse.new(legal_spouse_params)\n respond_to do |format|\n\n if @legal_spouse.save\n format.html { redirect_to staff_register3_path, notice: 'Personal detail was successfully created.' }\n format.json { render :show, status: :created, location: @legal_spouse }\n else\n format.html { render :new }\n format.json { render json: @legal_spouse.errors, status: :unprocessable_entity }\n end\n end\n end",
"def setup_multi_sig_sign_hash2(tx_code,keypair)\n #this will search the multi-sign-server for the published transaction with a matching tx_code.\n #if the transaction is found it will get the b64 encoded transaction from the server \n #and sign it with this keypair that is assumed to be a valid signer for this transaction.\n #after it signs the transaction it will send the signed transaction back to the multi-sign-server\n #that will continue to collect more signatures from other signers until the total signer weight threshold is met,\n #at witch point the multi-sign-server will send the fully signed transaction to the stellar network for validation\n # this function only returns the sig_hash to be sent to send_to_multi_sign_server(sig_hash) to publish signing of tx_code\n # this sig_hash can be modified before it is sent \n # example: \n # sig_hash[\"tx_title\"] = \"some cool transaction\"\n # sig_hash[\"signer_weight\"] = 2\n # the other values should already be filled in by the function that for the most part should not be changed.\n\n #this action get_tx when sent to the mss-server will returns the master created transaction with added info, \n #{\"tx_num\"=>1, \"signer\"=>0, \"tx_code\"=>\"7ZZUMOSZ26\", \"tx_title\"=>\"test multi sig tx\", \"signer_address\"=>\"\", \"signer_weight\"=>\"\", \"master_address\"=>\"GDZ4AFAB...\", \"tx_envelope_b64\"=>\"AAAA...\",\"signer_sig\"=>\"URYE...\"}\n get_tx = {\"action\"=>\"get_tx\",\"tx_code\"=>\"7ZZUMOSZ26\"}\n get_tx[\"tx_code\"] = tx_code\n result = Utils.send_to_multi_sign_server(get_tx)\n puts \"mss result: #{result}\"\n puts \"env_b64: #{result[\"tx_envelope_b64\"]}\"\n env = Utils.b64_to_envelope(result[\"tx_envelope_b64\"])\n if env.nil?\n puts \"env was nil\"\n return nil\n end\n tx = env.tx\n signature = Utils.sign_transaction_env(env,keypair)\n #sig_b64 = ??\n envnew = Utils.envelope_addsigners(env, tx, keypair)\n tx_envelope_b64 = Utils.envelope_to_b64(envnew)\n submit_sig = {\"action\"=>\"sign_tx\",\"tx_title\"=>\"test tx\",\"tx_code\"=>\"JIEWFJYE\", \"signer_address\"=>\"GAJYGYI...\", \"signer_weight\"=>\"1\", \"tx_envelope_b64\"=>\"AAAA...\",\"signer_sig\"=>\"JIDYR...\"}\n submit_sig[\"tx_code\"] = tx_code\n submit_sig[\"tx_title\"] = tx_code\n sig_b64 = Stellar::Convert.to_base64 signature\n submit_sig[\"signer_sig\"] = sig_b64\n #sig_bytes = Stellar::Convert.from_base64 sig_b64\n #sig_b64 = Stellar::Convert.to_base64 sig_bytes\n submit_sig[\"tx_envelope_b64\"] = tx_envelope_b64\n submit_sig[\"signer_address\"] = keypair.address\n return submit_sig\nend",
"def create\n @attorney = Attorney.new(attorney_params)\n respond_to do |format|\n if @attorney.save\n @attorney.user_id = current_user.id\n current_user.email = (attorney_params)[:email]\n current_user.password = (attorney_params)[:password]\n current_user.role = params[:role].to_i\n current_user.image = (attorney_params)[:profile_image]\n current_user.first_name = (attorney_params)[:first_name]+\" \"+(attorney_params)[:middle_name]+\" \"+(attorney_params)[:last_name]\n current_user.save\n @attorney.save\n sign_in(current_user, :bypass => true)\n format.html { redirect_to attorneys_path, notice: 'Attorney was successfully created.' }\n format.json { render :show, status: :created, location: @attorney }\n else\n format.html { render :new }\n format.json { render json: @attorney.errors, status: :unprocessable_entity }\n end\n end\n end",
"def trust_transaction_params\n params.require(:trust_transaction).permit(:date, :transactionAmount, :transactionType, :note)\n end",
"def create\n chef_server_rest.post(\"nodes\", data_for_save)\n self\n rescue Net::HTTPClientException => e\n # Chef Server before 12.3 rejects node JSON with 'policy_name' or\n # 'policy_group' keys, but 'policy_name' will be detected first.\n # Backcompat can be removed in 13.0\n if e.response.code == \"400\" && e.response.body.include?(\"Invalid key policy_name\")\n chef_server_rest.post(\"nodes\", data_for_save_without_policyfile_attrs)\n else\n raise\n end\n end",
"def network_connections_trust_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: DefaultApi.network_connections_trust ...'\n end\n # resource path\n local_var_path = '/api/v1/network/connections/trust'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json', 'application/xml', ])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'Array<String>' \n\n # auth_names\n auth_names = opts[:auth_names] || []\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DefaultApi#network_connections_trust\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def create\n @diseasesynonym = Diseasesynonym.new(diseasesynonym_params)\n\n respond_to do |format|\n if @diseasesynonym.save\n format.html { redirect_to @diseasesynonym, notice: 'Diseasesynonym was successfully created.' }\n format.json { render :show, status: :created, location: @diseasesynonym }\n else\n format.html { render :new }\n format.json { render json: @diseasesynonym.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @server = Server.new(params[:server])\n @server.account_id = @oeaccount.id \n respond_to do |format|\n if @server.save\n @server.send_create\n # NOTE TO MYSELF YOU NEED TO CHECK IF THE DEPLOYMENTS AND ROLES BELONG TO THE USER\n\tif params[:deployment_ids]\n #@server.deployments << Deployment.find(params[:deployments][:ids])\n @server.deployment_ids = params[:deployment_ids]\n\tend\n\tif params[:role_ids]\n #@server.roles << Role.find(params[:roles][:ids])\n @server.role_ids = params[:role_ids]\n\tend\n format.html { redirect_to servers_url, notice: 'Server was successfully created.' }\n format.json { render json: @server, status: :created, location: @server }\n else\n format.html { render action: \"new\" }\n format.json { render json: @server.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @want = Wants.new(want_params)\n last = {:LATITUDE => @want.LATITUDE, :LONGITUDE => @want.LONGITUDE}\n respond_to do |format|\n if @want.save\n session[:last] = last\n format.html { redirect_to wants_path, notice: 'Wants was successfully created.' }\n format.json { render :show, status: :created, location: @want }\n else\n format.html { render :new }\n format.json { render json: @want.errors, status: :unprocessable_entity }\n end\n end\n end",
"def upsert_marketo_lead(params)\n # todo: verify required fields? perhaps get form fields and validation logic from marketo?\n # removing params included by rails\n params.delete :action\n params.delete :controller\n params.delete :marketo_form\n # parse incoming values to json\n body = {\n #\"action\"=>\"createOnly\",\n \"lookupField\"=>\"email\",\n \"input\"=>[params]\n }.to_json\n @body = body\n # set post uri\n uri = URI(Config.get_create_lead_url)\n # setup http request\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n uri.query = \"access_token=#{get_marketo_token}\"\n request = Net::HTTP::Post.new(uri, { 'Content-Type' => 'application/json' })\n request.body = @body\n # make http request\n response = http.request(request)\n return response.body\n end",
"def flag_xms_system_to_be_normal \n put(\"/globalsettings.json/xms/normal\")\nend",
"def register\n usr=params[:user]\n pass=encryptor(usr[:password])\n confPass=encryptor(usr[:password_confirmation])\n #puts(pass)\n #puts(usr[:password])\n @key_name_prefix=\"grupo_\"\n options = {\n :body =>{\n \"firstName\": usr[:firstName],\n \"lastName\": usr[:lastName],\n \"email\": usr[:email],\n \"password\": pass,\n \"password_confirmation\": confPass\n }.to_json,\n :headers => {'Content-Type'=> 'application/json'\n }\n }\n #puts(options)\n resultsLDAP = HTTParty.post(\"http://192.168.99.104:4001/user/resources/ldapcruds\", options)\n if resultsLDAP.code == 201\n # options = {\n # :body => params.to_json,\n # :headers => {\n # 'Content-Type' => 'application/json'\n # }\n # }\n options = {\n :body =>{ \"user\":{\n \"firstName\": usr[:firstName],\n \"lastName\": usr[:lastName],\n \"email\": usr[:email],\n \"password\": pass,\n \"password_confirmation\": confPass\n }\n }.to_json,\n :headers => {'Content-Type'=> 'application/json'\n }\n }\n #puts(options)\n results = HTTParty.post(\"http://192.168.99.101:4051/users\", options)\n if results.code == 201\n user = results.parsed_response\n aux = params[:user]\n options = {\n :body =>{ \"notification_key\": \"\",\n \"user_id\": user\n }.to_json,\n :headers => {'Content-Type'=> 'application/json'\n }\n }\n results3 = HTTParty.post(\"http://192.168.99.101:4051/group_keys\".to_s,options)\n if results3.code == 201\n head 201\n else\n render json: results3.parsed_response, status: results3.code\n end\n else\n render json: results.parsed_response, status: results.code\n end\n elsif resultsLDAP.code == 400\n render json: {\"email\": [\"has already been taken\"]}.to_json, status: 422\n else\n renderError(\"Not Avalible\", 503, \"OpenLDAP server conection failed\")\n end\n end",
"def create\n megam_rest.post_license(to_hash)\n end",
"def post_request(secureNetId, secureKey, url)\n uri = URI.parse(url) # Parse the URI\n http = Net::HTTP.new(uri.host, uri.port) # New HTTP connection\n http.use_ssl = true # Must use SSL!\n req = Net::HTTP::Post.new(uri.request_uri) # HTTP POST request \n body = {} # Request body hash\n yield body # Build body of request\n req.body = body.to_json # Convert hash to json string\n req[\"Content-Type\"] = 'application/json' # JSON body\n req[\"Origin\"] = 'worldpay.com' # CORS origin\n req.basic_auth secureNetId, secureKey # HTTP basic auth\n res = http.request(req) # Make the call\n return JSON.parse(res.body) # Convert JSON to hashmap\nend",
"def create\n Puppet.debug(self.class.to_s.split('::').last + ': Calling create method :')\n\n response, status_code, headers = Puppet::Provider::Cudawaf.post('SecurityPolicy', message(resource), {})\n\n if status_code == 201\n @property_hash.clear\n return response, status_code, headers\n else\n raise(self.class.to_s.split('::').last + ': Not able to create the security policy. Please check the security policy api parameters')\n end\n end",
"def create\n @store_policies_information = Store::Policies::Information.new(params[:store_policies_information])\n\n respond_to do |format|\n if @store_policies_information.save\n format.html { redirect_to @store_policies_information, notice: 'Information was successfully created.' }\n format.json { render json: @store_policies_information, status: :created, location: @store_policies_information }\n else\n format.html { render action: \"new\" }\n format.json { render json: @store_policies_information.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @mattress = Mattress.new(params[:mattress])\n\n respond_to do |format|\n if @mattress.save\n format.html { redirect_to [:admin, @mattress], notice: 'Mattress was successfully created.' }\n format.json { render json: @mattress, status: :created, location: @mattress }\n else\n format.html { render action: \"new\" }\n format.json { render json: @mattress.errors, status: :unprocessable_entity }\n end\n end\n end",
"def skill_mastery_params\n params.require(:skill_mastery).permit(:skill_id, :requirement_1_id, :requirement_1_lv, :requirement_2_id, :requirement_2_lv)\n end",
"def priv_policy_params\n params.require(:priv_policy).permit(:store_name, :policy)\n end",
"def create\n @site_page_keystore = SitePageKeystore.new(site_page_keystore_params)\n\n respond_to do |format|\n if @site_page_keystore.save\n format.html { redirect_to site_page_keystores_path, notice: 'Site page keystore was successfully created.' }\n format.json { render action: 'show', status: :created, location: @site_page_keystore }\n else\n format.html { render action: 'new' }\n format.json { render json: @site_page_keystore.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ware_house = WareHouse.new(ware_house_params)\n\n respond_to do |format|\n if @ware_house.save\n format.html { redirect_to @ware_house, notice: 'Ware house was successfully created.' }\n format.json { render :show, status: :created, location: @ware_house }\n else\n format.html { render :new }\n format.json { render json: @ware_house.errors, status: :unprocessable_entity }\n end\n end\n end",
"def getTrustedParams(user, retcode=nil)\n token = getTrustedToken(user)\n return unless token\n token = %{<wst:RequestSecurityTokenResponse xmlns:wst=\"http://schemas.xmlsoap.org/ws/2005/02/trust\"><wst:RequestedSecurityToken><wsse:BinarySecurityToken xmlns:wsse=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\">#{token}</wsse:BinarySecurityToken></wst:RequestedSecurityToken><wsp:AppliesTo xmlns:wsp=\"http://schemas.xmlsoap.org/ws/2004/09/policy\"><wsa:EndpointReference xmlns:wsa=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\"><wsa:Address>uri:WindowsLiveID</wsa:Address></wsa:EndpointReference></wsp:AppliesTo></wst:RequestSecurityTokenResponse>}\n params = {}\n params['wa'] = securityalgorithm\n params['wresult'] = token\n params['wctx'] = retcode if retcode\n params\n end",
"def create\n @witness_salon = WitnessSalon.new(witness_salon_params)\n\n respond_to do |format|\n if @witness_salon.save\n format.html { redirect_to @witness_salon, notice: 'Witness salon was successfully created.' }\n format.json { render :show, status: :created, location: @witness_salon }\n else\n format.html { render :new }\n format.json { render json: @witness_salon.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @machine = Machine.new(machine_params)\n # authorize(@machine)\n respond_to do |format|\n if @machine.save\n format.html { redirect_to @machine, notice: 'Machine was successfully created.' }\n format.json { render :show, status: :created, location: @machine }\n else\n format.html { render :new }\n format.json { render json: @machine.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n byebug\n @admin_skill = Admin::Skill.new(admin_skill_params)\n\n if @admin_skill.save\n render json: @admin_skill, status: :created, location: @admin_skill\n else\n render json: @admin_skill.errors, status: :unprocessable_entity\n end\n end",
"def create\n @identity = Identity.new(identity_params)\n\n if @identity.save\n render json: @identity, status: :created, location: [:admin, @identity]\n else\n render json: @identity.errors, status: :unprocessable_entity\n end\n end",
"def wondersoft_create\n Rails.logger.info_log.info \" I,[#{Time.now.strftime(\"%Y-%m-%d %H:%M:%S %Z\")}]\" \"INFO -- : Entered in SyncsettingsController wondersoft_create method\"\n begin\n params.permit!\n data={wonder_soft:{user_name:params[:username],password:params[:password],database_name:params[:databasename],server_name:params[:servername],manual_sync_time:params[:manual_sync_time]}}\n @wondersoft=RestClient.post $api_service+'/sync_settings/wondersoft_connection',data\n flash[:notice] = \"WonderSoft Connection successfully created\"\n rescue => e\n Rails.logger.custom_log.error { \"#{e} SyncsettingsController wondersoft_create method\" } \n end\n end",
"def create\n @symptom = Symptom.new(symptom_params)\n\n if @symptom.save\n render json: @symptom, status: :created\n else\n render json: @symptom.errors, status: :unprocessable_entity\n end\n end",
"def create\n @charity_trustee = CharityTrustee.new(charity_trustee_params)\n\n respond_to do |format|\n if @charity_trustee.save\n format.html { redirect_to @charity_trustee, notice: 'Charity trustee was successfully created.' }\n format.json { render :show, status: :created, location: @charity_trustee }\n else\n format.html { render :new }\n format.json { render json: @charity_trustee.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @stress = current_user.stresses.new(params[:stress])\n\n respond_to do |format|\n if @stress.save\n flash[:notice] = 'Stress was successfully created.'\n format.html { redirect_to(@stress) }\n else\n format.html { render :action => \"new\" }\n end\n end\n end",
"def create\n authorize! :create_almacen,Sigesp::Solicitud \n unidad = session['unidad'] \n return render json: { unidad: \"Esta Unidad Administrativa no tiene Numero de Control \" }, status: :unprocessable_entity if Sigesp::CtrlRequisicion.control_compra(unidad).nil?\n\n @solicitudes = Sigesp::Solicitud.crear_solicitudes_almacen(sigesp_solicitud_alamcen_params)\n @grupoSolicitud = SolicitudGrupo.new\n @solicitudes.each do |solicitud|\n @grupoSolicitud.solicitudes << solicitud \n end\n if @grupoSolicitud.valid? \n @grupoSolicitud.guardar(unidad,current_usuario)\n return render json: { url: sigesp_solicitudsalmacen_path(@grupoSolicitud.solicitudes[0])} \n else\n return render json:@grupoSolicitud.errors ,status: :unprocessable_entity\n end \n end",
"def signed_post_request url, body\n body_json= body.to_json\n token = jwt_post_signature url, body_json\n HTTParty.post('http://localhost:5000'+url,\n {headers:{\n \"Authorization\"=>\"JWT token=\\\"#{token}\\\"\",\n \"Content-Type\"=> \"application/json;charset=utf-8\",\n },\n body: body_json}\n )\n\n end",
"def mv_request(user, lp)\n\turl = lp + \"/mvs/\"\n\n\tidentifying_factors = {}\n\tauthenticating_factors = {}\n\n authenticating_factors = Hash.new.tap do |h|\n h['password'] = user['password'] if user['password']\n end\n\n identifying_factors = Hash.new.tap do |h|\n h[\"firstName\"] = user[\"firstName\"] if user[\"firstName\"]\n h[\"lastName\"] = user[\"lastName\"] if user[\"lastName\"]\n h[\"email\"] = user[\"email\"] if user[\"email\"]\n h[\"memberId\"] = user[\"memberId\"] if user[\"memberId\"]\n end\n\n\tbody = {\"identifyingFactors\" => identifying_factors}.to_json\n\n\trequest = {\"url\" => url, \"body\" => body}\n\n\treturn request\nend",
"def get_trust_objects_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: NsxComponentAdministrationApi.get_trust_objects ...\"\n end\n # resource path\n local_var_path = \"/trust-management\"\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'TrustManagementData')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: NsxComponentAdministrationApi#get_trust_objects\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def create\n @user = User.find(params[:user_id])\n\t @resourcethread = @user.resource_threads.find(params[:resource_thread_id])\n @resourcethread.increment!(:resource_count)\n @resource = @resourcethread.resources.create(resource_params)\n @resource.update_attribute(:trust, 100)\n @resource.update_attribute(:user, @current_user)\n redirect_to user_resource_thread_path(@user, @resourcethread)\n end",
"def diseasesynonym_params\n params.require(:diseasesynonym).permit(:synonym)\n end",
"def csr_params\n params.require(:csr).permit(\n :user_id,\n :hostname,\n :cert_password,\n :cert_rsa_key_length,\n :country,\n :dn_st,\n :dn_l,\n :dn_o,\n :dn_ou\n )\n end",
"def create\n @xmt_mgr_password = Xmt::Password.new(xmt_mgr_password_params)\n\n respond_to do |format|\n if @xmt_mgr_password.save\n format.html { redirect_to @xmt_mgr_password, notice: 'Password was successfully created.' }\n format.json { render :show, status: :created, location: @xmt_mgr_password }\n else\n format.html { render :new }\n format.json { render json: @xmt_mgr_password.errors, status: :unprocessable_entity }\n end\n end\n end",
"def addhost(config)\n\n uri = URI.parse(\"#{config[\"addurl\"]}\")\n node = { \"EntityType\" => \"Orion.Nodes\", \"IPAddress\" => \"#{config[\"ipaddr\"]}\",\n \"Caption\"=> \"#{config[\"nodename\"]}\", \"DynamicIP\" => \"False\", \"EngineID\" => \"#{config[\"engineid\"]}\", \n \"Status\" => 1, \"UnManaged\" => \"False\", \"Allow64BitCounters\" => \"True\", \n \"SysObjectID\" => \"\", \"MachineType\" => \"\", \"VendorIcon\" => \"\", \n \"ObjectSubType\" => \"SNMP\", \"SNMPVersion\" => 2, \"Community\" => \"#{config[\"community\"]}\",\n }\n\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n request = Net::HTTP::Post.new(uri.request_uri, initheader = {'Content-Type' =>'application/json'})\n request.body = node.to_json\n request.basic_auth(\"#{config[\"username\"]}\", \"#{config[\"password\"]}\")\n\n response = http.request(request)\nend",
"def have_secret\n tmurl = params[:trustme]\n tmheader = request.headers[\"HTTP_X_TRUSTME\"]\n secret = Rails.application.config.admin_secret\n logger.info \"checking tmurl #{tmurl}, tmheader #{tmheader}, secret #{secret}\"\n if !(tmurl == secret or tmheader == secret)\n head :unauthorized\n end\n end",
"def trusts_to(selected_trustee)\n self.trusts.where(:trustee_id => selected_trustee.id)\n end",
"def create\n puts management_params\n @management = Management.new(management_params)\n if @management.save\n render json: @management, status: :created\n else \n render json: @management.errors, status: :unprocessable_entity\n end\n end",
"def create\n @stone = Stone.new(stone_params)\n\n \n if @stone.save\n respond_with @stone\n else\n render json: @stone.errors, status: :unprocessable_entity \n end\n \n \n end",
"def create\n @physician = Physician.new(params[:physician])\n\n respond_to do |format|\n if @physician.save\n format.html { redirect_to @physician, :notice => 'Physician was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @physician.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @medication = Medication.new(params[:medication])\n @medication.user_id = current_user.id\n @medication.pass = @medication.build_pass(serial_number: SerialNumberGenerator.generate,\n auth_token: AuthTokenGenerator.token)\n\n respond_to do |format|\n if @medication.save!\n format.html { redirect_to medications_path, notice: 'Medication was successfully created.' }\n format.json { render json: @medication, status: :created, location: @medication }\n else\n format.html { render action: \"new\" }\n format.json { render json: @medication.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post_privileges_target(privileges_targe)\n privileges_target = {\n \"name\"=>nil, \n \"repositoryTargetId\"=>nil,\n \"description\"=>\"\", \n \"repositoryId\"=>\"\",\n \"repositoryGroupId\"=>\"\",\n \"method\"=>[\"create\",\"read\",\"update\",\"delete\"],\n \"type\"=>\"target\"\n }.merge(privileges_targe);\n request = {\"data\"=>privileges_target}\n post(\"#{url_base}/privileges_target\", request)[\"data\"]\n end",
"def certifying_body_params\n params.require(:certifying_body).permit(:name, :mission, :url)\n end",
"def synonymprotein_params\n params.require(:synonymprotein).permit(:synonymname)\n end"
] |
[
"0.5523912",
"0.55049187",
"0.5178948",
"0.51492435",
"0.5119799",
"0.5092038",
"0.5042583",
"0.50357723",
"0.49923077",
"0.49550903",
"0.4938231",
"0.49223912",
"0.48975712",
"0.48963857",
"0.48731193",
"0.48671374",
"0.48496756",
"0.4841221",
"0.48371908",
"0.48151177",
"0.4814602",
"0.4784417",
"0.4762523",
"0.4755378",
"0.4748685",
"0.47483358",
"0.47402862",
"0.47265753",
"0.47124133",
"0.46965495",
"0.46951213",
"0.46931309",
"0.46788374",
"0.46783918",
"0.46591932",
"0.46569255",
"0.46461007",
"0.463941",
"0.46276316",
"0.46107554",
"0.46107256",
"0.46028513",
"0.46012133",
"0.46008357",
"0.4596386",
"0.4590516",
"0.45863178",
"0.45776027",
"0.45771888",
"0.4575005",
"0.45746124",
"0.45669162",
"0.45568737",
"0.45498997",
"0.45476294",
"0.45392942",
"0.4529104",
"0.45269328",
"0.45259255",
"0.45255727",
"0.45240098",
"0.4521774",
"0.4514608",
"0.4506617",
"0.45065182",
"0.45055458",
"0.4503543",
"0.449548",
"0.44944906",
"0.44925788",
"0.4489365",
"0.44855526",
"0.44830534",
"0.44829726",
"0.44720152",
"0.44707075",
"0.44629875",
"0.44573134",
"0.4455011",
"0.44543323",
"0.44534248",
"0.4452627",
"0.44484073",
"0.44443604",
"0.4440027",
"0.44379026",
"0.4427126",
"0.44240046",
"0.44139624",
"0.44094017",
"0.44086507",
"0.440608",
"0.4403542",
"0.44031048",
"0.44030285",
"0.4402974",
"0.44026548",
"0.44017795",
"0.43897194",
"0.43858853"
] |
0.4850628
|
16
|
PATCH/PUT /trust_moneys/1 PATCH/PUT /trust_moneys/1.json
|
def update
respond_to do |format|
if @trust_money.update(trust_money_params)
format.html { redirect_to @trust_money, notice: 'Trust money was successfully updated.' }
format.json { render :show, status: :ok, location: @trust_money }
else
format.html { render :edit }
format.json { render json: @trust_money.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update!(**args)\n @trust_prop = args[:trust_prop] if args.key?(:trust_prop)\n end",
"def update!(**args)\n @trust_settings_for_client = args[:trust_settings_for_client] if args.key?(:trust_settings_for_client)\n end",
"def update\n respond_to do |format|\n if @trustee.update(trustee_params)\n format.html { redirect_to @trustee, notice: 'Trustee was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @trustee.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @metadata = args[:metadata] if args.key?(:metadata)\n @pomeroy_id = args[:pomeroy_id] if args.key?(:pomeroy_id)\n @trust_level = args[:trust_level] if args.key?(:trust_level)\n end",
"def update\n respond_to do |format|\n if @trust_transaction.update(trust_transaction_params)\n format.html { redirect_to @trust_transaction, notice: 'Trust transaction was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @trust_transaction.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize! :update, @theorem\n if @theorem.update(theorem_params)\n render json: @theorem, status: :ok, location: @theorem\n else\n render json: @theorem.errors, status: :unprocessable_entity\n end\n end",
"def update\n @moresmalltrial = Moresmalltrial.find(params[:id])\n\n respond_to do |format|\n if @moresmalltrial.update_attributes(params[:moresmalltrial])\n format.html { redirect_to @moresmalltrial, notice: 'Moresmalltrial was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @moresmalltrial.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize! :update_almacen,Sigesp::Solicitud\n if @sigesp_solicitud.update(sigesp_solicitud_alamcen_params)\n return render json: { url: sigesp_solicitudsalmacen_path(@sigesp_solicitud)} \n else\n return render json:@sigesp_solicitud.errors ,status: :unprocessable_entity\n end \n end",
"def update\n @request_for_change.set_manager(force: true)\n @request_for_change.set_security_officer(force: true)\n\n respond_to do |format|\n if @request_for_change.update(request_for_change_params)\n format.html { redirect_to edit_request_for_change_path(@request_for_change), notice: 'Request for change was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @request_for_change.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @source_trust = args[:source_trust] if args.key?(:source_trust)\n end",
"def update\n respond_to do |format|\n if @trustees_minute.update(trustees_minute_params)\n format.html { redirect_to @trustees_minute, notice: 'Trustees minute was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @trustees_minute.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @third_party_claims = args[:third_party_claims] if args.key?(:third_party_claims)\n end",
"def update\n keystone.update_tenant({:id=>params[:id],:name=>params[:name],:description=>params[:description],:enabled=>params[:enabled]})\n respond_to do |format|\n format.html { redirect_to tenants_path, :notice => 'Tenant was successfully updated.' }\n format.json { head :ok }\n end\n end",
"def update\n @identity = Identity.find(params[:id])\n\n if @identity.update(identity_params)\n head :no_content\n else\n render json: @identity.errors, status: :unprocessable_entity\n end\n end",
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def patch_kubernetes_trusted_registries_policy_with_http_info(moid, kubernetes_trusted_registries_policy, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: KubernetesApi.patch_kubernetes_trusted_registries_policy ...'\n end\n # verify the required parameter 'moid' is set\n if @api_client.config.client_side_validation && moid.nil?\n fail ArgumentError, \"Missing the required parameter 'moid' when calling KubernetesApi.patch_kubernetes_trusted_registries_policy\"\n end\n # verify the required parameter 'kubernetes_trusted_registries_policy' is set\n if @api_client.config.client_side_validation && kubernetes_trusted_registries_policy.nil?\n fail ArgumentError, \"Missing the required parameter 'kubernetes_trusted_registries_policy' when calling KubernetesApi.patch_kubernetes_trusted_registries_policy\"\n end\n # resource path\n local_var_path = '/api/v1/kubernetes/TrustedRegistriesPolicies/{Moid}'.sub('{' + 'Moid' + '}', CGI.escape(moid.to_s))\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n content_type = @api_client.select_header_content_type(['application/json', 'application/json-patch+json'])\n if !content_type.nil?\n header_params['Content-Type'] = content_type\n end\n header_params[:'If-Match'] = opts[:'if_match'] if !opts[:'if_match'].nil?\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body] || @api_client.object_to_http_body(kubernetes_trusted_registries_policy)\n\n # return_type\n return_type = opts[:debug_return_type] || 'KubernetesTrustedRegistriesPolicy'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['cookieAuth', 'http_signature', 'oAuth2', 'oAuth2']\n\n new_options = opts.merge(\n :operation => :\"KubernetesApi.patch_kubernetes_trusted_registries_policy\",\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: KubernetesApi#patch_kubernetes_trusted_registries_policy\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def update!(params)\n res = @client.put(path, nil, params, \"Content-Type\" => \"application/json\")\n @attributes = res.json if res.status == 201\n res\n end",
"def update\n @mattress = Mattress.find(params[:id])\n\n respond_to do |format|\n if @mattress.update_attributes(params[:mattress])\n format.html { redirect_to [:admin, @mattress], notice: 'Mattress was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @mattress.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_current_logged_in_users_password(args = {}) \n put(\"/users.json/current/password\", args)\nend",
"def update\n authorize @attorney\n respond_to do |format|\n if @attorney.update(attorney_params)\n format.html { redirect_to @attorney, success: I18n.t('notices.updated', entity: Attorney.model_name.human, title: @attorney.name) }\n format.json { render :show, status: :ok, location: @attorney }\n else\n format.html { render :edit }\n format.json { render json: @attorney.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @mystic.update(mystic_params)\n format.html { redirect_to @mystic, notice: 'Mystic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @mystic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_resource(resource, params)\n resource.role_id = 1\n resource.update_without_password(params)\n end",
"def flag_xms_system_to_be_normal \n put(\"/globalsettings.json/xms/normal\")\nend",
"def update\n @mint_coin = @coin.mint_coins.find(params[:id])\n\n respond_to do |format|\n if @mint_coin.update_attributes(params[:mint_coin])\n format.html { redirect_to coin_mint_coins_url([@coin]), :notice => 'Mint coin was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @mint_coin.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n authenticate_user!\n authorize! :index, @user, :message => 'Not authorized as an administrator.'\n \n @key_policy_maker = KeyPolicyMaker.find(params[:id])\n\n respond_to do |format|\n if @key_policy_maker.update_attributes(params[:key_policy_maker])\n format.html { redirect_to :back, notice: 'Key policy maker successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @key_policy_maker.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @symptom = Symptom.find(params[:id])\n\n if @symptom.update(symptom_params)\n render json: @symptom, status: :updated\n else\n render json: @symptom.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @claim.update(claim_params)\n format.html { redirect_to @claim, notice: 'Claim was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @claim.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_by_body\n @person = Person.find(person_update_params[:id])\n\n if @person.update_attributes(person_update_params)\n render json: { status: 'PUT Success' }, status: :ok\n else\n render json: { status: 'Error', message:'Error updating person', person: @person.errors }, status: :unprocessable_entity\n end\n end",
"def update\n authorize! :update, @user, :message => t('errors.messages.not_authorized_as_manager')\n @marina = Marina.find(params[:id])\n\n respond_to do |format|\n if @marina.update_attributes(params[:marina])\n format.html { redirect_to @marina, notice: 'Marina was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @marina.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @req.update(req_params)\n flash[:notice] = \"Your requirement has been saved\"\n format.html { redirect_to @req }\n format.json { render :show, status: :ok, location: @req }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @req.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_tenant_maintenance_window(args = {}) \n id = args['id']\n temp_path = \"/tenants.json/maintenance/{tenantId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"tenantId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend",
"def update\n @my_ministry = MyMinistry.find(params[:id])\n\n respond_to do |format|\n if @my_ministry.update_attributes(params[:my_ministry])\n format.html { redirect_to @my_ministry, notice: 'My ministry was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @my_ministry.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @attorney.update(attorney_params)\n current_user.email = (attorney_params)[:email]\n current_user.password = (attorney_params)[:password] if (attorney_params)[:password]\n current_user.image = (attorney_params)[:profile_image]\n current_user.first_name = (attorney_params)[:first_name]+\" \"+(attorney_params)[:middle_name]+\" \"+(attorney_params)[:last_name]\n current_user.save\n sign_in(current_user, :bypass => true)\n format.html { redirect_to @attorney, notice: 'Attorney was successfully updated.' }\n format.json { render :show, status: :ok, location: @attorney }\n else\n format.html { render :edit }\n format.json { render json: @attorney.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_kubernetes_trusted_registries_policy_with_http_info(moid, kubernetes_trusted_registries_policy, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: KubernetesApi.update_kubernetes_trusted_registries_policy ...'\n end\n # verify the required parameter 'moid' is set\n if @api_client.config.client_side_validation && moid.nil?\n fail ArgumentError, \"Missing the required parameter 'moid' when calling KubernetesApi.update_kubernetes_trusted_registries_policy\"\n end\n # verify the required parameter 'kubernetes_trusted_registries_policy' is set\n if @api_client.config.client_side_validation && kubernetes_trusted_registries_policy.nil?\n fail ArgumentError, \"Missing the required parameter 'kubernetes_trusted_registries_policy' when calling KubernetesApi.update_kubernetes_trusted_registries_policy\"\n end\n # resource path\n local_var_path = '/api/v1/kubernetes/TrustedRegistriesPolicies/{Moid}'.sub('{' + 'Moid' + '}', CGI.escape(moid.to_s))\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n content_type = @api_client.select_header_content_type(['application/json', 'application/json-patch+json'])\n if !content_type.nil?\n header_params['Content-Type'] = content_type\n end\n header_params[:'If-Match'] = opts[:'if_match'] if !opts[:'if_match'].nil?\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body] || @api_client.object_to_http_body(kubernetes_trusted_registries_policy)\n\n # return_type\n return_type = opts[:debug_return_type] || 'KubernetesTrustedRegistriesPolicy'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['cookieAuth', 'http_signature', 'oAuth2', 'oAuth2']\n\n new_options = opts.merge(\n :operation => :\"KubernetesApi.update_kubernetes_trusted_registries_policy\",\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: KubernetesApi#update_kubernetes_trusted_registries_policy\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def update\n @admin_skill = Admin::Skill.find(params[:id])\n\n if @admin_skill.update(admin_skill_params)\n head :no_content\n else\n render json: @admin_skill.errors, status: :unprocessable_entity\n end\n end",
"def update_current_tenant_maintenance_window(args = {}) \n id = args['id']\n temp_path = \"/tenants.json/maintenance\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"tenantId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend",
"def update\n # this action is not provided for partyroles\n end",
"def update_current_logged_in_users_password(args = {}) \n id = args['id']\n temp_path = \"/users.json/current/password\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"userId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend",
"def update_resource(resource, params)\n check_id_uniformity(params)\n resource.assign_attributes(json_api_attributes(params))\n authorize resource, :update?\n resource.save!\n resource\n end",
"def update_user_for_tenant(args = {}) \n id = args['id']\n temp_path = \"/tenants.json/{tenantId}/users/{userId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"tenantId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend",
"def update\n @skill_set = SkillSet.find(params[:id])\n\n respond_to do |format|\n if @skill_set.update_attributes(params[:skill_set])\n format.html { redirect_to @skill_set, notice: 'Skill set was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @skill_set.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @witness = Witness.find(params[:id])\n\n respond_to do |format|\n if @witness.update_attributes(params[:witness])\n # commented so hosts font receive emails off season\n # if(params[:witness][:host_id].present?)\n # HostMailer.witness_assigned(\n # params[:witness][:host_id],\n # @witness.id,\n # I18n.locale\n # ).deliver\n\n #@host = Host.find(params[:witness][:host_id])\n #@host.update_attributes(assignment_time: Time.now.utc.localtime)\n #end\n\n\n \n format.json { render json: @witness, status: :created, location: @witness }\n else\n format.json { render json: @witness.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @expected_action = args[:expected_action] if args.key?(:expected_action)\n @express = args[:express] if args.key?(:express)\n @firewall_policy_evaluation = args[:firewall_policy_evaluation] if args.key?(:firewall_policy_evaluation)\n @hashed_account_id = args[:hashed_account_id] if args.key?(:hashed_account_id)\n @headers = args[:headers] if args.key?(:headers)\n @ja3 = args[:ja3] if args.key?(:ja3)\n @requested_uri = args[:requested_uri] if args.key?(:requested_uri)\n @site_key = args[:site_key] if args.key?(:site_key)\n @token = args[:token] if args.key?(:token)\n @transaction_data = args[:transaction_data] if args.key?(:transaction_data)\n @user_agent = args[:user_agent] if args.key?(:user_agent)\n @user_ip_address = args[:user_ip_address] if args.key?(:user_ip_address)\n @waf_token_assessment = args[:waf_token_assessment] if args.key?(:waf_token_assessment)\n end",
"def update\n @atr = Atr.find(params[:id])\n @mcr_atr=@atr.mcr_atr\n @man_rsc=@mcr_atr.man_rsc\n http = Net::HTTP.new(\"192.168.119.163\",9999)\n post_params = {'value' => @atr.value}\n request = Net::HTTP::Put.new(\"/mbs/#{@man_rsc.domain}/#{@man_rsc.name}/#{@mcr_atr.name}/#{@atr.name}\")\n request.set_form_data(post_params)\n begin\n response = http.request(request)\n rescue Errno::ECONNREFUSED\n end\n\n respond_to do |format|\n if @atr.update_attributes(params[:atr])\n format.html { redirect_to :back }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @atr.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @patient = Patient.find(params[:id])\n\n respond_to do |format|\n if @patient.update_attributes(params[:patient].except(:person_attributes))\n format.html { redirect_to people_url, notice: 'Patient was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @patient.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @taxinomy = Taxinomy.find(params[:id])\n\n respond_to do |format|\n if @taxinomy.update_attributes(params[:taxinomy])\n format.html { redirect_to @taxinomy, notice: 'Taxinomy was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @taxinomy.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @skill = Skill.find(params[:id])\n\n if @skill.update(skill_params)\n head :no_content\n else\n render json: @skill.errors, status: :unprocessable_entity\n end\n end",
"def update_users_password(args = {}) \n put(\"/users.json/backoffice/#{args[:userId]}/password/#{args[:password]}\", args)\nend",
"def update_users_password(args = {}) \n put(\"/users.json/backoffice/#{args[:userId]}/password/#{args[:password]}\", args)\nend",
"def update\n# respond_to do |format|\n# if @req.update(req_params)\n format.json { render :json => {:status => 'success'}}\n# format.html { redirect_to @req, notice: 'Req was successfully updated.' }\n# format.json { render :show, status: :ok, location: @req }\n# else\n format.json { render :json => {:status => 'failed'}}\n# format.html { render :edit }\n# format.json { render json: @req.errors, status: :unprocessable_entity }\n# end\n# end\n end",
"def update\n @stress = current_user.stresses.find(params[:id])\n\n respond_to do |format|\n if @stress.update_attributes(params[:stress])\n flash[:notice] = 'Stress was successfully updated.'\n format.html { redirect_to(@stress) }\n else\n format.html { render :action => \"edit\" }\n end\n end\n end",
"def update\n @server = Server.find(params[:id])\n checkaccountobject(\"servers\",@server)\n respond_to do |format|\n if @server.update_attributes(params[:server])\n @server.send_update\n format.html { redirect_to @server, notice: 'Server was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @server.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @person.seat\n render json: {errors: 'Cannot update a seated person'}, status: 422\n else\n @person.update person_params\n render json: @person\n end\n end",
"def update\n @strain = Strain.find(params[:id])\n\n respond_to do |format|\n if @strain.update_attributes(params[:strain])\n format.html { redirect_to @strain, :notice => 'Strain was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @strain.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update \n sneaker = find_sneaker\n # update! exceptions will be handled by the rescue_from ActiveRecord::RecordInvalid code\n sneaker.update(sneaker_params)\n render json: sneaker\n end",
"def update\n @grant = Grant.find(params[:id])\n\n respond_to do |format|\n if @grant.update_attributes(params[:grant])\n format.html { redirect_to root_url, notice: 'Training was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @grant.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @request = @skill.requests.find(params[:id])\n\n respond_to do |format|\n if @request.update_attributes(params[:request])\n format.html { redirect_to myrequests_path, notice: 'request was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @request.errors, status: :unprocessable_entity }\n end\n end\n end",
"def updatePendingPay\n if !(Integer(params[:id]) rescue false)\n renderError(\"Not Acceptable (Invalid Params)\", 406, \"The parameter id is not an integer\")\n return -1\n end\n options = {\n :body => params.to_json,\n :headers => {\n 'Content-Type' => 'application/json'\n }\n }\n resul = HTTParty.get(\"http://192.168.99.101:4055/lists/\"+params[:id])\n user = resul[\"user_id\"]\n if user == (@current_user[\"id\"]).to_i\n results = HTTParty.put(\"http://192.168.99.101:4055/lists/\"+params[:id], options)\n if results.code == 201\n head 201\n else\n render json: results.parsed_response, status: results.code\n end\n else\n renderError(\"Not Acceptable (Invalid Params)\", 403, \"The user does not have permmision\")\n end\n end",
"def update\n authorize! :manage, @node\n\n respond_to do |format|\n if @node.update_attributes(params[:node])\n format.html { redirect_to @node, notice: 'Node was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @node.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @microplst = Microplst.find(params[:id])\n\n respond_to do |format|\n if @microplst.update_attributes(params[:microplst])\n format.html { redirect_to @microplst, notice: 'Microplst was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @microplst.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @infrastructure = Infrastructure.find(params[:id])\n checkaccountobject(\"infrastructures\",@infrastructure)\n\n respond_to do |format|\n if @infrastructure.update_attributes(params[:infrastructure])\n format.html { redirect_to @infrastructure, notice: 'Infrastructure was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @infrastructure.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @orphan.update(orphan_params)\n format.html { redirect_to @orphan, notice: 'Orphan was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @orphan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @allow_open = args[:allow_open] if args.key?(:allow_open)\n @create_time = args[:create_time] if args.key?(:create_time)\n @description = args[:description] if args.key?(:description)\n @labels = args[:labels] if args.key?(:labels)\n @mtls_policy = args[:mtls_policy] if args.key?(:mtls_policy)\n @name = args[:name] if args.key?(:name)\n @server_certificate = args[:server_certificate] if args.key?(:server_certificate)\n @update_time = args[:update_time] if args.key?(:update_time)\n end",
"def update\n @skill = Skill.find(params[:id])\n\t\tauthorize! :update, Skill\n\t\t\n respond_to do |format|\n if @skill.update_attributes(params[:skill])\n format.html { redirect_to skills_path, notice: 'Skill was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @skill.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @patient = Patient.find(params[:patient_id]) \n @managed_care = ManagedCare.find(params[:id])\n @managed_care.updated_user = current_user.login_name\n @subscriber = @patient.subscribers.all\n @providers = @patient.providers\n @groups = @patient.groups \n \n respond_to do |format|\n if @managed_care.update_attributes(params[:managed_care])\n format.html { redirect_back_or_default patient_managed_cares_path(:patient_id =>params[:patient_id]), notice: 'Managed care was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @managed_care.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @store_policies_information = Store::Policies::Information.find(params[:id])\n\n respond_to do |format|\n if @store_policies_information.update_attributes(params[:store_policies_information])\n format.html { redirect_to @store_policies_information, notice: 'Information was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @store_policies_information.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @request_id = args[:request_id] if args.key?(:request_id)\n @resource_info = args[:resource_info] if args.key?(:resource_info)\n @validate_only = args[:validate_only] if args.key?(:validate_only)\n end",
"def update\n respond_to do |format|\n if @special_requirement.update(special_requirement_params)\n format.html { redirect_to @special_requirement, notice: 'Special requirement was successfully updated.' }\n format.json { render :show, status: :ok, location: @special_requirement }\n else\n format.html { render :edit }\n format.json { render json: @special_requirement.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize! :edit, @questionnaire\n\n @questionnaire.load_JSON(params[:questionnaire], current_user)\n\n respond_to do |format|\n# if @questionnaire.update_attributes(params[:questionnaire])\n format.html { redirect_to @questionnaire, notice: 'Kysymyslomakkeen muokkaaminen onnistui.' }\n format.json { head :no_content }\n# else\n# format.html { render action: \"edit\" }\n# format.json { render json: @questionnaire.errors, status: :unprocessable_entity }\n# end\n\n end\n end",
"def update\n respond_to do |format|\n if @mystock.update(mystock_params)\n format.html { redirect_to @mystock, notice: 'mystock was successfully updated.' }\n format.json { render :show, status: :ok, location: @mystock }\n else\n format.html { render :edit }\n format.json { render json: @mystock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n # { clinic: {id: references, \"license_id\"=>nil, \"name\"=>string } }\n \n if @clinic.update_attributes(params[:clinic].except(:api_license_id))\n head :no_content\n else\n render json: clinic.errors.full_messages, status: :unprocessable_entity\n end\n end",
"def update\n @special_needs_type = SpecialNeedsType.find(params[:id])\n\n respond_to do |format|\n if @special_needs_type.update_attributes(params[:special_needs_type])\n format.html { redirect_to @special_needs_type, :notice => 'Tipo de necessidade especial atualizada com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @special_needs_type.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @server1 = Server1.find(params[:id])\n\n respond_to do |format|\n if @server1.update_attributes(params[:server1])\n format.html { redirect_to @server1, notice: 'Server was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @server1.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @premise.update(premise_params)\n format.html { redirect_to @premise, notice: 'Premise was successfully updated.' }\n format.json { render :show, status: :ok, location: @premise }\n else\n format.html { render :edit }\n format.json { render json: @premise.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n head :unauthorized\n end",
"def update\n authorize :resquest_type, :update?\n respond_to do |format|\n if @resquest_type.update(resquest_type_params)\n format.html { redirect_to @resquest_type, notice: 'Resquest type was successfully updated.' }\n format.json { render :show, status: :ok, location: @resquest_type }\n else\n format.html { render :edit }\n format.json { render json: @resquest_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @restriction = Restriction.find(params[:id])\n\n if @restriction.update(params[:restriction])\n head :no_content\n else\n render json: @restriction.errors, status: :unprocessable_entity\n end\n end",
"def modify_server(server_uuid, params)\n data = { \"server\" => params }\n json = JSON.generate data\n response = put \"server/#{server_uuid}\", json\n\n response\n end",
"def update!(**args)\n @behavioral_trust_verdict = args[:behavioral_trust_verdict] if args.key?(:behavioral_trust_verdict)\n @card_testing_verdict = args[:card_testing_verdict] if args.key?(:card_testing_verdict)\n @stolen_instrument_verdict = args[:stolen_instrument_verdict] if args.key?(:stolen_instrument_verdict)\n @transaction_risk = args[:transaction_risk] if args.key?(:transaction_risk)\n end",
"def update\n if request.content_type == \"application/json\"\n # .update is like a \"update people set ...\" in sql\n if @person.update(person_params)\n render json: @person\n else\n render json: @person.errors, status: :not_found\n end\n else\n render status: :bad_request\n end\n end",
"def update\n @mostsmallmission = Mostsmallmission.find(params[:id])\n\n respond_to do |format|\n if @mostsmallmission.update_attributes(params[:mostsmallmission])\n format.html { redirect_to @mostsmallmission, notice: 'Mostsmallmission was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @mostsmallmission.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @precious_metal = PreciousMetal.find(params[:id])\n\n respond_to do |format|\n if @precious_metal.update_attributes(params[:precious_metal])\n format.html { redirect_to @precious_metal, :notice => 'Precious metal was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @precious_metal.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @person.authorizer = current_person\n\n respond_to do |format|\n if @person.update(person_params)\n @person.invite!(current_person) if params['resend_invite']=='true' \n \n format.html { redirect_to :people, notice: 'Profile successfully updated.' }\n format.json { render :show, status: :ok, location: @person }\n else\n format.html { render :edit }\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @moresmallarmorinfo = Moresmallarmorinfo.find(params[:id])\n\n respond_to do |format|\n if @moresmallarmorinfo.update_attributes(params[:moresmallarmorinfo])\n format.html { redirect_to @moresmallarmorinfo, notice: 'Moresmallarmorinfo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @moresmallarmorinfo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n #@user = User.find(params[:id])\n \n if @gym.update(gym_params)\n render JSON: @gym\n else\n render JSON: @gym.errors, status: :unprocessable_entity\nend\nend",
"def update\n respond_to do |format|\n if @witness_salon.update(witness_salon_params)\n format.html { redirect_to @witness_salon, notice: 'Witness salon was successfully updated.' }\n format.json { render :show, status: :ok, location: @witness_salon }\n else\n format.html { render :edit }\n format.json { render json: @witness_salon.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_resource(resource, params)\n resource.update_without_password(params)\n end",
"def update_resource(resource, params)\n resource.update_without_password(params)\n end",
"def update_resource(resource, params)\n resource.update_without_password(params)\n end",
"def update_resource(resource, params)\n resource.update_without_password(params)\n end",
"def update_resource(resource, params)\n resource.update_without_password(params)\n end",
"def update_resource(resource, params)\n resource.update_without_password(params)\n end",
"def update_resource(resource, params)\n resource.update_without_password(params)\n end",
"def update_resource(resource, params)\n resource.update_without_password(params)\n end",
"def update!(**args)\n @bare_metal_node_pool_id = args[:bare_metal_node_pool_id] if args.key?(:bare_metal_node_pool_id)\n @validate_only = args[:validate_only] if args.key?(:validate_only)\n end",
"def update\n @create_request_skill = CreateRequestSkill.find(params[:id])\n\n respond_to do |format|\n if @create_request_skill.update_attributes(params[:create_request_skill])\n format.html { redirect_to @create_request_skill, notice: 'Create request skill was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @create_request_skill.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @matrixspecy.update(matrixspecy_params)\n format.html { redirect_to @matrixspecy, notice: 'Matrixspecy was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @matrixspecy.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @skillset.update(skillset_params)\n format.html { redirect_to @skillset, notice: 'Skillset was successfully updated.' }\n format.json { render :show, status: :ok, location: @skillset }\n else\n format.html { render :edit }\n format.json { render json: @skillset.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @shop_claim = ShopClaim.find(params[:id])\n\n if @shop_claim.update(shop_claim_params)\n head :no_content\n else\n render json: @shop_claim.errors, status: :unprocessable_entity\n end\n end",
"def update\n @physician = Physician.find(params[:id])\n\n respond_to do |format|\n if @physician.update_attributes(params[:physician])\n format.html { redirect_to @physician, :notice => 'Physician was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @physician.errors, :status => :unprocessable_entity }\n end\n end\n end"
] |
[
"0.6510162",
"0.64779127",
"0.61509436",
"0.6076243",
"0.5976691",
"0.5937054",
"0.5885354",
"0.58324695",
"0.5803035",
"0.5798475",
"0.5789043",
"0.5742952",
"0.56697446",
"0.56017435",
"0.5592119",
"0.5576621",
"0.5568902",
"0.55615926",
"0.55545837",
"0.55084616",
"0.5507015",
"0.5501615",
"0.5495149",
"0.5479733",
"0.54795915",
"0.54772955",
"0.5463902",
"0.54618",
"0.54561937",
"0.5451793",
"0.54512054",
"0.54499054",
"0.54460496",
"0.54372704",
"0.5435697",
"0.5433762",
"0.54265535",
"0.542303",
"0.5421294",
"0.54199076",
"0.54107165",
"0.5405054",
"0.5402795",
"0.5399649",
"0.5397108",
"0.5394737",
"0.5382583",
"0.5375646",
"0.5375646",
"0.5371811",
"0.53618866",
"0.53617096",
"0.53593767",
"0.5357616",
"0.5350411",
"0.5346252",
"0.53456867",
"0.5335571",
"0.53331906",
"0.53324676",
"0.53312886",
"0.53242946",
"0.5318278",
"0.5317834",
"0.5315704",
"0.5314212",
"0.53129244",
"0.53110266",
"0.5310739",
"0.5309306",
"0.5308183",
"0.53037405",
"0.5301311",
"0.53001815",
"0.52992475",
"0.5293681",
"0.5291369",
"0.52909017",
"0.52887905",
"0.5288068",
"0.528683",
"0.5286646",
"0.52795964",
"0.52795666",
"0.52762145",
"0.52756387",
"0.5271194",
"0.5271194",
"0.5271194",
"0.5271194",
"0.5271194",
"0.5271194",
"0.5271194",
"0.5271194",
"0.5270961",
"0.5270057",
"0.52674496",
"0.526461",
"0.52633834",
"0.5261716"
] |
0.5727918
|
12
|
DELETE /trust_moneys/1 DELETE /trust_moneys/1.json
|
def destroy
@trust_money.destroy
respond_to do |format|
format.html { redirect_to trust_moneys_url, notice: 'Trust money was successfully destroyed.' }
format.json { head :no_content }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def destroy\n @moresmalltrial = Moresmalltrial.find(params[:id])\n @moresmalltrial.destroy\n\n respond_to do |format|\n format.html { redirect_to moresmalltrials_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @trustees_minute.destroy\n respond_to do |format|\n format.html { redirect_to trustees_minutes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n \n keystone.delete_tenant(keystone.get_tenant(params[:id])[:id])\n\n respond_to do |format|\n format.html { redirect_to tenants_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @trustee.destroy\n respond_to do |format|\n format.html { redirect_to trustees_url }\n format.json { head :no_content }\n end\n end",
"def delete_trust(xml) \n if current_user \n trust_root = xml.root.get_elements('TrustRoot').first.text \n unless trust_root.empty? \n @trust = current_user.trusts.find(:first, :conditions => ['trust_root = ?', trust_root]) \n if @trust \n @trust.destroy \n return render(:text => \"<Response>success</Response>\") \n end \n end \n end \n render :text => '<Response>trust root does not exist</Response>' \n end",
"def destroy\n @trust_transaction.destroy\n respond_to do |format|\n format.html { redirect_to trust_transactions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @server = Server.find(params[:id])\n checkaccountobject(\"servers\",@server)\n @server.send_delete\n respond_to do |format|\n format.html { redirect_to servers_url }\n format.json { head :ok }\n end\n end",
"def destroy\n onesecgroup('delete', resource[:name])\n @property_hash.clear\n end",
"def destroy\n onevnet('delete', resource[:name])\n @property_hash.clear\n end",
"def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end",
"def destroy\n @claim.destroy\n respond_to do |format|\n format.html { redirect_to claims_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n authenticate_user!\n authorize! :index, @user, :message => 'Not authorized as an administrator.'\n \n @key_policy_maker = KeyPolicyMaker.find(params[:id])\n @key_policy_maker.destroy\n\n respond_to do |format|\n format.html { redirect_to :back }\n format.json { head :no_content }\n end\n end",
"def destroy\n @privilege.destroy\n respond_to do |format|\n format.html { redirect_to privileges_url }\n format.json { head :no_content }\n end\n end",
"def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend",
"def destroy\n @infrastructure = Infrastructure.find(params[:id])\n checkaccountobject(\"infrastructures\",@infrastructure)\n @infrastructure.send_delete\n\n respond_to do |format|\n format.html { redirect_to infrastructures_url }\n format.json { head :ok }\n end\n end",
"def destroy\n authorize @demand\n @demand.destroy\n respond_to do |format|\n format.html { redirect_to demands_url, notice: 'Demand was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @identity.destroy\n\n head :no_content\n end",
"def destroy\n @mattress = Mattress.find(params[:id])\n @mattress.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_mattresses_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @aliexpress = Aliexpress.find(params[:id])\n @aliexpress.destroy\n\n respond_to do |format|\n format.html { redirect_to aliexpresses_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @trust_fund = TrustFund.find(params[:id])\n @trust_fund.destroy\n\n respond_to do |format|\n format.html { redirect_to trust_funds_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @pharmaceutical_master.destroy\n respond_to do |format|\n format.html { redirect_to pharmaceutical_masters_url, notice: DELETE_NOTICE }\n format.json { head :no_content }\n end\n end",
"def destroy\n @identity.destroy\n respond_to do |format|\n format.html { redirect_to identities_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n name, type = resource[:name].split('/')\n case type\n when 'MX'\n @dnsres.each do |res|\n preference = res.preference\n target = res.to_rdata\n nsupdate(\"server #{server}\n update delete #{name} MX #{preference} #{target}.\n send\")\n end\n when 'SRV'\n @dnsres.each do |res|\n priority = res.priority\n weight = res.weight\n port = res.port\n target = res.to_rdata\n nsupdate(\"server #{server}\n update delete #{name} SRV #{priority} #{weight} #{port} #{target}\n send\")\n end\n else\n rdata = @dnsres.to_rdata\n nsupdate(\"server #{server}\n update delete #{name} #{type} #{rdata}\n send\")\n end\n end",
"def destroy\n @small_concert.destroy\n respond_to do |format|\n format.html { redirect_to '/admin/small_concerts' }\n format.json { head :no_content }\n end\n end",
"def destroy\n\n @ministorage.destroy\n respond_to do |format|\n format.html { redirect_to admin_ministorages_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n FileUtils.rm_r(@target_path) if File.exist?(@target_path)\n\n @author_site_storage.destroy\n respond_to do |format|\n format.html { redirect_to author_site_storages_url, notice: t('success_delete') }\n format.json { head :no_content }\n end\n end",
"def destroy\n @storage = @client.storages.find(params[:id])\n @storage.destroy\n\n respond_to do |format|\n format.html { redirect_to client_url(@client) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @server1 = Server1.find(params[:id])\n @server1.destroy\n\n respond_to do |format|\n format.html { redirect_to server1s_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pharmacy.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def deleteEntityWebsite( entity_id, gen_id)\n params = Hash.new\n params['entity_id'] = entity_id\n params['gen_id'] = gen_id\n return doCurl(\"delete\",\"/entity/website\",params)\n end",
"def destroy\n @manage_heal.destroy\n respond_to do |format|\n format.html { redirect_to manage_heals_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @database = Database.find(params[:id])\n path = @database.path\n delete = %x[rm -R #{path}]\n @database.destroy\n\n respond_to do |format|\n format.html { redirect_to databases_url }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @mostsmallmission = Mostsmallmission.find(params[:id])\n @mostsmallmission.destroy\n\n respond_to do |format|\n format.html { redirect_to mostsmallmissions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @taxinomy = Taxinomy.find(params[:id])\n @taxinomy.destroy\n\n respond_to do |format|\n format.html { redirect_to taxinomies_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @mystic.destroy\n respond_to do |format|\n format.html { redirect_to mystics_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @stress = current_user.stresses.find(params[:id])\n @stress.destroy\n\n respond_to do |format|\n format.html { redirect_to(stresses_path) }\n end\n end",
"def delete\n response = WebPay.client.delete(path)\n response['deleted']\n end",
"def destroy\n @policy.destroy\n respond_to do |format|\n format.html { redirect_to policys_url }\n format.json { render json: { status: 200 } }\n end\n end",
"def cancelReservation(lease_uuid)\n broker_url = APP_CONFIG['broker_ip'] + ':' + APP_CONFIG['broker_port'].to_s \n cert_path = APP_CONFIG['cert_path']\n \n header = {\"Content-Type\" => \"application/json\"}\n options = {uuid: lease_uuid}\n\n #puts options.to_json \n uri = URI.parse(broker_url+\"/resources/leases\")\n pem = File.read(cert_path)\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n http.cert = OpenSSL::X509::Certificate.new(pem)\n http.key = OpenSSL::PKey::RSA.new(pem)\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n request = Net::HTTP::Delete.new(uri.request_uri, header)\n request.body = options.to_json\n\n response = http.request(request)\n puts response\n if response.header.code != '200'\n puts \"Something went wrong\"\n puts response\n end\n end",
"def destroy\n @htc.destroy\n respond_to do |format|\n format.html { redirect_to htcs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cert.destroy\n respond_to do |format|\n format.html { redirect_to certs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @healthpro.destroy\n respond_to do |format|\n format.html { redirect_to root_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n @kota_stone.destroy\n respond_to do |format|\n format.html { redirect_to kota_stones_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @person.skills.delete_all\n \n @person.destroy\n respond_to do |format|\n format.html { redirect_to people_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @diagnoz = Diagnoz.find(params[:id])\n @diagnoz.destroy\n\n respond_to do |format|\n format.html { redirect_to diagnozs_url }\n format.json { head :no_content }\n end\n end",
"def delete\n # Read the configuration from DynamoDB \n db = AWS::DynamoDB.new\n table = db.tables[CONFIGS[:db][:party_configs][:table]]\n table.hash_key = [:party_id, :string]\n item = table.items[id]\n return false if (!item.exists?)\n item.delete\n return true\n end",
"def destroy\n @aliquotum = Aliquotum.find(params[:id])\n @aliquotum.destroy\n\n respond_to do |format|\n format.html { redirect_to aliquota_url }\n format.json { head :no_content }\n end\n end",
"def delete_user_for_tenant(args = {}) \n delete(\"/tenants.json/#{args[:tenantId]}/users/#{args[:userId]}\", args)\nend",
"def destroy\n @license.destroy\n respond_to do |format|\n format.html { redirect_to root_path, notice: 'Запись о лицензии удалена.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @consensu = Consensu.find(params[:id])\n @consensu.destroy\n\n respond_to do |format|\n format.html { redirect_to consensus_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n authorize @sims_biga_license\n @sims_biga_license.destroy\n respond_to do |format|\n format.html { redirect_to sims_biga_licenses_url, notice: t('flash.notice.destroied.') }\n format.json { head :no_content }\n end\n end",
"def destroy\n @certified.destroy\n respond_to do |format|\n format.html { redirect_to certifieds_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @keystore.destroy\n respond_to do |format|\n format.html { redirect_to keystores_url, notice: 'Keystore was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n client=Client.find_by_id(params[:id])\n if client != nil\n if client.destroy\n head 204\n end\n else\n head 404\n end\n end",
"def destroy\n @stone = Stone.find(params[:id])\n @stone.destroy\n\n respond_to do |format|\n format.html { redirect_to stones_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @store = Store.find(params[:id])\n #tib_res = Tibbr::ExternalResource.find_by_resource_key({:resource => {:key => \"ID_#{@store.id}\", :resource_type => \"ad:store\"}, :client_id => session[:app_id]})\n # tib_res.destroy\n @store.destroy\n \n \n\n respond_to do |format|\n format.html { redirect_to stores_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @moresmallarmorinfo = Moresmallarmorinfo.find(params[:id])\n @moresmallarmorinfo.destroy\n\n respond_to do |format|\n format.html { redirect_to moresmallarmorinfos_url }\n format.json { head :no_content }\n end\n end",
"def delete_workset (token, workset_name)\n Rails.logger.debug \"delete_workset #{workset_name}\"\n\n url = URI.parse(\"#{APP_CONFIG['registry_url']}/worksets/#{workset_name}\")\n http = Net::HTTP.new(url.host, url.port)\n if Rails.env.development?\n http.set_debug_output($stdout)\n end\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n request = Net::HTTP::Delete.new(url.request_uri)\n request.add_field(\"Authorization\", \"Bearer #{token}\")\n request.add_field(\"Accept\", \"application/vnd.htrc-workset+xml\")\n response = http.request(request)\n\n case response\n when Net::HTTPUnauthorized then\n raise Exceptions::SessionExpiredError.new(\"Session expired. Please login again\")\n when Net::HTTPSuccess then\n # Do nothing\n else\n raise Exceptions::SystemError.new(\"Error deleting workset (HTTP #{response.code})\")\n end\n\n end",
"def delete_and_give_me_a_json(additional_path, params = nil)\n if self.service_base_path != nil\n if params == nil\n params = Hash.new\n end\n params[:api_key] = self.access_token\n message = self.http_client.delete \"#{self.base_url}#{self.service_base_path}/#{additional_path}.json\", params\n trata_erro(message.content)\n end\n end",
"def destroy\r\n @sivic_ministerio.destroy\r\n respond_to do |format|\r\n format.html { redirect_to sivic_ministerios_url }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n @retroaspecto = Retroaspecto.find(params[:id])\n @retroaspecto.destroy\n\n respond_to do |format|\n format.html { redirect_to retroaspectos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n return redirect_to root_url, notice: \"Vous n'avez pas accès à cette ressource.\" if !permition_to_write?(@user)\n @capacite = Capacite.find(params[:id])\n @capacite.destroy\n\n respond_to do |format|\n format.html { redirect_to capacites_url }\n format.json { head :no_content }\n end\n end",
"def rm_create path, entity, data, msg\n\n rmp = nil\n re = rm_request path, entity => data\n chk (re.code!='201'), msg + \"\\n#{re.code} #{re.msg}\\n\\n\"\n rmp = JSON.parse(re.body)[entity] rescue nil\n chk !rmp, msg + \"\\n#{re.body.inspect}\\n\\n\"\n return rmp\n\nend",
"def destroy\n @ministerio = Ministerio.find(params[:id])\n @ministerio.destroy\n\n respond_to do |format|\n format.html { redirect_to ministerios_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @solo.destroy\n respond_to do |format|\n format.html { redirect_to solos_url, notice: 'Solo was successfully destroyed.' }\n format.json { head :no_content }\n end\n authorize @solo\n end",
"def destroy\n @claimant = Claimant.find(params[:id])\n @claimant.destroy\n\n respond_to do |format|\n format.html { redirect_to claimants_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cpanel_mall.destroy\n respond_to do |format|\n format.html { redirect_to cpanel_malls_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @shop_claim.destroy\n\n head :no_content\n end",
"def destroy\n @admin.destroy\n\n render json: { operation: 'OK' }, status: :ok\n end",
"def destroy\n @momsg = Momsg.find(params[:id])\n @momsg.destroy\n\n respond_to do |format|\n format.html { redirect_to momsgs_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @treq = Treq.find(params[:id])\n @treq.destroy\n\n respond_to do |format|\n format.html { redirect_to treqs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n authenticate_user!\n @server = Server.find(params[:id])\n @server.destroy\n\n respond_to do |format|\n format.html { redirect_to servers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @claim.destroy\n respond_to do |format|\n format.html { redirect_to insurer_claims_url, notice: 'Claim was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n debug(\"#{self.class}::destroy\")\n\n #Retrieval of key\n if ((defined? $key) && !(($key.nil?) || ($key.empty?)))\n Puppet.debug('INFO: key already provided as a command parameter ' + $key)\n\n elsif (!($name.to_s.empty?) )\n\n #Retrieve key\n uriAttributeMap1 = {}\n uriAttributeMap1[:name] = $name\n resourceType = \"storage-service-levels\"\n $key = self.retrieveKeyOfObjectType('/api/1.0/slo/storage-service-levels', resourceType, uriAttributeMap1)\n\n end\n\n\n apiUri = '/api/1.0/slo/storage-service-levels/'+$key\n resourceType = \"storageservicelevel\"\n\n if(transport.http_delete_request(apiUri ,resourceType))\n if(resource[:name] != null)\n puts \"#{resourceType} : #{resource[:name]} successfully deleted\"\n\t\t\telse\n\t\t\t puts \" #{resourceType} successfully deleted\"\n\t\t\tend\n else\n if(resource[:name] != null)\n puts \" #{resourceType} : #{resource[:name]} deletion failed\"\n\t\t else\n\t\t\t puts \" #{resourceType} deletion failed\"\n\t\t end\n end\n\nend",
"def destroy\n @tx_land_grants_efn.destroy\n respond_to do |format|\n format.html { redirect_to tx_land_grants_efns_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @matiawase.destroy\n respond_to do |format|\n format.html { redirect_to matiawases_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @mutant.destroy\n head :no_content\n end",
"def destroy\n @orphan.destroy\n respond_to do |format|\n format.html { redirect_to orphans_url }\n format.json { head :no_content }\n end\n end",
"def delete_array_for_tenant(args = {}) \n delete(\"/tenants.json/#{args[:tenantId]}/arrays/#{args[:arrayId]}\", args)\nend",
"def destroy\n @medium_mission = MediumMission.find(params[:id])\n @medium_mission.destroy\n\n respond_to do |format|\n format.html { redirect_to medium_missions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @medium_trial = MediumTrial.find(params[:id])\n @medium_trial.destroy\n\n respond_to do |format|\n format.html { redirect_to medium_trials_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @secret.destroy\n respond_to do |format|\n format.html { redirect_to secrets_url, notice: 'El secreto se eliminó correctamente.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @grant = Grant.find(params[:id])\n @grant.destroy\n\n respond_to do |format|\n format.html { redirect_to grants_url }\n format.json { head :ok }\n end\n end",
"def delete\n res = HTTParty.get URL, headers: HEADERS\n message = JSON.parse res.body, symbolize_names: true\n if res.code == 200\n numSubs = message[:data].count\n if numSubs > 0\n message[:data].each do |sub|\n id = sub[:id]\n delRes = HTTParty.delete \"#{URL}/#{id}\", headers: HEADERS\n #TODO handle status codes\n end\n end\n end\n end",
"def destroy\n file_store = FileStore.find_by_sha1_hash!(params[:id])\n if user['id'] == file_store.user_id || user['role'] == 'admin' ||\n (user['uname'] == 'file_store' && user['role'] == 'system')\n file_store.destroy\n head :no_content\n else\n render_error 403\n end\n end",
"def destroy\n @ministerios = Ministerios.find(params[:id])\n @ministerios.destroy\n\n respond_to do |format|\n format.html { redirect_to(ministerios_url) }\n format.xml { head :ok }\n end\n end",
"def rm_update path, data, msg\n\n re = rm_request path, data, 'PUT'\n puts re.body\n chk (re.code!='200'), msg + \"\\n#{re.code} #{re.msg}\\n\\n\"\n return true\n\nend",
"def destroy\n @thirtyone.destroy\n respond_to do |format|\n format.html { redirect_to thirtyones_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @policy = Policy.find(params[:id])\n @policy.destroy\n\n respond_to do |format|\n format.html { redirect_to motor_policies_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @m1.destroy\n respond_to do |format|\n format.html { redirect_to m1s_url, notice: 'M1 was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def deleteEntityPhone( entity_id, gen_id)\n params = Hash.new\n params['entity_id'] = entity_id\n params['gen_id'] = gen_id\n return doCurl(\"delete\",\"/entity/phone\",params)\n end",
"def destroy\n @store_policies_information = Store::Policies::Information.find(params[:id])\n @store_policies_information.destroy\n\n respond_to do |format|\n format.html { redirect_to store_policies_information_index_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @early_access_request.destroy\n respond_to do |format|\n format.html { redirect_to early_access_requests_url, notice: 'Anfrage wurde gelöscht.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @moonwalk.destroy\n respond_to do |format|\n format.html { redirect_to moonwalks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @store_manager_policy = Store::Manager::Policy.find(params[:id])\n @store_manager_policy.destroy\n\n respond_to do |format|\n format.html { redirect_to store_manager_policies_url }\n format.json { head :no_content }\n end\n end",
"def delete\n render json: Alien.delete(params[\"id\"])\n end",
"def destroy\n @server_ins_transaction = ServerInsTransaction.find(params[:id])\n @server_ins_transaction.destroy\n\n respond_to do |format|\n format.html { redirect_to server_ins_transactions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @mystock.destroy\n respond_to do |format|\n format.html { redirect_to mystocks_path, notice: 'mystock was successfully destroyed.' }\n format.json { head :no_content }\n end\n end"
] |
[
"0.6612225",
"0.6435048",
"0.642754",
"0.6395023",
"0.63516265",
"0.6321232",
"0.63130873",
"0.6241977",
"0.6236176",
"0.6235031",
"0.62324655",
"0.6185294",
"0.615585",
"0.6150322",
"0.61460894",
"0.6117683",
"0.6115404",
"0.61024165",
"0.6095944",
"0.6092853",
"0.6082935",
"0.60806257",
"0.607481",
"0.6074309",
"0.606939",
"0.60603625",
"0.60505354",
"0.6037036",
"0.60340524",
"0.60281205",
"0.6022236",
"0.60105735",
"0.60057896",
"0.60053337",
"0.6004208",
"0.5991223",
"0.5981281",
"0.5980718",
"0.5979552",
"0.5977828",
"0.59772223",
"0.5972962",
"0.59686965",
"0.5965061",
"0.59645385",
"0.59636664",
"0.5963369",
"0.5960439",
"0.5959323",
"0.59571165",
"0.59546936",
"0.595315",
"0.59454054",
"0.59451455",
"0.59444696",
"0.59414065",
"0.59370303",
"0.59367067",
"0.59277797",
"0.59245455",
"0.5923731",
"0.59232736",
"0.59220785",
"0.59220093",
"0.5917924",
"0.5917356",
"0.591466",
"0.591059",
"0.590768",
"0.5903643",
"0.5898451",
"0.5897674",
"0.58932734",
"0.5892872",
"0.589214",
"0.58910406",
"0.5889939",
"0.5886211",
"0.58847153",
"0.5884054",
"0.58806986",
"0.5878985",
"0.5874306",
"0.5870865",
"0.5870476",
"0.58670527",
"0.5866893",
"0.5863755",
"0.5863071",
"0.58611184",
"0.5859179",
"0.5855592",
"0.5853443",
"0.58522534",
"0.585156",
"0.5850387",
"0.5845575",
"0.5845316",
"0.5843728",
"0.58420914"
] |
0.65613014
|
1
|
Use callbacks to share common setup or constraints between actions.
|
def set_trust_money
@trust_money = TrustMoney.find(params[:id])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def define_action_helpers?; end",
"def set_actions\n actions :all\n end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def setup_handler\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def workflow\n end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup\n # override and do something appropriate\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def before_action \n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def setup_signals; end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def initialize(*args)\n super\n @action = :set\nend",
"def after_set_callback; end",
"def setup\n #implement in subclass;\n end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def around_hooks; end",
"def save_action; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def default_action; end",
"def setup(&blk)\n @setup_block = blk\n end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def duas1(action)\n action.call\n action.call\nend",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend"
] |
[
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576",
"0.53124547",
"0.529654",
"0.5296262",
"0.52952296",
"0.52600986",
"0.52442724",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.5232394",
"0.523231",
"0.5227454",
"0.52226824",
"0.52201617",
"0.5212327",
"0.52079266",
"0.52050185",
"0.51754695",
"0.51726824",
"0.51710224",
"0.5166172",
"0.5159343",
"0.51578903",
"0.51522785",
"0.5152022",
"0.51518047",
"0.51456624",
"0.51398855",
"0.5133759",
"0.5112076",
"0.5111866",
"0.5111866",
"0.5110294",
"0.5106169",
"0.509231",
"0.50873137",
"0.5081088",
"0.508059",
"0.50677156",
"0.50562143",
"0.5050554",
"0.50474834",
"0.50474834",
"0.5036181",
"0.5026331",
"0.5022976",
"0.5015441",
"0.50121695",
"0.5000944",
"0.5000019",
"0.4996878",
"0.4989888",
"0.4989888",
"0.49864885",
"0.49797225",
"0.49785787",
"0.4976161",
"0.49683493",
"0.4965126",
"0.4958034",
"0.49559742",
"0.4954353",
"0.49535993",
"0.4952725",
"0.49467874",
"0.49423352",
"0.49325448",
"0.49282882",
"0.49269363",
"0.49269104",
"0.49252945",
"0.4923091",
"0.49194667",
"0.49174926",
"0.49173003",
"0.49171105",
"0.4915879",
"0.49155936"
] |
0.0
|
-1
|
Never trust parameters from the scary internet, only allow the white list through.
|
def trust_money_params
params.require(:trust_money).permit(:source_type, :agency_id, :etc)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def param_whitelist\n [:role, :title]\n end",
"def expected_permitted_parameter_names; end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end",
"def valid_params_request?; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def permitted_params\n []\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end",
"def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end",
"def safe_params\n params.require(:user).permit(:name)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def check_params; true; end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def quote_params\n params.permit!\n end",
"def valid_params?; end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend",
"def filtered_parameters; end",
"def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end",
"def filtering_params\n params.permit(:email, :name)\n end",
"def check_params\n true\n end",
"def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend",
"def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end",
"def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end",
"def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end",
"def active_code_params\n params[:active_code].permit\n end",
"def filtering_params\n params.permit(:email)\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end",
"def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end",
"def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end",
"def list_params\n params.permit(:name)\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def url_whitelist; end",
"def admin_social_network_params\n params.require(:social_network).permit!\n end",
"def filter_params\n params.require(:filters).permit(:letters)\n end",
"def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end",
"def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end",
"def sensitive_params=(params)\n @sensitive_params = params\n end",
"def permit_request_params\n params.permit(:address)\n end",
"def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end",
"def secure_params\n params.require(:location).permit(:name)\n end",
"def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end",
"def question_params\n params.require(:survey_question).permit(question_whitelist)\n end",
"def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end",
"def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end",
"def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end",
"def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end",
"def url_params\n params[:url].permit(:full)\n end",
"def backend_user_params\n params.permit!\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end",
"def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end",
"def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end",
"def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end",
"def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end",
"def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end"
] |
[
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",
"0.62894756",
"0.6283177",
"0.6242471",
"0.62382483",
"0.6217549",
"0.6214457",
"0.6209053",
"0.6193042",
"0.6177802",
"0.6174604",
"0.61714715",
"0.6161512",
"0.6151757",
"0.6150663",
"0.61461",
"0.61213595",
"0.611406",
"0.6106206",
"0.6105114",
"0.6089039",
"0.6081015",
"0.6071004",
"0.60620916",
"0.6019971",
"0.601788",
"0.6011056",
"0.6010898",
"0.6005122",
"0.6005122",
"0.6001556",
"0.6001049",
"0.59943926",
"0.5992201",
"0.59909594",
"0.5990628",
"0.5980841",
"0.59669393",
"0.59589154",
"0.5958826",
"0.5957911",
"0.5957385",
"0.5953072",
"0.59526145",
"0.5943361",
"0.59386164",
"0.59375334",
"0.59375334",
"0.5933856",
"0.59292704",
"0.59254247",
"0.5924164",
"0.59167904",
"0.59088355",
"0.5907542",
"0.59064597",
"0.5906243",
"0.5898226",
"0.589687",
"0.5896091",
"0.5894501",
"0.5894289",
"0.5891739",
"0.58860534",
"0.5882406",
"0.587974",
"0.58738774",
"0.5869024",
"0.58679986",
"0.5867561",
"0.5865932",
"0.5864461",
"0.58639693",
"0.58617616",
"0.5861436",
"0.5860451",
"0.58602303",
"0.5854586",
"0.58537364",
"0.5850427",
"0.5850199"
] |
0.0
|
-1
|
GET /alumni_news_items GET /alumni_news_items.json
|
def index
@undergrad_cat = NewsItemCategory.find(2)
@alumni_news_items = @undergrad_cat.news_items
# @alumni_news_items = AlumniNewsItem.all
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n respond_to do |format|\n format.html # index.html.haml\n format.json { render :json => @news_items }\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @news_item }\n end\n end",
"def index\n @enable_news_edit = true\n @news = Roxiware::NewsItem.order(\"post_date DESC\")\n @title = @title + \" : News\"\n @meta_description = @title\n clean_news = []\n @news.each do |news_item| \n @meta_keywords = @meta_keywords + \", \" + news_item.headline\n\tclean_news << news_item.ajax_attrs(@role)\n end \n respond_to do |format|\n format.html\n\tformat.json { render :json=>clean_news }\n end\n end",
"def index\n @discourse_news_items = DiscourseNewsItem.all\n end",
"def index\n \n @news = News.all\n @latest_news = News.latest_news\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @news }\n end\n end",
"def index\n @news = Newsfeed.order(\"created_at DESC\")\n render json: { is_success: true, message: \"news fetch successful\", data: @news }, status: 200\n end",
"def index\n @items = current_user.items\n respond_to do |format|\n format.html\n format.json { render json: @items }\n end\n end",
"def index\n @news = WebInterface::NewsItem.order('created_at desc')\n end",
"def index\n @news = News.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @news }\n end\n end",
"def index\n #@items = Item.find_by_user_id(Session[user_id])\n @items = Item.all\n render json: @items\n end",
"def index\n @news = New.order('created_at DESC')\n render json: @news.as_json(except: [:body], methods: [:short_body]), status: :ok\n end",
"def index\n @items = @channel.items\n @items = @query.search(@items)\n @items = @items.order_by_published_at_desc\n @items = @items.page(params[:page]).per(10)\n\n respond_to do |format|\n format.html\n format.json { render json: @items }\n end\n end",
"def index\n @news_items = NewsItem.find(:all, :order => 'updated_at desc')\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @news_items.to_xml }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.haml\n format.json { render :json => @news_item }\n end\n end",
"def set_alumni_news_item\n @alumni_news_item = AlumniNewsItem.find(params[:id])\n end",
"def index\n @news_data = NewsDatum.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @news_data }\n end\n end",
"def fetch_news\n @news = News.fetch_and_store_news! @agencyfeed\n render template: 'news/list', status: :ok\n end",
"def get_news( category = \"home\" )\n url = \"https://api.nytimes.com/svc/topstories/v2/#{ category }.json\"\n options = { api_key: Rails.application.secrets.NY_TIMES_TOP_STORIES_KEY }\n\n response = HTTParty.get( url, :query => options )\n\n response\n end",
"def index\n @api_v1_news_links = Api::V1::NewsLink.all\n end",
"def show\n @news_list = NewsList.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @news_list }\n end\n end",
"def index\n @news_posts = NewsPost.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @news_posts }\n end\n end",
"def index\n @news = News.where(status: News.statuses[:published])\n render(\n json: ActiveModel::ArraySerializer.new(\n @news,\n each_serializer: NewsSerializer\n )\n )\n end",
"def index\n @items = Item.includes(:user).order(created_at: :desc).all\n render json: @items\n end",
"def index\n @news_items = do_index(NewsItem, params)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @news_items }\n end\n end",
"def index\n @feed_items = @user.feed_items\n render json: @feed_items\n end",
"def index\n @project_news = ProjectNews.last(10)\n respond_to do |format|\n format.json {render json: @project_news, :only => [:date, :content, :tags]}\n end\n end",
"def index\n #pagination parameters\n page_size = params[:page_size] ? params[:page_size].to_i : Page_size\n page = params[:page] ? params[:page].to_i : 1\n offset = page_size*(page - 1)\n @news = News.limit(page_size).offset(offset).order('created_at desc').includes(:user, :comments)\n\n if @news.blank?\n render json: {status: \"FEED_EMPTY\", message: \"No news feeds\", data: {}}, status: :ok\n else\n news_data = []\n # format likes, comments and user for each news\n @news.each do |news|\n news_data << {news: news, comments: news.comments.count, likes: liked_user_id(news), user: news.user.username}\n end\n render json: {status: \"SUCCESS\", message: \"List of news feeds\", data: news_data}, status: :ok\n end\n end",
"def index\n @tourism_articles = @tourism_articles.published.recent.page(params[:page]).per(10)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tourism_articles }\n end\n end",
"def my\n items = current_user.items\n render json: items\n end",
"def show\n @items = Item.find(params[:id])\n render json: @items\n end",
"def index\n @items = Item.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def index\n @items = Item.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def index\n @items = Item.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def index\n @items = Item.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def index\n @items = Item.found\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def index\n @hotnews_reads = HotnewsRead.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @hotnews_reads }\n end\n end",
"def index\n @items = Item.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @items }\n end\n end",
"def index\n if params[:news_id]\n @news = News.find(params[:news_id])\n @discusses = @news.discusses\n else\n @discusses = Discuss.all\n end\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @discusses }\n end\n end",
"def index\n @user_news = UserNews.all\n end",
"def index\n @items = Item.find(:all, :order => 'id ASC')\n # @items = Item.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def show\n @admin_useful_news = Admin::UsefulNews.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @admin_useful_news }\n end\n end",
"def index\n @articles = current_user.articles\n json_response(@articles)\n end",
"def index\n news_url = 'https://newsapi.org/v1/articles?source=national-geographic&sortBy=top&apiKey=ba8b42abfab743f3bfe37fe0f9df3557'\n response = HTTParty.get(news_url)\n @news_data = response\n\n @all_posts = current_user.posts\n # @new_post = Post.new #post is not tagged to user\n @new_post = current_user.posts.new\n end",
"def index\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @news_posts }\n end\n end",
"def index\n @newsinfos = Newsinfo.all\n end",
"def index\n @communities = Community.all\n render json: {items: @communities}\n end",
"def index\n # Find all news from the DB\n @news = News.all\n @news.sort!{|a,b| b.created_at <=> a.created_at}\n\n @items = Kaminari.paginate_array(@news).page(params[:page]).per(3)\n \n respond_to do |format|\n format.js\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def index\n @api_v1_items = Item.all\n render json: @api_v1_items\n end",
"def index\n self.identify_user\n @items = @user.items\n @itemlist = @items.map do |item|\n convert_to_json(item)\n end\n respond_to do |format|\n format.json { render :json => @itemlist }\n format.xml { render :xml => @items }\n format.html { render text: \"Unsupported Format\", status: 404 }\n end\n end",
"def new\n @news_list = NewsList.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @news_list }\n end\n end",
"def index\n @rentable_items = RentableItem.all\n render json: @rentable_items\n end",
"def alumni_news_item_params\n params.require(:alumni_news_item).permit(:title, :content)\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @news_item.ajax_attrs(@role) }\n end\n end",
"def index\n @response = HTTParty.get(\"http://newsapi.org/v2/top-headlines?category=sports&q=golf&apiKey=12e692d8e7254efa8cf6276ea99736b0\")\n @report = JSON.parse(@response.body)\n @article = @report[\"articles\"]\n end",
"def read_news_item(url)\n where(:user_id => User.current_user_id, :url => url).update_all(:read => true)\n end",
"def show\n # Find news from the DB\n @news = News.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @news }\n end\n end",
"def index\n @news = News.all\n end",
"def index\n @news = News.all\n end",
"def index\n @news = News.all\n end",
"def index\n @news = News.all\n end",
"def new\n authorize! :create, Roxiware::NewsItem\n @news_item = Roxiware::NewsItem.new({:headline=>\"Headline\", :content=>\"Content\", :post_date=>DateTime.now.utc}, :as=>@role)\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @news_item.ajax_attrs(@role) }\n end\n end",
"def index\n @items = Admin::Item.by_agency(@current_agency.id)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @admin_items }\n end\n end",
"def index\n respond_to do |format|\n format.html\n format.json { render :json => Item.all}\n end\n\n end",
"def articles\n @articles = Article.all\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @administration }\n end\n end",
"def index\n @news_latests = NewsLatest.all\n end",
"def _state_news(state_id)\n get('state/news', state_id, options: { type: :array })\n end",
"def index\n @section = Section.find(params[:section_id])\n @items = @section.items\n render json: ItemSerializer.new(@items)\n end",
"def index\n @news = News.where(\"duplicate_of is null\")\n #.as_json(only: [:id, :title, :image, :author, :published, :category, :content])\n\n render json: @news\n end",
"def index\n @news_stories = NewsStory.all\n end",
"def show\n @news = News.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @news }\n end\n end",
"def show\n @news = News.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @news }\n end\n end",
"def show\n @news = News.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @news }\n end\n end",
"def show\n @news = News.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @news }\n end\n end",
"def index\n @articles = Article.all\n\n respond_to do |format|\n format.json { render json: @articles }\n end\n end",
"def index\n @newslines = Newsline.all\n end",
"def index\n if params[:uid]\n @current_user = User.find_by(uid: params[:uid])\n render json: {\n status: 'SUCCESS',\n message: 'Loaded users',\n value: @current_user.items\n }\n else\n items = Item.order(created_at: :desc)\n render json: { status: 'SUCCESS', message: 'Loaded items', value: items }\n end\n end",
"def index\n if @item\n @inter_library_loans = @item.inter_library_loans.page(params[:page])\n else\n @inter_library_loans = InterLibraryLoan.page(params[:page])\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @inter_library_loans }\n format.rss { render layout: false }\n format.atom\n end\n end",
"def index\n render json: Item.paginate(page: params[:page], per_page: 25)\n end",
"def create\n @alumni_news_item = AlumniNewsItem.new(alumni_news_item_params)\n\n respond_to do |format|\n if @alumni_news_item.save\n format.html { redirect_to @alumni_news_item, notice: 'Alumni news was successfully created.' }\n format.json { render action: 'show', status: :created, location: @alumni_news_item }\n else\n format.html { render action: 'new' }\n format.json { render json: @alumni_news_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @items = Item.eager_load(:rss).paginate(page: params[:page], :per_page => 10).order(\"date DESC\")\n end",
"def index\n @page = (params[:page] || 1).to_i\n @items_per_page = (params[:num] || 50).to_i\n # @items = Item.all\n results = Item.search(\"\", @page, @items_per_page)\n @items = results[0]\n @count = results[1]\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def getItems()\n return mergeWithAPI(@item_json)['data']\n end",
"def index\n @announcements = Announcement.visible.where(locale: I18n.locale || 'en').paginate(:page => params[:page], :per_page => 10)\n \n @announcements.first.increase_views unless @announcements.empty?\n\n @title = \"News\"\n\n logger.debug @announcement.inspect\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @announcements }\n end\n end",
"def index\n\t\t@auction_items = @auction.auction_items\n\t\trender json: @auction_items.as_json\n\tend",
"def show\n @news = News.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @news }\n end\n end",
"def set_news_item\n @news_item = NewsItem.find(params[:id])\n end",
"def set_news_item\n @news_item = NewsItem.find(params[:id])\n end",
"def set_news_item\n @news_item = NewsItem.find(params[:id])\n end",
"def index\n @menu = \"articles\"\n @num_articles = num_articles\n @page_number = 1\n begin\n @page_number = params[:page].to_i unless params[:page].blank?\n last_page = (@num_articles / Ufo::MAX_PAGE_ITEMS) + 1\n if @page_number <= 0\n @page_number = 1\n elsif @page_number > last_page\n @page_number = last_page\n end\n rescue\n logger.error \"Page number not valid!\"\n end\n @articles = Rails.cache.fetch(\"articles/index/#{@page_number}\", :expires_in => 1.week) do\n Article.where(:status => 1).without(:article_helper_method, :article_type, :date_filter, :email, :partial_1).desc(:published_date).skip((@page_number-1) * Ufo::MAX_PAGE_ITEMS).limit(Ufo::MAX_PAGE_ITEMS).entries\n end\n @page_title = \"Articles\"\n @page_description = \"Latest Articles\"\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @articles }\n end\n end",
"def index\n params[:feeds] = current_user.feeds.collect { |item| item.id }\n if params[:feeds].count > 0\n @articles = Article.search(params)\n else\n @articles = []\n end\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @articles }\n end\n end",
"def index\n @articles = Article.page(params[:page]).order(:pub_date,:source,:headline)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @articles }\n end\n end",
"def index\n @articles = Article.all(:order=> \"created_at DESC\")\n @archive_items = Article.all(:order=> \"created_at DESC\")\n @title = \"Archive\"\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @articles }\n end\n end",
"def index\n @items = Item.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @boards }\n end\n end",
"def index\n @universes = Universe.all.page(params[:page]).per(25)\n respond_to do |format|\n format.html\n format.json { render json: @universes }\n end\n end",
"def reset_whats_new_for_all_users \n get(\"/users.json/news/reset\")\nend",
"def reset_whats_new_for_all_users \n get(\"/users.json/news/reset\")\nend",
"def items\n \tbegin\n \t@categories = Category.all.includes(items: [:dimensions])\n \t@ingredients = Ingredient.actives\n \trender 'api/v1/home/items', status: :ok\n \trescue Exception => e\n \t\terror_handling_bad_request(e)\n \tend\n\n\tend",
"def list_items( args={} )\n @session.base_url = \"http://my.cl.ly\"\n \n url = \"/items\"\n args.each do |k, v|\n # probably a nicer way to do this\n if url == \"/items\"\n url << \"?#{k.to_s}=#{v.to_s}\"\n else\n url << \"&#{k.to_s}=#{v.to_s}\"\n end\n end\n resp = @session.get( url )\n \n raise AuthorizationError if resp.status == 401\n Crack::JSON.parse(resp.body)\n end",
"def show\n @news = News.find(params[:id])\n data = {\n :title => @news.title,\n :id => @news.id,\n :content => @news.content,\n :content_html => @news.content_html,\n :created_at => @news.created_at,\n :updated_at => @news.updated_at\n }\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: data.to_json }\n end\n end",
"def items\n @beverages = Beverage.available\n respond_to do |format|\n format.json { render :json => @beverages.to_json(methods: :image_url)}\n end\n end"
] |
[
"0.7233282",
"0.6933822",
"0.66139245",
"0.6610566",
"0.65969634",
"0.6571096",
"0.6530904",
"0.6519706",
"0.64900935",
"0.6449386",
"0.6429913",
"0.6424784",
"0.6420015",
"0.63949746",
"0.63637286",
"0.6360672",
"0.6357958",
"0.62923354",
"0.6290286",
"0.6260707",
"0.6243574",
"0.62253344",
"0.6223919",
"0.6220824",
"0.6190926",
"0.6169287",
"0.6162682",
"0.61508054",
"0.61502874",
"0.6134671",
"0.6133167",
"0.6133167",
"0.6133167",
"0.6133167",
"0.6112992",
"0.60973614",
"0.609292",
"0.60902447",
"0.6085484",
"0.6084332",
"0.60783666",
"0.6077365",
"0.60508317",
"0.6038887",
"0.6037608",
"0.60084975",
"0.60052025",
"0.6004261",
"0.6001932",
"0.5991936",
"0.5991274",
"0.59908783",
"0.5980603",
"0.5978721",
"0.59670365",
"0.59313065",
"0.59218407",
"0.59218407",
"0.59218407",
"0.59218407",
"0.59196174",
"0.59106016",
"0.5908413",
"0.58968663",
"0.58940375",
"0.58903146",
"0.5886613",
"0.58862996",
"0.58837473",
"0.5882184",
"0.5882184",
"0.5882184",
"0.5882184",
"0.5878463",
"0.5871714",
"0.58497125",
"0.58479536",
"0.58429116",
"0.5840031",
"0.5836872",
"0.58113956",
"0.58094984",
"0.5802762",
"0.5801026",
"0.57972634",
"0.579416",
"0.579416",
"0.579416",
"0.5791278",
"0.578868",
"0.5785713",
"0.578564",
"0.57847834",
"0.57756567",
"0.57718164",
"0.57718164",
"0.57599616",
"0.5757454",
"0.57570547",
"0.57564694"
] |
0.6782471
|
2
|
GET /alumni_news_items/1 GET /alumni_news_items/1.json
|
def show
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @news_item }\n end\n end",
"def index\n respond_to do |format|\n format.html # index.html.haml\n format.json { render :json => @news_items }\n end\n end",
"def index\n \n @news = News.all\n @latest_news = News.latest_news\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @news }\n end\n end",
"def index\n @news = Newsfeed.order(\"created_at DESC\")\n render json: { is_success: true, message: \"news fetch successful\", data: @news }, status: 200\n end",
"def new\n respond_to do |format|\n format.html # new.html.haml\n format.json { render :json => @news_item }\n end\n end",
"def index\n @news = News.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @news }\n end\n end",
"def index\n @news = New.order('created_at DESC')\n render json: @news.as_json(except: [:body], methods: [:short_body]), status: :ok\n end",
"def index\n @undergrad_cat = NewsItemCategory.find(2)\n @alumni_news_items = @undergrad_cat.news_items\n # @alumni_news_items = AlumniNewsItem.all\n end",
"def index\n @enable_news_edit = true\n @news = Roxiware::NewsItem.order(\"post_date DESC\")\n @title = @title + \" : News\"\n @meta_description = @title\n clean_news = []\n @news.each do |news_item| \n @meta_keywords = @meta_keywords + \", \" + news_item.headline\n\tclean_news << news_item.ajax_attrs(@role)\n end \n respond_to do |format|\n format.html\n\tformat.json { render :json=>clean_news }\n end\n end",
"def show\n @news_list = NewsList.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @news_list }\n end\n end",
"def index\n @news = WebInterface::NewsItem.order('created_at desc')\n end",
"def index\n @news_data = NewsDatum.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @news_data }\n end\n end",
"def index\n #@items = Item.find_by_user_id(Session[user_id])\n @items = Item.all\n render json: @items\n end",
"def index\n @project_news = ProjectNews.last(10)\n respond_to do |format|\n format.json {render json: @project_news, :only => [:date, :content, :tags]}\n end\n end",
"def set_alumni_news_item\n @alumni_news_item = AlumniNewsItem.find(params[:id])\n end",
"def index\n @discourse_news_items = DiscourseNewsItem.all\n end",
"def show\n @admin_useful_news = Admin::UsefulNews.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @admin_useful_news }\n end\n end",
"def index\n @news_items = NewsItem.find(:all, :order => 'updated_at desc')\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @news_items.to_xml }\n end\n end",
"def show\n # Find news from the DB\n @news = News.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @news }\n end\n end",
"def index\n @items = current_user.items\n respond_to do |format|\n format.html\n format.json { render json: @items }\n end\n end",
"def fetch_news\n @news = News.fetch_and_store_news! @agencyfeed\n render template: 'news/list', status: :ok\n end",
"def index\n @news_posts = NewsPost.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @news_posts }\n end\n end",
"def index\n @api_v1_news_links = Api::V1::NewsLink.all\n end",
"def show\n @news = News.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @news }\n end\n end",
"def show\n @news = News.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @news }\n end\n end",
"def show\n @news = News.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @news }\n end\n end",
"def show\n @news = News.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @news }\n end\n end",
"def get_news( category = \"home\" )\n url = \"https://api.nytimes.com/svc/topstories/v2/#{ category }.json\"\n options = { api_key: Rails.application.secrets.NY_TIMES_TOP_STORIES_KEY }\n\n response = HTTParty.get( url, :query => options )\n\n response\n end",
"def index\n @items = @channel.items\n @items = @query.search(@items)\n @items = @items.order_by_published_at_desc\n @items = @items.page(params[:page]).per(10)\n\n respond_to do |format|\n format.html\n format.json { render json: @items }\n end\n end",
"def new\n @news_list = NewsList.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @news_list }\n end\n end",
"def show\n @items = Item.find(params[:id])\n render json: @items\n end",
"def index\n @tourism_articles = @tourism_articles.published.recent.page(params[:page]).per(10)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tourism_articles }\n end\n end",
"def index\n @items = Item.find(:all, :order => 'id ASC')\n # @items = Item.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def index\n @api_v1_items = Item.all\n render json: @api_v1_items\n end",
"def index\n @news = News.where(status: News.statuses[:published])\n render(\n json: ActiveModel::ArraySerializer.new(\n @news,\n each_serializer: NewsSerializer\n )\n )\n end",
"def index\n @hotnews_reads = HotnewsRead.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @hotnews_reads }\n end\n end",
"def index\n if params[:news_id]\n @news = News.find(params[:news_id])\n @discusses = @news.discusses\n else\n @discusses = Discuss.all\n end\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @discusses }\n end\n end",
"def show\n @news = News.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @news }\n end\n end",
"def index\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @news_posts }\n end\n end",
"def get_item( item )\n @session.base_url = \"http://cl.ly\"\n resp = @session.get( \"/\" + item )\n \n raise ItemNotFound if resp.status == 404\n Crack::JSON.parse(resp.body)\n end",
"def show\n @news_datum = NewsDatum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @news_datum }\n end\n end",
"def index\n @news = News.where(\"duplicate_of is null\")\n #.as_json(only: [:id, :title, :image, :author, :published, :category, :content])\n\n render json: @news\n end",
"def index\n @response = HTTParty.get(\"http://newsapi.org/v2/top-headlines?category=sports&q=golf&apiKey=12e692d8e7254efa8cf6276ea99736b0\")\n @report = JSON.parse(@response.body)\n @article = @report[\"articles\"]\n end",
"def index\n @news_items = do_index(NewsItem, params)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @news_items }\n end\n end",
"def index\n @items = Item.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def index\n @items = Item.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def index\n @items = Item.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def index\n @items = Item.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def index\n @items = Item.found\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def index\n @items = Item.includes(:user).order(created_at: :desc).all\n render json: @items\n end",
"def show\n @news = News.find(params[:id])\n data = {\n :title => @news.title,\n :id => @news.id,\n :content => @news.content,\n :content_html => @news.content_html,\n :created_at => @news.created_at,\n :updated_at => @news.updated_at\n }\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: data.to_json }\n end\n end",
"def index\n @items = Item.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @items }\n end\n end",
"def show\n @news_company = NewsCompany.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @news_company }\n end\n end",
"def show\n @hotnews_read = HotnewsRead.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @hotnews_read }\n end\n end",
"def new\n # Create new news\n @news = News.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @news }\n end\n end",
"def show\n if @news.nil?\n render json: {error: \"Not Found\"}, status: :not_found\n else\n render json: @news, status: :ok\n end\n end",
"def index\n #pagination parameters\n page_size = params[:page_size] ? params[:page_size].to_i : Page_size\n page = params[:page] ? params[:page].to_i : 1\n offset = page_size*(page - 1)\n @news = News.limit(page_size).offset(offset).order('created_at desc').includes(:user, :comments)\n\n if @news.blank?\n render json: {status: \"FEED_EMPTY\", message: \"No news feeds\", data: {}}, status: :ok\n else\n news_data = []\n # format likes, comments and user for each news\n @news.each do |news|\n news_data << {news: news, comments: news.comments.count, likes: liked_user_id(news), user: news.user.username}\n end\n render json: {status: \"SUCCESS\", message: \"List of news feeds\", data: news_data}, status: :ok\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @news_item.ajax_attrs(@role) }\n end\n end",
"def index\n @feed_items = @user.feed_items\n render json: @feed_items\n end",
"def show\n @item = Item.all.where(collection_id: params[:id])\n render :json => @item\n end",
"def new\n @news = News.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @news }\n end\n end",
"def new\n @news = News.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @news }\n end\n end",
"def new\n @news = News.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @news }\n end\n end",
"def new\n authorize! :create, Roxiware::NewsItem\n @news_item = Roxiware::NewsItem.new({:headline=>\"Headline\", :content=>\"Content\", :post_date=>DateTime.now.utc}, :as=>@role)\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @news_item.ajax_attrs(@role) }\n end\n end",
"def show\n @feed_item = Item.find(params[:id])\n\n render json: @feed_item\n end",
"def index\n @announcements = Announcement.visible.where(locale: I18n.locale || 'en').paginate(:page => params[:page], :per_page => 10)\n \n @announcements.first.increase_views unless @announcements.empty?\n\n @title = \"News\"\n\n logger.debug @announcement.inspect\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @announcements }\n end\n end",
"def new\n @news = News.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @news }\n end\n end",
"def read_news_item(url)\n where(:user_id => User.current_user_id, :url => url).update_all(:read => true)\n end",
"def show\n @activity_item = ActivityItem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @activity_item }\n end\n end",
"def my\n items = current_user.items\n render json: items\n end",
"def index\n @articles = current_user.articles\n json_response(@articles)\n end",
"def index\n @newsinfos = Newsinfo.all\n end",
"def index\n respond_to do |format|\n format.html\n format.json { render :json => Item.all}\n end\n\n end",
"def index\n @articles = Article.all\n\n respond_to do |format|\n format.json { render json: @articles }\n end\n end",
"def index\n @communities = Community.all\n render json: {items: @communities}\n end",
"def show\n @news_agency = NewsAgency.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @news_agency }\n end\n end",
"def index\n news_url = 'https://newsapi.org/v1/articles?source=national-geographic&sortBy=top&apiKey=ba8b42abfab743f3bfe37fe0f9df3557'\n response = HTTParty.get(news_url)\n @news_data = response\n\n @all_posts = current_user.posts\n # @new_post = Post.new #post is not tagged to user\n @new_post = current_user.posts.new\n end",
"def show\n item = Item.find(params[:id])\n render json: item\n end",
"def show\n \n render status: 200, :json => @item\n\n end",
"def index\n @rentable_items = RentableItem.all\n render json: @rentable_items\n end",
"def create\n @alumni_news_item = AlumniNewsItem.new(alumni_news_item_params)\n\n respond_to do |format|\n if @alumni_news_item.save\n format.html { redirect_to @alumni_news_item, notice: 'Alumni news was successfully created.' }\n format.json { render action: 'show', status: :created, location: @alumni_news_item }\n else\n format.html { render action: 'new' }\n format.json { render json: @alumni_news_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_api_v1_news\n @api_v1_news = News.find(params[:id])\n end",
"def index\n # Find all news from the DB\n @news = News.all\n @news.sort!{|a,b| b.created_at <=> a.created_at}\n\n @items = Kaminari.paginate_array(@news).page(params[:page]).per(3)\n \n respond_to do |format|\n format.js\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def index\n @user_news = UserNews.all\n end",
"def show\n @news_item = NewsItem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @news_item }\n end\n end",
"def show\n @news_item = NewsItem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @news_item }\n end\n end",
"def show\n @item_datum = ItemData.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item_datum }\n end\n end",
"def show\n render json: NewsEntry.find(params[:id]).to_json(include: [:feed])\n end",
"def index\n @news = News.all\n end",
"def index\n @news = News.all\n end",
"def index\n @news = News.all\n end",
"def index\n @news = News.all\n end",
"def show\n @news_post = NewsPost.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @news_post }\n end\n end",
"def set_news_item\n @news_item = NewsItem.find(params[:id])\n end",
"def set_news_item\n @news_item = NewsItem.find(params[:id])\n end",
"def set_news_item\n @news_item = NewsItem.find(params[:id])\n end",
"def show\n render json: Item.find(params[:id])\n end",
"def articles\n @articles = Article.all\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @administration }\n end\n end",
"def index\n self.identify_user\n @items = @user.items\n @itemlist = @items.map do |item|\n convert_to_json(item)\n end\n respond_to do |format|\n format.json { render :json => @itemlist }\n format.xml { render :xml => @items }\n format.html { render text: \"Unsupported Format\", status: 404 }\n end\n end",
"def show\n# @item = Item.get(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = TodoItem.find(params[:id])\n \n respond_to do |format|\n format.html\n format.json {render json: {\n success:true, \n data: [@item],\n message: \"TodoItem found.\"\n }}\n end\n end"
] |
[
"0.70880896",
"0.70823866",
"0.6791093",
"0.66198057",
"0.6564841",
"0.65466505",
"0.6528711",
"0.6506889",
"0.6488905",
"0.64824665",
"0.6431809",
"0.6416213",
"0.63568264",
"0.6353612",
"0.6343249",
"0.63359964",
"0.6335246",
"0.6325119",
"0.63034606",
"0.62951523",
"0.6275533",
"0.6267868",
"0.62556326",
"0.62491417",
"0.62491417",
"0.62491417",
"0.62491417",
"0.62433976",
"0.6222212",
"0.62094885",
"0.6200618",
"0.61841047",
"0.6169614",
"0.61658716",
"0.6162583",
"0.6160196",
"0.6159389",
"0.61554605",
"0.61298394",
"0.6119732",
"0.61144274",
"0.6110966",
"0.6100921",
"0.60977775",
"0.6088443",
"0.6088443",
"0.6088443",
"0.6088443",
"0.6085785",
"0.6084667",
"0.60483307",
"0.6046257",
"0.6026806",
"0.6026311",
"0.6017716",
"0.6016292",
"0.6012834",
"0.6003928",
"0.6000137",
"0.59999996",
"0.5998073",
"0.5997971",
"0.5996751",
"0.59904927",
"0.5990209",
"0.5980509",
"0.59794486",
"0.5978418",
"0.5970239",
"0.5964043",
"0.59554654",
"0.5953217",
"0.5941078",
"0.59406954",
"0.59361887",
"0.5934125",
"0.5931968",
"0.593012",
"0.59243476",
"0.5921128",
"0.592022",
"0.59135187",
"0.59127355",
"0.59061646",
"0.5899546",
"0.5899546",
"0.58927333",
"0.58908874",
"0.58895546",
"0.58895546",
"0.58895546",
"0.58895546",
"0.5888589",
"0.5876617",
"0.5876617",
"0.5876617",
"0.5874769",
"0.5874065",
"0.5870945",
"0.58619916",
"0.58414096"
] |
0.0
|
-1
|
POST /alumni_news_items POST /alumni_news_items.json
|
def create
@alumni_news_item = AlumniNewsItem.new(alumni_news_item_params)
respond_to do |format|
if @alumni_news_item.save
format.html { redirect_to @alumni_news_item, notice: 'Alumni news was successfully created.' }
format.json { render action: 'show', status: :created, location: @alumni_news_item }
else
format.html { render action: 'new' }
format.json { render json: @alumni_news_item.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create\n respond_to do |format|\n if @news_item.save\n format.html { redirect_to @news_item, :notice => 'News item was successfully created.' }\n format.json { render :json => @news_item, :status => :created, :location => @news_item }\n else\n format.html { render action: 'new' }\n format.json { render :json => @news_item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @news_item = NewsItem.new(news_item_params)\n\n respond_to do |format|\n if @news_item.save\n format.html { redirect_to [:admin, @news_item], notice: 'News item was successfully created.' }\n format.json { render :show, status: :created, location: @news_item }\n else\n format.html { render :new }\n format.json { render json: @news_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def alumni_news_item_params\n params.require(:alumni_news_item).permit(:title, :content)\n end",
"def create\n @item = Item.new(item_params)\n\n if @item.save\n render json: @item\n else\n render json: { error: t('story_create_error') }, status: :unprocessable_entity\n end\n end",
"def create\n item = list.items.create!(item_params)\n render json: item, status: 201\n end",
"def news_item_params\n params.require(:news_item).permit(:actionItemID, :newsText, :newsDate, :title)\n end",
"def create\n params[:post_date] = DateTime.now\n respond_to do |format|\n @news_item.assign_attributes(params, :as=>@role)\n if @news_item.save\n\t format.html { redirect_to @news_item, :notice => 'NewsItem was successfully updated.' }\n format.json { render :json => @news_item.ajax_attrs(@role) }\n else\n\t format.html { redirect_to @news_item, :notice => 'Failure updating news_item.' }\n format.json { render :json=>report_error(@news_item)}\n\tend\n end\n end",
"def news_item_params\n params.require(:news_item).permit(:title, :date, :content, :id_for_app, :url)\n end",
"def create\n @discourse_news_item = DiscourseNewsItem.new(discourse_news_item_params)\n\n respond_to do |format|\n if @discourse_news_item.save\n format.html { redirect_to @discourse_news_item, notice: 'Discourse news item was successfully created.' }\n format.json { render :show, status: :created, location: @discourse_news_item }\n else\n format.html { render :new }\n format.json { render json: @discourse_news_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def news_item_params\n params.require(:news_item).permit(:news, :title, :description, :link, :representative_id, :issue, :rating)\n end",
"def news_item_params\n params.require(:news_item).permit(:news, :title, :description, :link, :representative_id, :issue, :rating)\n end",
"def create\n @news = News.new(news_params)\n\n respond_to do |format|\n if @news.save\n format.html { redirect_to @news, notice: 'An item was successfully created.' }\n format.json { render :show, status: :created, location: @news }\n else\n format.html { render :new }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(item_params)\n # @item.build_note\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render json: @item, status: :created, location: @item }\n else\n respond_with(@items)\n end\n end\n end",
"def news_item_params\n params.require(:news_item).permit(:posted_date, :title, :body, :picture, :is_book, :is_news, :piclink, :book_number, :group_id, :friendly_link)\n end",
"def create\n @news_item = NewsItem.new(params[:news_item])\n @news_item.created_by = current_user\n\n respond_to do |format|\n if @news_item.save\n flash[:notice] = 'NewsItem was successfully created.'\n format.html { redirect_to news_item_url(@news_item) }\n format.xml { head :created, :location => news_item_url(@news_item) }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @news_item.errors.to_xml }\n end\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.haml\n format.json { render :json => @news_item }\n end\n end",
"def news_item_params\n params.require(:news_item).permit(:user_id, :carer_user_id, :location, :narrative)\n end",
"def create\n create_params = item_params\n item = Item.new(\n name: create_params[:name], \n is_complete: false, #create_params[:is_complete], \n list_id: create_params[:list_id])\n\n item.save!\n render json: item\n end",
"def create\n\n respond_to do |format|\n if @news_item.save\n format.html { redirect_to(news_items_path, :notice => t(\"screens.notice.successfully_created\")) }\n format.xml { render :xml => @news_item, :status => :created, :location => @news_item }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @news_item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @news_item = NewsItem.new(params[:news_item])\n\n respond_to do |format|\n if @news_item.save\n flash[:notice] = 'NewsItem was successfully created.'\n format.html { redirect_to(@news_item) }\n format.xml { render :xml => @news_item, :status => :created, :location => @news_item }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @news_item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(item_params)\n if @item.save\n @items = Item.all\n render status: 201, :json => @item\n \n else\n render status: 404, json: { message: @item.errors}.to_json\n end\n \n \n end",
"def create\n item = Item.new(item_params)\n item.user = current_user\n if item.save\n render json: item\n else\n render json: {errors: item.errors}, status: :unprocessable_entity\n end\n end",
"def create\n puts params\n item_data = {\n :title => params[:title],\n :description => params[:description]\n }\n @item = current_user.items.build(item_data)\n if params[:attachments]\n params[:attachments].each do |att_id|\n @att = Attachment.find(att_id)\n @item.attachments.push(@att)\n if @att.att_type == 'photo'\n @item.photos.build(\n photo_url: @att.url\n )\n end\n end\n end\n if @item.save\n respond_to do |format|\n format.json { render :json => @item.to_json, :status => 200 }\n format.xml { head :ok }\n format.html { redirect_to :action => :index }\n end\n else\n respond_to do |format|\n format.json { render :text => \"Could not create item\", :status => :unprocessable_entity } # placeholder\n format.xml { head :ok }\n format.html { render :action => :new, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(params[:item])\n @item.subjects = Subject.find(params[:subject_ids]) if params[:subject_ids]\n @items = load_items(@item)\n \n @months = Month.where(['publish=?', true]).order('position, calendar_type_id')\n respond_to do |format|\n if @item.save\n format.html { redirect_to(admin_item_url(@item), :notice => 'Item was successfully created.') }\n format.xml { render :xml => @item, :status => :created, :location => @item }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @item_datum = ItemData.new(params[:item_datum])\n\n respond_to do |format|\n if @item_datum.save\n format.html { redirect_to @item_datum, notice: 'Item datum was successfully created.' }\n format.json { render json: @item_datum, status: :created, location: @item_datum }\n else\n format.html { render action: \"new\" }\n format.json { render json: @item_datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n item = Item.new(item_params)\n item.done = \"0\"\n item.trash = \"0\"\n\n if item.save\n render json: {data:item}, status: :created\n else\n render json: {data:item}, status: :unprocessable_entity\n end\n end",
"def set_alumni_news_item\n @alumni_news_item = AlumniNewsItem.find(params[:id])\n end",
"def index\n respond_to do |format|\n format.html # index.html.haml\n format.json { render :json => @news_items }\n end\n end",
"def create\n @item = @client.items.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully added.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = build_item\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to items_path, notice: 'アップロードしたでー' }\n format.json { render action: 'show', status: :created, location: @item }\n else\n format.html { render action: 'new' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @news = New.new(news_params)\n\n if @news.save\n render json: @news, status: :created\n else\n render json: @news.errors, status: :unprocessable_entity\n end\n end",
"def index\n @enable_news_edit = true\n @news = Roxiware::NewsItem.order(\"post_date DESC\")\n @title = @title + \" : News\"\n @meta_description = @title\n clean_news = []\n @news.each do |news_item| \n @meta_keywords = @meta_keywords + \", \" + news_item.headline\n\tclean_news << news_item.ajax_attrs(@role)\n end \n respond_to do |format|\n format.html\n\tformat.json { render :json=>clean_news }\n end\n end",
"def create\n @item = Item.new(item_params)\n if @item.save\n render json: ItemSerializer.new(@item)\n else\n render json: @section.errors, status: :unprocessable_entity\n end\n end",
"def create\n @request_item = RequestItem.new(request_item_params)\n @request_item.item = Item.new(name: params[:request_item][:item][:name])\n\n if @request_item.save\n render json: @request_item \n else\n render json: @request_item.errors, status: :bad_request\n end\n end",
"def create \n #whitelist params and save them to a variable \n item_params = params.require(:item).permit(:name, :category, :image, :price)\n #create a new item from 'item_params'\n @item = Item.new(item_params)\n #if item saves, render the new item in JSON\n if @item.save \n render json: @item\n end\n end",
"def create\n\t\titem = Item.create(item_params)\n\t\trender json: item\n\tend",
"def item_params\n params.require(:item).permit(:item, :body)\n end",
"def new\n authorize! :create, Roxiware::NewsItem\n @news_item = Roxiware::NewsItem.new({:headline=>\"Headline\", :content=>\"Content\", :post_date=>DateTime.now.utc}, :as=>@role)\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @news_item.ajax_attrs(@role) }\n end\n end",
"def create\n @item = Item.new(params[:item])\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to lists_path, :notice => 'Item was successfully created.' }\n format.json { render :json => lists_path, :status => :created, :location => lists_path }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def item_params\n params.require(:item).permit(:title, :body)\n end",
"def create\n @item = Item.new(params[:item])\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to root_url, notice: 'Item was successfully created.' }\n format.json { render json: @item, status: :created, item: @item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user = User.find(current_user.id)\n @item = @user.items.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to '/items', notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(item_params)\n @item.user = current_user\n @item.date = Parsi::Date.parse(item_params['date']).to_gregorian unless item_params['date'].blank?\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to items_url, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_item(user_id, data) \n data = data.just(SETTABLE_ITEM_FIELDS)\n data[:user_id] = user_id\n data[:title] ||= 'item'\n data[:price] ||= 5\n data[:price] = data[:price].to_i\n data[:slug] = get_unique_slug($items,:slug,data[:title])\n\n data[:imgs] = data[:imgs].to_a.map {|link| {link: link}}\n data[:videos] = data[:videos].to_a.map {|link| {link: link}}\n data[:status] = :pending\n item = $items.add(data)\nend",
"def create\n @itemtipo = Itemtipo.new(itemtipo_params)\n\n if @itemtipo.save\n render json: @itemtipo, status: :created, location: @itemtipo\n else\n render json: @itemtipo.errors, status: :unprocessable_entity\n end\n end",
"def create\n ListItem.transaction do\n item = Item.new(item_params)\n item.save\n\n @list_item = ListItem.new(list_item_params)\n @list_item.item_id = item.id\n @list_item.list_id = params[:list_id]\n\n\n if @list_item.save\n render json: @list_item, status: :created\n else\n render json: @list_item.errors, status: :unprocessable_entity\n end\n end\n end",
"def create\n\n @item = Item.new(params[:item])\n @item.user_id = current_user.id\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to '/main', :notice => 'Item was successfully created.' }\n format.json { render :json => @item, :status => :created, :location => @item }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(params[:item])\n @item.save\n respond_with @item\n end",
"def createItem(title, description, date)\n new_item = List.new\n new_item.title = title\n new_item.description = description\n new_item.save\n new_item.date = date\n end",
"def create\n @news_list = NewsList.new(params[:news_list])\n\n respond_to do |format|\n if @news_list.save\n format.html { redirect_to @news_list, notice: 'News list was successfully created.' }\n format.json { render json: @news_list, status: :created, location: @news_list }\n else\n format.html { render action: \"new\" }\n format.json { render json: @news_list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new#(item_params)\n\n # jsonとして渡ってきたパラメターをパースして,新規作成したitemに設定\n @item.title = params['item']['title']\n @item.user_id = params['item']['user_id']\n @item.start = params['item']['start']\n @item.end = params['item']['end']\n @item.allDay = params['item']['all_day']\n\n # upload_file = image_params[:file]\n # image = {}\n # if upload_file != nil\n # image[:filename] = upload_file.original_filename\n # image[:file] = upload_file.read\n # end\n # @image = Image.new(image)\n # if @image.save\n # flash[:success] = \"画像を保存しました。\"\n # # redirect_to @image\n # else\n # flash[:error] = \"保存できませんでした。\"\n # end\n\n respond_to do |format|\n if @item.save\n # format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.html { redirect_to @item }\n format.json { render :show, status: :created, location: @item }\n #format.html { redirect_to edit_item_path(@item.id) }\n #format.json { redirect_to edit_item_path(@item.id) }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n user = current_user\n params[:news][:category_news_id] = params[:category]\n \n @news = user.news.new(params[:news])\n\n respond_to do |format|\n if @news.save\n format.html { redirect_to news_index_url, notice: 'News was successfully created.' }\n format.json { render json: @news, status: :created, location: @news }\n else\n format.html { render action: \"new\" }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(params[:item])\n @item.user = current_user\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, :notice => 'Item was successfully created.' }\n format.json { render :json => @item, :status => :created, :location => @item }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new_item_params\n params.require(:new_item).permit(:title, :content, :url, :description, :url, :url_to_image, :author)\n end",
"def create\n @item = current_user.items.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to root_path, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @list = List.find(params[:item][:list_id])\n params[:item][:price] = params[:item][:price].nil? ? 0 : (params[:item][:price].to_f * 100).to_i\n\n article_id = unless !params[:article] or params[:article][:name].blank?\n article = Article.find_by_name(params[:article][:name])\n if article.nil?\n Article.create!(params[:article]).id\n else\n article.id\n end\n else\n Article.find(params[:item][:article_id]).id rescue nil\n end\n\n @item = @list.items.find_by_article_id(article_id)\n\n if @item.nil?\n @item = Item.create(params[:item].merge({ :article_id => article_id }))\n else\n @item.quantity = @item.quantity + params[:item][:quantity].to_i\n @item.update_attribute(:price, params[:item][:price]) unless @item.price == params[:item][:price]\n end\n\n if @item.save\n @item.article.update_attribute(:last_price, @item.price) unless @item.price == @item.article.last_price\n if request.xhr?\n @articles = current_user.articles.for_list(@list)\n @new_item = Item.new\n render :create\n else\n redirect_to(list_path(@list), :notice => t('controllers.items.item.created', :count => @item.quantity, :name => @item.article.name))\n end\n else\n @articles = Article.select([:id, :name]).order(:name)\n render :action => \"new\"\n end\n end",
"def create\n\n @item = Item.new(item_params)\n #まだView設定がまだのため仮の登録データ、あとでViewからのデータをitem_paramsで定義します。\n atai = 1\n watasi = \"hoge\"\n\n @item.status = atai\n @item.upper_category = watasi\n @item.middle_category = watasi\n @item.lower_category = watasi\n @item.seller = watasi\n @item.size_type = watasi\n \n \n @item.save\n redirect_to root_path\n # respond_to do |format|\n # if @item.save\n # format.html { redirect_to @item, notice: 'Item was successfully created.' }\n # format.json { render :show, status: :created, location: @item }\n # else\n # format.html { render :new }\n # format.json { render json: @item.errors, status: :unprocessable_entity }\n # end\n # end\n end",
"def create\n @curriculumID = Curriculum.find(params[:curriculum_id])\n @item = @curriculumID.items.build(params[:item])\n respond_to do |format|\n if @item.save\n format.html { redirect_to @curriculumID, notice: \"Lehrplaninhalt #{@item.title} wurde erfolgreich angelegt.\" }\n format.json { render action: 'show', status: :created, location: @item } \n else\n format.html { render action: 'new' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_todo_item(name, list_id)\n data = {\n item: {\n name: name\n }\n }\n rest(\"post\", \"lists/#{list_id}/items\", data)\n end",
"def create\n\n \t\t@item = current_user.items.build(item_params)\n \t\tif @item.save\n \t\t\tflash[:success] = \"Item created!\"\n \t\t\tredirect_to items_path\n \t\telse\n \t\t\t@feed_items = []\n \t\t\trender 'static_pages/home'\n \t\tend\n \tend",
"def create\n @item = Item.new(params[:item])\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render json: @item, status: :created, location: @item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(params[:item])\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render json: @item, status: :created, location: @item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(params[:item])\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render json: @item, status: :created, location: @item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(params[:item])\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render json: @item, status: :created, location: @item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(params[:item])\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render json: @item, status: :created, location: @item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(params[:item])\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render json: @item, status: :created, location: @item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(params[:item])\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render json: @item, status: :created, location: @item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(params[:item])\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render json: @item, status: :created, location: @item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def discourse_news_item_params\n params.fetch(:discourse_news_item, {})\n end",
"def set_news_item\n @news_item = NewsItem.find(params[:id])\n end",
"def set_news_item\n @news_item = NewsItem.find(params[:id])\n end",
"def set_news_item\n @news_item = NewsItem.find(params[:id])\n end",
"def create\n @item = current_user.items.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: \"Item was successfully created.\" }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @admin_useful_news = Admin::UsefulNews.new(params[:useful_news])\n\n respond_to do |format|\n if @admin_useful_news.save\n format.html { redirect_to admin_useful_news_index_path, notice: 'Useful news was successfully created.' }\n format.json { render json: @admin_useful_news, status: :created, location: @admin_useful_news }\n else\n format.html { render action: \"new\" }\n format.json { render json: @admin_useful_news.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @news = New.order('created_at DESC')\n render json: @news.as_json(except: [:body], methods: [:short_body]), status: :ok\n end",
"def update\n params[:post_date] = DateTime.now\n respond_to do |format|\n @news_item.assign_attributes(params, :as=>@role)\n if @news_item.save\n format.html { redirect_to @news_item, :notice => 'NewsItem was successfully updated.' }\n format.json { render :json => @news_item.ajax_attrs(@role) }\n else\n\t format.html { redirect_to @news_item, :notice => 'Failure updating news_item.' }\n format.json { render :json=>report_error(@news_item)}\n end\n end\n end",
"def create\n @item = Todo.create title: params[:title], done: false, created_at: DateTime.now, done_at: nil\n render :json => @item.to_json\n end",
"def create\n @news = News.new(params[:news])\n\n respond_to do |format|\n if @news.save\n format.html { redirect_to @news, notice: 'Новость добавлена.' }\n format.json { render json: @news, status: :created, location: @news }\n else\n format.html { render action: \"new\" }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @feed_item = FeedItem.new(feed_item_params)\n\n respond_to do |format|\n if @feed_item.save\n format.json { render :show, status: :created, location: @feed_item }\n else\n format.json { render json: @feed_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @news_list = NewsList.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @news_list }\n end\n end",
"def create\n @item = Item.new(params[:item])\n @item.user = current_user\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render json: @item, status: :created, location: @item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n pt = params[:news]\n @news = News.new(pt)\n @news.user_id = current_user.id\n @news.node_id = params[:node] || pt[:node_id]\n\n respond_to do |format|\n if @news.save\n format.html { redirect_to @news, notice: t(\"news.create_news_success\")}\n format.json { render json: @news, status: :created, location: @news }\n else\n format.html { render action: \"new\" }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @item = current_user.items.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item }\n end\n end",
"def item_create\n @item = Item.new(item_params)\n respond_to do |format|\n if @item.save\n format.html { redirect_to item_index_path, notice: 'O item foi criado com sucesso.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :item_new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @task_item = Task::Item.new(task_item_params)\n\n respond_to do |format|\n if @task_item.save\n format.html { redirect_to task_list_path(@task_item.list), notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @task_item }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.js { render :new, status: :unprocessable_entity }\n format.json { render json: @task_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n # defined object to receive strict item_params including :description, :price, :stockQty ; else return 400\n @item = Item.new(item_params)\n \n if @item.save\n render json: @item.to_json, status: 201\n else\n head 400\n end\n end",
"def create\n @item = Item.new(item_params)\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_item_to_project\n @project = Project.find(params[:id])\n @item = Item.find(params[:item_id])\n\n @project.items << @item\n\n render json: @project, include: :items\n end",
"def create\n @item = current_owner.items.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to items_path, notice: 'Item was created successfully' }\n format.json { render :show, status: :created, location: items_path }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
[
"0.69212556",
"0.679088",
"0.6723702",
"0.6716267",
"0.67068595",
"0.6584015",
"0.65362185",
"0.640015",
"0.6383678",
"0.6381812",
"0.6381812",
"0.6365448",
"0.63312453",
"0.6326434",
"0.62806755",
"0.625567",
"0.6251146",
"0.62226677",
"0.6180844",
"0.61353314",
"0.61287814",
"0.6128745",
"0.610891",
"0.6050347",
"0.6036918",
"0.6017029",
"0.6012427",
"0.6009949",
"0.59888303",
"0.59831274",
"0.597241",
"0.5958975",
"0.5951392",
"0.59482175",
"0.59152675",
"0.59014094",
"0.590017",
"0.5899838",
"0.5895683",
"0.58919793",
"0.58883333",
"0.5881319",
"0.58621603",
"0.5861774",
"0.58614665",
"0.58532405",
"0.5853164",
"0.5830638",
"0.581063",
"0.58058476",
"0.5797336",
"0.5783516",
"0.5782205",
"0.57799935",
"0.57741284",
"0.57722354",
"0.57704026",
"0.57688165",
"0.5768636",
"0.5767985",
"0.57653016",
"0.57653016",
"0.57653016",
"0.57653016",
"0.57653016",
"0.57653016",
"0.57653016",
"0.57649124",
"0.5764475",
"0.57610786",
"0.57610786",
"0.57610786",
"0.57604474",
"0.575787",
"0.574635",
"0.574188",
"0.5721615",
"0.5718554",
"0.5712133",
"0.57097906",
"0.57019866",
"0.56946766",
"0.5692015",
"0.56899416",
"0.5686531",
"0.5678111",
"0.56771624",
"0.56648785",
"0.5662739",
"0.56575376",
"0.56575376",
"0.56575376",
"0.56575376",
"0.56575376",
"0.56575376",
"0.56575376",
"0.56575376",
"0.56575376",
"0.56575376",
"0.56575376"
] |
0.7126492
|
0
|
PATCH/PUT /alumni_news_items/1 PATCH/PUT /alumni_news_items/1.json
|
def update
respond_to do |format|
if @alumni_news_item.update(alumni_news_item_params)
format.html { redirect_to @alumni_news_item, notice: 'Alumni news was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @alumni_news_item.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update\n respond_to do |format|\n if @news_item.update_attributes(params[:news_item])\n format.html { redirect_to @news_item, :notice => 'News item was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: 'edit' }\n format.json { render :json => @news_item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n render json: Item.update(params[\"id\"], params[\"item\"])\n end",
"def update\n respond_to do |format|\n if @news_item.update(news_item_params)\n format.html { redirect_to [:admin, @news_item], notice: 'News item was successfully updated.' }\n format.json { render :show, status: :ok, location: @news_item }\n else\n format.html { render :edit }\n format.json { render json: @news_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n @news.title = news_params[\"title\"]\n @news.content = news_params[\"content\"]\n @news.user_id = @current_user.id\n if @news.save\n format.html { redirect_to @news, notice: 'News was successfully updated.' }\n format.json { head :no_content }\n end\n end\n end",
"def update\n @news = News.find(params[:id])\n pt = params[:news]\n @news.node_id = pt[:node_id]\n @news.title = pt[:title]\n @news.body = pt[:body]\n\n respond_to do |format|\n if @news.update_attributes(params[:news])\n format.html { redirect_to @news, notice: t(\"news.update_news_success\") }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(params)\n res = @client.put(path, nil, params, \"Content-Type\" => \"application/json\")\n @attributes = res.json if res.status == 201\n res\n end",
"def update\n respond_to do |format|\n if @news.update(news_params)\n format.html { redirect_to @news, notice: 'An item was successfully updated.' }\n format.json { render :show, status: :ok, location: @news }\n else\n format.html { render :edit }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n respond_to do |format|\n if @news_item.update_attributes(params[:news_item])\n format.html { redirect_to(news_items_path, :notice => t(\"screens.notice.successfully_updated\")) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @news_item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n\n #update the item of request_item\n if (params[:request_item].present?)\n @request_item.item = params[:request_item][:item].present? ? Item.new(name: params[:request_item][:item][:name]) : @request_item.item\n end\n #update all other parameters\n if @request_item.update(request_item_params)\n render json: @request_item\n else\n render json: @request_item.errors, status: :bad_request\n end\n\n end",
"def update\n @news_item = NewsItem.find(params[:id])\n @news_item.created_by = current_user\n\n respond_to do |format|\n if @news_item.update_attributes(params[:news_item])\n flash[:notice] = 'NewsItem was successfully updated.'\n format.html { redirect_to news_item_url(@news_item) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @news_item.errors.to_xml }\n end\n end\n end",
"def update\n respond_to do |format|\n if @discourse_news_item.update(discourse_news_item_params)\n format.html { redirect_to @discourse_news_item, notice: 'Discourse news item was successfully updated.' }\n format.json { render :show, status: :ok, location: @discourse_news_item }\n else\n format.html { render :edit }\n format.json { render json: @discourse_news_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @news.update_attributes(news_params)\n render json: @news, status: :ok\n else\n render json: {message: \"Not found\"}, status: :not_found\n end\n end",
"def update\n @todo = Todo.find(params[:id])\n @todo.update_attributes(params[:todo])\n render :json => @todo\n end",
"def update\n params[:post_date] = DateTime.now\n respond_to do |format|\n @news_item.assign_attributes(params, :as=>@role)\n if @news_item.save\n format.html { redirect_to @news_item, :notice => 'NewsItem was successfully updated.' }\n format.json { render :json => @news_item.ajax_attrs(@role) }\n else\n\t format.html { redirect_to @news_item, :notice => 'Failure updating news_item.' }\n format.json { render :json=>report_error(@news_item)}\n end\n end\n end",
"def update\n\n if @api_v1_item.update(api_v1_item_params)\n render json: @api_v1_item\n else\n render json: @api_v1_item.errors\n end\n end",
"def update\n @news_item = NewsItem.find(params[:id])\n\n respond_to do |format|\n if @news_item.update_attributes(params[:news_item])\n flash[:notice] = 'NewsItem was successfully updated.'\n format.html { redirect_to(@news_item) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @news_item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @news = News.find(params[:id])\n\n respond_to do |format|\n if @news.update_attributes(params[:news])\n format.html { redirect_to @news, notice: 'Новость изменена.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @todo = Todo.find(params[:id])\n if @todo.update_attributes(todo_params)\n render json: @todo, status: :ok\n else\n render json: @todo.errors, status: 422\n end\n end",
"def update(url, data)\n RestClient.put url, data, :content_type => :json\nend",
"def update\n @admin_useful_news = Admin::UsefulNews.find(params[:id])\n\n respond_to do |format|\n if @admin_useful_news.update_attributes(params[:useful_news])\n format.html { redirect_to admin_useful_news_index_path, notice: 'Useful news was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @admin_useful_news.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @news = News.find(params[:id])\n\n respond_to do |format|\n if @news.update_attributes(params[:news])\n format.html { redirect_to @news, notice: 'News was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @item.update_attributes(item_params)\n render json: @item, status: :ok\n else\n render_error(@item, :unprocessable_entity)\n end\n end",
"def update\n respond_to do |format|\n if @api_v1_todo.update(api_v1_todo_params)\n format.json { render json: @api_v1_todo, status: :ok }\n else\n format.json { render json: @api_v1_todo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @news.update(news_params)\n format.html { redirect_to users_path, notice: 'Noticia modificada exitosamente' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @item.update(item_params)\n render json: @item, status: :ok\n else\n render json: @item.errors, status: :unprocessable_entity\n end\n end",
"def update!(**args)\n @items = args[:items] if args.key?(:items)\n @request_id = args[:request_id] if args.key?(:request_id)\n end",
"def update!(**args)\n @items = args[:items] if args.key?(:items)\n @request_id = args[:request_id] if args.key?(:request_id)\n end",
"def update\n @item = Item.find(params[:id])\n @item.update_attributes(params[:item])\n respond_with @item\n end",
"def update_attributes(attributes = {},user)\n Rails.logger.debug \"Call to article.update_attributes\"\n if self.valid? #Validate if the Article object is valid\n Rails.logger.debug \"The news article is valid!\"\n \n #Create a raw Article object\n article = {'title'=>attributes[:title],\n 'content'=>attributes[:content],\n 'date'=>Util.date_to_epoch(attributes[:date]),\n 'creatorEmail'=>self.creator_email,\n 'institutionId'=>user['institutionId'] \n }\n reqUrl = \"/api/newsArticle/#{self.id}\" #Set the request url\n rest_response = MwHttpRequest.http_put_request(reqUrl,article,user['email'],user['password']) #Make the PUT request to the server with the required parameters\n Rails.logger.debug \"Response from server: #{rest_response.code} #{rest_response.message}: #{rest_response.body}\"\n if rest_response.code == \"200\" #Validate if the response from the server is 200, which means OK\n article = Article.rest_to_article(rest_response.body)\n return true, article #Return success\n else\n return false, \"#{rest_response.code}\", \"#{rest_response.message}\"#Return error\n end\n else\n Rails.logger.debug self.errors.full_messages\n return false, self.errors.full_messages #Return invalid object error\n end\n end",
"def update\n json_response(@food_item.update!(food_item_params))\n end",
"def update\n authorize @system_news, :update?\n respond_to do |format|\n if @system_news.update(system_news_params)\n format.html { redirect_to @system_news, notice: 'News was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @system_news.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @news = News.find(params[:id])\n @title = t('label.news.editing')\n\n respond_to do |format|\n if @news.update_attributes(params[:news])\n flash[:notice] = t('message.news.updated')\n format.html { redirect_to(news_item_path(:id=>@news)) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @news.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @item = TodoItem.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:todo_item])\n format.html { redirect_to @item, notice: 'TodoItem was successfully updated.' }\n format.json {render json: {\n success: true,\n data: [],\n message: \"TodoItem was successfully updated.\"\n }}\n else\n format.html { render action: \"edit\" }\n format.json { render json: {\n success: false,\n data: [],\n message: @item.errors\n }}\n end\n end\n end",
"def update\n @itemtipo = Itemtipo.find(params[:id])\n\n if @itemtipo.update(itemtipo_params)\n head :no_content\n else\n render json: @itemtipo.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @news.update(news_params)\n format.html { redirect_to @news, notice: 'Nyheten uppdaterades!' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @news_list = NewsList.find(params[:id])\n\n respond_to do |format|\n if @news_list.update_attributes(params[:news_list])\n format.html { redirect_to @news_list, notice: 'News list was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @news_list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = @user.items.find(params[:id])\n\n @item.update(:type_list => \"\", :tag_list => \"\")\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to [@user, @item], notice: 'item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n\n\n end",
"def update\n respond_to do |format|\n if @newsinfo.update(newsinfo_params)\n format.html { redirect_to @newsinfo, notice: 'Newsinfo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @newsinfo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @todo = Todo.find(params[:todo][:id])\n if @todo.update_attributes(user_params)\n render json: @todo\n else\n render nothing: true, status: :bad_request\n end\n end",
"def update\n respond_to do |format|\n if @news.update(news_params)\n format.html { redirect_to @news, notice: 'Новость успешно обновлена' }\n format.json { render :show, status: :ok, location: @news }\n else\n format.html { render :edit }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = @client.items.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @todo.update(todo_params.merge!(updated_by_id: current_user.id))\n render json: @todo\n else\n render json: {errors: @todo.errors.full_messages}, status: 422\n end\n end",
"def update\n Rails.logger.debug params.inspect\n @item = Item.find(params[:id])\n respond_to do |format|\n if @item.update_attributes(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n respond_with(@items)\n end\n end\n end",
"def update\n respond_to do |format|\n if @news.update(news_params)\n format.html { redirect_to @news, success: 'Запись успешно обновлена.' }\n format.json { render :show, status: :ok, location: @news }\n else\n format.html { render :edit }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @company_news.update(company_news_params)\n format.html { redirect_to company_news_path, notice: 'Новость отредактирована' }\n format.json { render :show, status: :ok, location: @company_news }\n else\n format.html { render :edit }\n format.json { render json: @company_news.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to lists_path, :notice => 'Item was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @items = args[:items] if args.key?(:items)\n @title = args[:title] if args.key?(:title)\n end",
"def update!(**args)\n @items = args[:items] if args.key?(:items)\n @title = args[:title] if args.key?(:title)\n end",
"def update\n \n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, :notice => 'Item was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n \n @list_item = ListItem.find(params[:id])\n\n if @list_item.update(list_item_params)\n head :no_content\n else\n render json: @list_item.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @convenience_item.update(convenience_item_params)\n format.html { redirect_to @convenience_item, notice: 'Convenience item was successfully updated.' }\n format.json { render :show, status: :ok, location: @convenience_item }\n else\n format.html { render :edit }\n format.json { render json: @convenience_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n item = Item.find(params[:id])\n if item.user == current_user\n if item.update(item_params)\n render json: item\n else\n render json: {errors: item.errors}, status: :unprocessable_entity\n end\n else\n render json: {errors: \"you can't do it\"}, status: :unprocessable_entity\n end\n end",
"def update\n params[:news][:category] = \"默认\" if params[:news][:category] == \"\"\n @news = News.find(params[:id])\n \n respond_to do |format|\n if @news.update_attributes(params[:news])\n flash[:success] = \"恭喜,新闻修改成功\"\n format.html { redirect_to news_index_path(:id => @news.id) }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @item.update(item_params)\n render status: 201, :json => @item, :include =>[{:location =>{:except=>[:id, :created_at, :updated_at]}}, {:food =>{:except =>[:id, :created_at, :updated_at]}}], :except => [:created_at, :updated_at, :food_id, :location_id]\n else\n render status: 404, json: { message: @item.errors}.to_json\n end\n\n \n end",
"def update\n @todo = Todo.find(params[:id])\n if @todo.update(todo_params)\n render json: @todo\n else\n render json: @todo.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @test_item.update(test_item_params)\n format.html { redirect_to @test_item, notice: 'Test item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @test_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @news_update.update(news_update_params)\n format.html { redirect_to @news_update, notice: 'News update was successfully updated.' }\n format.json { render :show, status: :ok, location: @news_update }\n else\n format.html { render :edit }\n format.json { render json: @news_update.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n@article=Article.find(params[:id])\n @article.title=params[:article][:title]\n@article.body=params[:article][:body]\n respond_to do |format|\n if @article.update(article_params)\n format.html { redirect_to @article, notice: 'successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @article.errors, status: :unprocessable_entity }\n end\n end\nend",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def UpdateView params = {}\n \n APICall(path: 'views.json',method: 'PUT',payload: params.to_json)\n \n end",
"def update\n \n params[:news][:category_news_id] = params[:category]\n @news = News.find(params[:id])\n\n respond_to do |format|\n if @news.update_attributes(params[:news])\n format.html { redirect_to news_index_url, notice: 'News was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n respond_to do |format|\n if @item.update_attributes(params[:item])\n flash[:notice] = \"Item has been updated\"\n format.json { render :json => @item.to_json, :status => 200 }\n format.xml { head :ok }\n format.html { render :action => :edit }\n else\n format.json { render :text => \"Could not update item\", :status => :unprocessable_entity } #placeholder\n format.xml { render :xml => @item.errors, :status => :unprocessable_entity }\n format.html { render :action => :edit, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, :notice => 'Item was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @item_datum = ItemData.find(params[:id])\n\n respond_to do |format|\n if @item_datum.update_attributes(params[:item_datum])\n format.html { redirect_to @item_datum, notice: 'Item datum was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item_datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def updateItem(app, repo_url, item, id)\n headers = defaultHeaders(app[\"token\"])\n data = id.merge(item).to_json\n response = HTTParty.post(repo_url,\n headers: headers,\n body: data)\n response \nend",
"def update\n respond_to do |format|\n if @news.update(news_params)\n format.html { redirect_to news_index_path, notice: 'News was successfully updated.' }\n format.json { render :show, status: :ok, location: @news }\n else\n format.html { render :edit }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @todo_item.update(todo_item_params)\n format.html { redirect_to @todo_item, notice: 'Todo item was successfully updated.' }\n format.json { render :show, status: :ok, location: @todo_item }\n else\n format.html { render :edit }\n format.json { render json: @todo_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to items_path, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @news_agency = NewsAgency.find(params[:id])\n\n respond_to do |format|\n if @news_agency.update_attributes(params[:news_agency])\n format.html { redirect_to @news_agency, notice: 'News agency was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @news_agency.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n item = @list.list_items.find(params[:id])\n\n if item.update_attributes(params[:list_item])\n render json: item\n else\n error(t('messages.list_item.errors.update'))\n end\n end",
"def update\n\t\t# @article = ArticleCrawler.new(resource_item_params['source_url']) if !resource_item_params['source_url'].nil?\n\t respond_to do |format|\n\t if @resource_item.update(resource_item_params)\n\t \tgon.resource_item = @resource_item\n\t format.html { redirect_to @resource_item, notice: 'Resource item was successfully updated.' }\n\t if Rails.env.production?\n\t \tRestClient.patch(\"https://lensshift-drive.firebaseio.com/resources/#{@resource_item.google_doc_id}.json\", @resource_item.to_json)\n\t end\n\t format.json { render json: @resource_item.to_json, status: :ok, location: @resource_item }\n\t else\n\t \tgon.resource_item = resource_item_params\n\t format.html { render :edit, location: @resource_item, status: :unprocessable_entity, error: @resource_item.errors }\n\t format.json { render json: @resource_item.errors, status: :unprocessable_entity }\n\t end\n\t end\n\tend",
"def update_by_body\n @person = Person.find(person_update_params[:id])\n\n if @person.update_attributes(person_update_params)\n render json: { status: 'PUT Success' }, status: :ok\n else\n render json: { status: 'Error', message:'Error updating person', person: @person.errors }, status: :unprocessable_entity\n end\n end",
"def set_alumni_news_item\n @alumni_news_item = AlumniNewsItem.find(params[:id])\n end",
"def update\n @item = Item.find(params[:id])\n\n get_relations_from_params\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @alumno = Alumno.find(params[:id])\n\n respond_to do |format|\n if @alumno.update_attributes(params[:alumno])\n head :no_content\n else\n render json: @alumno.errors, status: :unprocessable_entity\n end\n end\n end",
"def update\n respond_to do |format|\n if @news.update(news_params)\n format.html { redirect_to @news, notice: 'News was successfully updated.' }\n format.json { render :show, status: :ok, location: @news }\n else\n format.html { render :edit }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @news.update(news_params)\n format.html { redirect_to @news, notice: 'News was successfully updated.' }\n format.json { render :show, status: :ok, location: @news }\n else\n format.html { render :edit }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @research_item = ResearchItem.find(params[:id])\n\n respond_to do |format|\n if @research_item.update_attributes(params[:research_item])\n format.html { redirect_to @research_item, :notice => 'Research item was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @research_item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
[
"0.68376845",
"0.66334856",
"0.662979",
"0.65002084",
"0.6474196",
"0.6450485",
"0.6431119",
"0.6429213",
"0.6350141",
"0.6314212",
"0.62687004",
"0.6259719",
"0.62417406",
"0.62033004",
"0.6198649",
"0.6178684",
"0.6169075",
"0.61415565",
"0.6141403",
"0.6119451",
"0.61102885",
"0.6108086",
"0.61029035",
"0.60997",
"0.60955316",
"0.60914963",
"0.60914963",
"0.608628",
"0.60489357",
"0.60314643",
"0.60225266",
"0.6021613",
"0.60192543",
"0.6018704",
"0.6018127",
"0.6011055",
"0.60064024",
"0.5993847",
"0.5992862",
"0.5992202",
"0.5989387",
"0.59832245",
"0.5974567",
"0.5969438",
"0.59651905",
"0.59634566",
"0.596175",
"0.5961693",
"0.5961693",
"0.59573317",
"0.59496915",
"0.594154",
"0.593967",
"0.59331435",
"0.59329045",
"0.5925078",
"0.59245193",
"0.5917703",
"0.59135234",
"0.59108305",
"0.59108305",
"0.59108305",
"0.59108305",
"0.59108305",
"0.59108305",
"0.59108305",
"0.59108305",
"0.59108305",
"0.59108305",
"0.59108305",
"0.59099275",
"0.5909641",
"0.5908994",
"0.58979666",
"0.58972335",
"0.5896251",
"0.58947283",
"0.5894672",
"0.58907163",
"0.58906",
"0.58904713",
"0.5886935",
"0.5885113",
"0.5883148",
"0.5880731",
"0.58800274",
"0.587884",
"0.587884",
"0.5874938",
"0.5874938",
"0.5874938",
"0.5874938",
"0.5874938",
"0.5874938",
"0.5874938",
"0.5874938",
"0.5874938",
"0.58723825",
"0.5863018",
"0.5863018"
] |
0.7107624
|
0
|
DELETE /alumni_news_items/1 DELETE /alumni_news_items/1.json
|
def destroy
@alumni_news_item.destroy
respond_to do |format|
format.html { redirect_to alumni_news_items_url }
format.json { head :no_content }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def destroy\n @news_item.destroy\n \n respond_to do |format|\n format.html { redirect_to news_items_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @news_item.destroy\n respond_to do |format|\n format.html { redirect_to admin_news_items_url, notice: 'News item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @discourse_news_item.destroy\n respond_to do |format|\n format.html { redirect_to discourse_news_items_url, notice: 'Discourse news item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n render json: Item.delete(params[\"id\"])\n end",
"def destroy\n @news_items = NewsItem.find(params[:id])\n @news_items.destroy\n\n respond_to do |format|\n format.html { redirect_to(news_items_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @news.destroy\n respond_to do |format|\n format.html { redirect_to news_index_url, notice: 'An item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @news_item = NewsItem.find(params[:id])\n @news_item.destroy\n\n respond_to do |format|\n format.html { redirect_to(news_items_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @news_item = NewsItem.find(params[:id])\n @news_item.destroy\n\n respond_to do |format|\n format.html { redirect_to news_items_url }\n format.xml { head :ok }\n end\n end",
"def delete_from_entzumena\n headline = Headline.where({:source_item_type => params[:source_item_type], :source_item_id => params[:source_item_id]}).first\n if headline.destroy\n render :json => true, :status => 200\n else\n render :json => false, :status => :error\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @news.destroy\n respond_to do |format|\n format.html { redirect_to news_index_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @news.destroy\n respond_to do |format|\n format.html { redirect_to admin_news_index_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n @api_v1_item.destroy\n render json: {message: 'deletado com sucesso'}\n end",
"def delete_item(id)\n record \"/todos/delete_item/#{id}\"\n end",
"def destroy\n @admin_useful_news = Admin::UsefulNews.find(params[:id])\n @admin_useful_news.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_useful_news_index_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @news.destroy\n respond_to do |format|\n format.html { redirect_to :news_index }\n format.json { head :no_content }\n end\n end",
"def destroy\n @news = News.find(params[:id])\n @news.destroy\n\n respond_to do |format|\n format.html { redirect_to news_index_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n # Find news in DB\n @news = News.find(params[:id])\n # Delete news\n @news.destroy\n\n respond_to do |format|\n # Redirect the user to the news index page\n format.html { redirect_to news_index_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @newsinfo.destroy\n respond_to do |format|\n format.html { redirect_to newsinfos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @news.destroy\n respond_to do |format|\n format.html { redirect_to news_index_url, notice: 'Новость успешно удалена' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @news = News.find(params[:id])\n @news.destroy\n\n respond_to do |format|\n format.html { redirect_to news_index_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @news = News.find(params[:id])\n @news.destroy\n\n respond_to do |format|\n format.html { redirect_to news_index_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @news = News.find(params[:id])\n @news.destroy\n\n respond_to do |format|\n format.html { redirect_to news_index_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @news = News.find(params[:id])\n @news.destroy\n\n respond_to do |format|\n format.html { redirect_to news_index_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item_datum = ItemData.find(params[:id])\n @item_datum.destroy\n\n respond_to do |format|\n format.html { redirect_to item_datum_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @news_agency = NewsAgency.find(params[:id])\n @news_agency.destroy\n\n respond_to do |format|\n format.html { redirect_to news_agencies_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @news.destroy\n respond_to do |format|\n format.html { redirect_to news_index_path, notice: 'Uutinen poistettu' }\n format.json { render :index, status: :ok, location: news_index_path }\n end\n end",
"def destroy\n @news_datum = NewsDatum.find(params[:id])\n @news_datum.destroy\n\n respond_to do |format|\n format.html { redirect_to news_data_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to tasks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test_item.destroy\n respond_to do |format|\n format.html { redirect_to test_items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n\n if @news.nil?\n render json: {error: \"Not found\"}, status: :not_found\n else\n @news.destroy\n render json: @news, status: :ok\n end\n end",
"def destroy\n @admins_news.destroy\n respond_to do |format|\n format.html { redirect_to admins_news_index_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @api_v1_news_link.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_news_links_url, notice: 'News link was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @news.destroy\n respond_to do |format|\n format.html { redirect_to news_index_path, notice: t('flash.notice.news_deleted') }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n @company_news.destroy\n respond_to do |format|\n format.html { redirect_to company_news_index_url, notice: 'Новость была удалена' }\n format.json { head :no_content }\n end\n end",
"def destroy\n if @news.removed?\n @news.destroy\n else\n @news.removed!\n end\n\n respond_to do |format|\n format.html { redirect_to news_index_url, notice: 'Новость успешно удалена!' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @news.destroy\n respond_to do |format|\n format.html { redirect_to news_index_url, success: 'Запись успешно удалена.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n# @item = Item.get(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to({action: :index}, notice: 'Item was successfully deleted.') }\n format.json { head :ok }\n end\n end",
"def destroy\n @local_news = LocalNews.find(params[:id])\n @local_news.destroy\n respond_to do |format|\n format.html { redirect_to noticias_local_news_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def delete_item(item_id)\n response = Unirest.delete CONNECT_HOST + '/v1/' + LOCATION_ID + '/items/' + item_id,\n headers: REQUEST_HEADERS\n\n if response.code == 200\n puts 'Successfully deleted item'\n return response.body\n else\n puts 'Item deletion failed'\n puts response.body\n return nil\n end\nend",
"def destroy\n @lineitem.destroy\n respond_to do |format|\n format.html { redirect_to lineitems_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @activity_item = ActivityItem.find(params[:id])\n @activity_item.destroy\n\n respond_to do |format|\n format.html { redirect_to activity_items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n head :no_content\n end",
"def destroy\n @news_list = NewsList.find(params[:id])\n @news_list.destroy\n\n respond_to do |format|\n format.html { redirect_to news_lists_url }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url}\n format.json { head :no_content }\n end\n end",
"def destroy\n @news = News.find(params[:id])\n @news.destroy\n\n respond_to do |format|\n format.html { redirect_to(news_item_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @item = @user.items.find(params[:id])\n @item.destroy\n\n\n respond_to do |format|\n format.html { redirect_to user_items_path(@user) }\n format.json { head :no_content }\n end\n end",
"def delete_item\n item_id = params[\"item_id\"]\n\n item = TextItem.find_by_id(item_id)\n item = Image.find_by_id(item_id) if item.nil?\n item = Collection.find_by_id(item_id) if item.nil?\n render_json :status => :not_found, :messages => \"Could not find the item with id #{item_id}.\" and return if item.nil?\n\n if item.class == Collection\n if params[\"id\"].nil?\n render_json :status => :bad_request, :messages => \"Can't delete a collection reference without providing the parent collection id. Please use the longer url for item deletion.\" and return\n end\n collection = Collection.find_by_id(params[\"id\"])\n else\n collection = Ownership.find_by_item_id(item_id).parent\n end\n;\n render_json :status => :not_found, :messages => \"Could not find parent collection for the item.\" and return if (collection.nil?)\n render_json :status => :forbidden, :messages => \"The user is not allowed to delete from this collection.\" and return if (!collection.delete?(@user, @client))\n\n collection.delete_item(item_id)\n render_json :entry => {} and return\n end",
"def destroy\n return if new_record?\n \n @api.delete \"/items/#{shortcode_url}.json\"\n end",
"def destroy\n @gg_news.destroy\n respond_to do |format|\n format.html { redirect_to gg_news_index_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = @client.items.find(params[:id])\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully removed from Inventory.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n authorize @system_news, :destroy?\n @system_news.destroy\n respond_to do |format|\n format.html { redirect_to system_news_index_url }\n format.json { head :no_content }\n end\n end",
"def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end",
"def destroy\n @moment_item.destroy\n respond_to do |format|\n format.html { redirect_to moment_items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @line_item.destroy\n respond_to do |format|\n format.html { redirect_to line_items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @line_item.destroy\n respond_to do |format|\n format.html { redirect_to line_items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @line_item.destroy\n respond_to do |format|\n format.html { redirect_to line_items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n item = @item.name\n @item.deleted = true\n @item.deleted_at = Time.now\n @item.save\n\n respond_to do |format|\n format.html { redirect_to items_url, notice: \"#{item} was successfully deleted.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sitemenu.destroy\n respond_to do |format|\n format.html { redirect_to sitemenus_url }\n format.json { head :no_content }\n end\n end",
"def item_destroy\n @item = Item.find(params[:id])\n @item.destroy\n respond_to do |format|\n format.html { redirect_to item_index_path, notice: 'O item foi removido com sucesso.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to '/items', notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to lists_url }\n format.json { head :ok }\n end\n end",
"def destroy\n # @item.destroy\n # respond_to do |format|\n # format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n # format.json { head :no_content }\n # end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: '削除に成功しました。' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @newsline.destroy\n respond_to do |format|\n format.html { redirect_to newslines_url, notice: 'Newsline was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sub1_line_item.destroy\n respond_to do |format|\n format.html { redirect_to sub1_line_items_url, notice: 'Sub1 line item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @feed_item.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @fooditem = Fooditem.find(params[:id])\n @fooditem.destroy\n\n respond_to do |format|\n format.html { redirect_to fooditems_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admin_item = Admin::Item.find(params[:id])\n @admin_item.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admin_item = Admin::Item.find(params[:id])\n @admin_item.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @apiv1_item.destroy\n respond_to do |format|\n format.html { redirect_to apiv1_items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end"
] |
[
"0.7383478",
"0.72197795",
"0.70828426",
"0.7070211",
"0.70491827",
"0.70027846",
"0.6960674",
"0.6952112",
"0.6912653",
"0.68666136",
"0.6832792",
"0.682805",
"0.6815279",
"0.6811384",
"0.68070203",
"0.67974824",
"0.6794741",
"0.67810625",
"0.6780675",
"0.6776958",
"0.67731225",
"0.67731225",
"0.67731225",
"0.67731225",
"0.67633235",
"0.6730798",
"0.67259985",
"0.67094076",
"0.67068017",
"0.67018783",
"0.6693618",
"0.6686236",
"0.6684209",
"0.6681385",
"0.6675306",
"0.6669872",
"0.66655695",
"0.6664954",
"0.6664619",
"0.6658806",
"0.6658795",
"0.6658795",
"0.6658795",
"0.6658795",
"0.6658795",
"0.6658795",
"0.6658795",
"0.6658795",
"0.6658795",
"0.6658795",
"0.66555566",
"0.66511863",
"0.6647197",
"0.66466445",
"0.66460425",
"0.6641739",
"0.66390306",
"0.6635049",
"0.6634657",
"0.6630556",
"0.66271293",
"0.662587",
"0.66222745",
"0.6622255",
"0.6622071",
"0.6622071",
"0.6622071",
"0.6622071",
"0.6622071",
"0.6622071",
"0.6622071",
"0.6622071",
"0.6622071",
"0.6622071",
"0.6622071",
"0.6622071",
"0.6622071",
"0.6622071",
"0.6622071",
"0.6614893",
"0.66080797",
"0.6602063",
"0.66004616",
"0.66004616",
"0.65995866",
"0.6596457",
"0.6593783",
"0.65908384",
"0.65893096",
"0.6586368",
"0.65671843",
"0.65661675",
"0.6564537",
"0.6563874",
"0.6561078",
"0.65592223",
"0.6543567",
"0.6538357",
"0.6538357",
"0.65333146"
] |
0.77582276
|
0
|
Use callbacks to share common setup or constraints between actions.
|
def set_alumni_news_item
@alumni_news_item = AlumniNewsItem.find(params[:id])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def define_action_helpers?; end",
"def set_actions\n actions :all\n end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def setup_handler\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def workflow\n end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup\n # override and do something appropriate\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def before_action \n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def setup_signals; end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def initialize(*args)\n super\n @action = :set\nend",
"def after_set_callback; end",
"def setup\n #implement in subclass;\n end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def around_hooks; end",
"def save_action; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def default_action; end",
"def setup(&blk)\n @setup_block = blk\n end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def duas1(action)\n action.call\n action.call\nend",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend"
] |
[
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576",
"0.53124547",
"0.529654",
"0.5296262",
"0.52952296",
"0.52600986",
"0.52442724",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.5232394",
"0.523231",
"0.5227454",
"0.52226824",
"0.52201617",
"0.5212327",
"0.52079266",
"0.52050185",
"0.51754695",
"0.51726824",
"0.51710224",
"0.5166172",
"0.5159343",
"0.51578903",
"0.51522785",
"0.5152022",
"0.51518047",
"0.51456624",
"0.51398855",
"0.5133759",
"0.5112076",
"0.5111866",
"0.5111866",
"0.5110294",
"0.5106169",
"0.509231",
"0.50873137",
"0.5081088",
"0.508059",
"0.50677156",
"0.50562143",
"0.5050554",
"0.50474834",
"0.50474834",
"0.5036181",
"0.5026331",
"0.5022976",
"0.5015441",
"0.50121695",
"0.5000944",
"0.5000019",
"0.4996878",
"0.4989888",
"0.4989888",
"0.49864885",
"0.49797225",
"0.49785787",
"0.4976161",
"0.49683493",
"0.4965126",
"0.4958034",
"0.49559742",
"0.4954353",
"0.49535993",
"0.4952725",
"0.49467874",
"0.49423352",
"0.49325448",
"0.49282882",
"0.49269363",
"0.49269104",
"0.49252945",
"0.4923091",
"0.49194667",
"0.49174926",
"0.49173003",
"0.49171105",
"0.4915879",
"0.49155936"
] |
0.0
|
-1
|
Never trust parameters from the scary internet, only allow the white list through.
|
def alumni_news_item_params
params.require(:alumni_news_item).permit(:title, :content)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def param_whitelist\n [:role, :title]\n end",
"def expected_permitted_parameter_names; end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end",
"def valid_params_request?; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def permitted_params\n []\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end",
"def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end",
"def safe_params\n params.require(:user).permit(:name)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def check_params; true; end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def quote_params\n params.permit!\n end",
"def valid_params?; end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend",
"def filtered_parameters; end",
"def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end",
"def filtering_params\n params.permit(:email, :name)\n end",
"def check_params\n true\n end",
"def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend",
"def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end",
"def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end",
"def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end",
"def active_code_params\n params[:active_code].permit\n end",
"def filtering_params\n params.permit(:email)\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end",
"def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end",
"def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end",
"def list_params\n params.permit(:name)\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def url_whitelist; end",
"def admin_social_network_params\n params.require(:social_network).permit!\n end",
"def filter_params\n params.require(:filters).permit(:letters)\n end",
"def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end",
"def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end",
"def sensitive_params=(params)\n @sensitive_params = params\n end",
"def permit_request_params\n params.permit(:address)\n end",
"def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end",
"def secure_params\n params.require(:location).permit(:name)\n end",
"def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end",
"def question_params\n params.require(:survey_question).permit(question_whitelist)\n end",
"def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end",
"def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end",
"def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end",
"def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end",
"def url_params\n params[:url].permit(:full)\n end",
"def backend_user_params\n params.permit!\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end",
"def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end",
"def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end",
"def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end",
"def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end",
"def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end"
] |
[
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",
"0.62894756",
"0.6283177",
"0.6242471",
"0.62382483",
"0.6217549",
"0.6214457",
"0.6209053",
"0.6193042",
"0.6177802",
"0.6174604",
"0.61714715",
"0.6161512",
"0.6151757",
"0.6150663",
"0.61461",
"0.61213595",
"0.611406",
"0.6106206",
"0.6105114",
"0.6089039",
"0.6081015",
"0.6071004",
"0.60620916",
"0.6019971",
"0.601788",
"0.6011056",
"0.6010898",
"0.6005122",
"0.6005122",
"0.6001556",
"0.6001049",
"0.59943926",
"0.5992201",
"0.59909594",
"0.5990628",
"0.5980841",
"0.59669393",
"0.59589154",
"0.5958826",
"0.5957911",
"0.5957385",
"0.5953072",
"0.59526145",
"0.5943361",
"0.59386164",
"0.59375334",
"0.59375334",
"0.5933856",
"0.59292704",
"0.59254247",
"0.5924164",
"0.59167904",
"0.59088355",
"0.5907542",
"0.59064597",
"0.5906243",
"0.5898226",
"0.589687",
"0.5896091",
"0.5894501",
"0.5894289",
"0.5891739",
"0.58860534",
"0.5882406",
"0.587974",
"0.58738774",
"0.5869024",
"0.58679986",
"0.5867561",
"0.5865932",
"0.5864461",
"0.58639693",
"0.58617616",
"0.5861436",
"0.5860451",
"0.58602303",
"0.5854586",
"0.58537364",
"0.5850427",
"0.5850199"
] |
0.0
|
-1
|
Overwrite to provide default options.
|
def default_options
{}
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_default_options\n end",
"def default_options=(opts); end",
"def default_options; {} end",
"def option(options)\n default_options.merge! options\n end",
"def options\n original_options = super\n user_defaults = @config\n user_defaults.merge(original_options)\n end",
"def options\n opts = super\n opts[:overwrite_original] = true if @overwrite_original\n opts\n end",
"def options\n opts = super\n opts[:overwrite_original] = true if @overwrite_original\n opts\n end",
"def default_options; end",
"def default_options; end",
"def default_options; end",
"def define_options(opt)\n # override this; no additional options by default\n end",
"def default_options\n sync{ @opts || {} }\n end",
"def default_options=( opts )\n sync{ @opts = opts.nil? ? nil : opts.dup }\n end",
"def options\n defaults.merge!(@options)\n end",
"def options\n defaults.merge!(@options)\n end",
"def reset_options!\n @options = self::DEFAULT_OPTIONS.clone # 'self::' is necessary with ruby 1.8\n end",
"def set_default_options!\n @options ||= OpenStruct.new\n @options.skip_uncovered = false\n @options.mute = false\n @options.reports = []\n end",
"def give_options\n clean_user_options\n @user_options.merge(default_options)\n end",
"def default_options\n {}\n end",
"def default_options\n {}\n end",
"def default_options\n {}\n end",
"def reset\n @options = VALID_OPTIONS_KEYS.inject({}) do |opts, k|\n default_option = OnTheSnow::Config.const_get(\"DEFAULT_#{k.upcase}\")\n self.send(\"#{k}=\", default_option)\n opts[k.to_s] = default_option #unless default_option.nil?\n opts\n end\n self\n end",
"def default_options\n # {}\n end",
"def default_options\n {}\n end",
"def default_options\n {}\n end",
"def default_options\n {}\n end",
"def prepare_options(options)\n options = self.class.defaults.merge(self.options).merge(options)\n end",
"def set_default_options(iParameters)\n @DefaultOptions.merge!(iParameters)\n end",
"def reset!\n @options = defaults\n end",
"def reset!\n @options = defaults\n end",
"def default_opts\n { :default => default }.merge( opts )\n end",
"def set_default_options(options = T.unsafe(nil)); end",
"def set_default_options()\n @options = OpenStruct.new(\n :output_base => nil,\n :verbose => false,\n :config_file => nil,\n :samples => nil,\n :delay => 30,\n :scheduler_opts => ''\n )\nend",
"def options!(**opts)\n options.merge!(opts)\n end",
"def defaults_and_options options\n options\n end",
"def merge!(defaults)\n @options = @options.reverse_merge(defaults)\n end",
"def default_options\n @default_options ||= {}\n end",
"def set_defaults(options = T.unsafe(nil)); end",
"def default_options\n { }\n end",
"def default_emerge_install_options(options)\n default_emerge_options(nil, options)\n end",
"def merge_default_options( opts )\n @default_options.merge!( opts )\n nil\n end",
"def reset!\n @options = Name.defaults.dup\n end",
"def initialize(*)\n super\n self.options = options.dup\n end",
"def _apply_default_options args, defaults\n options = args.extract_options!\n args << options.reverse_merge!(defaults)\n end",
"def reset_options\n VALID_OPTIONS_KEYS.each do |key|\n send(\"#{key}=\", default_options[key])\n end\n end",
"def reset\n @options = Marshal.load(@default)\nend",
"def initialize(options={})\n \n @options=DEFAULT_OPTIONS.dup.merge(options)\n end",
"def initialize(options={})\n \n @options=DEFAULT_OPTIONS.dup.merge(options)\n end",
"def defaults\n super\n end",
"def set_defaults\n super\n end",
"def set_defaults\n super\n end",
"def options\n original_options = super\n defaults = Thor::CoreExt::HashWithIndifferentAccess.new(\n {\n width: 72,\n count: 200,\n },\n )\n\n config_path = File.expand_path(ENV.fetch('AUGURY_CFG_PATH', '~/.augury.yml'))\n if File.file?(config_path)\n config_options = Thor::CoreExt::HashWithIndifferentAccess.new(YAML.load_file(config_path) || {})\n defaults = defaults.merge(config_options)\n end\n\n # Enforce implied options\n defaults[:links] = true if original_options[:remove_links] || defaults[:remove_links]\n\n Thor::CoreExt::HashWithIndifferentAccess.new(defaults.merge(original_options))\n end",
"def default_opts(hash={})\n hash.each {|k, v| @opts[k] = v unless @opts.has_key?(k)}\n end",
"def set_options(options={})\n @options.merge!(options)\n end",
"def default_options(options = nil)\n # initialize from superclass\n @default_options = superclass.default_options if @default_options.nil?\n\n unless options.nil?\n unless options.is_a? Hash\n raise ArgumentError, 'default_options must call with Hash'\n end\n options.each do |option, default_value|\n if @valid_option_keys.include?(option)\n @default_options[option] = default_value\n else\n raise ArgumentError, \"Unknown option '#{option}'\"\n end\n end\n end\n\n @default_options.dup\n end",
"def set_default_options(options)\n opts = options.dup\n\n extra_options = opts.delete(:extra_options)\n extra_options = DEFAULT_EXTRA_OPTIONS.merge(extra_options)\n\n has_timeout_string_arg = extra_options[:mongocryptd_spawn_args].any? do |elem|\n elem.is_a?(String) && elem.match(/\\A--idleShutdownTimeoutSecs=\\d+\\z/)\n end\n\n timeout_int_arg_idx = extra_options[:mongocryptd_spawn_args].index('--idleShutdownTimeoutSecs')\n has_timeout_int_arg = timeout_int_arg_idx && extra_options[:mongocryptd_spawn_args][timeout_int_arg_idx + 1].is_a?(Integer)\n\n unless has_timeout_string_arg || has_timeout_int_arg\n extra_options[:mongocryptd_spawn_args] << '--idleShutdownTimeoutSecs=60'\n end\n\n opts[:bypass_auto_encryption] ||= false\n\n opts.merge(extra_options)\n end",
"def default_options\n DEFAULT_OPTIONS\n end",
"def initialize\n @options = defaults\n end",
"def initialize\n @options = defaults\n end",
"def merge_defaults(options = {})\n\t\t\tdefaults = {}\n\t\t\tdefaults[:debug] = @debug if @debug\n\n\t\t\t# overwrite defaults with any given options\n\t\t\tdefaults.merge!(options)\n\t\tend",
"def set_defaults\n end",
"def set_defaults\n end",
"def initialize **opts\n @options = DEFAULT_OPTIONS.merge opts\n end",
"def default_options\n options = {}\n options[:verbose] = false\n options[:copy_only] = false\n options[:output_folder] = FileUtils.pwd\n\n options\n end",
"def options\n @unfrozen_options ||= super.dup\n end",
"def options=(options={})\n @options = @options ? @options.merge(options) : options\n end",
"def set_options(opts)\n common_options(opts)\n end",
"def default_options\n @default_options ||= self.class.default_options\n end",
"def reset_defaults_and_overrides\n default.clear\n override.clear\n end",
"def default!(defaults = {})\n replace(defaults.merge(self))\n end",
"def defaults\n ActiveSupport::OrderedOptions.new\n end",
"def add_default_command_options(options)\n defaults = self[:default_run_options]\n options = defaults.merge(options)\n\n env = self[:default_environment]\n env = env.merge(options[:env]) if options[:env]\n options[:env] = env unless env.empty?\n\n shell = options[:shell] || self[:default_shell]\n options[:shell] = shell unless shell.nil?\n\n options\n end",
"def set_defaults\n\n end",
"def set_defaults\n\n end",
"def set_defaults\n\n end",
"def set_defaults\n\n end",
"def set_defaults\n\n end",
"def set_defaults\n\n end",
"def resolve_defaults(options)\n options.merge(@defaults)\n end",
"def set_default_options(options = nil)\n #give some sensical options instead of blank elements\n @options = Hash.new\n @options[:default_title] = \"My Awesome Title\"\n @options[:default_link] = \"http://default.wordpress.com\"\n @options[:default_description] = \"My Awesome Description\"\n @options[:pub_date] = \"Tue, 10 Mar 2009 00:12:59 +0000\"\n @options[:base_blog_url] = \"http://default.wordpress.com\"\n @options[:creator] = \"Hiro\"\n end",
"def set_defaults\r\n @options = {\r\n :caching => true\r\n }\r\n end",
"def override(opts)\n new(global, opts)\n end",
"def merge_defaults(options = {})\n defaults = {}\n # defaults[:character_name] = @charater_name if @charater_name\n defaults[:region] = @region if @region\n defaults[:caching] = @caching if @caching\n defaults[:cache_timeout] = @cache_timeout if @cache_timeout\n defaults[:debug] = @debug if @debug\n\n # overwrite defaults with any given options\n defaults.merge!(options)\n end",
"def options\n default_options.merge(all_options).delete_if do |key, value|\n option_not_allowed?(key)\n end\n end",
"def apply_start_block_option_overrides(options)\n @requested_args.each { |option_name, option_value| options.update(option_name, option_value, add_missing: false) }\n end",
"def reset_options_with(options)\n set_agent_with(options[:user_agent]) if options.include? :user_agent\n @strict = options[:strict] if options.include? :strict\n if options.include? :load\n options = load_config_file(options[:load]) || {}\n options.symbolize_keys!\n end\n set_google_with(options[:google]) if options.include? :google\n @dicts = options[:dicts].symbolize_keys! if options.include? :dicts\n end",
"def options\n @options ||= if top_class?\n DEFAULT_OPTIONS\n else\n superclass.options\n end.dup\n end",
"def default_options\n {\n appid: app_id,\n device_id: device_id,\n locale: locale,\n ip: ip,\n offer_types: offer_types,\n timestamp: Time.now.to_i\n }\n end",
"def default_url_options_without_override\n super.merge(alternate_name.present? ? {prefill: {alternate: alternate_name}} : {})\n end",
"def options\n @options ||= OpenStruct.new(default_options)\n end",
"def merge_default_options(name, type, options = {})\n list_options[name][type].merge(options)\n\t\tend",
"def initialize(options = {})\n @options = default_options.merge(options)\n end",
"def default_options\n @default_options ||= OpenStruct.new\n end",
"def set_default_options(options)\n opts = options.dup\n\n extra_options = opts.delete(:extra_options) || Options::Redacted.new\n extra_options = DEFAULT_EXTRA_OPTIONS.merge(extra_options)\n\n has_timeout_string_arg = extra_options[:mongocryptd_spawn_args].any? do |elem|\n elem.is_a?(String) && elem.match(/\\A--idleShutdownTimeoutSecs=\\d+\\z/)\n end\n\n timeout_int_arg_idx = extra_options[:mongocryptd_spawn_args].index('--idleShutdownTimeoutSecs')\n has_timeout_int_arg = timeout_int_arg_idx && extra_options[:mongocryptd_spawn_args][timeout_int_arg_idx + 1].is_a?(Integer)\n\n unless has_timeout_string_arg || has_timeout_int_arg\n extra_options[:mongocryptd_spawn_args] << '--idleShutdownTimeoutSecs=60'\n end\n\n opts[:bypass_auto_encryption] ||= false\n set_or_create_clients(opts)\n opts[:key_vault_client] = @key_vault_client\n\n Options::Redacted.new(opts).merge(extra_options: extra_options)\n end",
"def set_defaults\n default_user_agent = Config.user_agent || Typhoeus::USER_AGENT\n\n options[:headers] = {'User-Agent' => default_user_agent}.merge(options[:headers] || {})\n options[:headers]['Expect'] ||= ''\n options[:verbose] = Typhoeus::Config.verbose if options[:verbose].nil? && !Typhoeus::Config.verbose.nil?\n options[:maxredirs] ||= 50\n options[:proxy] = Typhoeus::Config.proxy unless options.has_key?(:proxy) || Typhoeus::Config.proxy.nil?\n end",
"def set_options(options)\n @options.merge!(options)\n end",
"def with_options( opts )\n saved, @opts = @opts, default_options.merge(opts)\n yield\n ensure\n @opts = saved\n end",
"def instance_options(default_options)\n initialize_default_options(default_options)\n set_instance_options(@options)\n end",
"def default_adapter_options=(_arg0); end",
"def default_adapter_options=(_arg0); end"
] |
[
"0.84135216",
"0.81497043",
"0.7876203",
"0.7871955",
"0.77495855",
"0.7716972",
"0.7716972",
"0.77077246",
"0.77077246",
"0.77077246",
"0.76613855",
"0.7633435",
"0.7599269",
"0.75796056",
"0.75796056",
"0.7528701",
"0.7499236",
"0.74059355",
"0.73624355",
"0.736217",
"0.736217",
"0.7359798",
"0.7351722",
"0.73407215",
"0.73407215",
"0.73407215",
"0.7334086",
"0.7301802",
"0.72803265",
"0.72803265",
"0.7254109",
"0.725368",
"0.7246364",
"0.72422063",
"0.7216768",
"0.72145396",
"0.71745884",
"0.7169879",
"0.7151111",
"0.71407026",
"0.71403337",
"0.7122117",
"0.7095641",
"0.70933956",
"0.70906717",
"0.7079419",
"0.7067496",
"0.7067496",
"0.70499223",
"0.7049088",
"0.7049088",
"0.7032313",
"0.7026375",
"0.70030355",
"0.7001422",
"0.69993776",
"0.69906557",
"0.6966331",
"0.6966331",
"0.69506884",
"0.69505244",
"0.69505244",
"0.6949431",
"0.6934837",
"0.6917277",
"0.6914047",
"0.69083583",
"0.6905999",
"0.69019866",
"0.6866256",
"0.68574876",
"0.6845023",
"0.6842607",
"0.6842607",
"0.6842607",
"0.6842607",
"0.6842607",
"0.6842607",
"0.684249",
"0.68300426",
"0.6827004",
"0.6821272",
"0.6817261",
"0.67987823",
"0.67879903",
"0.67854774",
"0.6777184",
"0.67617834",
"0.6753524",
"0.6747775",
"0.67456913",
"0.67434114",
"0.6740243",
"0.67342967",
"0.6732391",
"0.67192775",
"0.67184114",
"0.66955066",
"0.66938585",
"0.66938585"
] |
0.7318091
|
27
|
Callback called after initialization.
|
def after_initialize
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def after_initialize; end",
"def after_initialize; end",
"def after_initialize; end",
"def after_initialize; end",
"def after_initialize\n end",
"def after_initialize\n end",
"def after_initialized\n end",
"def after_initialize(&block); end",
"def post_init\n end",
"def on_initialization_finished()\n end",
"def after_init\n end",
"def post_init\n end",
"def after_set_callback; end",
"def after_initialize\n end",
"def on_init; end",
"def on_init; end",
"def after_initialize \n end",
"def post_initialize\n end",
"def after_initialize(opts)\n end",
"def post_init\n\tend",
"def on_after_load\n end",
"def on_initialize\n end",
"def after_initialize\n # noop\n end",
"def after_initialize(options={}) ; end",
"def post_init()\n puts \"#{self} post_init done!\"\n end",
"def post_init()\n puts \"#{self} post_init done!\"\n end",
"def callback\n end",
"def at_init\n\n\t\tend",
"def after_generate_callbacks; end",
"def post_initialize\n # raise NotImplementedError\n end",
"def callbacks; end",
"def callbacks; end",
"def callback\n\n end",
"def callback_phase\n super\n end",
"def after_init(&block)\n config.internal.after_init = block\n end",
"def post_setup\n end",
"def callback &block\n super\n end",
"def callback &block\n super\n end",
"def initialize_after_opts\n end",
"def initialize\n # complete\n end",
"def on_ready\n end",
"def post_initialize\n nil\n end",
"def post_initialize\n nil\n end",
"def init\n\n end",
"def callback\n\tend",
"def post_initialize(args)\n nil\n end",
"def initialize()\n @callbacks = {}\n end",
"def before_initialize(&block); end",
"def post_initialize\n nil \n end",
"def after_initialize(plugins); end",
"def post_initialize(args)\n nil\n end",
"def post_initialize(args = {})\r\n nil\r\n end",
"def after_processing_hook; end",
"def after_setup\n # do nothing by default\n end",
"def on_before_load\n end",
"def init\n end",
"def init\n end",
"def init\n end",
"def init; end",
"def init; end",
"def init; end",
"def init; end",
"def on_load\n clear_output\n end",
"def ready; end",
"def ready; end",
"def on_setup\n nil\n end",
"def after_initialize_callback\n # The 'self.' bits below are needed, do not remove.\n self.internal = unique_id unless self.internal?\n end",
"def after_initialize(&after_initialize_block)\n after_initialize_blocks << after_initialize_block if after_initialize_block\n end",
"def post_init(&block)\n @hooks[:post_init] = block\n end",
"def pre_initialize; end",
"def onLoad\n end",
"def after_load\n @after_load ||= default_after_load\n end",
"def initialize(callback)\n @callback = callback\n end",
"def Init()\n end",
"def after_loaded(o={}, &block)\n end",
"def finalize\n end",
"def initialize\n \n end",
"def after_setting_value_callback; end",
"def init\n\nend",
"def after_initialize_blocks\n @after_initialize_blocks ||= []\n end",
"def initialize()\r\n\r\n end",
"def pre_initialize\n end",
"def callback\n self.class.callback\n end",
"def callback\n self.class.callback\n end",
"def initialize\n\n\n\n end",
"def onStart\r\n end",
"def post_init\n puts \"#{self.class}/#{self} client post_init runs\"\n end",
"def after_view_setup\n end",
"def finalize\n end",
"def finalize\n end",
"def finalize\n end",
"def finalize\n end",
"def finalize\n end",
"def finalize\n end",
"def finalize\n end",
"def post_initialize_fields\n end",
"def after_resolution\n end",
"def initialize()\n\t\tend",
"def finalize\n\n end",
"def before_setup; end"
] |
[
"0.80069876",
"0.80069876",
"0.80069876",
"0.80069876",
"0.79419285",
"0.79419285",
"0.7929937",
"0.7924348",
"0.78855515",
"0.7848953",
"0.7838372",
"0.7807316",
"0.77661324",
"0.77393824",
"0.7725614",
"0.7725614",
"0.7679504",
"0.76715547",
"0.7515325",
"0.7494911",
"0.74524224",
"0.74159414",
"0.74015415",
"0.73834205",
"0.7339309",
"0.7339309",
"0.724217",
"0.7239033",
"0.7234354",
"0.718916",
"0.71053386",
"0.71053386",
"0.70995194",
"0.7001102",
"0.6972347",
"0.69606996",
"0.69559276",
"0.69559276",
"0.69298583",
"0.69064206",
"0.6887087",
"0.68853235",
"0.683113",
"0.6822609",
"0.6797157",
"0.67962176",
"0.67852706",
"0.67713594",
"0.6758946",
"0.67427975",
"0.6715894",
"0.67157537",
"0.6715585",
"0.66452974",
"0.6618601",
"0.6616916",
"0.6616916",
"0.6616916",
"0.660344",
"0.660344",
"0.660344",
"0.660344",
"0.6596525",
"0.65791464",
"0.65791464",
"0.6552212",
"0.6535967",
"0.6528516",
"0.6522459",
"0.64970285",
"0.64724666",
"0.64494133",
"0.6445271",
"0.6441873",
"0.6439297",
"0.64167047",
"0.6407745",
"0.64072317",
"0.6397531",
"0.6392859",
"0.6391099",
"0.637269",
"0.6372671",
"0.6372671",
"0.63656133",
"0.63489026",
"0.63437116",
"0.6328476",
"0.6327928",
"0.6327928",
"0.6327928",
"0.6327928",
"0.6327928",
"0.6327928",
"0.6327928",
"0.63231003",
"0.63139534",
"0.6313773",
"0.6309251",
"0.6308635"
] |
0.80124795
|
0
|
Callback before begin assertions.
|
def before_assert
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def before_assert(symbol=nil, &block)\n if block_given?\n @before_assert_callbacks << block\n elsif symbol\n @before_assert_callbacks << symbol\n end\n end",
"def assertions; end",
"def assertions; end",
"def assert\n\traise \"Assertion failed\" unless yield\nend",
"def assert\n\traise \"Assertion failed\" unless yield\nend",
"def assert \n\traise \"Assertion failed\" unless yield\nend",
"def assert\n\tyield\nend",
"def assert\n\tyield\nend",
"def assert\n\tputs \"Assertion Failed!\" unless yield\nend",
"def assert\n\traise \"Assertion Failed\" unless yield\nend",
"def assert\n\traise \"Assertion failed!\" unless \n\t yield\nend",
"def before() ; end",
"def assert\n \t raise \"Assertion failed!\" unless yield\nend",
"def before_test(test); end",
"def before_test(test); end",
"def assert\n raise \"Assertion failed!\" unless yield\nend",
"def assert\n\traise \"Assertion Failed!\" unless yield\nend",
"def assert\n\traise \"Assertion Failed!\" unless yield\nend",
"def assert\n\traise \"Assertion failed!\" unless yield\nend",
"def assert\n\traise \"Assertion failed!\" unless yield\nend",
"def assert\n\traise \"Assertion failed!\" unless yield\nend",
"def assert\n\traise \"Assertion failed!\" unless yield\nend",
"def assert\n\traise \"Assertion failed!\" unless yield\nend",
"def assert\n\traise \"Assertion failed!\" unless yield\nend",
"def assert\n\traise \"Assertion failed!\" unless yield\nend",
"def assert\n\traise \"Assertion failed!\" unless yield\nend",
"def assert\n\traise \"Assertion failed!\" unless yield\nend",
"def assert\n\traise \"Assertion failed!\" unless yield\nend",
"def assert\n\traise \"Assertion failed!\" unless yield\nend",
"def assert\n\traise \"Assertion failed!\" unless yield\nend",
"def assert \n\traise \"Assertion failed!\" unless yield\nend",
"def assert\n\traise \"Assertion error!\" unless yield\nend",
"def assert\r\n raise \"Assert Faild\" unless yield\r\nend",
"def assert\n \n raise \"Assertion failed\" unless yield \nend",
"def assert\n\traise \"Assert failed!\" unless yield\nend",
"def just_before_assertion\n # return a clone of self, but with\n ExampleBeforeAssertion.new(example_block.block, description, lets)\n end",
"def assert\n\traise \"Assertion Raised!\" unless yield\nend",
"def assert\n\tif yield\n\t\tputs \"true\"\n\telse\n\t\traise \"Assert failed!\"\n\tend\nend",
"def assert\n raise \"Assertion Failed!\" unless yield\n end",
"def assert\n raise \"Assertion failed!\" unless yield\n\nend",
"def assert\n raise \"Assertion failed!\" unless yield\n end",
"def assert_callback_before(configuration, task_name, before_task_name, msg = nil)\n msg ||= \"Expected configuration to callback #{task_name.inspect} before #{before_task_name.inspect} but did not\"\n test_callback_on(true, configuration, task_name, :before, before_task_name, msg)\n end",
"def assert\n\t\tif yield\n\t\t\tputs \"Passes assert\"\n\t\telse\n\t\t\tputs \"Fails assert\"\n\t\tend\n\tend",
"def assert\n raise \"Assertion failed\" unless yield\nend",
"def assert\n\traise ArgumentError.new(\"assertion error\") unless yield\nend",
"def assert\n raise \"Assertion failed\" unless yield\nend",
"def assert\n raise \"Assertion failed\" unless yield\nend",
"def assert\n raise \"Assertion failed\" unless yield\nend",
"def assert\n raise \"Assertion failed\" unless yield\nend",
"def assert\n puts \"Processing...\"\n raise \"Assertion failed!\" unless yield \n puts \"True!\"\nend",
"def assert\n raise \"Assertion Failed\" unless yield\nend",
"def assert \n raise \"Assert Failed!\" unless yield \nend",
"def assert\n# puts \"Processing...\"\n raise \"Assertion failed!\" unless yield \n puts \"True!\"\nend",
"def assert \t\t\t\t\t\t\t\t\t\n raise \"Assertion failed!\" unless yield \t\nend",
"def before; end",
"def assert\n\t# if yield\n\t# \tputs \"true\"\n\traise \"Assertion failed\" unless yield \n# end \nend",
"def before_tests(&block)\n @before_tests_proc = block\n end",
"def assert\n raise \"Assertion Failed!\" unless yield \nend",
"def assert\n raise \"Assertion Failed!\" unless yield \nend",
"def assert\n raise \"Assertion Failed!\" unless yield \nend",
"def assert_expected_assertions expected = 1\n yield\n ensure\n actual = tc.assertions + spec.assertions\n assert_equal expected, actual, \"expected #{expected} assertions to be \" +\n \"fired during the test, not #{actual}\"\n end",
"def assert_silent; end",
"def assert\n raise \"Assertion failed!\" unless yield\n puts \"Test passed\"\nend",
"def assert\n\traise ArgumentError.new(\"Assertion failed!\") unless yield\nend",
"def assert\n raise \"Assertion failed!\" unless yield\nend",
"def assert\n raise \"Assertion failed!\" unless yield\nend",
"def assert\n raise \"Assertion failed!\" unless yield\nend",
"def assert\n raise \"Assertion failed!\" unless yield\nend",
"def assert \n raise \"Assertion failed!\" unless yield\nend",
"def before() nil ; end",
"def assert\n raise \"Assertion failed!\" unless yield\nend",
"def assert\n raise \"Assertion failed!\" unless yield\nend",
"def assert\n raise \"Assertion failed!\" unless yield\nend",
"def assert\n raise \"Assertion failed!\" unless yield\nend",
"def assert\n raise \"Assertion failed!\" unless yield\nend",
"def assert\n raise \"Assertion failed!\" unless yield\nend",
"def assert\n raise \"Assertion failed!\" unless yield\nend",
"def assert\n raise \"Assertion failed!\" unless yield\nend",
"def assert\n raise \"Assertion failed!\" unless yield\nend",
"def assert\n raise \"Assertion failed!\" unless yield\nend",
"def assert\n raise \"Assertion failed!\" unless yield\nend",
"def assert\n raise \"Assertion failed!\" unless yield\nend",
"def assert\n raise \"Assertion failed!\" unless yield\nend",
"def assert\n raise \"Assertion failed!\" unless yield\nend",
"def assert\n raise \"Assertion failed!\" unless yield\nend",
"def assert\n raise \"Assertion failed!\" unless yield\nend",
"def assert\n raise \"Assertion failed!\" unless yield\nend",
"def assert\n raise \"Assertion failed!\" unless yield\nend",
"def assert\n raise \"Assertion failed!\" unless yield\nend",
"def assert\n raise \"Assertion failed!\" unless yield\nend",
"def assert\n raise \"Assertion failed!\" unless yield\nend",
"def assert\n raise \"Assertion failed!\" unless yield\nend",
"def assert\n raise \"Assertion failed!\" unless yield\nend",
"def assert\n raise \"Assertion failed!\" unless yield\nend",
"def assert\n raise \"Assertion failed!\" unless yield\nend",
"def assert\n raise \"Assertion failed!\" unless yield\nend",
"def assert\n raise \"Assertion failed!\" unless yield\nend",
"def assert\n raise \"Assertion failed!\" unless yield\nend",
"def assert\n raise \"Assertion failed!\" unless yield\nend",
"def assert\n raise \"Assertion failed!\" unless yield\nend"
] |
[
"0.6926338",
"0.67333734",
"0.67333734",
"0.656793",
"0.656793",
"0.65607977",
"0.6560058",
"0.6560058",
"0.65542305",
"0.65458816",
"0.6536247",
"0.65192246",
"0.6517277",
"0.6498014",
"0.6498014",
"0.64941454",
"0.64876235",
"0.64876235",
"0.6475417",
"0.6475417",
"0.6475417",
"0.6475417",
"0.6475417",
"0.6475417",
"0.6475417",
"0.6475417",
"0.6475417",
"0.6475417",
"0.6475417",
"0.64754134",
"0.64691395",
"0.6468352",
"0.64629793",
"0.6450886",
"0.6443321",
"0.6434049",
"0.64125025",
"0.6373906",
"0.6345256",
"0.6333711",
"0.6333586",
"0.63149655",
"0.63115036",
"0.6310992",
"0.6306853",
"0.6303472",
"0.6303472",
"0.6303472",
"0.6303472",
"0.6298292",
"0.6289084",
"0.62867856",
"0.62803394",
"0.62668693",
"0.6259723",
"0.62522405",
"0.6245252",
"0.624482",
"0.624482",
"0.624482",
"0.6236225",
"0.6233807",
"0.6230098",
"0.6227153",
"0.6226189",
"0.6226189",
"0.6226189",
"0.6226189",
"0.6221358",
"0.62205285",
"0.6216847",
"0.6216847",
"0.6216847",
"0.6216847",
"0.6216847",
"0.6216847",
"0.6216847",
"0.6216847",
"0.6216847",
"0.6216847",
"0.6216847",
"0.6216847",
"0.6216847",
"0.6216847",
"0.6216847",
"0.6216847",
"0.6216847",
"0.6216847",
"0.6216847",
"0.6216847",
"0.6216847",
"0.6216847",
"0.6216847",
"0.6216847",
"0.6216847",
"0.6216847",
"0.6216847",
"0.6216847",
"0.6216847",
"0.6216847"
] |
0.788816
|
0
|
only including this show method for the sake of the cancelling a session it shouldn't be actually accessible as a page (because there's no need) update: also works as a way for someone to book a session by opening the link in a new tab. Woop!
|
def show
update
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def show\n # allow non-js peeps to destroy their session\n end",
"def set_show_session\n session[:cheese_order] = nil\n session[:current_page] = nil\n end",
"def session; end",
"def session; end",
"def session; end",
"def session; end",
"def show\n # Remember where the user is so if they're not logged in here, we can bring them back after sign in.\n session[:return_to] = request.url\n end",
"def session\n end",
"def link\n id = session[:id].to_s\n url =\"http://ourco2.org/dopplr/?userid=\"+id\n redirect_to \"https://www.dopplr.com/api/AuthSubRequest?scope=http://www.dopplr.com&next=\"+url+\"&session=1\"\n end",
"def show\n @session = Session.where(unique_id: params[:id])\n # New round logic here\n\n end",
"def show\n # raise\n if session[:created_at] && session[:created_at] < 2.minutes.ago\n reset_session\n end\n @plain_url = Short.decrypt(@short)\n end",
"def show\n @edition = Edition.find(params[:id])\n session[:edition_id] = @edition.id\n expire_site_pages\n redirect_to home_path\n end",
"def open_session; end",
"def show_popup\n if @cohort_entrance = CohortEntrance.find_by_code(params[:cohort_entrance_id])\n session[:cohort_entrance_id] = @cohort_entrance.id.to_s\n # send to back to whence they came.\n if params[:return_url]\n session[:popup] = true\n @signup_popup = true\n @roll_title = params[:roll]\n @source = params[:source]\n session[:return_url] = params[:return_url]\n else\n session[:return_url] = Settings::ShelbyAPI.web_root\n end\n else\n redirect_to \"#{Settings::ShelbyAPI.web_root}/?access=nos\"\n end\n end",
"def new\n super\n reset_session\n end",
"def toggle_edit_mode\r\n session[:edit_mode] ||= 0 \r\n# called without logged in \r\n if session[:edit_mode] < 1 \r\n dc_render_404 \r\n else\r\n session[:edit_mode] = (session[:edit_mode] == 1) ? 2 : 1\r\n redirect_to params[:return_to]\r\n end\r\nend",
"def show\n @subject = subject\n @live_link = get_live_link(subject)\n @session_code\n end",
"def invalidSession(context)\n context.response << \"<html><head><meta http-equiv=REFRESH content='1; URL=#{context.baseURL}'></head><body><b>That session no longer exists (#{$$}:#{$$.to_s(16)}).<p>You are being forwarded to a <a href='#{context.baseURL}'>new session</a>.</b></body></html>\"\n end",
"def show\n @session_user = current_user\n end",
"def index\n @title = 'Got Debt?'\n if session\n @session_obj = session.inspect\n else\n @session_obj = nil \n end\n end",
"def show\n session[:return_to] ||= request.referer\n end",
"def set_session\n \n end",
"def hide_promo\n session[:promo][:dismissed_at] = DateTime.now if session[:promo]\n render :nothing => true\n end",
"def show\n authorize Session\n end",
"def edit_user\n session[:prev_url] = request.referer if request.referer.present?\n end",
"def require_session_ownership\r\n if session_user.screen_name == params[:screen_name]\r\n @user = session_user\r\n return true\r\n end\r\n\r\n # wrong screen_name in url doesn't match session_user! redir to the current session\r\n # user's stats page\r\n params[:screen_name] = session_user.screen_name\r\n redirect_to url_for(params)\r\n end",
"def stop_session\n @office = params[:id] ? Office.find(params[:id]) : Office.new\n tok_session = OpentokSession.find(:first, :conditions => {:office_id => @office.id})\n if tok_session.is_live\n tok_session.is_live = false\n tok_session.save\n end\n render :nothing => true\n end",
"def show\n session[:curso_id] = @curso.id\n session[:curso_nome] = @curso.nome\n session[:curso_nota] = @curso.nota\n session[:curso_media] = @curso.media_alunos\n redirect_to alunos_path\n end",
"def session; @session; end",
"def session; @session; end",
"def session; @session; end",
"def confirm_own_account_page\n #\t unless ((@user_id == session[:user_id])||(session[:admin]))\n # \t\tflash[:notice] = \"That URL is not for your account!\"\n #\t\t redirect_to(user_path( :id => session[:user_id]))\n #\t end\n end",
"def public\n session[:computing_id] = 'Non-UVA'\n redirect_to :action => :new\n end",
"def show\n return unless restrict_to_hosts\n\n get_session_data(@session)\n end",
"def close\n session = Session.find_by(id: params[:id])\n session.update(active: false)\n end",
"def stop_session\n @lesson = Lesson.find(params[:lesson_id])\n @event = params[:id] ? Event.find(params[:id]) : Event.new\n tok_session = OpentokSession.find(:first, :conditions => {:event_id => @event.id})\n if tok_session.is_live\n tok_session.is_live = false\n tok_session.save\n end\n render :nothing => true\n end",
"def show\n redirect_to :back#:actina => \"after_log_in_prosess\" :action => \"chouse\"\n end",
"def send_user\n session[:url]\n session.delete(:url)\n end",
"def show\n if !session[:is_admin]\n redirect_to root_url\n end\n end",
"def show\n session[\"current_loan_id\"] = @loan.id\n end",
"def session() request.session end",
"def hide_currents\n session[:announcements_hide_time] = Time.now\n\n respond_to do |format|\n format.html { redirect_to :back }\n format.js\n end\n end",
"def show\r\n @session = Session.find(params[:id])\r\n\r\n if((@session.state == \"won\") && (@session.updated_at.to_i + 3 < Time.now.to_i))\r\n @session.state = \"nextQuestion\"\r\n @session.save\r\n end\r\n\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.xml { render :xml => @session }\r\n #format.json { render :json => @session }\r\n format.json { render_for_api :in_progress_session, :json => @session, :root => :session }\r\n\t\t\r\n end\r\n end",
"def disallow_session_user\r\n redirect_to_widget_if(params[:redirect_to]) || redirect_to(my_profile_url) if session_user\r\n end",
"def destroy \n session.delete :user_id \n head :no_content \n end",
"def show_logout\n @show_logout = true\n end",
"def finish\n session = Session.find(params[:id])\n if session.finish!\n redirect_to admin_sessions_url\n else\n render :edit\n end\n end",
"def no_session # :nologin: :norobots:\n end",
"def set_appointment_store_id\n begin\n @appointment = Appointment.visible.find(params[:appointment_store_id])\n @case = @appointment.case\n flash[:notice] = \"All Module's changes will be linked to <a href='/appointments/#{@appointment.id}'>#{@appointment}\".html_safe\n session[:appointment_store_id] = @appointment.id\n rescue ActiveRecord::RecordNotFound\n flash[:notice] = \"Linking modules disabled\".html_safe\n session[:appointment_store_id] = nil\n end\n puts \"#{session[:appointment_store_id]}\"\n # redirect_back(fallback_location: root_url)\n if @case\n redirect_to case_path(@case)\n else\n redirect_to cases_path\n end\n\n end",
"def canceladd\n @session['groupcluster']=nil\n @session['groupshop']=nil\n @session['groupkey']=nil\n render :update do |page|\n page.redirect_to url_for(:controller=>'machines', :action=>'list')\n end\n end",
"def index\n params[:id] = session_user_id\n show\n end",
"def show\n @bug = Bug.find(params[:id])\n if(session[:admin] || session[:user_id] == @bug.user_id)\n respond_to do |format|\n format.html # show.html.erb\n end\n else\n redirect_to :action => \"index\"\n end\n end",
"def show\n #logger.debug( cookies.inspect )\n logger.debug( \"Authorization header: #{request.headers['Authorization']}\" )\n @session = Session.get(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml\n format.json do\n render :json => {\n :session => {\n :token => @session.token,\n :link => {\n :rel => 'session',\n :uri => session_path(@session)\n }\n }\n }\n end\n end\n end",
"def repel_usr_guest\n redirect_to(\"/\") if session[:usr_id].nil?\n end",
"def cancel\n set_session\n\n if @session.cancel\n respond_to do |format|\n format.html { redirect_back allow_other_host: false, fallback_location: batch_connect_sessions_url, notice: t(\"dashboard.batch_connect_sessions_status_blurb_cancel_success\") }\n format.json { head :no_content }\n end\n else\n respond_to do |format|\n format.html { redirect_back allow_other_host: false, fallback_location: batch_connect_sessions_url, alert: t(\"dashboard.batch_connect_sessions_status_blurb_cancel_failure\") }\n format.json { render json: @session.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n session[:discussion_id] = @discussion.id\n session[:classroom_id] = @discussion.classroom_id\n session[:textbook_id] = @discussion.textbook_id\n session[:lesson_id] = @discussion.lesson_id\n session[:teaching_id] = @discussion.teaching_id\n end",
"def show\n if !current_user || current_user.status != \"1\"\n redirect_to new_user_session_path\n end\n end",
"def show\n @quotation = Quotation.find(params[:id])\n cookies[:create_inv] = 0\n cookies.delete :create\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @quotation }\n format.json { render :json => @quotation }\n end\n end",
"def select_session\n @session = Session.find_by_session_id(@session_id)\n @session = @session.last rescue @session\n set_req_no\n end",
"def on_session_interact(session)\n\tend",
"def check_another_user(url, session:)\n session.visit(url)\n marys_draft = NameDescription.last\n assert(session.has_link?(href: name_description_path(marys_draft.id)))\n session.first(:link, href: name_description_path(marys_draft.id)).click\n assert_flash_error(session: session)\n end",
"def logout \r\n session[:edit_mode] = 0\r\n session[:user_id] = nil\r\n render action: 'login', layout: 'cms'\r\nend",
"def logout \r\n session[:edit_mode] = 0\r\n session[:user_id] = nil\r\n render action: 'login', layout: 'cms'\r\nend",
"def show\n @event = Event.find_by_key(params[:id])\n key = @event.key\n\n # Get all Stored Joomen as Array\n unless cookies['my_joomen'].nil?\n cookie_store = cookies['my_joomen'].split(',')\n cookie_store.push(key)\n else\n cookie_store = [key]\n end\n\n # Create new Cookie including current joomen\n cookies['my_joomen'] = cookie_store.uniq.join(',')\n\n # is a password required ?\n unless @event.password.nil? or @event.password.empty?\n\n if (session['open_joomen'] != key)\n\n # Validate Password\n if (params[:event].nil?) || (@event.password != params[:event][:password])\n\n if params[:event].nil? || params[:event][:password].nil?\n flash[:notice] = \"Bitte geben Sie ein Passwort für dieses Joomen an\"\n else\n flash[:error] = \"Ihr Passwort scheint nicht korrekt zu sein\"\n end\n # goto Passwort Input-Form\n render(:action => :password)\n\n # Password Correct => create Session\n else\n session['open_joomen'] = key\n end\n end\n end\n\n flash[:notice] = ''\n flash[:error] = ''\n end",
"def refresh\n @session = ::Session.new(user: current_user)\n\n if @session.save\n current_session.destroy\n render :show, status: :created, location: @session\n else\n render json: @session.errors, status: :unprocessable_entity\n end\n end",
"def session_id\n super\n end",
"def session_id\n super\n end",
"def show\n if cookies[:admin_id]\n \n else\n redirect_to \"/\"\n end\n end",
"def using_session(name, &block)\n self.last_used_session = name\n super\n ensure\n self.last_used_session = nil\n end",
"def check_session\n session.delete(\"accepted\") if session[:updated_at].present? && session[:updated_at].to_time <= 10.minutes.ago\n end",
"def session\n self\n end",
"def show\n if cookies[:show]\n response.set_cookie(:show,\n :value => cookies[:show].to_i + 1\n )\n else\n @show_message = true;\n # set the visited cookie\n response.set_cookie(:show,\n :value => 1,\n :expires => Time.now + (60 * 60 * 2)\n )\n\n end\n end",
"def show\n if params[:turn_on]\n session[:admin] = true if @user&.admin && !in_admin_mode?\n elsif params[:turn_off]\n session[:admin] = nil\n end\n\n redirect_back_or_default(\"/\")\n end",
"def show\r\n jump_to(\"/profiles/#{session[:account_id]}/basic\")\r\n end",
"def toggle_current_user_note\n session[:show_current_user_note] = !session[:show_current_user_note]\n\n respond_with :js\n end",
"def edit\n redirect_back_or_default(\"/\") if\n !@user&.admin && session[:real_user_id].blank?\n end",
"def activar\n # flash[:notice] = \"klkkkk\"\n \n session[:cliente_id] = \"desktop\" # SETEADO MANUAL ADMINISTRATIVAMENTE OK TED.\n session[:tipo_cliente] = \"123\" # SETEADO MANUAL ADMINISTRATIVAMENTE OK TED.\n\n @tipo_cliente = \"desktop\" # SETEADO MANUAL ADMINISTRATIVAMENTE OK TED.\n @cliente_id = \"123\" # SETEADO MANUAL ADMINISTRATIVAMENTE OK TED.\n session[:chekeado] = \"chekeado\"\n\n if (session[:terminal_autorizada] == false)\n sign_out(current_user) \n end\n session[:terminal_autorizada] = true\n #creado para complemento (convention over configuration) del controlador del view de acticion de equipos. ok ted.\n end",
"def destroy\n session[:superadmin_mode] = false\n redirect_to_home\n end",
"def menu\n \tredirect_to session_new_path\n end",
"def show\n if current_user.has_role? :admin\n else\n session[:quiz_id] = @quiz.id\n redirect_to quiz_items_url\n end\n end",
"def reload\n @session_id = nil\n login\n end",
"def destroy\n @current_session = CurrentSession.find(params[:id])\n @current_session.destroy\n\n head :no_content\n end",
"def destroy\n session[:developer_id] = nil\n redirect_to sessions_new_path\n end",
"def show\n puts \"======================================\"\n puts \"The session id is #{session[:user_id]}\"\n puts \"======================================\"\n @user = User.find_by_id(session[:user_id])\n end",
"def index\n session[ :current_user_id ] = nil\n end",
"def enforce_viewing_context_for_show_requests \n if params[:viewing_context] == \"browse\"\n session[:viewing_context] = params[:viewing_context]\n elsif session[:viewing_context] == \"edit\"\n if editor?\n redirect_to :action=>:edit\n else\n session[:viewing_context] = \"browse\"\n end\n end\n end",
"def session ; request.session ; end",
"def show\n unless logged_in?\n flash.now[:danger] = 'Você não possui autorização'\n render 'sessions/new'\n end\n end",
"def lookup_user\n if session[:user]\n @user = User.get(session[:user])\n if @user == nil or not @user.lookup_valid?(session[:lookup])\n session.delete(:user)\n session.delete(:lookup)\n modal({:heading => \"Felaktig Session\" ,:body => \"Din session har blivit korrupt och du loggas nu ut.\"})\n redirect '/login'\n end\n return\n end\n redirect '/login'\n end",
"def index\n @plan_reason_masters = PlanReasonMaster.all\n session[:active_tab] =\"MeetingPlan\"\n session[:active_tab1] =\"Master\"\n end",
"def edit\n session[:return_to] ||= request.referer\n @Urlmaster = Urlmaster.find(params[:id])\n end",
"def show_relaxation_session\n\t\t@user = current_user\n\t\t@relaxation_sessions = RelaxationSession.where(:username => @user.username)\n\tend",
"def show\n if @invite.first_viewed_at < Time.now - 1.year && @invite.created_at < Time.now - 1.hour\n @invite.first_viewed_at = Time.now\n end\n @invite.most_recently_viewed_at = Time.now\n @invite.save\n \n cookies[:user_url] = @invite.url\n end",
"def hide_tips\n session[:hide_tips] = true\n end",
"def set_session_vars\n if params[:return_to]\n session[:return_to] = params[:return_to]\n elsif (current_user.nil? && in_mode?('show')) || (current_user && in_mode?('index', 'edit', 'show'))\n store_location\n end\n set_default_view_type\n end",
"def update_copy_session\n @user = current_user\n session[:copy_flag] = true\n end",
"def stopSession\n @test.update(session_expired_at: Time.now - 24*60*60)\n\n # consolidate drafts into steps\n helpers.parseDraft(@test.session_id)\n\n render json: 1\n end",
"def sign_out\n click_link t(\"sessions.signout\")\nend",
"def login\r\n session[:edit_mode] = 0 unless params[:ok]\r\n render action: 'login', layout: 'cms'\r\nend",
"def show\n @session = Session.find(params[:id])\n redirect_to \"user/show\"\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @session }\n end\n end",
"def session_options; end"
] |
[
"0.66385925",
"0.6331114",
"0.61879855",
"0.61879855",
"0.61879855",
"0.61879855",
"0.61628985",
"0.6119198",
"0.6112874",
"0.60910314",
"0.6001623",
"0.5994266",
"0.59591526",
"0.595192",
"0.5914905",
"0.5898938",
"0.5878766",
"0.5836117",
"0.5777711",
"0.575785",
"0.57528913",
"0.5741939",
"0.5737934",
"0.5722016",
"0.57030773",
"0.56807935",
"0.5673848",
"0.56710935",
"0.5668215",
"0.5668215",
"0.5668215",
"0.56633663",
"0.56554055",
"0.5651524",
"0.56484765",
"0.5641755",
"0.56229675",
"0.5618831",
"0.56102824",
"0.5603736",
"0.5595587",
"0.5581499",
"0.55742925",
"0.5542832",
"0.5542788",
"0.553431",
"0.5532267",
"0.552898",
"0.5527848",
"0.55022055",
"0.5499654",
"0.5492079",
"0.5488113",
"0.54865825",
"0.5484003",
"0.54725116",
"0.54681915",
"0.54678893",
"0.54674226",
"0.5460122",
"0.5452892",
"0.5449989",
"0.5449989",
"0.54477197",
"0.5444784",
"0.544152",
"0.544152",
"0.5433091",
"0.54264355",
"0.54166794",
"0.5410669",
"0.5407511",
"0.5405684",
"0.5403027",
"0.53955126",
"0.5393757",
"0.5392761",
"0.5388736",
"0.5382207",
"0.5375953",
"0.53757775",
"0.5369183",
"0.53670466",
"0.5362275",
"0.5362164",
"0.5358088",
"0.5357648",
"0.53554666",
"0.53552526",
"0.53520286",
"0.53475183",
"0.53324896",
"0.53320843",
"0.53316313",
"0.5331412",
"0.5322903",
"0.53124577",
"0.53093684",
"0.5306593",
"0.53057253",
"0.53049934"
] |
0.0
|
-1
|
When a user performs a search, this method is used to filter out results that are hidden from the user based on what they're searching for. For example, if a user searches for post flags by flagger name, they can see their own flags, and if they're a moderator they can see flags on other users' uploads, but they can't see flags on their own uploads.
|
def visible_for_search(relation, attribute = nil)
relation
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def hide_filter\n perm_links = ministry.lmi_hide.map { |lmi| \"lmi_total_#{lmi}\" }\n query = table[:perm_link].does_not_match(\"%_custom_%\")\n query = query.and(table[:perm_link].not_in(perm_links)) if perm_links.any?\n query\n end",
"def filter_findings\n findings\n end",
"def hide_flagged_records(solr_parameters)\n unless see_unpublished?\n solr_parameters[:fq] << '-flags_isim:[* TO *]'\n end\n end",
"def list_entries_with_search\n list_entries_without_search.where(search_condition)\n end",
"def search_as_hidden_fields(options={})\n ordered_query_facet_parameters = params_for_ui\n ordered_query_facet_parameters.delete(:q) if options[:omit_keys].include?(:q)\n return hash_as_hidden_fields(ordered_query_facet_parameters)\n end",
"def filtered?\n filtered\n end",
"def get_results\n # 1. if the search is blank do NOT run the search (handled in subclasses)\n !self.search_text.blank? && !self.search_query.blank? && !self.search_type.blank? && !self.search_locale.blank?\n end",
"def index\n @filter = params[:filter] if params.has_key? :filter and %w{unapproved invited}.include? params[:filter]\n\n if params[:search]\n @search = User.search { fulltext params[:search] }\n @users = user_query.where(id: @search.results.map(&:id))\n else\n @users = user_query.order(updated_at: :desc)\n end\n end",
"def filter\n end",
"def hidden_filter_params\n safe_join(known_filter_params.map do |p|\n hidden_field_tag p, params[p] if params[p] && p != :search\n end.compact)\n end",
"def filtered_entries; end",
"def search?\n not user.nil?\n end",
"def verify_unpublishable_search\n # only logged in users viewing their own resources can search unpublished\n unless logged_in? && params[:user_id].present? && current_user.id == params[:user_id].to_i\n params.merge! published: true\n end\n end",
"def filter\n\t\tchain(\n\t\t\tsuper, # Use automatic filter switching, i.e. use params[:filter] and #filter_options\n\t\t\t{:published => true}, # Only find published tags\n\t\t\tlambda { |tag| !tag.active_businesses_in_city(@city).empty? } # Only find tags with at least one active business\n\t\t)\n\tend",
"def filter\n @exams = @patient.exams\n @exams = @exams.by_exam_description(params[:filter]) unless params[:filter].blank?\n Exam.filter_cancelled(@exams) unless params[:show_cancelled].blank?\n render :partial => \"exams/results\", :locals => {:exams => @exams, :patient => @patient}\n end",
"def search_fields_for_advanced_search\n @search_fields_for_advanced_search ||=\n blacklight_config.search_fields.reject do |_key, field_def|\n field_def.include_in_advanced_search.is_a?(FalseClass)\n end\n end",
"def setHiddenSearch(value)\n if value != false && value != true\n case value.downcase\n when 'on', 'true', 'yes', 'y', '1'\n @searchHidden = true\n when 'off', 'false', 'no', 'n', '0'\n @searchHidden = false\n end\n else\n @searchHidden = value\n end\n end",
"def search_results\n pages = Alchemy::PgSearch.config[:page_search_scope].pages\n # Since CanCan cannot (oh the irony) merge +accessible_by+ scope with pg_search scopes,\n # we need to fake a page object here\n if can? :show, Alchemy::Page.new(restricted: true, public_on: Date.current)\n pages.full_text_search(params[:query])\n else\n pages.not_restricted.full_text_search(params[:query])\n end\n end",
"def search\n\t authorize! :search, Book\n\n\t query = params[:search] || \"\"\n page = params[:page] ? params[:page].to_i : 1\n \n @conditions = Condition.all\n\t @result = Book.search(query, page)\n @result = Book.calculate_hidden(@result, session[:user_id])\n\n\tend",
"def apply_permissive_visibility_filter(solr_params)\n return unless current_exhibit\n return if scope.respond_to?(:can?) && scope.can?(:curate, current_exhibit) && !blacklight_params[:public]\n\n solr_params.append_filter_query \"-#{blacklight_config.document_model.visibility_field(current_exhibit)}:false\"\n end",
"def filter(options={})\n super\n end",
"def index\n\n # Grab user's diets as saved in profile and pass it into the search\n user_diets = current_user.compile_diets\n\n if params[:search_by_diet].present?\n allowed_diets_in_search = (user_diets << params[:search_by_diet]).flatten!\n else\n allowed_diets_in_search = user_diets\n end\n\n # Grab user's allergies as saved in profile and pass it into the search\n user_allergies = current_user.compile_allergies\n\n if params[:search_by_allergy].present?\n allowed_allergies_in_search = (user_allergies << params[:search_by_allergy]).flatten!\n else\n allowed_allergies_in_search = user_allergies\n end\n\n user_excluded_ingredients = current_user.compile_excluded_ingredients\n\n @results = Yummly.search(\n params[:search_by_all],\n \"maxTotalTimeInSeconds\" => params[:search_by_time],\n \"allowedCourse[]\" => params[:search_by_course],\n \"allowedAllergy[]\" => allowed_allergies_in_search,\n \"allowedDiet[]\" => allowed_diets_in_search,\n \"excludedIngredient[]\" => user_excluded_ingredients,\n maxResult: 50);\n \n\n end",
"def index\n unfiltered_users = User.search(params[:term])\n @users = unfiltered_users.select do | user | user.archived == nil end\n end",
"def cemetary\n unfiltered_users = User.search(params[:term])\n @users = unfiltered_users.select do | user | user.archived == true end\n end",
"def search filter\n if filter && is_searchable?\n filter = [filter, Chronic.parse(filter).strftime(\"%Y-%m-%d\")] rescue filter\n handle_joins(self.fields, scoped.select(\"DISTINCT(`#{self.table_name}`.`id`), `#{self.table_name}`.*\"))\n .where(build_filter(filter, self.fields))\n else\n scoped\n end\n end",
"def index\n @item_collections = ItemCollection.where('is_private=false')\n if !params[:search].nil? || params[:search] == ''\n t = ItemCollection.arel_table\n @item_collections = ItemCollection.where(t[:name].matches(\"%#{params[:search]}%\").and(t[:is_private].eq(false)))\n #@item_collections = ItemCollection.where('name LIKE ? AND is_private=false', \"%#{params[:search]}%\")\n end\n end",
"def show\n @search = Caterer.ransack(params[:q])\n @caterers = @search.result.where(draft: false)\n end",
"def search\n user_type = params[:search][:user_type]\n zip_code = params[:search][:zip_code]\n if user_type == \"All\"\n @users = User.approved\n else\n @users = user_type.constantize.all.collect{|x| x.user}.approved\n end\n if zip_code.blank?\n @users = @users.paginate(:page => 1)\n else\n @users = @users.reject{|x| x.zip_code != zip_code }.paginate(:page => 1)\n end\n render 'index'\n end",
"def private_messages_search\n raise Discourse::InvalidAccess.new if @guardian.anonymous?\n\n @search_pms = true # needed by posts_eager_loads\n posts =\n posts_scope(posts_eager_loads(posts_query(@opts[:limit], type_filter: @opts[:type_filter])))\n posts.each { |post| @results.posts << post }\n end",
"def add_custom_search_filters(search); end",
"def index\n if current_user.typeof == false\n @searchers = Searcher.all\n else\n redirect_to home_home_page_path\n end\n end",
"def filters\n end",
"def search\n @user = User.find(params[:user_id])\n @tags = show_user_tags @user\n result_search = search_bookmarks_by params[:tag_name], @user\n\n if current_user? @user\n @bookmarks = result_search.paginate(page: params[:page], per_page: 10) \n else\n temp = []\n result_search.each do |bookmark|\n unless bookmark.privacy? then\n temp.push(bookmark)\n end\n end\n @bookmarks = temp.paginate(page: params[:page], per_page: 10)\n end\n end",
"def search_args\n [params[:query], current_user]\n end",
"def search (query_string)\n\n OpenWFE::Extras::Workitem.search(query_string, store_names).find_all do |wi|\n\n @user.admin? or (\n wi.store_name != 'users' || wi.participant_name == @user.name)\n end\n end",
"def filter_results(current_role, results, filter_data)\n if filter_data['annotationText'].present?\n results = results.joins(annotations: :annotation_text)\n .where('lower(annotation_texts.content) LIKE ?',\n \"%#{AnnotationText.sanitize_sql_like(filter_data['annotationText'].downcase)}%\")\n end\n if filter_data['section'].present?\n results = results.joins(grouping: :section).where('section.name': filter_data['section'])\n end\n if filter_data['markingState'].present?\n remark_results = results.where.not('results.remark_request_submitted_at': nil)\n .where('results.marking_state': Result::MARKING_STATES[:incomplete])\n released_results = results.where.not('results.id': remark_results).where('results.released_to_students': true)\n case filter_data['markingState']\n when 'remark_requested'\n results = remark_results\n when 'released'\n results = released_results\n when 'complete'\n results = results.where.not('results.id': released_results)\n .where('results.marking_state': Result::MARKING_STATES[:complete])\n when 'in_progress'\n results = results.where.not('results.id': remark_results).where.not('results.id': released_results)\n .where('results.marking_state': Result::MARKING_STATES[:incomplete])\n end\n end\n\n unless current_role.ta? || filter_data['tas'].blank?\n results = results.joins(grouping: { tas: :user }).where('user.user_name': filter_data['tas'])\n end\n if filter_data['tags'].present?\n results = results.joins(grouping: :tags).where('tags.name': filter_data['tags'])\n end\n unless filter_data.dig('totalMarkRange', 'max').blank? && filter_data.dig('totalMarkRange', 'min').blank?\n result_ids = results.ids\n total_marks_hash = Result.get_total_marks(result_ids)\n if filter_data.dig('totalMarkRange', 'max').present?\n total_marks_hash.select! { |_, value| value <= filter_data['totalMarkRange']['max'].to_f }\n end\n if filter_data.dig('totalMarkRange', 'min').present?\n total_marks_hash.select! { |_, value| value >= filter_data['totalMarkRange']['min'].to_f }\n end\n results = Result.where('results.id': total_marks_hash.keys)\n end\n unless filter_data.dig('totalExtraMarkRange', 'max').blank? && filter_data.dig('totalExtraMarkRange', 'min').blank?\n result_ids = results.ids\n total_marks_hash = Result.get_total_extra_marks(result_ids)\n if filter_data.dig('totalExtraMarkRange', 'max').present?\n total_marks_hash.select! do |_, value|\n value <= filter_data['totalExtraMarkRange']['max'].to_f\n end\n end\n if filter_data.dig('totalExtraMarkRange', 'min').present?\n total_marks_hash.select! do |_, value|\n value >= filter_data['totalExtraMarkRange']['min'].to_f\n end\n end\n results = Result.where('results.id': total_marks_hash.keys)\n end\n if filter_data['criteria'].present?\n results = results.joins(marks: :criterion)\n temp_results = Result.none\n num_criteria = 0\n filter_data['criteria'].each do |name, range|\n num_criteria += 1\n if range.present? && range['min'].present? && range['max'].present?\n temp_results = temp_results.or(results\n .where('criteria.name = ? AND marks.mark >= ? AND marks.mark <= ?',\n name, range['min'].to_f, range['max'].to_f))\n elsif range.present? && range['min'].present?\n temp_results = temp_results.or(results\n .where('criteria.name = ? AND marks.mark >= ?',\n name, range['min'].to_f))\n elsif range.present? && range['max'].present?\n temp_results = temp_results.or(results\n .where('criteria.name = ? AND marks.mark <= ?',\n name, range['max'].to_f))\n else\n temp_results = temp_results.or(results\n .where(criteria: { name: name }))\n end\n end\n results = temp_results.group(:id).having('count(results.id) >= ?', num_criteria)\n end\n results.joins(grouping: :group)\n end",
"def get_results_by_what\n\n initialize_filter\n\n cond = String.new\n if (@search_category_list || @search_from_input_box || @search_by_what_where_url) &&\n !(@search_by_author || @search_by_author_url)\n\n #did one click a tag?\n if @search_category_list\n @filter[:category_list] = params[:blog_entry][:category_list] if params[:blog_entry]\n @filter[:searchterms] = @filter[:category_list] = params[:category_list] if params[:category_list] &&( params[:blog_entry].nil? ||params[:blog_entry][:category_list]==\"\")\n else\n #prepare search input, look at things tagged with search terms as well\n @filter[:category_list] = params[:blog_entry][:search].split(',')\n @filter[:category_list].each{|item| item = item.strip} if @filter[:category_list].size > 1\n @filter[:searchterms] = params[:blog_entry][:search].strip unless params[:blog_entry][:search].nil?\n end\n\n #the second one is for tagged by searching\n @messages, @messages2 = Array.new\n if @search_from_input_box\n cond = \"1=1 \"\n elsif @search_category_list\n cond = \"1=1 \"\n end\n\n #conditions for distance, no unmapped being supported here\n cond = cond + \"AND (\" + BlogEntry.distance_sql(session[:geo_location], :miles, :sphere) << \"<= #{@filter[:radius]}\" + \")\"\n distcond = cond\n\n cond = cond + %Q{ AND lower(what) LIKE '%#{@filter[:searchterms].downcase.gsub(/[.,']/, '%')}%' } if @filter[:searchterms]\n\n @messages = BlogEntry.find :all, :conditions => cond, :order => 'blog_entries.created_at desc', :limit => @filter[:post_limit], :include =>[:user, :categories, :ratings]\n\n # but you also need to check tags because not only is the what a good candidate, the tags are there for search too\n @filter[:category_list] = params[:category_list] if params[:category_list]\n\n # wait input box overrides tag search\n @filter[:category_list] = params[:blog_entry][:search] if params[:blog_entry]&& params[:blog_entry][:search]!= \"\"\n\n @messages2 = BlogEntry.find_tagged_with @filter[:category_list], {:on=> :categories, :conditions=> distcond, :order => 'blog_entries.created_at desc', :limit => @filter[:post_limit], :include =>[:user, :ratings] }\n\n @messages2 = @messages2.find_all{|m| m.distance_to(session[:geo_location]) <= @filter[:radius].to_f || ( @filter[:show_unmapped] && m.lat.nil?)}\n\n @filter[:searchterms] = @filter[:category_list]\n @messages.concat(@messages2) if @messages2\n\n @messages = @messages.uniq\n #search by author (only possible through tag)\n elsif @search_by_author || @search_by_author_url && !@default_logged_in_search\n if params[:blog_entry].nil? && params[:author]\n params[:blog_entry]=Hash.new\n if author= User.find_by_name(params[:author])\n params[:blog_entry][:author_id] = author.id\n @filter[:author_id] = author.id\n end\n end\n\n @filter[:post_limit] = 500 if logged_in?\n @messages =BlogEntry.find :all, :conditions => {:user_id => params[:blog_entry][:author_id]}, :order => 'blog_entries.created_at desc', :include =>[:user, :ratings], :limit => @filter[:post_limit]\n\n elsif @search_by_location || @default_logged_in_search\n get_initial_messages\n else\n #fallback\n get_initial_messages\n end\n\n if session[:sliders]==true\n @messages = @messages.find_all{|m| m.rating >=@filter[:rating_from].to_f && m.rating <= @filter[:rating_to].to_f }\n @messages = @messages.find_all{|m| m.price|| 0 >= @filter[:price_from].to_f && m.price||0 <= @filter[:price_to].to_f }\n end\n\n\n finish_search\n\n end",
"def search\n @users ||= User.search_user(params[:search])\n authorize! :read, @user\n end",
"def filters; end",
"def filters; end",
"def filter\n super\n end",
"def results_with_inactive_users\n self.inactive_reviewers unless @results_with_inactive_users\n @results_with_inactive_users\n end",
"def hidden_search_state\n hidden_search_params = @facet_field.search_state.params_for_search.except(:utf8, :page)\n hidden_search_params[:range]&.except!(@facet_field.key)\n Blacklight::HiddenSearchStateComponent.new(params: hidden_search_params)\n end",
"def apply_permissive_visibility_filter(solr_params)\n return unless current_exhibit\n return if !blacklight_params[:public] && scope&.context&.key?(:current_ability) && scope.context[:current_ability].can?(:curate, current_exhibit)\n\n solr_params.append_filter_query \"-#{blacklight_config.document_model.visibility_field(current_exhibit)}:false\"\n end",
"def all_search\n @results ||= []\n feat_keyword ||= {:name_contains => params[:q]}\n reward_keyword ||= {:partner_business_name_contains => params[:q]}\n\n Feat.search(feat_keyword).all.each do |r|\n @results << r\n end if !Feat.search(feat_keyword).all.nil? && feat_keyword.length > 0\n\n Reward.search(reward_keyword).all.each do |r|\n @results << r\n end if !Reward.search(reward_keyword).all.nil? && reward_keyword.length > 0\n end",
"def filters\n # Call model column on self (metadata since element in array is a string, not a variable hence we use send) <=> self.send(profile) == true\n %w[sight_seeing_adventurer art_lover serial_shopper nature_lover food_addict sport_lover history_passionate tech_fan relaxed city_wanderer].select! {|profile| send(profile) == true }\n end",
"def filter\n @filter = params[:q]\n end",
"def visible_posts_for(user, args = {})\n search_conditions = {\n where: {\n friends_only: false,\n user_id: self.id\n },\n page: args[:page],\n per_page: 20,\n include: [:user, :attachments, comments: [:attachments]],\n order: {created_at: :desc}\n }\n user = User.find(user) if user.is_a?(String) or user.is_a?(Fixnum)\n if args[:latest_post_id]\n search_conditions[:where].merge!({ record_id: {gt: args[:latest_post_id] }})\n end\n if (user and self.friends_with?(user)) or user == self\n search_conditions[:where].delete(:friends_only)\n end\n Post.search(search_conditions).results\n end",
"def index\n search = params[:term].present? ? params[:term] : nil\n @offers = if search\n Offer.search(search, where: { user_id: { not: current_user.id }})\n else\n Offer.all\n end\n @request = Request.new\n @ver_oferta_todas = Offer.where.not(:user_id => current_user.id)\n end",
"def search_with_filters\n @search_keyword = params[\"search\"]\n @project_id = params[\"project_id\"]\n @developer_id = Developer.find_by_gamer_id(current_gamer.id).id\n @projects = Project.where(owner_id: @developer_id).all\n @country = params[\"country\"]\n @age_from = params[\"age_from\"]\n @age_from = @age_from.to_i if !@age_from.blank?\n @age_to = params[\"age_to\"]\n @age_to = @age_to.to_i if !@age_to.blank?\n @gender = params[\"gender\"]\n @education = params[\"education\"]\n @synonym_type = params[\"synonym_type\"]\n\n if !@age_from.blank? && !@age_to.blank? && @age_from.to_i > @age_to.to_i\n temp = @age_from\n @age_from = @age_to\n @age_to = temp\n end\n\n if @synonym_type == \"0\"\n @synonym_type = nil\n elsif @synonym_type == \"1\"\n @synonym_type = true\n elsif @synonym_type == \"2\"\n @synonym_type = false\n end\n\n if !@search_keyword.blank?\n @search_keyword = @search_keyword.strip\n @search_keyword = @search_keyword.split(\" \").join(\" \")\n\n @search_keyword_model = Keyword.find_by_name(@search_keyword)\n if !@search_keyword_model.blank?\n \n if !current_developer.my_subscription\n .can_search_word(@search_keyword_model.id)\n \n flash[:error] = t(:search_not_allowed)\n redirect_to search_keywords_path, flash: flash\n return\n end\n\n @synonyms, @votes =\n @search_keyword_model.retrieve_synonyms(@country, @age_from, \n @age_to, @gender, @education, @synonym_type)\n\n @no_synonyms_found = true if @synonyms.blank?\n\n @total_votes = 0\n @votes.each { |synonym_id, synonym_votes| @total_votes += synonym_votes }\n\n @categories =\n @search_keyword_model.categories.map { |c| c.get_name_by_locale }\n\n @category_ids = @search_keyword_model.categories.map { |c| c.id }\n\n if !@no_synonyms_found\n @charts = @synonyms.map{ |s| { s.id => \n [piechart_gender(s.id, @gender, @country, @education, @age_from, @age_to), \n piechart_country(s.id, @gender, @country, @education, @age_from, @age_to),\n piechart_age(s.id, @gender, @country, @education, @age_from, @age_to), \n piechart_education(s.id, @gender, @country, @education, @age_from,@age_to)] } }\n end \n\n if request.xhr?\n render \"filtered_results.js\"\n end\n else\n redirect_to search_keywords_path(search: @search_keyword)\n end\n else\n redirect_to search_keywords_path\n end\n end",
"def filter\n filter = \"\"\n\n filter = filter_by_user\n filter += filter_by_status\n filter += filter_by_milestones_projects_and_customers\n filter += filter_by_properties\n\n if session[:hide_deferred].to_i > 0\n filter << \"(tasks.hide_until IS NULL OR tasks.hide_until < '#{@tz.now.utc.to_s(:db)}') AND \"\n end \n filter << \"(tasks.milestone_id NOT IN (#{@completed_milestone_ids}) OR tasks.milestone_id IS NULL) AND \"\n\n filter = filter.gsub(/( AND )$/, \"\")\n return filter\n end",
"def filter; end",
"def filter; end",
"def filter; end",
"def search_filter(search_term)\n @items = @items.where('client_name like ? OR client_ssn like ? OR case_id like ?', \"%#{search_term}%\", \"%#{search_term}%\", \"%#{search_term}%\")\n @old_items = @items.where('client_name like ? OR client_ssn like ? OR case_id like ?', \"%#{search_term}%\", \"%#{search_term}%\", \"%#{search_term}%\")\n session[:search] = search_term\n end",
"def autofilter\r\n\t\tfalse\r\n\tend",
"def autofilter\r\n\t\tfalse\r\n\tend",
"def autofilter\r\n\t\tfalse\r\n\tend",
"def autofilter\r\n\t\tfalse\r\n\tend",
"def filter\n\tfilter_disabled\n\tfilter_repeated\n\tfilter_silenced\n\tfilter_dependencies\n end",
"def extra_search_actions(items, extra_filters = [], kind = nil)\n (extra_filters || []).each do |filter|\n case filter\n when 'my_country'\n case kind || params[:type]\n when 'people', 'counselors'\n items = items.where(country: current_user.country)\n when 'churches', 'groups'\n items = items.joins(:user).where(users:{ country: current_user.country })\n when 'contents'\n items = items.joins(:user).where(users:{ country: current_user.country })\n when 'events'\n items = items.joins('inner join user_groups on user_groups.id = events.eventable_id and events.eventable_type = \\'UserGroup\\' inner join users on users.id = user_groups.user_id').where('users.country = ?', current_user.country)\n \n # TODO\n end\n when 'my_groups'\n case kind || params[:type]\n when 'people', 'counselors'\n items = items.joins(:user_groups).where(user_groups: {id: current_user.user_groups.pluck(:id)})\n when 'churches', 'groups'\n items = items.where(id: current_user.user_groups.select(:id))\n when 'contents'\n items = items.where(user_id: current_user.user_groups_members.select(:id))\n when 'events'\n items = items.where(id: current_user.user_groups_events.select(:id))\n end\n end\n end\n items\n end",
"def postFetchFilter\n @filtered= Filter.new(@detail.waypoints)\n\n # caches with warnings we choose not to include.\n beforeFilterTotal = @filtered.totalWaypoints\n if @option['includeArchived']\n @appliedFilters['--includeArchived'] = { 'f' => \"\", 't' => \"also archived\" }\n else\n # this would cause too much noise, don't advertise\n #@appliedFilters['--excludeArchived'] = { 'f' => \"\", 't' => \"not archived\" }\n @filtered.removeByElement('archived')\n end\n excludedFilterTotal = beforeFilterTotal - @filtered.totalWaypoints\n showRemoved(excludedFilterTotal, \"Archived\")\n #\n beforeFilterTotal = @filtered.totalWaypoints\n if @option['includeDisabled']\n @appliedFilters['-z'] = { 'f' => \"\", 't' => \"also disabled\" }\n else\n @appliedFilters['+z'] = { 'f' => \"\", 't' => \"not disabled\" }\n @filtered.removeByElement('disabled')\n end\n excludedFilterTotal = beforeFilterTotal - @filtered.totalWaypoints\n showRemoved(excludedFilterTotal, \"Disabled\")\n\n # exclude Premium Member Only caches on request\n beforeFilterTotal = @filtered.totalWaypoints\n if @option['noPMO']\n @appliedFilters['-O'] = { 'f' => \"\", 't' => \"no PMO\" }\n @filtered.removeByElement('membersonly')\n end\n if @option['onlyPMO']\n @appliedFilters['-Q'] = { 'f' => \"\", 't' => \"PMO\" }\n @filtered.removeByElement('membersonly', false)\n end\n excludedFilterTotal = beforeFilterTotal - @filtered.totalWaypoints\n showRemoved(excludedFilterTotal, \"PM-Only\")\n\n beforeFilterTotal = @filtered.totalWaypoints\n if @option['descKeyword']\n @appliedFilters['-K'] = { 'f' => \"#{@option['descKeyword']}\", 't' => \"matching descr. keyword\" }\n @filtered.descKeyword(@option['descKeyword'])\n end\n excludedFilterTotal = beforeFilterTotal - @filtered.totalWaypoints\n showRemoved(excludedFilterTotal, \"Keyword\")\n\n beforeFilterTotal = @filtered.totalWaypoints\n if @option['difficultyMin']\n @appliedFilters['-d'] = { 'f' => \"#{@option['difficultyMin']}\", 't' => \"difficulty min\" }\n @filtered.difficultyMin(@option['difficultyMin'].to_f)\n end\n if @option['difficultyMax']\n @appliedFilters['-D'] = { 'f' => \"#{@option['difficultyMax']}\", 't' => \"difficulty max\" }\n @filtered.difficultyMax(@option['difficultyMax'].to_f)\n end\n if @option['terrainMin']\n @appliedFilters['-t'] = { 'f' => \"#{@option['terrainMin']}\", 't' => \"terrain min\" }\n @filtered.terrainMin(@option['terrainMin'].to_f)\n end\n if @option['terrainMax']\n @appliedFilters['-T'] = { 'f' => \"#{@option['terrainMax']}\", 't' => \"terrain max\" }\n @filtered.terrainMax(@option['terrainMax'].to_f)\n end\n if @option['sizeMin']\n @appliedFilters['-s'] = { 'f' => \"#{@option['sizeMin']}\", 't' => \"size min\" }\n @filtered.sizeMin(@option['sizeMin'])\n end\n if @option['sizeMax']\n @appliedFilters['-S'] = { 'f' => \"#{@option['sizeMax']}\", 't' => \"size max\" }\n @filtered.sizeMax(@option['sizeMax'])\n end\n excludedFilterTotal = beforeFilterTotal - @filtered.totalWaypoints\n showRemoved(excludedFilterTotal, \"D/T/Size\")\n\n beforeFilterTotal = @filtered.totalWaypoints\n if @option['favFactorMin']\n @appliedFilters['-g'] = { 'f' => \"#{@option['favFactorMin']}\", 't' => \"favFactor min\" }\n @filtered.favFactorMin(@option['favFactorMin'].to_f)\n end\n if @option['favFactorMax']\n @appliedFilters['-G'] = { 'f' => \"#{@option['favFactorMax']}\", 't' => \"favFactor max\" }\n @filtered.favFactorMax(@option['favFactorMax'].to_f)\n end\n excludedFilterTotal = beforeFilterTotal - @filtered.totalWaypoints\n showRemoved(excludedFilterTotal, \"FavFactor\")\n\n # We filter for users again. While this may be a bit obsessive, this is in case\n # our local cache is not valid.\n beforeFilterTotal = @filtered.totalWaypoints\n if @option['userExclude']\n @appliedFilters['-E'] = { 'f' => \"#{@option['userExclude']}\", 't' => \"not done by\" }\n @option['userExclude'].split($delimiters).each{ |user|\n @filtered.userExclude(user)\n }\n end\n if @option['userInclude']\n @appliedFilters['-e'] = { 'f' => \"#{@option['userInclude']}\", 't' => \"done by\" }\n @option['userInclude'].split($delimiters).each{ |user|\n @filtered.userInclude(user)\n }\n end\n excludedFilterTotal = beforeFilterTotal - @filtered.totalWaypoints\n showRemoved(excludedFilterTotal, \"User\")\n\n beforeFilterTotal = @filtered.totalWaypoints\n if @option['attributeExclude']\n @appliedFilters['-A'] = { 'f' => \"#{@option['attributeExclude']}\", 't' => \"attr no\" }\n @option['attributeExclude'].split($delimiters).each{ |attribute|\n @filtered.attributeExclude(attribute)\n }\n end\n if @option['attributeInclude']\n @appliedFilters['-a'] = { 'f' => \"#{@option['attributeExclude']}\", 't' => \"attr yes\" }\n @option['attributeInclude'].split($delimiters).each{ |attribute|\n @filtered.attributeInclude(attribute)\n }\n end\n excludedFilterTotal = beforeFilterTotal - @filtered.totalWaypoints\n showRemoved(excludedFilterTotal, \"Attribute\")\n\n beforeFilterTotal = @filtered.totalWaypoints\n if @option['minLongitude']\n @appliedFilters['--minLon'] = { 'f' => \"#{@option['minLongitude']}\", 't' => \"West\" }\n @filtered.longMin(@option['minLongitude'])\n end\n if @option['maxLongitude']\n @appliedFilters['--maxLon'] = { 'f' => \"#{@option['maxLongitude']}\", 't' => \"East\" }\n @filtered.longMax(@option['maxLongitude'])\n end\n if @option['minLatitude']\n @appliedFilters['--minLat'] = { 'f' => \"#{@option['minLatitude']}\", 't' => \"South\" }\n @filtered.latMin(@option['minLatitude'])\n end\n if @option['maxLatitude']\n @appliedFilters['--maxLat'] = { 'f' => \"#{@option['maxLatitude']}\", 't' => \"North\" }\n @filtered.latMax(@option['maxLatitude'])\n end\n excludedFilterTotal = beforeFilterTotal - @filtered.totalWaypoints\n showRemoved(excludedFilterTotal, \"Lat/Lon\")\n\n displayMessage \"Post-fetch filter complete, #{caches(@filtered.totalWaypoints)} left.\"\n return @filtered.totalWaypoints\n end",
"def search_for_item\n search_service.fetch(params[:id], { fl: ['visibility_ssi'] })\n end",
"def filter(query_type, options = {})\n bool.filter(query_type, options)\n self\n end",
"def search\n @users = User.search(@search_term)\n @tweets = Tweet.search(@search_term)\n @tags = Tag.search(@search_term)\n end",
"def filter_by_visibility(solr_parameters)\n # add a new solr facet query ('fq') parameter that limits results to those with a 'public_b' field of 1\n solr_parameters[:fq] ||= []\n fq = viewable_metadata_visibilities.map { |visibility| \"(visibility_ssi:\\\"#{visibility}\\\")\" }.join(\" OR \")\n solr_parameters[:fq] << \"(#{fq})\"\n end",
"def search_diagnose\n\t\t# Searching for diagnose as per user entered term\n\t\tif Diagnose.where(user_type: \"admin\").any_of({ :name => /^#{params[:term]}/i }).present?\n\t\t\t# if search show from the admin then the search term from diagnose of admin\n\t\t\tdiagnose = Diagnose.where(user_type: \"admin\").any_of({ :name => /^#{params[:term]}/i }).all.collect{|diagnosis| {label: diagnosis.name}}.uniq.to_json\n\t\telse\n\t\t\t# else the term is not equal to the admin diagnose then that search from the user term\n\t\t\tdiagnose = current_user.diagnose.any_of({ :name => /^#{params[:term]}/i }).all.collect{|diagnosis| {label: diagnosis.name}}.uniq.to_json \n\t\tend\n\t\t# render to the diagnose name page\n\t\trespond_to do |format|\n\t\t format.json { render :json => diagnose }\n\t\tend\n\tend",
"def filter_by(filter, current_user = nil)\n return self unless filter.present?\n\n records = self\n\n records = records.where(id: filter[:tag_ids]) if filter[:tag_ids]\n\n if filter[:user_id]\n records = records.from_user_id(filter[:user_id], current_user&.id)\n elsif filter[:user_slug]\n records = records.from_user(filter[:user_slug], current_user&.id)\n end\n\n if filter[:topic_id]\n records = records.for_topic_id(filter[:topic_id]) if filter[:topic_id]\n elsif filter[:topic_slug]\n records = records.for_topic(filter[:topic_slug])\n end\n\n records = records.bookmarked_by_user(current_user.id) if filter[:bookmarked] && current_user\n\n records = records.where(accepted: filter[:accepted]) if filter[:accepted]\n records = records.with_visibility(filter[:visibility]) if filter[:visibility]\n\n return records\n end",
"def filter\n list.children.each do |item|\n item.toggle_class :hidden, !(item.value =~ Regexp.new(@input.value, 'i'))\n end\n end",
"def filtered_by_instance(notifiable)\n filtered_by_association(\"notifiable\", notifiable)\n end",
"def filters_for_user(user)\n user.present? ? filters_with_external : public_filters\n end",
"def filter_by_user_id\n @query = @query.where(user_id: @user_id)\n end",
"def filter_description\n c = self.filter_clause\n c ? \"Show where #{c}\" : \"Show all\"\n end",
"def search_activity\n case activity\n when \"voted\"\n query\n .includes(:votes)\n .where(decidim_opinions_opinion_votes: { decidim_author_id: @current_user })\n when \"my_opinions\"\n query\n .where.not(coauthorships_count: 0)\n .joins(:coauthorships)\n .where(decidim_coauthorships: { decidim_author_type: \"Decidim::UserBaseEntity\" })\n .where(decidim_coauthorships: { decidim_author_id: @current_user })\n else # Assume 'all'\n query\n end\n end",
"def filters_for(model)\n filters = session['search'][model.to_s] if session['search'] && session['search'][model.to_s].presence\n filters.delete_if { |k, v| v.nil? } if filters\n end",
"def filter\n @filter\n end",
"def search\n\t\t@search = Elasticsearch::Model.search(params[:q], [Majorpost, Campaign, User]).page(params[:page]).per_page(10).records\n\t\tif user_signed_in?\n\t\t\tshow_contacts\n\t\t\tshow_followed\n\t\t\tshow_liked\n\t\tend\n\t\t@site_activity = PublicActivity::Activity.order(\"created_at desc\").where(owner_type: \"User\", :published => true,:abandoned => nil,trackable_type: [\"Subscription\",\"LikedUser\"]).page(params[:page]).per_page(5)\n\trescue\n\t \tflash[:error] = t('errors.messages.not_saved')\n\t \tredirect_to(:back)\t\t\n\tend",
"def autofilter\n true\n end",
"def search\n @user = current_user\n temp_revs = []\n unless params[:search_terms].nil?\n tags = tags_from_string(params[:search_terms])\n temp_revs = filter_reviews(temp_revs, tags)\n end\n @user.friends.each do |friend|\n temp_revs += friend.reviews\n end\n tags = tags_from_string(params[:search_terms])\n temp_revs = filter_reviews(temp_revs, tags)\n @reviews = temp_revs.sort_by(&:post_date).reverse\n end",
"def filter_users\n allowed_keys=[\"email\", \"admin\"]\n filtering_keys=allowed_keys & params.keys\n filtering_keys.each {|key| filter_by_key(key)}\n end",
"def search\n @sharedpurposes = Sharedpurpose.search params[:search]\n \n render \"index\"\n end",
"def discard_search_results(search_id:)\n {\n method: \"DOM.discardSearchResults\",\n params: { searchId: search_id }.compact\n }\n end",
"def filter\n do_authorize_class\n\n filter_response, opts = Settings.api_response.response_advanced(\n api_filter_params,\n Access::ByPermission.dataset_items(current_user, dataset_id: params[:dataset_id]),\n DatasetItem,\n DatasetItem.filter_settings(:reverse_order)\n )\n\n respond_filter(filter_response, opts)\n end",
"def filter_associated_data(resource, search_term, search_value,\n display_terms)\n filtered_data = @data[resource].select do |entity|\n entity[search_term].to_s == search_value.to_s\n end\n\n filtered_data.map do |data|\n data.select { |key, _| display_terms.include? key }\n end\n end",
"def search\n searcher = @admin || @user\n query = params[:query]\n if query.blank?\n redirect_to(:action => 'index', :admin_id => @admin.id)\n else\n query.strip!\n\n case params[:type]\n when 'student' then\n @students = Student.students_of_teacher(searcher).search_data(query, filtered_params)\n when 'teacher' then\n @teachers = searcher.children.unblocked.search_data(query, filtered_params)\n else\n @students = Student.students_of_teacher(searcher).search_data(query, filtered_params)\n @teachers = searcher.children.unblocked.search_data(query, filtered_params)\n end\n end\n end",
"def search\n @user_opt = params[:user_opt]\n @key = params[:q]\n @votes = Hash.new\n @msg = \"\"\n @isDeletable = Array.new\n @posts = Array.new\n @user = current_user\n\n if @user_opt.to_i == 1\n @posts = Post.where(\"title like ? or message like ?\", \"%\" + params[:q] +\"%\",\"%\"+ params[:q] + \"%\")\n ## create a votes variable and initialize it with vote count and display them index page\n else\n @users = User.where(\"username like ?\", \"%\" + params[:q] +\"%\")\n for user in @users\n @posts = @posts + Post.find_all_by_user_id(user.id)\n end\n end\n\n for post in @posts\n @votes[post.id] = PostsUsers.get_vote_count(post.id)\n end\n\n # Checking which of the posts user can delete\n for post in @posts\n @isDeletable[post.id] = (post.user_id == @user.id) || @user.admin_rights\n end\n\n if @posts.empty?\n @msg = \"No search results found. Try new search\"\n end\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n\n end",
"def search_type\n case type\n when \"opinions\"\n query.only_amendables\n when \"amendments\"\n query.only_visible_emendations_for(@current_user, @component)\n else # Assume 'all'\n query.amendables_and_visible_emendations_for(@current_user, @component)\n end\n end",
"def user_search_results\n @limit = 25\n load_facility\n @price_group = PriceGroup.find(params[:price_group_id]) if params[:price_group_id].present?\n @account = Account.find(params[:account_id]) if params[:account_id].present?\n @product = Product.find(params[:product_id]) if params[:product_id].present?\n @search_type = valid_search_types.find { |t| t == params[:search_type] }\n @users, @count = UserFinder.search_with_count(params[:search_term], @limit)\n\n render layout: false\n end",
"def filter_by_user\n Entry.where(user_id: user_id)\n .paginate(page: page_number)\n .order(checkin_at: :desc)\n end",
"def search_by_user(user, additional_filters={})\n additional_filters[:user] = user\n return search(additional_filters)\n end",
"def index\n @estAdmin = admin?\n id = session[:user]['id']\n search = params[:search]&.downcase\n @factures = if @estAdmin && !search\n Facture.includes('client').all\n elsif @estAdmin && search\n Facture.includes('client').search(search).all\n elsif search\n Facture.includes('client').where(user_id: id).search(search)\n else\n Facture.includes('client').where(user_id: id)\n end\n\n @factures = @factures.page(params[:page]).per(7)\n end",
"def search\n unless params[:query].blank?\n @listings = custom_search(params[:query])\n #print \"\\n\\n\\n***203 #{@listings}***\\n\\n\\n\"\n @header_type = \"Search for \\\"\" + params[:query] + \"\\\"\"\n \n #will render search.rhtml by default\n else\n browse\n end\n end",
"def never_show *names\n names.each_with_object({}) { |name, hsh| hsh[name.to_sym] = FilterByNever.new(name) }\n end",
"def filterable?; @filterable; end",
"def filter\n regexp = Regexp.new(@input.value.to_s, 'i')\n list.children.each do |item|\n item.toggle_class :hidden, !(item.label =~ regexp)\n end\n end",
"def filter\n filter = \"\"\n\n if session[:filter_user].to_i > 0\n task_ids = User.find(session[:filter_user].to_i).tasks.collect { |t| t.id }.join(',')\n if task_ids == ''\n filter = \"tasks.id IN (0) AND \"\n else\n filter = \"tasks.id IN (#{task_ids}) AND \"\n end\n elsif session[:filter_user].to_i < 0\n not_task_ids = Task.find(:all, :select => \"tasks.*\", :joins => \"LEFT OUTER JOIN task_owners t_o ON tasks.id = t_o.task_id\", :readonly => false, :conditions => [\"tasks.company_id = ? AND t_o.id IS NULL\", current_user.company_id]).collect { |t| t.id }.join(',')\n if not_task_ids == ''\n filter = \"tasks.id = 0 AND \"\n else\n filter = \"tasks.id IN (#{not_task_ids}) AND \" if not_task_ids != \"\"\n end\n end\n\n if session[:filter_milestone].to_i > 0\n filter << \"tasks.milestone_id = #{session[:filter_milestone]} AND \"\n elsif session[:filter_milestone].to_i < 0\n filter << \"(tasks.milestone_id IS NULL OR tasks.milestone_id = 0) AND \"\n end\n\n unless session[:filter_status].to_i == -1 || session[:filter_status].to_i == -2\n if session[:filter_status].to_i == 0\n filter << \"(tasks.status = 0 OR tasks.status = 1) AND \"\n elsif session[:filter_status].to_i == 2\n filter << \"(tasks.status > 1) AND \"\n else\n filter << \"tasks.status = #{session[:filter_status].to_i} AND \"\n end\n end\n\n if session[:filter_status].to_i == -2\n filter << \"tasks.hidden = 1 AND \"\n else\n filter << \"(tasks.hidden = 0 OR tasks.hidden IS NULL) AND \"\n end\n\n if session[:hide_deferred].to_i > 0\n filter << \"(tasks.hide_until IS NULL OR tasks.hide_until < '#{@tz.now.utc.to_s(:db)}') AND \"\n end \n\n unless session[:filter_customer].to_i == 0\n filter << \"tasks.project_id IN (#{current_user.projects.find(:all, :conditions => [\"customer_id = ?\", session[:filter_customer]]).collect(&:id).compact.join(',') }) AND \"\n end\n\n filter << \"(tasks.milestone_id NOT IN (#{@completed_milestone_ids}) OR tasks.milestone_id IS NULL) \"\n\n return filter\n end",
"def filter(options={})\n raise NotImplementedError\n end",
"def filtering_ids\n return nil unless current_user\n\n return @filtering_ids if @filtering_ids\n\n @filtering_ids = Rails.cache.read cache_ids_key\n end",
"def where(params)\n query(params).select { |spammer| spammer.appears? }\n end",
"def super_search\n @browse_state.attributes=(params)\n @search_filter1 = @browse_state.make_search_filter\n \n ## Condition - when to include or exlude romance from the search list.\n if params[:search_filter].nil? || (!params[:search_filter].nil? && params[:search_filter][:romance] == \"19\") \n cond = params[:search_filter][:romance].to_i if !params[:search_filter].nil? && !params[:search_filter][:romance].nil?\n cond = 19 if !params[:search_filter].nil? && params[:search_filter][:romance].nil?\n cond = 19 if params[:search_filter].nil?\n else\n cond = 0\n end\n \n ## Month validation as it should not be greater than 12.\n if !params[:search_filter].nil? && ( !params[:search_filter][:start_time].nil? || !params[:search_filter][:end_time].nil?) \n if params[:search_filter][:start_time] && params[:search_filter][:start_time] != \"MM/DD/YYYY\"\n s = params[:search_filter][:start_time].split('/')\n if s[0].to_i > 12\n params[:search_filter][:start_time] = Time.now.utc\n end\n end\n \n if params[:search_filter][:end_time] && params[:search_filter][:end_time] != \"MM/DD/YYYY\"\n s = params[:search_filter][:end_time].split('/')\n if s[0].to_i > 12\n params[:search_filter][:end_time] = Time.now.utc\n end\n end\n end\n \n ## Condition for getting activity id range.\n if !params[:search_filter].nil? && !params[:search_filter][:purpose_id].blank? \n p_id = params[:search_filter][:purpose_id].to_i\n elsif !params[:search_filter].nil? && params[:search_filter][:purpose_id].blank?\n p_id = 1..21\n end \n \n ## Condition for getting purpose id range.\n if !params[:search_filter].nil? && !params[:search_filter][:activity_id].blank? \n a_id = params[:search_filter][:activity_id].to_i\n elsif !params[:search_filter].nil? && params[:search_filter][:activity_id].blank?\n a_id = 1..14\n end \n \n ## Condition for getting zip codes in the given radius.\n if params[:checked_locat] == \"1\"\n if params[:search_filter][:city] == \"Atlanta\" or params[:search_filter][:city] == \"atlanta\" or params[:search_filter][:city] == \"ATLANTA\"\n st = \"GA\"\n elsif params[:search_filter][:city] == \"Boulder\" or params[:search_filter][:city] == \"boulder\" or params[:search_filter][:city] == \"BOULDER\"\n st = \"CO\"\n elsif params[:search_filter][:city] == \"San Diego\" or params[:search_filter][:city] == \"san diego\" or params[:search_filter][:city] == \"SAN DIEGO\"\n st = \"CA\"\n elsif params[:search_filter][:city] == \"Dallas\" or params[:search_filter][:city] == \"dallas\" or params[:search_filter][:city] == \"DALLAS\"\n st = \"TX\"\n elsif params[:search_filter][:city] == \"Houston\" or params[:search_filter][:city] == \"houston\" or params[:search_filter][:city] == \"HOUSTON\"\n st = \"TX\"\n elsif params[:search_filter][:city] == \"Miami\" or params[:search_filter][:city] == \"miami\" or params[:search_filter][:city] == \"MIAMI\"\n st = \"FL\"\n elsif params[:search_filter][:city] == \"San Francisco\" or params[:search_filter][:city] == \"san francisco\" or params[:search_filter][:city] == \"SAN FRANCISCO\"\n st = \"CA\"\n elsif params[:search_filter][:city] == \"Portland\" or params[:search_filter][:city] == \"portland\" or params[:search_filter][:city] == \"PORTLAND\"\n st = \"OR\"\n elsif params[:search_filter][:city] == \"San Jose\" or params[:search_filter][:city] == \"san jose\" or params[:search_filter][:city] == \"SAN JOSE\"\n st = \"CA\"\n end\n \n if !params[:search_filter].nil? && (!params[:search_filter][:zip].blank? || !params[:search_filter][:city].blank?)\n if st != \"\"\n r = ZipCode.find(:first,:select => \"latitude,longitude\",:conditions => [\"zip = ? or (city = '#{params[:search_filter][:city]}' and state = '#{st}')\",params[:search_filter][:zip]])\n else\n r = ZipCode.find(:first,:select => \"latitude,longitude\",:conditions => [\"zip = ? or city = ?\",params[:search_filter][:zip],params[:search_filter][:city]])\n end\n rad = params[:search_filter][:radius].to_i\n if !r.nil?\n sql = \"SELECT dest.id,dest.zip,3956 * 2 * ASIN(SQRT( POWER(SIN((orig.latitude - dest.latitude) * pi()/180 / 2), 2) + COS(orig.latitude * pi()/180) * COS(dest.latitude * pi()/180) * POWER(SIN((orig.longitude -dest.longitude) * pi()/180 / 2), 2) )) as distance FROM zip_codes dest, zip_codes orig WHERE dest.id = orig.id and dest.longitude between #{r.longitude}-#{rad}/abs(cos(radians(#{r.latitude}))*69) and #{r.longitude}+#{rad}/abs(cos(radians(#{r.latitude}))*69) and dest.latitude between #{r.latitude}-(#{rad}/69) and #{r.latitude}+(#{rad}/69) LIMIT 4096\"\n z = ZipCode.find_by_sql(sql)\n zcids = z.collect(&:id)\n end\n else\n zcids = \"\"\n end\n end\n \n zcids = \"\" if r.nil?\n \n params[:search_filter] ||= params[\"amp;search_filter\"] # Hack to stop a malformed feed url from causing an exception - dave\n if params[:search_filter].nil?\n @search_filter = SearchFilter.new\n else\n @search_filter = SearchFilter.new(params[:search_filter])\n end\n \n if !params[:search_filter].nil?\n if params[:search_filter][:start_time] == \"MM/DD/YYYY\" && params[:search_filter][:end_time] == \"MM/DD/YYYY\"\n @search_filter.start_time = Time.now.utc\n elsif params[:search_filter][:start_time] != \"MM/DD/YYYY\" && params[:search_filter][:end_time] == \"MM/DD/YYYY\"\n @search_filter.start_time = params[:search_filter][:start_time].to_date.to_time\n elsif params[:search_filter][:start_time] == \"MM/DD/YYYY\" && params[:search_filter][:end_time] != \"MM/DD/YYYY\"\n @search_filter.start_time = params[:search_filter][:end_time].to_date.to_time\n @search_filter.end_time = nil\n elsif params[:search_filter][:start_time] != \"MM/DD/YYYY\" && params[:search_filter][:end_time] != \"MM/DD/YYYY\"\n if params[:search_filter][:start_time].nil? && !params[:search_filter][:start_date].nil?\n params[:search_filter][:start_time] = params[:search_filter][:start_date]\n end\n @search_filter.start_time = params[:search_filter][:start_time].to_date.to_time if !params[:format] && !params[:search_filter][:start_time].nil?\n @search_filter.start_time = Time.now.utc if !params[:format] && params[:search_filter][:start_time].nil?\n @search_filter.end_time = params[:search_filter][:end_time].to_date.to_time if !params[:search_filter][:end_time].nil? \n end\n end\n \n if !params[:search_filter].nil?\n location = params[:search_filter][:location] ? params[:search_filter][:location] : ''\n terms = params[:search_filter][:terms] ? params[:search_filter][:terms] : ''\n person = params[:search_filter][:person] ? params[:search_filter][:person] : ''\n state = params[:search_filter][:state] ? params[:search_filter][:state] : ''\n country = params[:search_filter][:country] ? params[:search_filter][:country] : ''\n airport_id = params[:search_filter][:airport_id] ? params[:search_filter][:airport_id] : ''\n param_string = \"posted #{country} #{state} #{location} #{terms} #{person} #{airport_id}\" if !private_mw?\n param_string = \"posted #{state} #{location} #{terms} #{person} #{airport_id}\" if private_mw?\n if params[:search_filter][:virtual_f] == \"0\" && params[:checked_locat] == \"1\"\n @invitations = Invitation.search \"#{param_string}\",:with => {:start_date => @search_filter.start_time..Time.now.utc.advance(:days => 1000),:is_public => 1,:deactivated => 0,:purpose_id => p_id,:activity_id => a_id,:zip_code_id => zcids}, :without => {:purpose_id => cond},:conditions => {:virtual_f => \"no_flag\",:university_name => @univ_account}, :order => :start_date, :sort_mode => :desc, :page => params[:page], :per_page => 10 if params[:search_filter][:start_time] == \"MM/DD/YYYY\" && params[:search_filter][:end_time] == \"MM/DD/YYYY\"\n @invitations = Invitation.search \"#{param_string}\",:with => {:start_date => params[:search_filter][:start_time].to_date.to_time..params[:search_filter][:start_time].to_date.to_time.advance(:days => 1000),:is_public => 1,:deactivated => 0,:purpose_id => p_id,:activity_id => a_id,:zip_code_id => zcids}, :without => {:purpose_id => cond},:conditions => {:virtual_f => \"no_flag\",:university_name => @univ_account}, :order => :id, :sort_mode => :desc, :page => params[:page], :per_page => 10 if params[:search_filter][:start_time] != \"MM/DD/YYYY\" && params[:search_filter][:end_time] == \"MM/DD/YYYY\"\n @invitations = Invitation.search \"#{param_string}\",:with => {:start_date => @search_filter.start_time..Time.now.utc.advance(:days => 1000),:is_public => 1,:deactivated => 0,:purpose_id => p_id,:activity_id => a_id,:zip_code_id => zcids}, :without => {:purpose_id => cond},:conditions => {:virtual_f => \"no_flag\",:university_name => @univ_account}, :order => :start_date, :sort_mode => :desc, :page => params[:page], :per_page => 10 if params[:search_filter][:start_time] == \"MM/DD/YYYY\" && params[:search_filter][:end_time] != \"MM/DD/YYYY\"\n @invitations = Invitation.search \"#{param_string}\",:with => {:start_date => params[:search_filter][:start_time].to_date.to_time..params[:search_filter][:end_time].to_date.to_time,:is_public => 1,:deactivated => 0,:purpose_id => p_id,:activity_id => a_id,:zip_code_id => zcids}, :without => {:purpose_id => cond},:conditions => {:virtual_f => \"no_flag\",:university_name => @univ_account}, :order => :start_date, :sort_mode => :desc, :page => params[:page], :per_page => 10 if params[:search_filter][:start_time] != \"MM/DD/YYYY\" && params[:search_filter][:end_time] != \"MM/DD/YYYY\"\n elsif params[:search_filter][:virtual_f] == \"v_flag\" && (params[:checked_locat] == \"0\" || params[:checked_locat] == \"\")\n @invitations = Invitation.search \"#{param_string}\",:with => {:start_date => @search_filter.start_time..Time.now.utc.advance(:days => 1000),:is_public => 1,:deactivated => 0,:purpose_id => p_id,:activity_id => a_id},:conditions => {:virtual_f => \"v_flag\",:university_name => @univ_account}, :without => {:purpose_id => cond}, :order => :start_date, :sort_mode => :desc, :page => params[:page], :per_page => 10 \n @invitations = Invitation.search \"#{param_string}\",:with => {:start_date => params[:search_filter][:start_time].to_date.to_time..params[:search_filter][:start_time].to_date.to_time.advance(:days => 1000),:is_public => 1,:deactivated => 0,:purpose_id => p_id,:activity_id => a_id}, :without => {:purpose_id => cond},:conditions => {:virtual_f => \"v_flag\",:university_name => @univ_account}, :order => :start_date, :sort_mode => :desc, :page => params[:page], :per_page => 10 if params[:search_filter][:start_time] != \"MM/DD/YYYY\" && params[:search_filter][:end_time] == \"MM/DD/YYYY\"\n @invitations = Invitation.search \"#{param_string}\",:with => {:start_date => @search_filter.start_time..Time.now.utc.advance(:days => 1000),:is_public => 1,:deactivated => 0,:purpose_id => p_id,:activity_id => a_id},:conditions => {:virtual_f => \"v_flag\",:university_name => @univ_account}, :without => {:purpose_id => cond}, :order => :start_date, :sort_mode => :desc, :page => params[:page], :per_page => 10 if params[:search_filter][:start_time] == \"MM/DD/YYYY\" && params[:search_filter][:end_time] != \"MM/DD/YYYY\"\n @invitations = Invitation.search \"#{param_string}\",:with => {:start_date => params[:search_filter][:start_time].to_date.to_time..params[:search_filter][:end_time].to_date.to_time,:is_public => 1,:deactivated => 0,:purpose_id => p_id,:activity_id => a_id}, :without => {:purpose_id => cond},:conditions => {:virtual_f => \"v_flag\",:university_name => @univ_account}, :order => :start_date, :sort_mode => :desc, :page => params[:page], :per_page => 10 if params[:search_filter][:start_time] != \"MM/DD/YYYY\" && params[:search_filter][:end_time] != \"MM/DD/YYYY\"\n else\n @invitations = Invitation.search \"#{param_string}\",:with => {:start_date => @search_filter.start_time..Time.now.utc.advance(:days => 1000),:is_public => 1,:deactivated => 0,:purpose_id => p_id,:activity_id => a_id,:zip_code_id => zcids}, :without => {:purpose_id => cond},:conditions => {:university_name => @univ_account}, :order => :id, :sort_mode => :desc, :page => params[:page], :per_page => 10 if params[:search_filter][:start_time] == \"MM/DD/YYYY\" && params[:search_filter][:end_time] == \"MM/DD/YYYY\"\n @invitations = Invitation.search \"#{param_string}\",:with => {:start_date => params[:search_filter][:start_time].to_date.to_time..params[:search_filter][:start_time].to_date.to_time.advance(:days => 1000),:is_public => 1,:deactivated => 0,:purpose_id => p_id,:activity_id => a_id,:zip_code_id => zcids}, :without => {:purpose_id => cond},:conditions => {:university_name => @univ_account}, :order => :start_date, :sort_mode => :desc, :page => params[:page], :per_page => 10 if params[:search_filter][:start_time] != \"MM/DD/YYYY\" && params[:search_filter][:end_time] == \"MM/DD/YYYY\"\n @invitations = Invitation.search \"#{param_string}\",:with => {:start_date => @search_filter.start_time..Time.now.utc.advance(:days => 1000),:is_public => 1,:deactivated => 0,:purpose_id => p_id,:activity_id => a_id,:zip_code_id => zcids}, :without => {:purpose_id => cond},:conditions => {:university_name => @univ_account}, :order => :start_date, :sort_mode => :desc, :page => params[:page], :per_page => 10 if params[:search_filter][:start_time] == \"MM/DD/YYYY\" && params[:search_filter][:end_time] != \"MM/DD/YYYY\"\n @invitations = Invitation.search \"#{param_string}\",:with => {:start_date => params[:search_filter][:start_time].to_date.to_time..params[:search_filter][:end_time].to_date.to_time,:is_public => 1,:deactivated => 0,:purpose_id => p_id,:activity_id => a_id,:zip_code_id => zcids}, :without => {:purpose_id => cond},:conditions => {:university_name => @univ_account}, :order => :start_date, :sort_mode => :desc, :page => params[:page], :per_page => 10 if params[:search_filter][:start_time] != \"MM/DD/YYYY\" && params[:search_filter][:end_time] != \"MM/DD/YYYY\" && !params[:search_filter][:start_time].nil? && !params[:search_filter][:end_time].nil? && !params[:format]\n\n @invitations = Invitation.search \"#{param_string}\",:with => {:start_date => params[:search_filter][:start_time].to_date.to_time..params[:search_filter][:start_time].to_date.to_time.advance(:days => 1000),:is_public => 1,:deactivated => 0,:purpose_id => p_id,:activity_id => a_id,:zip_code_id => zcids}, :without => {:purpose_id => cond},:conditions => {:university_name => @univ_account}, :order => :start_date, :sort_mode => :desc, :page => params[:page], :per_page => 10 if params[:search_filter][:start_time] != \"MM/DD/YYYY\" && params[:search_filter][:end_time] != \"MM/DD/YYYY\" && !params[:search_filter][:start_time].nil? && params[:search_filter][:end_time].nil? && !params[:format]\n @invitations = Invitation.search \"#{param_string}\",:with => {:start_date => params[:search_filter][:start_time].to_date.to_time..params[:search_filter][:start_time].to_date.to_time.advance(:days => 1000),:is_public => 1,:deactivated => 0,:purpose_id => p_id,:activity_id => a_id,:zip_code_id => zcids}, :without => {:purpose_id => cond},:conditions => {:university_name => @univ_account}, :order => :start_date, :sort_mode => :desc, :page => params[:page], :per_page => 10 if params[:search_filter][:start_time] != \"MM/DD/YYYY\" && params[:search_filter][:end_time] != \"MM/DD/YYYY\" && !params[:search_filter][:start_time].nil? && params[:search_filter][:end_time].nil? && !params[:format]\n @invitations = Invitation.search \"#{param_string}\",:with => {:start_date => params[:search_filter][:start_date].to_date.to_time..params[:search_filter][:start_date].to_date.to_time,:is_public => 1,:deactivated => 0,:purpose_id => p_id,:activity_id => a_id,:zip_code_id => zcids}, :without => {:purpose_id => cond},:conditions => {:university_name => @univ_account}, :order => :start_date, :sort_mode => :desc, :page => params[:page], :per_page => 10 if params[:search_filter][:start_time] != \"MM/DD/YYYY\" && params[:search_filter][:end_time] != \"MM/DD/YYYY\" && params[:format]\n end\n else\n @search_filter.start_time = Time.now.utc\n @invitations = Invitation.search \"posted\",:with => {:start_date => @search_filter.start_time..Time.now.utc.advance(:days => 1000),:is_public => 1,:deactivated => 0}, :without => {:purpose_id => cond},:conditions => {:university_name => @univ_account}, :order => :start_date, :sort_mode => :desc, :page => params[:page], :per_page => 10 \n end\n @feed_params = @search_filter.to_rss_params \n if params[:format]\n handle_rss()\n else\n render :action => \"new_super_search\", :layout => 'new_super_search' unless check_render_facebook('super_search')\n end\n end",
"def index\n @page_title = ['Words']\n\n sanitize_flag_id\n\n # conditionally clear_all_filters_and_orders\n if params[:reset]\n clear_all_filters_and_orders\n redirect_to words_path and return\n end\n if params[:format] == 'download'\n clear_all_filters_and_orders\n end\n\n # Quick test filters 10 random words from given filters\n if params[:quick_test]\n params[:sort_by] = 'random'; params[:sort_by.to_s] = 'random'\n params[:record_limit] = 10; params[:record_limit.to_s] = 10\n end\n\n # words collection with eager loaded flags, this collection can be modified going forward\n @words = current_user.words.includes(:flags)\n # user dictionaries\n @dictionaries = current_user.dictionaries\n\n # checking filters\n if params[:flag_id]\n if params[:flag_id].kind_of? Array\n flag_ids = params[:flag_id].map{|id| id.to_i}.sort\n # flag_ids = Flag.find(params[:flag_id]).pluck(:id)\n relevant_word_ids = []\n flag_ids.map do |flag_id|\n relevant_word_ids << @words.with_flag_id(flag_id).pluck(:id)\n end\n @words = @words.where(:id => relevant_word_ids)\n else\n if params[:flag_id].to_i > 0\n @flag = Flag.find(params[:flag_id])\n @temp_words = @words.with_flag_id(@flag.id)\n elsif params[:flag_id].to_i == 0\n @temp_words = @words.without_flag\n end\n relevant_word_ids = @temp_words.pluck(:id)\n @words = @words.where(:id => relevant_word_ids)\n end\n end\n if params[:filter_by]\n if params[:filter_by] == 'without_trick'\n @words = @words.without_trick\n elsif params[:filter_by] == 'with_trick'\n @words = @words.with_trick\n end\n end\n if params[:search_text]\n if params[:search_negative] == '1'\n search_negative = true\n else\n search_negative = false\n end\n @words = @words.search(database: AppSetting.get('database'), search_text: params[:search_text], search_type: params[:search_type], search_negative: search_negative)\n end\n\n # checking orders\n if params[:sort_by]\n if params[:sort_by] == 'random'\n @words = @words.sort_by { rand } # Note that @words is an Array now\n elsif params[:sort_by] == 'recent'\n @words = @words.reorder(:updated_at => :desc)\n elsif params[:sort_by] == 'id'\n @words = @words.reorder(:id => :asc)\n end\n end\n\n # limiting records\n @words = Word.limit_records(:record_limit => params[:record_limit], :collection => @words)\n\n # generating additions required instance variables\n @flag_size = Word.number_of_flag_associations(@words)\n\n # generating custom ETag\n # fresh_when([@words, @filters, @order])\n\n # responding\n current_etag = [current_user.id, current_filters_and_orders, @words]\n if ENV['RAILS_ENV'] == 'development'\n # current_etag << Time.now # adding time as parameter to disable etags in development mode\n end\n if params[:sort_by] == 'random'\n current_etag = Time.now # skipping caching in case of random sort\n end\n if stale?(etag: current_etag)\n respond_to do |format|\n format.html # index.html.erb\n format.json # index.json.jbuilder\n format.xml { render :xml => @words.to_xml(:include => {:flags => {:only => [:name, :value]}}, :only => [:word, :trick, :additional_info]) }\n format.download { send_data JSON.pretty_generate(WordDataElement.word_data_backup(@words)), {:filename => \"words #{Time.now.getutc}.json\".split(' ').join('-')} }\n end\n end\n\n end"
] |
[
"0.6334397",
"0.63224846",
"0.6149986",
"0.606387",
"0.60252094",
"0.5999065",
"0.58453584",
"0.58444136",
"0.5786225",
"0.57678837",
"0.5725121",
"0.5703746",
"0.56858015",
"0.56816006",
"0.5672651",
"0.56722015",
"0.56695783",
"0.5667469",
"0.5656655",
"0.5644497",
"0.5629063",
"0.56243205",
"0.56127036",
"0.5606214",
"0.5592347",
"0.55877423",
"0.5587114",
"0.5583635",
"0.5581547",
"0.55784214",
"0.5541851",
"0.5541536",
"0.5541384",
"0.55398935",
"0.5537689",
"0.55292773",
"0.5523178",
"0.5517492",
"0.5515942",
"0.5515942",
"0.5515763",
"0.5508393",
"0.5498953",
"0.5498053",
"0.54973644",
"0.5486026",
"0.5485997",
"0.5484158",
"0.5484035",
"0.5466729",
"0.5451563",
"0.5446061",
"0.5446061",
"0.5446061",
"0.5444367",
"0.5432717",
"0.5432717",
"0.5432717",
"0.5432717",
"0.541038",
"0.5407788",
"0.5404559",
"0.5401094",
"0.5391368",
"0.5390743",
"0.5380817",
"0.53615594",
"0.53608036",
"0.5358495",
"0.5357754",
"0.53539157",
"0.53511953",
"0.53471774",
"0.5338869",
"0.53244615",
"0.53200305",
"0.5317623",
"0.53120285",
"0.5307256",
"0.5297387",
"0.52882135",
"0.5283942",
"0.5282831",
"0.52783",
"0.5270099",
"0.52699316",
"0.52649254",
"0.5260154",
"0.5258152",
"0.5249911",
"0.52486867",
"0.52460706",
"0.5245016",
"0.5242139",
"0.5235795",
"0.5233602",
"0.5233079",
"0.5230892",
"0.5220588",
"0.5219487",
"0.521604"
] |
0.0
|
-1
|
The list of attributes that are permitted to be returned by the API.
|
def api_attributes
record.class.column_names.map(&:to_sym)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def attributes\n @allowed_attributes\n end",
"def restricted_attributes\n if model.respond_to?(:restricted_alchemy_resource_attributes)\n model.restricted_alchemy_resource_attributes\n else\n []\n end\n end",
"def showable_attributes\n return attributes if permitted_to?(WriteAllPrivilege)\n attributes.reject do |k,v|\n !allowed?(:read, k, true)\n end\n end",
"def attributes\n permissions.select { |k, v| v.present? }.as_json\n end",
"def attributes\n ATTRIBUTES\n end",
"def attributes\n @list.map(&:attributes)\n end",
"def attributes\n @attributes ||= []\n @attributes\n end",
"def list_attributes\n if @attributes.empty?\n fetch_configuration()\n end\n return @attributes.keys\n end",
"def attributes\n ATTRIBUTE_NAMES\n end",
"def attributes\n @attributes ||= []\n end",
"def permitted_attributes\n klass.properties.keys.map(&:to_sym) + %i[id edit_users edit_groups read_groups visibility work_members_attributes]\n end",
"def allowed_custom_attributes\n [\n token_sale_registered_attribute,\n token_sale_phase_attribute,\n token_sale_kyc_confirmed_attribute,\n token_sale_has_purchased_attribute,\n kyc_marketing_attribute,\n first_name_attribute,\n last_name_attribute,\n company_name_attribute,\n project_description_attribute,\n kit_marketing_attribute,\n name_poc_attribute,\n team_bio_attribute,\n video_url_attribute,\n url_blog_attribute,\n project_url_attribute,\n tech_doc_attribute,\n twitter_handle_attribute,\n organization_name_attribute\n ]\n end",
"def list_of_attributes\n @list_of_attributes ||= []\n end",
"def attributes\n restricted = defined?(self.class::NON_ATTRIBUTE_PARAMS) ? self.class::NON_ATTRIBUTE_PARAMS : []\n (self.class::PARAM_DEFAULTS.keys - restricted).index_with { |attr| send(attr) }.with_indifferent_access\n end",
"def attributes\n []\n end",
"def allowed_attributes\n self.new.attributes.keys.reject do |col|\n protected_attributes.include?(col)\n end\n end",
"def attributes\n @attributes\n end",
"def attributes\n @attributes\n end",
"def attributes\n @attributes\n end",
"def attributes\n @attrs.keys\n end",
"def attributes_protected_by_default\n []\n end",
"def attributes\n data[:attributes]\n end",
"def readable_attributes \n return attributes if permitted_to?(ReadAllPrivilege)\n attributes.reject do |k,v|\n !allowed?(:read, k)\n end\n end",
"def attributes\n attrs = sort_members(@context.attributes).find_all{|a| @options.show_all || a.visibility == :public || a.visibility == :protected}\n attrs.collect{|a| {:name=>a.name, :visibility=>a.visibility, :rw=>a.rw, :description=>markup(a.comment, true)}}\n end",
"def permitted\n {attrib_name => spec.permitted}\n end",
"def attributes\n @attrs\n end",
"def attributes\n @_attributes\n end",
"def get_attributes\n\t\t\t@@attributes\n\t\tend",
"def attribute_list # :nodoc:\n [:id, :version, :uid, :user, :timestamp, :changeset]\n end",
"def attributes\n @attributes ||= get_field_by_type(ATTRIBUTE_FIELDS)\n end",
"def attributes\n @attributes\n end",
"def list_attributes\n list = \"Age: #{@age} Earth years old\\nSize: #{@size}\\nVisitor Count: #{@visitor_count}\\nInhabitants: #{@inhabitants}\\n\"\n return list\n end",
"def attributes\n @_attributes\n end",
"def attributes\n attributes = resource_class.list_attributes\n attributes &= params[:attributes].split(',') if params[:attributes]\n\n associations = resource_class.reflect_on_all_associations\n\n attributes.map do |attribute|\n next if attribute.blank?\n association = associations.detect { |association| association.foreign_key == attribute }\n\n # If attribute is an association and is not polymorphic, use the association\n # name instead of the foreign key.\n if association\n association.name unless association.options.include? :polymorphic\n else\n attribute\n end\n end.compact\n end",
"def allowed_sort_attributes\n @scope.attribute_names\n end",
"def required_attributes\n self.class::REQUIRED_ATTRIBUTES\n end",
"def attribute_list # :nodoc:\n [:id, :version, :uid, :user, :timestamp, :changeset, :tags]\n end",
"def valid_filter_attributes\n resource_class.attribute_names\n end",
"def permissions\n @attributes[:permissions]\n end",
"def permissions\n @attributes[:permissions]\n end",
"def resource_non_human_attributes\n %w(id created_at updated_at)\n end",
"def attribute_list\n [:id, :version, :uid, :user, :timestamp, :lon, :lat, :changeset]\n end",
"def only\n attributes.fetch(:only)\n end",
"def attributes\n @attributes ||= []\n raise TypeError, \"attributes contain bad elements #{@attributes}\" unless @attributes.all?{ |attribute| attribute.is_a? String }\n @attributes.sort!\n @attributes.uniq!\n @attributes\n end",
"def attributes\n data.require(:attributes)\n end",
"def attributes\n @attributes\n end",
"def attributes\n load_attributes! unless attributes_loaded?\n @attributes.values\n end",
"def _filtered_attributes\n return accessible_attributes.to_a if accessible_attributes.present?\n\n return self.new.attributes.keys - protected_attributes.to_a\n end",
"def attributes\n self\n .class\n .attribute_names\n .map { |attr| [attr, send(attr)] }\n .reject { |_, value| value.nil? }\n .map do |attr, value|\n [attr, value.respond_to?(:attributes) ? value.attributes : value]\n end\n .to_h\n end",
"def attributes\n @attributes ||= descriptors_fields.select{|field| field.scope == ATTRIBUTE_FIELDS }\n end",
"def attributes\n @json_attributes.reject{|k,v| !schema.fields.include?(k)}\n end",
"def to_rest\n return attributes\n end",
"def resource_attributes\n resource_class.attribute_names\n end",
"def valid_attributes\n %w[\n amount\n authorisationId\n automaticResponseUrl\n captureDay\n captureMode\n complementaryCode\n complementaryInfo\n currencyCode\n customerLanguage\n expirationdate\n keyVersion\n maskedPan\n merchantId\n normalReturnUrl\n orderId\n paymentMeanBrand\n paymentMeanBrandList\n paymentMeanType\n responseCode\n transactionDateTime\n transactionReference\n ]\n end",
"def attributes\n @attributes ||= {}\n @attributes\n end",
"def inspect_attributes\n %i[uuid name type slug status email]\n end",
"def attributes\n self.class.attribute_names.map do |attr|\n type = self.class.attribute_types[attr.to_s]\n value = public_send(attr)\n [attr, type ? type.serialize(value) : value]\n end.to_h\n end",
"def readable_attributes resource = nil\n accessible_attributes(resource).delete_if { |attribute| attribute =~ /(_attributes)|(_id)|(_ids)$/ }\n end",
"def attributes\n list.values.map { |field| [field.name, field.value] }.to_h\n end",
"def attributes_protected_by_default\n []\n end",
"def attributes\n instance_values.with_indifferent_access.slice(*USER_ATTRIBUTES)\n end",
"def collectible_attribute_list_params\n params.fetch(:collectible_attribute_list, {})\n end",
"def permitted_params\n res = attribute_names.map(&:to_sym) - %i[disabled user_id created_at updated_at tracker_id tracker_history_id\n admin_id]\n refine_permitted_params res\n end",
"def attributes\n end",
"def writable_attributes\n return attributes if permitted_to?(WriteAllPrivilege)\n attributes.reject do |k,v|\n !allowed?(:write, k)\n end\n end",
"def attributes; @attributes ||= []; end",
"def attributes\n self.class::ATTRIBUTES\n end",
"def attr_list\n\t\ta_list \n\tend",
"def accept_all_attributes\n accept_attributes Object\n end",
"def attribute_values\n attributes.values\n end",
"def attributes(*attrs)\n if attrs.size > 0\n attrs.each{|attr| attribute attr}\n end\n @attributes ||= []\n end",
"def attrs\n @attrs\n end",
"def attribute_names\n @attributes.keys\n end",
"def attribute_names\n @attributes.keys\n end",
"def attribute_names\n @attributes.keys\n end",
"def attribute_names\n @attributes.keys\n end",
"def attributes\n end",
"def attributes\n @attributes ||= Set.new\n end",
"def assignable_attribute_names\n stored_attributes = object.attribute_names.select &method(:permitted?)\n transient_attributes = permitted.select do |attribute_name|\n check_method(\"#{attribute_name}=\")\n true\n end.map(&:to_s)\n stored_attributes + transient_attributes\n end",
"def attributes\n @params\n end",
"def attribute_keys\n return [] unless self[:attributes]\n self[:attributes].keys\n end",
"def serializable_attributes\n IDME_SERIALIZABLE_ATTRIBUTES + REQUIRED_ATTRIBUTES\n end",
"def attrs\n @attrs\n end",
"def attributes\n @attributes = { } if !instance_variable_defined?(:@attributes) or @attributes.nil?\n @attributes\n end",
"def resource_attributes\n self.class.attributes.names - [:options]\n end",
"def object_attributes\n []\n end",
"def attributes\n @@attributes\n end",
"def attribs\n\t\t@attributes\n\tend",
"def get_attribs_all( )\n url = \"#{self.url}/cid?auth=#{self.authtoken}\"\n status, response = rest_get( url )\n return status, response['results'] if ok?( status ) && response['results']\n return status, ''\n end",
"def attributes\n # Note: the values returned here are ignored by\n # ActiveModel::Serializers#serializable_hash; just the keys are\n # used to again call those getter methods... But we do want to\n # check the values so we can leave 'nil' out of the hash.\n attribute_keys.inject(\n ActiveSupport::HashWithIndifferentAccess.new) do |result, key|\n value = send(key)\n result[key] = value unless value == nil\n result\n end\n end",
"def attributes\n if @attributes.empty?\n fetch_configuration()\n end\n return @attributes\n end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attributes; end"
] |
[
"0.81178725",
"0.77115315",
"0.74468434",
"0.73411125",
"0.7229378",
"0.7209567",
"0.7171707",
"0.71683663",
"0.7085622",
"0.7066835",
"0.7061077",
"0.7008751",
"0.69908464",
"0.6959041",
"0.6956525",
"0.69564134",
"0.692772",
"0.692772",
"0.692772",
"0.6891234",
"0.6873543",
"0.6858582",
"0.6855106",
"0.68212795",
"0.6794613",
"0.67882514",
"0.674911",
"0.6739019",
"0.67165315",
"0.6710062",
"0.6702204",
"0.6699947",
"0.6699893",
"0.6696585",
"0.66747427",
"0.66708887",
"0.66624004",
"0.66318554",
"0.6619933",
"0.6619933",
"0.66150105",
"0.6594518",
"0.6588097",
"0.657723",
"0.6562735",
"0.65607846",
"0.6558713",
"0.6557077",
"0.6544665",
"0.65323913",
"0.6511099",
"0.65044785",
"0.64937633",
"0.64916396",
"0.6486523",
"0.64735323",
"0.64709365",
"0.6459258",
"0.64428616",
"0.643867",
"0.64354324",
"0.6433072",
"0.6432482",
"0.6429766",
"0.64278525",
"0.6422997",
"0.641977",
"0.64063406",
"0.6399295",
"0.63918835",
"0.63840145",
"0.6383249",
"0.6375868",
"0.6375868",
"0.6375868",
"0.6375868",
"0.63724786",
"0.63652265",
"0.6354865",
"0.63532794",
"0.6350229",
"0.6345994",
"0.63453215",
"0.63445574",
"0.6337822",
"0.63372946",
"0.6337215",
"0.6321416",
"0.63195515",
"0.631672",
"0.6311295",
"0.63007855",
"0.63007855",
"0.63007855",
"0.63007855",
"0.63007855",
"0.63007855",
"0.63007855",
"0.63007855",
"0.63007855",
"0.63007855"
] |
0.0
|
-1
|
The list of attributes that are permitted to be used as data attributes in tables and in the tag on show pages.
|
def html_data_attributes
data_attributes = record.class.columns.select do |column|
column.type.in?(%i[integer boolean datetime float uuid interval]) && !column.array?
end.map(&:name).map(&:to_sym)
api_attributes & data_attributes
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def attributes\n @allowed_attributes\n end",
"def list_attributes\n list = \"Age: #{@age} Earth years old\\nSize: #{@size}\\nVisitor Count: #{@visitor_count}\\nInhabitants: #{@inhabitants}\\n\"\n return list\n end",
"def attribute_list # :nodoc:\n [:id, :version, :uid, :user, :timestamp, :changeset, :tags]\n end",
"def attributes\n ATTRIBUTE_NAMES\n end",
"def attributes\n @attrs.keys\n end",
"def attributes\n data[:attributes]\n end",
"def attributes\n attrs = sort_members(@context.attributes).find_all{|a| @options.show_all || a.visibility == :public || a.visibility == :protected}\n attrs.collect{|a| {:name=>a.name, :visibility=>a.visibility, :rw=>a.rw, :description=>markup(a.comment, true)}}\n end",
"def allowed_custom_attributes\n [\n token_sale_registered_attribute,\n token_sale_phase_attribute,\n token_sale_kyc_confirmed_attribute,\n token_sale_has_purchased_attribute,\n kyc_marketing_attribute,\n first_name_attribute,\n last_name_attribute,\n company_name_attribute,\n project_description_attribute,\n kit_marketing_attribute,\n name_poc_attribute,\n team_bio_attribute,\n video_url_attribute,\n url_blog_attribute,\n project_url_attribute,\n tech_doc_attribute,\n twitter_handle_attribute,\n organization_name_attribute\n ]\n end",
"def attributes\n restricted = defined?(self.class::NON_ATTRIBUTE_PARAMS) ? self.class::NON_ATTRIBUTE_PARAMS : []\n (self.class::PARAM_DEFAULTS.keys - restricted).index_with { |attr| send(attr) }.with_indifferent_access\n end",
"def attributes\n @attributes ||= []\n end",
"def attributes\n @attributes ||= descriptors_fields.select{|field| field.scope == ATTRIBUTE_FIELDS }\n end",
"def allowed_attributes\n self.new.attributes.keys.reject do |col|\n protected_attributes.include?(col)\n end\n end",
"def attributes\n ATTRIBUTES\n end",
"def attr_strings\n @attr_strings\n end",
"def attributes\n @attributes ||= get_field_by_type(ATTRIBUTE_FIELDS)\n end",
"def attr_columns\n @attr_columns\n end",
"def attribute_list # :nodoc:\n [:id, :version, :uid, :user, :timestamp, :changeset]\n end",
"def attributes\n @attributes ||= []\n @attributes\n end",
"def restricted_attributes\n if model.respond_to?(:restricted_alchemy_resource_attributes)\n model.restricted_alchemy_resource_attributes\n else\n []\n end\n end",
"def attributes\n @attrs\n end",
"def attributes_protected_by_default\n []\n end",
"def allowed_sort_attributes\n @scope.attribute_names\n end",
"def attrs\n @attrs\n end",
"def attributes\n @list.map(&:attributes)\n end",
"def data_attributes\n end",
"def data_attributes\n @schema.schema.select {|k,_| k.to_s.start_with?('data_') or k.to_s.start_with?('data-')}.inject({}) {|col,(k,v)| col[k[5..-1].to_sym]=v;col}\n end",
"def attr_list\n\t\ta_list \n\tend",
"def attrs\n @attrs\n end",
"def list_attributes\n if @attributes.empty?\n fetch_configuration()\n end\n return @attributes.keys\n end",
"def safe_attributes\n self.source.custom_fields_safe_attributes + %w(_slug seo_title meta_keywords meta_description _destroy)\n end",
"def attributes\n attrs = Hash.new\n attribute_list.each do |attribute|\n value = self.send(attribute)\n attrs[attribute] = value unless value.nil?\n end\n attrs\n end",
"def attributes\n @data.keys\n end",
"def attribute_list\n [:id, :version, :uid, :user, :timestamp, :lon, :lat, :changeset]\n end",
"def showable_attributes\n return attributes if permitted_to?(WriteAllPrivilege)\n attributes.reject do |k,v|\n !allowed?(:read, k, true)\n end\n end",
"def attribute_names\n @attributes.keys\n end",
"def attribute_names\n @attributes.keys\n end",
"def attribute_names\n @attributes.keys\n end",
"def attribute_names\n @attributes.keys\n end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def permitted_attributes\n klass.properties.keys.map(&:to_sym) + %i[id edit_users edit_groups read_groups visibility work_members_attributes]\n end",
"def attributes\n @attributes = Hash[attrs.map { |a| [a.to_sym, send(\"#{a}\")] }]\n end",
"def attributes\n []\n end",
"def list_of_attributes\n @list_of_attributes ||= []\n end",
"def attributes\n @attributes ||= []\n raise TypeError, \"attributes contain bad elements #{@attributes}\" unless @attributes.all?{ |attribute| attribute.is_a? String }\n @attributes.sort!\n @attributes.uniq!\n @attributes\n end",
"def attributes\n end",
"def attributes\n [type, column_options]\n end",
"def values\n @attrs.values\n end",
"def attributes\n list.values.map { |field| [field.name, field.value] }.to_h\n end",
"def attrs\n @options[:attrs]\n end",
"def inspect_attributes\n %i[uuid name type slug status email]\n end",
"def attributes\n self\n .class\n .attribute_names\n .map { |attr| [attr, send(attr)] }\n .reject { |_, value| value.nil? }\n .map do |attr, value|\n [attr, value.respond_to?(:attributes) ? value.attributes : value]\n end\n .to_h\n end",
"def attributes; @attributes ||= []; end",
"def attribs\n\t\t@attributes\n\tend",
"def attributes\n @attributes\n end",
"def attributes\n @attributes\n end",
"def attributes\n @attributes\n end",
"def attributes\n data.require(:attributes)\n end",
"def attrs_authoritative\n @authority = :attributes\n self\n end",
"def attributes\n self.class.attribute_names.map do |attr|\n type = self.class.attribute_types[attr.to_s]\n value = public_send(attr)\n [attr, type ? type.serialize(value) : value]\n end.to_h\n end",
"def attributes\n @_attributes\n end",
"def attribute_names\n @attributes.keys\n end",
"def attributes\n instance_values.with_indifferent_access.slice(*USER_ATTRIBUTES)\n end",
"def attributes_protected_by_default\n []\n end",
"def attribute_names\n attributes.keys.sort\n end",
"def attribute_names\n attributes.keys.sort\n end",
"def attributes\n (node.attributes['attrs'] || \"\").split(/\\s*,\\s*/).where_not.blank?\n end",
"def attribute_names\n @attributes.map(&:name)\n end",
"def attributes\n end",
"def attribute_names\n @name_to_definition.keys\n end",
"def attribute_names\n @attribute_names ||= attributes.keys\n end",
"def attributes\n @_attributes\n end",
"def attributes\n @attributes ||= {}\n @attributes\n end",
"def attributes\n self._attributes.inject({}) do |hash, attr|\n hash[attr.to_s] = send(attr)\n hash\n end\n end",
"def permitted\n {attrib_name => spec.permitted}\n end",
"def get_attributes\n\t\t\t@@attributes\n\t\tend",
"def attribute_names\n Array.new\n end",
"def tags\n @attributes.select { |k, _| tag_names.include?(k.to_s) }\n end",
"def attribute_values\n attributes.values\n end",
"def attribute_values\n @columns.map do |column|\n @attributes[column.to_sym]\n end\n end",
"def attributes\n @attributes\n end",
"def attributes\n { 'username' => nil, 'work_place_refno' => nil, 'party_refno' => nil, 'user_roles' => nil,\n 'password_change_required' => nil, 'password_expiry_date' => nil, 'user_is_signed_ta_cs' => nil }\n end",
"def attributes\n load_attributes! unless attributes_loaded?\n @attributes.values\n end",
"def attributes\n Hash[instance_variables.map{|attrib| [attrib.to_s[1..attrib.to_s.size], nil]}]\n end",
"def display_attributes\n self.class.display_attribute_names.map do |name|\n [name.to_s, self.send(name)]\n end.to_h\n end",
"def attributes\n self.class.attribute_names.map do |name|\n [name.to_s, self.send(name)]\n end.to_h\n end",
"def attr\n @attr.map{|k,v| \"#{k}=\\\"#{h v}\\\"\"}.sort.join(' ')\n end",
"def attribute_keys\n return [] unless self[:attributes]\n self[:attributes].keys\n end",
"def attributes(*attrs)\n if attrs.size > 0\n attrs.each{|attr| attribute attr}\n end\n @attributes ||= []\n end",
"def serializable_attributes\n IDME_SERIALIZABLE_ATTRIBUTES + REQUIRED_ATTRIBUTES\n end",
"def attribute_names\n @attributes.keys.sort\n end"
] |
[
"0.7580632",
"0.72128683",
"0.7202275",
"0.7202074",
"0.714402",
"0.7090582",
"0.7079916",
"0.7048852",
"0.7030326",
"0.6994557",
"0.6994492",
"0.6980055",
"0.69781053",
"0.6971298",
"0.6969956",
"0.6955982",
"0.6954862",
"0.6909662",
"0.68979704",
"0.68924457",
"0.68919957",
"0.68558276",
"0.6854808",
"0.6849468",
"0.6837799",
"0.6822261",
"0.6818867",
"0.68138623",
"0.6782416",
"0.67605245",
"0.67474353",
"0.67390937",
"0.67351395",
"0.67339045",
"0.67313826",
"0.67313826",
"0.67313826",
"0.67313826",
"0.67236525",
"0.67236525",
"0.67236525",
"0.67236525",
"0.67236525",
"0.67236525",
"0.67236525",
"0.67236525",
"0.67236525",
"0.67236525",
"0.67236525",
"0.67213655",
"0.6715502",
"0.67111117",
"0.66904944",
"0.6669323",
"0.666863",
"0.6657523",
"0.6651835",
"0.6650268",
"0.66491765",
"0.6641644",
"0.66274047",
"0.66093415",
"0.6602569",
"0.6595257",
"0.6595257",
"0.6595257",
"0.6589991",
"0.65893304",
"0.658626",
"0.65792155",
"0.65768",
"0.6572972",
"0.657243",
"0.6571501",
"0.6571501",
"0.6568695",
"0.65578806",
"0.65466046",
"0.6533622",
"0.65316415",
"0.652228",
"0.6514194",
"0.65060633",
"0.649566",
"0.6495335",
"0.64929813",
"0.64899814",
"0.64789283",
"0.6465594",
"0.6457127",
"0.6452939",
"0.64346236",
"0.6429802",
"0.6429093",
"0.6428098",
"0.6426509",
"0.6418437",
"0.64130926",
"0.64080733",
"0.6402743"
] |
0.72819895
|
1
|
Convert to hash, encoding subrepos as path to their repofile Used for serialization to disk so that a .repo doesn't hold information about its repo's grandchildren
|
def to_hash
{ "path_to" => @path_to,
"url" => @url,
"subrepos" => @subrepos.each(&:path_to),
"isHead" => @is_head,
}
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def repo_to_hash(repo)\n { :path => repo.path }\n end",
"def repo_to_hash(repo)\n { :path => repo.path }\n end",
"def hash_from_git(tree)\n ({}).tap do |objs|\n tree.each do |b|\n objs[b.name] = (\n case b\n when Grit::Tree\n hash_from_git(b.contents)\n when Grit::Blob\n b.data\n end\n )\n end\n end\n end",
"def repo_path\n @path\n end",
"def repo_root; end",
"def repo_path\n DeliveryGolang::Helpers.repo_path(node)\n end",
"def git_checksum_hash(tree, prefix=nil)\n\n tree.contents.each do |obj|\n if obj.class == Grit::Blob\n item = [prefix, obj.name].join\n @currenthash[item] = Digest::MD5.hexdigest(obj.data)\n #puts \"#{item} : \" + @currenthash[item]\n else\n git_checksum_hash(obj, [prefix, obj.name, \"/\"].join)\n end\n end\n\n return @currenthash\n end",
"def repo_dir; end",
"def build_repo repo_path, file_structure\n file_structure.each do |entry|\n add_file entry\n end\n end",
"def primary_repo_transforms\n primary_repo_base_dir = File.expand_path(\n File.join(\n config.base_dir(:rtfile_dir),\n config.setting(:relative_path_to_primary_repo)\n )\n )\n\n {\n :base_dir => {\n :from => config.base_dir(:rtfile_dir),\n :to => primary_repo_base_dir + '/',\n },\n :language_code => {\n :from => config.setting(:language_code_3_chars),\n :to => config.setting(:primary_repo_lang_code),\n }\n }\n end",
"def repo_path\n @repo_path ||= Pathname.new(Dir.pwd).descend { |p| break p if (p + '.git').directory? }\n end",
"def repos_file\n File.join(folder, REPOS_FILE_NAME)\n end",
"def repos_path\n ::File.expand_path(@repos_path)\n end",
"def path\n \"repos/#{@user}/#{name}\"\n end",
"def repo_all_commits_structures(repo_dir, commits_file, structures_dir)\n sdir = Pathname.new(Dir.pwd) + Pathname.new(structures_dir)\n base_dir = Pathname.new(repo_dir).basename.to_s\n FileUtils.mkdir_p(sdir + \"dir\")\n FileUtils.mkdir_p(sdir + \"dep\")\n lang = detect_language(repo_dir) # Detect programming language \n i = MCommits.new(commits_file).all_commits.size # Reverse order\n file_kenc = KeyEncoder.new\n make_temp_dir do |tmpdir|\n # Copy repo to temp folder\n FileUtils.cp_r repo_dir, tmpdir\n temp_repo_dir = tmpdir + \"/\" + base_dir\n \n chdir_return(temp_repo_dir) do\n keep_going = true\n while keep_going do\n i -= 1\n # Generate Directory Structure Graph\n puts \"Generating Dir Structure Graph\"\n directory_graph(\".\", \"%s/%d.txt\" % [(sdir+\"dir\").relative_path_from(Pathname.new Dir.pwd).to_s, i], file_kenc)\n\n key_count = file_kenc.key_count\n\n # Generate dependency graph if language is supported\n unless lang.nil?\n case lang\n when :ruby\n puts \"Generating Dependency Graph\"\n RubyFilesMatcher.new('.').dependency_graph_to_file(\"%s/%d.txt\" % [(sdir+\"dep\").relative_path_from(Pathname.new Dir.pwd).to_s, i], file_kenc)\n else\n puts \"Unsupported Programming Language\"\n end\n raise \"Dependency Graph is not supposed to generate more keys!\" if key_count != file_kenc.key_count\n end\n\n puts \"Rewinding...\"\n stdin, stdout, stderr = Open3.popen3(\"git reset --hard HEAD~1\")\n keep_going = false if stderr.readlines.length > 0 # While not getting \"...unknown revision or path not in the working tree...\"\n end\n end\n \n end\n raise \"Number of Commits Don't Match\" if i != 0\n file_kenc.to_file(sdir + \"file_key.txt\")\nend",
"def repo_path\n @repo_path ||= \"/tmp/extension-repo-#{id}\"\n end",
"def repo_path\n @config.get_value('GIT_REPO_ROOT')\n end",
"def submodule_sha_at(submodule_name, root_sha)\n # Finding the SHA-1 that each submodule uses for a given commit is a\n # little hacky; we run a git command and parse the output.\n cmd = %(git ls-tree %s %s) % [root_sha, submodule_name]\n %x(#{cmd}).split(\" \")[2]\n end",
"def repo_path\n # root dir is system home folder, need to exist prior to app launch\n # /home\n root_dir = Pathname(Settings.application.root_dir)\n\n # base dir is aq_git user home folder, need to exist prior to app launch\n # /home/aq_git\n base_dir = root_dir + Settings.application.repo_user\n\n if self.kind == \"git\"\n repo_path = Settings.application.repo_git_path\n end\n\n # git_dir is where the repositories are gonna be stored, creating if needed\n # /home/aq_git/git or /home/aq_git/hg\n scm_dir = base_dir + repo_path\n scm_dir.mkdir if base_dir.exist? && !scm_dir.exist?\n\n # repo dir is the repository own path\n # /home/aq_git/git/username\n if self.owner\n repo_dir = scm_dir + self.owner.login\n elsif current_user\n repo_dir = scm_dir + current_user.login\n end\n repo_dir.mkdir if !repo_dir.exist?\n\n # the dot dir is the .git (or .hg) located in the repository\n # /home/aq_git/git/username/reposit.git\n if self.is_git?\n dot_dir = repo_dir + (self.name + \".#{self.kind}\")\n dot_dir.mkdir if !dot_dir.exist?\n end\n\n self.path = dot_dir.to_s\n end",
"def git_dir; end",
"def repo_files\n @vault.sys.auths.select { |_,v| v.type == 'approle' }\n .keys\n .inject([]) { |acc, elem| acc + role_files(elem) }\n end",
"def repos\n api.repos.map(&:to_hash)\n end",
"def get_checksums(commit)\n # Reset @currenthash\n @currenthash = Hash.new\n path = find_relative_git_cookbook_path\n #puts \"path is '#{path}' commit hash is #{commit}\"\n #puts \"commit.tree is #{commit.tree}\"\n unless path == '.'\n tree = commit.tree / path\n git_checksum_hash(tree)\n else\n git_checksum_hash(commit.tree)\n end\n end",
"def repository_root\n File.expand_path(@repo.path + \"/../\")\n end",
"def git_sha_for(path)\n website.git_repository.git_sha path\n end",
"def structure_repo_ids\n default_struct_map['contents'].map { |content| content['contents'].map { |content| content['repo_id'] } }.flatten\n end",
"def hash(option_json)\n\t\tif(File.exist?(GROWTH::GROWTH_REPOSITORY))then\n\t\t\tg = Git.open(GROWTH::GROWTH_REPOSITORY)\n\t\t\treturn {status: \"ok\", hash: g.log()[-1].sha}\n\t\telse\n\t\t\treturn {status: \"error\", message: \"GRWOTH git repository '#{GROWTH::GROWTH_REPOSITORY}' not found \"}\n\t\tend\n\tend",
"def get_path(commit)\n repos_path = File.expand_path('repos')\n File.join(repos_path, commit)\n end",
"def repo_path\n current_user = User.current\n # root dir is the system home folder, need to exist prior to app launch\n # e.g. /home\n root_dir = Pathname(Settings.repos.root_dir)\n\n # base dir is aq_git user home folder, need to exist prior to app launch\n # e.g. /home/aq_git\n\n base_dir = root_dir + Settings.repos.repo_user\n\n if self.kind == \"git\"\n repo_path = Settings.git.repo_path\n end\n\n # git dir is where the repositories are gonna be stored, creating if needed\n # e.g. /home/aq_git/git or /home/aq_git/hg\n scm_dir = base_dir + repo_path\n scm_dir.mkdir if base_dir.exist? && !scm_dir.exist?\n\n # repo dir is the repository own path\n # e.g. /home/aq_git/git/username\n if self.owner\n repo_dir = scm_dir + self.owner.login\n elsif current_user\n repo_dir = scm_dir + current_user.login\n end\n repo_dir.mkdir if !repo_dir.exist?\n\n # the dot dir is the .git (or .hg) located in the repository\n # e.g. /home/aq_git/git/username/some_repo.git\n if self.is_git?\n dot_dir = repo_dir + (self.name + \".#{self.kind}\")\n dot_dir.mkdir if !dot_dir.exist?\n end\n\n self.path = dot_dir.to_s\n end",
"def to_h\n {\n :sha => self.sha,\n :tree_sha => self.tree_sha,\n :parents => self.parents,\n :author_name => self.author_name,\n :author_email => self.author_email,\n :author_date => self.author_date,\n :committer_name => self.committer_name,\n :committer_email => self.committer_email,\n :committer_date => self.committer_date,\n :title => self.title\n }\n end",
"def save_repos(repos)\n json = MultiJson.encode(repos)\n File.open(repos_file, 'w') { |f| f.write(json) }\n end",
"def find_all(repo, options = {})\n refs = []\n already = {}\n Dir.chdir(repo.path) do\n files = Dir.glob(prefix + '/**/*')\n files.each do |ref|\n next if !File.file?(ref)\n id = File.read(ref).chomp\n name = ref.sub(\"#{prefix}/\", '')\n commit = Commit.create(repo, :id => id)\n if !already[name]\n refs << self.new(name, commit)\n already[name] = true\n end\n end\n\n if File.file?('packed-refs')\n File.readlines('packed-refs').each do |line|\n if m = /^(\\w{40}) (.*?)$/.match(line)\n next if !Regexp.new('^' + prefix).match(m[2])\n name = m[2].sub(\"#{prefix}/\", '')\n commit = Commit.create(repo, :id => m[1])\n if !already[name]\n refs << self.new(name, commit)\n already[name] = true\n end\n end\n end\n end\n end\n\n refs\n end",
"def git_object(hash)\n return `git cat-file -p #{hash}`\nend",
"def get_repo_paths\n\t\t\tpaths = {}\n\t\t\tpathspec = read_command_output( 'hg', 'paths' )\n\t\t\tpathspec.split.each_slice( 3 ) do |name, _, url|\n\t\t\t\tpaths[ name ] = url\n\t\t\tend\n\t\t\treturn paths\n\t\tend",
"def read_repository_info\n repository_url = File.open(@repository_conf).gets.chomp\n name = repository_url.split(\"/\").last.split(\".\").first\n return {\n :url => repository_url,\n :name => name,\n :container_prefix => container_prefix(name),\n :path => \"#{@work_dir}/#{name}\",\n }.freeze\n end",
"def applicable_owners_files_hash\n return @applicable_owners_files_hash if !@applicable_owners_files_hash.nil?\n\n # Make hash of (directory => [files in that directory in this commit]) pairs\n\n puts \"changed files: #{changed_files.inspect}\"\n\n affected_dirs_hash = changed_files.collect_to_reverse_hash do |file|\n File.dirname(file)\n end\n\n puts \"affected_dirs_hash: #{affected_dirs_hash.inspect}\"\n\n affected_dirs = affected_dirs_hash.keys\n\n # Make hash of owners file => [file1, file2, file3]\n res = affected_dirs.inject(Hash.new) do |hash, dir|\n owner = find_owners_file(dir)\n\n # If there's no OWNERS file for this dir, just skip it\n if owner.nil?\n return hash\n end\n\n data = {\n :owner_data => owner,\n :files => affected_dirs_hash[dir]\n }\n\n key = owner[:path]\n\n if (hash.include?(key))\n combined_data = hash[key]\n combined_data[:files] = combined_data[:files] + data[:files]\n\n hash[key] = combined_data\n else\n hash[key] = data\n end\n hash\n end \n\n @applicable_owners_files_hash = res\n end",
"def repo_to_uri(repo)\n\tif @bigboy.key?(repo.to_sym)\n\t\tif @bigboy[repo.to_sym].is_a?(Array)\n\t\t\tputs \"\\nThe URIs for \" + \"#{ARGV[0]}\".red + \" are: \"\n\t\t\t@bigboy[repo.to_sym].each { |n| puts n.green }\n\t\telse\n\t\t\tputs \"\\nThe URI for \" + \"#{ARGV[0]} \".red + \"is \" + \" #{@bigboy[repo.to_sym]}\".green\n\t\tend\n\telse\n\t\tputs \"\\nSorry, I can't find that repo.\".magenta\n\tend\nend",
"def collected_repo_keys\n self.repos.collect { |repo| repo.repo_key }\n end",
"def get_entry_hash(path, commit = @commit)\n if path.start_with?(File::SEPARATOR) # transform from absolute to relative\n path = path[1..-1]\n end\n if path == '' # root Tree\n entry_hash = { name: path, oid: commit.tree_id, type: :tree, filemode: 0 } # mimic Tree#path output\n else # Tree or Blob\n begin\n entry_hash = commit.tree.path(path)\n rescue Rugged::TreeError # path not valid\n entry_hash = nil\n end\n end\n entry_hash\n end",
"def create_in_repo(repo, base_dir)\n self.repo_path = File.join(base_dir, self.ident)\n\n super repo, repo_path\n\n # write contents to FILE_BIN -- note this file never changes!\n repo.chdir do\n fname = File.join(repo_path, FILE_BIN)\n File.binwrite(fname, self.contents)\n repo.add fname\n end\n dirty!\n\n self\n end",
"def repo_path\n @repo.dirstate.copy_map[@path] || @path\n end",
"def get_user_repo_hash(user, data)\n return {\n 'user_id' => user['_id'],\n 'open_issues' => data['open_issues'],\n 'watchers' => data['watchers'],\n 'pushed_at' => data['pushed_at'],\n 'homepage' => data['homepage'],\n 'git_url' => data['git_url'],\n 'updated_at' => data['updated_at'],\n 'fork' => data['fork'],\n 'forks' => data['forks'],\n 'language' => data['language'],\n 'private' => data['private'],\n 'size' => data['size'],\n 'clone_url' => data['clone_url'],\n 'created_at' => data['created_at'],\n 'name' => data['name'], # a unique name for a user repo\n 'html_url' => data['html_url'],\n 'description' => data['description']\n }\n end",
"def uri_hash # :nodoc:\n normalized =\n if @repository =~ %r%^\\w+://(\\w+@)?% then\n uri = URI(@repository).normalize.to_s.sub %r%/$%,''\n uri.sub(/\\A(\\w+)/) { $1.downcase }\n else\n @repository\n end\n\n Digest::SHA1.hexdigest normalized\n end",
"def to_s\n \"#{@timestamp}/#{@repo_name}/#{@sha}\"\n end",
"def repository_folder(repo_name)\n File.join(folder, \"#{repo_name}.git\")\n end",
"def raw_gitdir\n\t\t\twith_dir do\n\t\t\t\treturn Pathname.new(%x/git rev-parse --git-dir/.chomp)\n\t\t\tend\n\t\tend",
"def repo_all_commits_authors(repo_dir, commits_file, structures_dir)\n puts \"Generating Authors Hash\"\n base_dir = Pathname.new(repo_dir).basename.to_s\n mc = MCommits.new(commits_file)\n auth_kenc = KeyEncoder.new\n mc.all_commits.each do |commit|\n begin\n auth_kenc.encode(parse_name(commit['author']))\n rescue\n puts commit['author']\n puts parse_name(commit['author'])\n end\n end\n auth_kenc.to_file(Pathname.new(structures_dir) + \"auth_key.txt\")\nend",
"def write_to(git)\n self.mode ||= git.default_tree_mode\n self.sha ||= begin\n lines = []\n each_pair(false) do |key, entry|\n mode, sha = case entry\n when Tree then entry.write_to(git)\n when Array then entry\n else [entry.mode, entry.id]\n end\n \n # modes should not begin with zeros (although it is not fatal\n # if they do), otherwise fsck will print warnings like this:\n #\n # warning in tree 980127...: contains zero-padded file modes\n lines << zero_strip(\"#{mode} #{key}\\0#{[sha].pack(\"H*\")}\")\n end\n\n git.set(:tree, lines.join)\n end\n\n [mode, sha]\n end",
"def json_key(payload)\n File.join(\n 'repositories',\n payload.fetch(:data, :account, :name, 'default'),\n 'repository.json'\n )\n end",
"def raw_data_in_committer(committer, dir, filename)\n data = nil\n\n [*dir.split(::File::SEPARATOR), filename].each do |key|\n data = data ? data[key] : committer.tree[key]\n break unless data\n end\n\n data\n end",
"def format_repo repo\n {\n 'baseurl' => repo.full_path,\n # yum repos have descr field but no name, if descr is empty use the repo name\n 'descr' => repo.description.blank? ? repo.name : repo.description,\n 'enabled' => repo.enabled ? '1' : '0',\n 'gpgcheck' => !!repo.gpg_key ? '1' : '0'\n }\n end",
"def get_tree_sha\n sha = nil\n trees = get_json(\"#{@git_data_trees}/#{@branch}\")\n trees['tree'].find{|t| t['path'] == 'src'}['sha']\n end",
"def build_hash_tree(filenames)\n files_tree = filenames.inject({}) { |h, i| t = h; i.split(\"/\").each { |n| t[n] ||= {}; t = t[n] }; h }\nend",
"def uri_to_repo(uri)\n\tparsed = URI.parse(uri)\n\tnew_uri = parsed.to_s\n\tnew_uri.gsub!(\"https\", \"http\") if parsed.scheme == \"https\"\n\tnew_uri.chop! if new_uri[-1] == \"/\"\n\tif @bigboy.value?(new_uri)\n\t\tputs \"\\nThe repo for \" + \"#{ARGV[0]} \".green + \"is \" + \"#{@bigboy.key(new_uri)}\".red\n\telsif @bigboy.values.flatten.include?(new_uri)\n\t\tarrays = @bigboy.values.select { |n| n.is_a?(Array) }\n\t\tmatches = arrays.select { |n| n.include?(new_uri) }\n\t\tputs \"\\nThe repo for \" + \"#{ARGV[0]} \".green + \"is \" + \"#{@bigboy.key(matches.flatten)}\".red\n\telse \n\t\tputs \"\\nSorry, I can't find that URI.\".magenta\n\tend\nend",
"def loadRepository\n\n @DIR_NAME = @REPOSITORYPATHORSELECT\n\n #puts \"#{@DIR_NAME} Index is... #{@DIR_NAME.index(\"/\")} : #{@@FS}\"\n\n \t\tif (@DIR_NAME.index(\"/\") != nil && @@FS == \"\\\\\" )\n \t\t\t@DIR_NAME = Parser.replaceAll(@DIR_NAME,\"/\",@@FS)\n \t\telsif( @DIR_NAME.index(\"\\\\\") != nil && @@FS == \"/\")\n \t\t\t@DIR_NAME = Parser.replaceAll(@DIR_NAME,\"\\\\\",@@FS)\n end\n\n #puts \"1 dirname... #{@DIR_NAME}\"\n\n @DIR_NAME = @DIR_NAME[0..@DIR_NAME.rindex(@@FS)]\n #puts \"2 dirname... #{@DIR_NAME}\"\n \t\t@FILE_NAME = @REPOSITORYPATHORSELECT\n #puts \"1 filename... #{@FILE_NAME}\"\n \t\tif( @FILE_NAME.index(\"/\") != nil && @@FS == \"\\\\\")\n \t\t\t@FILE_NAME = Parser.replaceAll(@FILE_NAME,\"/\",@@FS)\n \t\telsif( @FILE_NAME.index(\"\\\\\") != nil && @@FS == \"/\")\n \t\t\t@FILE_NAME = Parser.replaceAll(@FILE_NAME,\"\\\\\",@@FS)\n end\n #puts \"2 filename... #{@FILE_NAME}\"\n @FILE_NAME = @FILE_NAME[@FILE_NAME.rindex(@@FS)+1,@FILE_NAME.size]\n #puts \"3 filename... #{@FILE_NAME}\"\n\n #puts \"loadRepository : #{@DIR_NAME}\"\n if !File.exist?(@DIR_NAME)\n FileUtils.mkdir_p(@DIR_NAME)\n end\n if File.exist?(@DIR_NAME+@FILE_NAME)\n loadeOb = File.open(@DIR_NAME+@FILE_NAME).read\n @REPOSITORY = YAML::load(loadeOb)\n else\n @REPOSITORY = Hash.new\n end\n return @REPOSITORY\n end",
"def get_tree_sha(dir)\n get_trees['tree'].find { |t| t['path'] == dir }['sha']\n end",
"def committed_files sha\n array_output_of \"git diff-tree --no-commit-id --name-only -r #{sha}\"\nend",
"def link_commits(repo_path, username, repo_name)\n\n # create a partial repo URL for GitHub repository\n partial_URL = \"https://github.com/#{username}/#{repo_name}/commit/\"\n \n # access the repository at the given repo_path\n repo = Grit::Repo.new(repo_path)\n \n all_commits = get_all_commits(repo)\n \n #all_commits.each{ |commit|\n # puts \"[#{commit.sha}](#{partial_URL + commit.sha})\\n\\n\"\n #}\n\n return all_commits.map do |commit|\n \"[#{commit.sha}](#{partial_URL + commit.sha})\\n\\n\"\n end\nend",
"def recurse_and_hash_tree(node)\n\n ## exit program if given a bunk file/dir\n print_and_exit \"given a bunk file/node\" unless File.exist? node\n\n ## if we have a file then return it's hash\n return Digest::MD5.hexdigest( node + File.read(node) ) if File.file? node\n\n ## we should have a directory now. exit otherwise...\n print_and_exit \"is there a strange device in this dir?\" unless File.directory? node\n\n ## recurse through each element in the directory and remember their hashes\n children_hash = \"\"\n Dir.glob(File.join node, '*' ) { |element| children_hash << recurse_and_hash_tree(element) }\n \n ## return the mashed up hash\n return Digest::MD5.hexdigest( node + children_hash ) \n\n end",
"def blob_path(relative = true)\n blob_path = File.join(self.class.name, hash.to_s)\n if relative\n blob_path\n else\n File.join(repository_path, blob_path)\n end\n end",
"def directory_hash(path, name=nil)\n data = {:folder => (name || path.split(\"/\").last)}\n data[:children] = children = []\n Dir.foreach(path) do |entry|\n next if (entry == '..' || entry == '.' || entry == 'yamproject.json' || entry == '.DS_Store')\n full_path = File.join(path, entry)\n if File.directory?(full_path)\n children << directory_hash(full_path, entry)\n else\n children << entry\n end\n end\n return data\nend",
"def gitrepo(repo, name, ref = 'master')\n mod name.split('/').join('-'),\n :git => \"https://#{repo}/#{name}.git\",\n :ref => ref\nend",
"def altered_files; `git show --name-only #{node} 2> /dev/null`.split(\"\\n\"); end",
"def repo; end",
"def repo; end",
"def repo; end",
"def repo; end",
"def repo\n @repo\n end",
"def abspath\n \"#{repo_base_path}/#{self.git_repo_path}\"\n end",
"def repos\n pry(Git::Multi.repositories)\nend",
"def file_ids_hash\n if @file_ids_hash.blank?\n # load the file sha's from cache if possible\n cache_file = File.join(self.path,'.loopoff')\n if File.exists?(cache_file)\n @file_ids_hash = YAML.load(File.read(cache_file))\n else\n # build it\n @file_ids_hash = {}\n self.loopoff_file_names.each do |f|\n @file_ids_hash[File.basename(f)] = Grit::GitRuby::Internal::LooseStorage.calculate_sha(File.read(f),'blob')\n end\n # write the cache\n File.open(cache_file,'w') do |f|\n f.puts YAML.dump(@file_ids_hash) \n end\n end \n end\n @file_ids_hash\n end",
"def save_to_git\n FileUtils.makedirs File.dirname(blob_path(false)) unless File.exists? File.dirname(blob_path(false))\n File.open(blob_path(false), 'w') do |file|\n file.write to_yaml_git\n end\n if (repository.tree/blob_path).nil?\n add_blob\n end\n end",
"def data_path(filename)\n File.join(File.dirname(__FILE__), 'repo', filename)\n end",
"def uri_hash # :nodoc:\n require_relative '../openssl'\n\n normalized =\n if @repository =~ %r{^\\w+://(\\w+@)?}\n uri = URI(@repository).normalize.to_s.sub %r{/$},''\n uri.sub(/\\A(\\w+)/) { $1.downcase }\n else\n @repository\n end\n\n OpenSSL::Digest::SHA1.hexdigest normalized\n end",
"def create_stable_hash(folder_commits)\n stable_hash = {}\n folder_commits.first.each_key {|key| stable_hash[key] = [0] }\n return stable_hash\n end",
"def save_commit_info(sha)\n unless File.directory?(File.dirname(commit_info_file))\n FileUtils.mkdir_p(File.dirname(commit_info_file))\n end\n File.write(commit_info_file, sha)\n end",
"def dir\n # config.repos_dir + @name\n end",
"def tree_root\n repo.tree\n end",
"def get_sha_and_contents\n repo_req = @api.get do |req|\n req.headers['User-Agent'] = \"#{@user_agent}\"\n req.headers['Authorization'] = \"token #{@current_user.github_token}\"\n end\n\n repo_contents = JSON.parse(repo_req.body)['content']\n repo_sha = JSON.parse(repo_req.body)['sha']\n return { sha: repo_sha, content: repo_contents } \n end",
"def update_commitlist(h)\n h.map do |entry|\n sha = entry[\"commit\"].to_s.strip\n n = entry[\"note\"]\n # First, try to look it up in our existing repo\n if commit_exists?(sha) || sha.empty?\n entry # do nothing, put it back in the hash\n else\n # Ok, we know it doesn't exist. Now look it up in gitlog.json\n if @gitlog_json.key? sha\n m = @gitlog_json[sha][\"message\"]\n svn_id = m.lines.select {|l| l.match? /git-svn-id/ }.join.strip\n grep_cmd = <<~EOS.strip\n git -C ./tmp/src rev-list --all --grep=\"#{svn_id}\" --\n EOS\n stdout, stderr, status = Open3.capture3(grep_cmd)\n if stderr.empty?\n {\n \"commit\" => stdout.strip,\n \"note\" => <<~EOS.strip\n #{entry[\"note\"].to_s.lines.join(\"\\n\")}\n\n Formerly #{sha} before HTTPD rewrote Git history.\n EOS\n }\n else\n warn \"ERROR getting commit #{sha}. #{stderr}\"\n entry\n end\n else\n warn \"ERROR commit #{sha} does not exist in gitlog.json\"\n entry\n end\n end\n end\nend",
"def user_repos1\n addons = Addon.joins(:user).where(\"lower(users.login) = ?\", params[:login].downcase)\n render json: to_v1_repo_hashes(addons)\n end",
"def repo_files\n @vault.sys.auths.select { |_,v| v.type == 'ldap' }\n .keys\n .inject([]) { |acc, elem| acc + group_files(elem) }\n end",
"def repository_info(repository_owner, repository_name, reload = false)\n if @repository_info.nil? || reload\n @repository_info = {}\n\n @repository_info.default_proc = proc {|hash, repository|\n hash[repository] = RepositoryInfo.new(false, nil, {})\n\n matches = (config['repositories'] || {}).select do |pattern, value|\n repository =~ /^#{ pattern.gsub(/^([^\\/]+\\/)??\\*+/, '\\1[^/]+').gsub(/\\*+/, '[^/]*') }$/\n end\n exact_match = matches.delete(repository) || {}\n\n hash[repository].members.each do |key|\n matches.sort {|a, b| a.first <=> b.first }.map {|v| v.last}.each do |match|\n hash[repository][key] = match[key.to_s] if match.has_key?(key.to_s) && !match[key.to_s].nil?\n end\n hash[repository][key] = exact_match[key.to_s] if exact_match.has_key?(key.to_s) && !exact_match[key.to_s].nil?\n end\n hash[repository].freeze\n\n hash[repository]\n }\n end\n\n @repository_info[\"#{repository_owner}/#{repository_name}\"]\n end",
"def repo\n if @repo == NRSER::NO_ARG\n @repo = QB::Repo.from_path root_path\n end\n \n @repo\n end",
"def build_repo(repo_path, file_structure)\n file_structure.each do |entry|\n path = repo_path.join(entry)\n dir, filename = path.split unless entry.end_with?(\"/\")\n FileUtils.mkdir_p(dir || entry)\n\n next unless filename\n\n build_file(dir, filename)\n end\n end",
"def get_tree_sha\n sha = nil\n trees = open('https://api.github.com/repos/twitter/bootstrap/git/trees/master').read\n trees = JSON.parse trees\n trees['tree'].find{|t| t['path'] == 'less'}['sha']\n end",
"def team_repositories\n team_profiles.map(&:repositories).flatten\n end",
"def local\n return Global.git_repository_directory + @address_digest\n end",
"def git_path\n File.join(\n user.storage_path,\n 'repositories',\n 'scratchpad')\n end",
"def uri\n \"file://\" + self.repos_path\n end",
"def getChangesOfCommit(commit_id = false)\n my_commit = ((commit_id == false and @repo.commits.size > 0) ? @repo.commits.first : @repo.commit(commit_id))\n if my_commit == nil\n return false\n end\n \n # get list of changed files and parse it\n @filelist = Hash.new\n options = {:r => true, :name_status => true, :no_commit_id => true}\n if @repo.commit(my_commit.sha).parents[0] == nil # if my_commit is the first commit\n options[:root] = true\n end\n changed_files_list = @git.diff_tree(options, my_commit.id).strip\n if changed_files_list.class == String and changed_files_list.length > 0\n changed_files_list.split(\"\\n\").each do |f|\n commit = my_commit\n operation = f[0,1] # D/M/A\n filepath = f[2..-1] # path+filename\n path = \"/\" + filepath.match(/^.+\\//).to_s # just path\n status = \"created\"\n if operation =~ /^D$/i # deleted\n # the file was deleted, so get the blob from the parent-commit\n commit = @repo.commit(my_commit.parents[0].sha)\n status = \"deleted\"\n elsif operation =~ /^M$/i # modified\n status = \"updated\"\n end\n blob = commit.tree/(filepath)\n\n #name = filepath.gsub(path[1..-1], '') #blob.name\n path = path.gsub(/\\/private\\/[0-9]+\\//,'')\n \n \n \n @filelist[\"/\" + filepath] = {\"uploaded\" => '1', \"status\" => status, \"blob_hash\" => blob.id, \"name\" => blob.name, \"path\" => \"/#{path}\", \"size\" => blob.size, \"filetype\" => blob.mime_type, \"filedate\" => @repo.commit(commit.sha).date.strftime('%T %F').to_s}\n \n \n end\n end\n\n if @filelist.size > 0\n return @filelist\n else\n return false\n end\n end",
"def getFile(tree, name, path = '')\n blob = nil\n\n tree.each_blob do |file|\n blob = file if file[:name] == name[/[^\\/]*/]\n blob[:name] = path + blob[:name]\n end\n\n if blob.nil?\n tree.each_tree do |subtree|\n if subtree[:name] == name[/[^\\/]*/]\n path += name.slice! name[/[^\\/]*/]\n name[0] = ''\n return getFile($repo.lookup(subtree[:oid]), name, path + '/')\n end\n end\n end\n\n return blob\nend",
"def to_hash\n {\n 'git' => @git,\n 'ref' => @ref\n }\n end",
"def hash\n [_hash, name, owner].hash\n end",
"def hash\n return (path + file_id.to_s).hash\n end",
"def data\n @repo_data\n end",
"def all\n return @raw_repos unless @raw_repos.empty?\n return [Template.root.basename.to_s] if Template.project?\n Template.root.join(Meta.new({}).repos_dir).children.map do |path|\n path.basename.to_s\n end\n\n rescue Errno::ENOENT\n then raise(\n Error::RepoNotFound\n )\n end",
"def tree(root = '')\n build_hash(files(root), root)\n end",
"def hash\n folder.hash ^ name.hash # eXclusive OR operator\n end",
"def to_hash\n result = super\n result[:source_type] = :git\n result[:location] = location\n result[:commitish_type] = commitish_type\n result[:commitish] = commitish\n result\n end"
] |
[
"0.7141848",
"0.7141848",
"0.6206251",
"0.6089584",
"0.6037521",
"0.59238327",
"0.5913882",
"0.59111756",
"0.584282",
"0.58198816",
"0.5798512",
"0.5783281",
"0.57764965",
"0.5745922",
"0.56756926",
"0.56717056",
"0.5670672",
"0.5669056",
"0.5663526",
"0.5659797",
"0.5659541",
"0.5657498",
"0.5653374",
"0.564783",
"0.56447476",
"0.56374025",
"0.56165856",
"0.5610798",
"0.56086063",
"0.56053793",
"0.5588327",
"0.5578596",
"0.5577842",
"0.5574951",
"0.55663484",
"0.5555061",
"0.5548131",
"0.5541755",
"0.55376095",
"0.551492",
"0.551018",
"0.5497999",
"0.5473766",
"0.5465065",
"0.5462119",
"0.54576445",
"0.5442058",
"0.54344535",
"0.5429498",
"0.5421188",
"0.5419519",
"0.5415274",
"0.5409945",
"0.5398608",
"0.5388151",
"0.537984",
"0.53773904",
"0.5373613",
"0.536926",
"0.53661954",
"0.53622496",
"0.53617793",
"0.5346417",
"0.53430134",
"0.53430134",
"0.53430134",
"0.53430134",
"0.53368354",
"0.53315914",
"0.53303677",
"0.5329101",
"0.5328625",
"0.53275484",
"0.53172916",
"0.5298503",
"0.5295862",
"0.52942604",
"0.5294174",
"0.52930254",
"0.52894044",
"0.5285305",
"0.52812284",
"0.5274836",
"0.5271791",
"0.52678746",
"0.5267146",
"0.52631694",
"0.52483195",
"0.5246909",
"0.5244708",
"0.5244175",
"0.5243572",
"0.5232787",
"0.52076817",
"0.5207535",
"0.5206696",
"0.520383",
"0.51883465",
"0.5182722",
"0.5178765"
] |
0.64014906
|
2
|
=== Group Querying ===
|
def is_in_role_group? name
group_members = i_am_i_can.role_group_model.find_by!(name: name)._roles.names
(get_roles.names & group_members).present?
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def group\n return if record.respond_to?(:where)\n record.group\n end",
"def get_groups\n sparql = SPARQL.parse(\"SELECT DISTINCT ?uri ?label\n WHERE {\n ?uri <http://www.bbc.co.uk/ontologies/sport/hasMatch> ?match_uri .\n ?uri <#{RDF::RDFS.label}> ?label .\n }\n ORDER BY ASC(?label)\n \")\n results = QUERYABLE.query(sparql)\n end",
"def group\n klass.collection.group(\n :key => field_list,\n :cond => selector,\n :initial => { :group => [] },\n :reduce => Javascript.group\n ).collect do |docs|\n docs[\"group\"] = docs[\"group\"].collect do |attrs|\n Mongoid::Factory.from_db(klass, attrs)\n end\n docs\n end\n end",
"def group_query_builder group\n query_arr = []\n g_question_names = questions_for_group(group).map{|question|sanitize(question.attribute_name)}.uniq\n\n entities_for_group(group).each do |entity|\n cols = []\n e_question_names = questions_for_entity(entity).map{|question|sanitize(question.attribute_name)}\n\n #\n g_question_names.each do |q_name|\n if e_question_names.include? q_name\n cols.push \"CAST(\\\"#{q_name}\\\" AS FLOAT) AS \\\"#{q_name}\\\"\"\n else\n cols.push \"CAST(888 AS FLOAT) AS #{q_name}\"\n end\n end\n\n #\n cols.push \"#{entity.reference_year} AS year\" unless entity.reference_year.nil?\n cols.push sanitize(entity.entity_type_fk)\n\n # convert to sql\n query_arr.push \"SELECT \\n\\t#{cols.join(\",\\n\\t\")} \\nFROM #{entity.entity_type}\"\n end\n\n return query_arr.join(\"\\nUNION ALL\\n\")\n end",
"def group\n raise \"View#reduce must have been set before grouping is permitted\" unless query[:reduce]\n update_query(:group => true)\n end",
"def group(*) end",
"def find_group_results(group, offset, limit)\n #place solution here\n @coll.find(:group => group).skip(offset).limit(limit).sort({:secs => 1}).projection(group: false, _id: false)\n end",
"def key_groups(input_query, key)\n input_query.group(key)\n .count\n .sort_by { |_k, v| v }\n .reverse\n end",
"def group\n raise \"View#reduce must have been set before grouping is permitted\" unless query[:reduce]\n update_query(:group => true)\n end",
"def group_by\n\n end",
"def grouping_query(field, phrase, op = 'AND')\n raise 'op must be AND or OR' unless ['AND', 'OR'].include? op\n\n \"_query_:\\\"{!lucene q.op=#{op}}#{field}:(#{phrase})\\\"\"\n end",
"def group_by\n end",
"def all\n # Grab first five matching users\n @users = User.where(\"LOWER(name) LIKE ?\", \"%#{@query}%\").limit(5)\n\n # Grab first five matching groups\n @groups = Group.where.not(privacy: :secret_group)\n .where(\"LOWER(name) LIKE ?\", \"%#{@query}%\").limit(5)\n\n # Sort the users and groups together\n @users_and_groups = (@users + @groups).sort_by { |item| SearchScore.name(item.name, @query) }\n end",
"def fetch\n sort = 'created_at DESC'\n\n case params[:sort_by]\n when 'recent'\n sort = 'created_at DESC'\n else\n\n end\n\n q = '%' + params[:query].downcase + '%'\n\n groups = Group.where(\"LOWER(name) LIKE ? OR LOWER(identifier) LIKE ? OR lower(tags) LIKE ?\", q, q, q)\n .order(sort)\n\n paginate json: groups\n end",
"def test_it_can_group_by\n groups = FinderClass.group_by(@items.all, :merchant_id)\n assert_instance_of Hash, groups\n assert_equal 12334141, groups.keys.first\n assert_instance_of Item, groups.values.first.first\n end",
"def groups; end",
"def groups; end",
"def groups; end",
"def groups\n @parent.groups(@filter)\n end",
"def group_by(*args)\n args.each do |arg|\n if arg.is_a?(String)\n self.groups = self.groups.concat(SkyDB::Query::Selection.parse_groups(arg))\n elsif arg.is_a?(Symbol)\n self.groups << SelectionGroup.new(:expression => arg.to_s)\n else\n raise \"Invalid group by argument: #{arg} (#{arg.class})\"\n end\n end\n \n return self\n end",
"def search(options)\n rsp = @flickr.send_request('flickr.groups.search', options)\n \n returning Flickr::FlickrResponse.new(:page => rsp.groups[:page].to_i,\n :pages => rsp.groups[:pages].to_i,\n :per_page => rsp.groups[:perpage].to_i,\n :total => rsp.groups[:total].to_i,\n :objects => [],\n :api => self,\n :method => :search,\n :options => options) do |groups|\n rsp.groups.group.each do |group|\n attributes = create_attributes(group)\n\n groups << Group.new(@flickr, attributes)\n end if rsp.groups.group\n end\n end",
"def group; end",
"def search_query_for(group)\n { q: \"uid:(#{group.map { |e| \"\\\"#{e.uid}\\\"\" }.join(' OR ')})\",\n def_type: 'lucene',\n facet: false,\n fl: @options[:fl] ? @options[:fl] :\n (@options[:fulltext] ?\n RLetters::Solr::Connection::DEFAULT_FIELDS_FULLTEXT :\n RLetters::Solr::Connection::DEFAULT_FIELDS),\n tv: @options[:term_vectors] || false,\n rows: group.size }\n end",
"def employees_select_by(group)\n employees\n end",
"def index\n @groups = Group.all\n @users = User.all\n @tags = ActsAsTaggableOn::Tag.most_used\n if params[:search]\n @groups = Group.search(params[:search]).order(name: :asc)\n @pgheader = 'Search Results'\n elsif params[:tag]\n @groups = Group.tagged_with(params[:tag])\n else\n# @groups = Group.all.order(name: :asc)\n \n# by adding limit we only produce 5 results, and order random will choose the results at random.\n @groups = Group.limit(3).order(\"RANDOM()\")\n @pgheader = 'How about joining...'\n end\n end",
"def exercise2\n @content = ActiveRecord::Base.connection.execute(\"\n SELECT\n gr.name as group_name,\n u.name as user_name,\n sum(m.mapviews) as groups_count\n FROM (((users as u\n INNER JOIN groups_users as gu ON u.id=gu.user_id)\n INNER JOIN groups as gr ON gr.id = gu.group_id)\n INNER JOIN maps as m ON m.user_id = u.id)\n GROUP BY (gr.name, u.name)\n ORDER BY gr.name, groups_count DESC;\");\n\n @results2 = []\n\n index = 0\n @content.each do |r|\n @results2[index] = Result2.new r\n index = index + 1;\n end\n\n return @results2\n end",
"def groups\n quads\n end",
"def groups(*args)\n end",
"def search_groups(search_text,options={})\r\n options = {:direct_query => false }.merge options\r\n search_text = prep_text_for_match_query(search_text,true,!options.delete(:direct_query))\r\n\r\n if (search_text.index('\"'))\r\n mysql_match_term = 'match (gti.name_text, gti.description_text, gti.tags_text) against (? IN BOOLEAN MODE)'\r\n else\r\n mysql_match_term = 'match (gti.name_text, gti.description_text, gti.tags_text) against (?)'\r\n end\r\n ModelUtil.add_joins!(options,'join group_text_indices gti on gti.group_id=groups.id')\r\n ModelUtil.add_conditions!(options,[\"#{mysql_match_term}\",search_text])\r\n \r\n # MM2: This allows the rank to come through with the results. The search should be sanitized and therefore ok to use like this\r\n options = options_with_rank(options, mysql_match_term, search_text, [\"groups.*\"])\r\n \r\n Group.find(:all, options)\r\n end",
"def get_group_by_id(id)\n $r.hgetall(\"group:#{id}\")\n end",
"def groups(opts={'start' => nil, 'limit' => nil})\n update if running?\n if succeeded?\n return Cursor.new({'collection' => link('groups'),\n 'start' => opts['start'],\n 'limit' => opts['limit']}.update(@opts)) { |g| g['group_id'] }\n elsif running?\n raise VeritableError.new(\"Grouping on column #{column_id} is still running and not yet ready to return groups.\")\n elsif failed?\n raise VeritableError.new(\"Grouping on column #{column_id} has failed and cannot return groups.\")\n else\n raise VeritableError.new(\"Grouping -- Shouldn't be here -- please let us know at support@priorknowledge.com.\")\n end\n end",
"def index\n @groups = Group.order(created_at: :desc)\n drillz = UserDrill.where(completed: true).where(user_id: @user.id)\n @drills = Drill.where(:id => drillz).all\n # @user_groups = Group.where???\n # render json: @groups\n end",
"def groups(*groups); end",
"def groups(*groups); end",
"def stacked_grouping_query?\n @summary.query_group.group_count == 2\n end",
"def find_group_and_members(name)\n results = find_group(name)\n filtered_results(results)\n end",
"def group_all\n grp = {}\n grp.merge!(groupby_fields)\n grp.merge!(groupby_values)\n { '$group' => grp }\n end",
"def group_by_field\n self.find_field(self.group_by_field_name)\n end",
"def index\n @study_periods = @year.study_periods\n @search = @study_periods.search(params[:q])\n @groups=@search.result(:distinct => true)\n end",
"def group\n field = options[:fields].first\n documents.group_by { |doc| doc.send(field) }\n end",
"def index\n @criteria = Criterium.order(id: 'asc')\n @groups = Group.all\n end",
"def i_groups; end",
"def group(store)\n groups.find_by(store: store)\n end",
"def group_by?; @group_by; end",
"def index\n @study_process_graphics = @year.study_process_graphics\n @search = @study_process_graphics.search(params[:q])\n @groups=@search.result(:distinct => true)\n end",
"def group_items\n @group_items ||= Product.includes(:pictures)\n .where(group: group.presence || '_ZZZZ_', active: true, hidden: false)\n .order(:option_sort, :option_title)\n end",
"def test_get_all_ad_groups\n test_add_ad_groups() unless (@ad_group_1 and @ad_group_2 and @ad_group_3)\n found_1 = false\n found_2 = false\n found_3 = false\n selector = @ad_group_srv.module::AdGroupSelector.new\n response = @ad_group_srv.get(selector)\n assert_not_nil(response.rval.entries, 'Empty result set returned')\n response.rval.entries.each do |ad_group|\n found_1 = true if ad_group.id == @ad_group_1.id\n found_2 = true if ad_group.id == @ad_group_2.id\n found_3 = true if ad_group.id == @ad_group_3.id\n end\n assert(found_1, 'Ad group #1 not found in returned results')\n assert(found_2, 'Ad group #2 not found in returned results')\n assert(found_3, 'Ad group #3 not found in returned results')\n end",
"def group_data_from_results(res, groupname, key)\n groups = res['groups']\n groups.each do |group|\n return group[key] if group['group_name'] == groupname\n end\n nil\n end",
"def getEntitySearchGroupBynearest( group_id, country, per_page, page, language, latitude, longitude, where, domain, path, unitOfDistance, restrict_category_ids)\n params = Hash.new\n params['group_id'] = group_id\n params['country'] = country\n params['per_page'] = per_page\n params['page'] = page\n params['language'] = language\n params['latitude'] = latitude\n params['longitude'] = longitude\n params['where'] = where\n params['domain'] = domain\n params['path'] = path\n params['unitOfDistance'] = unitOfDistance\n params['restrict_category_ids'] = restrict_category_ids\n return doCurl(\"get\",\"/entity/search/group/bynearest\",params)\n end",
"def group(entry)\n push(\"$group\" => evolve(entry.__expand_complex__))\n end",
"def recommend_request_sql_query(group_request)\n sql_select_requests = LesseeRequest.where(\"group_id != #{group_request.group_id} and active != false\")\n .where(\"city_id = #{group_request.city_id} and state_id = #{group_request.state_id} and country_id = #{group_request.country_id}\")\n .where(\"smoke = #{group_request.smoke}\")\n .where(\"max_rent <= #{group_request.max_rent + 300} and max_rent >= #{group_request.max_rent - 300}\")\n # |a - b| <= 300\n # a <= 300 + b && a >= -300 + b\n\n current_group_num = group_request.group.users.count\n select_requests = []\n sql_select_requests.each do |request|\n if request.group.users.count + current_group_num <= group_request.max_n_housemates &&\n current_group_num + request.group.users.count <= request.max_n_housemates &&\n group_request.latest_movein_date >= request.earliest_movein_date &&\n group_request.earliest_movein_date <= request.latest_movein_date &&\n group_request.min_duration <= request.max_duration &&\n group_request.max_duration >= request.min_duration\n select_requests.push(request)\n end\n end\n select_requests\n end",
"def each_content_entry_group(content_type, &block)\n field = content_type.group_by_field\n groups = content_type.list_of_groups || []\n\n groups.each do |group|\n block.call({\n name: group[:name],\n url: content_entries_path(current_site, content_type.slug, {\n group: group[:name],\n where: %({\"#{field.name}_id\": \"#{group[:_id]}\"}),\n q: params[:q]\n })\n })\n end\n end",
"def exercise3\n @content = ActiveRecord::Base.connection.execute(\"\n SELECT\n gr.name as group,\n u.name as name,\n SUM(m.mapviews) as views,\n CONCAT(CAST(ROUND((SUM(m.mapviews)*100)/SUM(SUM(m.mapviews)) OVER (PARTITION BY gr.name),2) as text), '%') as percent_of_group_views\n FROM (((users as u\n INNER JOIN groups_users as gu ON u.id=gu.user_id)\n INNER JOIN groups as gr ON gr.id = gu.group_id)\n INNER JOIN maps as m ON m.user_id = u.id)\n GROUP BY (gr.name, u.name)\n ORDER BY gr.name ASC, percent_of_group_views DESC;\");\n\n @results3 = []\n\n index = 0\n @content.each do |r|\n @results3[index] = Result3.new r\n index = index + 1;\n end\n\n return @results3\n end",
"def test_grouping\n make_dummy_source(\"http://groupme/source1\", N::FOAFX.Goat, N::FOAFX.Bee)\n make_dummy_source(\"http://groupme/source2\", N::FOAFX.Goat)\n make_dummy_source(\"http://groupme/source3\", N::FOAFX.Bee)\n results = Source.groups_by_property(:type, [ N::FOAFX.Goat, N::FOAFX.Bee ])\n assert_equal(2, results.size)\n assert_equal(2, results[N::FOAFX.Goat].size)\n assert_equal(2, results[N::FOAFX.Bee].size)\n end",
"def show_group\r\n show_group_by_id()\r\n end",
"def find_group(query_string, page = 1, oauth = true)\n\t\t\toptions = {\"q\" => query_string, \"page\" => page}\n\t\t\tif oauth\n\t\t\t\toptions.merge!(key: Goodreads.configuration[:api_key])\n\t\t\t\tdata = oauth_request(\"/group/search.xml\", options)\n\t\t\telse\n\t\t\t\tdata = request(\"/group/search.xml\", options)\n\t\t\tend\n\t\t\tHashie::Mash.new(data)\n\t\tend",
"def result\n query_group.with_context do\n if primary.summarise?\n summary_result\n else\n simple_result\n end\n end\n end",
"def get_query_group(project_id, query_group_id)\n get \"projects/#{project_id}/querygroups/#{query_group_id}\"\n end",
"def search_query\n query = @grouping_class.new(sanitized_attributes, params)\n data = query.run\n @search_data = Rails.cache.fetch(['search_data', params], expires_in: 1.week) do\n query.build_hash(data, params)\n end\n @filtered_data = query.filter(@search_data, params)\n render :json => Kaminari.paginate_array(@filtered_data).page(params[:page]).per(params[:per_page]),\n :meta => metadata(@filtered_data, params)\n end",
"def requested_groups\n @request.empty? ? GROUPS : select_groups\n end",
"def groups()\n\t\t\tend",
"def groups_in_pairs\n\t #@group_locate = Group.instantiator(params[:id])\n @groups = [['[None]', nil]] + Group.in_pairs(groups = [], parent_name = \"\", list = [], params[:id])\n end",
"def groups\r\n @groups ||= fetch_groups\r\n end",
"def execute\n perform_search(Group.all)\n .then(&method(:paginate))\n .then(&method(:sort))\n end",
"def test_grouping_partial_set\n\n i = CartItem.for_product(Product.find(5))\n i.save\n\n groups = CartGroup.groups_for_items([i])\n\n assert_equal(1, groups.size)\n\n assert_equal(1, groups[0].size)\n assert_equal(5, groups[0][0].product_id)\n assert(!groups[0].set_discount?)\n assert_equal(BigDecimal('14.99'), groups[0].total)\n assert_equal(BigDecimal('0.00'), groups[0].savings)\n groups[0].items_with_prices { |item, price| assert_equal(BigDecimal('14.99'), price) }\n\n end",
"def find_groups\n @groups ||= Group.find(:all)\n end",
"def find_groups\n initialize_groups\n @edges.each do |e|\n v1 = e[0]\n v2 = e[1]\n g1 = group_for_id(v1)\n g2 = group_for_id(v2)\n merge_groups(g1, g2)\n end\n end",
"def in_frontend_groups\n # groups = []\n # xrefs = self.racc_route_destination_xrefs\n \n # vlabels = self.racc_routes.map {|rr| rr.vlabel_map }\n # vlabels.compact!\n # vlabels.delete_if {|v| v.group.category != \"f\" || v.group.group_default == false}\n # groups = vlabels.map {|v| Operation.first(:conditions => {:app_id => v.app_id, :newop_rec => v.vlabel}).group }\n Group.all(:conditions => [\"name IN \n (SELECT vlabel_group FROM racc_op WHERE newop_rec IN \n (SELECT vlabel FROM racc_vlabel_map WHERE vlabel IN \n (SELECT route_name FROM racc_route WHERE route_id IN \n (SELECT route_id FROM racc_route_destination_xref WHERE app_id = :app_id AND destination_id = :id)\n AND app_id = :app_id)\n AND app_id = :app_id)\n AND app_id = :app_id)\n AND app_id = :app_id AND category = :category AND group_default = :group_default\", {:id => self.id, :app_id => self.app_id, :category => 'f', :group_default => false}])\n end",
"def group_by(collection, grouping_key)\n [].tap do |providers| #building the returned Array\n extract_uniq_values_for_key(collection, grouping_key).each do |provider_name|\n current_provider_array, collection = collection.partition{|h| h[grouping_key] == provider_name} #reducing the collection\n providers << current_provider_array\n end\n end\nend",
"def test_grouping\n\n i1 = CartItem.create(:product_id => 1)\n i2 = CartItem.create(:product_id => 4)\n i3 = CartItem.create(:product_id => 5)\n\n groups = CartGroup.groups_for_items([i1, i2, i3])\n\n assert_equal(2, groups.size)\n\n assert_equal(1, groups[0].size)\n assert_equal(1, groups[0][0].product_id)\n assert(!groups[0].set_discount?)\n assert_equal(BigDecimal('9.99'), groups[0].total)\n assert_equal(BigDecimal('0.00'), groups[0].savings)\n groups[0].items_with_prices { |item, price| assert_equal(BigDecimal('9.99'), price) }\n\n assert_equal(2, groups[1].size)\n assert_equal(4, groups[1][0].product_id)\n assert_equal(5, groups[1][1].product_id)\n assert_equal(5, groups[1].sorted_items[0].product_id)\n assert_equal(4, groups[1].sorted_items[1].product_id)\n assert(groups[1].set_discount?)\n assert_equal(BigDecimal('23.98'), groups[1].total)\n assert_equal(ApplicationHelper.round_currency(BigDecimal('6.00')), ApplicationHelper.round_currency(groups[1].savings))\n groups[1].items_with_prices do |item, price|\n assert_equal(BigDecimal('0.00'), price) if item.product.id == 5\n assert_equal(BigDecimal('23.98'), price) if item.product.id == 4\n end\n\n end",
"def groups_where_member\n self.groups-self.groups_where_admin_and_wrapper\n end",
"def exercise1\n @content = ActiveRecord::Base.connection.execute(\"\n SELECT\n u.name as user_name,\n COUNT(gr.name) as groups_count,\n CONCAT('[', COALESCE(STRING_AGG(gr.name, ', ' ), ''),']') as groups\n FROM ((users as u\n LEFT JOIN groups_users as gu ON u.id=gu.user_id)\n LEFT JOIN groups as gr ON gr.id = gu.group_id)\n GROUP BY user_name\n ORDER BY groups_count;\");\n\n @results1 = []\n\n index = 0\n @content.each do |r|\n @results1[index] = Result1.new r\n index = index + 1;\n end\n\n return @results1\n end",
"def to_list\n\t\t# Binder.collection.group(key: :owner, cond: {}, initial: {count: 0}, reduce: \"function(doc,prev) {prev.count += +1;}\")\n\t\t# <query>.selector inserted into conditions field\n\t\trange = Range.new(grouphash['range'].first.to_i,grouphash['range'].last.to_i)\n\t\traw = kollection.titleize.constantize.collection.group(\t:key => grouphash['groupvals']['key'],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t:cond => grouphash['groupvals']['cond'],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t:initial => grouphash['groupvals']['initial'],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t:reduce => grouphash['groupvals']['reduce'])\n\t\traw = raw.map{ |f| { f['owner'] => f['count'].to_i } }\n\t\traw = raw.reject{ |f| range.cover?(f.first[1]) }\n\t\traw.map{ |f| f.first[0] }\n\tend",
"def grouped(start, field, reduce)\n collection = klass.collection.group(\n :cond => selector,\n :initial => { start => \"start\" },\n :reduce => reduce.gsub(\"[field]\", field)\n )\n collection.empty? ? nil : collection.first[start.to_s]\n end",
"def my_groups\n groups = Group.joins(:group_users).where(:group_users => {user_id: params[:user_id]})\n\n paginate json: groups\n end",
"def group(*values)\n values.inject(self) { |res, val| res._group(val) or fail ArgumentError, \"Unknown value for group: #{val}\" }\n end",
"def list_group\n RequestListGroup.where(:request_id => id).last\n end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = AdGroupSearchResultSet.new(resp)\n return results\n end",
"def aggregate\n klass.collection.group(\n :key => field_list,\n :cond => selector,\n :initial => { :count => 0 },\n :reduce => Javascript.aggregate\n )\n end",
"def group_builder; end",
"def groups\n return [] if new_record?\n cached_groups do\n fetch_groups!\n end\n end",
"def search_constrains\n {group: @group}\n end",
"def validate_query_within_group\n unless (self.class.by_share_group[share_group] - [self]).all?(&:query)\n errors.add(:query, :blank)\n end\n end",
"def index\n @all_groups = Group.joins(:users).where(\"memberships.user_id = ? and memberships.acceptance_status = ?\" , current_user, true)\n end",
"def set_GroupBy(value)\n set_input(\"GroupBy\", value)\n end",
"def grouping\n @ole.Grouping\n end",
"def index\n query = params[:query]\n @tasks_groups =\n if query.nil? or query.blank?\n TasksGroup.where(removed: false).paginate(:page => params[:page], :per_page => 10)\n else\n TasksGroup.search(query).where(removed: false).paginate(:page => params[:page], :per_page => 10)\n end\n end",
"def each\n group.each\n end",
"def filter_by_group(group)\n self.get_venues_for_search\n @venues_for_search.each do |venue|\n venue['attributes']['groups'].each do |groups|\n if groups[\"name\"].downcase == group.downcase\n groups[\"items\"].each do |item|\n if item[\"displayValue\"].split(\" \").first != \"No\"\n @venues_by_group << venue[\"name\"]\n end\n end\n end\n end \n end\n @venues_by_group\n end",
"def filtergroup(n=1, opt_h={:cached => true})\n if opt_h[:cached]\n if @filtergroups[n]\n return @filtergroups[n]\n else\n get_filtergroup n\n end\n else\n get_filtergroup n\n end\n end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = HaplogroupsResultSet.new(resp)\n return results\n end",
"def ii_groups; end",
"def generate_groups(groups, type)\r\n [].tap do |results|\r\n groups.each do |n, obj|\r\n group = {}\r\n group[\"name\"] = obj['name']\r\n group[\"code\"] = n\r\n group[\"risk_category\"] = \"AUTO\"\r\n group[type] = obj[type]\r\n results << group\r\n end\r\n end\r\nend",
"def add_grouping(solr_params)\n solr_params.merge!(Arclight::Engine.config.catalog_controller_group_query_params) if blacklight_params[:group] == 'true'\n\n solr_params\n end",
"def add_grouping(solr_params)\n solr_params.merge!(Arclight::Engine.config.catalog_controller_group_query_params) if blacklight_params[:group] == 'true'\n\n solr_params\n end",
"def add_group_result(result, group: nil)\n data = {result: result}\n if group\n data[:group] = group\n end\n if result.present?\n @group_results << data\n end\n end",
"def group\n @group\n end",
"def groups_list(trace: false, &block)\n r = dropbox_query(query: '2/team/groups/list', trace: trace)\n r['groups'].each(&block)\n while r['has_more']\n r = dropbox_query(query: '2/team/groups/list/continue', query_data: \"{\\\"cursor\\\":\\\"#{r['cursor']}\\\"}\", trace: trace)\n r['groups'].each(&block)\n end\n end",
"def group\n @group ||= Innsights::Fetchers::Group.new(@group_object) if @group_object\n end",
"def group\n @object.send(:try, Innsights.group_call) if Innsights.group_call.present?\n end",
"def groups(group_names)\n search(filter: group_filter(group_names))\n end"
] |
[
"0.7249811",
"0.69476086",
"0.68611515",
"0.679284",
"0.65190023",
"0.65134776",
"0.64668787",
"0.6462983",
"0.639155",
"0.63870037",
"0.63638943",
"0.6359463",
"0.6276422",
"0.6264285",
"0.6194671",
"0.615772",
"0.615772",
"0.615772",
"0.6118337",
"0.6109248",
"0.6106193",
"0.6104139",
"0.6090858",
"0.6089139",
"0.60794294",
"0.60672474",
"0.6055314",
"0.6033458",
"0.6032426",
"0.60322815",
"0.60322136",
"0.6001667",
"0.5996504",
"0.5996504",
"0.5968253",
"0.5960536",
"0.5955876",
"0.5954689",
"0.5941525",
"0.5922762",
"0.59205836",
"0.5916952",
"0.5890735",
"0.5873384",
"0.58577913",
"0.58480674",
"0.5843391",
"0.5835983",
"0.5834718",
"0.5824907",
"0.58163786",
"0.5814883",
"0.5802064",
"0.58017004",
"0.5797138",
"0.57884234",
"0.5784667",
"0.5775304",
"0.57702965",
"0.57692647",
"0.57688165",
"0.5768229",
"0.57553095",
"0.57540077",
"0.5737406",
"0.57242036",
"0.5722864",
"0.57179445",
"0.571108",
"0.5697447",
"0.56806916",
"0.56739086",
"0.5657138",
"0.5642541",
"0.5641471",
"0.5639817",
"0.56393176",
"0.5633973",
"0.56191784",
"0.56052685",
"0.5592997",
"0.5592417",
"0.55860114",
"0.5582482",
"0.5579528",
"0.5561346",
"0.55582213",
"0.5551981",
"0.55414295",
"0.55406255",
"0.55364317",
"0.553589",
"0.55246276",
"0.5523748",
"0.5523748",
"0.55230796",
"0.5509755",
"0.5509317",
"0.5508827",
"0.5508103",
"0.55076677"
] |
0.0
|
-1
|
Resets arguments passed to generate
|
def reset(state)
note 'Reset'
state[:description] = ''
state[:params] = []
state[:return] = ''
state[:example] = ''
state[:in_param] = false
state[:in_return] = false
state[:in_example] = false
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def reset\n @args = nil\n end",
"def reset! #:nodoc:\n @@args = false\n @@banner = false\n @@header = Array.new\n @@options = Array.new\n @@footer = Array.new\n end",
"def _rl_reset_argument()\r\n @rl_numeric_arg = @rl_arg_sign = 1\r\n @rl_explicit_arg = false\r\n @_rl_argcxt = 0\r\n end",
"def reset\n @params = initial_params\n self\n end",
"def initialize(*args)\n reset\n end",
"def reset!\n @options = Name.defaults.dup\n end",
"def reset!; end",
"def reset!; end",
"def reset!; end",
"def reset!; end",
"def reset!\n end",
"def reset!\n end",
"def reset_for_next_command\n # self.args, self.switches, self.options = [], [], {}\n self.output, self.capture = false, false\n end",
"def arguments=(_arg0); end",
"def reset!\n @options = defaults\n end",
"def reset!\n @options = defaults\n end",
"def reset\n @params = nil\n @logger = nil\n end",
"def reset()\n \n end",
"def reset!\n tap { set_defaults }\n end",
"def reset\n end",
"def reset\n end",
"def reset\n end",
"def reset\n end",
"def reset; end",
"def reset; end",
"def reset; end",
"def reset; end",
"def reset; end",
"def reset; end",
"def reset; end",
"def reset; end",
"def reset; end",
"def reset; end",
"def reset; end",
"def reset; end",
"def reset; end",
"def reset; end",
"def reset; end",
"def reset; end",
"def reset; end",
"def reset; end",
"def reset() end",
"def initialize_copy(*args)\n super\n\n reset_main_generator\n end",
"def reset\n\n end",
"def reset\n super\n @params.values.uniq.each do |param|\n param.send(:reset) if param.is_a? Parameter\n end\n end",
"def reset ; end",
"def reset\n end",
"def reset\n end",
"def reset\n @params = Hash.new\n end",
"def reset()\n end",
"def reset!\n @options = {}\n end",
"def reset(arguments, options)\n options[:persistence] ||= Persistence.new\n options[:persistence].clear\n end",
"def reset\n initialize(@options)\n end",
"def reset\n end",
"def reset\n end",
"def resets; end",
"def reset\n super\n @params.values.uniq.each { |param| param.reset if param.is_a? Parameter }\n end",
"def reset\n # TODO\n end",
"def generators=(_arg0); end",
"def reset\n \n end",
"def reset\n @count = @options[:start]\n end",
"def clear_parameters\n @interface.clear_parameters\n current_parameters\n end",
"def reset\n @options = Marshal.load(@default)\nend",
"def reset\n self.options = nil\n self.option_processors = nil\n end",
"def clearMagazineCargoGlobal _args\n \"clearMagazineCargoGlobal _args;\" \n end",
"def reset\n\t\tend",
"def reset\n initialize\n setup\n end",
"def reset\n setup\n end",
"def reset_params\n @params = {}\n end",
"def reset()\n #This is a stub, used for indexing\n end",
"def reset()\n #This is a stub, used for indexing\n end",
"def lnbClear _args\n \"lnbClear _args;\" \n end",
"def initial_generate\n \n end",
"def reset_defaults; end",
"def reset!\n @defaults.each do |k, v|\n instance_variable_set(k, v)\n end\n end",
"def reset(*)\n super.tap do\n # noinspection RailsParamDefResolve\n try(:initialize_state, submission.params, **{}) if simulating\n end\n end",
"def removeUniform _args\n \"removeUniform _args;\" \n end",
"def reset\n @sha_in_phrase = \"\"\n @params = {}\n end",
"def reset_all\n @params.each_key {|k| reset(k.to_s)}\n @params = {}\n end",
"def reset\n\t\tself.gen = Random.new(SEED)\n\tend",
"def reset\n\t\tself.gen = Random.new(SEED)\n\tend",
"def cmd_reset(*args)\n if args.length > 0\n cmd_reset_help\n return\n end\n client.reset\n end",
"def reset\n # Empty, but subclasses will override this.\n end",
"def reset\n $iptr = 0\n $program = []\n $labels = {}\n $binding = binding\nend",
"def reset_all\n clear_commands\n reset_colors\n @app_info = nil\n @app_exe = nil\n @verbose_parameters = true\n @@default_method = nil\n @@class_cache = {}\n end",
"def reset!\n @x = @init_x\n @y = @init_y\n end",
"def reset\n\n end",
"def reset!\n initialize\n end",
"def reset!\n @stmt_api.reset!\n @param_positions = {}\n @blobs_to_write.clear\n @rowid_index = nil\n end",
"def reset\n unapply\n apply\n end",
"def reset\n @left_generator.reset\n @right_generator.reset\n\n nil\n end",
"def internal_reset(initial_value); end",
"def reset(*args,&ruby_block)\n # Gain access to the writer as local variable.\n reseter_proc = @inout_reseter_proc\n # # The context is the one of the writer.\n # Execute the code generating the writer in context.\n HDLRuby::High.space_push(@namespace)\n HDLRuby::High.cur_block.open do\n instance_exec(ruby_block,*args,&reseter_proc)\n end\n HDLRuby::High.space_pop\n end",
"def reset\n configure({})\n end",
"def reset\n @perms = []\n @depends = []\n @next_blocks = []\n @clobbers = []\n @offset = nil\n @state = nil\n @once = false\n @references = 0\n @used_references = 0\n @generated = false\n end",
"def reset!\n self.user_values = {}\n\n # @inputs have to be nil, not an empty hash. otherwise\n # the memoized inputs will not pick up the changes.\n @inputs = nil\n end",
"def reset\n super\n end",
"def clearWeaponCargoGlobal _args\n \"clearWeaponCargoGlobal _args;\" \n end",
"def reset!\n @defaults.each { |key, value| instance_variable_set(key, value) }\n end",
"def reset!\n @defaults.each { |key, value| instance_variable_set(key, value) }\n end"
] |
[
"0.7613592",
"0.67471886",
"0.6509575",
"0.6277423",
"0.62344766",
"0.6204325",
"0.6170612",
"0.6170612",
"0.6170612",
"0.6170612",
"0.61696476",
"0.61696476",
"0.6145702",
"0.61323303",
"0.6123948",
"0.6123948",
"0.6075356",
"0.60731447",
"0.60702443",
"0.60436994",
"0.60436994",
"0.60436994",
"0.60436994",
"0.60367006",
"0.60367006",
"0.60367006",
"0.60367006",
"0.60367006",
"0.60367006",
"0.60367006",
"0.60367006",
"0.60367006",
"0.60367006",
"0.60367006",
"0.60367006",
"0.60367006",
"0.60367006",
"0.60367006",
"0.60367006",
"0.60367006",
"0.60367006",
"0.60357106",
"0.60285014",
"0.6021775",
"0.60055584",
"0.600049",
"0.5999297",
"0.5999297",
"0.59862053",
"0.59635663",
"0.5935091",
"0.5917668",
"0.5912372",
"0.59078693",
"0.59078693",
"0.590501",
"0.58944756",
"0.5884368",
"0.5879702",
"0.5874209",
"0.5865147",
"0.5849915",
"0.5838071",
"0.5833025",
"0.5820443",
"0.5809199",
"0.5792863",
"0.57763404",
"0.577268",
"0.5769394",
"0.5769394",
"0.5765897",
"0.5761325",
"0.5757005",
"0.57544684",
"0.57519114",
"0.5738268",
"0.57377136",
"0.572839",
"0.57264066",
"0.57264066",
"0.5722218",
"0.5718522",
"0.5713828",
"0.5713603",
"0.5691778",
"0.56735855",
"0.56712735",
"0.5669395",
"0.56646895",
"0.5659422",
"0.56576294",
"0.5656535",
"0.5656439",
"0.564973",
"0.5644205",
"0.5639788",
"0.56377053",
"0.56319165",
"0.56319165"
] |
0.6119415
|
16
|
Remembers a user in the database for use in persistent sessions.
|
def remember
self.remember_token = User.new_token
update_attribute(:remember_digest, User.digest(remember_token))
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def reset_user\n return unless exists?(:previous_user)\n set :user, fetch(:previous_user)\n unset :previous_user\n clear_sessions\n end",
"def change_password\n @user = User.find_by_id(session[:remember_token])\n end",
"def set_user\n zeus = User.find(@zeus_user.id)\n zeus.state = User.states['retrieved_password']\n zeus.save!\n \n request.session[:rbac_user_id] = @zeus_user.id\n end",
"def set_session_current_user(user)\n self.current_user = user\n # Try to reuse existing sessions.\n if session[:authpwn_suid]\n token = Tokens::SessionUid.with_code(session[:authpwn_suid]).first\n if token\n if token.user == user\n token.touch\n return user\n else\n token.destroy\n end\n end\n end\n if user\n session[:authpwn_suid] = Tokens::SessionUid.random_for(user,\n request.remote_ip, request.user_agent || 'N/A').suid\n else\n session.delete :authpwn_suid\n end\n end",
"def with_user(new_user, &block)\n begin\n set_user(new_user)\n yield exists?(:previous_user) ? fetch(:previous_user) : nil\n ensure\n reset_user\n end\n \n clear_sessions\n end",
"def remember user\n # generates the remember token and saves it's encrypted form to the db\n user.remember\n cookies.permanent.signed[:user_id] = user.id\n cookies.permanent[:remember_token] = user.remember_token\n end",
"def load_user(user)\n session[:user_id] = user.id\n session_reset_timeout!\n user.update_attributes last_login_on: Time.now, login_count: user.login_count + 1\n end",
"def sign_in(user)\n remember_token = User.new_remember_token\n cookies.permanent[:remember_token] = remember_token\n user.update_attribute(:remember_token, User.hash(remember_token))\n self.current_user = user\n end",
"def sign_in(user)\n remember_token = User.new_remember_token\n cookies.permanent[:remember_token] = remember_token\n user.update_attribute(:remember_token, User.hash(remember_token))\n self.current_user = user\n end",
"def set_user\n @user = User.find(session[:user_id])\n end",
"def set_user\n @user = User.find(session[:user_id])\n end",
"def set_user\n @user = User.find(session[:user_id])\n end",
"def lookup_user\n reset_session #use this when they ask you to find a user\n if session[:user_id]\n @user = User.find(session[:user_id])\n end\n end",
"def save_session user\n # The password_seed method is used to generate the stored token.\n # The remember_token is then stored as a signed cookie along with the\n # user's ID from the database.\n remember_token = password_seed\n cookies.permanent.signed[:remember_user_id] = user.id\n cookies.permanent.signed[:remember_user_token] = remember_token\n \n # The WHIRLPOOL hash of remember_token and the user's password seed is\n # then stored in the database.\n remember_hash = Digest::Whirlpool.hexdigest(remember_token +\n user.password_seed)\n user.update_attributes(:remember_hash => remember_hash)\n user.save\n end",
"def change_password\n @user=User.find(current_user)\n end",
"def alter_current_user(&block)\n user = current_user\n user = User.find(user.id) if user.frozen? # Since we're modifying it, we can't use the one from memcached.\n yield(user)\n user.save if logged_in?\n $CACHE.delete(\"users/#{session[:user_id]}\")\n set_current_user(user)\n user\n end",
"def set_user\n @user = User.find(session[:id]) if @user.nil && session[:id]\n end",
"def remember\n self.remember_token = User.new_token\n self.remember_digest = User.digest(self.remember_token)\n update_attribute(:remember_digest, self.remember_digest) #for new user, this creates record\n end",
"def set_user\n @user = User.find(session[:user_id])\n end",
"def set_current_user(user)\n sha1 = Digest::SHA1.hexdigest(user.id.to_s + Time.now.to_i.to_s)\n cookies[:remember_token] = { :value => sha1, :expires => 3.years.from_now }\n user.remember_token = sha1\n user.save\n @current_user = user\n end",
"def set_user\n @user = User.find_by(username: params[:user][:username])\n session[:user_id] = @user.id\n end",
"def current_user=(new_user)\n current_session.user = new_user\n end",
"def sign_in(user)\n # Issues new random piece of text (aka\n # remember_token) to user\n remember_token = User.new_remember_token\n # Giving user plain text token\n cookies.permanent[:remember_token] = remember_token\n # Hashing the version of the remember_token which the host maintains.\n user.update_attribute(:remember_token, User.hash(remember_token))\n #sets the one who signed in (user) to current user\n self.current_user=user\n end",
"def sign_in(user)\n remember_token = User.new_remember_token # create a new remember token\n cookies.permanent[:remember_token] = remember_token # save the remember token on the client side as a cookie\n user.update_attributes remember_token: User.hash(remember_token) # save the remember token on the server side in the DB\n self.current_user = user\n end",
"def set_user\n @user = User.where(:username => params[:id]).first!\n end",
"def set_user\n require_logged_in\n @user = User.find_by(id: session[:user_id])\n end",
"def fetch_user\n @current_user = User.find_by(:id => session[:user_id]) if session[:user_id]\n\n session[:user_id] = nil unless @current_user.present?\n end",
"def sign_in(user)\n sign_out\n\n user.touch(:last_login_at)\n user_session = user.sessions.new(ip_address: request.remote_ip, user_agent: request.user_agent)\n if user_session.save\n user.password_resets.delete_all\n @current_session = user_session\n end\n end",
"def user_remember(user)\n user.remember_user\n cookies.permanent.signed[:user_id] = user.id\n cookies.permanent[:remember_token] = user.remember_token\n end",
"def set_user\n if session[:user_id].nil?\n @user = nil\n else\n @user = User.find(session[:user_id])\n end\n end",
"def remember\n self.remember_token = User.new_token\n\n # update_attribute bypasses validations, since we don't have user's password\n # here, which is normally necessary for changing records on the table\n update_attribute(:remember_digest, User.digest(remember_token))\n end",
"def change_password\n @user = current_user\n end",
"def change_password\n @user = current_user\n end",
"def resetpass\r\n @user = User.new\r\n end",
"def set_user\n if session[:user_id]\n @user = User.find(session[:user_id])\n end\n end",
"def fetch_user\n\n # Check if user_id in the session is the id of a real user in our db. If it is, we will get the user object in @current_user; if not, we will get nil\n if session[:user_id].present?\n @current_user = User.find_by id: session[:user_id]\n end\n\n # If we did get nil from the above query, delete the session because the user_id is stale (invalid)\n if @current_user.nil?\n session[:user_id] = nil # unless @current_user.present?\n end\n\n end",
"def user_remember(user)\n user.remember\n cookies.permanent.signed[:user_id] = user.id\n cookies.permanent[:remember_token] = user.remember_token\n end",
"def forget_everything\n empty_session!\n PersistentUser.new(@user).delete\n end",
"def set_user_session\n @user = user_session.find(params[:id])\n end",
"def reset_current_user(user_x)\n user = User === user_x ? user_x : User.find(user_x)\n unless user.nil? || current_user_id == user.id\n clear_auth_cookie\n reset_user_session\n set_current_user(user)\n end \n end",
"def set_user\n UserInfo.current_user = session[:user]\n end",
"def remember\n # give the variable to \"self\", the user\n # sets the remember_token attribute of the user object\n self.remember_token = User.new_token\n # update attribute of the User, bypass validations (password), hash the\n # remember_token using digest (not totally sure that's right)\n update_attribute(:remember_digest, User.digest(remember_token))\n end",
"def remember\n self.remember_token = Incline::User::new_token\n update_attribute(:remember_digest, Incline::User::digest(self.remember_token))\n end",
"def remember(user) \n user.remember # the method creates remember_token for that user and saves the hashed the version in the db \n cookies.permanent.signed[:user_id] = user.id # This stores the user.ID(encrypted) in the browser cookie\n cookies.permanent[:remember_token] = user.remember_token # This stores the remember token(encrypted) in the cookie \n # the remember token was created in the first line of code \"user.remember\"\n end",
"def sign_in(user)\n remember_token = User.new_token\n cookies.permanent[:remember_token] = remember_token\n user.update_attribute(:remember_digest, User.digest(remember_token))\n cookies.permanent.signed[:user_id] = user.id\n self.current_user = user\n end",
"def remember\n self.remember_token = User.new_token\n #so @user.remember_token = some random string\n update_attribute(:remember_digest, User.digest(remember_token))\n #so the User in the database has its remember_digest collumn updated to the Bcrypt of the remember_token\n end",
"def restore_last_user\n return @last_user if @last_user\n if session[:last_user_id].present?\n @last_user = User.find_by_id(session[:last_user_id])\n message = translate(\"users.sign_in_back\", user: @last_user.name)\n set_flash_message(message, :success, false)\n session.destroy()\n session[:id] = @last_user.id if @last_user.present?\n return @last_user\n end\n end",
"def current_user\n if session[:user_id] # Do not know how to check for nil session expires. #TODO - figure out session expires\n @current_user = User.create_from_database(session[:user_id].to_i)\n else\n session.clear\n @message = \"You are not logged in. Please log in.\"\n redirect \"/login\"\n end \n end",
"def current_user=(new_user)\n session[:user_id] = new_user.id\n @current_user = new_user\n end",
"def current_user=(new_user)\n session[:user] = (new_user.nil? || new_user.is_a?(Symbol)) ? nil : new_user.id\n @current_users = nil\n end",
"def set_current_user(user)\n if user.new_record?\n set_unlogged_in_user(user)\n else\n set_logged_in_user(user)\n end\n end",
"def current_user=(new_user)\n session[:user_id] = new_user ? new_user.id : nil\n end",
"def current_user=(new_user)\n session[:user_id] = new_user ? new_user.id : nil\n end",
"def set_user\n @user = User.find(user_id)\n end",
"def change_password\n @user = User.new\n end",
"def set_user\n @user = User.unscoped.find(params[:id])\n end",
"def destroy\n User.find(current_user.id)\n reset_session\n redirect_to new_user_path\n end",
"def log_in_user!(user)\n session[:session_token] = user.reset_session_token!\n end",
"def log_in_user!(user)\n session[:session_token] = user.reset_session_token!\n end",
"def remember\n self.remember_token = User.new_token\n self.update_attribute :remember_digest, User.digest(remember_token)\n end",
"def remember(user)\n\t\t#calls the remember method in AdminUser model\n\t\tuser.remember\n\t\t#cookies method helps to do permanent sessions. This is actually a syntactic sugar for a bigger thing. \n\t\tcookies.permanent.signed[:user_name] = user.username\n\t\t#save the remembertoken as well. this dosent need to be encrypted\n\t\tcookies.permanent[:remember_token] = user.remember_token\n\tend",
"def set_user\n @user = User.find(current_user)\n end",
"def set_user\n @user = User.find(current_user)\n end",
"def set_user\n # @user = User.find(params[:id])\n @user = User.find_by_sql(['SELECT \"users\".* FROM \"users\" WHERE \"users\".\"id\" = ? LIMIT 1', params[:id]])[0]\n end",
"def set_user(user)\n reset_session\n if user && user.is_a?(Marty::User)\n Marty::User.current = user\n start_user_session(user)\n else\n Marty::User.current = nil\n end\n end",
"def remember\n self.remember_token = User.new_token\n update_attribute(:remember_digest, User.digest(remember_token))\n end",
"def remember\n self.remember_token = User.new_token\n # Writes token to db\n update_attribute(:remember_digest, User.digest(remember_token))\n end",
"def remember\n self.remember_token = User.new_token\n self.update_attribute(:remember_digest, User.digest(self.remember_token))\n end",
"def switch\n authorize!(:manage, :all)\n user = User.find_by(login: params[:login].upcase)\n if user\n session[:original_user_id] = session[:user_id]\n session[:user_id] = user.id\n redirect_to root_url, notice: \"Sie sind nun der Nutzer mit dem Login #{user.login}.\"\n else\n redirect_to root_url, notice: \"Der Nutzer existiert nicht im System.\"\n end\n end",
"def persist\n # Create a new token and save it to database.\n # NOTE: Bypass the validations because we don’t have access to the user’s password.\n @remember_token = User.new_token\n update_column(:remember_digest, User.digest(remember_token))\n end",
"def remember\n self.remember_token = User.new_token\n update remember_digest: User.digest(remember_token)\n end",
"def set_user\n @user = User.find_by_id(params[:id])\n require_same_user\n #redirect_to signin_path unless @user #for a route that does not exist redirect it back to home page\n end",
"def remember(user)\n user.persist\n cookies.permanent.signed[:user_id] = user.id\n cookies.permanent[:remember_token] = user.remember_token\n end",
"def remember(user)\n user.remember # Calls model\n cookies.permanent.signed[:user_id] = user.id # Save off encryped user ID\n cookies.permanent[:remember_token] = user.remember_token # Save off random thing for validation\n end",
"def current_user=(new_user)\n session[:user_id] = new_user ? new_user.id : nil\n @current_user = new_user || nil\n end",
"def set_user\n @user = User.find(current_user[:id])\n end",
"def set_user\n @user = User.find(current_user[:id])\n end",
"def remember\n self.remember_token = User.generate_remember_token\n update_attribute(:remember_digest, User.digest(remember_token))\n end",
"def user=(user)\n session[:user] = nil && return if user.nil?\n session[:user] = store_user(user)\n @user = session[:user] ? user : session[:user] \n end",
"def user=(user)\n session[:user] = nil && return if user.nil?\n session[:user] = store_user(user)\n @user = session[:user] ? user : session[:user] \n end",
"def user=(user)\n session[:user] = nil && return if user.nil?\n session[:user] = store_user(user)\n @user = session[:user] ? user : session[:user] \n end",
"def remember\n self.remember_token = User.new_token\n update_attribute(:remember_digest, User.digest(remember_token))\n end",
"def remember\n self.remember_token = User.new_token\n update_attribute(:remember_digest, User.digest(remember_token))\n end",
"def remember\n self.login_token = User.new_token\n update_attribute(:login_digest, User.digest(self.login_token))\n end",
"def current_user=(new_user)\n session[:user_id] = new_user ? new_user.id : nil\n @current_user = new_user || false\n end",
"def current_user=(new_user)\n session[:user_id] = new_user ? new_user.id : nil\n @current_user = new_user || false\n end"
] |
[
"0.68847036",
"0.65202016",
"0.6288528",
"0.6221299",
"0.6220095",
"0.6177217",
"0.6141952",
"0.61285347",
"0.61285347",
"0.6122638",
"0.6121868",
"0.6121868",
"0.61191475",
"0.6094944",
"0.6088155",
"0.6087507",
"0.6085413",
"0.6080089",
"0.6078",
"0.6067664",
"0.604671",
"0.6039976",
"0.6030235",
"0.6027223",
"0.6000635",
"0.5996913",
"0.5977766",
"0.5973093",
"0.5971543",
"0.5968983",
"0.5952099",
"0.59466034",
"0.59466034",
"0.5941424",
"0.5937312",
"0.5936054",
"0.5928936",
"0.5925495",
"0.5924715",
"0.5910626",
"0.58932173",
"0.5890197",
"0.5888593",
"0.58843607",
"0.5883934",
"0.5877648",
"0.58769196",
"0.5873437",
"0.5866357",
"0.5853414",
"0.58495015",
"0.5844992",
"0.5844992",
"0.5840656",
"0.5838108",
"0.58263034",
"0.58215165",
"0.58177096",
"0.58177096",
"0.58139086",
"0.58092606",
"0.5808909",
"0.5808909",
"0.5808151",
"0.58081335",
"0.5805442",
"0.5801462",
"0.57963425",
"0.5792024",
"0.57900804",
"0.5787435",
"0.57839316",
"0.57806903",
"0.57787883",
"0.57765365",
"0.577418",
"0.577418",
"0.5770237",
"0.57684815",
"0.57684815",
"0.57684815",
"0.57588",
"0.57588",
"0.57583934",
"0.5757197",
"0.5757197"
] |
0.0
|
-1
|
Returns true if the given token matches the digest.
|
def authenticated?(remember_token)
BCrypt::Password.new(remember_digest).is_password?(remember_token)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def authenticated?(digest, token)\n digest = send(\"#{digest}_digest\")\n # Use metaprogramming to select the appropriate token attribute based on\n # the parameter digest.\n return false if digest.nil? # Digest does not exist in the database.\n BCrypt::Password.new(digest).is_password?(token)\n # Decrypts the digest and compares it to the token.\n end",
"def authenticated?(token, digest = nil)\n return false if digest.present? && BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n digest.is_digest_for? token\n end",
"def validate_token(digest, token)\n if token.nil? || digest.nil?\n false\n else\n BCrypt::Password.new(digest).is_password?(token)\n end\n end",
"def authenticated_with_token?(token)\n return false if token.nil?\n token == remember_digest\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n digest == Digest::SHA1.hexdigest(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n digest == Digest::SHA1.hexdigest(token)\n end",
"def valid_signature?(token)\n return false unless token =~ /&HMACSHA256=(.*)$/\n original_signature = CGI.unescape(token[/&HMACSHA256=(.*)$/, 1])\n bare_token = token.gsub(/&HMACSHA256=(.*)$/, '')\n signature = Base64.encode64(HMAC::SHA256.new(Base64.decode64(shared_secret)).update(bare_token.toutf8).digest).strip\n return original_signature == signature\n end",
"def match_token(token)\n return true\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\") # no need for self.send as we're in the user model\n return false if digest.nil?\n # verify the token matches the digest\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n # when digest nil ist soll die methode false zurückgeben damit Bcrypt keinen Fehler hervorrufen kann, wenn man sich bei zwei BRowsern eingeloggt hat und sich nur bei einem abmeldet, aber beide schließt.\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token) #takes a token, hashes it and compares it to the original hash_digest from the database. If hash_digest of given token is equal to the one saved in the database, authenticatedß returns true.\n end",
"def authenticated?(attribute, token)\n digest = self.try(\"#{attribute}_digest\")\n return false if digest.nil?\n ::BCrypt::Password.new(digest) == token\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_token_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n \n digest = send(\"#{attribute}_digest\")\n \n return false if digest.blank? \n #ry.binding\n \n #BCrypt::Password.new will fail with invalid_hash as the new hash not having the valid_hash? coming tru for BCrypt gem.\n #It should be passed all the params as in cost and salt, so that it can be successfully be parsed. Otherwise use create.\n #https://github.com/codahale/bcrypt-ruby/blob/master/lib/bcrypt/password.rb\n # alias is_password, :== \n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n \treturn false if digest.nil?\n \tBCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n\tdigest = send(\"#{attribute}_digest\")\n\treturn false if digest.nil?\n\tBCrypt::Password.new(digest).is_password?(token)\nend",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token) \n end",
"def authenticated?(auth_token)\n return false if auth_token_digest.nil?\n BCrypt::Password.new(auth_token_digest).is_password? (auth_token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n\t\tdigest = send(\"#{attribute}_digest\")\n\t\treturn false if digest.nil?\n\t\tBCrypt::Password.new(digest).is_password?(token)\n\tend",
"def authenticated?(attribute, token)\n\t\tdigest = send(\"#{attribute}_digest\")\n\t\treturn false if digest.nil?\n\t\tBCrypt::Password.new(digest).is_password?(token)\n\tend",
"def authenticated?(attribute, token)\n\t\tdigest = send(\"#{attribute}_digest\")\n\t\treturn false if digest.nil?\n\t\tBCrypt::Password.new(digest).is_password?(token)\n\tend",
"def authenticated?(attribute, token)\n\t\tdigest = send(\"#{attribute}_digest\")\n\t\treturn false if digest.nil?\n\t\tBCrypt::Password.new(digest).is_password?(token)\n\tend",
"def authenticated?(attribute, token)\n\t\tdigest = send(\"#{attribute}_digest\")\n\t\treturn false if digest.nil?\n\t\tBCrypt::Password.new(digest).is_password?(token)\n\tend",
"def authenticated?(attribute, token)\n\t\tdigest = send(\"#{attribute}_digest\")\n\t\treturn false if digest.nil?\n\t\tBCrypt::Password.new(digest).is_password?(token)\n\tend",
"def authenticated?(attribute, token)\n\t\tdigest = send(\"#{attribute}_digest\")\n\t\treturn false if digest.nil?\n\t\tBCrypt::Password.new(digest).is_password?(token)\n\tend",
"def authenticated?(attribute, token)\n\t\tdigest = send(\"#{attribute}_digest\")\n\t\treturn false if digest.nil?\n\t\tBCrypt::Password.new(digest).is_password?(token)\n\tend",
"def authenticated?(attribute, token)\n\t\tdigest = send(\"#{attribute}_digest\")\n\t\treturn false if digest.nil?\n\t\tBCrypt::Password.new(digest).is_password?(token)\n\tend",
"def authenticated?(attribute, token)\n\t\tdigest = send(\"#{attribute}_digest\")\n\t\treturn false if digest.nil?\n\t\tBCrypt::Password.new(digest).is_password?(token)\n\tend",
"def authenticated?(attribute, token)\n\t\tdigest = send(\"#{attribute}_digest\")\n\t\treturn false if digest.nil?\n\t\tBCrypt::Password.new(digest).is_password?(token)\n\tend",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\") # self is omitted on send()\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n digest.present? ? BCrypt::Password.new(digest).is_password?(token) : false\n end",
"def authenticated?(attribute, token)\n digest = self.send(\"#{attribute}_digest\")\n return false if digest.nil? \n \n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n \tdigest = send(\"#{attribute}_digest\")\n \treturn false if digest.nil?\n \tBCrypt::Password.new(digest).is_password?(token)\n \tend",
"def authenticated?(token)\n digest = self.otp_digest\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute,token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{ attribute }_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n\n digest = self.send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n\n end",
"def valid_token?(token)\n exists?(:token => token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil? # Password.new(nil) raises error\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n \tdigest = send(\"#{attribute}_digest\")\n \treturn false if digest.nil?\n \tBCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = self.send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = self.send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = self.send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = self.send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = self.send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = self.send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = self.send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = self.send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end"
] |
[
"0.78424853",
"0.76170635",
"0.7406786",
"0.72879815",
"0.7143585",
"0.71428716",
"0.71428716",
"0.7028208",
"0.6984801",
"0.6964507",
"0.6905196",
"0.6859846",
"0.6843323",
"0.6824065",
"0.67973304",
"0.67884517",
"0.67749035",
"0.676529",
"0.6751168",
"0.67464095",
"0.6743642",
"0.6717869",
"0.6717869",
"0.6717869",
"0.6717869",
"0.6717869",
"0.6717869",
"0.6717869",
"0.6717869",
"0.6717869",
"0.6717869",
"0.6717869",
"0.6717869",
"0.6717869",
"0.6717869",
"0.6717869",
"0.6717869",
"0.6717869",
"0.6717869",
"0.6717869",
"0.6717869",
"0.6717869",
"0.6717869",
"0.6717869",
"0.6717869",
"0.6717869",
"0.6717869",
"0.6717869",
"0.6717869",
"0.6717869",
"0.6717869",
"0.6717869",
"0.6717869",
"0.6717869",
"0.6717869",
"0.6717869",
"0.6717869",
"0.6717869",
"0.6717869",
"0.6717869",
"0.6717869",
"0.6717869",
"0.6717869",
"0.6717869",
"0.6717869",
"0.6717869",
"0.6717869",
"0.6717869",
"0.6717869",
"0.6717869",
"0.6716728",
"0.67155164",
"0.67155164",
"0.67155164",
"0.67155164",
"0.67155164",
"0.67155164",
"0.67155164",
"0.67155164",
"0.67155164",
"0.67155164",
"0.6714587",
"0.6714452",
"0.6714318",
"0.671096",
"0.6710529",
"0.67039156",
"0.6687869",
"0.6679038",
"0.6677953",
"0.66753757",
"0.6671193",
"0.66700786",
"0.66696876",
"0.66696876",
"0.66696876",
"0.66696876",
"0.66696876",
"0.66696876",
"0.66696876",
"0.66696876"
] |
0.0
|
-1
|
This looks up the product first directly by the product_id, then using the product_id as the EAN.
|
def extract_product_id(order_line_product_id)
api.lookup_product(order_line_product_id)['number']
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def product\n Product.find_by_outer_id(outer_id) || Product.find_by_num_iid(num_iid)\n end",
"def product\n id = self.product_id\n found_product = FarMar::Product.find(id)\n return found_product\n end",
"def product(product_id)\n FarMar::Product.all.find { |product| product.id == product_id }\n end",
"def get_product_by_id(product_id)\n return Product.find(product_id)\n end",
"def product(product)\n products.find(product.id)\n end",
"def product\n sale_product = Product.new(:id, :name, :vendor_id)\n Product.all.each do |pro_id, pro|\n if pro_id == product_id\n sale_product = pro\n break\n end\n end\n return sale_product\n end",
"def product\n FarMar::Product.all.select { |product| product.product_id == product_info }\n end",
"def product\n FarMar::Product.find(self.product_id)\n end",
"def find(product_asin)\n new( SpreeEcs::Product.find(product_asin, { :response_group => \"Large, Variations\" }))\n end",
"def getProduct(id)\n @products.find {|prod| prod.productId.to_i == id.to_i}\n end",
"def get_product\n @product = Product.find_by_uuid(params[:product_id])\n if @product.nil?\n raise Repia::Errors::NotFound\n end\n end",
"def product\n product_sold = nil\n products = FarMar::Product.all\n products.each do |product|\n if product.id == self.product_id\n product_sold = product\n return product_sold\n end#of if\n end#of do\n end",
"def product\n FarMar::Product.find(@product_id)\n end",
"def set_product\n @product = LowestPrice.where(id: params[:id]).first\n end",
"def find_by_id(id)\n get_product_by_id(id)\n end",
"def set_product\n @product = Product.includes(:lotteries, :ranking_config_items).find(params[:id])\n end",
"def set_product\n #@product = Product.find params[:id]\n @product = Product.where(id: params[:id]).includes(\n {product_impact_line_items: [:impact_line_item, :impact_entries]}).first\n end",
"def set_product\n begin \n @product = Product.find(params[:id])\n rescue ActiveRecord::RecordNotFound => e\n puts e\n end\n end",
"def find(product_id)\n all.each do |product|\n if product.product_id == product_id\n return product\n end\n end\n return nil\n end",
"def set_product\n begin\n @product = Product.find(params[:id])\n rescue\n raise Cinema::NotFound \n end\n end",
"def find(product_id, options = nil)\n request = Request.new(@client)\n path = \"/products/\" + CGI.escape(product_id) + \"\"\n data = {\n\n }\n\n response = Response.new(request.get(path, data, options))\n return_values = Array.new\n \n body = response.body\n body = body[\"product\"]\n \n \n obj = Product.new(@client)\n return_values.push(obj.fill_with_data(body))\n \n\n \n return_values[0]\n end",
"def set_product\n @product = Product.with_default_includes.find(params[:id])\n end",
"def set_product\n @product = Product.where(id: params[:id], tenant: @tenant).first\n end",
"def get_product product_id\n # Retrieve the product that was just created\n @server.call(\"call\", @session_id, \"catalog_product.info\", [product_id, @current_store_id, [\"image\"]])\n rescue XMLRPC::FaultException => exception\n return exception\n end",
"def product\n @product ||= Product.find(params[:id])\n end",
"def set_orden_product\n @orden_product = OrdenProduct.find(params[:id])\n end",
"def set_product\n @product = Product.includes(:product_type).find(params[:id])\n end",
"def set_product\n begin\n @product = Product.friendly.find(params[:id])\n rescue ActiveRecord::RecordNotFound => message_error\n @message_error = message_error\n end\n end",
"def fetch_product\n @product = Product.visible.find(params[:id]) if params[:id]\n end",
"def set_product\n @product = current_seller.product.find(params[:id])\n end",
"def set_product\n \n @product = Product.find(params[:id].to_i)\n end",
"def get_product\n @product = Product.find(params[:id])\n end",
"def find_price_by_product_id(product_id, products = Products)\n products[\"prices\"].each do |product|\n return product[\"price\"] if product[\"product_id\"]== product_id\n end\n end",
"def set_product\n @product = current_api_v1_user.products.find(params[:id])\n end",
"def set_product\n @product = Product.find_by!(code: params[:id])\n end",
"def set_product\n @product = Product.find(params[:id])\n\n rescue ActiveRecord::RecordNotFound\n error = { :error => \"The product you were looking for could not be found.\"}\n respond_with(error, :status => 404)\n end",
"def product\n if PRODUCT_UPDATE_MUST_HAVE.include?(Employee.where(id: session[\"found_user_id\"]).first.admin_rights)\n id = params[\"product_id\"]\n if id == \"new\"\n @product = Product.new\n @product.items_per_bunch = 100\n @product.markup = 100\n else\n @product = Product.where(florist_id: session[\"found_florist_id\"]).where(id: id).first\n end\n render(:product_updates) and return\n else\n redirect_to \"/products\" and return\n end\n end",
"def set_product\r\n\t\t\t@product = @application.products.find(params[:id])\r\n\t\tend",
"def product_id\n read('product_id')\n end",
"def get_product( row )\n puts \"get product row:\" + row.join(\"--\")\n pro = Variant.find_by_sku( at_in(:sku , row ) )\n if pro\n puts \"Found #{at_in(:sku,row)} \"\n pro.product \n else\n p = Product.create( :name => \"sku\" , :price => 5 , :sku => \"sku\")\n p.save!\n master = Variant.find_by_sku(\"sku\")\n master.product = Product.find_by_name(\"sku\")\n master.save\n Product.find_by_name(\"sku\")\n end\n end",
"def set_product_product\n @product_product = Product::Product.find(params[:id])\n end",
"def find_product\n @stock_product = Product.where(id: params[:product_id]).take\n if @stock_product.present?\n @stockitem = Stockitem.new\n else\n render json: { msg: 'Produto não existe em estoque' }\n end\n end",
"def set_product\n @product = @products.find(params[:id])\n end",
"def set_product\n @product = Product.find(params[:product_id]) if params[:product_id]\n end",
"def set_product\n @product = Product.friendly.find(params[:id])\n # logger.debug \"product #{@product.id}\"\n end",
"def set_product\n @product = Product.friendly.find(params[:product_id])\n # logger.debug \"product #{@product.id}\"\n end",
"def set_product\n @product = Product.find_by( :id => params[:id] )\n end",
"def set_product\n @product = product.find(params[:id])\n end",
"def set_product\n @product = params[:id] ? Product.find(params[:id]) : Product.find(params[:product_id])\n end",
"def check_product\n return unless product_item_params.key?(:product_id)\n\n unless Product.exists?(product_item_params[:product_id])\n raise ActiveRecord::RecordNotFound, \"Product with id='#{product_item_params[:product_id]}' not found\"\n end\n end",
"def show\n begin\n set_product\n rescue ActiveRecord::RecordNotFound\n logger.error \"Attempt to access invalid product #{params[:id]}\"\n redirect_to products_path, :notice => 'Invalid product'\n end\n end",
"def find_or_create_product(asin)\n Product.first(asin: asin) || Product.create(lookup_product(asin))\n end",
"def lookup_product(asin)\n logger.info \"Looking up product #{asin}...\"\n\n # Look the product up in Amazon.\n response = settings.vacuum.get(query: {\n 'Operation' => 'ItemLookup',\n 'IdType' => 'ASIN',\n 'ItemId' => asin,\n 'ResponseGroup' => LOOKUP_GROUPS.join(',')\n })\n # Parse the XML and remove all those pesky namespaces.\n xml = Nokogiri::XML(response.body)\n xml.remove_namespaces!\n # Extract the attributes we need from the response.\n LOOKUP_XPATHS.merge(LOOKUP_XPATHS) do |key, value|\n node = xml.xpath(value)\n node.map(&:text).join(', ') unless node.empty?\n end\n end",
"def find(product_id)\n path = \"/product-view/products/#{product_id}\"\n\n response, status = BeyondApi::Request.get(@session,\n path)\n\n handle_response(response, status)\n end",
"def set_product\n @product = Product.find_by_hashid(params[:id])\n end",
"def related_products(product_id)\n item = DirectedEdge::Item.new(@database, \"product#{product_id}\")\n item.related(['product']).map { |product| product.sub('product', '').to_i }\n end",
"def set_product\n\t @product = Product.friendly.find(params[:id])\n\t end",
"def set_product\n @product = Product.find(params[:id])\n rescue ActiveRecord::RecordNotFound\n render :json => { Status: \"KO\", Cause: t(\"products.not_found\") }.as_json, status: :not_found\n end",
"def set_product\n\t\t@product = Item.find(params[:id])\n\tend",
"def set_product\n if !@products\n @products = Product.all\n end\n price_ranges = [ {to: 10 }, {from: 10.01, to: 20 }, {from: 20.01, to: 30 }, {from: 30.01}]\n if !@producss\n @producss = Product.search \"*\", aggs: {price: {ranges: price_ranges}, category_id: {}, condition_id: {}, date: {}}\n end\n if !@producs\n @producs = Product.search(params.fetch(:name, \"*\")).to_a\n end\n end",
"def set_product\n #@product = Product.find(params[:id])\n end",
"def init_product\n @product = current_facility_products.find_by!(url_name: params[:\"#{singular_object_name}_id\"] || params[:id])\n end",
"def set_product\n @product = Product.find(params[:id])\n end",
"def set_product\n @product = Product.find(params[:id])\n end",
"def set_product\n @product = Product.find(params[:id])\n end",
"def set_product\n @product = Product.find(params[:id])\n end",
"def set_product\n @product = Product.find(params[:id])\n end",
"def set_eventproduct\n @eventproduct = Eventproduct.find(params[:id])\n end",
"def set_product\n\t\t\t@product = Product.find(params[:product_id])\n\t\tend",
"def set_product\n @products = Product.find(params[:id])\n end",
"def set_product\n @product = Product.friendly.find(params[:id])\n end",
"def set_product\n @product = Product.friendly.find(params[:id])\n end",
"def set_product\n @product = Product.friendly.find(params[:id])\n end",
"def set_product\n @product = Product.friendly.find(params[:id])\n end",
"def set_product\n @product = Product.friendly.find(params[:id])\n end",
"def set_product\n @product = Product.friendly.find(params[:id])\n end",
"def get_product_image\n @product_image = ProductImage.find_by_uuid(params[:id])\n if @product_image.nil?\n raise Repia::Errors::NotFound\n end\n end",
"def load_product\n @product = Product.find(params[:product_id])\n end",
"def set_pe_exchange_product\n @pe_exchange_product = PeExchangeProduct.find(params[:id])\n end",
"def index\n @product = @seller.products.find(params[:product_id]) \n end",
"def set_product\n @product = Product.unscoped.find(params[:id])\n end",
"def set_product\n @product = Product.find(params[:id])\n end",
"def set_product\n @product = Product.find(params[:id])\n @item = Product.find(params[:id])\n end",
"def set_product\n\t\t@product = Product.find_by_name!(params[:id].tr('-', ' '))\n\n\trescue ActiveRecord::RecordNotFound\n\t\tredirect_to :controller => 'errors', :action => 'show', :code => '404' \n\tend",
"def onix_xml_for_product(product_or_rr, full_message = false) #:nodoc:\n if product_or_rr.kind_of? Elibri::ApiClient::ApiAdapters::V1::Product\n rr = product_or_rr.record_reference\n else\n rr = product_or_rr\n end\n resp = get \"/products/#{rr}\", :headers => {\"X-eLibri-API-ONIX-dialect\" => @onix_dialect}\n if full_message\n resp.parsed_response\n else\n resp.parsed_response.css('Product').first\n end\n end",
"def set_product\n @product = Product.find(params[:product_id])\n end",
"def set_product\n @product = Product.find_by_id(params[:id])\n if @product.nil?\n render json: {success: false, message: I18n.t(\"products.does_not_exist\")}\n return\n end\n end",
"def getItem\n Product.select(:product).find(params[:id])\n end",
"def set_product\n @product = Product.find(params[:id])\n end",
"def set_product\n if params[:id] =~ /[[:alpha:]]/\n @product = Product.find_by(url: params[:id])\n else\n @product = Product.find(params[:id])\n end\n end",
"def set_product\n @product = Product.find(params[:id])\n end",
"def set_product\n @product = Product.find(params[:id])\n end",
"def set_product\n @product = Product.find(params[:id])\n end",
"def set_product\n @product = Product.find(params[:id])\n end",
"def set_product\n @product = Product.find(params[:id])\n end",
"def set_product\n @product = Product.find(params[:id])\n end",
"def set_product\n @product = Product.find(params[:id])\n end",
"def set_product\n @product = Product.find(params[:id])\n end",
"def set_product\n @product = Product.find(params[:id])\n end",
"def set_product\n @product = Product.find(params[:id])\n end"
] |
[
"0.7176233",
"0.7140765",
"0.70057446",
"0.68903685",
"0.6846688",
"0.6843145",
"0.68376046",
"0.67133564",
"0.6656534",
"0.66530675",
"0.66346174",
"0.66017276",
"0.65703595",
"0.6565071",
"0.65458477",
"0.6461577",
"0.64559615",
"0.6426951",
"0.6374022",
"0.63371766",
"0.6303903",
"0.62693506",
"0.6258005",
"0.62487227",
"0.6226303",
"0.61696875",
"0.61609036",
"0.6151132",
"0.6148335",
"0.6134528",
"0.6100375",
"0.60876083",
"0.60820585",
"0.6081808",
"0.608102",
"0.60799044",
"0.6064508",
"0.60616684",
"0.60578966",
"0.60502154",
"0.60374266",
"0.6026517",
"0.60208243",
"0.6008283",
"0.6002437",
"0.6002375",
"0.59993124",
"0.599893",
"0.5990973",
"0.5975244",
"0.59456563",
"0.59428906",
"0.59273833",
"0.59213346",
"0.590387",
"0.59014034",
"0.5891444",
"0.5890334",
"0.58763",
"0.5874223",
"0.5871687",
"0.58646345",
"0.58614016",
"0.58614016",
"0.58614016",
"0.58614016",
"0.58614016",
"0.5859326",
"0.58467686",
"0.5842428",
"0.5839915",
"0.5839915",
"0.5839915",
"0.5839915",
"0.5839915",
"0.5839915",
"0.5839108",
"0.5837437",
"0.5835527",
"0.5831101",
"0.5826868",
"0.58188987",
"0.5814248",
"0.5808598",
"0.5806604",
"0.5805303",
"0.57956463",
"0.5791018",
"0.57830566",
"0.5780318",
"0.5774388",
"0.5774388",
"0.5774388",
"0.5774388",
"0.5774388",
"0.5774388",
"0.5774388",
"0.5774388",
"0.5774388",
"0.5774388"
] |
0.5938873
|
52
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.