repo stringlengths 5 58 | path stringlengths 9 168 | func_name stringlengths 9 130 | original_string stringlengths 66 10.5k | language stringclasses 1
value | code stringlengths 66 10.5k | code_tokens list | docstring stringlengths 8 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 94 266 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
softlayer/softlayer-ruby | lib/softlayer/Account.rb | SoftLayer.Account.find_vlan_with_number | def find_vlan_with_number(vlan_number)
filter = SoftLayer::ObjectFilter.new() { |filter|
filter.accept('networkVlans.vlanNumber').when_it is vlan_number
}
vlan_data = self.service.object_mask("mask[id,vlanNumber,primaryRouter,networkSpace]").object_filter(filter).getNetworkVlans
return ... | ruby | def find_vlan_with_number(vlan_number)
filter = SoftLayer::ObjectFilter.new() { |filter|
filter.accept('networkVlans.vlanNumber').when_it is vlan_number
}
vlan_data = self.service.object_mask("mask[id,vlanNumber,primaryRouter,networkSpace]").object_filter(filter).getNetworkVlans
return ... | [
"def",
"find_vlan_with_number",
"(",
"vlan_number",
")",
"filter",
"=",
"SoftLayer",
"::",
"ObjectFilter",
".",
"new",
"(",
")",
"{",
"|",
"filter",
"|",
"filter",
".",
"accept",
"(",
"'networkVlans.vlanNumber'",
")",
".",
"when_it",
"is",
"vlan_number",
"}",
... | Searches the account's list of VLANs for the ones with the given
vlan number. This may return multiple results because a VLAN can
span different routers and you will get a separate segment for
each router.
The IDs of the different segments can be helpful for ordering
firewalls. | [
"Searches",
"the",
"account",
"s",
"list",
"of",
"VLANs",
"for",
"the",
"ones",
"with",
"the",
"given",
"vlan",
"number",
".",
"This",
"may",
"return",
"multiple",
"results",
"because",
"a",
"VLAN",
"can",
"span",
"different",
"routers",
"and",
"you",
"wil... | 48d7e0e36a3b02d832e7e303a513020a8fbde93b | https://github.com/softlayer/softlayer-ruby/blob/48d7e0e36a3b02d832e7e303a513020a8fbde93b/lib/softlayer/Account.rb#L267-L274 | train |
softlayer/softlayer-ruby | lib/softlayer/Client.rb | SoftLayer.Client.service_named | def service_named(service_name, service_options = {})
raise ArgumentError,"Please provide a service name" if service_name.nil? || service_name.empty?
# Strip whitespace from service_name and ensure that it starts with "SoftLayer_".
# If it does not, then add the prefix.
full_name = service_name... | ruby | def service_named(service_name, service_options = {})
raise ArgumentError,"Please provide a service name" if service_name.nil? || service_name.empty?
# Strip whitespace from service_name and ensure that it starts with "SoftLayer_".
# If it does not, then add the prefix.
full_name = service_name... | [
"def",
"service_named",
"(",
"service_name",
",",
"service_options",
"=",
"{",
"}",
")",
"raise",
"ArgumentError",
",",
"\"Please provide a service name\"",
"if",
"service_name",
".",
"nil?",
"||",
"service_name",
".",
"empty?",
"full_name",
"=",
"service_name",
"."... | Returns a service with the given name.
If a service has already been created by this client that same service
will be returned each time it is called for by name. Otherwise the system
will try to construct a new service object and return that.
If the service has to be created then the service_options will be pass... | [
"Returns",
"a",
"service",
"with",
"the",
"given",
"name",
"."
] | 48d7e0e36a3b02d832e7e303a513020a8fbde93b | https://github.com/softlayer/softlayer-ruby/blob/48d7e0e36a3b02d832e7e303a513020a8fbde93b/lib/softlayer/Client.rb#L170-L188 | train |
softlayer/softlayer-ruby | lib/softlayer/Service.rb | SoftLayer.Service.call_softlayer_api_with_params | def call_softlayer_api_with_params(method_name, parameters, args)
additional_headers = {};
# The client knows about authentication, so ask him for the auth headers
authentication_headers = self.client.authentication_headers
additional_headers.merge!(authentication_headers)
if parameters ... | ruby | def call_softlayer_api_with_params(method_name, parameters, args)
additional_headers = {};
# The client knows about authentication, so ask him for the auth headers
authentication_headers = self.client.authentication_headers
additional_headers.merge!(authentication_headers)
if parameters ... | [
"def",
"call_softlayer_api_with_params",
"(",
"method_name",
",",
"parameters",
",",
"args",
")",
"additional_headers",
"=",
"{",
"}",
";",
"authentication_headers",
"=",
"self",
".",
"client",
".",
"authentication_headers",
"additional_headers",
".",
"merge!",
"(",
... | Issue an HTTP request to call the given method from the SoftLayer API with
the parameters and arguments given.
Parameters are information _about_ the call, the object mask or the
particular object in the SoftLayer API you are calling.
Arguments are the arguments to the SoftLayer method that you wish to
invoke.
... | [
"Issue",
"an",
"HTTP",
"request",
"to",
"call",
"the",
"given",
"method",
"from",
"the",
"SoftLayer",
"API",
"with",
"the",
"parameters",
"and",
"arguments",
"given",
"."
] | 48d7e0e36a3b02d832e7e303a513020a8fbde93b | https://github.com/softlayer/softlayer-ruby/blob/48d7e0e36a3b02d832e7e303a513020a8fbde93b/lib/softlayer/Service.rb#L221-L276 | train |
HewlettPackard/ilo-sdk-ruby | lib/ilo-sdk/helpers/bios_helper.rb | ILO_SDK.BiosHelper.set_bios_settings | def set_bios_settings(options, system_id = 1)
r = response_handler(rest_patch("/redfish/v1/Systems/#{system_id}/bios/Settings/", body: options))
@logger.warn(r) if r['error']
true
end | ruby | def set_bios_settings(options, system_id = 1)
r = response_handler(rest_patch("/redfish/v1/Systems/#{system_id}/bios/Settings/", body: options))
@logger.warn(r) if r['error']
true
end | [
"def",
"set_bios_settings",
"(",
"options",
",",
"system_id",
"=",
"1",
")",
"r",
"=",
"response_handler",
"(",
"rest_patch",
"(",
"\"/redfish/v1/Systems/#{system_id}/bios/Settings/\"",
",",
"body",
":",
"options",
")",
")",
"@logger",
".",
"warn",
"(",
"r",
")"... | Set BIOS settings
@param options [Hash] Hash of options to set
@param system_id [Integer, String] ID of the system
@raise [RuntimeError] if the request failed
@return true | [
"Set",
"BIOS",
"settings"
] | ac171cd75d070ccf64017d43777ded40a5f018f9 | https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/bios_helper.rb#L28-L32 | train |
HewlettPackard/ilo-sdk-ruby | lib/ilo-sdk/helpers/bios_helper.rb | ILO_SDK.BiosHelper.set_uefi_shell_startup | def set_uefi_shell_startup(uefi_shell_startup, uefi_shell_startup_location, uefi_shell_startup_url)
new_action = {
'UefiShellStartup' => uefi_shell_startup,
'UefiShellStartupLocation' => uefi_shell_startup_location,
'UefiShellStartupUrl' => uefi_shell_startup_url
}
response = r... | ruby | def set_uefi_shell_startup(uefi_shell_startup, uefi_shell_startup_location, uefi_shell_startup_url)
new_action = {
'UefiShellStartup' => uefi_shell_startup,
'UefiShellStartupLocation' => uefi_shell_startup_location,
'UefiShellStartupUrl' => uefi_shell_startup_url
}
response = r... | [
"def",
"set_uefi_shell_startup",
"(",
"uefi_shell_startup",
",",
"uefi_shell_startup_location",
",",
"uefi_shell_startup_url",
")",
"new_action",
"=",
"{",
"'UefiShellStartup'",
"=>",
"uefi_shell_startup",
",",
"'UefiShellStartupLocation'",
"=>",
"uefi_shell_startup_location",
... | Set the UEFI shell start up
@param uefi_shell_startup [String, Symbol]
@param uefi_shell_startup_location [String, Symbol]
@param uefi_shell_startup_url [String, Symbol]
@raise [RuntimeError] if the request failed
@return true | [
"Set",
"the",
"UEFI",
"shell",
"start",
"up"
] | ac171cd75d070ccf64017d43777ded40a5f018f9 | https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/bios_helper.rb#L71-L80 | train |
HewlettPackard/ilo-sdk-ruby | lib/ilo-sdk/helpers/bios_helper.rb | ILO_SDK.BiosHelper.get_bios_dhcp | def get_bios_dhcp
response = rest_get('/redfish/v1/Systems/1/bios/Settings/')
bios = response_handler(response)
{
'Dhcpv4' => bios['Dhcpv4'],
'Ipv4Address' => bios['Ipv4Address'],
'Ipv4Gateway' => bios['Ipv4Gateway'],
'Ipv4PrimaryDNS' => bios['Ipv4PrimaryDNS'],
... | ruby | def get_bios_dhcp
response = rest_get('/redfish/v1/Systems/1/bios/Settings/')
bios = response_handler(response)
{
'Dhcpv4' => bios['Dhcpv4'],
'Ipv4Address' => bios['Ipv4Address'],
'Ipv4Gateway' => bios['Ipv4Gateway'],
'Ipv4PrimaryDNS' => bios['Ipv4PrimaryDNS'],
... | [
"def",
"get_bios_dhcp",
"response",
"=",
"rest_get",
"(",
"'/redfish/v1/Systems/1/bios/Settings/'",
")",
"bios",
"=",
"response_handler",
"(",
"response",
")",
"{",
"'Dhcpv4'",
"=>",
"bios",
"[",
"'Dhcpv4'",
"]",
",",
"'Ipv4Address'",
"=>",
"bios",
"[",
"'Ipv4Addr... | Get the BIOS DHCP
@raise [RuntimeError] if the request failed
@return [String] bios_dhcp | [
"Get",
"the",
"BIOS",
"DHCP"
] | ac171cd75d070ccf64017d43777ded40a5f018f9 | https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/bios_helper.rb#L85-L96 | train |
HewlettPackard/ilo-sdk-ruby | lib/ilo-sdk/helpers/bios_helper.rb | ILO_SDK.BiosHelper.set_bios_dhcp | def set_bios_dhcp(dhcpv4, ipv4_address = '', ipv4_gateway = '', ipv4_primary_dns = '', ipv4_secondary_dns = '', ipv4_subnet_mask = '')
new_action = {
'Dhcpv4' => dhcpv4,
'Ipv4Address' => ipv4_address,
'Ipv4Gateway' => ipv4_gateway,
'Ipv4PrimaryDNS' => ipv4_primary_dns,
'Ipv... | ruby | def set_bios_dhcp(dhcpv4, ipv4_address = '', ipv4_gateway = '', ipv4_primary_dns = '', ipv4_secondary_dns = '', ipv4_subnet_mask = '')
new_action = {
'Dhcpv4' => dhcpv4,
'Ipv4Address' => ipv4_address,
'Ipv4Gateway' => ipv4_gateway,
'Ipv4PrimaryDNS' => ipv4_primary_dns,
'Ipv... | [
"def",
"set_bios_dhcp",
"(",
"dhcpv4",
",",
"ipv4_address",
"=",
"''",
",",
"ipv4_gateway",
"=",
"''",
",",
"ipv4_primary_dns",
"=",
"''",
",",
"ipv4_secondary_dns",
"=",
"''",
",",
"ipv4_subnet_mask",
"=",
"''",
")",
"new_action",
"=",
"{",
"'Dhcpv4'",
"=>"... | Set the BIOS DHCP
@param dhcpv4 [String, Symbol]
@param ipv4_address [String, Symbol]
@param ipv4_gateway [String, Symbol]
@param ipv4_primary_dns [String, Symbol]
@param ipv4_secondary_dns [String, Symbol]
@param ipv4_subnet_mask [String, Symbol]
@raise [RuntimeError] if the request failed
@return true | [
"Set",
"the",
"BIOS",
"DHCP"
] | ac171cd75d070ccf64017d43777ded40a5f018f9 | https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/bios_helper.rb#L107-L119 | train |
HewlettPackard/ilo-sdk-ruby | lib/ilo-sdk/helpers/bios_helper.rb | ILO_SDK.BiosHelper.set_url_boot_file | def set_url_boot_file(url_boot_file)
new_action = { 'UrlBootFile' => url_boot_file }
response = rest_patch('/redfish/v1/Systems/1/bios/Settings/', body: new_action)
response_handler(response)
true
end | ruby | def set_url_boot_file(url_boot_file)
new_action = { 'UrlBootFile' => url_boot_file }
response = rest_patch('/redfish/v1/Systems/1/bios/Settings/', body: new_action)
response_handler(response)
true
end | [
"def",
"set_url_boot_file",
"(",
"url_boot_file",
")",
"new_action",
"=",
"{",
"'UrlBootFile'",
"=>",
"url_boot_file",
"}",
"response",
"=",
"rest_patch",
"(",
"'/redfish/v1/Systems/1/bios/Settings/'",
",",
"body",
":",
"new_action",
")",
"response_handler",
"(",
"res... | Set the URL boot file
@param url_boot_file [String, Symbol]
@raise [RuntimeError] if the request failed
@return true | [
"Set",
"the",
"URL",
"boot",
"file"
] | ac171cd75d070ccf64017d43777ded40a5f018f9 | https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/bios_helper.rb#L133-L138 | train |
HewlettPackard/ilo-sdk-ruby | lib/ilo-sdk/helpers/bios_helper.rb | ILO_SDK.BiosHelper.set_bios_service | def set_bios_service(name, email)
new_action = {
'ServiceName' => name,
'ServiceEmail' => email
}
response = rest_patch('/redfish/v1/Systems/1/bios/Settings/', body: new_action)
response_handler(response)
true
end | ruby | def set_bios_service(name, email)
new_action = {
'ServiceName' => name,
'ServiceEmail' => email
}
response = rest_patch('/redfish/v1/Systems/1/bios/Settings/', body: new_action)
response_handler(response)
true
end | [
"def",
"set_bios_service",
"(",
"name",
",",
"email",
")",
"new_action",
"=",
"{",
"'ServiceName'",
"=>",
"name",
",",
"'ServiceEmail'",
"=>",
"email",
"}",
"response",
"=",
"rest_patch",
"(",
"'/redfish/v1/Systems/1/bios/Settings/'",
",",
"body",
":",
"new_action... | Set the BIOS service
@param name [String, Symbol]
@param email [String, Symbol]
@raise [RuntimeError] if the request failed
@return true | [
"Set",
"the",
"BIOS",
"service"
] | ac171cd75d070ccf64017d43777ded40a5f018f9 | https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/bios_helper.rb#L157-L165 | train |
HewlettPackard/ilo-sdk-ruby | lib/ilo-sdk/helpers/log_entry_helper.rb | ILO_SDK.LogEntryHelper.clear_logs | def clear_logs(log_type)
new_action = { 'Action' => 'ClearLog' }
response = rest_post(uri_for_log_type(log_type), body: new_action)
response_handler(response)
true
end | ruby | def clear_logs(log_type)
new_action = { 'Action' => 'ClearLog' }
response = rest_post(uri_for_log_type(log_type), body: new_action)
response_handler(response)
true
end | [
"def",
"clear_logs",
"(",
"log_type",
")",
"new_action",
"=",
"{",
"'Action'",
"=>",
"'ClearLog'",
"}",
"response",
"=",
"rest_post",
"(",
"uri_for_log_type",
"(",
"log_type",
")",
",",
"body",
":",
"new_action",
")",
"response_handler",
"(",
"response",
")",
... | Clear the specified logs
@param [String, Symbol] log_type
@raise [RuntimeError] if the request failed
@return true | [
"Clear",
"the",
"specified",
"logs"
] | ac171cd75d070ccf64017d43777ded40a5f018f9 | https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/log_entry_helper.rb#L34-L39 | train |
HewlettPackard/ilo-sdk-ruby | lib/ilo-sdk/helpers/log_entry_helper.rb | ILO_SDK.LogEntryHelper.get_logs | def get_logs(severity_level, duration, log_type)
response = rest_get("#{uri_for_log_type(log_type)}Entries/")
entries = response_handler(response)['Items']
start_time = Time.now.utc - (duration * 3600)
if severity_level.nil?
entries.select { |e| Time.parse(e['Created']) > start_time }
... | ruby | def get_logs(severity_level, duration, log_type)
response = rest_get("#{uri_for_log_type(log_type)}Entries/")
entries = response_handler(response)['Items']
start_time = Time.now.utc - (duration * 3600)
if severity_level.nil?
entries.select { |e| Time.parse(e['Created']) > start_time }
... | [
"def",
"get_logs",
"(",
"severity_level",
",",
"duration",
",",
"log_type",
")",
"response",
"=",
"rest_get",
"(",
"\"#{uri_for_log_type(log_type)}Entries/\"",
")",
"entries",
"=",
"response_handler",
"(",
"response",
")",
"[",
"'Items'",
"]",
"start_time",
"=",
"... | Get the specified logs
@param [String, Symbol, NilClass] severity_level Set to nil to get all logs
@param [String, Symbol] duration Up to this many hours ago
@param [String, Symbol] log_type IEL or IML
@raise [RuntimeError] if the request failed
@return [Array] log entries | [
"Get",
"the",
"specified",
"logs"
] | ac171cd75d070ccf64017d43777ded40a5f018f9 | https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/log_entry_helper.rb#L56-L65 | train |
HewlettPackard/ilo-sdk-ruby | lib/ilo-sdk/helpers/computer_details_helper.rb | ILO_SDK.ComputerDetailsHelper.get_computer_details | def get_computer_details
general_computer_details = get_general_computer_details
computer_network_details = get_computer_network_details
array_controller_details = get_array_controller_details
general_computer_details.merge(computer_network_details).merge(array_controller_details)
end | ruby | def get_computer_details
general_computer_details = get_general_computer_details
computer_network_details = get_computer_network_details
array_controller_details = get_array_controller_details
general_computer_details.merge(computer_network_details).merge(array_controller_details)
end | [
"def",
"get_computer_details",
"general_computer_details",
"=",
"get_general_computer_details",
"computer_network_details",
"=",
"get_computer_network_details",
"array_controller_details",
"=",
"get_array_controller_details",
"general_computer_details",
".",
"merge",
"(",
"computer_net... | Get all of the computer details
@raise [RuntimeError] if the request failed
@return [Hash] computer_details | [
"Get",
"all",
"of",
"the",
"computer",
"details"
] | ac171cd75d070ccf64017d43777ded40a5f018f9 | https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/computer_details_helper.rb#L18-L23 | train |
HewlettPackard/ilo-sdk-ruby | lib/ilo-sdk/helpers/computer_details_helper.rb | ILO_SDK.ComputerDetailsHelper.get_general_computer_details | def get_general_computer_details
response = rest_get('/redfish/v1/Systems/1/')
details = response_handler(response)
{
'GeneralDetails' => {
'manufacturer' => details['Manufacturer'],
'model' => details['Model'],
'AssetTag' => details['AssetTag'],
'bios_v... | ruby | def get_general_computer_details
response = rest_get('/redfish/v1/Systems/1/')
details = response_handler(response)
{
'GeneralDetails' => {
'manufacturer' => details['Manufacturer'],
'model' => details['Model'],
'AssetTag' => details['AssetTag'],
'bios_v... | [
"def",
"get_general_computer_details",
"response",
"=",
"rest_get",
"(",
"'/redfish/v1/Systems/1/'",
")",
"details",
"=",
"response_handler",
"(",
"response",
")",
"{",
"'GeneralDetails'",
"=>",
"{",
"'manufacturer'",
"=>",
"details",
"[",
"'Manufacturer'",
"]",
",",
... | Get the general computer details
@raise [RuntimeError] if the request failed
@return [Fixnum] general_computer_details | [
"Get",
"the",
"general",
"computer",
"details"
] | ac171cd75d070ccf64017d43777ded40a5f018f9 | https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/computer_details_helper.rb#L28-L41 | train |
HewlettPackard/ilo-sdk-ruby | lib/ilo-sdk/helpers/computer_details_helper.rb | ILO_SDK.ComputerDetailsHelper.get_computer_network_details | def get_computer_network_details
network_adapters = []
response = rest_get('/redfish/v1/Systems/1/NetworkAdapters/')
networks = response_handler(response)['links']['Member']
networks.each do |network|
response = rest_get(network['href'])
detail = response_handler(response)
... | ruby | def get_computer_network_details
network_adapters = []
response = rest_get('/redfish/v1/Systems/1/NetworkAdapters/')
networks = response_handler(response)['links']['Member']
networks.each do |network|
response = rest_get(network['href'])
detail = response_handler(response)
... | [
"def",
"get_computer_network_details",
"network_adapters",
"=",
"[",
"]",
"response",
"=",
"rest_get",
"(",
"'/redfish/v1/Systems/1/NetworkAdapters/'",
")",
"networks",
"=",
"response_handler",
"(",
"response",
")",
"[",
"'links'",
"]",
"[",
"'Member'",
"]",
"networks... | Get the computer network details
@raise [RuntimeError] if the request failed
@return [Hash] computer_network_details | [
"Get",
"the",
"computer",
"network",
"details"
] | ac171cd75d070ccf64017d43777ded40a5f018f9 | https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/computer_details_helper.rb#L46-L76 | train |
HewlettPackard/ilo-sdk-ruby | lib/ilo-sdk/helpers/firmware_update.rb | ILO_SDK.FirmwareUpdateHelper.set_fw_upgrade | def set_fw_upgrade(uri, tpm_override_flag = true)
new_action = { 'Action' => 'InstallFromURI', 'FirmwareURI' => uri, 'TPMOverrideFlag' => tpm_override_flag }
response = rest_post('/redfish/v1/Managers/1/UpdateService/', body: new_action)
response_handler(response)
true
end | ruby | def set_fw_upgrade(uri, tpm_override_flag = true)
new_action = { 'Action' => 'InstallFromURI', 'FirmwareURI' => uri, 'TPMOverrideFlag' => tpm_override_flag }
response = rest_post('/redfish/v1/Managers/1/UpdateService/', body: new_action)
response_handler(response)
true
end | [
"def",
"set_fw_upgrade",
"(",
"uri",
",",
"tpm_override_flag",
"=",
"true",
")",
"new_action",
"=",
"{",
"'Action'",
"=>",
"'InstallFromURI'",
",",
"'FirmwareURI'",
"=>",
"uri",
",",
"'TPMOverrideFlag'",
"=>",
"tpm_override_flag",
"}",
"response",
"=",
"rest_post"... | Set the Firmware Upgrade
@param [String, Symbol] uri
@raise [RuntimeError] if the request failed
@return true | [
"Set",
"the",
"Firmware",
"Upgrade"
] | ac171cd75d070ccf64017d43777ded40a5f018f9 | https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/firmware_update.rb#L27-L32 | train |
petebrowne/sprockets-helpers | lib/sprockets/helpers.rb | Sprockets.Helpers.asset_path | def asset_path(source, options = {})
uri = URI.parse(source)
return source if uri.absolute?
options[:prefix] = Sprockets::Helpers.prefix unless options[:prefix]
if Helpers.debug || options[:debug]
options[:manifest] = false
options[:digest] = false
options[:asset_host] ... | ruby | def asset_path(source, options = {})
uri = URI.parse(source)
return source if uri.absolute?
options[:prefix] = Sprockets::Helpers.prefix unless options[:prefix]
if Helpers.debug || options[:debug]
options[:manifest] = false
options[:digest] = false
options[:asset_host] ... | [
"def",
"asset_path",
"(",
"source",
",",
"options",
"=",
"{",
"}",
")",
"uri",
"=",
"URI",
".",
"parse",
"(",
"source",
")",
"return",
"source",
"if",
"uri",
".",
"absolute?",
"options",
"[",
":prefix",
"]",
"=",
"Sprockets",
"::",
"Helpers",
".",
"p... | Returns the path to an asset either in the Sprockets environment
or the public directory. External URIs are untouched.
==== Options
* <tt>:ext</tt> - The extension to append if the source does not have one.
* <tt>:dir</tt> - The directory to prepend if the file is in the public directory.
* <tt>:digest</tt> - We... | [
"Returns",
"the",
"path",
"to",
"an",
"asset",
"either",
"in",
"the",
"Sprockets",
"environment",
"or",
"the",
"public",
"directory",
".",
"External",
"URIs",
"are",
"untouched",
"."
] | e3b952a392345432046ef7016bf60c502eb370ae | https://github.com/petebrowne/sprockets-helpers/blob/e3b952a392345432046ef7016bf60c502eb370ae/lib/sprockets/helpers.rb#L127-L151 | train |
HewlettPackard/ilo-sdk-ruby | lib/ilo-sdk/helpers/chassis_helper.rb | ILO_SDK.ChassisHelper.get_power_metrics | def get_power_metrics
chassis = rest_get('/redfish/v1/Chassis/')
chassis_uri = response_handler(chassis)['links']['Member'][0]['href']
power_metrics_uri = response_handler(rest_get(chassis_uri))['links']['PowerMetrics']['href']
response = rest_get(power_metrics_uri)
metrics = response_hand... | ruby | def get_power_metrics
chassis = rest_get('/redfish/v1/Chassis/')
chassis_uri = response_handler(chassis)['links']['Member'][0]['href']
power_metrics_uri = response_handler(rest_get(chassis_uri))['links']['PowerMetrics']['href']
response = rest_get(power_metrics_uri)
metrics = response_hand... | [
"def",
"get_power_metrics",
"chassis",
"=",
"rest_get",
"(",
"'/redfish/v1/Chassis/'",
")",
"chassis_uri",
"=",
"response_handler",
"(",
"chassis",
")",
"[",
"'links'",
"]",
"[",
"'Member'",
"]",
"[",
"0",
"]",
"[",
"'href'",
"]",
"power_metrics_uri",
"=",
"re... | Get the power metrics
@raise [RuntimeError] if the request failed
@return [Hash] power_metrics | [
"Get",
"the",
"power",
"metrics"
] | ac171cd75d070ccf64017d43777ded40a5f018f9 | https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/chassis_helper.rb#L18-L43 | train |
HewlettPackard/ilo-sdk-ruby | lib/ilo-sdk/helpers/chassis_helper.rb | ILO_SDK.ChassisHelper.get_thermal_metrics | def get_thermal_metrics
chassis = rest_get('/redfish/v1/Chassis/')
chassis_uri = response_handler(chassis)['links']['Member'][0]['href']
thermal_metrics_uri = response_handler(rest_get(chassis_uri))['links']['ThermalMetrics']['href']
response = rest_get(thermal_metrics_uri)
temperatures = ... | ruby | def get_thermal_metrics
chassis = rest_get('/redfish/v1/Chassis/')
chassis_uri = response_handler(chassis)['links']['Member'][0]['href']
thermal_metrics_uri = response_handler(rest_get(chassis_uri))['links']['ThermalMetrics']['href']
response = rest_get(thermal_metrics_uri)
temperatures = ... | [
"def",
"get_thermal_metrics",
"chassis",
"=",
"rest_get",
"(",
"'/redfish/v1/Chassis/'",
")",
"chassis_uri",
"=",
"response_handler",
"(",
"chassis",
")",
"[",
"'links'",
"]",
"[",
"'Member'",
"]",
"[",
"0",
"]",
"[",
"'href'",
"]",
"thermal_metrics_uri",
"=",
... | Get the thermal metrics
@raise [RuntimeError] if the request failed
@return [Hash] thermal_metrics | [
"Get",
"the",
"thermal",
"metrics"
] | ac171cd75d070ccf64017d43777ded40a5f018f9 | https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/chassis_helper.rb#L48-L67 | train |
HewlettPackard/ilo-sdk-ruby | lib/ilo-sdk/helpers/date_time_helper.rb | ILO_SDK.DateTimeHelper.set_time_zone | def set_time_zone(time_zone)
time_response = rest_get('/redfish/v1/Managers/1/DateTime/')
new_time_zone = response_handler(time_response)['TimeZoneList'].select { |timezone| timezone['Name'] == time_zone }
new_action = { 'TimeZone' => { 'Index' => new_time_zone[0]['Index'] } }
response = rest_pa... | ruby | def set_time_zone(time_zone)
time_response = rest_get('/redfish/v1/Managers/1/DateTime/')
new_time_zone = response_handler(time_response)['TimeZoneList'].select { |timezone| timezone['Name'] == time_zone }
new_action = { 'TimeZone' => { 'Index' => new_time_zone[0]['Index'] } }
response = rest_pa... | [
"def",
"set_time_zone",
"(",
"time_zone",
")",
"time_response",
"=",
"rest_get",
"(",
"'/redfish/v1/Managers/1/DateTime/'",
")",
"new_time_zone",
"=",
"response_handler",
"(",
"time_response",
")",
"[",
"'TimeZoneList'",
"]",
".",
"select",
"{",
"|",
"timezone",
"|"... | Set the Time Zone
@param [Fixnum] time_zone
@raise [RuntimeError] if the request failed
@return true | [
"Set",
"the",
"Time",
"Zone"
] | ac171cd75d070ccf64017d43777ded40a5f018f9 | https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/date_time_helper.rb#L27-L34 | train |
HewlettPackard/ilo-sdk-ruby | lib/ilo-sdk/helpers/date_time_helper.rb | ILO_SDK.DateTimeHelper.set_ntp | def set_ntp(use_ntp)
new_action = { 'Oem' => { 'Hp' => { 'DHCPv4' => { 'UseNTPServers' => use_ntp } } } }
response = rest_patch('/redfish/v1/Managers/1/EthernetInterfaces/1/', body: new_action)
response_handler(response)
true
end | ruby | def set_ntp(use_ntp)
new_action = { 'Oem' => { 'Hp' => { 'DHCPv4' => { 'UseNTPServers' => use_ntp } } } }
response = rest_patch('/redfish/v1/Managers/1/EthernetInterfaces/1/', body: new_action)
response_handler(response)
true
end | [
"def",
"set_ntp",
"(",
"use_ntp",
")",
"new_action",
"=",
"{",
"'Oem'",
"=>",
"{",
"'Hp'",
"=>",
"{",
"'DHCPv4'",
"=>",
"{",
"'UseNTPServers'",
"=>",
"use_ntp",
"}",
"}",
"}",
"}",
"response",
"=",
"rest_patch",
"(",
"'/redfish/v1/Managers/1/EthernetInterfaces... | Set whether or not ntp servers are being used
@param [TrueClass, FalseClass] use_ntp
@raise [RuntimeError] if the request failed
@return true | [
"Set",
"whether",
"or",
"not",
"ntp",
"servers",
"are",
"being",
"used"
] | ac171cd75d070ccf64017d43777ded40a5f018f9 | https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/date_time_helper.rb#L48-L53 | train |
HewlettPackard/ilo-sdk-ruby | lib/ilo-sdk/helpers/date_time_helper.rb | ILO_SDK.DateTimeHelper.set_ntp_servers | def set_ntp_servers(ntp_servers)
new_action = { 'StaticNTPServers' => ntp_servers }
response = rest_patch('/redfish/v1/Managers/1/DateTime/', body: new_action)
response_handler(response)
true
end | ruby | def set_ntp_servers(ntp_servers)
new_action = { 'StaticNTPServers' => ntp_servers }
response = rest_patch('/redfish/v1/Managers/1/DateTime/', body: new_action)
response_handler(response)
true
end | [
"def",
"set_ntp_servers",
"(",
"ntp_servers",
")",
"new_action",
"=",
"{",
"'StaticNTPServers'",
"=>",
"ntp_servers",
"}",
"response",
"=",
"rest_patch",
"(",
"'/redfish/v1/Managers/1/DateTime/'",
",",
"body",
":",
"new_action",
")",
"response_handler",
"(",
"response... | Set the NTP Servers
@param [Fixnum] ntp_servers
@raise [RuntimeError] if the request failed
@return true | [
"Set",
"the",
"NTP",
"Servers"
] | ac171cd75d070ccf64017d43777ded40a5f018f9 | https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/date_time_helper.rb#L67-L72 | train |
HewlettPackard/ilo-sdk-ruby | lib/ilo-sdk/cli.rb | ILO_SDK.Cli.output | def output(data = {}, indent = 0)
case @options['format']
when 'json'
puts JSON.pretty_generate(data)
when 'yaml'
puts data.to_yaml
else
# rubocop:disable Metrics/BlockNesting
if data.class == Hash
data.each do |k, v|
if v.class == Hash || v.... | ruby | def output(data = {}, indent = 0)
case @options['format']
when 'json'
puts JSON.pretty_generate(data)
when 'yaml'
puts data.to_yaml
else
# rubocop:disable Metrics/BlockNesting
if data.class == Hash
data.each do |k, v|
if v.class == Hash || v.... | [
"def",
"output",
"(",
"data",
"=",
"{",
"}",
",",
"indent",
"=",
"0",
")",
"case",
"@options",
"[",
"'format'",
"]",
"when",
"'json'",
"puts",
"JSON",
".",
"pretty_generate",
"(",
"data",
")",
"when",
"'yaml'",
"puts",
"data",
".",
"to_yaml",
"else",
... | Print output in a given format. | [
"Print",
"output",
"in",
"a",
"given",
"format",
"."
] | ac171cd75d070ccf64017d43777ded40a5f018f9 | https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/cli.rb#L223-L254 | train |
HewlettPackard/ilo-sdk-ruby | lib/ilo-sdk/helpers/boot_settings_helper.rb | ILO_SDK.BootSettingsHelper.set_boot_order | def set_boot_order(boot_order)
new_action = { 'PersistentBootConfigOrder' => boot_order }
response = rest_patch('/redfish/v1/systems/1/bios/Boot/Settings/', body: new_action)
response_handler(response)
true
end | ruby | def set_boot_order(boot_order)
new_action = { 'PersistentBootConfigOrder' => boot_order }
response = rest_patch('/redfish/v1/systems/1/bios/Boot/Settings/', body: new_action)
response_handler(response)
true
end | [
"def",
"set_boot_order",
"(",
"boot_order",
")",
"new_action",
"=",
"{",
"'PersistentBootConfigOrder'",
"=>",
"boot_order",
"}",
"response",
"=",
"rest_patch",
"(",
"'/redfish/v1/systems/1/bios/Boot/Settings/'",
",",
"body",
":",
"new_action",
")",
"response_handler",
"... | Set the boot order
@param [Fixnum] boot_order
@raise [RuntimeError] if the request failed
@return true | [
"Set",
"the",
"boot",
"order"
] | ac171cd75d070ccf64017d43777ded40a5f018f9 | https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/boot_settings_helper.rb#L45-L50 | train |
HewlettPackard/ilo-sdk-ruby | lib/ilo-sdk/helpers/boot_settings_helper.rb | ILO_SDK.BootSettingsHelper.set_temporary_boot_order | def set_temporary_boot_order(boot_target)
response = rest_get('/redfish/v1/Systems/1/')
boottargets = response_handler(response)['Boot']['BootSourceOverrideSupported']
unless boottargets.include? boot_target
raise "BootSourceOverrideTarget value - #{boot_target} is not supported. Valid values ... | ruby | def set_temporary_boot_order(boot_target)
response = rest_get('/redfish/v1/Systems/1/')
boottargets = response_handler(response)['Boot']['BootSourceOverrideSupported']
unless boottargets.include? boot_target
raise "BootSourceOverrideTarget value - #{boot_target} is not supported. Valid values ... | [
"def",
"set_temporary_boot_order",
"(",
"boot_target",
")",
"response",
"=",
"rest_get",
"(",
"'/redfish/v1/Systems/1/'",
")",
"boottargets",
"=",
"response_handler",
"(",
"response",
")",
"[",
"'Boot'",
"]",
"[",
"'BootSourceOverrideSupported'",
"]",
"unless",
"boott... | Set the temporary boot order
@param [Fixnum] boot_target
@raise [RuntimeError] if the request failed
@return true | [
"Set",
"the",
"temporary",
"boot",
"order"
] | ac171cd75d070ccf64017d43777ded40a5f018f9 | https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/boot_settings_helper.rb#L64-L74 | train |
HewlettPackard/ilo-sdk-ruby | lib/ilo-sdk/helpers/service_root_helper.rb | ILO_SDK.ServiceRootHelper.get_schema | def get_schema(schema_prefix)
response = rest_get('/redfish/v1/Schemas/')
schemas = response_handler(response)['Items']
schema = schemas.select { |s| s['Schema'].start_with?(schema_prefix) }
raise "NO schema found with this schema prefix : #{schema_prefix}" if schema.empty?
info = []
... | ruby | def get_schema(schema_prefix)
response = rest_get('/redfish/v1/Schemas/')
schemas = response_handler(response)['Items']
schema = schemas.select { |s| s['Schema'].start_with?(schema_prefix) }
raise "NO schema found with this schema prefix : #{schema_prefix}" if schema.empty?
info = []
... | [
"def",
"get_schema",
"(",
"schema_prefix",
")",
"response",
"=",
"rest_get",
"(",
"'/redfish/v1/Schemas/'",
")",
"schemas",
"=",
"response_handler",
"(",
"response",
")",
"[",
"'Items'",
"]",
"schema",
"=",
"schemas",
".",
"select",
"{",
"|",
"s",
"|",
"s",
... | Get the schema information with given prefix
@param [String, Symbol] schema_prefix
@raise [RuntimeError] if the request failed
@return [Array] schema | [
"Get",
"the",
"schema",
"information",
"with",
"given",
"prefix"
] | ac171cd75d070ccf64017d43777ded40a5f018f9 | https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/service_root_helper.rb#L19-L31 | train |
HewlettPackard/ilo-sdk-ruby | lib/ilo-sdk/helpers/service_root_helper.rb | ILO_SDK.ServiceRootHelper.get_registry | def get_registry(registry_prefix)
response = rest_get('/redfish/v1/Registries/')
registries = response_handler(response)['Items']
registry = registries.select { |reg| reg['Schema'].start_with?(registry_prefix) }
info = []
registry.each do |reg|
response = rest_get(reg['Location'][0... | ruby | def get_registry(registry_prefix)
response = rest_get('/redfish/v1/Registries/')
registries = response_handler(response)['Items']
registry = registries.select { |reg| reg['Schema'].start_with?(registry_prefix) }
info = []
registry.each do |reg|
response = rest_get(reg['Location'][0... | [
"def",
"get_registry",
"(",
"registry_prefix",
")",
"response",
"=",
"rest_get",
"(",
"'/redfish/v1/Registries/'",
")",
"registries",
"=",
"response_handler",
"(",
"response",
")",
"[",
"'Items'",
"]",
"registry",
"=",
"registries",
".",
"select",
"{",
"|",
"reg... | Get the Registry with given registry_prefix
@param [String, Symbol] registry_prefix
@raise [RuntimeError] if the request failed
@return [Array] registry | [
"Get",
"the",
"Registry",
"with",
"given",
"registry_prefix"
] | ac171cd75d070ccf64017d43777ded40a5f018f9 | https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/service_root_helper.rb#L37-L48 | train |
HewlettPackard/ilo-sdk-ruby | lib/ilo-sdk/helpers/manager_network_protocol_helper.rb | ILO_SDK.ManagerNetworkProtocolHelper.set_timeout | def set_timeout(timeout)
new_action = { 'SessionTimeoutMinutes' => timeout }
response = rest_patch('/redfish/v1/Managers/1/NetworkService/', body: new_action)
response_handler(response)
true
end | ruby | def set_timeout(timeout)
new_action = { 'SessionTimeoutMinutes' => timeout }
response = rest_patch('/redfish/v1/Managers/1/NetworkService/', body: new_action)
response_handler(response)
true
end | [
"def",
"set_timeout",
"(",
"timeout",
")",
"new_action",
"=",
"{",
"'SessionTimeoutMinutes'",
"=>",
"timeout",
"}",
"response",
"=",
"rest_patch",
"(",
"'/redfish/v1/Managers/1/NetworkService/'",
",",
"body",
":",
"new_action",
")",
"response_handler",
"(",
"response"... | Set the Session Timeout Minutes
@param [Fixnum] timeout
@raise [RuntimeError] if the request failed
@return true | [
"Set",
"the",
"Session",
"Timeout",
"Minutes"
] | ac171cd75d070ccf64017d43777ded40a5f018f9 | https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/manager_network_protocol_helper.rb#L27-L32 | train |
HewlettPackard/ilo-sdk-ruby | lib/ilo-sdk/helpers/ethernet_interface_helper.rb | ILO_SDK.EthernetInterfaceHelper.set_ilo_ipv4_dhcp | def set_ilo_ipv4_dhcp(manager_id: 1, ethernet_interface: 1)
new_action = {
'Oem' => {
'Hp' => {
'DHCPv4' => {
'Enabled' => true,
'UseDNSServers' => true,
'UseDomainName' => true,
'UseGateway' => true,
'UseNTPServer... | ruby | def set_ilo_ipv4_dhcp(manager_id: 1, ethernet_interface: 1)
new_action = {
'Oem' => {
'Hp' => {
'DHCPv4' => {
'Enabled' => true,
'UseDNSServers' => true,
'UseDomainName' => true,
'UseGateway' => true,
'UseNTPServer... | [
"def",
"set_ilo_ipv4_dhcp",
"(",
"manager_id",
":",
"1",
",",
"ethernet_interface",
":",
"1",
")",
"new_action",
"=",
"{",
"'Oem'",
"=>",
"{",
"'Hp'",
"=>",
"{",
"'DHCPv4'",
"=>",
"{",
"'Enabled'",
"=>",
"true",
",",
"'UseDNSServers'",
"=>",
"true",
",",
... | Set EthernetInterface to obtain IPv4 settings from DHCP
@param manager_id [Integer, String] ID of the Manager
@param ethernet_interface [Integer, String] ID of the EthernetInterface
@raise [RuntimeError] if the request failed
@return true | [
"Set",
"EthernetInterface",
"to",
"obtain",
"IPv4",
"settings",
"from",
"DHCP"
] | ac171cd75d070ccf64017d43777ded40a5f018f9 | https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/ethernet_interface_helper.rb#L29-L48 | train |
HewlettPackard/ilo-sdk-ruby | lib/ilo-sdk/helpers/ethernet_interface_helper.rb | ILO_SDK.EthernetInterfaceHelper.set_ilo_ipv4_static | def set_ilo_ipv4_static(ip:, netmask:, gateway: '0.0.0.0', manager_id: 1, ethernet_interface: 1)
new_action = {
'Oem' => { 'Hp' => { 'DHCPv4' => { 'Enabled' => false } } },
'IPv4Addresses' => [
'Address' => ip, 'SubnetMask' => netmask, 'Gateway' => gateway
]
}
respons... | ruby | def set_ilo_ipv4_static(ip:, netmask:, gateway: '0.0.0.0', manager_id: 1, ethernet_interface: 1)
new_action = {
'Oem' => { 'Hp' => { 'DHCPv4' => { 'Enabled' => false } } },
'IPv4Addresses' => [
'Address' => ip, 'SubnetMask' => netmask, 'Gateway' => gateway
]
}
respons... | [
"def",
"set_ilo_ipv4_static",
"(",
"ip",
":",
",",
"netmask",
":",
",",
"gateway",
":",
"'0.0.0.0'",
",",
"manager_id",
":",
"1",
",",
"ethernet_interface",
":",
"1",
")",
"new_action",
"=",
"{",
"'Oem'",
"=>",
"{",
"'Hp'",
"=>",
"{",
"'DHCPv4'",
"=>",
... | Set EthernetInterface to static IPv4 address
@param ip [String] IPv4 address
@param netmask [String] IPv4 subnet mask
@param gateway [String] IPv4 default gateway
@param manager_id [Integer, String] ID of the Manager
@param ethernet_interface [Integer, String] ID of the EthernetInterface
@raise [RuntimeError] if ... | [
"Set",
"EthernetInterface",
"to",
"static",
"IPv4",
"address"
] | ac171cd75d070ccf64017d43777ded40a5f018f9 | https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/ethernet_interface_helper.rb#L58-L68 | train |
HewlettPackard/ilo-sdk-ruby | lib/ilo-sdk/helpers/ethernet_interface_helper.rb | ILO_SDK.EthernetInterfaceHelper.set_ilo_ipv4_dns_servers | def set_ilo_ipv4_dns_servers(dns_servers:, manager_id: 1, ethernet_interface: 1)
new_action = {
'Oem' => {
'Hp' => {
'DHCPv4' => { 'UseDNSServers' => false },
'IPv4' => { 'DNSServers' => dns_servers }
}
}
}
response = rest_patch("/redfish/v1/... | ruby | def set_ilo_ipv4_dns_servers(dns_servers:, manager_id: 1, ethernet_interface: 1)
new_action = {
'Oem' => {
'Hp' => {
'DHCPv4' => { 'UseDNSServers' => false },
'IPv4' => { 'DNSServers' => dns_servers }
}
}
}
response = rest_patch("/redfish/v1/... | [
"def",
"set_ilo_ipv4_dns_servers",
"(",
"dns_servers",
":",
",",
"manager_id",
":",
"1",
",",
"ethernet_interface",
":",
"1",
")",
"new_action",
"=",
"{",
"'Oem'",
"=>",
"{",
"'Hp'",
"=>",
"{",
"'DHCPv4'",
"=>",
"{",
"'UseDNSServers'",
"=>",
"false",
"}",
... | Set EthernetInterface DNS servers
@param dns_servers [Array] list of DNS servers
@param manager_id [Integer, String] ID of the Manager
@param ethernet_interface [Integer, String] ID of the EthernetInterface
@raise [RuntimeError] if the request failed
@return true | [
"Set",
"EthernetInterface",
"DNS",
"servers"
] | ac171cd75d070ccf64017d43777ded40a5f018f9 | https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/ethernet_interface_helper.rb#L76-L88 | train |
HewlettPackard/ilo-sdk-ruby | lib/ilo-sdk/helpers/ethernet_interface_helper.rb | ILO_SDK.EthernetInterfaceHelper.set_ilo_hostname | def set_ilo_hostname(hostname:, domain_name: nil, manager_id: 1, ethernet_interface: 1)
new_action = { 'Oem' => { 'Hp' => { 'HostName' => hostname } } }
new_action['Oem']['Hp'].merge!('DHCPv4' => {}, 'DHCPv6' => {}) if domain_name
new_action['Oem']['Hp']['DHCPv4']['UseDomainName'] = false if domain_na... | ruby | def set_ilo_hostname(hostname:, domain_name: nil, manager_id: 1, ethernet_interface: 1)
new_action = { 'Oem' => { 'Hp' => { 'HostName' => hostname } } }
new_action['Oem']['Hp'].merge!('DHCPv4' => {}, 'DHCPv6' => {}) if domain_name
new_action['Oem']['Hp']['DHCPv4']['UseDomainName'] = false if domain_na... | [
"def",
"set_ilo_hostname",
"(",
"hostname",
":",
",",
"domain_name",
":",
"nil",
",",
"manager_id",
":",
"1",
",",
"ethernet_interface",
":",
"1",
")",
"new_action",
"=",
"{",
"'Oem'",
"=>",
"{",
"'Hp'",
"=>",
"{",
"'HostName'",
"=>",
"hostname",
"}",
"}... | Set iLO hostname and domain name
@param hostname [String] iLO hostname
@param domain_name [String] iLO domain name
@param manager_id [Integer, String] ID of the Manager
@param ethernet_interface [Integer, String] ID of the EthernetInterface
@raise [RuntimeError] if the request failed
@return true | [
"Set",
"iLO",
"hostname",
"and",
"domain",
"name"
] | ac171cd75d070ccf64017d43777ded40a5f018f9 | https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/ethernet_interface_helper.rb#L97-L106 | train |
HewlettPackard/ilo-sdk-ruby | lib/ilo-sdk/rest.rb | ILO_SDK.Rest.rest_api | def rest_api(type, path, options = {})
raise InvalidRequest, 'Must specify path' unless path
raise InvalidRequest, 'Must specify type' unless type
@logger.debug "Making :#{type} rest call to #{@host}#{path}"
uri = URI.parse(URI.escape("#{@host}#{path}"))
http = @disable_proxy ? Net::HTTP.... | ruby | def rest_api(type, path, options = {})
raise InvalidRequest, 'Must specify path' unless path
raise InvalidRequest, 'Must specify type' unless type
@logger.debug "Making :#{type} rest call to #{@host}#{path}"
uri = URI.parse(URI.escape("#{@host}#{path}"))
http = @disable_proxy ? Net::HTTP.... | [
"def",
"rest_api",
"(",
"type",
",",
"path",
",",
"options",
"=",
"{",
"}",
")",
"raise",
"InvalidRequest",
",",
"'Must specify path'",
"unless",
"path",
"raise",
"InvalidRequest",
",",
"'Must specify type'",
"unless",
"type",
"@logger",
".",
"debug",
"\"Making ... | Make a restful API request to the iLO
@param [Symbol] type the rest method/type Options are :get, :post, :put, :patch, and :delete
@param [String] path the path for the request. Usually starts with "/rest/"
@param [Hash] options the options for the request
@option options [String] :body Hash to be converted into js... | [
"Make",
"a",
"restful",
"API",
"request",
"to",
"the",
"iLO"
] | ac171cd75d070ccf64017d43777ded40a5f018f9 | https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/rest.rb#L30-L54 | train |
HewlettPackard/ilo-sdk-ruby | lib/ilo-sdk/rest.rb | ILO_SDK.Rest.response_handler | def response_handler(response)
case response.code.to_i
when RESPONSE_CODE_OK # Synchronous read/query
begin
return JSON.parse(response.body)
rescue JSON::ParserError => e
@logger.warn "Failed to parse JSON response. #{e}"
return response.body
end
w... | ruby | def response_handler(response)
case response.code.to_i
when RESPONSE_CODE_OK # Synchronous read/query
begin
return JSON.parse(response.body)
rescue JSON::ParserError => e
@logger.warn "Failed to parse JSON response. #{e}"
return response.body
end
w... | [
"def",
"response_handler",
"(",
"response",
")",
"case",
"response",
".",
"code",
".",
"to_i",
"when",
"RESPONSE_CODE_OK",
"begin",
"return",
"JSON",
".",
"parse",
"(",
"response",
".",
"body",
")",
"rescue",
"JSON",
"::",
"ParserError",
"=>",
"e",
"@logger"... | Handle the response for rest call.
If an asynchronous task was started, this waits for it to complete.
@param [HTTPResponse] HTTP response
@raise [ILO_SDK::BadRequest] if the request failed with a 400 status
@raise [ILO_SDK::Unauthorized] if the request failed with a 401 status
@raise [ILO_SDK::NotFound] if the ... | [
"Handle",
"the",
"response",
"for",
"rest",
"call",
".",
"If",
"an",
"asynchronous",
"task",
"was",
"started",
"this",
"waits",
"for",
"it",
"to",
"complete",
"."
] | ac171cd75d070ccf64017d43777ded40a5f018f9 | https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/rest.rb#L102-L132 | train |
HewlettPackard/ilo-sdk-ruby | lib/ilo-sdk/helpers/manager_account_helper.rb | ILO_SDK.ManagerAccountHelper.get_account_privileges | def get_account_privileges(username)
response = rest_get('/redfish/v1/AccountService/Accounts/')
accounts = response_handler(response)['Items']
accounts.each do |account|
if account['Oem']['Hp']['LoginName'] == username
return account['Oem']['Hp']['Privileges']
end
end
... | ruby | def get_account_privileges(username)
response = rest_get('/redfish/v1/AccountService/Accounts/')
accounts = response_handler(response)['Items']
accounts.each do |account|
if account['Oem']['Hp']['LoginName'] == username
return account['Oem']['Hp']['Privileges']
end
end
... | [
"def",
"get_account_privileges",
"(",
"username",
")",
"response",
"=",
"rest_get",
"(",
"'/redfish/v1/AccountService/Accounts/'",
")",
"accounts",
"=",
"response_handler",
"(",
"response",
")",
"[",
"'Items'",
"]",
"accounts",
".",
"each",
"do",
"|",
"account",
"... | Get the Privileges for a user
@param [String, Symbol] username
@raise [RuntimeError] if the request failed
@return [Hash] privileges | [
"Get",
"the",
"Privileges",
"for",
"a",
"user"
] | ac171cd75d070ccf64017d43777ded40a5f018f9 | https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/manager_account_helper.rb#L19-L27 | train |
HewlettPackard/ilo-sdk-ruby | lib/ilo-sdk/helpers/manager_account_helper.rb | ILO_SDK.ManagerAccountHelper.set_account_privileges | def set_account_privileges(username, privileges)
response = rest_get('/redfish/v1/AccountService/Accounts/')
accounts = response_handler(response)['Items']
id = '0'
accounts.each do |account|
if account['Oem']['Hp']['LoginName'] == username
id = account['Id']
break
... | ruby | def set_account_privileges(username, privileges)
response = rest_get('/redfish/v1/AccountService/Accounts/')
accounts = response_handler(response)['Items']
id = '0'
accounts.each do |account|
if account['Oem']['Hp']['LoginName'] == username
id = account['Id']
break
... | [
"def",
"set_account_privileges",
"(",
"username",
",",
"privileges",
")",
"response",
"=",
"rest_get",
"(",
"'/redfish/v1/AccountService/Accounts/'",
")",
"accounts",
"=",
"response_handler",
"(",
"response",
")",
"[",
"'Items'",
"]",
"id",
"=",
"'0'",
"accounts",
... | Set the privileges for a user
@param [TrueClass, FalseClass] username
@param [Hash] privileges
@option privileges [TrueClass, FalseClass] :LoginPriv
@option privileges [TrueClass, FalseClass] :RemoteConsolePriv
@option privileges [TrueClass, FalseClass] :UserConfigPriv
@option privileges [TrueClass, FalseClass] :... | [
"Set",
"the",
"privileges",
"for",
"a",
"user"
] | ac171cd75d070ccf64017d43777ded40a5f018f9 | https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/manager_account_helper.rb#L40-L60 | train |
HewlettPackard/ilo-sdk-ruby | lib/ilo-sdk/helpers/https_cert_helper.rb | ILO_SDK.HttpsCertHelper.get_certificate | def get_certificate
uri = URI.parse(URI.escape(@host))
options = { use_ssl: true, verify_mode: OpenSSL::SSL::VERIFY_NONE }
Net::HTTP.start(uri.host, uri.port, options) do |http|
http.peer_cert
end
end | ruby | def get_certificate
uri = URI.parse(URI.escape(@host))
options = { use_ssl: true, verify_mode: OpenSSL::SSL::VERIFY_NONE }
Net::HTTP.start(uri.host, uri.port, options) do |http|
http.peer_cert
end
end | [
"def",
"get_certificate",
"uri",
"=",
"URI",
".",
"parse",
"(",
"URI",
".",
"escape",
"(",
"@host",
")",
")",
"options",
"=",
"{",
"use_ssl",
":",
"true",
",",
"verify_mode",
":",
"OpenSSL",
"::",
"SSL",
"::",
"VERIFY_NONE",
"}",
"Net",
"::",
"HTTP",
... | Get the SSL Certificate
@raise [RuntimeError] if the request failed
@return [OpenSSL::X509::Certificate] x509_certificate
rubocop:disable Style/SymbolProc | [
"Get",
"the",
"SSL",
"Certificate"
] | ac171cd75d070ccf64017d43777ded40a5f018f9 | https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/https_cert_helper.rb#L19-L25 | train |
HewlettPackard/ilo-sdk-ruby | lib/ilo-sdk/helpers/https_cert_helper.rb | ILO_SDK.HttpsCertHelper.generate_csr | def generate_csr(country, state, city, org_name, org_unit, common_name)
new_action = {
'Action' => 'GenerateCSR',
'Country' => country,
'State' => state,
'City' => city,
'OrgName' => org_name,
'OrgUnit' => org_unit,
'CommonName' => common_name
}
... | ruby | def generate_csr(country, state, city, org_name, org_unit, common_name)
new_action = {
'Action' => 'GenerateCSR',
'Country' => country,
'State' => state,
'City' => city,
'OrgName' => org_name,
'OrgUnit' => org_unit,
'CommonName' => common_name
}
... | [
"def",
"generate_csr",
"(",
"country",
",",
"state",
",",
"city",
",",
"org_name",
",",
"org_unit",
",",
"common_name",
")",
"new_action",
"=",
"{",
"'Action'",
"=>",
"'GenerateCSR'",
",",
"'Country'",
"=>",
"country",
",",
"'State'",
"=>",
"state",
",",
"... | Generate a Certificate Signing Request
@param [String] country
@param [String] state
@param [String] city
@param [String] orgName
@param [String] orgUnit
@param [String] commonName
@raise [RuntimeError] if the request failed
@return true | [
"Generate",
"a",
"Certificate",
"Signing",
"Request"
] | ac171cd75d070ccf64017d43777ded40a5f018f9 | https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/https_cert_helper.rb#L51-L64 | train |
HewlettPackard/ilo-sdk-ruby | lib/ilo-sdk/helpers/secure_boot_helper.rb | ILO_SDK.SecureBootHelper.set_uefi_secure_boot | def set_uefi_secure_boot(secure_boot_enable)
new_action = { 'SecureBootEnable' => secure_boot_enable }
response = rest_patch('/redfish/v1/Systems/1/SecureBoot/', body: new_action)
response_handler(response)
true
end | ruby | def set_uefi_secure_boot(secure_boot_enable)
new_action = { 'SecureBootEnable' => secure_boot_enable }
response = rest_patch('/redfish/v1/Systems/1/SecureBoot/', body: new_action)
response_handler(response)
true
end | [
"def",
"set_uefi_secure_boot",
"(",
"secure_boot_enable",
")",
"new_action",
"=",
"{",
"'SecureBootEnable'",
"=>",
"secure_boot_enable",
"}",
"response",
"=",
"rest_patch",
"(",
"'/redfish/v1/Systems/1/SecureBoot/'",
",",
"body",
":",
"new_action",
")",
"response_handler"... | Set the UEFI secure boot true or false
@param [Boolean] secure_boot_enable
@raise [RuntimeError] if the request failed
@return true | [
"Set",
"the",
"UEFI",
"secure",
"boot",
"true",
"or",
"false"
] | ac171cd75d070ccf64017d43777ded40a5f018f9 | https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/secure_boot_helper.rb#L27-L32 | train |
HewlettPackard/ilo-sdk-ruby | lib/ilo-sdk/helpers/power_helper.rb | ILO_SDK.PowerHelper.set_power_state | def set_power_state(state)
new_action = { 'Action' => 'Reset', 'ResetType' => state }
response = rest_post('/redfish/v1/Systems/1/', body: new_action)
response_handler(response)
true
end | ruby | def set_power_state(state)
new_action = { 'Action' => 'Reset', 'ResetType' => state }
response = rest_post('/redfish/v1/Systems/1/', body: new_action)
response_handler(response)
true
end | [
"def",
"set_power_state",
"(",
"state",
")",
"new_action",
"=",
"{",
"'Action'",
"=>",
"'Reset'",
",",
"'ResetType'",
"=>",
"state",
"}",
"response",
"=",
"rest_post",
"(",
"'/redfish/v1/Systems/1/'",
",",
"body",
":",
"new_action",
")",
"response_handler",
"(",... | Set the Power State
@param [String, Symbol] state
@raise [RuntimeError] if the request failed
@return true | [
"Set",
"the",
"Power",
"State"
] | ac171cd75d070ccf64017d43777ded40a5f018f9 | https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/power_helper.rb#L27-L32 | train |
HewlettPackard/ilo-sdk-ruby | lib/ilo-sdk/helpers/snmp_service_helper.rb | ILO_SDK.SNMPServiceHelper.set_snmp | def set_snmp(snmp_mode, snmp_alerts)
new_action = { 'Mode' => snmp_mode, 'AlertsEnabled' => snmp_alerts }
response = rest_patch('/redfish/v1/Managers/1/SnmpService/', body: new_action)
response_handler(response)
true
end | ruby | def set_snmp(snmp_mode, snmp_alerts)
new_action = { 'Mode' => snmp_mode, 'AlertsEnabled' => snmp_alerts }
response = rest_patch('/redfish/v1/Managers/1/SnmpService/', body: new_action)
response_handler(response)
true
end | [
"def",
"set_snmp",
"(",
"snmp_mode",
",",
"snmp_alerts",
")",
"new_action",
"=",
"{",
"'Mode'",
"=>",
"snmp_mode",
",",
"'AlertsEnabled'",
"=>",
"snmp_alerts",
"}",
"response",
"=",
"rest_patch",
"(",
"'/redfish/v1/Managers/1/SnmpService/'",
",",
"body",
":",
"new... | Set the SNMP Mode and Alerts Enabled value
@param [String, Symbol] snmp_mode
@param [Boolean] snmp_alerts
@raise [RuntimeError] if the request failed
@return true | [
"Set",
"the",
"SNMP",
"Mode",
"and",
"Alerts",
"Enabled",
"value"
] | ac171cd75d070ccf64017d43777ded40a5f018f9 | https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/snmp_service_helper.rb#L36-L41 | train |
HewlettPackard/ilo-sdk-ruby | lib/ilo-sdk/helpers/virtual_media_helper.rb | ILO_SDK.VirtualMediaHelper.get_virtual_media | def get_virtual_media
response = rest_get('/redfish/v1/Managers/1/VirtualMedia/')
media = {}
response_handler(response)['links']['Member'].each do |vm|
response = rest_get(vm['href'])
virtual_media = response_handler(response)
media[virtual_media['Id']] = {
'Image' =>... | ruby | def get_virtual_media
response = rest_get('/redfish/v1/Managers/1/VirtualMedia/')
media = {}
response_handler(response)['links']['Member'].each do |vm|
response = rest_get(vm['href'])
virtual_media = response_handler(response)
media[virtual_media['Id']] = {
'Image' =>... | [
"def",
"get_virtual_media",
"response",
"=",
"rest_get",
"(",
"'/redfish/v1/Managers/1/VirtualMedia/'",
")",
"media",
"=",
"{",
"}",
"response_handler",
"(",
"response",
")",
"[",
"'links'",
"]",
"[",
"'Member'",
"]",
".",
"each",
"do",
"|",
"vm",
"|",
"respon... | Get the Virtual Media Information
@raise [RuntimeError] if the request failed
@return [String] virtual_media | [
"Get",
"the",
"Virtual",
"Media",
"Information"
] | ac171cd75d070ccf64017d43777ded40a5f018f9 | https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/virtual_media_helper.rb#L18-L30 | train |
HewlettPackard/ilo-sdk-ruby | lib/ilo-sdk/helpers/virtual_media_helper.rb | ILO_SDK.VirtualMediaHelper.insert_virtual_media | def insert_virtual_media(id, image)
new_action = {
'Action' => 'InsertVirtualMedia',
'Target' => '/Oem/Hp',
'Image' => image
}
response = rest_post("/redfish/v1/Managers/1/VirtualMedia/#{id}/", body: new_action)
response_handler(response)
true
end | ruby | def insert_virtual_media(id, image)
new_action = {
'Action' => 'InsertVirtualMedia',
'Target' => '/Oem/Hp',
'Image' => image
}
response = rest_post("/redfish/v1/Managers/1/VirtualMedia/#{id}/", body: new_action)
response_handler(response)
true
end | [
"def",
"insert_virtual_media",
"(",
"id",
",",
"image",
")",
"new_action",
"=",
"{",
"'Action'",
"=>",
"'InsertVirtualMedia'",
",",
"'Target'",
"=>",
"'/Oem/Hp'",
",",
"'Image'",
"=>",
"image",
"}",
"response",
"=",
"rest_post",
"(",
"\"/redfish/v1/Managers/1/Virt... | Insert Virtual Media
@param [String, Symbol] id
@param [String, Symbol] image
@return true | [
"Insert",
"Virtual",
"Media"
] | ac171cd75d070ccf64017d43777ded40a5f018f9 | https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/virtual_media_helper.rb#L44-L53 | train |
HewlettPackard/ilo-sdk-ruby | lib/ilo-sdk/helpers/virtual_media_helper.rb | ILO_SDK.VirtualMediaHelper.eject_virtual_media | def eject_virtual_media(id)
new_action = {
'Action' => 'EjectVirtualMedia',
'Target' => '/Oem/Hp'
}
response = rest_post("/redfish/v1/Managers/1/VirtualMedia/#{id}/", body: new_action)
response_handler(response)
true
end | ruby | def eject_virtual_media(id)
new_action = {
'Action' => 'EjectVirtualMedia',
'Target' => '/Oem/Hp'
}
response = rest_post("/redfish/v1/Managers/1/VirtualMedia/#{id}/", body: new_action)
response_handler(response)
true
end | [
"def",
"eject_virtual_media",
"(",
"id",
")",
"new_action",
"=",
"{",
"'Action'",
"=>",
"'EjectVirtualMedia'",
",",
"'Target'",
"=>",
"'/Oem/Hp'",
"}",
"response",
"=",
"rest_post",
"(",
"\"/redfish/v1/Managers/1/VirtualMedia/#{id}/\"",
",",
"body",
":",
"new_action",... | Eject Virtual Media
@param [String, Symbol] id
@return true | [
"Eject",
"Virtual",
"Media"
] | ac171cd75d070ccf64017d43777ded40a5f018f9 | https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/virtual_media_helper.rb#L58-L66 | train |
HewlettPackard/ilo-sdk-ruby | lib/ilo-sdk/helpers/computer_system_helper.rb | ILO_SDK.ComputerSystemHelper.set_asset_tag | def set_asset_tag(asset_tag)
@logger.warn '[Deprecated] `set_asset_tag` is deprecated. Please use `set_system_settings(AssetTag: <tag>)` instead.'
new_action = { 'AssetTag' => asset_tag }
response = rest_patch('/redfish/v1/Systems/1/', body: new_action)
response_handler(response)
true
... | ruby | def set_asset_tag(asset_tag)
@logger.warn '[Deprecated] `set_asset_tag` is deprecated. Please use `set_system_settings(AssetTag: <tag>)` instead.'
new_action = { 'AssetTag' => asset_tag }
response = rest_patch('/redfish/v1/Systems/1/', body: new_action)
response_handler(response)
true
... | [
"def",
"set_asset_tag",
"(",
"asset_tag",
")",
"@logger",
".",
"warn",
"'[Deprecated] `set_asset_tag` is deprecated. Please use `set_system_settings(AssetTag: <tag>)` instead.'",
"new_action",
"=",
"{",
"'AssetTag'",
"=>",
"asset_tag",
"}",
"response",
"=",
"rest_patch",
"(",
... | Set the Asset Tag
@deprecated Use {#set_system_settings} instead
@param asset_tag [String, Symbol]
@raise [RuntimeError] if the request failed
@return true | [
"Set",
"the",
"Asset",
"Tag"
] | ac171cd75d070ccf64017d43777ded40a5f018f9 | https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/computer_system_helper.rb#L48-L54 | train |
HewlettPackard/ilo-sdk-ruby | lib/ilo-sdk/helpers/computer_system_helper.rb | ILO_SDK.ComputerSystemHelper.set_indicator_led | def set_indicator_led(state)
@logger.warn '[Deprecated] `set_indicator_led` is deprecated. Please use `set_system_settings(IndicatorLED: <state>)` instead.'
new_action = { 'IndicatorLED' => state }
response = rest_patch('/redfish/v1/Systems/1/', body: new_action)
response_handler(response)
... | ruby | def set_indicator_led(state)
@logger.warn '[Deprecated] `set_indicator_led` is deprecated. Please use `set_system_settings(IndicatorLED: <state>)` instead.'
new_action = { 'IndicatorLED' => state }
response = rest_patch('/redfish/v1/Systems/1/', body: new_action)
response_handler(response)
... | [
"def",
"set_indicator_led",
"(",
"state",
")",
"@logger",
".",
"warn",
"'[Deprecated] `set_indicator_led` is deprecated. Please use `set_system_settings(IndicatorLED: <state>)` instead.'",
"new_action",
"=",
"{",
"'IndicatorLED'",
"=>",
"state",
"}",
"response",
"=",
"rest_patch"... | Set the UID indicator LED
@deprecated Use {#set_system_settings} instead
@param state [String, Symbol]
@raise [RuntimeError] if the request failed
@return true | [
"Set",
"the",
"UID",
"indicator",
"LED"
] | ac171cd75d070ccf64017d43777ded40a5f018f9 | https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/computer_system_helper.rb#L71-L77 | train |
HewlettPackard/ilo-sdk-ruby | lib/ilo-sdk/helpers/account_service_helper.rb | ILO_SDK.AccountServiceHelper.userhref | def userhref(uri, username)
response = rest_get(uri)
items = response_handler(response)['Items']
items.each do |it|
return it['links']['self']['href'] if it['UserName'] == username
end
end | ruby | def userhref(uri, username)
response = rest_get(uri)
items = response_handler(response)['Items']
items.each do |it|
return it['links']['self']['href'] if it['UserName'] == username
end
end | [
"def",
"userhref",
"(",
"uri",
",",
"username",
")",
"response",
"=",
"rest_get",
"(",
"uri",
")",
"items",
"=",
"response_handler",
"(",
"response",
")",
"[",
"'Items'",
"]",
"items",
".",
"each",
"do",
"|",
"it",
"|",
"return",
"it",
"[",
"'links'",
... | Get the HREF for a user with a specific username
@param [String, Symbol] uri
@param [String, Symbol] username
@raise [RuntimeError] if the request failed
@return [String] userhref | [
"Get",
"the",
"HREF",
"for",
"a",
"user",
"with",
"a",
"specific",
"username"
] | ac171cd75d070ccf64017d43777ded40a5f018f9 | https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/account_service_helper.rb#L20-L26 | train |
HewlettPackard/ilo-sdk-ruby | lib/ilo-sdk/helpers/account_service_helper.rb | ILO_SDK.AccountServiceHelper.create_user | def create_user(username, password)
new_action = { 'UserName' => username, 'Password' => password, 'Oem' => { 'Hp' => { 'LoginName' => username } } }
response = rest_post('/redfish/v1/AccountService/Accounts/', body: new_action)
response_handler(response)
true
end | ruby | def create_user(username, password)
new_action = { 'UserName' => username, 'Password' => password, 'Oem' => { 'Hp' => { 'LoginName' => username } } }
response = rest_post('/redfish/v1/AccountService/Accounts/', body: new_action)
response_handler(response)
true
end | [
"def",
"create_user",
"(",
"username",
",",
"password",
")",
"new_action",
"=",
"{",
"'UserName'",
"=>",
"username",
",",
"'Password'",
"=>",
"password",
",",
"'Oem'",
"=>",
"{",
"'Hp'",
"=>",
"{",
"'LoginName'",
"=>",
"username",
"}",
"}",
"}",
"response"... | Create a user
@param [String, Symbol] username
@param [String, Symbol] password
@raise [RuntimeError] if the request failed
@return true | [
"Create",
"a",
"user"
] | ac171cd75d070ccf64017d43777ded40a5f018f9 | https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/account_service_helper.rb#L41-L46 | train |
HewlettPackard/ilo-sdk-ruby | lib/ilo-sdk/helpers/account_service_helper.rb | ILO_SDK.AccountServiceHelper.change_password | def change_password(username, password)
new_action = { 'Password' => password }
userhref = userhref('/redfish/v1/AccountService/Accounts/', username)
response = rest_patch(userhref, body: new_action)
response_handler(response)
true
end | ruby | def change_password(username, password)
new_action = { 'Password' => password }
userhref = userhref('/redfish/v1/AccountService/Accounts/', username)
response = rest_patch(userhref, body: new_action)
response_handler(response)
true
end | [
"def",
"change_password",
"(",
"username",
",",
"password",
")",
"new_action",
"=",
"{",
"'Password'",
"=>",
"password",
"}",
"userhref",
"=",
"userhref",
"(",
"'/redfish/v1/AccountService/Accounts/'",
",",
"username",
")",
"response",
"=",
"rest_patch",
"(",
"use... | Change the password for a user
@param [String, Symbol] username
@param [String, Symbol] password
@raise [RuntimeError] if the request failed
@return true | [
"Change",
"the",
"password",
"for",
"a",
"user"
] | ac171cd75d070ccf64017d43777ded40a5f018f9 | https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/account_service_helper.rb#L53-L59 | train |
HewlettPackard/ilo-sdk-ruby | lib/ilo-sdk/helpers/account_service_helper.rb | ILO_SDK.AccountServiceHelper.delete_user | def delete_user(username)
userhref = userhref('/redfish/v1/AccountService/Accounts/', username)
response = rest_delete(userhref)
response_handler(response)
true
end | ruby | def delete_user(username)
userhref = userhref('/redfish/v1/AccountService/Accounts/', username)
response = rest_delete(userhref)
response_handler(response)
true
end | [
"def",
"delete_user",
"(",
"username",
")",
"userhref",
"=",
"userhref",
"(",
"'/redfish/v1/AccountService/Accounts/'",
",",
"username",
")",
"response",
"=",
"rest_delete",
"(",
"userhref",
")",
"response_handler",
"(",
"response",
")",
"true",
"end"
] | Delete a specific user
@param [String, Symbol] username
@raise [RuntimeError] if the request failed
@return true | [
"Delete",
"a",
"specific",
"user"
] | ac171cd75d070ccf64017d43777ded40a5f018f9 | https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/account_service_helper.rb#L65-L70 | train |
nledez/proxmox | lib/proxmox.rb | Proxmox.Proxmox.templates | def templates
data = http_action_get "nodes/#{@node}/storage/local/content"
template_list = {}
data.each do |ve|
name = ve['volid'].gsub(%r{local:vztmpl\/(.*).tar.gz}, '\1')
template_list[name] = ve
end
template_list
end | ruby | def templates
data = http_action_get "nodes/#{@node}/storage/local/content"
template_list = {}
data.each do |ve|
name = ve['volid'].gsub(%r{local:vztmpl\/(.*).tar.gz}, '\1')
template_list[name] = ve
end
template_list
end | [
"def",
"templates",
"data",
"=",
"http_action_get",
"\"nodes/#{@node}/storage/local/content\"",
"template_list",
"=",
"{",
"}",
"data",
".",
"each",
"do",
"|",
"ve",
"|",
"name",
"=",
"ve",
"[",
"'volid'",
"]",
".",
"gsub",
"(",
"%r{",
"\\/",
"}",
",",
"'\... | Get template list
:call-seq:
templates -> Hash
Return a Hash of all templates
Example:
templates
Example return:
{
'ubuntu-10.04-standard_10.04-4_i386' => {
'format' => 'tgz',
'content' => 'vztmpl',
'volid' => 'local:vztmpl/ubuntu-10.04-standard_10.04-4_i386.tar.gz',
... | [
"Get",
"template",
"list"
] | cc679cc69deb78b20f88074b235e172869070a0d | https://github.com/nledez/proxmox/blob/cc679cc69deb78b20f88074b235e172869070a0d/lib/proxmox.rb#L108-L116 | train |
nledez/proxmox | lib/proxmox.rb | Proxmox.Proxmox.openvz_get | def openvz_get
data = http_action_get "nodes/#{@node}/openvz"
ve_list = {}
data.each do |ve|
ve_list[ve['vmid']] = ve
end
ve_list
end | ruby | def openvz_get
data = http_action_get "nodes/#{@node}/openvz"
ve_list = {}
data.each do |ve|
ve_list[ve['vmid']] = ve
end
ve_list
end | [
"def",
"openvz_get",
"data",
"=",
"http_action_get",
"\"nodes/#{@node}/openvz\"",
"ve_list",
"=",
"{",
"}",
"data",
".",
"each",
"do",
"|",
"ve",
"|",
"ve_list",
"[",
"ve",
"[",
"'vmid'",
"]",
"]",
"=",
"ve",
"end",
"ve_list",
"end"
] | Get CT list
:call-seq:
openvz_get -> Hash
Return a Hash of all openvz container
Example:
openvz_get
Example return:
{
'101' => {
'maxswap' => 536870912,
'disk' => 405168128,
'ip' => '192.168.1.5',
'status' => 'running',
'netout' => 272,
... | [
"Get",
"CT",
"list"
] | cc679cc69deb78b20f88074b235e172869070a0d | https://github.com/nledez/proxmox/blob/cc679cc69deb78b20f88074b235e172869070a0d/lib/proxmox.rb#L155-L162 | train |
nledez/proxmox | lib/proxmox.rb | Proxmox.Proxmox.openvz_post | def openvz_post(ostemplate, vmid, config = {})
config['vmid'] = vmid
config['ostemplate'] = "local%3Avztmpl%2F#{ostemplate}.tar.gz"
vm_definition = config.to_a.map { |v| v.join '=' }.join '&'
http_action_post("nodes/#{@node}/openvz", vm_definition)
end | ruby | def openvz_post(ostemplate, vmid, config = {})
config['vmid'] = vmid
config['ostemplate'] = "local%3Avztmpl%2F#{ostemplate}.tar.gz"
vm_definition = config.to_a.map { |v| v.join '=' }.join '&'
http_action_post("nodes/#{@node}/openvz", vm_definition)
end | [
"def",
"openvz_post",
"(",
"ostemplate",
",",
"vmid",
",",
"config",
"=",
"{",
"}",
")",
"config",
"[",
"'vmid'",
"]",
"=",
"vmid",
"config",
"[",
"'ostemplate'",
"]",
"=",
"\"local%3Avztmpl%2F#{ostemplate}.tar.gz\"",
"vm_definition",
"=",
"config",
".",
"to_a... | Create CT container
:call-seq:
openvz_post(ostemplate, vmid) -> String
openvz_post(ostemplate, vmid, options) -> String
Return a String as task ID
Examples:
openvz_post('ubuntu-10.04-standard_10.04-4_i386', 200)
openvz_post('ubuntu-10.04-standard_10.04-4_i386', 200, {'hostname' => 'test.test.com', 'p... | [
"Create",
"CT",
"container"
] | cc679cc69deb78b20f88074b235e172869070a0d | https://github.com/nledez/proxmox/blob/cc679cc69deb78b20f88074b235e172869070a0d/lib/proxmox.rb#L181-L187 | train |
nledez/proxmox | lib/proxmox.rb | Proxmox.Proxmox.create_ticket | def create_ticket
post_param = { username: @username, realm: @realm, password: @password }
@site['access/ticket'].post post_param do |response, _request, _result, &_block|
if response.code == 200
extract_ticket response
else
@connection_status = 'error'
end
... | ruby | def create_ticket
post_param = { username: @username, realm: @realm, password: @password }
@site['access/ticket'].post post_param do |response, _request, _result, &_block|
if response.code == 200
extract_ticket response
else
@connection_status = 'error'
end
... | [
"def",
"create_ticket",
"post_param",
"=",
"{",
"username",
":",
"@username",
",",
"realm",
":",
"@realm",
",",
"password",
":",
"@password",
"}",
"@site",
"[",
"'access/ticket'",
"]",
".",
"post",
"post_param",
"do",
"|",
"response",
",",
"_request",
",",
... | Methods manages auth | [
"Methods",
"manages",
"auth"
] | cc679cc69deb78b20f88074b235e172869070a0d | https://github.com/nledez/proxmox/blob/cc679cc69deb78b20f88074b235e172869070a0d/lib/proxmox.rb#L340-L349 | train |
nledez/proxmox | lib/proxmox.rb | Proxmox.Proxmox.extract_ticket | def extract_ticket(response)
data = JSON.parse(response.body)
ticket = data['data']['ticket']
csrf_prevention_token = data['data']['CSRFPreventionToken']
unless ticket.nil?
token = 'PVEAuthCookie=' + ticket.gsub!(/:/, '%3A').gsub!(/=/, '%3D')
end
@connection_status = 'connect... | ruby | def extract_ticket(response)
data = JSON.parse(response.body)
ticket = data['data']['ticket']
csrf_prevention_token = data['data']['CSRFPreventionToken']
unless ticket.nil?
token = 'PVEAuthCookie=' + ticket.gsub!(/:/, '%3A').gsub!(/=/, '%3D')
end
@connection_status = 'connect... | [
"def",
"extract_ticket",
"(",
"response",
")",
"data",
"=",
"JSON",
".",
"parse",
"(",
"response",
".",
"body",
")",
"ticket",
"=",
"data",
"[",
"'data'",
"]",
"[",
"'ticket'",
"]",
"csrf_prevention_token",
"=",
"data",
"[",
"'data'",
"]",
"[",
"'CSRFPre... | Method create ticket | [
"Method",
"create",
"ticket"
] | cc679cc69deb78b20f88074b235e172869070a0d | https://github.com/nledez/proxmox/blob/cc679cc69deb78b20f88074b235e172869070a0d/lib/proxmox.rb#L352-L364 | train |
nledez/proxmox | lib/proxmox.rb | Proxmox.Proxmox.check_response | def check_response(response)
if response.code == 200
JSON.parse(response.body)['data']
else
'NOK: error code = ' + response.code.to_s
end
end | ruby | def check_response(response)
if response.code == 200
JSON.parse(response.body)['data']
else
'NOK: error code = ' + response.code.to_s
end
end | [
"def",
"check_response",
"(",
"response",
")",
"if",
"response",
".",
"code",
"==",
"200",
"JSON",
".",
"parse",
"(",
"response",
".",
"body",
")",
"[",
"'data'",
"]",
"else",
"'NOK: error code = '",
"+",
"response",
".",
"code",
".",
"to_s",
"end",
"end... | Extract data or return error | [
"Extract",
"data",
"or",
"return",
"error"
] | cc679cc69deb78b20f88074b235e172869070a0d | https://github.com/nledez/proxmox/blob/cc679cc69deb78b20f88074b235e172869070a0d/lib/proxmox.rb#L367-L373 | train |
nledez/proxmox | lib/proxmox.rb | Proxmox.Proxmox.http_action_post | def http_action_post(url, data = {})
@site[url].post data, @auth_params do |response, _request, _result, &_block|
check_response response
end
end | ruby | def http_action_post(url, data = {})
@site[url].post data, @auth_params do |response, _request, _result, &_block|
check_response response
end
end | [
"def",
"http_action_post",
"(",
"url",
",",
"data",
"=",
"{",
"}",
")",
"@site",
"[",
"url",
"]",
".",
"post",
"data",
",",
"@auth_params",
"do",
"|",
"response",
",",
"_request",
",",
"_result",
",",
"&",
"_block",
"|",
"check_response",
"response",
"... | Methods manage http dialogs | [
"Methods",
"manage",
"http",
"dialogs"
] | cc679cc69deb78b20f88074b235e172869070a0d | https://github.com/nledez/proxmox/blob/cc679cc69deb78b20f88074b235e172869070a0d/lib/proxmox.rb#L376-L380 | train |
farcaller/rly | lib/rly/lex.rb | Rly.Lex.next | def next
while @pos < @input.length
if self.class.ignores_list[@input[@pos]]
ignore_symbol
next
end
m = self.class.token_regexps.match(@input[@pos..-1])
if m && ! m[0].empty?
val = nil
type = nil
resolved_type = nil
m.na... | ruby | def next
while @pos < @input.length
if self.class.ignores_list[@input[@pos]]
ignore_symbol
next
end
m = self.class.token_regexps.match(@input[@pos..-1])
if m && ! m[0].empty?
val = nil
type = nil
resolved_type = nil
m.na... | [
"def",
"next",
"while",
"@pos",
"<",
"@input",
".",
"length",
"if",
"self",
".",
"class",
".",
"ignores_list",
"[",
"@input",
"[",
"@pos",
"]",
"]",
"ignore_symbol",
"next",
"end",
"m",
"=",
"self",
".",
"class",
".",
"token_regexps",
".",
"match",
"("... | Processes the next token in input
This is the main interface to lexer. It returns next available token or **nil**
if there are no more tokens available in the input string.
{#each} Raises {LexError} if the input cannot be processed. This happens if
there were no matches by 'token' rules and no matches by 'literal... | [
"Processes",
"the",
"next",
"token",
"in",
"input"
] | d5a58194f73a15adb4d7c9940557838641bb2a31 | https://github.com/farcaller/rly/blob/d5a58194f73a15adb4d7c9940557838641bb2a31/lib/rly/lex.rb#L119-L176 | train |
eltiare/carrierwave-vips | lib/carrierwave/vips.rb | CarrierWave.Vips.auto_orient | def auto_orient
manipulate! do |image|
o = image.get('exif-Orientation').to_i rescue nil
o ||= image.get('exif-ifd0-Orientation').to_i rescue 1
case o
when 1
# Do nothing, everything is peachy
when 6
image.rot270
when 8
imag... | ruby | def auto_orient
manipulate! do |image|
o = image.get('exif-Orientation').to_i rescue nil
o ||= image.get('exif-ifd0-Orientation').to_i rescue 1
case o
when 1
# Do nothing, everything is peachy
when 6
image.rot270
when 8
imag... | [
"def",
"auto_orient",
"manipulate!",
"do",
"|",
"image",
"|",
"o",
"=",
"image",
".",
"get",
"(",
"'exif-Orientation'",
")",
".",
"to_i",
"rescue",
"nil",
"o",
"||=",
"image",
".",
"get",
"(",
"'exif-ifd0-Orientation'",
")",
".",
"to_i",
"rescue",
"1",
"... | Read the camera EXIF data to determine orientation and adjust accordingly | [
"Read",
"the",
"camera",
"EXIF",
"data",
"to",
"determine",
"orientation",
"and",
"adjust",
"accordingly"
] | d09a95513e0b54dca18264b63944ae31b2368bda | https://github.com/eltiare/carrierwave-vips/blob/d09a95513e0b54dca18264b63944ae31b2368bda/lib/carrierwave/vips.rb#L55-L74 | train |
eltiare/carrierwave-vips | lib/carrierwave/vips.rb | CarrierWave.Vips.convert | def convert(f, opts = {})
opts = opts.dup
f = f.to_s.downcase
allowed = %w(jpeg jpg png)
raise ArgumentError, "Format must be one of: #{allowed.join(',')}" unless allowed.include?(f)
self.format_override = f == 'jpeg' ? 'jpg' : f
opts[:Q] = opts.delete(:quality) if opts.has_key?(:qua... | ruby | def convert(f, opts = {})
opts = opts.dup
f = f.to_s.downcase
allowed = %w(jpeg jpg png)
raise ArgumentError, "Format must be one of: #{allowed.join(',')}" unless allowed.include?(f)
self.format_override = f == 'jpeg' ? 'jpg' : f
opts[:Q] = opts.delete(:quality) if opts.has_key?(:qua... | [
"def",
"convert",
"(",
"f",
",",
"opts",
"=",
"{",
"}",
")",
"opts",
"=",
"opts",
".",
"dup",
"f",
"=",
"f",
".",
"to_s",
".",
"downcase",
"allowed",
"=",
"%w(",
"jpeg",
"jpg",
"png",
")",
"raise",
"ArgumentError",
",",
"\"Format must be one of: #{allo... | Convert the file to a different format
=== Parameters
[f (String)] the format for the file format (jpeg, png)
[opts (Hash)] options to be passed to converting function (ie, :interlace => true for png) | [
"Convert",
"the",
"file",
"to",
"a",
"different",
"format"
] | d09a95513e0b54dca18264b63944ae31b2368bda | https://github.com/eltiare/carrierwave-vips/blob/d09a95513e0b54dca18264b63944ae31b2368bda/lib/carrierwave/vips.rb#L106-L115 | train |
eltiare/carrierwave-vips | lib/carrierwave/vips.rb | CarrierWave.Vips.resize_to_fill | def resize_to_fill(new_width, new_height)
manipulate! do |image|
image = resize_image image, new_width, new_height, :max
if image.width > new_width
top = 0
left = (image.width - new_width) / 2
elsif image.height > new_height
left = 0
top = (image.h... | ruby | def resize_to_fill(new_width, new_height)
manipulate! do |image|
image = resize_image image, new_width, new_height, :max
if image.width > new_width
top = 0
left = (image.width - new_width) / 2
elsif image.height > new_height
left = 0
top = (image.h... | [
"def",
"resize_to_fill",
"(",
"new_width",
",",
"new_height",
")",
"manipulate!",
"do",
"|",
"image",
"|",
"image",
"=",
"resize_image",
"image",
",",
"new_width",
",",
"new_height",
",",
":max",
"if",
"image",
".",
"width",
">",
"new_width",
"top",
"=",
"... | Resize the image to fit within the specified dimensions while retaining
the aspect ratio of the original image. If necessary, crop the image in
the larger dimension.
=== Parameters
[width (Integer)] the width to scale the image to
[height (Integer)] the height to scale the image to | [
"Resize",
"the",
"image",
"to",
"fit",
"within",
"the",
"specified",
"dimensions",
"while",
"retaining",
"the",
"aspect",
"ratio",
"of",
"the",
"original",
"image",
".",
"If",
"necessary",
"crop",
"the",
"image",
"in",
"the",
"larger",
"dimension",
"."
] | d09a95513e0b54dca18264b63944ae31b2368bda | https://github.com/eltiare/carrierwave-vips/blob/d09a95513e0b54dca18264b63944ae31b2368bda/lib/carrierwave/vips.rb#L146-L170 | train |
eltiare/carrierwave-vips | lib/carrierwave/vips.rb | CarrierWave.Vips.resize_to_limit | def resize_to_limit(new_width, new_height)
manipulate! do |image|
image = resize_image(image,new_width,new_height) if new_width < image.width || new_height < image.height
image
end
end | ruby | def resize_to_limit(new_width, new_height)
manipulate! do |image|
image = resize_image(image,new_width,new_height) if new_width < image.width || new_height < image.height
image
end
end | [
"def",
"resize_to_limit",
"(",
"new_width",
",",
"new_height",
")",
"manipulate!",
"do",
"|",
"image",
"|",
"image",
"=",
"resize_image",
"(",
"image",
",",
"new_width",
",",
"new_height",
")",
"if",
"new_width",
"<",
"image",
".",
"width",
"||",
"new_height... | Resize the image to fit within the specified dimensions while retaining
the original aspect ratio. Will only resize the image if it is larger than the
specified dimensions. The resulting image may be shorter or narrower than specified
in the smaller dimension but will not be larger than the specified values.
=== P... | [
"Resize",
"the",
"image",
"to",
"fit",
"within",
"the",
"specified",
"dimensions",
"while",
"retaining",
"the",
"original",
"aspect",
"ratio",
".",
"Will",
"only",
"resize",
"the",
"image",
"if",
"it",
"is",
"larger",
"than",
"the",
"specified",
"dimensions",
... | d09a95513e0b54dca18264b63944ae31b2368bda | https://github.com/eltiare/carrierwave-vips/blob/d09a95513e0b54dca18264b63944ae31b2368bda/lib/carrierwave/vips.rb#L183-L188 | train |
prometheus-ev/jekyll-localization | lib/jekyll/localization.rb | Jekyll.Convertible.read_yaml | def read_yaml(base, name, alt = true)
_localization_original_read_yaml(base, name)
read_alternate_language_content(base, name) if alt && content.empty?
end | ruby | def read_yaml(base, name, alt = true)
_localization_original_read_yaml(base, name)
read_alternate_language_content(base, name) if alt && content.empty?
end | [
"def",
"read_yaml",
"(",
"base",
",",
"name",
",",
"alt",
"=",
"true",
")",
"_localization_original_read_yaml",
"(",
"base",
",",
"name",
")",
"read_alternate_language_content",
"(",
"base",
",",
"name",
")",
"if",
"alt",
"&&",
"content",
".",
"empty?",
"end... | Overwrites the original method to optionally set the content of a
file with no content in it to the content of a file with another
language which does have content in it. | [
"Overwrites",
"the",
"original",
"method",
"to",
"optionally",
"set",
"the",
"content",
"of",
"a",
"file",
"with",
"no",
"content",
"in",
"it",
"to",
"the",
"content",
"of",
"a",
"file",
"with",
"another",
"language",
"which",
"does",
"have",
"content",
"i... | 753a293f0efbb252a6a0e1161994ac65d0c50e60 | https://github.com/prometheus-ev/jekyll-localization/blob/753a293f0efbb252a6a0e1161994ac65d0c50e60/lib/jekyll/localization.rb#L187-L190 | train |
prometheus-ev/jekyll-localization | lib/jekyll/localization.rb | Jekyll.Page.destination | def destination(dest)
# The url needs to be unescaped in order to preserve the correct filename
path = File.join(dest, @dir, CGI.unescape(url))
if ext == '.html' && _localization_original_url !~ /\.html\z/
path.sub!(Localization::LANG_END_RE, '')
File.join(path, "index#{ext}#{@lang_ex... | ruby | def destination(dest)
# The url needs to be unescaped in order to preserve the correct filename
path = File.join(dest, @dir, CGI.unescape(url))
if ext == '.html' && _localization_original_url !~ /\.html\z/
path.sub!(Localization::LANG_END_RE, '')
File.join(path, "index#{ext}#{@lang_ex... | [
"def",
"destination",
"(",
"dest",
")",
"path",
"=",
"File",
".",
"join",
"(",
"dest",
",",
"@dir",
",",
"CGI",
".",
"unescape",
"(",
"url",
")",
")",
"if",
"ext",
"==",
"'.html'",
"&&",
"_localization_original_url",
"!~",
"/",
"\\.",
"\\z",
"/",
"pa... | Overwrites the original method to cater for language extension in output
file name. | [
"Overwrites",
"the",
"original",
"method",
"to",
"cater",
"for",
"language",
"extension",
"in",
"output",
"file",
"name",
"."
] | 753a293f0efbb252a6a0e1161994ac65d0c50e60 | https://github.com/prometheus-ev/jekyll-localization/blob/753a293f0efbb252a6a0e1161994ac65d0c50e60/lib/jekyll/localization.rb#L207-L217 | train |
prometheus-ev/jekyll-localization | lib/jekyll/localization.rb | Jekyll.Page.process | def process(name)
self.ext = File.extname(name)
self.basename = name[0 .. -self.ext.length-1].
sub(Localization::LANG_END_RE, '')
end | ruby | def process(name)
self.ext = File.extname(name)
self.basename = name[0 .. -self.ext.length-1].
sub(Localization::LANG_END_RE, '')
end | [
"def",
"process",
"(",
"name",
")",
"self",
".",
"ext",
"=",
"File",
".",
"extname",
"(",
"name",
")",
"self",
".",
"basename",
"=",
"name",
"[",
"0",
"..",
"-",
"self",
".",
"ext",
".",
"length",
"-",
"1",
"]",
".",
"sub",
"(",
"Localization",
... | Overwrites the original method to filter the language extension from
basename | [
"Overwrites",
"the",
"original",
"method",
"to",
"filter",
"the",
"language",
"extension",
"from",
"basename"
] | 753a293f0efbb252a6a0e1161994ac65d0c50e60 | https://github.com/prometheus-ev/jekyll-localization/blob/753a293f0efbb252a6a0e1161994ac65d0c50e60/lib/jekyll/localization.rb#L223-L227 | train |
4commerce-technologies-AG/midi-smtp-server | lib/midi-smtp-server.rb | MidiSmtpServer.Smtpd.stop | def stop(wait_seconds_before_close = 2, gracefully = true)
# always signal shutdown
shutdown if gracefully
# wait if some connection(s) need(s) more time to handle shutdown
sleep wait_seconds_before_close if connections?
# drop tcp_servers while raising SmtpdStopServiceException
@con... | ruby | def stop(wait_seconds_before_close = 2, gracefully = true)
# always signal shutdown
shutdown if gracefully
# wait if some connection(s) need(s) more time to handle shutdown
sleep wait_seconds_before_close if connections?
# drop tcp_servers while raising SmtpdStopServiceException
@con... | [
"def",
"stop",
"(",
"wait_seconds_before_close",
"=",
"2",
",",
"gracefully",
"=",
"true",
")",
"shutdown",
"if",
"gracefully",
"sleep",
"wait_seconds_before_close",
"if",
"connections?",
"@connections_mutex",
".",
"synchronize",
"do",
"@tcp_server_threads",
".",
"eac... | Stop the server | [
"Stop",
"the",
"server"
] | b86a3268ebd32b46854659a2edc1eddaf86adb7b | https://github.com/4commerce-technologies-AG/midi-smtp-server/blob/b86a3268ebd32b46854659a2edc1eddaf86adb7b/lib/midi-smtp-server.rb#L48-L61 | train |
4commerce-technologies-AG/midi-smtp-server | lib/midi-smtp-server.rb | MidiSmtpServer.Smtpd.on_auth_event | def on_auth_event(ctx, authorization_id, authentication_id, authentication)
# if authentification is used, override this event
# and implement your own user management.
# otherwise all authentifications are blocked per default
logger.debug("Deny access from #{ctx[:server][:remote_ip]}:#{ctx[:ser... | ruby | def on_auth_event(ctx, authorization_id, authentication_id, authentication)
# if authentification is used, override this event
# and implement your own user management.
# otherwise all authentifications are blocked per default
logger.debug("Deny access from #{ctx[:server][:remote_ip]}:#{ctx[:ser... | [
"def",
"on_auth_event",
"(",
"ctx",
",",
"authorization_id",
",",
"authentication_id",
",",
"authentication",
")",
"logger",
".",
"debug",
"(",
"\"Deny access from #{ctx[:server][:remote_ip]}:#{ctx[:server][:remote_port]} for #{authentication_id}\"",
"+",
"(",
"authorization_id",... | check the authentification on AUTH
if any value returned, that will be used for ongoing processing
otherwise the original value will be used for authorization_id | [
"check",
"the",
"authentification",
"on",
"AUTH",
"if",
"any",
"value",
"returned",
"that",
"will",
"be",
"used",
"for",
"ongoing",
"processing",
"otherwise",
"the",
"original",
"value",
"will",
"be",
"used",
"for",
"authorization_id"
] | b86a3268ebd32b46854659a2edc1eddaf86adb7b | https://github.com/4commerce-technologies-AG/midi-smtp-server/blob/b86a3268ebd32b46854659a2edc1eddaf86adb7b/lib/midi-smtp-server.rb#L296-L302 | train |
4commerce-technologies-AG/midi-smtp-server | lib/midi-smtp-server.rb | MidiSmtpServer.Smtpd.serve_service | def serve_service
raise 'Service was already started' unless stopped?
# set flag to signal shutdown by stop / shutdown command
@shutdown = false
# instantiate the service for alls @hosts and @ports
@hosts.each_with_index do |host, index|
# instantiate the service for each host an... | ruby | def serve_service
raise 'Service was already started' unless stopped?
# set flag to signal shutdown by stop / shutdown command
@shutdown = false
# instantiate the service for alls @hosts and @ports
@hosts.each_with_index do |host, index|
# instantiate the service for each host an... | [
"def",
"serve_service",
"raise",
"'Service was already started'",
"unless",
"stopped?",
"@shutdown",
"=",
"false",
"@hosts",
".",
"each_with_index",
"do",
"|",
"host",
",",
"index",
"|",
"ports_for_host",
"=",
"(",
"index",
"<",
"@ports",
".",
"length",
"?",
"@p... | Start the listeners for all hosts | [
"Start",
"the",
"listeners",
"for",
"all",
"hosts"
] | b86a3268ebd32b46854659a2edc1eddaf86adb7b | https://github.com/4commerce-technologies-AG/midi-smtp-server/blob/b86a3268ebd32b46854659a2edc1eddaf86adb7b/lib/midi-smtp-server.rb#L347-L367 | train |
4commerce-technologies-AG/midi-smtp-server | lib/midi-smtp-server.rb | MidiSmtpServer.Smtpd.serve_service_on_host_and_port | def serve_service_on_host_and_port(host, port)
# log information
logger.info('Running service on ' + (host == '' ? '<any>' : host) + ':' + port.to_s)
# instantiate the service for host and port
# if host is empty "" wildcard (all) interfaces are used
# otherwise it will be bind to single h... | ruby | def serve_service_on_host_and_port(host, port)
# log information
logger.info('Running service on ' + (host == '' ? '<any>' : host) + ':' + port.to_s)
# instantiate the service for host and port
# if host is empty "" wildcard (all) interfaces are used
# otherwise it will be bind to single h... | [
"def",
"serve_service_on_host_and_port",
"(",
"host",
",",
"port",
")",
"logger",
".",
"info",
"(",
"'Running service on '",
"+",
"(",
"host",
"==",
"''",
"?",
"'<any>'",
":",
"host",
")",
"+",
"':'",
"+",
"port",
".",
"to_s",
")",
"tcp_server",
"=",
"TC... | Start the listener thread on single host and port | [
"Start",
"the",
"listener",
"thread",
"on",
"single",
"host",
"and",
"port"
] | b86a3268ebd32b46854659a2edc1eddaf86adb7b | https://github.com/4commerce-technologies-AG/midi-smtp-server/blob/b86a3268ebd32b46854659a2edc1eddaf86adb7b/lib/midi-smtp-server.rb#L370-L455 | train |
4commerce-technologies-AG/midi-smtp-server | lib/midi-smtp-server.rb | MidiSmtpServer.Smtpd.process_reset_session | def process_reset_session(session, connection_initialize = false)
# set active command sequence info
session[:cmd_sequence] = connection_initialize ? :CMD_HELO : :CMD_RSET
# drop any auth challenge
session[:auth_challenge] = {}
# test existing of :ctx hash
session[:ctx] || session[:c... | ruby | def process_reset_session(session, connection_initialize = false)
# set active command sequence info
session[:cmd_sequence] = connection_initialize ? :CMD_HELO : :CMD_RSET
# drop any auth challenge
session[:auth_challenge] = {}
# test existing of :ctx hash
session[:ctx] || session[:c... | [
"def",
"process_reset_session",
"(",
"session",
",",
"connection_initialize",
"=",
"false",
")",
"session",
"[",
":cmd_sequence",
"]",
"=",
"connection_initialize",
"?",
":CMD_HELO",
":",
":CMD_RSET",
"session",
"[",
":auth_challenge",
"]",
"=",
"{",
"}",
"session... | reset the context of current smtpd dialog | [
"reset",
"the",
"context",
"of",
"current",
"smtpd",
"dialog"
] | b86a3268ebd32b46854659a2edc1eddaf86adb7b | https://github.com/4commerce-technologies-AG/midi-smtp-server/blob/b86a3268ebd32b46854659a2edc1eddaf86adb7b/lib/midi-smtp-server.rb#L1048-L1098 | train |
4commerce-technologies-AG/midi-smtp-server | lib/midi-smtp-server.rb | MidiSmtpServer.Smtpd.process_auth_plain | def process_auth_plain(session, encoded_auth_response)
begin
# extract auth id (and password)
@auth_values = Base64.decode64(encoded_auth_response).split("\x00")
# check for valid credentials parameters
raise Smtpd500Exception unless @auth_values.length == 3
# call event fu... | ruby | def process_auth_plain(session, encoded_auth_response)
begin
# extract auth id (and password)
@auth_values = Base64.decode64(encoded_auth_response).split("\x00")
# check for valid credentials parameters
raise Smtpd500Exception unless @auth_values.length == 3
# call event fu... | [
"def",
"process_auth_plain",
"(",
"session",
",",
"encoded_auth_response",
")",
"begin",
"@auth_values",
"=",
"Base64",
".",
"decode64",
"(",
"encoded_auth_response",
")",
".",
"split",
"(",
"\"\\x00\"",
")",
"raise",
"Smtpd500Exception",
"unless",
"@auth_values",
"... | handle plain authentification | [
"handle",
"plain",
"authentification"
] | b86a3268ebd32b46854659a2edc1eddaf86adb7b | https://github.com/4commerce-technologies-AG/midi-smtp-server/blob/b86a3268ebd32b46854659a2edc1eddaf86adb7b/lib/midi-smtp-server.rb#L1101-L1124 | train |
amoniacou/danthes | lib/danthes/view_helpers.rb | Danthes.ViewHelpers.subscribe_to | def subscribe_to(channel, opts = {})
js_tag = opts.delete(:include_js_tag){ true }
subscription = Danthes.subscription(channel: channel)
content = raw("if (typeof Danthes != 'undefined') { Danthes.sign(#{subscription.to_json}) }")
js_tag ? content_tag('script', content, type: 'text/javascript') ... | ruby | def subscribe_to(channel, opts = {})
js_tag = opts.delete(:include_js_tag){ true }
subscription = Danthes.subscription(channel: channel)
content = raw("if (typeof Danthes != 'undefined') { Danthes.sign(#{subscription.to_json}) }")
js_tag ? content_tag('script', content, type: 'text/javascript') ... | [
"def",
"subscribe_to",
"(",
"channel",
",",
"opts",
"=",
"{",
"}",
")",
"js_tag",
"=",
"opts",
".",
"delete",
"(",
":include_js_tag",
")",
"{",
"true",
"}",
"subscription",
"=",
"Danthes",
".",
"subscription",
"(",
"channel",
":",
"channel",
")",
"conten... | Subscribe the client to the given channel. This generates
some JavaScript calling Danthes.sign with the subscription
options. | [
"Subscribe",
"the",
"client",
"to",
"the",
"given",
"channel",
".",
"This",
"generates",
"some",
"JavaScript",
"calling",
"Danthes",
".",
"sign",
"with",
"the",
"subscription",
"options",
"."
] | bac689d465aaf22c09b6e51fbca8a735bd8fb468 | https://github.com/amoniacou/danthes/blob/bac689d465aaf22c09b6e51fbca8a735bd8fb468/lib/danthes/view_helpers.rb#L15-L20 | train |
russ/lacquer | lib/lacquer/cache_utils.rb | Lacquer.CacheUtils.clear_cache_for | def clear_cache_for(*paths)
return unless Lacquer.configuration.enable_cache
case Lacquer.configuration.job_backend
when :delayed_job
require 'lacquer/delayed_job_job'
Delayed::Job.enqueue(Lacquer::DelayedJobJob.new(paths))
when :resque
require 'lacquer/resque_job'
... | ruby | def clear_cache_for(*paths)
return unless Lacquer.configuration.enable_cache
case Lacquer.configuration.job_backend
when :delayed_job
require 'lacquer/delayed_job_job'
Delayed::Job.enqueue(Lacquer::DelayedJobJob.new(paths))
when :resque
require 'lacquer/resque_job'
... | [
"def",
"clear_cache_for",
"(",
"*",
"paths",
")",
"return",
"unless",
"Lacquer",
".",
"configuration",
".",
"enable_cache",
"case",
"Lacquer",
".",
"configuration",
".",
"job_backend",
"when",
":delayed_job",
"require",
"'lacquer/delayed_job_job'",
"Delayed",
"::",
... | Sends url.purge command to varnish to clear cache.
clear_cache_for(root_path, blog_posts_path, '/other/content/*') | [
"Sends",
"url",
".",
"purge",
"command",
"to",
"varnish",
"to",
"clear",
"cache",
"."
] | 690fef73ee6f9229f0191a7d75bf6172499ffaf4 | https://github.com/russ/lacquer/blob/690fef73ee6f9229f0191a7d75bf6172499ffaf4/lib/lacquer/cache_utils.rb#L28-L43 | train |
amoniacou/danthes | lib/danthes/faye_extension.rb | Danthes.FayeExtension.incoming | def incoming(message, callback)
if message['channel'] == '/meta/subscribe'
authenticate_subscribe(message)
elsif message['channel'] !~ %r{^/meta/}
authenticate_publish(message)
end
callback.call(message)
end | ruby | def incoming(message, callback)
if message['channel'] == '/meta/subscribe'
authenticate_subscribe(message)
elsif message['channel'] !~ %r{^/meta/}
authenticate_publish(message)
end
callback.call(message)
end | [
"def",
"incoming",
"(",
"message",
",",
"callback",
")",
"if",
"message",
"[",
"'channel'",
"]",
"==",
"'/meta/subscribe'",
"authenticate_subscribe",
"(",
"message",
")",
"elsif",
"message",
"[",
"'channel'",
"]",
"!~",
"%r{",
"}",
"authenticate_publish",
"(",
... | Callback to handle incoming Faye messages. This authenticates both
subscribe and publish calls. | [
"Callback",
"to",
"handle",
"incoming",
"Faye",
"messages",
".",
"This",
"authenticates",
"both",
"subscribe",
"and",
"publish",
"calls",
"."
] | bac689d465aaf22c09b6e51fbca8a735bd8fb468 | https://github.com/amoniacou/danthes/blob/bac689d465aaf22c09b6e51fbca8a735bd8fb468/lib/danthes/faye_extension.rb#L7-L14 | train |
russ/lacquer | lib/lacquer/varnish.rb | Lacquer.Varnish.send_command | def send_command(command)
Lacquer.configuration.varnish_servers.collect do |server|
retries = 0
response = nil
begin
retries += 1
connection = Net::Telnet.new(
'Host' => server[:host],
'Port' => server[:port],
'Timeout' => server[:tim... | ruby | def send_command(command)
Lacquer.configuration.varnish_servers.collect do |server|
retries = 0
response = nil
begin
retries += 1
connection = Net::Telnet.new(
'Host' => server[:host],
'Port' => server[:port],
'Timeout' => server[:tim... | [
"def",
"send_command",
"(",
"command",
")",
"Lacquer",
".",
"configuration",
".",
"varnish_servers",
".",
"collect",
"do",
"|",
"server",
"|",
"retries",
"=",
"0",
"response",
"=",
"nil",
"begin",
"retries",
"+=",
"1",
"connection",
"=",
"Net",
"::",
"Teln... | Sends commands over telnet to varnish servers listed in the config. | [
"Sends",
"commands",
"over",
"telnet",
"to",
"varnish",
"servers",
"listed",
"in",
"the",
"config",
"."
] | 690fef73ee6f9229f0191a7d75bf6172499ffaf4 | https://github.com/russ/lacquer/blob/690fef73ee6f9229f0191a7d75bf6172499ffaf4/lib/lacquer/varnish.rb#L27-L82 | train |
4commerce-technologies-AG/midi-smtp-server | lib/midi-smtp-server/tls-transport.rb | MidiSmtpServer.TlsTransport.start | def start(io)
# start SSL negotiation
ssl = OpenSSL::SSL::SSLSocket.new(io, @ctx)
# connect to server socket
ssl.accept
# make sure to close also the underlying io
ssl.sync_close = true
# return as new io socket
return ssl
end | ruby | def start(io)
# start SSL negotiation
ssl = OpenSSL::SSL::SSLSocket.new(io, @ctx)
# connect to server socket
ssl.accept
# make sure to close also the underlying io
ssl.sync_close = true
# return as new io socket
return ssl
end | [
"def",
"start",
"(",
"io",
")",
"ssl",
"=",
"OpenSSL",
"::",
"SSL",
"::",
"SSLSocket",
".",
"new",
"(",
"io",
",",
"@ctx",
")",
"ssl",
".",
"accept",
"ssl",
".",
"sync_close",
"=",
"true",
"return",
"ssl",
"end"
] | start ssl connection over existing tcpserver socket | [
"start",
"ssl",
"connection",
"over",
"existing",
"tcpserver",
"socket"
] | b86a3268ebd32b46854659a2edc1eddaf86adb7b | https://github.com/4commerce-technologies-AG/midi-smtp-server/blob/b86a3268ebd32b46854659a2edc1eddaf86adb7b/lib/midi-smtp-server/tls-transport.rb#L54-L63 | train |
johnkoht/responsive-images | lib/responsive_images/view_helpers.rb | ResponsiveImages.ViewHelpers.responsive_image_tag | def responsive_image_tag image, options={}
# Merge any options passed with the configured options
sizes = ResponsiveImages.options.deep_merge(options)
# Let's create a hash of the alternative options for our data attributes
data_sizes = alternative_sizes(image, sizes)
# Get the image... | ruby | def responsive_image_tag image, options={}
# Merge any options passed with the configured options
sizes = ResponsiveImages.options.deep_merge(options)
# Let's create a hash of the alternative options for our data attributes
data_sizes = alternative_sizes(image, sizes)
# Get the image... | [
"def",
"responsive_image_tag",
"image",
",",
"options",
"=",
"{",
"}",
"sizes",
"=",
"ResponsiveImages",
".",
"options",
".",
"deep_merge",
"(",
"options",
")",
"data_sizes",
"=",
"alternative_sizes",
"(",
"image",
",",
"sizes",
")",
"image_src",
"=",
"src_pat... | Create a image tag with our responsive image data attributes | [
"Create",
"a",
"image",
"tag",
"with",
"our",
"responsive",
"image",
"data",
"attributes"
] | b5449b2dcb6f96cc8d5a335e9b032858285b156a | https://github.com/johnkoht/responsive-images/blob/b5449b2dcb6f96cc8d5a335e9b032858285b156a/lib/responsive_images/view_helpers.rb#L12-L21 | train |
johnkoht/responsive-images | lib/responsive_images/view_helpers.rb | ResponsiveImages.ViewHelpers.alternative_sizes | def alternative_sizes image, sizes
data_sizes = {}
sizes[:sizes].each do |size, value|
if value.present?
data_sizes["data-#{size}-src"] = (value == :default ? image.url : image.send(value))
else
false
end
end
data_sizes
end | ruby | def alternative_sizes image, sizes
data_sizes = {}
sizes[:sizes].each do |size, value|
if value.present?
data_sizes["data-#{size}-src"] = (value == :default ? image.url : image.send(value))
else
false
end
end
data_sizes
end | [
"def",
"alternative_sizes",
"image",
",",
"sizes",
"data_sizes",
"=",
"{",
"}",
"sizes",
"[",
":sizes",
"]",
".",
"each",
"do",
"|",
"size",
",",
"value",
"|",
"if",
"value",
".",
"present?",
"data_sizes",
"[",
"\"data-#{size}-src\"",
"]",
"=",
"(",
"val... | Loop over the images sizes and create our data attributes hash | [
"Loop",
"over",
"the",
"images",
"sizes",
"and",
"create",
"our",
"data",
"attributes",
"hash"
] | b5449b2dcb6f96cc8d5a335e9b032858285b156a | https://github.com/johnkoht/responsive-images/blob/b5449b2dcb6f96cc8d5a335e9b032858285b156a/lib/responsive_images/view_helpers.rb#L47-L57 | train |
worlddb/world.db | worlddb-models/lib/worlddb/reader.rb | WorldDb.ReaderBase.load_continent_defs | def load_continent_defs( name, more_attribs={} )
reader = create_values_reader( name, more_attribs )
reader.each_line do |attribs, values|
## check optional values
values.each_with_index do |value, index|
logger.warn "unknown type for value >#{value}<"
end
rec = Continent.find... | ruby | def load_continent_defs( name, more_attribs={} )
reader = create_values_reader( name, more_attribs )
reader.each_line do |attribs, values|
## check optional values
values.each_with_index do |value, index|
logger.warn "unknown type for value >#{value}<"
end
rec = Continent.find... | [
"def",
"load_continent_defs",
"(",
"name",
",",
"more_attribs",
"=",
"{",
"}",
")",
"reader",
"=",
"create_values_reader",
"(",
"name",
",",
"more_attribs",
")",
"reader",
".",
"each_line",
"do",
"|",
"attribs",
",",
"values",
"|",
"values",
".",
"each_with_... | use ContinentDef Reader | [
"use",
"ContinentDef",
"Reader"
] | 8fd44fa8d8dc47290c63b881c713634494aae291 | https://github.com/worlddb/world.db/blob/8fd44fa8d8dc47290c63b881c713634494aae291/worlddb-models/lib/worlddb/reader.rb#L198-L221 | train |
agoragames/bracket_tree | lib/bracket_tree/positional_relation.rb | BracketTree.PositionalRelation.all | def all
if @side
if @round
seats = by_round @round, @side
else
side_root = @bracket.root.send(@side)
seats = []
@bracket.top_down(side_root) do |node|
seats << node
end
end
else
if @round
seats = by_roun... | ruby | def all
if @side
if @round
seats = by_round @round, @side
else
side_root = @bracket.root.send(@side)
seats = []
@bracket.top_down(side_root) do |node|
seats << node
end
end
else
if @round
seats = by_roun... | [
"def",
"all",
"if",
"@side",
"if",
"@round",
"seats",
"=",
"by_round",
"@round",
",",
"@side",
"else",
"side_root",
"=",
"@bracket",
".",
"root",
".",
"send",
"(",
"@side",
")",
"seats",
"=",
"[",
"]",
"@bracket",
".",
"top_down",
"(",
"side_root",
")"... | Retrieves all seats based on the stored relation conditions
@return [Array<BracketTree::Node>] | [
"Retrieves",
"all",
"seats",
"based",
"on",
"the",
"stored",
"relation",
"conditions"
] | 68d90aa5c605ef2996fc7a360d4f90dcfde755ca | https://github.com/agoragames/bracket_tree/blob/68d90aa5c605ef2996fc7a360d4f90dcfde755ca/lib/bracket_tree/positional_relation.rb#L67-L91 | train |
agoragames/bracket_tree | lib/bracket_tree/positional_relation.rb | BracketTree.PositionalRelation.by_round | def by_round round, side
depth = @bracket.depth[side] - (round - 1)
seats = []
side_root = @bracket.root.send(side)
@bracket.top_down(side_root) do |node|
if node.depth == depth
seats << node
end
end
seats
end | ruby | def by_round round, side
depth = @bracket.depth[side] - (round - 1)
seats = []
side_root = @bracket.root.send(side)
@bracket.top_down(side_root) do |node|
if node.depth == depth
seats << node
end
end
seats
end | [
"def",
"by_round",
"round",
",",
"side",
"depth",
"=",
"@bracket",
".",
"depth",
"[",
"side",
"]",
"-",
"(",
"round",
"-",
"1",
")",
"seats",
"=",
"[",
"]",
"side_root",
"=",
"@bracket",
".",
"root",
".",
"send",
"(",
"side",
")",
"@bracket",
".",
... | Retrieves an Array of Nodes for a given round on a given side
@param [Fixnum] round to pull
@param [Fixnum] side of the tree to pull from
@return [Array] array of Nodes from the round | [
"Retrieves",
"an",
"Array",
"of",
"Nodes",
"for",
"a",
"given",
"round",
"on",
"a",
"given",
"side"
] | 68d90aa5c605ef2996fc7a360d4f90dcfde755ca | https://github.com/agoragames/bracket_tree/blob/68d90aa5c605ef2996fc7a360d4f90dcfde755ca/lib/bracket_tree/positional_relation.rb#L108-L120 | train |
BrunoMazzo/Danger-Slather | lib/slather/plugin.rb | Danger.DangerSlather.configure | def configure(xcodeproj_path, scheme, options: {})
require 'slather'
@project = Slather::Project.open(xcodeproj_path)
@project.scheme = scheme
@project.workspace = options[:workspace]
@project.build_directory = options[:build_directory]
@project.ignore_list = options[:ignore_list]
... | ruby | def configure(xcodeproj_path, scheme, options: {})
require 'slather'
@project = Slather::Project.open(xcodeproj_path)
@project.scheme = scheme
@project.workspace = options[:workspace]
@project.build_directory = options[:build_directory]
@project.ignore_list = options[:ignore_list]
... | [
"def",
"configure",
"(",
"xcodeproj_path",
",",
"scheme",
",",
"options",
":",
"{",
"}",
")",
"require",
"'slather'",
"@project",
"=",
"Slather",
"::",
"Project",
".",
"open",
"(",
"xcodeproj_path",
")",
"@project",
".",
"scheme",
"=",
"scheme",
"@project",
... | Required method to configure slather. It's required at least the path
to the project and the scheme used with code coverage enabled
@return [void] | [
"Required",
"method",
"to",
"configure",
"slather",
".",
"It",
"s",
"required",
"at",
"least",
"the",
"path",
"to",
"the",
"project",
"and",
"the",
"scheme",
"used",
"with",
"code",
"coverage",
"enabled"
] | 98be417dd89b922a20404810550a5d280d349b0e | https://github.com/BrunoMazzo/Danger-Slather/blob/98be417dd89b922a20404810550a5d280d349b0e/lib/slather/plugin.rb#L19-L36 | train |
BrunoMazzo/Danger-Slather | lib/slather/plugin.rb | Danger.DangerSlather.total_coverage | def total_coverage
unless @project.nil?
@total_coverage ||= begin
total_project_lines = 0
total_project_lines_tested = 0
@project.coverage_files.each do |coverage_file|
total_project_lines_tested += coverage_file.num_lines_tested
total_project_lines +=... | ruby | def total_coverage
unless @project.nil?
@total_coverage ||= begin
total_project_lines = 0
total_project_lines_tested = 0
@project.coverage_files.each do |coverage_file|
total_project_lines_tested += coverage_file.num_lines_tested
total_project_lines +=... | [
"def",
"total_coverage",
"unless",
"@project",
".",
"nil?",
"@total_coverage",
"||=",
"begin",
"total_project_lines",
"=",
"0",
"total_project_lines_tested",
"=",
"0",
"@project",
".",
"coverage_files",
".",
"each",
"do",
"|",
"coverage_file",
"|",
"total_project_line... | Total coverage of the project
@return [Float] | [
"Total",
"coverage",
"of",
"the",
"project"
] | 98be417dd89b922a20404810550a5d280d349b0e | https://github.com/BrunoMazzo/Danger-Slather/blob/98be417dd89b922a20404810550a5d280d349b0e/lib/slather/plugin.rb#L40-L52 | train |
BrunoMazzo/Danger-Slather | lib/slather/plugin.rb | Danger.DangerSlather.notify_if_coverage_is_less_than | def notify_if_coverage_is_less_than(options)
minimum_coverage = options[:minimum_coverage]
notify_level = options[:notify_level] || :fail
if total_coverage < minimum_coverage
notify_message = "Total coverage less than #{minimum_coverage}%"
if notify_level == :fail
fail notify... | ruby | def notify_if_coverage_is_less_than(options)
minimum_coverage = options[:minimum_coverage]
notify_level = options[:notify_level] || :fail
if total_coverage < minimum_coverage
notify_message = "Total coverage less than #{minimum_coverage}%"
if notify_level == :fail
fail notify... | [
"def",
"notify_if_coverage_is_less_than",
"(",
"options",
")",
"minimum_coverage",
"=",
"options",
"[",
":minimum_coverage",
"]",
"notify_level",
"=",
"options",
"[",
":notify_level",
"]",
"||",
":fail",
"if",
"total_coverage",
"<",
"minimum_coverage",
"notify_message",... | Method to check if the coverage of the project is at least a minumum
@param options [Hash] a hash with the options
@option options [Float] :minimum_coverage the minimum code coverage required
@option options [Symbol] :notify_level the level of notification
@return [Array<String>] | [
"Method",
"to",
"check",
"if",
"the",
"coverage",
"of",
"the",
"project",
"is",
"at",
"least",
"a",
"minumum"
] | 98be417dd89b922a20404810550a5d280d349b0e | https://github.com/BrunoMazzo/Danger-Slather/blob/98be417dd89b922a20404810550a5d280d349b0e/lib/slather/plugin.rb#L59-L70 | train |
BrunoMazzo/Danger-Slather | lib/slather/plugin.rb | Danger.DangerSlather.notify_if_modified_file_is_less_than | def notify_if_modified_file_is_less_than(options)
minimum_coverage = options[:minimum_coverage]
notify_level = options[:notify_level] || :fail
if all_modified_files_coverage.count > 0
files_to_notify = all_modified_files_coverage.select do |file|
file.percentage_lines_tested < minim... | ruby | def notify_if_modified_file_is_less_than(options)
minimum_coverage = options[:minimum_coverage]
notify_level = options[:notify_level] || :fail
if all_modified_files_coverage.count > 0
files_to_notify = all_modified_files_coverage.select do |file|
file.percentage_lines_tested < minim... | [
"def",
"notify_if_modified_file_is_less_than",
"(",
"options",
")",
"minimum_coverage",
"=",
"options",
"[",
":minimum_coverage",
"]",
"notify_level",
"=",
"options",
"[",
":notify_level",
"]",
"||",
":fail",
"if",
"all_modified_files_coverage",
".",
"count",
">",
"0"... | Method to check if the coverage of modified files is at least a minumum
@param options [Hash] a hash with the options
@option options [Float] :minimum_coverage the minimum code coverage required for a file
@option options [Symbol] :notify_level the level of notification
@return [Array<String>] | [
"Method",
"to",
"check",
"if",
"the",
"coverage",
"of",
"modified",
"files",
"is",
"at",
"least",
"a",
"minumum"
] | 98be417dd89b922a20404810550a5d280d349b0e | https://github.com/BrunoMazzo/Danger-Slather/blob/98be417dd89b922a20404810550a5d280d349b0e/lib/slather/plugin.rb#L77-L97 | train |
BrunoMazzo/Danger-Slather | lib/slather/plugin.rb | Danger.DangerSlather.modified_files_coverage_table | def modified_files_coverage_table
unless @project.nil?
line = ''
if all_modified_files_coverage.count > 0
line << "File | Coverage\n"
line << "-----|-----\n"
all_modified_files_coverage.each do |coverage_file|
file_name = coverage_file.source_file_pathname... | ruby | def modified_files_coverage_table
unless @project.nil?
line = ''
if all_modified_files_coverage.count > 0
line << "File | Coverage\n"
line << "-----|-----\n"
all_modified_files_coverage.each do |coverage_file|
file_name = coverage_file.source_file_pathname... | [
"def",
"modified_files_coverage_table",
"unless",
"@project",
".",
"nil?",
"line",
"=",
"''",
"if",
"all_modified_files_coverage",
".",
"count",
">",
"0",
"line",
"<<",
"\"File | Coverage\\n\"",
"line",
"<<",
"\"-----|-----\\n\"",
"all_modified_files_coverage",
".",
"ea... | Build a coverage markdown table of the modified files coverage
@return [String] | [
"Build",
"a",
"coverage",
"markdown",
"table",
"of",
"the",
"modified",
"files",
"coverage"
] | 98be417dd89b922a20404810550a5d280d349b0e | https://github.com/BrunoMazzo/Danger-Slather/blob/98be417dd89b922a20404810550a5d280d349b0e/lib/slather/plugin.rb#L117-L131 | train |
BrunoMazzo/Danger-Slather | lib/slather/plugin.rb | Danger.DangerSlather.show_coverage | def show_coverage
unless @project.nil?
line = "## Code coverage\n"
line << total_coverage_markdown
line << modified_files_coverage_table
line << '> Powered by [Slather](https://github.com/SlatherOrg/slather)'
markdown line
end
end | ruby | def show_coverage
unless @project.nil?
line = "## Code coverage\n"
line << total_coverage_markdown
line << modified_files_coverage_table
line << '> Powered by [Slather](https://github.com/SlatherOrg/slather)'
markdown line
end
end | [
"def",
"show_coverage",
"unless",
"@project",
".",
"nil?",
"line",
"=",
"\"## Code coverage\\n\"",
"line",
"<<",
"total_coverage_markdown",
"line",
"<<",
"modified_files_coverage_table",
"line",
"<<",
"'> Powered by [Slather](https://github.com/SlatherOrg/slather)'",
"markdown",
... | Show a header with the total coverage and coverage table
@return [Array<String>] | [
"Show",
"a",
"header",
"with",
"the",
"total",
"coverage",
"and",
"coverage",
"table"
] | 98be417dd89b922a20404810550a5d280d349b0e | https://github.com/BrunoMazzo/Danger-Slather/blob/98be417dd89b922a20404810550a5d280d349b0e/lib/slather/plugin.rb#L143-L151 | train |
BrunoMazzo/Danger-Slather | lib/slather/plugin.rb | Danger.DangerSlather.all_modified_files_coverage | def all_modified_files_coverage
unless @project.nil?
all_modified_files_coverage ||= begin
modified_files = git.modified_files.nil? ? [] : git.modified_files
added_files = git.added_files.nil? ? [] : git.added_files
all_changed_files = modified_files | added_files
@... | ruby | def all_modified_files_coverage
unless @project.nil?
all_modified_files_coverage ||= begin
modified_files = git.modified_files.nil? ? [] : git.modified_files
added_files = git.added_files.nil? ? [] : git.added_files
all_changed_files = modified_files | added_files
@... | [
"def",
"all_modified_files_coverage",
"unless",
"@project",
".",
"nil?",
"all_modified_files_coverage",
"||=",
"begin",
"modified_files",
"=",
"git",
".",
"modified_files",
".",
"nil?",
"?",
"[",
"]",
":",
"git",
".",
"modified_files",
"added_files",
"=",
"git",
"... | Array of files that we have coverage information and was modified
@return [Array<File>] | [
"Array",
"of",
"files",
"that",
"we",
"have",
"coverage",
"information",
"and",
"was",
"modified"
] | 98be417dd89b922a20404810550a5d280d349b0e | https://github.com/BrunoMazzo/Danger-Slather/blob/98be417dd89b922a20404810550a5d280d349b0e/lib/slather/plugin.rb#L155-L168 | train |
mobomo/green_onion | lib/green_onion/compare.rb | GreenOnion.Compare.diff_iterator | def diff_iterator
@images.first.height.times do |y|
@images.first.row(y).each_with_index do |pixel, x|
unless pixel == @images.last[x,y]
@diff_index << [x,y]
pixel_difference_filter(pixel, x, y)
end
end
end
end | ruby | def diff_iterator
@images.first.height.times do |y|
@images.first.row(y).each_with_index do |pixel, x|
unless pixel == @images.last[x,y]
@diff_index << [x,y]
pixel_difference_filter(pixel, x, y)
end
end
end
end | [
"def",
"diff_iterator",
"@images",
".",
"first",
".",
"height",
".",
"times",
"do",
"|",
"y",
"|",
"@images",
".",
"first",
".",
"row",
"(",
"y",
")",
".",
"each_with_index",
"do",
"|",
"pixel",
",",
"x",
"|",
"unless",
"pixel",
"==",
"@images",
".",... | Run through all of the pixels on both org image, and fresh image. Change the pixel color accordingly. | [
"Run",
"through",
"all",
"of",
"the",
"pixels",
"on",
"both",
"org",
"image",
"and",
"fresh",
"image",
".",
"Change",
"the",
"pixel",
"color",
"accordingly",
"."
] | 6e4bab440e22dab00fa3e543888c6d924e97777b | https://github.com/mobomo/green_onion/blob/6e4bab440e22dab00fa3e543888c6d924e97777b/lib/green_onion/compare.rb#L27-L36 | train |
mobomo/green_onion | lib/green_onion/compare.rb | GreenOnion.Compare.pixel_difference_filter | def pixel_difference_filter(pixel, x, y)
chans = []
[:r, :b, :g].each do |chan|
chans << channel_difference(chan, pixel, x, y)
end
@images.last[x,y] = ChunkyPNG::Color.rgb(chans[0], chans[1], chans[2])
end | ruby | def pixel_difference_filter(pixel, x, y)
chans = []
[:r, :b, :g].each do |chan|
chans << channel_difference(chan, pixel, x, y)
end
@images.last[x,y] = ChunkyPNG::Color.rgb(chans[0], chans[1], chans[2])
end | [
"def",
"pixel_difference_filter",
"(",
"pixel",
",",
"x",
",",
"y",
")",
"chans",
"=",
"[",
"]",
"[",
":r",
",",
":b",
",",
":g",
"]",
".",
"each",
"do",
"|",
"chan",
"|",
"chans",
"<<",
"channel_difference",
"(",
"chan",
",",
"pixel",
",",
"x",
... | Changes the pixel color to be the opposite RGB value | [
"Changes",
"the",
"pixel",
"color",
"to",
"be",
"the",
"opposite",
"RGB",
"value"
] | 6e4bab440e22dab00fa3e543888c6d924e97777b | https://github.com/mobomo/green_onion/blob/6e4bab440e22dab00fa3e543888c6d924e97777b/lib/green_onion/compare.rb#L39-L45 | train |
mobomo/green_onion | lib/green_onion/compare.rb | GreenOnion.Compare.channel_difference | def channel_difference(chan, pixel, x, y)
ChunkyPNG::Color.send(chan, pixel) + ChunkyPNG::Color.send(chan, @images.last[x,y]) - 2 * [ChunkyPNG::Color.send(chan, pixel), ChunkyPNG::Color.send(chan, @images.last[x,y])].min
end | ruby | def channel_difference(chan, pixel, x, y)
ChunkyPNG::Color.send(chan, pixel) + ChunkyPNG::Color.send(chan, @images.last[x,y]) - 2 * [ChunkyPNG::Color.send(chan, pixel), ChunkyPNG::Color.send(chan, @images.last[x,y])].min
end | [
"def",
"channel_difference",
"(",
"chan",
",",
"pixel",
",",
"x",
",",
"y",
")",
"ChunkyPNG",
"::",
"Color",
".",
"send",
"(",
"chan",
",",
"pixel",
")",
"+",
"ChunkyPNG",
"::",
"Color",
".",
"send",
"(",
"chan",
",",
"@images",
".",
"last",
"[",
"... | Interface to run the R, G, B methods on ChunkyPNG | [
"Interface",
"to",
"run",
"the",
"R",
"G",
"B",
"methods",
"on",
"ChunkyPNG"
] | 6e4bab440e22dab00fa3e543888c6d924e97777b | https://github.com/mobomo/green_onion/blob/6e4bab440e22dab00fa3e543888c6d924e97777b/lib/green_onion/compare.rb#L48-L50 | train |
mobomo/green_onion | lib/green_onion/compare.rb | GreenOnion.Compare.percentage_diff | def percentage_diff(org, fresh)
diff_images(org, fresh)
@total_px = @images.first.pixels.length
@changed_px = @diff_index.length
@percentage_changed = ( (@diff_index.length.to_f / @images.first.pixels.length) * 100 ).round(2)
end | ruby | def percentage_diff(org, fresh)
diff_images(org, fresh)
@total_px = @images.first.pixels.length
@changed_px = @diff_index.length
@percentage_changed = ( (@diff_index.length.to_f / @images.first.pixels.length) * 100 ).round(2)
end | [
"def",
"percentage_diff",
"(",
"org",
",",
"fresh",
")",
"diff_images",
"(",
"org",
",",
"fresh",
")",
"@total_px",
"=",
"@images",
".",
"first",
".",
"pixels",
".",
"length",
"@changed_px",
"=",
"@diff_index",
".",
"length",
"@percentage_changed",
"=",
"(",... | Returns the numeric results of the diff of 2 images | [
"Returns",
"the",
"numeric",
"results",
"of",
"the",
"diff",
"of",
"2",
"images"
] | 6e4bab440e22dab00fa3e543888c6d924e97777b | https://github.com/mobomo/green_onion/blob/6e4bab440e22dab00fa3e543888c6d924e97777b/lib/green_onion/compare.rb#L53-L58 | train |
mobomo/green_onion | lib/green_onion/compare.rb | GreenOnion.Compare.save_visual_diff | def save_visual_diff(org, fresh)
x, y = @diff_index.map{ |xy| xy[0] }, @diff_index.map{ |xy| xy[1] }
@diffed_image = org.insert(-5, '_diff')
begin
@images.last.rect(x.min, y.min, x.max, y.max, ChunkyPNG::Color.rgb(0,255,0))
rescue NoMethodError
puts "Both skins are the same.".co... | ruby | def save_visual_diff(org, fresh)
x, y = @diff_index.map{ |xy| xy[0] }, @diff_index.map{ |xy| xy[1] }
@diffed_image = org.insert(-5, '_diff')
begin
@images.last.rect(x.min, y.min, x.max, y.max, ChunkyPNG::Color.rgb(0,255,0))
rescue NoMethodError
puts "Both skins are the same.".co... | [
"def",
"save_visual_diff",
"(",
"org",
",",
"fresh",
")",
"x",
",",
"y",
"=",
"@diff_index",
".",
"map",
"{",
"|",
"xy",
"|",
"xy",
"[",
"0",
"]",
"}",
",",
"@diff_index",
".",
"map",
"{",
"|",
"xy",
"|",
"xy",
"[",
"1",
"]",
"}",
"@diffed_imag... | Saves the visual diff as a separate file | [
"Saves",
"the",
"visual",
"diff",
"as",
"a",
"separate",
"file"
] | 6e4bab440e22dab00fa3e543888c6d924e97777b | https://github.com/mobomo/green_onion/blob/6e4bab440e22dab00fa3e543888c6d924e97777b/lib/green_onion/compare.rb#L67-L78 | train |
ranjib/etcd-ruby | lib/etcd/keys.rb | Etcd.Keys.get | def get(key, opts = {})
response = api_execute(key_endpoint + key, :get, params: opts)
Response.from_http_response(response)
end | ruby | def get(key, opts = {})
response = api_execute(key_endpoint + key, :get, params: opts)
Response.from_http_response(response)
end | [
"def",
"get",
"(",
"key",
",",
"opts",
"=",
"{",
"}",
")",
"response",
"=",
"api_execute",
"(",
"key_endpoint",
"+",
"key",
",",
":get",
",",
"params",
":",
"opts",
")",
"Response",
".",
"from_http_response",
"(",
"response",
")",
"end"
] | Retrives a key with its associated data, if key is not present it will
return with message "Key Not Found"
This method takes the following parameters as arguments
* key - whose data is to be retrieved | [
"Retrives",
"a",
"key",
"with",
"its",
"associated",
"data",
"if",
"key",
"is",
"not",
"present",
"it",
"will",
"return",
"with",
"message",
"Key",
"Not",
"Found"
] | f7153c6a7829b1cd5e5a4470d7ca6f5217c4c917 | https://github.com/ranjib/etcd-ruby/blob/f7153c6a7829b1cd5e5a4470d7ca6f5217c4c917/lib/etcd/keys.rb#L21-L24 | train |
ranjib/etcd-ruby | lib/etcd/keys.rb | Etcd.Keys.set | def set(key, opts = nil)
fail ArgumentError, 'Second argument must be a hash' unless opts.is_a?(Hash)
path = key_endpoint + key
payload = {}
[:ttl, :value, :dir, :prevExist, :prevValue, :prevIndex].each do |k|
payload[k] = opts[k] if opts.key?(k)
end
response = api_execute(p... | ruby | def set(key, opts = nil)
fail ArgumentError, 'Second argument must be a hash' unless opts.is_a?(Hash)
path = key_endpoint + key
payload = {}
[:ttl, :value, :dir, :prevExist, :prevValue, :prevIndex].each do |k|
payload[k] = opts[k] if opts.key?(k)
end
response = api_execute(p... | [
"def",
"set",
"(",
"key",
",",
"opts",
"=",
"nil",
")",
"fail",
"ArgumentError",
",",
"'Second argument must be a hash'",
"unless",
"opts",
".",
"is_a?",
"(",
"Hash",
")",
"path",
"=",
"key_endpoint",
"+",
"key",
"payload",
"=",
"{",
"}",
"[",
":ttl",
",... | Create or update a new key
This method takes the following parameters as arguments
* key - whose value to be set
* value - value to be set for specified key
* ttl - shelf life of a key (in seconds) (optional) | [
"Create",
"or",
"update",
"a",
"new",
"key"
] | f7153c6a7829b1cd5e5a4470d7ca6f5217c4c917 | https://github.com/ranjib/etcd-ruby/blob/f7153c6a7829b1cd5e5a4470d7ca6f5217c4c917/lib/etcd/keys.rb#L32-L41 | train |
ranjib/etcd-ruby | lib/etcd/keys.rb | Etcd.Keys.compare_and_swap | def compare_and_swap(key, opts = {})
fail ArgumentError, 'Second argument must be a hash' unless opts.is_a?(Hash)
fail ArgumentError, 'You must pass prevValue' unless opts.key?(:prevValue)
set(key, opts)
end | ruby | def compare_and_swap(key, opts = {})
fail ArgumentError, 'Second argument must be a hash' unless opts.is_a?(Hash)
fail ArgumentError, 'You must pass prevValue' unless opts.key?(:prevValue)
set(key, opts)
end | [
"def",
"compare_and_swap",
"(",
"key",
",",
"opts",
"=",
"{",
"}",
")",
"fail",
"ArgumentError",
",",
"'Second argument must be a hash'",
"unless",
"opts",
".",
"is_a?",
"(",
"Hash",
")",
"fail",
"ArgumentError",
",",
"'You must pass prevValue'",
"unless",
"opts",... | Set a new value for key if previous value of key is matched
This method takes the following parameters as arguments
* key - whose value is going to change if previous value is matched
* value - new value to be set for specified key
* prevValue - value of a key to compare with existing value of key
* ttl... | [
"Set",
"a",
"new",
"value",
"for",
"key",
"if",
"previous",
"value",
"of",
"key",
"is",
"matched"
] | f7153c6a7829b1cd5e5a4470d7ca6f5217c4c917 | https://github.com/ranjib/etcd-ruby/blob/f7153c6a7829b1cd5e5a4470d7ca6f5217c4c917/lib/etcd/keys.rb#L59-L63 | train |
ranjib/etcd-ruby | lib/etcd/keys.rb | Etcd.Keys.watch | def watch(key, opts = {})
params = { wait: true }
fail ArgumentError, 'Second argument must be a hash' unless opts.is_a?(Hash)
timeout = opts[:timeout] || @read_timeout
index = opts[:waitIndex] || opts[:index]
params[:waitIndex] = index unless index.nil?
params[:consistent] = opts[:c... | ruby | def watch(key, opts = {})
params = { wait: true }
fail ArgumentError, 'Second argument must be a hash' unless opts.is_a?(Hash)
timeout = opts[:timeout] || @read_timeout
index = opts[:waitIndex] || opts[:index]
params[:waitIndex] = index unless index.nil?
params[:consistent] = opts[:c... | [
"def",
"watch",
"(",
"key",
",",
"opts",
"=",
"{",
"}",
")",
"params",
"=",
"{",
"wait",
":",
"true",
"}",
"fail",
"ArgumentError",
",",
"'Second argument must be a hash'",
"unless",
"opts",
".",
"is_a?",
"(",
"Hash",
")",
"timeout",
"=",
"opts",
"[",
... | Gives a notification when specified key changes
This method takes the following parameters as arguments
@ key - key to be watched
@options [Hash] additional options for watching a key
@options [Fixnum] :index watch the specified key from given index
@options [Fixnum] :timeout specify http timeout | [
"Gives",
"a",
"notification",
"when",
"specified",
"key",
"changes"
] | f7153c6a7829b1cd5e5a4470d7ca6f5217c4c917 | https://github.com/ranjib/etcd-ruby/blob/f7153c6a7829b1cd5e5a4470d7ca6f5217c4c917/lib/etcd/keys.rb#L72-L88 | train |
marcelocf/gremlin_client | lib/gremlin_client/connection.rb | GremlinClient.Connection.receive_message | def receive_message(msg)
response = Oj.load(msg.data)
# this check is important in case a request timeout and we make new ones after
if response['requestId'] == @request_id
if @response.nil?
@response = response
else
@response['result']['data'].concat response['resu... | ruby | def receive_message(msg)
response = Oj.load(msg.data)
# this check is important in case a request timeout and we make new ones after
if response['requestId'] == @request_id
if @response.nil?
@response = response
else
@response['result']['data'].concat response['resu... | [
"def",
"receive_message",
"(",
"msg",
")",
"response",
"=",
"Oj",
".",
"load",
"(",
"msg",
".",
"data",
")",
"if",
"response",
"[",
"'requestId'",
"]",
"==",
"@request_id",
"if",
"@response",
".",
"nil?",
"@response",
"=",
"response",
"else",
"@response",
... | this has to be public so the websocket client thread sees it | [
"this",
"has",
"to",
"be",
"public",
"so",
"the",
"websocket",
"client",
"thread",
"sees",
"it"
] | 91645fd6a5e47e3faf2d925c9aebec86bb457fb1 | https://github.com/marcelocf/gremlin_client/blob/91645fd6a5e47e3faf2d925c9aebec86bb457fb1/lib/gremlin_client/connection.rb#L99-L111 | train |
marcelocf/gremlin_client | lib/gremlin_client/connection.rb | GremlinClient.Connection.treat_response | def treat_response
# note that the partial_content status should be processed differently.
# look at http://tinkerpop.apache.org/docs/3.0.1-incubating/ for more info
ok_status = [:success, :no_content, :partial_content].map { |st| STATUS[st] }
unless ok_status.include?(@response['status'... | ruby | def treat_response
# note that the partial_content status should be processed differently.
# look at http://tinkerpop.apache.org/docs/3.0.1-incubating/ for more info
ok_status = [:success, :no_content, :partial_content].map { |st| STATUS[st] }
unless ok_status.include?(@response['status'... | [
"def",
"treat_response",
"ok_status",
"=",
"[",
":success",
",",
":no_content",
",",
":partial_content",
"]",
".",
"map",
"{",
"|",
"st",
"|",
"STATUS",
"[",
"st",
"]",
"}",
"unless",
"ok_status",
".",
"include?",
"(",
"@response",
"[",
"'status'",
"]",
... | we validate our response here to make sure it is going to be
raising exceptions in the right thread | [
"we",
"validate",
"our",
"response",
"here",
"to",
"make",
"sure",
"it",
"is",
"going",
"to",
"be",
"raising",
"exceptions",
"in",
"the",
"right",
"thread"
] | 91645fd6a5e47e3faf2d925c9aebec86bb457fb1 | https://github.com/marcelocf/gremlin_client/blob/91645fd6a5e47e3faf2d925c9aebec86bb457fb1/lib/gremlin_client/connection.rb#L159-L167 | train |
yandex-money/yandex-money-sdk-ruby | lib/yandex_money/external_payment.rb | YandexMoney.ExternalPayment.request_external_payment | def request_external_payment(payment_options)
payment_options[:instance_id] = @instance_id
request = self.class.send_external_payment_request("/api/request-external-payment", payment_options)
RecursiveOpenStruct.new request.parsed_response
end | ruby | def request_external_payment(payment_options)
payment_options[:instance_id] = @instance_id
request = self.class.send_external_payment_request("/api/request-external-payment", payment_options)
RecursiveOpenStruct.new request.parsed_response
end | [
"def",
"request_external_payment",
"(",
"payment_options",
")",
"payment_options",
"[",
":instance_id",
"]",
"=",
"@instance_id",
"request",
"=",
"self",
".",
"class",
".",
"send_external_payment_request",
"(",
"\"/api/request-external-payment\"",
",",
"payment_options",
... | Requests a external payment
@see http://api.yandex.com/money/doc/dg/reference/request-external-payment.xml
@see https://tech.yandex.ru/money/doc/dg/reference/request-external-payment-docpage/
@param payment_options [Hash] Method's parameters. Check out docs for more information.
@raise [YandexMoney::InvalidReque... | [
"Requests",
"a",
"external",
"payment"
] | 5634ebc09aaad3c8f96e2cde20cc60edf6b47899 | https://github.com/yandex-money/yandex-money-sdk-ruby/blob/5634ebc09aaad3c8f96e2cde20cc60edf6b47899/lib/yandex_money/external_payment.rb#L38-L42 | train |
yandex-money/yandex-money-sdk-ruby | lib/yandex_money/external_payment.rb | YandexMoney.ExternalPayment.process_external_payment | def process_external_payment(payment_options)
payment_options[:instance_id] = @instance_id
request = self.class.send_external_payment_request("/api/process-external-payment", payment_options)
RecursiveOpenStruct.new request.parsed_response
end | ruby | def process_external_payment(payment_options)
payment_options[:instance_id] = @instance_id
request = self.class.send_external_payment_request("/api/process-external-payment", payment_options)
RecursiveOpenStruct.new request.parsed_response
end | [
"def",
"process_external_payment",
"(",
"payment_options",
")",
"payment_options",
"[",
":instance_id",
"]",
"=",
"@instance_id",
"request",
"=",
"self",
".",
"class",
".",
"send_external_payment_request",
"(",
"\"/api/process-external-payment\"",
",",
"payment_options",
... | Confirms a payment that was created using the request-extenral-payment method
@see http://api.yandex.com/money/doc/dg/reference/process-external-payment.xml
@see https://tech.yandex.ru/money/doc/dg/reference/process-external-payment-docpage/
@param payment_options [Hash] Method's parameters. Check out docs for mor... | [
"Confirms",
"a",
"payment",
"that",
"was",
"created",
"using",
"the",
"request",
"-",
"extenral",
"-",
"payment",
"method"
] | 5634ebc09aaad3c8f96e2cde20cc60edf6b47899 | https://github.com/yandex-money/yandex-money-sdk-ruby/blob/5634ebc09aaad3c8f96e2cde20cc60edf6b47899/lib/yandex_money/external_payment.rb#L55-L59 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.