id
int32
0
24.9k
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
20,800
HewlettPackard/hpe3par_ruby_sdk
lib/Hpe3parSdk/client.rb
Hpe3parSdk.Client.get_ip_ports
def get_ip_ports(state = nil) begin @port.get_ip_ports(state) rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
ruby
def get_ip_ports(state = nil) begin @port.get_ip_ports(state) rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
[ "def", "get_ip_ports", "(", "state", "=", "nil", ")", "begin", "@port", ".", "get_ip_ports", "(", "state", ")", "rescue", "=>", "ex", "Util", ".", "log_exception", "(", "ex", ",", "caller_locations", "(", "1", ",", "1", ")", "[", "0", "]", ".", "labe...
Gets an array of IP Ports. ==== Attributes * state - Port link state. type name: Integer. Refer Hpe3parSdk::PortLinkState for complete enumeration. ==== Returns Array of IP Port.
[ "Gets", "an", "array", "of", "IP", "Ports", "." ]
f8cfc6e597741be593cf7fe013accadf982ee68b
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L2259-L2266
20,801
HewlettPackard/hpe3par_ruby_sdk
lib/Hpe3parSdk/client.rb
Hpe3parSdk.Client.get_cpgs
def get_cpgs begin @cpg.get_cpgs rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
ruby
def get_cpgs begin @cpg.get_cpgs rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
[ "def", "get_cpgs", "begin", "@cpg", ".", "get_cpgs", "rescue", "=>", "ex", "Util", ".", "log_exception", "(", "ex", ",", "caller_locations", "(", "1", ",", "1", ")", "[", "0", "]", ".", "label", ")", "raise", "ex", "end", "end" ]
Gets entire list of CPGs. ==== Returns CPG array
[ "Gets", "entire", "list", "of", "CPGs", "." ]
f8cfc6e597741be593cf7fe013accadf982ee68b
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L2273-L2280
20,802
HewlettPackard/hpe3par_ruby_sdk
lib/Hpe3parSdk/client.rb
Hpe3parSdk.Client.get_cpg
def get_cpg(name) begin @cpg.get_cpg(name) rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
ruby
def get_cpg(name) begin @cpg.get_cpg(name) rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
[ "def", "get_cpg", "(", "name", ")", "begin", "@cpg", ".", "get_cpg", "(", "name", ")", "rescue", "=>", "ex", "Util", ".", "log_exception", "(", "ex", ",", "caller_locations", "(", "1", ",", "1", ")", "[", "0", "]", ".", "label", ")", "raise", "ex",...
Gets information about a Cpg. ==== Attributes * name - The name of the cpg to find type name: String ==== Returns CPG ==== Raises * Hpe3parSdk::HPE3PARException Error with code: 15 message: cpg does not exist
[ "Gets", "information", "about", "a", "Cpg", "." ]
f8cfc6e597741be593cf7fe013accadf982ee68b
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L2297-L2304
20,803
HewlettPackard/hpe3par_ruby_sdk
lib/Hpe3parSdk/client.rb
Hpe3parSdk.Client.create_cpg
def create_cpg(name, optional = nil) begin @cpg.create_cpg(name, optional) rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
ruby
def create_cpg(name, optional = nil) begin @cpg.create_cpg(name, optional) rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
[ "def", "create_cpg", "(", "name", ",", "optional", "=", "nil", ")", "begin", "@cpg", ".", "create_cpg", "(", "name", ",", "optional", ")", "rescue", "=>", "ex", "Util", ".", "log_exception", "(", "ex", ",", "caller_locations", "(", "1", ",", "1", ")", ...
Creates a new CPG. ==== Attributes * name - Name of the cpg type name: String * optional - Hash of other optional items type optional: Hash optional = { 'growthIncrementMiB' 100, # Growth increment in MiB for # each auto-grown operation ...
[ "Creates", "a", "new", "CPG", "." ]
f8cfc6e597741be593cf7fe013accadf982ee68b
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L2353-L2360
20,804
HewlettPackard/hpe3par_ruby_sdk
lib/Hpe3parSdk/client.rb
Hpe3parSdk.Client.modify_cpg
def modify_cpg(name, cpg_mods) begin @cpg.modify_cpg(name, cpg_mods) rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
ruby
def modify_cpg(name, cpg_mods) begin @cpg.modify_cpg(name, cpg_mods) rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
[ "def", "modify_cpg", "(", "name", ",", "cpg_mods", ")", "begin", "@cpg", ".", "modify_cpg", "(", "name", ",", "cpg_mods", ")", "rescue", "=>", "ex", "Util", ".", "log_exception", "(", "ex", ",", "caller_locations", "(", "1", ",", "1", ")", "[", "0", ...
Modifies a CPG. ==== Attributes * name - Name of the CPG type name: String * optional - hash of other optional items type optional: Hash optional = { 'newName'=> "newCPG:, # Specifies the name of the # CPG to update. 'di...
[ "Modifies", "a", "CPG", "." ]
f8cfc6e597741be593cf7fe013accadf982ee68b
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L2387-L2394
20,805
HewlettPackard/hpe3par_ruby_sdk
lib/Hpe3parSdk/client.rb
Hpe3parSdk.Client.get_cpg_available_space
def get_cpg_available_space(name) begin @cpg.get_cpg_available_space(name) rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
ruby
def get_cpg_available_space(name) begin @cpg.get_cpg_available_space(name) rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
[ "def", "get_cpg_available_space", "(", "name", ")", "begin", "@cpg", ".", "get_cpg_available_space", "(", "name", ")", "rescue", "=>", "ex", "Util", ".", "log_exception", "(", "ex", ",", "caller_locations", "(", "1", ",", "1", ")", "[", "0", "]", ".", "l...
Gets available space information about a cpg. ==== Attributes * name - The name of the cpg to find type name: String ==== Returns Available space details in form of LDLayoutCapacity object ==== Raises * Hpe3parSdk::HPE3PARException Error with code: 15 message: cpg does not exist
[ "Gets", "available", "space", "information", "about", "a", "cpg", "." ]
f8cfc6e597741be593cf7fe013accadf982ee68b
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L2411-L2418
20,806
HewlettPackard/hpe3par_ruby_sdk
lib/Hpe3parSdk/client.rb
Hpe3parSdk.Client.delete_cpg
def delete_cpg(name) begin @cpg.delete_cpg(name) rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
ruby
def delete_cpg(name) begin @cpg.delete_cpg(name) rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
[ "def", "delete_cpg", "(", "name", ")", "begin", "@cpg", ".", "delete_cpg", "(", "name", ")", "rescue", "=>", "ex", "Util", ".", "log_exception", "(", "ex", ",", "caller_locations", "(", "1", ",", "1", ")", "[", "0", "]", ".", "label", ")", "raise", ...
Deletes a CPG. ==== Attributes * name - The name of the CPG type name: String ==== Raises * Hpe3parSdk::HPE3PARException Error with code: 15 message: CPG does not exist * Hpe3parSdk::HTTPForbidden - IN_USE - The CPG Cannot be removed because it's in use. * Hpe3parSdk::HTTPForbidden ...
[ "Deletes", "a", "CPG", "." ]
f8cfc6e597741be593cf7fe013accadf982ee68b
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L2435-L2442
20,807
HewlettPackard/hpe3par_ruby_sdk
lib/Hpe3parSdk/client.rb
Hpe3parSdk.Client.get_online_physical_copy_status
def get_online_physical_copy_status(name) begin @volume.get_online_physical_copy_status(name) rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
ruby
def get_online_physical_copy_status(name) begin @volume.get_online_physical_copy_status(name) rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
[ "def", "get_online_physical_copy_status", "(", "name", ")", "begin", "@volume", ".", "get_online_physical_copy_status", "(", "name", ")", "rescue", "=>", "ex", "Util", ".", "log_exception", "(", "ex", ",", "caller_locations", "(", "1", ",", "1", ")", "[", "0",...
Gets the status of an online physical copy ==== Attributes * name - The name of the volume type name: str ==== Returns Status of online copy (String) ==== Raises * Hpe3parSdk::HPE3PARException Error: message: Volume not an online physical copy
[ "Gets", "the", "status", "of", "an", "online", "physical", "copy" ]
f8cfc6e597741be593cf7fe013accadf982ee68b
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L2459-L2466
20,808
HewlettPackard/hpe3par_ruby_sdk
lib/Hpe3parSdk/client.rb
Hpe3parSdk.Client.stop_offline_physical_copy
def stop_offline_physical_copy(name) begin @volume.stop_offline_physical_copy(name) rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
ruby
def stop_offline_physical_copy(name) begin @volume.stop_offline_physical_copy(name) rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
[ "def", "stop_offline_physical_copy", "(", "name", ")", "begin", "@volume", ".", "stop_offline_physical_copy", "(", "name", ")", "rescue", "=>", "ex", "Util", ".", "log_exception", "(", "ex", ",", "caller_locations", "(", "1", ",", "1", ")", "[", "0", "]", ...
Stops an offline physical copy operation ==== Attributes * name - The name of the volume type name: String
[ "Stops", "an", "offline", "physical", "copy", "operation" ]
f8cfc6e597741be593cf7fe013accadf982ee68b
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L2474-L2481
20,809
HewlettPackard/hpe3par_ruby_sdk
lib/Hpe3parSdk/client.rb
Hpe3parSdk.Client.stop_online_physical_copy
def stop_online_physical_copy(name) begin @volume.stop_online_physical_copy(name) rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
ruby
def stop_online_physical_copy(name) begin @volume.stop_online_physical_copy(name) rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
[ "def", "stop_online_physical_copy", "(", "name", ")", "begin", "@volume", ".", "stop_online_physical_copy", "(", "name", ")", "rescue", "=>", "ex", "Util", ".", "log_exception", "(", "ex", ",", "caller_locations", "(", "1", ",", "1", ")", "[", "0", "]", "....
Stops an online physical copy operation ==== Attributes * name - The name of the volume type name: String
[ "Stops", "an", "online", "physical", "copy", "operation" ]
f8cfc6e597741be593cf7fe013accadf982ee68b
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L2489-L2496
20,810
HewlettPackard/hpe3par_ruby_sdk
lib/Hpe3parSdk/client.rb
Hpe3parSdk.Client.resync_physical_copy
def resync_physical_copy(name) begin @volume.resync_physical_copy(name) rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
ruby
def resync_physical_copy(name) begin @volume.resync_physical_copy(name) rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
[ "def", "resync_physical_copy", "(", "name", ")", "begin", "@volume", ".", "resync_physical_copy", "(", "name", ")", "rescue", "=>", "ex", "Util", ".", "log_exception", "(", "ex", ",", "caller_locations", "(", "1", ",", "1", ")", "[", "0", "]", ".", "labe...
Resynchronizes a physical copy. ==== Attributes * name - The name of the volume type name: String
[ "Resynchronizes", "a", "physical", "copy", "." ]
f8cfc6e597741be593cf7fe013accadf982ee68b
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L2504-L2511
20,811
HewlettPackard/hpe3par_ruby_sdk
lib/Hpe3parSdk/client.rb
Hpe3parSdk.Client.wait_for_task_to_end
def wait_for_task_to_end(task_id, poll_rate_secs = 15) begin @task.wait_for_task_to_end(task_id, poll_rate_secs) rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
ruby
def wait_for_task_to_end(task_id, poll_rate_secs = 15) begin @task.wait_for_task_to_end(task_id, poll_rate_secs) rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
[ "def", "wait_for_task_to_end", "(", "task_id", ",", "poll_rate_secs", "=", "15", ")", "begin", "@task", ".", "wait_for_task_to_end", "(", "task_id", ",", "poll_rate_secs", ")", "rescue", "=>", "ex", "Util", ".", "log_exception", "(", "ex", ",", "caller_locations...
Waits for a 3PAR task to end. ==== Attributes * task_id - The Id of the task to be waited upon. type task_id: Integer * poll_rate_secs - The polling interval in seconds. type poll_rate_secs: Integer
[ "Waits", "for", "a", "3PAR", "task", "to", "end", "." ]
f8cfc6e597741be593cf7fe013accadf982ee68b
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L2521-L2528
20,812
HewlettPackard/hpe3par_ruby_sdk
lib/Hpe3parSdk/client.rb
Hpe3parSdk.Client.cancel_task
def cancel_task(task_id) begin @task.cancel_task(task_id) rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
ruby
def cancel_task(task_id) begin @task.cancel_task(task_id) rescue => ex Util.log_exception(ex, caller_locations(1, 1)[0].label) raise ex end end
[ "def", "cancel_task", "(", "task_id", ")", "begin", "@task", ".", "cancel_task", "(", "task_id", ")", "rescue", "=>", "ex", "Util", ".", "log_exception", "(", "ex", ",", "caller_locations", "(", "1", ",", "1", ")", "[", "0", "]", ".", "label", ")", "...
Cancel a 3PAR task ==== Attributes * task_id - The Id of the task to be cancelled. type task_id: Integer ==== Raises * Hpe3parSdk::HTTPBadRequest - NON_ACTIVE_TASK - The task is not active at this time. * Hpe3parSdk::HTTPConflict - INV_OPERATION_CANNOT_CANCEL_ TASK - Invalid operation: Tas...
[ "Cancel", "a", "3PAR", "task" ]
f8cfc6e597741be593cf7fe013accadf982ee68b
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L2542-L2549
20,813
HewlettPackard/hpe3par_ruby_sdk
lib/Hpe3parSdk/client.rb
Hpe3parSdk.Client.logout
def logout unless @log_file_path.nil? if Hpe3parSdk.logger != nil Hpe3parSdk.logger.close Hpe3parSdk.logger = nil end end begin @http.unauthenticate rescue Hpe3parSdk::HPE3PARException => ex #Do nothing end end
ruby
def logout unless @log_file_path.nil? if Hpe3parSdk.logger != nil Hpe3parSdk.logger.close Hpe3parSdk.logger = nil end end begin @http.unauthenticate rescue Hpe3parSdk::HPE3PARException => ex #Do nothing end end
[ "def", "logout", "unless", "@log_file_path", ".", "nil?", "if", "Hpe3parSdk", ".", "logger", "!=", "nil", "Hpe3parSdk", ".", "logger", ".", "close", "Hpe3parSdk", ".", "logger", "=", "nil", "end", "end", "begin", "@http", ".", "unauthenticate", "rescue", "Hp...
Logout from the 3PAR Array
[ "Logout", "from", "the", "3PAR", "Array" ]
f8cfc6e597741be593cf7fe013accadf982ee68b
https://github.com/HewlettPackard/hpe3par_ruby_sdk/blob/f8cfc6e597741be593cf7fe013accadf982ee68b/lib/Hpe3parSdk/client.rb#L2633-L2645
20,814
blythedunham/health_monitor
lib/health_monitor/built_in_checks.rb
HealthMonitor.BuiltInChecks.ey_agent_check
def ey_agent_check results = { :description => 'Run ey-agent to monitor haproxy and monitor' } agent_results = JSON.load( `sudo ey-agent` ) results.update( :message => agent_results.inspect, :status => agent_results && agent_results.any?{|k,v| v == 'down' } ) ...
ruby
def ey_agent_check results = { :description => 'Run ey-agent to monitor haproxy and monitor' } agent_results = JSON.load( `sudo ey-agent` ) results.update( :message => agent_results.inspect, :status => agent_results && agent_results.any?{|k,v| v == 'down' } ) ...
[ "def", "ey_agent_check", "results", "=", "{", ":description", "=>", "'Run ey-agent to monitor haproxy and monitor'", "}", "agent_results", "=", "JSON", ".", "load", "(", "`", "`", ")", "results", ".", "update", "(", ":message", "=>", "agent_results", ".", "inspect...
Call ey-agent to return nginx or apache status as well as database status
[ "Call", "ey", "-", "agent", "to", "return", "nginx", "or", "apache", "status", "as", "well", "as", "database", "status" ]
de41ae1204ff8d88d20e134c280e70d618d60dfc
https://github.com/blythedunham/health_monitor/blob/de41ae1204ff8d88d20e134c280e70d618d60dfc/lib/health_monitor/built_in_checks.rb#L49-L62
20,815
blythedunham/health_monitor
lib/health_monitor/health_monitoring.rb
HealthMonitor.HealthMonitoring.monitor_health
def monitor_health find_features @results = @features.inject({}) do |results, feature_name| results[ feature_name ] = monitor_health_of( feature_name ) results end healthy? ? on_healthy : on_unhealthy render_health end
ruby
def monitor_health find_features @results = @features.inject({}) do |results, feature_name| results[ feature_name ] = monitor_health_of( feature_name ) results end healthy? ? on_healthy : on_unhealthy render_health end
[ "def", "monitor_health", "find_features", "@results", "=", "@features", ".", "inject", "(", "{", "}", ")", "do", "|", "results", ",", "feature_name", "|", "results", "[", "feature_name", "]", "=", "monitor_health_of", "(", "feature_name", ")", "results", "end"...
Show a status page showing the health of monitored features Returns a 404 if any features have a success of unsuccessful Skip features: z2live.com/health/status?skip=mongo,mysql Include features: z2live.com/health/status?feature=mongo
[ "Show", "a", "status", "page", "showing", "the", "health", "of", "monitored", "features", "Returns", "a", "404", "if", "any", "features", "have", "a", "success", "of", "unsuccessful" ]
de41ae1204ff8d88d20e134c280e70d618d60dfc
https://github.com/blythedunham/health_monitor/blob/de41ae1204ff8d88d20e134c280e70d618d60dfc/lib/health_monitor/health_monitoring.rb#L188-L196
20,816
blythedunham/health_monitor
lib/health_monitor/health_monitoring.rb
HealthMonitor.HealthMonitoring.render_health
def render_health return if performed? respond_to do |format| format.html { render_health_html } format.js { render_health_json } format.xml { render_health_xml } end end
ruby
def render_health return if performed? respond_to do |format| format.html { render_health_html } format.js { render_health_json } format.xml { render_health_xml } end end
[ "def", "render_health", "return", "if", "performed?", "respond_to", "do", "|", "format", "|", "format", ".", "html", "{", "render_health_html", "}", "format", ".", "js", "{", "render_health_json", "}", "format", ".", "xml", "{", "render_health_xml", "}", "end"...
Render the result
[ "Render", "the", "result" ]
de41ae1204ff8d88d20e134c280e70d618d60dfc
https://github.com/blythedunham/health_monitor/blob/de41ae1204ff8d88d20e134c280e70d618d60dfc/lib/health_monitor/health_monitoring.rb#L257-L265
20,817
blythedunham/health_monitor
lib/health_monitor/health_monitoring.rb
HealthMonitor.HealthMonitoring.find_features
def find_features @features = if params[ :only ] params[ :only ].to_s.split( "," ).collect( &:to_sym ).uniq elsif skip = params[ :skip ] || params[ :exclude ] monitored_features.keys - skip.to_s.split( "," ).collect( &:to_sym ) else monitored_features.keys end end
ruby
def find_features @features = if params[ :only ] params[ :only ].to_s.split( "," ).collect( &:to_sym ).uniq elsif skip = params[ :skip ] || params[ :exclude ] monitored_features.keys - skip.to_s.split( "," ).collect( &:to_sym ) else monitored_features.keys end end
[ "def", "find_features", "@features", "=", "if", "params", "[", ":only", "]", "params", "[", ":only", "]", ".", "to_s", ".", "split", "(", "\",\"", ")", ".", "collect", "(", ":to_sym", ")", ".", "uniq", "elsif", "skip", "=", "params", "[", ":skip", "]...
Skip features by appending skip=mongo,fun,etc Include features by appending feature=mongo,urban_airship,etc to filter
[ "Skip", "features", "by", "appending", "skip", "=", "mongo", "fun", "etc", "Include", "features", "by", "appending", "feature", "=", "mongo", "urban_airship", "etc", "to", "filter" ]
de41ae1204ff8d88d20e134c280e70d618d60dfc
https://github.com/blythedunham/health_monitor/blob/de41ae1204ff8d88d20e134c280e70d618d60dfc/lib/health_monitor/health_monitoring.rb#L271-L281
20,818
cloudfoundry-attic/vmc
lib/vmc/cli/app/start.rb
VMC::App.Start.switch_mode
def switch_mode(app, mode) mode = nil if mode == "none" mode = "run" if mode == "" # no value given return false if app.debug == mode if mode.nil? with_progress("Removing debug mode") do app.debug = nil app.stop! if app.started? end return true ...
ruby
def switch_mode(app, mode) mode = nil if mode == "none" mode = "run" if mode == "" # no value given return false if app.debug == mode if mode.nil? with_progress("Removing debug mode") do app.debug = nil app.stop! if app.started? end return true ...
[ "def", "switch_mode", "(", "app", ",", "mode", ")", "mode", "=", "nil", "if", "mode", "==", "\"none\"", "mode", "=", "\"run\"", "if", "mode", "==", "\"\"", "# no value given", "return", "false", "if", "app", ".", "debug", "==", "mode", "if", "mode", "....
set app debug mode, ensuring it's valid, and shutting it down
[ "set", "app", "debug", "mode", "ensuring", "it", "s", "valid", "and", "shutting", "it", "down" ]
87528848570e3ffe58a57ce9a804abec6bdecc5a
https://github.com/cloudfoundry-attic/vmc/blob/87528848570e3ffe58a57ce9a804abec6bdecc5a/lib/vmc/cli/app/start.rb#L66-L85
20,819
lenovo/xclarity_client
lib/xclarity_client/services/xclarity_management_mixin.rb
XClarityClient.ManagementMixin.add_listname_on_body
def add_listname_on_body(resource, body) body.kind_of?(Array) ? process_body_as_array(resource, body) : process_body_as_hash(resource, body) end
ruby
def add_listname_on_body(resource, body) body.kind_of?(Array) ? process_body_as_array(resource, body) : process_body_as_hash(resource, body) end
[ "def", "add_listname_on_body", "(", "resource", ",", "body", ")", "body", ".", "kind_of?", "(", "Array", ")", "?", "process_body_as_array", "(", "resource", ",", "body", ")", ":", "process_body_as_hash", "(", "resource", ",", "body", ")", "end" ]
Process the response body to make sure that its contains the list name defined on resource Returns the list name present on body and the body itself
[ "Process", "the", "response", "body", "to", "make", "sure", "that", "its", "contains", "the", "list", "name", "defined", "on", "resource", "Returns", "the", "list", "name", "present", "on", "body", "and", "the", "body", "itself" ]
42a9cd16617302c028190de8b3d50abd134dd61f
https://github.com/lenovo/xclarity_client/blob/42a9cd16617302c028190de8b3d50abd134dd61f/lib/xclarity_client/services/xclarity_management_mixin.rb#L155-L157
20,820
lenovo/xclarity_client
lib/xclarity_client/services/xclarity_management_mixin.rb
XClarityClient.ManagementMixin.any_listname_of
def any_listname_of(resource) if resource::LIST_NAME.kind_of?(Array) resource::LIST_NAME.first # If is an array, any listname can be use else resource::LIST_NAME # If is not an array, just return the listname of resource end end
ruby
def any_listname_of(resource) if resource::LIST_NAME.kind_of?(Array) resource::LIST_NAME.first # If is an array, any listname can be use else resource::LIST_NAME # If is not an array, just return the listname of resource end end
[ "def", "any_listname_of", "(", "resource", ")", "if", "resource", "::", "LIST_NAME", ".", "kind_of?", "(", "Array", ")", "resource", "::", "LIST_NAME", ".", "first", "# If is an array, any listname can be use", "else", "resource", "::", "LIST_NAME", "# If is not an ar...
Return any listname described on resource
[ "Return", "any", "listname", "described", "on", "resource" ]
42a9cd16617302c028190de8b3d50abd134dd61f
https://github.com/lenovo/xclarity_client/blob/42a9cd16617302c028190de8b3d50abd134dd61f/lib/xclarity_client/services/xclarity_management_mixin.rb#L160-L166
20,821
lenovo/xclarity_client
lib/xclarity_client/services/xclarity_management_mixin.rb
XClarityClient.ManagementMixin.process_body_as_hash
def process_body_as_hash(resource, body) result = body if resource::LIST_NAME.kind_of? Array # search which list name is present on body list_name = resource::LIST_NAME.find { |name| body.keys.include?(name) && body[name].kind_of?(Array) } else list_name = any_listname_of(resource) ...
ruby
def process_body_as_hash(resource, body) result = body if resource::LIST_NAME.kind_of? Array # search which list name is present on body list_name = resource::LIST_NAME.find { |name| body.keys.include?(name) && body[name].kind_of?(Array) } else list_name = any_listname_of(resource) ...
[ "def", "process_body_as_hash", "(", "resource", ",", "body", ")", "result", "=", "body", "if", "resource", "::", "LIST_NAME", ".", "kind_of?", "Array", "# search which list name is present on body", "list_name", "=", "resource", "::", "LIST_NAME", ".", "find", "{", ...
Discover what list name defined on resource is present on body If none of then is find assume that the body is a single resource and add it value into array and assing to any list name
[ "Discover", "what", "list", "name", "defined", "on", "resource", "is", "present", "on", "body", "If", "none", "of", "then", "is", "find", "assume", "that", "the", "body", "is", "a", "single", "resource", "and", "add", "it", "value", "into", "array", "and...
42a9cd16617302c028190de8b3d50abd134dd61f
https://github.com/lenovo/xclarity_client/blob/42a9cd16617302c028190de8b3d50abd134dd61f/lib/xclarity_client/services/xclarity_management_mixin.rb#L178-L188
20,822
lenovo/xclarity_client
lib/xclarity_client/services/user_management.rb
XClarityClient.UserManagement.mount_response_change_password
def mount_response_change_password(response) response = JSON.parse(response.body) { changed: response['response']['changed'], message: response['messages'].first['explanation'] } end
ruby
def mount_response_change_password(response) response = JSON.parse(response.body) { changed: response['response']['changed'], message: response['messages'].first['explanation'] } end
[ "def", "mount_response_change_password", "(", "response", ")", "response", "=", "JSON", ".", "parse", "(", "response", ".", "body", ")", "{", "changed", ":", "response", "[", "'response'", "]", "[", "'changed'", "]", ",", "message", ":", "response", "[", "...
Mounts a friendly response for the change password request @param [response] response provided by LXCA in change password endpoint @return [Hash] represents LXCA response :changed [Boolean] says if the password was changed or not :message [String] message from LXCA about the operation
[ "Mounts", "a", "friendly", "response", "for", "the", "change", "password", "request" ]
42a9cd16617302c028190de8b3d50abd134dd61f
https://github.com/lenovo/xclarity_client/blob/42a9cd16617302c028190de8b3d50abd134dd61f/lib/xclarity_client/services/user_management.rb#L29-L36
20,823
markaby/markaby
lib/markaby/builder.rb
Markaby.Builder.capture
def capture(&block) @streams.push(@builder.target = Stream.new) @builder.level += 1 str = instance_eval(&block) str = @streams.last.join if @streams.last.any? @streams.pop @builder.level -= 1 @builder.target = @streams.last str end
ruby
def capture(&block) @streams.push(@builder.target = Stream.new) @builder.level += 1 str = instance_eval(&block) str = @streams.last.join if @streams.last.any? @streams.pop @builder.level -= 1 @builder.target = @streams.last str end
[ "def", "capture", "(", "&", "block", ")", "@streams", ".", "push", "(", "@builder", ".", "target", "=", "Stream", ".", "new", ")", "@builder", ".", "level", "+=", "1", "str", "=", "instance_eval", "(", "block", ")", "str", "=", "@streams", ".", "last...
Captures the HTML code built inside the +block+. This is done by creating a new stream for the builder object, running the block and passing back its stream as a string. >> Markaby::Builder.new.capture { h1 "TEST"; h2 "CAPTURE ME" } => "<h1>TEST</h1><h2>CAPTURE ME</h2>"
[ "Captures", "the", "HTML", "code", "built", "inside", "the", "+", "block", "+", ".", "This", "is", "done", "by", "creating", "a", "new", "stream", "for", "the", "builder", "object", "running", "the", "block", "and", "passing", "back", "its", "stream", "a...
e44d7e16cd86302ecce1694b95940b5eb402acf7
https://github.com/markaby/markaby/blob/e44d7e16cd86302ecce1694b95940b5eb402acf7/lib/markaby/builder.rb#L139-L148
20,824
markaby/markaby
lib/markaby/builder.rb
Markaby.Builder.tag!
def tag!(tag, *args, &block) ele_id = nil # TODO: Move this logic to the tagset so that the tagset itself can validate + raise when invalid if @auto_validation && @tagset if !@tagset.tagset.has_key?(tag) raise InvalidXhtmlError, "no element `#{tag}' for #{tagset.doctype}" el...
ruby
def tag!(tag, *args, &block) ele_id = nil # TODO: Move this logic to the tagset so that the tagset itself can validate + raise when invalid if @auto_validation && @tagset if !@tagset.tagset.has_key?(tag) raise InvalidXhtmlError, "no element `#{tag}' for #{tagset.doctype}" el...
[ "def", "tag!", "(", "tag", ",", "*", "args", ",", "&", "block", ")", "ele_id", "=", "nil", "# TODO: Move this logic to the tagset so that the tagset itself can validate + raise when invalid", "if", "@auto_validation", "&&", "@tagset", "if", "!", "@tagset", ".", "tagset"...
Create a tag named +tag+. Other than the first argument which is the tag name, the arguments are the same as the tags implemented via method_missing.
[ "Create", "a", "tag", "named", "+", "tag", "+", ".", "Other", "than", "the", "first", "argument", "which", "is", "the", "tag", "name", "the", "arguments", "are", "the", "same", "as", "the", "tags", "implemented", "via", "method_missing", "." ]
e44d7e16cd86302ecce1694b95940b5eb402acf7
https://github.com/markaby/markaby/blob/e44d7e16cd86302ecce1694b95940b5eb402acf7/lib/markaby/builder.rb#L152-L200
20,825
lenovo/xclarity_client
lib/xclarity_client/services/update_comp_management.rb
XClarityClient.UpdateCompManagement.add_uri
def add_uri(force_update_mode, onerror_mode, uri) fmode = force_update_mode.nil? uri += '&forceUpdateMode=' + force_update_mode unless fmode uri += '&onErrorMode=' + onerror_mode unless onerror_mode.nil? uri end
ruby
def add_uri(force_update_mode, onerror_mode, uri) fmode = force_update_mode.nil? uri += '&forceUpdateMode=' + force_update_mode unless fmode uri += '&onErrorMode=' + onerror_mode unless onerror_mode.nil? uri end
[ "def", "add_uri", "(", "force_update_mode", ",", "onerror_mode", ",", "uri", ")", "fmode", "=", "force_update_mode", ".", "nil?", "uri", "+=", "'&forceUpdateMode='", "+", "force_update_mode", "unless", "fmode", "uri", "+=", "'&onErrorMode='", "+", "onerror_mode", ...
splitted create_uri just to fix codeclimate error
[ "splitted", "create_uri", "just", "to", "fix", "codeclimate", "error" ]
42a9cd16617302c028190de8b3d50abd134dd61f
https://github.com/lenovo/xclarity_client/blob/42a9cd16617302c028190de8b3d50abd134dd61f/lib/xclarity_client/services/update_comp_management.rb#L86-L91
20,826
bmedici/rest-ftp-daemon
lib/rest-ftp-daemon/job_queue.rb
RestFtpDaemon.JobQueue.jobs_with_status
def jobs_with_status status # No status filter: return all execept queued if status.empty? @jobs.reject { |job| job.status == JOB_STATUS_QUEUED } # Status filtering: only those jobs else @jobs.select { |job| job.status == status.to_s } end end
ruby
def jobs_with_status status # No status filter: return all execept queued if status.empty? @jobs.reject { |job| job.status == JOB_STATUS_QUEUED } # Status filtering: only those jobs else @jobs.select { |job| job.status == status.to_s } end end
[ "def", "jobs_with_status", "status", "# No status filter: return all execept queued", "if", "status", ".", "empty?", "@jobs", ".", "reject", "{", "|", "job", "|", "job", ".", "status", "==", "JOB_STATUS_QUEUED", "}", "# Status filtering: only those jobs", "else", "@jobs...
Jobs acess and searching
[ "Jobs", "acess", "and", "searching" ]
72754b9fb1ada2a4711a2f2351a3aa47adaa43da
https://github.com/bmedici/rest-ftp-daemon/blob/72754b9fb1ada2a4711a2f2351a3aa47adaa43da/lib/rest-ftp-daemon/job_queue.rb#L210-L220
20,827
bmedici/rest-ftp-daemon
lib/rest-ftp-daemon/job.rb
RestFtpDaemon.Job.debug_value_utf8
def debug_value_utf8 value case value when Symbol return value.to_s.force_encoding(Encoding::UTF_8) when String return value.dup.force_encoding(Encoding::UTF_8) if value.is_a? String else return value end end
ruby
def debug_value_utf8 value case value when Symbol return value.to_s.force_encoding(Encoding::UTF_8) when String return value.dup.force_encoding(Encoding::UTF_8) if value.is_a? String else return value end end
[ "def", "debug_value_utf8", "value", "case", "value", "when", "Symbol", "return", "value", ".", "to_s", ".", "force_encoding", "(", "Encoding", "::", "UTF_8", ")", "when", "String", "return", "value", ".", "dup", ".", "force_encoding", "(", "Encoding", "::", ...
Force strings to UTF8
[ "Force", "strings", "to", "UTF8" ]
72754b9fb1ada2a4711a2f2351a3aa47adaa43da
https://github.com/bmedici/rest-ftp-daemon/blob/72754b9fb1ada2a4711a2f2351a3aa47adaa43da/lib/rest-ftp-daemon/job.rb#L246-L255
20,828
james2m/canard
lib/canard/user_model.rb
Canard.UserModel.has_roles_mask_accessors?
def has_roles_mask_accessors? instance_method_names = instance_methods.map { |method_name| method_name.to_s } [roles_attribute_name.to_s, "#{roles_attribute_name}="].all? do |accessor| instance_method_names.include?(accessor) end end
ruby
def has_roles_mask_accessors? instance_method_names = instance_methods.map { |method_name| method_name.to_s } [roles_attribute_name.to_s, "#{roles_attribute_name}="].all? do |accessor| instance_method_names.include?(accessor) end end
[ "def", "has_roles_mask_accessors?", "instance_method_names", "=", "instance_methods", ".", "map", "{", "|", "method_name", "|", "method_name", ".", "to_s", "}", "[", "roles_attribute_name", ".", "to_s", ",", "\"#{roles_attribute_name}=\"", "]", ".", "all?", "do", "|...
This is overridden by the ActiveRecord adapter as the attribute accessors don't show up in instance_methods.
[ "This", "is", "overridden", "by", "the", "ActiveRecord", "adapter", "as", "the", "attribute", "accessors", "don", "t", "show", "up", "in", "instance_methods", "." ]
59caec2648aa95b88fd53b999ab19d1366750b6c
https://github.com/james2m/canard/blob/59caec2648aa95b88fd53b999ab19d1366750b6c/lib/canard/user_model.rb#L83-L88
20,829
alagu/pagoda
lib/pagoda/app.rb
Shwedagon.App.create_new_post
def create_new_post(params) post_title = params['post']['title'] post_date = (Time.now).strftime("%Y-%m-%d") content = yaml_data(post_title).to_yaml + "---\n" + params[:post][:content] post_file = (post_date + " " + post_title).to_url + '.md' file = File.join(jekyll_site....
ruby
def create_new_post(params) post_title = params['post']['title'] post_date = (Time.now).strftime("%Y-%m-%d") content = yaml_data(post_title).to_yaml + "---\n" + params[:post][:content] post_file = (post_date + " " + post_title).to_url + '.md' file = File.join(jekyll_site....
[ "def", "create_new_post", "(", "params", ")", "post_title", "=", "params", "[", "'post'", "]", "[", "'title'", "]", "post_date", "=", "(", "Time", ".", "now", ")", ".", "strftime", "(", "\"%Y-%m-%d\"", ")", "content", "=", "yaml_data", "(", "post_title", ...
Create a new post from scratch. Return filename This would not commit the file.
[ "Create", "a", "new", "post", "from", "scratch", ".", "Return", "filename", "This", "would", "not", "commit", "the", "file", "." ]
c1587fb245946f8cca1ceee19ef6677f315c42ed
https://github.com/alagu/pagoda/blob/c1587fb245946f8cca1ceee19ef6677f315c42ed/lib/pagoda/app.rb#L43-L52
20,830
alagu/pagoda
lib/pagoda/app.rb
Shwedagon.App.merge_config
def merge_config(yaml, params) if params['post'].has_key? 'yaml' params['post']['yaml'].each do |key, value| if value == 'true' yaml[key] = true elsif value == 'false' yaml[key] = false else yaml[key] = value end end ...
ruby
def merge_config(yaml, params) if params['post'].has_key? 'yaml' params['post']['yaml'].each do |key, value| if value == 'true' yaml[key] = true elsif value == 'false' yaml[key] = false else yaml[key] = value end end ...
[ "def", "merge_config", "(", "yaml", ",", "params", ")", "if", "params", "[", "'post'", "]", ".", "has_key?", "'yaml'", "params", "[", "'post'", "]", "[", "'yaml'", "]", ".", "each", "do", "|", "key", ",", "value", "|", "if", "value", "==", "'true'", ...
Merge existing yaml with post params
[ "Merge", "existing", "yaml", "with", "post", "params" ]
c1587fb245946f8cca1ceee19ef6677f315c42ed
https://github.com/alagu/pagoda/blob/c1587fb245946f8cca1ceee19ef6677f315c42ed/lib/pagoda/app.rb#L56-L70
20,831
alagu/pagoda
lib/pagoda/app.rb
Shwedagon.App.update_post
def update_post(params) post_file = params[:post][:name] post = jekyll_post(post_file) yaml_config = merge_config(post.data, params) write_post_contents(params[:post][:content], yaml_config, post_file) post_file end
ruby
def update_post(params) post_file = params[:post][:name] post = jekyll_post(post_file) yaml_config = merge_config(post.data, params) write_post_contents(params[:post][:content], yaml_config, post_file) post_file end
[ "def", "update_post", "(", "params", ")", "post_file", "=", "params", "[", ":post", "]", "[", ":name", "]", "post", "=", "jekyll_post", "(", "post_file", ")", "yaml_config", "=", "merge_config", "(", "post", ".", "data", ",", "params", ")", "write_post_con...
Update exiting post.
[ "Update", "exiting", "post", "." ]
c1587fb245946f8cca1ceee19ef6677f315c42ed
https://github.com/alagu/pagoda/blob/c1587fb245946f8cca1ceee19ef6677f315c42ed/lib/pagoda/app.rb#L82-L89
20,832
alagu/pagoda
lib/pagoda/helper.rb
Shwedagon.App.jekyll_site
def jekyll_site if not @site # Supress stdout original_stdout = $stdout $stdout = File.new('/tmp/null.txt', 'w') config = Jekyll.configuration({'source' => cloned_repo_path}) @site = Jekyll::Site.new(config) @site.read $stdout = original_stdout en...
ruby
def jekyll_site if not @site # Supress stdout original_stdout = $stdout $stdout = File.new('/tmp/null.txt', 'w') config = Jekyll.configuration({'source' => cloned_repo_path}) @site = Jekyll::Site.new(config) @site.read $stdout = original_stdout en...
[ "def", "jekyll_site", "if", "not", "@site", "# Supress stdout", "original_stdout", "=", "$stdout", "$stdout", "=", "File", ".", "new", "(", "'/tmp/null.txt'", ",", "'w'", ")", "config", "=", "Jekyll", ".", "configuration", "(", "{", "'source'", "=>", "cloned_r...
Jekyll site instance
[ "Jekyll", "site", "instance" ]
c1587fb245946f8cca1ceee19ef6677f315c42ed
https://github.com/alagu/pagoda/blob/c1587fb245946f8cca1ceee19ef6677f315c42ed/lib/pagoda/helper.rb#L6-L20
20,833
alagu/pagoda
lib/pagoda/helper.rb
Shwedagon.App.posts_template_data
def posts_template_data(post_items) if post_items.nil? return [] end template_data = post_items.map do |post| { :title => post.data['title'], :filename => post.name, :date => post.date } end template_data.sort! { |x,y| y[:date]...
ruby
def posts_template_data(post_items) if post_items.nil? return [] end template_data = post_items.map do |post| { :title => post.data['title'], :filename => post.name, :date => post.date } end template_data.sort! { |x,y| y[:date]...
[ "def", "posts_template_data", "(", "post_items", ")", "if", "post_items", ".", "nil?", "return", "[", "]", "end", "template_data", "=", "post_items", ".", "map", "do", "|", "post", "|", "{", ":title", "=>", "post", ".", "data", "[", "'title'", "]", ",", ...
Gives out a sorted list of post template data for a post or draft
[ "Gives", "out", "a", "sorted", "list", "of", "post", "template", "data", "for", "a", "post", "or", "draft" ]
c1587fb245946f8cca1ceee19ef6677f315c42ed
https://github.com/alagu/pagoda/blob/c1587fb245946f8cca1ceee19ef6677f315c42ed/lib/pagoda/helper.rb#L86-L102
20,834
xuanxu/nimbus
lib/nimbus/application.rb
Nimbus.Application.nimbus_exception_handling
def nimbus_exception_handling begin yield rescue SystemExit => ex raise rescue Nimbus::Error => ex display_error_message(ex) Nimbus.stop rescue Exception => ex display_error_message(ex) Nimbus.stop end end
ruby
def nimbus_exception_handling begin yield rescue SystemExit => ex raise rescue Nimbus::Error => ex display_error_message(ex) Nimbus.stop rescue Exception => ex display_error_message(ex) Nimbus.stop end end
[ "def", "nimbus_exception_handling", "begin", "yield", "rescue", "SystemExit", "=>", "ex", "raise", "rescue", "Nimbus", "::", "Error", "=>", "ex", "display_error_message", "(", "ex", ")", "Nimbus", ".", "stop", "rescue", "Exception", "=>", "ex", "display_error_mess...
Provides the default exception handling for the given block.
[ "Provides", "the", "default", "exception", "handling", "for", "the", "given", "block", "." ]
6646dbc00147408765044a99702005d3d30e052e
https://github.com/xuanxu/nimbus/blob/6646dbc00147408765044a99702005d3d30e052e/lib/nimbus/application.rb#L57-L69
20,835
xuanxu/nimbus
lib/nimbus/regression_tree.rb
Nimbus.RegressionTree.seed
def seed(all_individuals, individuals_sample, ids_fenotypes) super @structure = build_node individuals_sample, Nimbus::LossFunctions.average(individuals_sample, @id_to_fenotype) end
ruby
def seed(all_individuals, individuals_sample, ids_fenotypes) super @structure = build_node individuals_sample, Nimbus::LossFunctions.average(individuals_sample, @id_to_fenotype) end
[ "def", "seed", "(", "all_individuals", ",", "individuals_sample", ",", "ids_fenotypes", ")", "super", "@structure", "=", "build_node", "individuals_sample", ",", "Nimbus", "::", "LossFunctions", ".", "average", "(", "individuals_sample", ",", "@id_to_fenotype", ")", ...
Creates the structure of the tree, as a hash of SNP splits and values. It just initializes the needed variables and then defines the first node of the tree. The rest of the structure of the tree is computed recursively building every node calling +build_node+.
[ "Creates", "the", "structure", "of", "the", "tree", "as", "a", "hash", "of", "SNP", "splits", "and", "values", "." ]
6646dbc00147408765044a99702005d3d30e052e
https://github.com/xuanxu/nimbus/blob/6646dbc00147408765044a99702005d3d30e052e/lib/nimbus/regression_tree.rb#L23-L26
20,836
xuanxu/nimbus
lib/nimbus/configuration.rb
Nimbus.Configuration.load
def load(config_file = DEFAULTS[:config_file]) user_config_params = {} dirname = Dir.pwd if File.exists?(File.expand_path(config_file, Dir.pwd)) begin config_file_path = File.expand_path config_file, Dir.pwd user_config_params = Psych.load(File.open(config_file_path)) ...
ruby
def load(config_file = DEFAULTS[:config_file]) user_config_params = {} dirname = Dir.pwd if File.exists?(File.expand_path(config_file, Dir.pwd)) begin config_file_path = File.expand_path config_file, Dir.pwd user_config_params = Psych.load(File.open(config_file_path)) ...
[ "def", "load", "(", "config_file", "=", "DEFAULTS", "[", ":config_file", "]", ")", "user_config_params", "=", "{", "}", "dirname", "=", "Dir", ".", "pwd", "if", "File", ".", "exists?", "(", "File", ".", "expand_path", "(", "config_file", ",", "Dir", ".",...
This is the first method to be called on Configuration when a config.yml file exists with user input options for the forest. * The method will read the config file and change the default value of the selected options. * Then based on the options and the existence of training, testing and forest files, it will mark:...
[ "This", "is", "the", "first", "method", "to", "be", "called", "on", "Configuration", "when", "a", "config", ".", "yml", "file", "exists", "with", "user", "input", "options", "for", "the", "forest", "." ]
6646dbc00147408765044a99702005d3d30e052e
https://github.com/xuanxu/nimbus/blob/6646dbc00147408765044a99702005d3d30e052e/lib/nimbus/configuration.rb#L105-L148
20,837
AlchemyCMS/alchemy-devise
app/models/alchemy/user.rb
Alchemy.User.fullname
def fullname(options = {}) if lastname.blank? && firstname.blank? login else options = {:flipped => false}.merge(options) fullname = options[:flipped] ? "#{lastname}, #{firstname}" : "#{firstname} #{lastname}" fullname.squeeze(" ").strip end end
ruby
def fullname(options = {}) if lastname.blank? && firstname.blank? login else options = {:flipped => false}.merge(options) fullname = options[:flipped] ? "#{lastname}, #{firstname}" : "#{firstname} #{lastname}" fullname.squeeze(" ").strip end end
[ "def", "fullname", "(", "options", "=", "{", "}", ")", "if", "lastname", ".", "blank?", "&&", "firstname", ".", "blank?", "login", "else", "options", "=", "{", ":flipped", "=>", "false", "}", ".", "merge", "(", "options", ")", "fullname", "=", "options...
Returns the firstname and lastname as a string If both are blank, returns the login @option options :flipped (false) Flip the firstname and lastname
[ "Returns", "the", "firstname", "and", "lastname", "as", "a", "string" ]
ab1781db136cc634c38775d939f45e98f9d74e8e
https://github.com/AlchemyCMS/alchemy-devise/blob/ab1781db136cc634c38775d939f45e98f9d74e8e/app/models/alchemy/user.rb#L125-L133
20,838
AlchemyCMS/alchemy-devise
app/models/alchemy/user.rb
Alchemy.User.deliver_welcome_mail
def deliver_welcome_mail if has_role?('author') || has_role?('editor') || has_role?('admin') Notifications.alchemy_user_created(self).deliver_later else Notifications.member_created(self).deliver_later end end
ruby
def deliver_welcome_mail if has_role?('author') || has_role?('editor') || has_role?('admin') Notifications.alchemy_user_created(self).deliver_later else Notifications.member_created(self).deliver_later end end
[ "def", "deliver_welcome_mail", "if", "has_role?", "(", "'author'", ")", "||", "has_role?", "(", "'editor'", ")", "||", "has_role?", "(", "'admin'", ")", "Notifications", ".", "alchemy_user_created", "(", "self", ")", ".", "deliver_later", "else", "Notifications", ...
Delivers a welcome mail depending from user's role.
[ "Delivers", "a", "welcome", "mail", "depending", "from", "user", "s", "role", "." ]
ab1781db136cc634c38775d939f45e98f9d74e8e
https://github.com/AlchemyCMS/alchemy-devise/blob/ab1781db136cc634c38775d939f45e98f9d74e8e/app/models/alchemy/user.rb#L160-L166
20,839
AlchemyCMS/alchemy-devise
app/controllers/alchemy/user_sessions_controller.rb
Alchemy.UserSessionsController.after_sign_out_path_for
def after_sign_out_path_for(resource_or_scope) if request.referer.blank? || request.referer.to_s =~ /admin/ root_path else request.referer end end
ruby
def after_sign_out_path_for(resource_or_scope) if request.referer.blank? || request.referer.to_s =~ /admin/ root_path else request.referer end end
[ "def", "after_sign_out_path_for", "(", "resource_or_scope", ")", "if", "request", ".", "referer", ".", "blank?", "||", "request", ".", "referer", ".", "to_s", "=~", "/", "/", "root_path", "else", "request", ".", "referer", "end", "end" ]
Overwriting the default of Devise
[ "Overwriting", "the", "default", "of", "Devise" ]
ab1781db136cc634c38775d939f45e98f9d74e8e
https://github.com/AlchemyCMS/alchemy-devise/blob/ab1781db136cc634c38775d939f45e98f9d74e8e/app/controllers/alchemy/user_sessions_controller.rb#L54-L60
20,840
xuanxu/nimbus
lib/nimbus/forest.rb
Nimbus.Forest.traverse_regression_forest
def traverse_regression_forest @predictions = {} prediction_count = trees.size @options.read_testing_data{|individual| individual_prediction = 0.0 trees.each do |t| individual_prediction = (individual_prediction + Nimbus::Tree.traverse(t, individual.snp_list)).round(5) ...
ruby
def traverse_regression_forest @predictions = {} prediction_count = trees.size @options.read_testing_data{|individual| individual_prediction = 0.0 trees.each do |t| individual_prediction = (individual_prediction + Nimbus::Tree.traverse(t, individual.snp_list)).round(5) ...
[ "def", "traverse_regression_forest", "@predictions", "=", "{", "}", "prediction_count", "=", "trees", ".", "size", "@options", ".", "read_testing_data", "{", "|", "individual", "|", "individual_prediction", "=", "0.0", "trees", ".", "each", "do", "|", "t", "|", ...
Traverse a testing set through every regression tree of the forest and get averaged predictions for every individual in the sample.
[ "Traverse", "a", "testing", "set", "through", "every", "regression", "tree", "of", "the", "forest", "and", "get", "averaged", "predictions", "for", "every", "individual", "in", "the", "sample", "." ]
6646dbc00147408765044a99702005d3d30e052e
https://github.com/xuanxu/nimbus/blob/6646dbc00147408765044a99702005d3d30e052e/lib/nimbus/forest.rb#L61-L71
20,841
metanorma/relaton
lib/relaton/db.rb
Relaton.Db.docid_type
def docid_type(code) stdclass = standard_class(code) or return [nil, code] prefix, code = strip_id_wrapper(code, stdclass) [@registry.processors[stdclass].idtype, code] end
ruby
def docid_type(code) stdclass = standard_class(code) or return [nil, code] prefix, code = strip_id_wrapper(code, stdclass) [@registry.processors[stdclass].idtype, code] end
[ "def", "docid_type", "(", "code", ")", "stdclass", "=", "standard_class", "(", "code", ")", "or", "return", "[", "nil", ",", "code", "]", "prefix", ",", "code", "=", "strip_id_wrapper", "(", "code", ",", "stdclass", ")", "[", "@registry", ".", "processor...
The document identifier class corresponding to the given code
[ "The", "document", "identifier", "class", "corresponding", "to", "the", "given", "code" ]
2fac19da2f3ef3c30b8e8d8815a14d2115df0be6
https://github.com/metanorma/relaton/blob/2fac19da2f3ef3c30b8e8d8815a14d2115df0be6/lib/relaton/db.rb#L64-L68
20,842
metanorma/relaton
lib/relaton/db.rb
Relaton.Db.to_xml
def to_xml db = @local_db || @db || return Nokogiri::XML::Builder.new(encoding: "UTF-8") do |xml| xml.documents do xml.parent.add_child db.all.join(" ") end end.to_xml end
ruby
def to_xml db = @local_db || @db || return Nokogiri::XML::Builder.new(encoding: "UTF-8") do |xml| xml.documents do xml.parent.add_child db.all.join(" ") end end.to_xml end
[ "def", "to_xml", "db", "=", "@local_db", "||", "@db", "||", "return", "Nokogiri", "::", "XML", "::", "Builder", ".", "new", "(", "encoding", ":", "\"UTF-8\"", ")", "do", "|", "xml", "|", "xml", ".", "documents", "do", "xml", ".", "parent", ".", "add_...
list all entries as a serialization @return [String]
[ "list", "all", "entries", "as", "a", "serialization" ]
2fac19da2f3ef3c30b8e8d8815a14d2115df0be6
https://github.com/metanorma/relaton/blob/2fac19da2f3ef3c30b8e8d8815a14d2115df0be6/lib/relaton/db.rb#L90-L97
20,843
metanorma/relaton
lib/relaton/db.rb
Relaton.Db.new_bib_entry
def new_bib_entry(code, year, opts, stdclass) bib = @registry.processors[stdclass].get(code, year, opts) bib = bib.to_xml if bib.respond_to? :to_xml bib = "not_found #{Date.today}" if bib.nil? || bib.empty? bib end
ruby
def new_bib_entry(code, year, opts, stdclass) bib = @registry.processors[stdclass].get(code, year, opts) bib = bib.to_xml if bib.respond_to? :to_xml bib = "not_found #{Date.today}" if bib.nil? || bib.empty? bib end
[ "def", "new_bib_entry", "(", "code", ",", "year", ",", "opts", ",", "stdclass", ")", "bib", "=", "@registry", ".", "processors", "[", "stdclass", "]", ".", "get", "(", "code", ",", "year", ",", "opts", ")", "bib", "=", "bib", ".", "to_xml", "if", "...
hash uses => , because the hash is imported from JSON @param code [String] @param year [String] @param opts [Hash] @param stdclass [Symbol] @return [Hash]
[ "hash", "uses", "=", ">", "because", "the", "hash", "is", "imported", "from", "JSON" ]
2fac19da2f3ef3c30b8e8d8815a14d2115df0be6
https://github.com/metanorma/relaton/blob/2fac19da2f3ef3c30b8e8d8815a14d2115df0be6/lib/relaton/db.rb#L171-L176
20,844
metanorma/relaton
lib/relaton/db_cache.rb
Relaton.DbCache.all
def all Dir.glob("#{@dir}/**/*.xml").sort.map do |f| File.read(f, encoding: "utf-8") end end
ruby
def all Dir.glob("#{@dir}/**/*.xml").sort.map do |f| File.read(f, encoding: "utf-8") end end
[ "def", "all", "Dir", ".", "glob", "(", "\"#{@dir}/**/*.xml\"", ")", ".", "sort", ".", "map", "do", "|", "f", "|", "File", ".", "read", "(", "f", ",", "encoding", ":", "\"utf-8\"", ")", "end", "end" ]
Returns all items @return [Array<Hash>]
[ "Returns", "all", "items" ]
2fac19da2f3ef3c30b8e8d8815a14d2115df0be6
https://github.com/metanorma/relaton/blob/2fac19da2f3ef3c30b8e8d8815a14d2115df0be6/lib/relaton/db_cache.rb#L52-L56
20,845
ZestFinance/zestphone
app/models/telephony/call.rb
Telephony.Call.terminate_conversation_and_all_call_legs
def terminate_conversation_and_all_call_legs(trace_only = false) if self.conversation Rails.logger.info "zestphone: ** Terminating all linked calls and conversation **" Rails.logger.info "zestphone: conversation - (pre) state: #{self.conversation.state}" Rails.logger.info "zestphone: c...
ruby
def terminate_conversation_and_all_call_legs(trace_only = false) if self.conversation Rails.logger.info "zestphone: ** Terminating all linked calls and conversation **" Rails.logger.info "zestphone: conversation - (pre) state: #{self.conversation.state}" Rails.logger.info "zestphone: c...
[ "def", "terminate_conversation_and_all_call_legs", "(", "trace_only", "=", "false", ")", "if", "self", ".", "conversation", "Rails", ".", "logger", ".", "info", "\"zestphone: ** Terminating all linked calls and conversation **\"", "Rails", ".", "logger", ".", "info", "\"z...
Nuclear termination if trace_only is "true", we only print what we're going to do but not actually do it
[ "Nuclear", "termination", "if", "trace_only", "is", "true", "we", "only", "print", "what", "we", "re", "going", "to", "do", "but", "not", "actually", "do", "it" ]
8f8b81d5bf33229ada36f74319799834ecda1599
https://github.com/ZestFinance/zestphone/blob/8f8b81d5bf33229ada36f74319799834ecda1599/app/models/telephony/call.rb#L86-L107
20,846
phaxio/phaxio-ruby
lib/phaxio/resource.rb
Phaxio.Resource.populate_attributes
def populate_attributes self.class.normal_attribute_list.each do |normal_attribute| self.public_send "#{normal_attribute}=", raw_data[normal_attribute] end self.class.time_attribute_list.each do |time_attribute| time = raw_data[time_attribute] time = Time.parse(time) if !time....
ruby
def populate_attributes self.class.normal_attribute_list.each do |normal_attribute| self.public_send "#{normal_attribute}=", raw_data[normal_attribute] end self.class.time_attribute_list.each do |time_attribute| time = raw_data[time_attribute] time = Time.parse(time) if !time....
[ "def", "populate_attributes", "self", ".", "class", ".", "normal_attribute_list", ".", "each", "do", "|", "normal_attribute", "|", "self", ".", "public_send", "\"#{normal_attribute}=\"", ",", "raw_data", "[", "normal_attribute", "]", "end", "self", ".", "class", "...
Populates the instance's attributes based on the `raw_data`.
[ "Populates", "the", "instance", "s", "attributes", "based", "on", "the", "raw_data", "." ]
eb701a0333da068844f0c7bba45ce70caff39148
https://github.com/phaxio/phaxio-ruby/blob/eb701a0333da068844f0c7bba45ce70caff39148/lib/phaxio/resource.rb#L17-L34
20,847
patricklindsay/will_paginate-materialize
lib/materialize_pagination/view_helpers.rb
MaterializePagination.ViewHelpers.will_paginate
def will_paginate(collection_or_options = nil, options = {}) if collection_or_options.is_a? Hash options, collection_or_options = collection_or_options, nil end unless options[:renderer] options = options.merge :renderer => MaterializePagination::Rails end super *[collectio...
ruby
def will_paginate(collection_or_options = nil, options = {}) if collection_or_options.is_a? Hash options, collection_or_options = collection_or_options, nil end unless options[:renderer] options = options.merge :renderer => MaterializePagination::Rails end super *[collectio...
[ "def", "will_paginate", "(", "collection_or_options", "=", "nil", ",", "options", "=", "{", "}", ")", "if", "collection_or_options", ".", "is_a?", "Hash", "options", ",", "collection_or_options", "=", "collection_or_options", ",", "nil", "end", "unless", "options"...
Change the default link renderer for will_paginate
[ "Change", "the", "default", "link", "renderer", "for", "will_paginate" ]
732aa4f4bdfeff9a63052ef2e9aaa78318833dfe
https://github.com/patricklindsay/will_paginate-materialize/blob/732aa4f4bdfeff9a63052ef2e9aaa78318833dfe/lib/materialize_pagination/view_helpers.rb#L4-L12
20,848
pascalh1011/migrant
lib/dsl/data_type.rb
DataType.Base.structure_changes_from
def structure_changes_from(current_structure = nil) new_structure = column if current_structure # General RDBMS data loss scenarios if new_structure[:limit] && current_structure[:limit].to_i != new_structure[:limit].to_i || new_structure[:type] != current_structure[:type] ||...
ruby
def structure_changes_from(current_structure = nil) new_structure = column if current_structure # General RDBMS data loss scenarios if new_structure[:limit] && current_structure[:limit].to_i != new_structure[:limit].to_i || new_structure[:type] != current_structure[:type] ||...
[ "def", "structure_changes_from", "(", "current_structure", "=", "nil", ")", "new_structure", "=", "column", "if", "current_structure", "# General RDBMS data loss scenarios", "if", "new_structure", "[", ":limit", "]", "&&", "current_structure", "[", ":limit", "]", ".", ...
Decides if and how a column will be changed Provide the details of a previously column, or simply nil to create a new column
[ "Decides", "if", "and", "how", "a", "column", "will", "be", "changed", "Provide", "the", "details", "of", "a", "previously", "column", "or", "simply", "nil", "to", "create", "a", "new", "column" ]
9415e0d4d26565b72972ccff39a17ffc5de71100
https://github.com/pascalh1011/migrant/blob/9415e0d4d26565b72972ccff39a17ffc5de71100/lib/dsl/data_type.rb#L55-L71
20,849
InfoTech/salesforce_ar_sync
lib/salesforce_ar_sync/salesforce_sync.rb
SalesforceArSync.SalesforceSync.salesforce_attributes_to_set
def salesforce_attributes_to_set(attributes = {}) {}.tap do |hash| # loop through the hash of attributes from the outbound message, and compare to our sf mappings and # create a reversed hash of value's and key's to pass to update_attributes attributes.each do |key, value| # make...
ruby
def salesforce_attributes_to_set(attributes = {}) {}.tap do |hash| # loop through the hash of attributes from the outbound message, and compare to our sf mappings and # create a reversed hash of value's and key's to pass to update_attributes attributes.each do |key, value| # make...
[ "def", "salesforce_attributes_to_set", "(", "attributes", "=", "{", "}", ")", "{", "}", ".", "tap", "do", "|", "hash", "|", "# loop through the hash of attributes from the outbound message, and compare to our sf mappings and", "# create a reversed hash of value's and key's to pass ...
An internal method used to get a hash of values that we are going to set from a Salesforce outbound message hash
[ "An", "internal", "method", "used", "to", "get", "a", "hash", "of", "values", "that", "we", "are", "going", "to", "set", "from", "a", "Salesforce", "outbound", "message", "hash" ]
3f6351fe462cc7374b8f00c0f36e8c8cfd9c39c4
https://github.com/InfoTech/salesforce_ar_sync/blob/3f6351fe462cc7374b8f00c0f36e8c8cfd9c39c4/lib/salesforce_ar_sync/salesforce_sync.rb#L99-L117
20,850
InfoTech/salesforce_ar_sync
lib/salesforce_ar_sync/salesforce_sync.rb
SalesforceArSync.SalesforceSync.salesforce_process_update
def salesforce_process_update(attributes = {}) attributes_to_update = salesforce_attributes_to_set(self.new_record? ? attributes : salesforce_empty_attributes.merge(attributes)) # only merge empty attributes for updates, so we don't overwrite the default create attributes attributes_to_update.each_pair do |...
ruby
def salesforce_process_update(attributes = {}) attributes_to_update = salesforce_attributes_to_set(self.new_record? ? attributes : salesforce_empty_attributes.merge(attributes)) # only merge empty attributes for updates, so we don't overwrite the default create attributes attributes_to_update.each_pair do |...
[ "def", "salesforce_process_update", "(", "attributes", "=", "{", "}", ")", "attributes_to_update", "=", "salesforce_attributes_to_set", "(", "self", ".", "new_record?", "?", "attributes", ":", "salesforce_empty_attributes", ".", "merge", "(", "attributes", ")", ")", ...
Gets passed the Salesforce outbound message hash of changed values and updates the corresponding model
[ "Gets", "passed", "the", "Salesforce", "outbound", "message", "hash", "of", "changed", "values", "and", "updates", "the", "corresponding", "model" ]
3f6351fe462cc7374b8f00c0f36e8c8cfd9c39c4
https://github.com/InfoTech/salesforce_ar_sync/blob/3f6351fe462cc7374b8f00c0f36e8c8cfd9c39c4/lib/salesforce_ar_sync/salesforce_sync.rb#L120-L129
20,851
InfoTech/salesforce_ar_sync
lib/salesforce_ar_sync/salesforce_sync.rb
SalesforceArSync.SalesforceSync.system_mod_stamp
def system_mod_stamp hash = JSON.parse(SF_CLIENT.http_get("/services/data/v#{SF_CLIENT.version}/query", :q => "SELECT SystemModstamp FROM #{salesforce_object_name} WHERE Id = '#{salesforce_id}'").body) hash["records"].first.try(:[], "SystemModstamp") end
ruby
def system_mod_stamp hash = JSON.parse(SF_CLIENT.http_get("/services/data/v#{SF_CLIENT.version}/query", :q => "SELECT SystemModstamp FROM #{salesforce_object_name} WHERE Id = '#{salesforce_id}'").body) hash["records"].first.try(:[], "SystemModstamp") end
[ "def", "system_mod_stamp", "hash", "=", "JSON", ".", "parse", "(", "SF_CLIENT", ".", "http_get", "(", "\"/services/data/v#{SF_CLIENT.version}/query\"", ",", ":q", "=>", "\"SELECT SystemModstamp FROM #{salesforce_object_name} WHERE Id = '#{salesforce_id}'\"", ")", ".", "body", ...
def salesforce_object_exists? return salesforce_object_exists_method if respond_to? salesforce_exists_method return salesforce_object_exists_default end Finds a salesforce record by its Id and returns nil or its SystemModstamp
[ "def", "salesforce_object_exists?", "return", "salesforce_object_exists_method", "if", "respond_to?", "salesforce_exists_method", "return", "salesforce_object_exists_default", "end", "Finds", "a", "salesforce", "record", "by", "its", "Id", "and", "returns", "nil", "or", "it...
3f6351fe462cc7374b8f00c0f36e8c8cfd9c39c4
https://github.com/InfoTech/salesforce_ar_sync/blob/3f6351fe462cc7374b8f00c0f36e8c8cfd9c39c4/lib/salesforce_ar_sync/salesforce_sync.rb#L138-L141
20,852
InfoTech/salesforce_ar_sync
lib/salesforce_ar_sync/salesforce_sync.rb
SalesforceArSync.SalesforceSync.salesforce_attributes_to_update
def salesforce_attributes_to_update(include_all = false) {}.tap do |hash| self.class.salesforce_sync_attribute_mapping.each do |key, value| if self.respond_to?(value) #Checkboxes in SFDC Cannot be nil. Here we check for boolean field type and set nil values to be false ...
ruby
def salesforce_attributes_to_update(include_all = false) {}.tap do |hash| self.class.salesforce_sync_attribute_mapping.each do |key, value| if self.respond_to?(value) #Checkboxes in SFDC Cannot be nil. Here we check for boolean field type and set nil values to be false ...
[ "def", "salesforce_attributes_to_update", "(", "include_all", "=", "false", ")", "{", "}", ".", "tap", "do", "|", "hash", "|", "self", ".", "class", ".", "salesforce_sync_attribute_mapping", ".", "each", "do", "|", "key", ",", "value", "|", "if", "self", "...
create a hash of updates to send to salesforce
[ "create", "a", "hash", "of", "updates", "to", "send", "to", "salesforce" ]
3f6351fe462cc7374b8f00c0f36e8c8cfd9c39c4
https://github.com/InfoTech/salesforce_ar_sync/blob/3f6351fe462cc7374b8f00c0f36e8c8cfd9c39c4/lib/salesforce_ar_sync/salesforce_sync.rb#L155-L170
20,853
InfoTech/salesforce_ar_sync
lib/salesforce_ar_sync/salesforce_sync.rb
SalesforceArSync.SalesforceSync.salesforce_perform_async_call?
def salesforce_perform_async_call? return false if salesforce_attributes_to_update.empty? || self.class.salesforce_async_attributes.empty? salesforce_attributes_to_update.keys.all? {|key| self.class.salesforce_async_attributes.include?(key) } && salesforce_id.present? end
ruby
def salesforce_perform_async_call? return false if salesforce_attributes_to_update.empty? || self.class.salesforce_async_attributes.empty? salesforce_attributes_to_update.keys.all? {|key| self.class.salesforce_async_attributes.include?(key) } && salesforce_id.present? end
[ "def", "salesforce_perform_async_call?", "return", "false", "if", "salesforce_attributes_to_update", ".", "empty?", "||", "self", ".", "class", ".", "salesforce_async_attributes", ".", "empty?", "salesforce_attributes_to_update", ".", "keys", ".", "all?", "{", "|", "key...
if attributes specified in the async_attributes array are the only attributes being modified, then sync the data via delayed_job
[ "if", "attributes", "specified", "in", "the", "async_attributes", "array", "are", "the", "only", "attributes", "being", "modified", "then", "sync", "the", "data", "via", "delayed_job" ]
3f6351fe462cc7374b8f00c0f36e8c8cfd9c39c4
https://github.com/InfoTech/salesforce_ar_sync/blob/3f6351fe462cc7374b8f00c0f36e8c8cfd9c39c4/lib/salesforce_ar_sync/salesforce_sync.rb#L206-L209
20,854
InfoTech/salesforce_ar_sync
lib/salesforce_ar_sync/salesforce_sync.rb
SalesforceArSync.SalesforceSync.salesforce_sync
def salesforce_sync return if self.salesforce_skip_sync? if salesforce_perform_async_call? Delayed::Job.enqueue(SalesforceArSync::SalesforceObjectSync.new(self.class.salesforce_web_class_name, salesforce_id, salesforce_attributes_to_update), :priority => 50) else if salesforce_object_e...
ruby
def salesforce_sync return if self.salesforce_skip_sync? if salesforce_perform_async_call? Delayed::Job.enqueue(SalesforceArSync::SalesforceObjectSync.new(self.class.salesforce_web_class_name, salesforce_id, salesforce_attributes_to_update), :priority => 50) else if salesforce_object_e...
[ "def", "salesforce_sync", "return", "if", "self", ".", "salesforce_skip_sync?", "if", "salesforce_perform_async_call?", "Delayed", "::", "Job", ".", "enqueue", "(", "SalesforceArSync", "::", "SalesforceObjectSync", ".", "new", "(", "self", ".", "class", ".", "salesf...
sync model data to Salesforce, adding any Salesforce validation errors to the models errors
[ "sync", "model", "data", "to", "Salesforce", "adding", "any", "Salesforce", "validation", "errors", "to", "the", "models", "errors" ]
3f6351fe462cc7374b8f00c0f36e8c8cfd9c39c4
https://github.com/InfoTech/salesforce_ar_sync/blob/3f6351fe462cc7374b8f00c0f36e8c8cfd9c39c4/lib/salesforce_ar_sync/salesforce_sync.rb#L212-L226
20,855
InfoTech/salesforce_ar_sync
app/controllers/salesforce_ar_sync/soap_message_controller.rb
SalesforceArSync.SoapMessageController.validate_ip_ranges
def validate_ip_ranges raise ActionController::RoutingError.new('Not Found') unless SalesforceArSync::IPConstraint.new.matches?(request) end
ruby
def validate_ip_ranges raise ActionController::RoutingError.new('Not Found') unless SalesforceArSync::IPConstraint.new.matches?(request) end
[ "def", "validate_ip_ranges", "raise", "ActionController", "::", "RoutingError", ".", "new", "(", "'Not Found'", ")", "unless", "SalesforceArSync", "::", "IPConstraint", ".", "new", ".", "matches?", "(", "request", ")", "end" ]
to be used in a before_filter, checks ip ranges specified in configuration and renders a 404 unless the request matches
[ "to", "be", "used", "in", "a", "before_filter", "checks", "ip", "ranges", "specified", "in", "configuration", "and", "renders", "a", "404", "unless", "the", "request", "matches" ]
3f6351fe462cc7374b8f00c0f36e8c8cfd9c39c4
https://github.com/InfoTech/salesforce_ar_sync/blob/3f6351fe462cc7374b8f00c0f36e8c8cfd9c39c4/app/controllers/salesforce_ar_sync/soap_message_controller.rb#L29-L31
20,856
futuresimple/api_client
lib/api_client/scope.rb
ApiClient.Scope.request
def request(method, path, options = {}) options = options.dup raw = raw? || options.delete(:raw) params(options) response = connection.send method, path, (@raw_body || @params), @headers raw ? response : @scopeable.parse(response) end
ruby
def request(method, path, options = {}) options = options.dup raw = raw? || options.delete(:raw) params(options) response = connection.send method, path, (@raw_body || @params), @headers raw ? response : @scopeable.parse(response) end
[ "def", "request", "(", "method", ",", "path", ",", "options", "=", "{", "}", ")", "options", "=", "options", ".", "dup", "raw", "=", "raw?", "||", "options", ".", "delete", "(", ":raw", ")", "params", "(", "options", ")", "response", "=", "connection...
Low-level connection methods
[ "Low", "-", "level", "connection", "methods" ]
75d664fbbac60204415924c1fedf12b7bc4634a1
https://github.com/futuresimple/api_client/blob/75d664fbbac60204415924c1fedf12b7bc4634a1/lib/api_client/scope.rb#L83-L90
20,857
alphagov/govuk_schemas
lib/govuk_schemas/random_example.rb
GovukSchemas.RandomExample.payload
def payload payload = @random_generator.payload # ensure the base payload is valid errors = validation_errors_for(payload) raise InvalidContentGenerated, error_message(payload, errors) if errors.any? if block_given? payload = yield(payload) # check the payload again after ...
ruby
def payload payload = @random_generator.payload # ensure the base payload is valid errors = validation_errors_for(payload) raise InvalidContentGenerated, error_message(payload, errors) if errors.any? if block_given? payload = yield(payload) # check the payload again after ...
[ "def", "payload", "payload", "=", "@random_generator", ".", "payload", "# ensure the base payload is valid", "errors", "=", "validation_errors_for", "(", "payload", ")", "raise", "InvalidContentGenerated", ",", "error_message", "(", "payload", ",", "errors", ")", "if", ...
Return a content item merged with a hash and with the excluded fields removed. If the resulting content item isn't valid against the schema an error will be raised. Example without block: generator.payload # => {"base_path"=>"/e42dd28e", "title"=>"dolor est...", "publishing_app"=>"elit"...} Example wi...
[ "Return", "a", "content", "item", "merged", "with", "a", "hash", "and", "with", "the", "excluded", "fields", "removed", ".", "If", "the", "resulting", "content", "item", "isn", "t", "valid", "against", "the", "schema", "an", "error", "will", "be", "raised"...
f709a10cd2af63b29c22288fc7e0ad6af426926a
https://github.com/alphagov/govuk_schemas/blob/f709a10cd2af63b29c22288fc7e0ad6af426926a/lib/govuk_schemas/random_example.rb#L78-L92
20,858
gopherst/hidemyass
lib/hidemyass/ip.rb
HideMyAss.IP.decode
def decode(elements) elements.each do |element| # Remove elements with CSS style "none" if !TAGS.include?(element.name) || (element["style"] && element["style"] =~ /none/) element.children.remove # Get rid of decoy children elsif element["class"] decoys.each d...
ruby
def decode(elements) elements.each do |element| # Remove elements with CSS style "none" if !TAGS.include?(element.name) || (element["style"] && element["style"] =~ /none/) element.children.remove # Get rid of decoy children elsif element["class"] decoys.each d...
[ "def", "decode", "(", "elements", ")", "elements", ".", "each", "do", "|", "element", "|", "# Remove elements with CSS style \"none\"", "if", "!", "TAGS", ".", "include?", "(", "element", ".", "name", ")", "||", "(", "element", "[", "\"style\"", "]", "&&", ...
Receives an array of elements and returns another without invisibles.
[ "Receives", "an", "array", "of", "elements", "and", "returns", "another", "without", "invisibles", "." ]
9011e43237c68c4e96e0137fdb550fcef23de8eb
https://github.com/gopherst/hidemyass/blob/9011e43237c68c4e96e0137fdb550fcef23de8eb/lib/hidemyass/ip.rb#L29-L45
20,859
norman/ambry
lib/ambry/abstract_key_set.rb
Ambry.AbstractKeySet.count
def count(&block) return keys.count unless block_given? proxy = HashProxy.new keys.inject(0) do |count, key| proxy.with(mapper[key], &block) ? count.succ : count end end
ruby
def count(&block) return keys.count unless block_given? proxy = HashProxy.new keys.inject(0) do |count, key| proxy.with(mapper[key], &block) ? count.succ : count end end
[ "def", "count", "(", "&", "block", ")", "return", "keys", ".", "count", "unless", "block_given?", "proxy", "=", "HashProxy", ".", "new", "keys", ".", "inject", "(", "0", ")", "do", "|", "count", ",", "key", "|", "proxy", ".", "with", "(", "mapper", ...
With no block, returns the number of keys. If a block is given, counts the number of elements yielding a true value.
[ "With", "no", "block", "returns", "the", "number", "of", "keys", ".", "If", "a", "block", "is", "given", "counts", "the", "number", "of", "elements", "yielding", "a", "true", "value", "." ]
f6563b0d3c881ace9839114f8a8b6e2f26ab9d07
https://github.com/norman/ambry/blob/f6563b0d3c881ace9839114f8a8b6e2f26ab9d07/lib/ambry/abstract_key_set.rb#L52-L58
20,860
misshie/interval-tree
lib/interval_tree.rb
IntervalTree.Tree.center
def center(intervals) i = intervals.reduce([intervals.first.first, intervals.first.last]) { |acc, int| [[acc.first, int.first].min, [acc.last, int.last].max] } i.first + (i.last - i.first) / 2 end
ruby
def center(intervals) i = intervals.reduce([intervals.first.first, intervals.first.last]) { |acc, int| [[acc.first, int.first].min, [acc.last, int.last].max] } i.first + (i.last - i.first) / 2 end
[ "def", "center", "(", "intervals", ")", "i", "=", "intervals", ".", "reduce", "(", "[", "intervals", ".", "first", ".", "first", ",", "intervals", ".", "first", ".", "last", "]", ")", "{", "|", "acc", ",", "int", "|", "[", "[", "acc", ".", "first...
augmented tree using a start point as resresentative value of the node
[ "augmented", "tree", "using", "a", "start", "point", "as", "resresentative", "value", "of", "the", "node" ]
14955993828edc004d4386da1bb429271dbecaa8
https://github.com/misshie/interval-tree/blob/14955993828edc004d4386da1bb429271dbecaa8/lib/interval_tree.rb#L97-L100
20,861
norman/ambry
lib/ambry/hash_proxy.rb
Ambry.HashProxy.method_missing
def method_missing(symbol) if hash.key?(symbol) hash[symbol] elsif hash.key?(symbol.to_s) hash[symbol.to_s] else raise NoMethodError end end
ruby
def method_missing(symbol) if hash.key?(symbol) hash[symbol] elsif hash.key?(symbol.to_s) hash[symbol.to_s] else raise NoMethodError end end
[ "def", "method_missing", "(", "symbol", ")", "if", "hash", ".", "key?", "(", "symbol", ")", "hash", "[", "symbol", "]", "elsif", "hash", ".", "key?", "(", "symbol", ".", "to_s", ")", "hash", "[", "symbol", ".", "to_s", "]", "else", "raise", "NoMethod...
Allows accessing a hash attribute as a method.
[ "Allows", "accessing", "a", "hash", "attribute", "as", "a", "method", "." ]
f6563b0d3c881ace9839114f8a8b6e2f26ab9d07
https://github.com/norman/ambry/blob/f6563b0d3c881ace9839114f8a8b6e2f26ab9d07/lib/ambry/hash_proxy.rb#L14-L22
20,862
norman/ambry
lib/ambry/hash_proxy.rb
Ambry.HashProxy.[]
def [](key) if hash.key?(key) then hash[key] elsif hash.key?(key.to_sym) then hash[key.to_sym] elsif hash.key?(key.to_s) then hash[key.to_s] end end
ruby
def [](key) if hash.key?(key) then hash[key] elsif hash.key?(key.to_sym) then hash[key.to_sym] elsif hash.key?(key.to_s) then hash[key.to_s] end end
[ "def", "[]", "(", "key", ")", "if", "hash", ".", "key?", "(", "key", ")", "then", "hash", "[", "key", "]", "elsif", "hash", ".", "key?", "(", "key", ".", "to_sym", ")", "then", "hash", "[", "key", ".", "to_sym", "]", "elsif", "hash", ".", "key?...
Allows accessing a hash attribute as hash key, either a string or symbol.
[ "Allows", "accessing", "a", "hash", "attribute", "as", "hash", "key", "either", "a", "string", "or", "symbol", "." ]
f6563b0d3c881ace9839114f8a8b6e2f26ab9d07
https://github.com/norman/ambry/blob/f6563b0d3c881ace9839114f8a8b6e2f26ab9d07/lib/ambry/hash_proxy.rb#L25-L30
20,863
norman/ambry
lib/ambry/mapper.rb
Ambry.Mapper.[]=
def []=(key, value) @lock.synchronize do @indexes = {} if value.id_changed? hash.delete value.to_id(true) end saved = hash[key] = value.to_hash.freeze adapter.save_database if @options[:sync] saved end end
ruby
def []=(key, value) @lock.synchronize do @indexes = {} if value.id_changed? hash.delete value.to_id(true) end saved = hash[key] = value.to_hash.freeze adapter.save_database if @options[:sync] saved end end
[ "def", "[]=", "(", "key", ",", "value", ")", "@lock", ".", "synchronize", "do", "@indexes", "=", "{", "}", "if", "value", ".", "id_changed?", "hash", ".", "delete", "value", ".", "to_id", "(", "true", ")", "end", "saved", "=", "hash", "[", "key", "...
Sets a hash by key.
[ "Sets", "a", "hash", "by", "key", "." ]
f6563b0d3c881ace9839114f8a8b6e2f26ab9d07
https://github.com/norman/ambry/blob/f6563b0d3c881ace9839114f8a8b6e2f26ab9d07/lib/ambry/mapper.rb#L28-L38
20,864
williambarry007/caboose-cms
app/models/caboose/invoice.rb
Caboose.Invoice.authorize_and_capture
def authorize_and_capture resp = StdClass.new if self.financial_status == Invoice::FINANCIAL_STATUS_CAPTURED resp.error = "Funds for this invoice have already been captured." else sc = self.site.store_config ...
ruby
def authorize_and_capture resp = StdClass.new if self.financial_status == Invoice::FINANCIAL_STATUS_CAPTURED resp.error = "Funds for this invoice have already been captured." else sc = self.site.store_config ...
[ "def", "authorize_and_capture", "resp", "=", "StdClass", ".", "new", "if", "self", ".", "financial_status", "==", "Invoice", "::", "FINANCIAL_STATUS_CAPTURED", "resp", ".", "error", "=", "\"Funds for this invoice have already been captured.\"", "else", "sc", "=", "self"...
Authorize and capture funds
[ "Authorize", "and", "capture", "funds" ]
7c112911318f94cc89dba86091903a3acaf0a833
https://github.com/williambarry007/caboose-cms/blob/7c112911318f94cc89dba86091903a3acaf0a833/app/models/caboose/invoice.rb#L282-L330
20,865
williambarry007/caboose-cms
app/models/caboose/invoice.rb
Caboose.Invoice.void
def void resp = StdClass.new t = InvoiceTransaction.where(:invoice_id => self.id, :transaction_type => InvoiceTransaction::TYPE_AUTHORIZE, :success => true).first if self.financial_status == Invoice::FINANCIAL_STATUS_CAPTURED resp.error = "This invoice has already been capt...
ruby
def void resp = StdClass.new t = InvoiceTransaction.where(:invoice_id => self.id, :transaction_type => InvoiceTransaction::TYPE_AUTHORIZE, :success => true).first if self.financial_status == Invoice::FINANCIAL_STATUS_CAPTURED resp.error = "This invoice has already been capt...
[ "def", "void", "resp", "=", "StdClass", ".", "new", "t", "=", "InvoiceTransaction", ".", "where", "(", ":invoice_id", "=>", "self", ".", "id", ",", ":transaction_type", "=>", "InvoiceTransaction", "::", "TYPE_AUTHORIZE", ",", ":success", "=>", "true", ")", "...
Void an authorized invoice
[ "Void", "an", "authorized", "invoice" ]
7c112911318f94cc89dba86091903a3acaf0a833
https://github.com/williambarry007/caboose-cms/blob/7c112911318f94cc89dba86091903a3acaf0a833/app/models/caboose/invoice.rb#L414-L468
20,866
puppetlabs/beaker-vmpooler
lib/beaker/hypervisor/vmpooler.rb
Beaker.Vmpooler.add_tags
def add_tags(host) host[:host_tags].merge( 'beaker_version' => Beaker::Version::STRING, 'jenkins_build_url' => @options[:jenkins_build_url], 'department' => @options[:department], 'project' => @options[:project], 'created_by' => @options...
ruby
def add_tags(host) host[:host_tags].merge( 'beaker_version' => Beaker::Version::STRING, 'jenkins_build_url' => @options[:jenkins_build_url], 'department' => @options[:department], 'project' => @options[:project], 'created_by' => @options...
[ "def", "add_tags", "(", "host", ")", "host", "[", ":host_tags", "]", ".", "merge", "(", "'beaker_version'", "=>", "Beaker", "::", "Version", "::", "STRING", ",", "'jenkins_build_url'", "=>", "@options", "[", ":jenkins_build_url", "]", ",", "'department'", "=>"...
Override host tags with presets @param [Beaker::Host] host Beaker host @return [Hash] Tag hash
[ "Override", "host", "tags", "with", "presets" ]
d54e825506d740ad12d6fe0a9d83b5172401f79b
https://github.com/puppetlabs/beaker-vmpooler/blob/d54e825506d740ad12d6fe0a9d83b5172401f79b/lib/beaker/hypervisor/vmpooler.rb#L75-L85
20,867
williambarry007/caboose-cms
app/models/caboose/subscription.rb
Caboose.Subscription.create_invoices
def create_invoices self.calculate_date_started_full if self.date_started_full.nil? v = self.variant interval = case v.subscription_interval when Variant::SUBSCRIPTION_INTERVAL_MONTHLY then 1.month when Variant::SUBSCRIPTION_INTERVAL_YEARLY then 1.year end ...
ruby
def create_invoices self.calculate_date_started_full if self.date_started_full.nil? v = self.variant interval = case v.subscription_interval when Variant::SUBSCRIPTION_INTERVAL_MONTHLY then 1.month when Variant::SUBSCRIPTION_INTERVAL_YEARLY then 1.year end ...
[ "def", "create_invoices", "self", ".", "calculate_date_started_full", "if", "self", ".", "date_started_full", ".", "nil?", "v", "=", "self", ".", "variant", "interval", "=", "case", "v", ".", "subscription_interval", "when", "Variant", "::", "SUBSCRIPTION_INTERVAL_M...
Verify invoices exist for the entire subscription period up until today
[ "Verify", "invoices", "exist", "for", "the", "entire", "subscription", "period", "up", "until", "today" ]
7c112911318f94cc89dba86091903a3acaf0a833
https://github.com/williambarry007/caboose-cms/blob/7c112911318f94cc89dba86091903a3acaf0a833/app/models/caboose/subscription.rb#L46-L129
20,868
williambarry007/caboose-cms
app/models/caboose/invoice_package.rb
Caboose.InvoicePackage.activemerchant_package
def activemerchant_package sc = self.invoice.site.store_config weight = 0.0 self.line_items.each{ |li| weight = weight + (li.variant.weight * li.quantity) } weight = weight * 0.035274 if sc.weight_unit == StoreConfig::WEIGHT_UNIT_METRIC # grams to ounces sp ...
ruby
def activemerchant_package sc = self.invoice.site.store_config weight = 0.0 self.line_items.each{ |li| weight = weight + (li.variant.weight * li.quantity) } weight = weight * 0.035274 if sc.weight_unit == StoreConfig::WEIGHT_UNIT_METRIC # grams to ounces sp ...
[ "def", "activemerchant_package", "sc", "=", "self", ".", "invoice", ".", "site", ".", "store_config", "weight", "=", "0.0", "self", ".", "line_items", ".", "each", "{", "|", "li", "|", "weight", "=", "weight", "+", "(", "li", ".", "variant", ".", "weig...
Gets the activemerchant package based on the shipping package
[ "Gets", "the", "activemerchant", "package", "based", "on", "the", "shipping", "package" ]
7c112911318f94cc89dba86091903a3acaf0a833
https://github.com/williambarry007/caboose-cms/blob/7c112911318f94cc89dba86091903a3acaf0a833/app/models/caboose/invoice_package.rb#L59-L75
20,869
williambarry007/caboose-cms
app/models/caboose/shipping_package.rb
Caboose.ShippingPackage.boxes
def boxes(rigid_variants) stackable = {} nonstackable = [] rigid_variants.each do |v| sgid = v.product.stackable_group_id if sgid stackable[sgid] = [] if stackable[sgid].nil? stackable[sgid] << v else nonstackable << [v.leng...
ruby
def boxes(rigid_variants) stackable = {} nonstackable = [] rigid_variants.each do |v| sgid = v.product.stackable_group_id if sgid stackable[sgid] = [] if stackable[sgid].nil? stackable[sgid] << v else nonstackable << [v.leng...
[ "def", "boxes", "(", "rigid_variants", ")", "stackable", "=", "{", "}", "nonstackable", "=", "[", "]", "rigid_variants", ".", "each", "do", "|", "v", "|", "sgid", "=", "v", ".", "product", ".", "stackable_group_id", "if", "sgid", "stackable", "[", "sgid"...
Gets the 3d dimensions of the variants after they're stacked
[ "Gets", "the", "3d", "dimensions", "of", "the", "variants", "after", "they", "re", "stacked" ]
7c112911318f94cc89dba86091903a3acaf0a833
https://github.com/williambarry007/caboose-cms/blob/7c112911318f94cc89dba86091903a3acaf0a833/app/models/caboose/shipping_package.rb#L55-L94
20,870
williambarry007/caboose-cms
app/controllers/caboose/application_controller.rb
Caboose.ApplicationController.init_cart
def init_cart # Check if the cart ID is defined and that it exists in the database create_new_invoice = false if session[:cart_id] @invoice = Caboose::Invoice.where(:id => session[:cart_id]).first create_new_invoice = true if @invoice.nil? || @invoice.status != 'cart' ...
ruby
def init_cart # Check if the cart ID is defined and that it exists in the database create_new_invoice = false if session[:cart_id] @invoice = Caboose::Invoice.where(:id => session[:cart_id]).first create_new_invoice = true if @invoice.nil? || @invoice.status != 'cart' ...
[ "def", "init_cart", "# Check if the cart ID is defined and that it exists in the database", "create_new_invoice", "=", "false", "if", "session", "[", ":cart_id", "]", "@invoice", "=", "Caboose", "::", "Invoice", ".", "where", "(", ":id", "=>", "session", "[", ":cart_id"...
Initialize the cart in the session
[ "Initialize", "the", "cart", "in", "the", "session" ]
7c112911318f94cc89dba86091903a3acaf0a833
https://github.com/williambarry007/caboose-cms/blob/7c112911318f94cc89dba86091903a3acaf0a833/app/controllers/caboose/application_controller.rb#L69-L101
20,871
williambarry007/caboose-cms
app/controllers/caboose/application_controller.rb
Caboose.ApplicationController.parse_url_params
def parse_url_params return if !Caboose.use_url_params url = "#{request.fullpath}" url[0] = "" if url.starts_with?('/') url = url.split('?')[0] if url.include?('?') arr = url.split('/') i = arr.count - 1 while i >= 1 do k = arr[i-1] ...
ruby
def parse_url_params return if !Caboose.use_url_params url = "#{request.fullpath}" url[0] = "" if url.starts_with?('/') url = url.split('?')[0] if url.include?('?') arr = url.split('/') i = arr.count - 1 while i >= 1 do k = arr[i-1] ...
[ "def", "parse_url_params", "return", "if", "!", "Caboose", ".", "use_url_params", "url", "=", "\"#{request.fullpath}\"", "url", "[", "0", "]", "=", "\"\"", "if", "url", ".", "starts_with?", "(", "'/'", ")", "url", "=", "url", ".", "split", "(", "'?'", ")...
Parses any parameters in the URL and adds them to the params
[ "Parses", "any", "parameters", "in", "the", "URL", "and", "adds", "them", "to", "the", "params" ]
7c112911318f94cc89dba86091903a3acaf0a833
https://github.com/williambarry007/caboose-cms/blob/7c112911318f94cc89dba86091903a3acaf0a833/app/controllers/caboose/application_controller.rb#L112-L128
20,872
williambarry007/caboose-cms
app/controllers/caboose/application_controller.rb
Caboose.ApplicationController.login_user
def login_user(user, remember = false) session["app_user"] = Caboose::StdClass.new({ :id => user.id , :site_id => user.site_id , :first_name => user.first_name , :last_name => user.last_name , :username => user.username , :email ...
ruby
def login_user(user, remember = false) session["app_user"] = Caboose::StdClass.new({ :id => user.id , :site_id => user.site_id , :first_name => user.first_name , :last_name => user.last_name , :username => user.username , :email ...
[ "def", "login_user", "(", "user", ",", "remember", "=", "false", ")", "session", "[", "\"app_user\"", "]", "=", "Caboose", "::", "StdClass", ".", "new", "(", "{", ":id", "=>", "user", ".", "id", ",", ":site_id", "=>", "user", ".", "site_id", ",", ":f...
Logs in a user
[ "Logs", "in", "a", "user" ]
7c112911318f94cc89dba86091903a3acaf0a833
https://github.com/williambarry007/caboose-cms/blob/7c112911318f94cc89dba86091903a3acaf0a833/app/controllers/caboose/application_controller.rb#L142-L152
20,873
williambarry007/caboose-cms
app/controllers/caboose/application_controller.rb
Caboose.ApplicationController.logged_in?
def logged_in? validate_token validate_cookie return true if !session["app_user"].nil? && session["app_user"] != false && session["app_user"].id != -1 && session["app_user"].id != User.logged_out_user_id(@site.id) return false end
ruby
def logged_in? validate_token validate_cookie return true if !session["app_user"].nil? && session["app_user"] != false && session["app_user"].id != -1 && session["app_user"].id != User.logged_out_user_id(@site.id) return false end
[ "def", "logged_in?", "validate_token", "validate_cookie", "return", "true", "if", "!", "session", "[", "\"app_user\"", "]", ".", "nil?", "&&", "session", "[", "\"app_user\"", "]", "!=", "false", "&&", "session", "[", "\"app_user\"", "]", ".", "id", "!=", "-"...
Returns whether or not a user is logged in
[ "Returns", "whether", "or", "not", "a", "user", "is", "logged", "in" ]
7c112911318f94cc89dba86091903a3acaf0a833
https://github.com/williambarry007/caboose-cms/blob/7c112911318f94cc89dba86091903a3acaf0a833/app/controllers/caboose/application_controller.rb#L155-L160
20,874
williambarry007/caboose-cms
app/controllers/caboose/application_controller.rb
Caboose.ApplicationController.validate_token
def validate_token token = params[:token] return false if token.nil? user = User.validate_token(token) return false if user.nil? login_user(user) return true end
ruby
def validate_token token = params[:token] return false if token.nil? user = User.validate_token(token) return false if user.nil? login_user(user) return true end
[ "def", "validate_token", "token", "=", "params", "[", ":token", "]", "return", "false", "if", "token", ".", "nil?", "user", "=", "User", ".", "validate_token", "(", "token", ")", "return", "false", "if", "user", ".", "nil?", "login_user", "(", "user", ")...
Checks to see if a token is given. If so, it tries to validate the token and log the user in.
[ "Checks", "to", "see", "if", "a", "token", "is", "given", ".", "If", "so", "it", "tries", "to", "validate", "the", "token", "and", "log", "the", "user", "in", "." ]
7c112911318f94cc89dba86091903a3acaf0a833
https://github.com/williambarry007/caboose-cms/blob/7c112911318f94cc89dba86091903a3acaf0a833/app/controllers/caboose/application_controller.rb#L164-L173
20,875
williambarry007/caboose-cms
app/controllers/caboose/application_controller.rb
Caboose.ApplicationController.validate_cookie
def validate_cookie if cookies[:caboose_user_id] user = User.where(:id => cookies[:caboose_user_id]).first if user login_user(user) return true end end return false end
ruby
def validate_cookie if cookies[:caboose_user_id] user = User.where(:id => cookies[:caboose_user_id]).first if user login_user(user) return true end end return false end
[ "def", "validate_cookie", "if", "cookies", "[", ":caboose_user_id", "]", "user", "=", "User", ".", "where", "(", ":id", "=>", "cookies", "[", ":caboose_user_id", "]", ")", ".", "first", "if", "user", "login_user", "(", "user", ")", "return", "true", "end",...
Checks to see if a remember me cookie value is present.
[ "Checks", "to", "see", "if", "a", "remember", "me", "cookie", "value", "is", "present", "." ]
7c112911318f94cc89dba86091903a3acaf0a833
https://github.com/williambarry007/caboose-cms/blob/7c112911318f94cc89dba86091903a3acaf0a833/app/controllers/caboose/application_controller.rb#L176-L185
20,876
williambarry007/caboose-cms
app/controllers/caboose/application_controller.rb
Caboose.ApplicationController.reject_param
def reject_param(url, param) arr = url.split('?') return url if (arr.count == 1) qs = arr[1].split('&').reject { |pair| pair.split(/[=;]/).first == param } url2 = arr[0] url2 += "?" + qs.join('&') if qs.count > 0 return url2 end
ruby
def reject_param(url, param) arr = url.split('?') return url if (arr.count == 1) qs = arr[1].split('&').reject { |pair| pair.split(/[=;]/).first == param } url2 = arr[0] url2 += "?" + qs.join('&') if qs.count > 0 return url2 end
[ "def", "reject_param", "(", "url", ",", "param", ")", "arr", "=", "url", ".", "split", "(", "'?'", ")", "return", "url", "if", "(", "arr", ".", "count", "==", "1", ")", "qs", "=", "arr", "[", "1", "]", ".", "split", "(", "'&'", ")", ".", "rej...
Removes a given parameter from a URL querystring
[ "Removes", "a", "given", "parameter", "from", "a", "URL", "querystring" ]
7c112911318f94cc89dba86091903a3acaf0a833
https://github.com/williambarry007/caboose-cms/blob/7c112911318f94cc89dba86091903a3acaf0a833/app/controllers/caboose/application_controller.rb#L270-L277
20,877
williambarry007/caboose-cms
app/controllers/caboose/application_controller.rb
Caboose.ApplicationController.under_construction_or_forwarding_domain?
def under_construction_or_forwarding_domain? d = Caboose::Domain.where(:domain => request.host_with_port).first if d.nil? Caboose.log("Could not find domain for #{request.host_with_port}\nAdd this domain to the caboose site.") elsif d.under_construction == true if d.site.u...
ruby
def under_construction_or_forwarding_domain? d = Caboose::Domain.where(:domain => request.host_with_port).first if d.nil? Caboose.log("Could not find domain for #{request.host_with_port}\nAdd this domain to the caboose site.") elsif d.under_construction == true if d.site.u...
[ "def", "under_construction_or_forwarding_domain?", "d", "=", "Caboose", "::", "Domain", ".", "where", "(", ":domain", "=>", "request", ".", "host_with_port", ")", ".", "first", "if", "d", ".", "nil?", "Caboose", ".", "log", "(", "\"Could not find domain for #{requ...
Make sure we're not under construction or on a forwarded domain
[ "Make", "sure", "we", "re", "not", "under", "construction", "or", "on", "a", "forwarded", "domain" ]
7c112911318f94cc89dba86091903a3acaf0a833
https://github.com/williambarry007/caboose-cms/blob/7c112911318f94cc89dba86091903a3acaf0a833/app/controllers/caboose/application_controller.rb#L314-L348
20,878
williambarry007/caboose-cms
app/controllers/caboose/checkout_controller.rb
Caboose.CheckoutController.shipping_json
def shipping_json render :json => { :error => 'Not logged in.' } and return if !logged_in? render :json => { :error => 'No shippable items.' } and return if !@invoice.has_shippable_items? render :json => { :error => 'Empty shipping address.' } and return if @invoice.shipping_address.nil? ...
ruby
def shipping_json render :json => { :error => 'Not logged in.' } and return if !logged_in? render :json => { :error => 'No shippable items.' } and return if !@invoice.has_shippable_items? render :json => { :error => 'Empty shipping address.' } and return if @invoice.shipping_address.nil? ...
[ "def", "shipping_json", "render", ":json", "=>", "{", ":error", "=>", "'Not logged in.'", "}", "and", "return", "if", "!", "logged_in?", "render", ":json", "=>", "{", ":error", "=>", "'No shippable items.'", "}", "and", "return", "if", "!", "@invoice", ".", ...
Step 3 - Shipping method @route GET /checkout/shipping/json
[ "Step", "3", "-", "Shipping", "method" ]
7c112911318f94cc89dba86091903a3acaf0a833
https://github.com/williambarry007/caboose-cms/blob/7c112911318f94cc89dba86091903a3acaf0a833/app/controllers/caboose/checkout_controller.rb#L99-L119
20,879
williambarry007/caboose-cms
app/controllers/caboose/checkout_controller.rb
Caboose.CheckoutController.update_stripe_details
def update_stripe_details render :json => false and return if !logged_in? sc = @site.store_config Stripe.api_key = sc.stripe_secret_key.strip u = logged_in_user c = nil if u.stripe_customer_id c = Stripe::Customer.retrieve(u.stripe_customer_id) ...
ruby
def update_stripe_details render :json => false and return if !logged_in? sc = @site.store_config Stripe.api_key = sc.stripe_secret_key.strip u = logged_in_user c = nil if u.stripe_customer_id c = Stripe::Customer.retrieve(u.stripe_customer_id) ...
[ "def", "update_stripe_details", "render", ":json", "=>", "false", "and", "return", "if", "!", "logged_in?", "sc", "=", "@site", ".", "store_config", "Stripe", ".", "api_key", "=", "sc", ".", "stripe_secret_key", ".", "strip", "u", "=", "logged_in_user", "c", ...
Step 5 - Update Stripe Details @route PUT /checkout/stripe-details
[ "Step", "5", "-", "Update", "Stripe", "Details" ]
7c112911318f94cc89dba86091903a3acaf0a833
https://github.com/williambarry007/caboose-cms/blob/7c112911318f94cc89dba86091903a3acaf0a833/app/controllers/caboose/checkout_controller.rb#L123-L165
20,880
williambarry007/caboose-cms
app/mailers/caboose/invoices_mailer.rb
Caboose.InvoicesMailer.fulfillment_new_invoice
def fulfillment_new_invoice(invoice) @invoice = invoice sc = invoice.site.store_config mail(:to => sc.fulfillment_email, :subject => 'New Order') end
ruby
def fulfillment_new_invoice(invoice) @invoice = invoice sc = invoice.site.store_config mail(:to => sc.fulfillment_email, :subject => 'New Order') end
[ "def", "fulfillment_new_invoice", "(", "invoice", ")", "@invoice", "=", "invoice", "sc", "=", "invoice", ".", "site", ".", "store_config", "mail", "(", ":to", "=>", "sc", ".", "fulfillment_email", ",", ":subject", "=>", "'New Order'", ")", "end" ]
Sends a notification email to the fulfillment dept about a new invoice
[ "Sends", "a", "notification", "email", "to", "the", "fulfillment", "dept", "about", "a", "new", "invoice" ]
7c112911318f94cc89dba86091903a3acaf0a833
https://github.com/williambarry007/caboose-cms/blob/7c112911318f94cc89dba86091903a3acaf0a833/app/mailers/caboose/invoices_mailer.rb#L29-L33
20,881
williambarry007/caboose-cms
app/mailers/caboose/invoices_mailer.rb
Caboose.InvoicesMailer.shipping_invoice_ready
def shipping_invoice_ready(invoice) @invoice = invoice sc = invoice.site.store_config mail(:to => sc.shipping_email, :subject => 'Order ready for shipping') end
ruby
def shipping_invoice_ready(invoice) @invoice = invoice sc = invoice.site.store_config mail(:to => sc.shipping_email, :subject => 'Order ready for shipping') end
[ "def", "shipping_invoice_ready", "(", "invoice", ")", "@invoice", "=", "invoice", "sc", "=", "invoice", ".", "site", ".", "store_config", "mail", "(", ":to", "=>", "sc", ".", "shipping_email", ",", ":subject", "=>", "'Order ready for shipping'", ")", "end" ]
Sends a notification email to the shipping dept that an invoice is ready to be shipped
[ "Sends", "a", "notification", "email", "to", "the", "shipping", "dept", "that", "an", "invoice", "is", "ready", "to", "be", "shipped" ]
7c112911318f94cc89dba86091903a3acaf0a833
https://github.com/williambarry007/caboose-cms/blob/7c112911318f94cc89dba86091903a3acaf0a833/app/mailers/caboose/invoices_mailer.rb#L36-L40
20,882
gernotkogler/xapian_db
lib/xapian_db/document_blueprint.rb
XapianDb.DocumentBlueprint.accessors_module
def accessors_module return @accessors_module unless @accessors_module.nil? @accessors_module = Module.new # Add the accessors for the indexed class and the score @accessors_module.instance_eval do define_method :indexed_class do self.values[0].value end defi...
ruby
def accessors_module return @accessors_module unless @accessors_module.nil? @accessors_module = Module.new # Add the accessors for the indexed class and the score @accessors_module.instance_eval do define_method :indexed_class do self.values[0].value end defi...
[ "def", "accessors_module", "return", "@accessors_module", "unless", "@accessors_module", ".", "nil?", "@accessors_module", "=", "Module", ".", "new", "# Add the accessors for the indexed class and the score", "@accessors_module", ".", "instance_eval", "do", "define_method", ":i...
Lazily build and return a module that implements accessors for each field @return [Module] A module containing all accessor methods
[ "Lazily", "build", "and", "return", "a", "module", "that", "implements", "accessors", "for", "each", "field" ]
5d84aa461e33d038cb505907b4a43db280ab3e36
https://github.com/gernotkogler/xapian_db/blob/5d84aa461e33d038cb505907b4a43db280ab3e36/lib/xapian_db/document_blueprint.rb#L228-L263
20,883
gernotkogler/xapian_db
lib/xapian_db/document_blueprint.rb
XapianDb.DocumentBlueprint.attribute
def attribute(name, options={}, &block) raise ArgumentError.new("You cannot use #{name} as an attribute name since it is a reserved method name of Xapian::Document") if reserved_method_name?(name) do_not_index = options.delete(:index) == false @type_map[name] = (options.delete(:as) || :string) ...
ruby
def attribute(name, options={}, &block) raise ArgumentError.new("You cannot use #{name} as an attribute name since it is a reserved method name of Xapian::Document") if reserved_method_name?(name) do_not_index = options.delete(:index) == false @type_map[name] = (options.delete(:as) || :string) ...
[ "def", "attribute", "(", "name", ",", "options", "=", "{", "}", ",", "&", "block", ")", "raise", "ArgumentError", ".", "new", "(", "\"You cannot use #{name} as an attribute name since it is a reserved method name of Xapian::Document\"", ")", "if", "reserved_method_name?", ...
Add an attribute to the blueprint. Attributes will be stored in the xapian documents an can be accessed from a search result. @param [String] name The name of the method that delivers the value for the attribute @param [Hash] options @option options [Integer] :weight (1) The weight for this attribute. @option opti...
[ "Add", "an", "attribute", "to", "the", "blueprint", ".", "Attributes", "will", "be", "stored", "in", "the", "xapian", "documents", "an", "can", "be", "accessed", "from", "a", "search", "result", "." ]
5d84aa461e33d038cb505907b4a43db280ab3e36
https://github.com/gernotkogler/xapian_db/blob/5d84aa461e33d038cb505907b4a43db280ab3e36/lib/xapian_db/document_blueprint.rb#L326-L337
20,884
gernotkogler/xapian_db
lib/xapian_db/document_blueprint.rb
XapianDb.DocumentBlueprint.attributes
def attributes(*attributes) attributes.each do |attr| raise ArgumentError.new("You cannot use #{attr} as an attribute name since it is a reserved method name of Xapian::Document") if reserved_method_name?(attr) @attributes_hash[attr] = {} @type_map[attr] = :string self.index attr ...
ruby
def attributes(*attributes) attributes.each do |attr| raise ArgumentError.new("You cannot use #{attr} as an attribute name since it is a reserved method name of Xapian::Document") if reserved_method_name?(attr) @attributes_hash[attr] = {} @type_map[attr] = :string self.index attr ...
[ "def", "attributes", "(", "*", "attributes", ")", "attributes", ".", "each", "do", "|", "attr", "|", "raise", "ArgumentError", ".", "new", "(", "\"You cannot use #{attr} as an attribute name since it is a reserved method name of Xapian::Document\"", ")", "if", "reserved_met...
Add a list of attributes to the blueprint. Attributes will be stored in the xapian documents ans can be accessed from a search result. @param [Array] attributes An array of method names that deliver the values for the attributes
[ "Add", "a", "list", "of", "attributes", "to", "the", "blueprint", ".", "Attributes", "will", "be", "stored", "in", "the", "xapian", "documents", "ans", "can", "be", "accessed", "from", "a", "search", "result", "." ]
5d84aa461e33d038cb505907b4a43db280ab3e36
https://github.com/gernotkogler/xapian_db/blob/5d84aa461e33d038cb505907b4a43db280ab3e36/lib/xapian_db/document_blueprint.rb#L342-L349
20,885
gernotkogler/xapian_db
lib/xapian_db/document_blueprint.rb
XapianDb.DocumentBlueprint.index
def index(*args, &block) case args.size when 1 @indexed_methods_hash[args.first] = IndexOptions.new(:weight => 1, :block => block) when 2 # Is it a method name with options? if args.last.is_a? Hash options = args.last assert_valid_keys options,...
ruby
def index(*args, &block) case args.size when 1 @indexed_methods_hash[args.first] = IndexOptions.new(:weight => 1, :block => block) when 2 # Is it a method name with options? if args.last.is_a? Hash options = args.last assert_valid_keys options,...
[ "def", "index", "(", "*", "args", ",", "&", "block", ")", "case", "args", ".", "size", "when", "1", "@indexed_methods_hash", "[", "args", ".", "first", "]", "=", "IndexOptions", ".", "new", "(", ":weight", "=>", "1", ",", ":block", "=>", "block", ")"...
Add an indexed value to the blueprint. Indexed values are not accessible from a search result. @param [Array] args An array of arguments; you can pass a method name, an array of method names or a method name and an options hash. @param [Block] &block An optional block for complex configurations Avaliable options:...
[ "Add", "an", "indexed", "value", "to", "the", "blueprint", ".", "Indexed", "values", "are", "not", "accessible", "from", "a", "search", "result", "." ]
5d84aa461e33d038cb505907b4a43db280ab3e36
https://github.com/gernotkogler/xapian_db/blob/5d84aa461e33d038cb505907b4a43db280ab3e36/lib/xapian_db/document_blueprint.rb#L367-L383
20,886
gernotkogler/xapian_db
lib/xapian_db/document_blueprint.rb
XapianDb.DocumentBlueprint.natural_sort_order
def natural_sort_order(name=nil, &block) raise ArgumentError.new("natural_sort_order accepts a method name or a block, but not both") if name && block @_natural_sort_order = name || block end
ruby
def natural_sort_order(name=nil, &block) raise ArgumentError.new("natural_sort_order accepts a method name or a block, but not both") if name && block @_natural_sort_order = name || block end
[ "def", "natural_sort_order", "(", "name", "=", "nil", ",", "&", "block", ")", "raise", "ArgumentError", ".", "new", "(", "\"natural_sort_order accepts a method name or a block, but not both\"", ")", "if", "name", "&&", "block", "@_natural_sort_order", "=", "name", "||...
Define the natural sort order. @param [String] name The name of the method that delivers the sort expression @param [Block] &block An optional block for complex configurations Pass a method name or a block, but not both
[ "Define", "the", "natural", "sort", "order", "." ]
5d84aa461e33d038cb505907b4a43db280ab3e36
https://github.com/gernotkogler/xapian_db/blob/5d84aa461e33d038cb505907b4a43db280ab3e36/lib/xapian_db/document_blueprint.rb#L408-L411
20,887
gernotkogler/xapian_db
lib/xapian_db/config.rb
XapianDb.Config.database
def database(path) # If the current database is a persistent database, we must release the # database and run the garbage collector to remove the write lock if @_database.is_a?(XapianDb::PersistentDatabase) @_database = nil GC.start end if path.to_sym == :memory @...
ruby
def database(path) # If the current database is a persistent database, we must release the # database and run the garbage collector to remove the write lock if @_database.is_a?(XapianDb::PersistentDatabase) @_database = nil GC.start end if path.to_sym == :memory @...
[ "def", "database", "(", "path", ")", "# If the current database is a persistent database, we must release the", "# database and run the garbage collector to remove the write lock", "if", "@_database", ".", "is_a?", "(", "XapianDb", "::", "PersistentDatabase", ")", "@_database", "="...
Set the global database to use @param [String] path The path to the database. Either apply a file sytem path or :memory for an in memory database
[ "Set", "the", "global", "database", "to", "use" ]
5d84aa461e33d038cb505907b4a43db280ab3e36
https://github.com/gernotkogler/xapian_db/blob/5d84aa461e33d038cb505907b4a43db280ab3e36/lib/xapian_db/config.rb#L83-L101
20,888
gernotkogler/xapian_db
lib/xapian_db/config.rb
XapianDb.Config.adapter
def adapter(type) begin @_adapter = XapianDb::Adapters.const_get("#{camelize(type.to_s)}Adapter") rescue NameError require File.dirname(__FILE__) + "/adapters/#{type}_adapter" @_adapter = XapianDb::Adapters.const_get("#{camelize(type.to_s)}Adapter") end end
ruby
def adapter(type) begin @_adapter = XapianDb::Adapters.const_get("#{camelize(type.to_s)}Adapter") rescue NameError require File.dirname(__FILE__) + "/adapters/#{type}_adapter" @_adapter = XapianDb::Adapters.const_get("#{camelize(type.to_s)}Adapter") end end
[ "def", "adapter", "(", "type", ")", "begin", "@_adapter", "=", "XapianDb", "::", "Adapters", ".", "const_get", "(", "\"#{camelize(type.to_s)}Adapter\"", ")", "rescue", "NameError", "require", "File", ".", "dirname", "(", "__FILE__", ")", "+", "\"/adapters/#{type}_...
Set the adapter @param [Symbol] type The adapter type; the following adapters are available: - :generic ({XapianDb::Adapters::GenericAdapter}) - :active_record ({XapianDb::Adapters::ActiveRecordAdapter}) - :datamapper ({XapianDb::Adapters::DatamapperAdapter})
[ "Set", "the", "adapter" ]
5d84aa461e33d038cb505907b4a43db280ab3e36
https://github.com/gernotkogler/xapian_db/blob/5d84aa461e33d038cb505907b4a43db280ab3e36/lib/xapian_db/config.rb#L108-L115
20,889
gernotkogler/xapian_db
lib/xapian_db/config.rb
XapianDb.Config.writer
def writer(type) # We try to guess the writer name begin require File.dirname(__FILE__) + "/index_writers/#{type}_writer" @_writer = XapianDb::IndexWriters.const_get("#{camelize(type.to_s)}Writer") rescue LoadError puts "XapianDb: cannot load #{type} writer; see README for supp...
ruby
def writer(type) # We try to guess the writer name begin require File.dirname(__FILE__) + "/index_writers/#{type}_writer" @_writer = XapianDb::IndexWriters.const_get("#{camelize(type.to_s)}Writer") rescue LoadError puts "XapianDb: cannot load #{type} writer; see README for supp...
[ "def", "writer", "(", "type", ")", "# We try to guess the writer name", "begin", "require", "File", ".", "dirname", "(", "__FILE__", ")", "+", "\"/index_writers/#{type}_writer\"", "@_writer", "=", "XapianDb", "::", "IndexWriters", ".", "const_get", "(", "\"#{camelize(...
Set the index writer @param [Symbol] type The writer type; the following adapters are available: - :direct ({XapianDb::IndexWriters::DirectWriter}) - :beanstalk ({XapianDb::IndexWriters::BeanstalkWriter}) - :resque ({XapianDb::IndexWriters::ResqueWriter}) - :sidekiq ({XapianDb::IndexWriters::SidekiqWriter}...
[ "Set", "the", "index", "writer" ]
5d84aa461e33d038cb505907b4a43db280ab3e36
https://github.com/gernotkogler/xapian_db/blob/5d84aa461e33d038cb505907b4a43db280ab3e36/lib/xapian_db/config.rb#L123-L132
20,890
gernotkogler/xapian_db
lib/xapian_db/config.rb
XapianDb.Config.language
def language(lang) lang ||= :none @_stemmer = XapianDb::Repositories::Stemmer.stemmer_for lang @_stopper = lang == :none ? nil : XapianDb::Repositories::Stopper.stopper_for(lang) end
ruby
def language(lang) lang ||= :none @_stemmer = XapianDb::Repositories::Stemmer.stemmer_for lang @_stopper = lang == :none ? nil : XapianDb::Repositories::Stopper.stopper_for(lang) end
[ "def", "language", "(", "lang", ")", "lang", "||=", ":none", "@_stemmer", "=", "XapianDb", "::", "Repositories", "::", "Stemmer", ".", "stemmer_for", "lang", "@_stopper", "=", "lang", "==", ":none", "?", "nil", ":", "XapianDb", "::", "Repositories", "::", ...
Set the language. @param [Symbol] lang The language; apply the two letter ISO639 code for the language @example XapianDb::Config.setup do |config| config.language :de end see {LANGUAGE_MAP} for supported languages
[ "Set", "the", "language", "." ]
5d84aa461e33d038cb505907b4a43db280ab3e36
https://github.com/gernotkogler/xapian_db/blob/5d84aa461e33d038cb505907b4a43db280ab3e36/lib/xapian_db/config.rb#L159-L163
20,891
gernotkogler/xapian_db
lib/xapian_db/utilities.rb
XapianDb.Utilities.assert_valid_keys
def assert_valid_keys(hash, *valid_keys) unknown_keys = hash.keys - [valid_keys].flatten raise(ArgumentError, "Unsupported option(s) detected: #{unknown_keys.join(", ")}") unless unknown_keys.empty? end
ruby
def assert_valid_keys(hash, *valid_keys) unknown_keys = hash.keys - [valid_keys].flatten raise(ArgumentError, "Unsupported option(s) detected: #{unknown_keys.join(", ")}") unless unknown_keys.empty? end
[ "def", "assert_valid_keys", "(", "hash", ",", "*", "valid_keys", ")", "unknown_keys", "=", "hash", ".", "keys", "-", "[", "valid_keys", "]", ".", "flatten", "raise", "(", "ArgumentError", ",", "\"Unsupported option(s) detected: #{unknown_keys.join(\", \")}\"", ")", ...
Taken from Rails
[ "Taken", "from", "Rails" ]
5d84aa461e33d038cb505907b4a43db280ab3e36
https://github.com/gernotkogler/xapian_db/blob/5d84aa461e33d038cb505907b4a43db280ab3e36/lib/xapian_db/utilities.rb#L45-L48
20,892
thoughtbot/bourne
lib/bourne/api.rb
Mocha.API.assert_received
def assert_received(mock, expected_method_name) matcher = have_received(expected_method_name) yield(matcher) if block_given? assert matcher.matches?(mock), matcher.failure_message end
ruby
def assert_received(mock, expected_method_name) matcher = have_received(expected_method_name) yield(matcher) if block_given? assert matcher.matches?(mock), matcher.failure_message end
[ "def", "assert_received", "(", "mock", ",", "expected_method_name", ")", "matcher", "=", "have_received", "(", "expected_method_name", ")", "yield", "(", "matcher", ")", "if", "block_given?", "assert", "matcher", ".", "matches?", "(", "mock", ")", ",", "matcher"...
Asserts that the given mock received the given method. Examples: assert_received(mock, :to_s) assert_received(Radio, :new) {|expect| expect.with(1041) } assert_received(radio, :volume) {|expect| expect.with(11).twice }
[ "Asserts", "that", "the", "given", "mock", "received", "the", "given", "method", "." ]
4b1f3d6908011923ffcd423af41eb2f30494e8e6
https://github.com/thoughtbot/bourne/blob/4b1f3d6908011923ffcd423af41eb2f30494e8e6/lib/bourne/api.rb#L13-L17
20,893
gernotkogler/xapian_db
lib/xapian_db/resultset.rb
XapianDb.Resultset.decorate
def decorate(match) klass_name = match.document.values[0].value blueprint = XapianDb::DocumentBlueprint.blueprint_for klass_name match.document.extend blueprint.accessors_module match.document.instance_variable_set :@score, match.percent match end
ruby
def decorate(match) klass_name = match.document.values[0].value blueprint = XapianDb::DocumentBlueprint.blueprint_for klass_name match.document.extend blueprint.accessors_module match.document.instance_variable_set :@score, match.percent match end
[ "def", "decorate", "(", "match", ")", "klass_name", "=", "match", ".", "document", ".", "values", "[", "0", "]", ".", "value", "blueprint", "=", "XapianDb", "::", "DocumentBlueprint", ".", "blueprint_for", "klass_name", "match", ".", "document", ".", "extend...
Decorate a Xapian match with field accessors for each configured attribute @param [Xapian::Match] a match @return [Xapian::Match] the decorated match
[ "Decorate", "a", "Xapian", "match", "with", "field", "accessors", "for", "each", "configured", "attribute" ]
5d84aa461e33d038cb505907b4a43db280ab3e36
https://github.com/gernotkogler/xapian_db/blob/5d84aa461e33d038cb505907b4a43db280ab3e36/lib/xapian_db/resultset.rb#L113-L119
20,894
gernotkogler/xapian_db
lib/xapian_db/database.rb
XapianDb.Database.delete_docs_of_class
def delete_docs_of_class(klass) writer.delete_document("C#{klass}") if klass.respond_to? :descendants klass.descendants.each do |subclass| writer.delete_document("C#{subclass}") end end true end
ruby
def delete_docs_of_class(klass) writer.delete_document("C#{klass}") if klass.respond_to? :descendants klass.descendants.each do |subclass| writer.delete_document("C#{subclass}") end end true end
[ "def", "delete_docs_of_class", "(", "klass", ")", "writer", ".", "delete_document", "(", "\"C#{klass}\"", ")", "if", "klass", ".", "respond_to?", ":descendants", "klass", ".", "descendants", ".", "each", "do", "|", "subclass", "|", "writer", ".", "delete_documen...
Delete all docs of a specific class. If `klass` tracks its descendants, then docs of any subclasses will be deleted, too. (ActiveRecord does this by default; the gem 'descendants_tracker' offers an alternative.) @param [Class] klass A class that has a {XapianDb::DocumentBlueprint} configuration
[ "Delete", "all", "docs", "of", "a", "specific", "class", "." ]
5d84aa461e33d038cb505907b4a43db280ab3e36
https://github.com/gernotkogler/xapian_db/blob/5d84aa461e33d038cb505907b4a43db280ab3e36/lib/xapian_db/database.rb#L44-L52
20,895
gernotkogler/xapian_db
lib/xapian_db/database.rb
XapianDb.Database.search
def search(expression, options={}) opts = {:sort_decending => false}.merge(options) @query_parser ||= QueryParser.new(self) query = @query_parser.parse(expression) # If we do not have a valid query we return an empty result set return Resultset.new(nil, opts) unless query...
ruby
def search(expression, options={}) opts = {:sort_decending => false}.merge(options) @query_parser ||= QueryParser.new(self) query = @query_parser.parse(expression) # If we do not have a valid query we return an empty result set return Resultset.new(nil, opts) unless query...
[ "def", "search", "(", "expression", ",", "options", "=", "{", "}", ")", "opts", "=", "{", ":sort_decending", "=>", "false", "}", ".", "merge", "(", "options", ")", "@query_parser", "||=", "QueryParser", ".", "new", "(", "self", ")", "query", "=", "@que...
Perform a search @param [String] expression A valid search expression. @param [Hash] options @option options [Integer] :per_page How many docs per page? @option options [Array<Integer>] :sort_indices (nil) An array of attribute indices to sort by. This option is used internally by the search method implemented o...
[ "Perform", "a", "search" ]
5d84aa461e33d038cb505907b4a43db280ab3e36
https://github.com/gernotkogler/xapian_db/blob/5d84aa461e33d038cb505907b4a43db280ab3e36/lib/xapian_db/database.rb#L71-L119
20,896
gernotkogler/xapian_db
lib/xapian_db/database.rb
XapianDb.Database.facets
def facets(attribute, expression) # return an empty hash if no search expression is given return {} if expression.nil? || expression.strip.empty? value_number = XapianDb::DocumentBlueprint.value_number_for(attribute) @query_parser ||= QueryParser.new(self) query ...
ruby
def facets(attribute, expression) # return an empty hash if no search expression is given return {} if expression.nil? || expression.strip.empty? value_number = XapianDb::DocumentBlueprint.value_number_for(attribute) @query_parser ||= QueryParser.new(self) query ...
[ "def", "facets", "(", "attribute", ",", "expression", ")", "# return an empty hash if no search expression is given", "return", "{", "}", "if", "expression", ".", "nil?", "||", "expression", ".", "strip", ".", "empty?", "value_number", "=", "XapianDb", "::", "Docume...
A very simple implementation of facets using Xapian collapse key. @param [Symbol, String] attribute the name of an attribute declared in one ore more blueprints @param [String] expression A valid search expression (see {#search} for examples). @return [Hash<Class, Integer>] A hash containing the classes and the hits...
[ "A", "very", "simple", "implementation", "of", "facets", "using", "Xapian", "collapse", "key", "." ]
5d84aa461e33d038cb505907b4a43db280ab3e36
https://github.com/gernotkogler/xapian_db/blob/5d84aa461e33d038cb505907b4a43db280ab3e36/lib/xapian_db/database.rb#L156-L173
20,897
gernotkogler/xapian_db
lib/xapian_db/indexer.rb
XapianDb.Indexer.store_fields
def store_fields # class name of the object goes to position 0 @xapian_doc.add_value 0, @obj.class.name # natural sort order goes to position 1 if @blueprint._natural_sort_order.is_a? Proc sort_value = @obj.instance_eval &@blueprint._natural_sort_order else sort_value = @o...
ruby
def store_fields # class name of the object goes to position 0 @xapian_doc.add_value 0, @obj.class.name # natural sort order goes to position 1 if @blueprint._natural_sort_order.is_a? Proc sort_value = @obj.instance_eval &@blueprint._natural_sort_order else sort_value = @o...
[ "def", "store_fields", "# class name of the object goes to position 0", "@xapian_doc", ".", "add_value", "0", ",", "@obj", ".", "class", ".", "name", "# natural sort order goes to position 1", "if", "@blueprint", ".", "_natural_sort_order", ".", "is_a?", "Proc", "sort_value...
Store all configured fields
[ "Store", "all", "configured", "fields" ]
5d84aa461e33d038cb505907b4a43db280ab3e36
https://github.com/gernotkogler/xapian_db/blob/5d84aa461e33d038cb505907b4a43db280ab3e36/lib/xapian_db/indexer.rb#L33-L57
20,898
gernotkogler/xapian_db
lib/xapian_db/indexer.rb
XapianDb.Indexer.index_text
def index_text term_generator = Xapian::TermGenerator.new term_generator.database = @database.writer term_generator.document = @xapian_doc if XapianDb::Config.stemmer term_generator.stemmer = XapianDb::Config.stemmer term_generator.stopper = XapianDb::Config.stopper if XapianDb...
ruby
def index_text term_generator = Xapian::TermGenerator.new term_generator.database = @database.writer term_generator.document = @xapian_doc if XapianDb::Config.stemmer term_generator.stemmer = XapianDb::Config.stemmer term_generator.stopper = XapianDb::Config.stopper if XapianDb...
[ "def", "index_text", "term_generator", "=", "Xapian", "::", "TermGenerator", ".", "new", "term_generator", ".", "database", "=", "@database", ".", "writer", "term_generator", ".", "document", "=", "@xapian_doc", "if", "XapianDb", "::", "Config", ".", "stemmer", ...
Index all configured text methods
[ "Index", "all", "configured", "text", "methods" ]
5d84aa461e33d038cb505907b4a43db280ab3e36
https://github.com/gernotkogler/xapian_db/blob/5d84aa461e33d038cb505907b4a43db280ab3e36/lib/xapian_db/indexer.rb#L60-L101
20,899
gernotkogler/xapian_db
lib/xapian_db/indexer.rb
XapianDb.Indexer.get_values_to_index_from
def get_values_to_index_from(obj) # if it's an array, we collect the values for its elements recursive if obj.is_a? Array return obj.map { |element| get_values_to_index_from element }.flatten.compact end # if the object responds to attributes and attributes is a hash, # we use th...
ruby
def get_values_to_index_from(obj) # if it's an array, we collect the values for its elements recursive if obj.is_a? Array return obj.map { |element| get_values_to_index_from element }.flatten.compact end # if the object responds to attributes and attributes is a hash, # we use th...
[ "def", "get_values_to_index_from", "(", "obj", ")", "# if it's an array, we collect the values for its elements recursive", "if", "obj", ".", "is_a?", "Array", "return", "obj", ".", "map", "{", "|", "element", "|", "get_values_to_index_from", "element", "}", ".", "flatt...
Get the values to index from an object
[ "Get", "the", "values", "to", "index", "from", "an", "object" ]
5d84aa461e33d038cb505907b4a43db280ab3e36
https://github.com/gernotkogler/xapian_db/blob/5d84aa461e33d038cb505907b4a43db280ab3e36/lib/xapian_db/indexer.rb#L104-L118