_id
stringlengths 2
6
| title
stringlengths 9
130
| partition
stringclasses 3
values | text
stringlengths 66
10.5k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q1600
|
Sorted.Set.c
|
train
|
def c(memo)
each do |order|
unless memo.keys.include?(order[0])
memo << order
end
end
end
|
ruby
|
{
"resource": ""
}
|
q1601
|
Sorted.Set.d
|
train
|
def d(memo, other)
other.each do |sort|
unless memo.keys.include?(sort[0])
memo << sort
end
end
end
|
ruby
|
{
"resource": ""
}
|
q1602
|
Hawkular::Alerts.Client.list_triggers
|
train
|
def list_triggers(ids = [], tags = [])
query = generate_query_params 'triggerIds' => ids, 'tags' => tags
sub_url = '/triggers' + query
ret = http_get(sub_url)
val = []
ret.each { |t| val.push(Trigger.new(t)) }
val
end
|
ruby
|
{
"resource": ""
}
|
q1603
|
Hawkular::Alerts.Client.get_single_trigger
|
train
|
def get_single_trigger(trigger_id, full = false)
the_trigger = '/triggers/' + trigger_id
ret = http_get(the_trigger)
trigger = Trigger.new(ret)
if full
ret = http_get(the_trigger + '/conditions')
ret.each { |c| trigger.conditions.push(Trigger::Condition.new(c)) }
ret = http_get(the_trigger + '/dampenings')
ret.each { |c| trigger.dampenings.push(Trigger::Dampening.new(c)) }
end
trigger
end
|
ruby
|
{
"resource": ""
}
|
q1604
|
Hawkular::Alerts.Client.create_trigger
|
train
|
def create_trigger(trigger, conditions = [], dampenings = [], _actions = [])
full_trigger = {}
full_trigger[:trigger] = trigger.to_h
conds = []
conditions.each { |c| conds.push(c.to_h) }
full_trigger[:conditions] = conds
damps = []
dampenings.each { |d| damps.push(d.to_h) } unless dampenings.nil?
full_trigger[:dampenings] = damps
http_post 'triggers/trigger', full_trigger
end
|
ruby
|
{
"resource": ""
}
|
q1605
|
Hawkular::Alerts.Client.set_group_conditions
|
train
|
def set_group_conditions(trigger_id, trigger_mode, group_conditions_info)
ret = http_put "triggers/groups/#{trigger_id}/conditions/#{trigger_mode}", group_conditions_info.to_h
conditions = []
ret.each { |c| conditions.push(Trigger::Condition.new(c)) }
conditions
end
|
ruby
|
{
"resource": ""
}
|
q1606
|
Hawkular::Alerts.Client.list_members
|
train
|
def list_members(trigger_id, orphans = false)
ret = http_get "triggers/groups/#{trigger_id}/members?includeOrphans=#{orphans}"
ret.collect { |t| Trigger.new(t) }
end
|
ruby
|
{
"resource": ""
}
|
q1607
|
Hawkular::Alerts.Client.create_group_dampening
|
train
|
def create_group_dampening(dampening)
ret = http_post "triggers/groups/#{dampening.trigger_id}/dampenings", dampening.to_h
Trigger::Dampening.new(ret)
end
|
ruby
|
{
"resource": ""
}
|
q1608
|
Hawkular::Alerts.Client.update_group_dampening
|
train
|
def update_group_dampening(dampening)
ret = http_put "triggers/groups/#{dampening.trigger_id}/dampenings/#{dampening.dampening_id}", dampening.to_h
Trigger::Dampening.new(ret)
end
|
ruby
|
{
"resource": ""
}
|
q1609
|
Hawkular::Alerts.Client.create_action
|
train
|
def create_action(plugin, action_id, properties = {})
the_plugin = hawk_escape plugin
# Check if plugin exists
http_get("/plugins/#{the_plugin}")
payload = { actionId: action_id, actionPlugin: plugin, properties: properties }
ret = http_post('/actions', payload)
Trigger::Action.new(ret)
end
|
ruby
|
{
"resource": ""
}
|
q1610
|
Hawkular::Alerts.Client.get_action
|
train
|
def get_action(plugin, action_id)
the_plugin = hawk_escape plugin
the_action_id = hawk_escape action_id
ret = http_get "/actions/#{the_plugin}/#{the_action_id}"
Trigger::Action.new(ret)
end
|
ruby
|
{
"resource": ""
}
|
q1611
|
Hawkular::Alerts.Client.delete_action
|
train
|
def delete_action(plugin, action_id)
the_plugin = hawk_escape plugin
the_action_id = hawk_escape action_id
http_delete "/actions/#{the_plugin}/#{the_action_id}"
end
|
ruby
|
{
"resource": ""
}
|
q1612
|
Hawkular::Alerts.Client.get_alerts_for_trigger
|
train
|
def get_alerts_for_trigger(trigger_id)
# TODO: add additional filters
return [] unless trigger_id
url = '/?triggerIds=' + trigger_id
ret = http_get(url)
val = []
ret.each { |a| val.push(Alert.new(a)) }
val
end
|
ruby
|
{
"resource": ""
}
|
q1613
|
Hawkular::Alerts.Client.alerts
|
train
|
def alerts(criteria: {}, tenants: nil)
query = generate_query_params(criteria)
uri = tenants ? '/admin/alerts/' : '/'
ret = http_get(uri + query, multi_tenants_header(tenants))
val = []
ret.each { |a| val.push(Alert.new(a)) }
val
end
|
ruby
|
{
"resource": ""
}
|
q1614
|
Hawkular::Alerts.Client.get_single_alert
|
train
|
def get_single_alert(alert_id)
ret = http_get('/alert/' + alert_id)
val = Alert.new(ret)
val
end
|
ruby
|
{
"resource": ""
}
|
q1615
|
Hawkular::Alerts.Client.resolve_alert
|
train
|
def resolve_alert(alert_id, by = nil, comment = nil)
sub_url = "/resolve/#{alert_id}"
query = generate_query_params 'resolvedBy' => by, 'resolvedNotes' => comment
sub_url += query
http_put(sub_url, {})
true
end
|
ruby
|
{
"resource": ""
}
|
q1616
|
Hawkular::Alerts.Client.create_event
|
train
|
def create_event(id, category, text, extras)
event = {}
event['id'] = id
event['ctime'] = Time.now.to_i * 1000
event['category'] = category
event['text'] = text
event.merge!(extras) { |_key, v1, _v2| v1 }
http_post('/events', event)
end
|
ruby
|
{
"resource": ""
}
|
q1617
|
Hawkular::Alerts.Client.add_tags
|
train
|
def add_tags(alert_ids, tags)
query = generate_query_params(alertIds: alert_ids, tags: tags)
http_put('/tags' + query, {})
end
|
ruby
|
{
"resource": ""
}
|
q1618
|
Hawkular::Alerts.Client.remove_tags
|
train
|
def remove_tags(alert_ids, tag_names)
query = generate_query_params(alertIds: alert_ids, tagNames: tag_names)
http_delete('/tags' + query)
end
|
ruby
|
{
"resource": ""
}
|
q1619
|
CZTop.CertStore.lookup
|
train
|
def lookup(pubkey)
ptr = ffi_delegate.lookup(pubkey)
return nil if ptr.null?
Certificate.from_ffi_delegate(ptr)
end
|
ruby
|
{
"resource": ""
}
|
q1620
|
CZTop.CertStore.insert
|
train
|
def insert(cert)
raise ArgumentError unless cert.is_a?(Certificate)
@_inserted_pubkeys ||= Set.new
pubkey = cert.public_key
raise ArgumentError if @_inserted_pubkeys.include? pubkey
ffi_delegate.insert(cert.ffi_delegate)
@_inserted_pubkeys << pubkey
end
|
ruby
|
{
"resource": ""
}
|
q1621
|
Declarative.Heritage.record
|
train
|
def record(method, *args, &block)
self << {method: method, args: DeepDup.(args), block: block} # DISCUSS: options.dup.
end
|
ruby
|
{
"resource": ""
}
|
q1622
|
Protocol.Utilities.find_method_module
|
train
|
def find_method_module(methodname, ancestors)
methodname = methodname.to_s
ancestors.each do |a|
begin
a.instance_method(methodname)
return a
rescue NameError
end
end
nil
end
|
ruby
|
{
"resource": ""
}
|
q1623
|
CZTop.Monitor.listen
|
train
|
def listen(*events)
events.each do |event|
EVENTS.include?(event) or
raise ArgumentError, "invalid event: #{event.inspect}"
end
@actor << [ "LISTEN", *events ]
end
|
ruby
|
{
"resource": ""
}
|
q1624
|
Jshint::Reporters.Junit.print_errors_for_code
|
train
|
def print_errors_for_code(code, errors)
name = fetch_error_messages(code, errors)
output << " <testcase classname=\"jshint.#{code}\" name=\"#{escape(name)}\">\n"
errors.each do |error|
output << add_error_message(code, error)
end
output << " </testcase>\n"
output
end
|
ruby
|
{
"resource": ""
}
|
q1625
|
Protocol.ProtocolModule.to_ruby
|
train
|
def to_ruby(result = '')
result << "#{name} = Protocol do"
first = true
if messages.empty?
result << "\n"
else
messages.each do |m|
result << "\n"
m.to_ruby(result)
end
end
result << "end\n"
end
|
ruby
|
{
"resource": ""
}
|
q1626
|
Protocol.ProtocolModule.understand?
|
train
|
def understand?(name, arity = nil)
name = name.to_s
!!find { |m| m.name == name && (!arity || m.arity == arity) }
end
|
ruby
|
{
"resource": ""
}
|
q1627
|
Protocol.ProtocolModule.check_failures
|
train
|
def check_failures(object)
check object
rescue CheckFailed => e
return e.errors.map { |e| e.protocol_message }
end
|
ruby
|
{
"resource": ""
}
|
q1628
|
Protocol.ProtocolModule.inherit
|
train
|
def inherit(modul, methodname, block_expected = nil)
Module === modul or
raise TypeError, "expected Module not #{modul.class} as modul argument"
methodnames = methodname.respond_to?(:to_ary) ?
methodname.to_ary :
[ methodname ]
methodnames.each do |methodname|
m = parse_instance_method_signature(modul, methodname)
block_expected and m.block_expected = block_expected
@descriptor.add_message m
end
self
end
|
ruby
|
{
"resource": ""
}
|
q1629
|
Protocol.ProtocolModule.method_added
|
train
|
def method_added(methodname)
methodname = methodname.to_s
if specification? and methodname !~ /^__protocol_check_/
protocol_check = instance_method(methodname)
parser = MethodParser.new(self, methodname)
if parser.complex?
define_method("__protocol_check_#{methodname}", protocol_check)
understand methodname, protocol_check.arity, parser.block_arg?
else
understand methodname, protocol_check.arity, parser.block_arg?
end
remove_method methodname
else
super
end
end
|
ruby
|
{
"resource": ""
}
|
q1630
|
CZTop.Actor.<<
|
train
|
def <<(message)
message = Message.coerce(message)
if TERM == message[0]
# NOTE: can't just send this to the actor. The sender might call
# #terminate immediately, which most likely causes a hang due to race
# conditions.
terminate
else
begin
@mtx.synchronize do
raise DeadActorError if not @running
message.send_to(self)
end
rescue IO::EAGAINWaitWritable
# The sndtimeo has been reached.
#
# This should fix the race condition (mainly on JRuby) between
# @running not being set to false yet but the actor handler already
# terminating and thus not able to receive messages anymore.
#
# This shouldn't result in an infinite loop, since it'll stop as
# soon as @running is set to false by #signal_shimmed_handler_death,
# at least when using a Ruby handler.
#
# In case of a C function handler, it MUST NOT crash and only
# terminate when being sent the "$TERM" message using #terminate (so
# #await_handler_death can set
# @running to false).
retry
end
end
self
end
|
ruby
|
{
"resource": ""
}
|
q1631
|
CZTop.Actor.send_picture
|
train
|
def send_picture(picture, *args)
@mtx.synchronize do
raise DeadActorError if not @running
Zsock.send(ffi_delegate, picture, *args)
end
end
|
ruby
|
{
"resource": ""
}
|
q1632
|
CZTop.Actor.terminate
|
train
|
def terminate
@mtx.synchronize do
return false if not @running
Message.new(TERM).send_to(self)
await_handler_death
true
end
rescue IO::EAGAINWaitWritable
# same as in #<<
retry
end
|
ruby
|
{
"resource": ""
}
|
q1633
|
Genealogy.QueryMethods.ancestors
|
train
|
def ancestors(options = {})
ids = []
if options[:generations]
raise ArgumentError, ":generations option must be an Integer" unless options[:generations].is_a? Integer
generation_count = 0
generation_ids = parents.compact.map(&:id)
while (generation_count < options[:generations]) && (generation_ids.length > 0)
next_gen_ids = []
ids += generation_ids
until generation_ids.empty?
ids.unshift(generation_ids.shift)
next_gen_ids += gclass.find(ids.first).parents.compact.map(&:id)
end
generation_ids = next_gen_ids
generation_count += 1
end
else
remaining_ids = parents.compact.map(&:id)
until remaining_ids.empty?
ids << remaining_ids.shift
remaining_ids += gclass.find(ids.last).parents.compact.map(&:id)
end
end
gclass.where(id: ids)
end
|
ruby
|
{
"resource": ""
}
|
q1634
|
Genealogy.QueryMethods.descendants
|
train
|
def descendants(options = {})
ids = []
if options[:generations]
generation_count = 0
generation_ids = children.map(&:id)
while (generation_count < options[:generations]) && (generation_ids.length > 0)
next_gen_ids = []
ids += generation_ids
until generation_ids.empty?
ids.unshift(generation_ids.shift)
next_gen_ids += gclass.find(ids.first).children.map(&:id)
end
generation_ids = next_gen_ids
generation_count += 1
end
else
remaining_ids = children.map(&:id)
until remaining_ids.empty?
ids << remaining_ids.shift
remaining_ids += gclass.find(ids.last).children.pluck(:id)
# break if (remaining_ids - ids).empty? can be necessary in case of loop. Idem for ancestors method
end
end
gclass.where(id: ids)
end
|
ruby
|
{
"resource": ""
}
|
q1635
|
Genealogy.QueryMethods.uncles_and_aunts
|
train
|
def uncles_and_aunts(options={})
relation = case options[:lineage]
when :paternal
[father]
when :maternal
[mother]
else
parents
end
ids = relation.compact.inject([]){|memo,parent| memo |= parent.siblings(half: options[:half]).pluck(:id)}
gclass.where(id: ids)
end
|
ruby
|
{
"resource": ""
}
|
q1636
|
CZTop.Poller.modify
|
train
|
def modify(socket, events)
ptr = ptr_for_socket(socket)
rc = ZMQ.poller_modify(@poller_ptr, ptr, events)
HasFFIDelegate.raise_zmq_err if rc == -1
remember_socket(socket, events)
end
|
ruby
|
{
"resource": ""
}
|
q1637
|
CZTop.Poller.remove
|
train
|
def remove(socket)
ptr = ptr_for_socket(socket)
rc = ZMQ.poller_remove(@poller_ptr, ptr)
HasFFIDelegate.raise_zmq_err if rc == -1
forget_socket(socket)
end
|
ruby
|
{
"resource": ""
}
|
q1638
|
CZTop.Poller.remove_reader
|
train
|
def remove_reader(socket)
if event_mask_for_socket(socket) == ZMQ::POLLIN
remove(socket)
return
end
raise ArgumentError, "not registered for readability only: %p" % socket
end
|
ruby
|
{
"resource": ""
}
|
q1639
|
CZTop.Poller.remove_writer
|
train
|
def remove_writer(socket)
if event_mask_for_socket(socket) == ZMQ::POLLOUT
remove(socket)
return
end
raise ArgumentError, "not registered for writability only: %p" % socket
end
|
ruby
|
{
"resource": ""
}
|
q1640
|
CZTop.Poller.wait
|
train
|
def wait(timeout = -1)
rc = ZMQ.poller_wait(@poller_ptr, @event_ptr, timeout)
if rc == -1
case CZMQ::FFI::Errors.errno
# NOTE: ETIMEDOUT for backwards compatibility, although this API is
# still DRAFT.
when Errno::EAGAIN::Errno, Errno::ETIMEDOUT::Errno
return nil
else
HasFFIDelegate.raise_zmq_err
end
end
return Event.new(self, @event_ptr)
end
|
ruby
|
{
"resource": ""
}
|
q1641
|
Hawkular::Operations.Client.invoke_specific_operation
|
train
|
def invoke_specific_operation(operation_payload, operation_name, &callback)
fail Hawkular::ArgumentError, 'Operation must be specified' if operation_name.nil?
required = %i[resourceId feedId]
check_pre_conditions operation_payload, required, &callback
invoke_operation_helper(operation_payload, operation_name, &callback)
end
|
ruby
|
{
"resource": ""
}
|
q1642
|
Hawkular::Operations.Client.add_deployment
|
train
|
def add_deployment(hash, &callback)
hash[:enabled] = hash.key?(:enabled) ? hash[:enabled] : true
hash[:force_deploy] = hash.key?(:force_deploy) ? hash[:force_deploy] : false
required = %i[resource_id feed_id destination_file_name binary_content]
check_pre_conditions hash, required, &callback
operation_payload = prepare_payload_hash([:binary_content], hash)
invoke_operation_helper(operation_payload, 'DeployApplication', hash[:binary_content], &callback)
end
|
ruby
|
{
"resource": ""
}
|
q1643
|
Hawkular::Operations.Client.undeploy
|
train
|
def undeploy(hash, &callback)
hash[:remove_content] = hash.key?(:remove_content) ? hash[:remove_content] : true
required = %i[resource_id feed_id deployment_name]
check_pre_conditions hash, required, &callback
hash[:destination_file_name] = hash[:deployment_name]
operation_payload = prepare_payload_hash([:deployment_name], hash)
invoke_operation_helper(operation_payload, 'UndeployApplication', &callback)
end
|
ruby
|
{
"resource": ""
}
|
q1644
|
Hawkular::Operations.Client.enable_deployment
|
train
|
def enable_deployment(hash, &callback)
required = %i[resource_id feed_id deployment_name]
check_pre_conditions hash, required, &callback
hash[:destination_file_name] = hash[:deployment_name]
operation_payload = prepare_payload_hash([:deployment_name], hash)
invoke_operation_helper(operation_payload, 'EnableApplication', &callback)
end
|
ruby
|
{
"resource": ""
}
|
q1645
|
Hawkular::Operations.Client.export_jdr
|
train
|
def export_jdr(resource_id, feed_id, delete_immediately = false, sender_request_id = nil, &callback)
fail Hawkular::ArgumentError, 'resource_id must be specified' if resource_id.nil?
fail Hawkular::ArgumentError, 'feed_id must be specified' if feed_id.nil?
check_pre_conditions(&callback)
invoke_specific_operation({ resourceId: resource_id,
feedId: feed_id,
deleteImmediately: delete_immediately,
senderRequestId: sender_request_id },
'ExportJdr', &callback)
end
|
ruby
|
{
"resource": ""
}
|
q1646
|
Hawkular::Operations.Client.update_collection_intervals
|
train
|
def update_collection_intervals(hash, &callback)
required = %i[resourceId feedId metricTypes availTypes]
check_pre_conditions hash, required, &callback
invoke_specific_operation(hash, 'UpdateCollectionIntervals', &callback)
end
|
ruby
|
{
"resource": ""
}
|
q1647
|
Geometry.Polyline.close!
|
train
|
def close!
unless @edges.empty?
# NOTE: parallel? is use here instead of collinear? because the
# edges are connected, and will therefore be collinear if
# they're parallel
if closed?
if @edges.first.parallel?(@edges.last)
unshift_edge Edge.new(@edges.last.first, shift_edge.last)
end
elsif
closing_edge = Edge.new(@edges.last.last, @edges.first.first)
# If the closing edge is collinear with the last edge, then
# simply extened the last edge to fill the gap
if @edges.last.parallel?(closing_edge)
closing_edge = Edge.new(pop_edge.first, @edges.first.first)
end
# Check that the new closing_edge isn't zero-length
if closing_edge.first != closing_edge.last
# If the closing edge is collinear with the first edge, then
# extend the first edge "backwards" to fill the gap
if @edges.first.parallel?(closing_edge)
unshift_edge Edge.new(closing_edge.first, shift_edge.last)
else
push_edge closing_edge
end
end
end
end
self
end
|
ruby
|
{
"resource": ""
}
|
q1648
|
Geometry.Polyline.bisector_map
|
train
|
def bisector_map
winding = 0
tangent_loop.each_cons(2).map do |v1,v2|
k = v1[0]*v2[1] - v1[1]*v2[0] # z-component of v1 x v2
winding += k
if v1 == v2 # collinear, same direction?
bisector = Vector[-v1[1], v1[0]]
block_given? ? (bisector * yield(bisector, 1)) : bisector
elsif 0 == k # collinear, reverse direction
nil
else
bisector_y = (v2[1] - v1[1])/k
# If v1 or v2 happens to be horizontal, then the other one must be used when calculating
# the x-component of the bisector (to avoid a divide by zero). But, comparing floats
# with zero is problematic, so use the one with the largest y-component instead checking
# for a y-component equal to zero.
v = (v2[1].abs > v1[1].abs) ? v2 : v1
bisector = Vector[(v[0]*bisector_y - 1)/v[1], bisector_y]
block_given? ? (bisector * yield(bisector, k)) : bisector
end
end
end
|
ruby
|
{
"resource": ""
}
|
q1649
|
Geometry.Polyline.tangent_loop
|
train
|
def tangent_loop
edges.map {|e| e.direction }.tap do |tangents|
# Generating a bisector for each vertex requires an edge on both sides of each vertex.
# Obviously, the first and last vertices each have only a single adjacent edge, unless the
# Polyline happens to be closed (like a Polygon). When not closed, duplicate the
# first and last direction vectors to fake the adjacent edges. This causes the first and last
# edges to have bisectors that are perpendicular to themselves.
if closed?
# Prepend the last direction vector so that the last edge can be used to find the bisector for the first vertex
tangents.unshift tangents.last
else
# Duplicate the first and last direction vectors to compensate for not having edges adjacent to the first and last vertices
tangents.unshift(tangents.first)
tangents.push(tangents.last)
end
end
end
|
ruby
|
{
"resource": ""
}
|
q1650
|
Geometry.Polyline.find_next_intersection
|
train
|
def find_next_intersection(edges, i, e)
for j in i..(edges.count-1)
e2 = edges[j][:edge]
next if !e2 || e.connected?(e2)
intersection = e.intersection(e2)
return [intersection, j] if intersection
end
nil
end
|
ruby
|
{
"resource": ""
}
|
q1651
|
Geometry.Polyline.find_last_intersection
|
train
|
def find_last_intersection(edges, i, e)
intersection, intersection_at = nil, nil
for j in i..(edges.count-1)
e2 = edges[j][:edge]
next if !e2 || e.connected?(e2)
_intersection = e.intersection(e2)
intersection, intersection_at = _intersection, j if _intersection
end
[intersection, intersection_at]
end
|
ruby
|
{
"resource": ""
}
|
q1652
|
CZTop.Config.[]
|
train
|
def [](path, default = "")
ptr = ffi_delegate.get(path, default)
return nil if ptr.null?
ptr.read_string
end
|
ruby
|
{
"resource": ""
}
|
q1653
|
XMLRPC.Create.methodResponse
|
train
|
def methodResponse(is_ret, *params)
if is_ret
resp = params.collect do |param|
@writer.ele("param", conv2value(param))
end
resp = [@writer.ele("params", *resp)]
else
if params.size != 1 or params[0] === XMLRPC::FaultException
raise ArgumentError, "no valid fault-structure given"
end
resp = @writer.ele("fault", conv2value(params[0].to_h))
end
tree = @writer.document(
@writer.pi("xml", 'version="1.0"'),
@writer.ele("methodResponse", resp)
)
@writer.document_to_str(tree) + "\n"
end
|
ruby
|
{
"resource": ""
}
|
q1654
|
SM.LineCollection.add_list_start_and_ends
|
train
|
def add_list_start_and_ends
level = 0
res = []
type_stack = []
@fragments.each do |fragment|
# $stderr.puts "#{level} : #{fragment.class.name} : #{fragment.level}"
new_level = fragment.level
while (level < new_level)
level += 1
type = fragment.type
res << ListStart.new(level, fragment.param, type) if type
type_stack.push type
# $stderr.puts "Start: #{level}"
end
while level > new_level
type = type_stack.pop
res << ListEnd.new(level, type) if type
level -= 1
# $stderr.puts "End: #{level}, #{type}"
end
res << fragment
level = fragment.level
end
level.downto(1) do |i|
type = type_stack.pop
res << ListEnd.new(i, type) if type
end
@fragments = res
end
|
ruby
|
{
"resource": ""
}
|
q1655
|
Rake.PackageTask.init
|
train
|
def init(name, version)
@name = name
@version = version
@package_files = Rake::FileList.new
@package_dir = 'pkg'
@need_tar = false
@need_tar_gz = false
@need_tar_bz2 = false
@need_zip = false
@tar_command = 'tar'
@zip_command = 'zip'
end
|
ruby
|
{
"resource": ""
}
|
q1656
|
ESX.Host.create_vm
|
train
|
def create_vm(specification)
spec = specification
spec[:cpus] = (specification[:cpus] || 1).to_i
spec[:cpu_cores] = (specification[:cpu_cores] || 1).to_i
spec[:guest_id] = specification[:guest_id] || 'otherGuest'
spec[:hw_version] = (specification[:hw_version] || 8).to_i
if specification[:disk_size]
spec[:disk_size] = (specification[:disk_size].to_i * 1024)
else
spec[:disk_size] = 4194304
end
spec[:memory] = (specification[:memory] || 128).to_i
if specification[:datastore]
spec[:datastore] = "[#{specification[:datastore]}]"
else
spec[:datastore] = '[datastore1]'
end
vm_cfg = {
:name => spec[:vm_name],
:guestId => spec[:guest_id],
:files => { :vmPathName => spec[:datastore] },
:numCPUs => spec[:cpus],
:numCoresPerSocket => spec[:cpu_cores],
:memoryMB => spec[:memory],
:deviceChange => [
{
:operation => :add,
:device => RbVmomi::VIM.VirtualLsiLogicController(
:key => 1000,
:busNumber => 0,
:sharedBus => :noSharing)
}
],
:version => 'vmx-'+spec[:hw_version].to_s.rjust(2,'0'),
:extraConfig => [
{
:key => 'bios.bootOrder',
:value => 'ethernet0'
}
]
}
#Add multiple nics
nics_count = 0
if spec[:nics]
spec[:nics].each do |nic_spec|
vm_cfg[:deviceChange].push(
{
:operation => :add,
:device => RbVmomi::VIM.VirtualE1000(create_net_dev(nics_count, nic_spec))
}
)
nics_count += 1
end
end
# VMDK provided, replace the empty vmdk
vm_cfg[:deviceChange].push(create_disk_spec(:disk_file => spec[:disk_file],
:disk_type => spec[:disk_type],
:disk_size => spec[:disk_size],
:datastore => spec[:datastore]))
unless @free_license
VM.wrap(@_datacenter.vmFolder.CreateVM_Task(:config => vm_cfg, :pool => @_datacenter.hostFolder.children.first.resourcePool).wait_for_completion,self)
else
gem_root = Gem::Specification.find_by_name("esx").gem_dir
template_path = File.join(gem_root, 'templates', 'vmx_template.erb')
spec[:guest_id] = convert_guest_id_for_vmdk(spec[:guest_id])
erb = ERB.new File.read(template_path)
vmx = erb.result binding
tmp_vmx = Tempfile.new 'vmx'
tmp_vmx.write vmx
tmp_vmx.close
ds = spec[:datastore]||'datastore1'
ds = ds.gsub('[','').gsub(']','')
vmx_path = "/vmfs/volumes/#{ds}/#{spec[:vm_name]}/#{spec[:vm_name]}.vmx"
remote_command "mkdir -p #{File.dirname(vmx_path)}"
upload_file tmp_vmx.path, vmx_path
remote_command "vim-cmd solo/registervm #{vmx_path}"
VM.wrap(@_datacenter.find_vm(spec[:vm_name]),self)
end
end
|
ruby
|
{
"resource": ""
}
|
q1657
|
ESX.Host.host_info
|
train
|
def host_info
[
@_host.summary.config.product.fullName,
@_host.summary.config.product.apiType,
@_host.summary.config.product.apiVersion,
@_host.summary.config.product.osType,
@_host.summary.config.product.productLineId,
@_host.summary.config.product.vendor,
@_host.summary.config.product.version
]
end
|
ruby
|
{
"resource": ""
}
|
q1658
|
ESX.Host.remote_command
|
train
|
def remote_command(cmd)
output = ""
Net::SSH.start(@address, @user, :password => @password) do |ssh|
output = ssh.exec! cmd
end
output
end
|
ruby
|
{
"resource": ""
}
|
q1659
|
ESX.Host.copy_from_template
|
train
|
def copy_from_template(template_disk, destination)
Log.debug "Copying from template #{template_disk} to #{destination}"
raise "Template does not exist" if not template_exist?(template_disk)
source = File.join(@templates_dir, File.basename(template_disk))
Net::SSH.start(@address, @user, :password => @password) do |ssh|
Log.debug "Clone disk #{source} to #{destination}"
Log.debug ssh.exec!("vmkfstools -i #{source} --diskformat thin #{destination} 2>&1")
end
end
|
ruby
|
{
"resource": ""
}
|
q1660
|
ESX.Host.import_disk
|
train
|
def import_disk(source, destination, print_progress = false, params = {})
use_template = params[:use_template] || false
if use_template
Log.debug "import_disk :use_template => true"
if !template_exist?(source)
Log.debug "import_disk, template does not exist, importing."
import_template(source, { :print_progress => print_progress })
end
copy_from_template(source, destination)
else
import_disk_convert source, destination, print_progress
end
end
|
ruby
|
{
"resource": ""
}
|
q1661
|
ESX.Host.import_disk_convert
|
train
|
def import_disk_convert(source, destination, print_progress = false)
tmp_dest = destination + ".tmp"
Net::SSH.start(@address, @user, :password => @password) do |ssh|
if not (ssh.exec! "ls #{destination} 2>/dev/null").nil?
raise Exception.new("Destination file #{destination} already exists")
end
Log.info "Uploading file... (#{File.basename(source)})" if print_progress
ssh.scp.upload!(source, tmp_dest) do |ch, name, sent, total|
if print_progress
print "\rProgress: #{(sent.to_f * 100 / total.to_f).to_i}%"
end
end
if print_progress
Log.info "Converting disk..."
ssh.exec "vmkfstools -i #{tmp_dest} --diskformat thin #{destination}; rm -f #{tmp_dest}"
else
ssh.exec "vmkfstools -i #{tmp_dest} --diskformat thin #{destination} >/dev/null 2>&1; rm -f #{tmp_dest}"
end
end
end
|
ruby
|
{
"resource": ""
}
|
q1662
|
ESX.Host.create_disk_spec
|
train
|
def create_disk_spec(params)
disk_type = params[:disk_type] || :flat
disk_file = params[:disk_file]
if disk_type == :sparse and disk_file.nil?
raise Exception.new("Creating sparse disks in ESX is not supported. Use an existing image.")
end
disk_size = params[:disk_size]
datastore = params[:datastore]
datastore = datastore + " #{disk_file}" if not disk_file.nil?
spec = {}
if disk_type == :sparse
spec = {
:operation => :add,
:device => RbVmomi::VIM.VirtualDisk(
:key => 0,
:backing => RbVmomi::VIM.VirtualDiskSparseVer2BackingInfo(
:fileName => datastore,
:diskMode => :persistent),
:controllerKey => 1000,
:unitNumber => 0,
:capacityInKB => disk_size)
}
else
spec = {
:operation => :add,
:device => RbVmomi::VIM.VirtualDisk(
:key => 0,
:backing => RbVmomi::VIM.VirtualDiskFlatVer2BackingInfo(
:fileName => datastore,
:diskMode => :persistent),
:controllerKey => 1000,
:unitNumber => 0,
:capacityInKB => disk_size)
}
end
spec[:fileOperation] = :create if disk_file.nil?
spec
end
|
ruby
|
{
"resource": ""
}
|
q1663
|
ESX.VM.destroy
|
train
|
def destroy
#disks = vm_object.config.hardware.device.grep(RbVmomi::VIM::VirtualDisk)
unless host.free_license
vm_object.Destroy_Task.wait_for_completion
else
host.remote_command "vim-cmd vmsvc/power.off #{vmid}"
host.remote_command "vim-cmd vmsvc/destroy #{vmid}"
end
end
|
ruby
|
{
"resource": ""
}
|
q1664
|
RI.AttributeFormatter.write_attribute_text
|
train
|
def write_attribute_text(prefix, line)
print prefix
line.each do |achar|
print achar.char
end
puts
end
|
ruby
|
{
"resource": ""
}
|
q1665
|
RI.OverstrikeFormatter.bold_print
|
train
|
def bold_print(text)
text.split(//).each do |ch|
print ch, BS, ch
end
end
|
ruby
|
{
"resource": ""
}
|
q1666
|
RI.SimpleFormatter.display_heading
|
train
|
def display_heading(text, level, indent)
text = strip_attributes(text)
case level
when 1
puts "= " + text.upcase
when 2
puts "-- " + text
else
print indent, text, "\n"
end
end
|
ruby
|
{
"resource": ""
}
|
q1667
|
Rack.Request.POST
|
train
|
def POST
if @env["rack.request.form_input"].eql? @env["rack.input"]
@env["rack.request.form_hash"]
elsif form_data? || parseable_data?
@env["rack.request.form_input"] = @env["rack.input"]
unless @env["rack.request.form_hash"] =
Utils::Multipart.parse_multipart(env)
form_vars = @env["rack.input"].read
# Fix for Safari Ajax postings that always append \0
form_vars.sub!(/\0\z/, '')
@env["rack.request.form_vars"] = form_vars
@env["rack.request.form_hash"] = Utils.parse_nested_query(form_vars)
@env["rack.input"].rewind
end
@env["rack.request.form_hash"]
else
{}
end
end
|
ruby
|
{
"resource": ""
}
|
q1668
|
Rack.Request.url
|
train
|
def url
url = scheme + "://"
url << host
if scheme == "https" && port != 443 ||
scheme == "http" && port != 80
url << ":#{port}"
end
url << fullpath
url
end
|
ruby
|
{
"resource": ""
}
|
q1669
|
DRb.DRbProtocol.open
|
train
|
def open(uri, config, first=true)
@protocol.each do |prot|
begin
return prot.open(uri, config)
rescue DRbBadScheme
rescue DRbConnError
raise($!)
rescue
raise(DRbConnError, "#{uri} - #{$!.inspect}")
end
end
if first && (config[:auto_load] != false)
auto_load(uri, config)
return open(uri, config, false)
end
raise DRbBadURI, 'can\'t parse uri:' + uri
end
|
ruby
|
{
"resource": ""
}
|
q1670
|
DRb.DRbProtocol.open_server
|
train
|
def open_server(uri, config, first=true)
@protocol.each do |prot|
begin
return prot.open_server(uri, config)
rescue DRbBadScheme
end
end
if first && (config[:auto_load] != false)
auto_load(uri, config)
return open_server(uri, config, false)
end
raise DRbBadURI, 'can\'t parse uri:' + uri
end
|
ruby
|
{
"resource": ""
}
|
q1671
|
DRb.DRbTCPSocket.send_request
|
train
|
def send_request(ref, msg_id, arg, b)
@msg.send_request(stream, ref, msg_id, arg, b)
end
|
ruby
|
{
"resource": ""
}
|
q1672
|
DRb.DRbObject.method_missing
|
train
|
def method_missing(msg_id, *a, &b)
if DRb.here?(@uri)
obj = DRb.to_obj(@ref)
DRb.current_server.check_insecure_method(obj, msg_id)
return obj.__send__(msg_id, *a, &b)
end
succ, result = self.class.with_friend(@uri) do
DRbConn.open(@uri) do |conn|
conn.send_message(self, msg_id, a, b)
end
end
if succ
return result
elsif DRbUnknown === result
raise result
else
bt = self.class.prepare_backtrace(@uri, result)
result.set_backtrace(bt + caller)
raise result
end
end
|
ruby
|
{
"resource": ""
}
|
q1673
|
DRb.DRbServer.stop_service
|
train
|
def stop_service
DRb.remove_server(self)
if Thread.current['DRb'] && Thread.current['DRb']['server'] == self
Thread.current['DRb']['stop_service'] = true
else
@thread.kill
end
end
|
ruby
|
{
"resource": ""
}
|
q1674
|
DRb.DRbServer.to_obj
|
train
|
def to_obj(ref)
return front if ref.nil?
return front[ref.to_s] if DRbURIOption === ref
@idconv.to_obj(ref)
end
|
ruby
|
{
"resource": ""
}
|
q1675
|
DRb.DRbServer.check_insecure_method
|
train
|
def check_insecure_method(obj, msg_id)
return true if Proc === obj && msg_id == :__drb_yield
raise(ArgumentError, "#{any_to_s(msg_id)} is not a symbol") unless Symbol == msg_id.class
raise(SecurityError, "insecure method `#{msg_id}'") if insecure_method?(msg_id)
if obj.private_methods.include?(msg_id.to_s)
desc = any_to_s(obj)
raise NoMethodError, "private method `#{msg_id}' called for #{desc}"
elsif obj.protected_methods.include?(msg_id.to_s)
desc = any_to_s(obj)
raise NoMethodError, "protected method `#{msg_id}' called for #{desc}"
else
true
end
end
|
ruby
|
{
"resource": ""
}
|
q1676
|
DRb.DRbServer.main_loop
|
train
|
def main_loop
Thread.start(@protocol.accept) do |client|
@grp.add Thread.current
Thread.current['DRb'] = { 'client' => client ,
'server' => self }
loop do
begin
succ = false
invoke_method = InvokeMethod.new(self, client)
succ, result = invoke_method.perform
if !succ && verbose
p result
result.backtrace.each do |x|
puts x
end
end
client.send_reply(succ, result) rescue nil
ensure
client.close unless succ
if Thread.current['DRb']['stop_service']
Thread.new { stop_service }
end
break unless succ
end
end
end
end
|
ruby
|
{
"resource": ""
}
|
q1677
|
::JdbcSpec.PostgreSQL.supports_standard_conforming_strings?
|
train
|
def supports_standard_conforming_strings?
# Temporarily set the client message level above error to prevent unintentional
# error messages in the logs when working on a PostgreSQL database server that
# does not support standard conforming strings.
client_min_messages_old = client_min_messages
self.client_min_messages = 'panic'
# postgres-pr does not raise an exception when client_min_messages is set higher
# than error and "SHOW standard_conforming_strings" fails, but returns an empty
# PGresult instead.
has_support = select('SHOW standard_conforming_strings').to_a[0][0] rescue false
self.client_min_messages = client_min_messages_old
has_support
end
|
ruby
|
{
"resource": ""
}
|
q1678
|
Rake.RDocTask.define
|
train
|
def define
if rdoc_task_name != "rdoc"
desc "Build the RDOC HTML Files"
else
desc "Build the #{rdoc_task_name} HTML Files"
end
task rdoc_task_name
desc "Force a rebuild of the RDOC files"
task rerdoc_task_name => [clobber_task_name, rdoc_task_name]
desc "Remove rdoc products"
task clobber_task_name do
rm_r rdoc_dir rescue nil
end
task :clobber => [clobber_task_name]
directory @rdoc_dir
task rdoc_task_name => [rdoc_target]
file rdoc_target => @rdoc_files + [Rake.application.rakefile] do
rm_r @rdoc_dir rescue nil
@before_running_rdoc.call if @before_running_rdoc
args = option_list + @rdoc_files
if @external
argstring = args.join(' ')
sh %{ruby -Ivendor vendor/rd #{argstring}}
else
require 'rdoc/rdoc'
RDoc::RDoc.new.document(args)
end
end
self
end
|
ruby
|
{
"resource": ""
}
|
q1679
|
RUNIT.Assert.assert_match
|
train
|
def assert_match(actual_string, expected_re, message="")
_wrap_assertion {
full_message = build_message(message, "Expected <?> to match <?>", actual_string, expected_re)
assert_block(full_message) {
expected_re =~ actual_string
}
Regexp.last_match
}
end
|
ruby
|
{
"resource": ""
}
|
q1680
|
Rake.GemPackageTask.init
|
train
|
def init(gem)
super(gem.name, gem.version)
@gem_spec = gem
@package_files += gem_spec.files if gem_spec.files
end
|
ruby
|
{
"resource": ""
}
|
q1681
|
ActiveSupport.XmlMini_REXML.parse
|
train
|
def parse(string)
require 'rexml/document' unless defined?(REXML::Document)
doc = REXML::Document.new(string)
merge_element!({}, doc.root)
end
|
ruby
|
{
"resource": ""
}
|
q1682
|
SM.ToHtml.init_tags
|
train
|
def init_tags
@attr_tags = [
InlineTag.new(SM::Attribute.bitmap_for(:BOLD), "<b>", "</b>"),
InlineTag.new(SM::Attribute.bitmap_for(:TT), "<tt>", "</tt>"),
InlineTag.new(SM::Attribute.bitmap_for(:EM), "<em>", "</em>"),
]
end
|
ruby
|
{
"resource": ""
}
|
q1683
|
SM.ToHtml.add_tag
|
train
|
def add_tag(name, start, stop)
@attr_tags << InlineTag.new(SM::Attribute.bitmap_for(name), start, stop)
end
|
ruby
|
{
"resource": ""
}
|
q1684
|
Net.HTTPHeader.set_form_data
|
train
|
def set_form_data(params, sep = '&')
self.body = params.map {|k,v| "#{urlencode(k.to_s)}=#{urlencode(v.to_s)}" }.join(sep)
self.content_type = 'application/x-www-form-urlencoded'
end
|
ruby
|
{
"resource": ""
}
|
q1685
|
Rinda.Tuple.each
|
train
|
def each # FIXME
if Hash === @tuple
@tuple.each { |k, v| yield(k, v) }
else
@tuple.each_with_index { |v, k| yield(k, v) }
end
end
|
ruby
|
{
"resource": ""
}
|
q1686
|
Rinda.Tuple.init_with_ary
|
train
|
def init_with_ary(ary)
@tuple = Array.new(ary.size)
@tuple.size.times do |i|
@tuple[i] = ary[i]
end
end
|
ruby
|
{
"resource": ""
}
|
q1687
|
Rinda.Tuple.init_with_hash
|
train
|
def init_with_hash(hash)
@tuple = Hash.new
hash.each do |k, v|
raise InvalidHashTupleKey unless String === k
@tuple[k] = v
end
end
|
ruby
|
{
"resource": ""
}
|
q1688
|
XSD.XSDFloat.narrow32bit
|
train
|
def narrow32bit(f)
if f.nan? || f.infinite?
f
elsif f.abs < MIN_POSITIVE_SINGLE
XSDFloat.positive?(f) ? POSITIVE_ZERO : NEGATIVE_ZERO
else
f
end
end
|
ruby
|
{
"resource": ""
}
|
q1689
|
XSD.XSDHexBinary.set_encoded
|
train
|
def set_encoded(value)
if /^[0-9a-fA-F]*$/ !~ value
raise ValueSpaceError.new("#{ type }: cannot accept '#{ value }'.")
end
@data = String.new(value).strip
@is_nil = false
end
|
ruby
|
{
"resource": ""
}
|
q1690
|
ActiveSupport.Rescuable.rescue_with_handler
|
train
|
def rescue_with_handler(exception)
if handler = handler_for_rescue(exception)
handler.arity != 0 ? handler.call(exception) : handler.call
true # don't rely on the return value of the handler
end
end
|
ruby
|
{
"resource": ""
}
|
q1691
|
SM.PreProcess.handle
|
train
|
def handle(text)
text.gsub!(/^([ \t#]*):(\w+):\s*(.+)?\n/) do
prefix = $1
directive = $2.downcase
param = $3
case directive
when "include"
filename = param.split[0]
include_file(filename, prefix)
else
yield(directive, param)
end
end
end
|
ruby
|
{
"resource": ""
}
|
q1692
|
SM.PreProcess.include_file
|
train
|
def include_file(name, indent)
if (full_name = find_include_file(name))
content = File.open(full_name) {|f| f.read}
# strip leading '#'s, but only if all lines start with them
if content =~ /^[^#]/
content.gsub(/^/, indent)
else
content.gsub(/^#?/, indent)
end
else
$stderr.puts "Couldn't find file to include: '#{name}'"
''
end
end
|
ruby
|
{
"resource": ""
}
|
q1693
|
SM.PreProcess.find_include_file
|
train
|
def find_include_file(name)
to_search = [ File.dirname(@input_file_name) ].concat @include_path
to_search.each do |dir|
full_name = File.join(dir, name)
stat = File.stat(full_name) rescue next
return full_name if stat.readable?
end
nil
end
|
ruby
|
{
"resource": ""
}
|
q1694
|
RDoc.Fortran95parser.parse_subprogram
|
train
|
def parse_subprogram(subprogram, params, comment, code,
before_contains=nil, function=nil, prefix=nil)
subprogram.singleton = false
prefix = "" if !prefix
arguments = params.sub(/\(/, "").sub(/\)/, "").split(",") if params
args_comment, params_opt =
find_arguments(arguments, code.sub(/^s*?contains\s*?(!.*?)?$.*/im, ""),
nil, nil, true)
params_opt = "( " + params_opt + " ) " if params_opt
subprogram.params = params_opt || ""
namelist_comment = find_namelists(code, before_contains)
block_comment = find_comments comment
if function
subprogram.comment = "<b><em> Function </em></b> :: <em>#{prefix}</em>\n"
else
subprogram.comment = "<b><em> Subroutine </em></b> :: <em>#{prefix}</em>\n"
end
subprogram.comment << args_comment if args_comment
subprogram.comment << block_comment if block_comment
subprogram.comment << namelist_comment if namelist_comment
# For output source code
subprogram.start_collecting_tokens
subprogram.add_token Token.new(1,1).set_text(code)
subprogram
end
|
ruby
|
{
"resource": ""
}
|
q1695
|
RDoc.Fortran95parser.collect_first_comment
|
train
|
def collect_first_comment(body)
comment = ""
not_comment = ""
comment_start = false
comment_end = false
body.split("\n").each{ |line|
if comment_end
not_comment << line
not_comment << "\n"
elsif /^\s*?!\s?(.*)$/i =~ line
comment_start = true
comment << $1
comment << "\n"
elsif /^\s*?$/i =~ line
comment_end = true if comment_start && COMMENTS_ARE_UPPER
else
comment_end = true
not_comment << line
not_comment << "\n"
end
}
return comment, not_comment
end
|
ruby
|
{
"resource": ""
}
|
q1696
|
RDoc.Fortran95parser.find_namelists
|
train
|
def find_namelists(text, before_contains=nil)
return nil if !text
result = ""
lines = "#{text}"
before_contains = "" if !before_contains
while lines =~ /^\s*?namelist\s+\/\s*?(\w+)\s*?\/([\s\w\,]+)$/i
lines = $~.post_match
nml_comment = COMMENTS_ARE_UPPER ?
find_comments($~.pre_match) : find_comments($~.post_match)
nml_name = $1
nml_args = $2.split(",")
result << "\n\n=== NAMELIST <tt><b>" + nml_name + "</tt></b>\n\n"
result << nml_comment + "\n" if nml_comment
if lines.split("\n")[0] =~ /^\//i
lines = "namelist " + lines
end
result << find_arguments(nml_args, "#{text}" + "\n" + before_contains)
end
return result
end
|
ruby
|
{
"resource": ""
}
|
q1697
|
RDoc.Fortran95parser.find_comments
|
train
|
def find_comments text
return "" unless text
lines = text.split("\n")
lines.reverse! if COMMENTS_ARE_UPPER
comment_block = Array.new
lines.each do |line|
break if line =~ /^\s*?\w/ || line =~ /^\s*?$/
if COMMENTS_ARE_UPPER
comment_block.unshift line.sub(/^\s*?!\s?/,"")
else
comment_block.push line.sub(/^\s*?!\s?/,"")
end
end
nice_lines = comment_block.join("\n").split "\n\s*?\n"
nice_lines[0] ||= ""
nice_lines.shift
end
|
ruby
|
{
"resource": ""
}
|
q1698
|
RDoc.Fortran95parser.initialize_public_method
|
train
|
def initialize_public_method(method, parent)
return if !method || !parent
new_meth = AnyMethod.new("External Alias for module", method.name)
new_meth.singleton = method.singleton
new_meth.params = method.params.clone
new_meth.comment = remove_trailing_alias(method.comment.clone)
new_meth.comment << "\n\n#{EXTERNAL_ALIAS_MES} #{parent.strip.chomp}\##{method.name}"
return new_meth
end
|
ruby
|
{
"resource": ""
}
|
q1699
|
RDoc.Fortran95parser.initialize_external_method
|
train
|
def initialize_external_method(new, old, params, file, comment, token=nil,
internal=nil, nolink=nil)
return nil unless new || old
if internal
external_alias_header = "#{INTERNAL_ALIAS_MES} "
external_alias_text = external_alias_header + old
elsif file
external_alias_header = "#{EXTERNAL_ALIAS_MES} "
external_alias_text = external_alias_header + file + "#" + old
else
return nil
end
external_meth = AnyMethod.new(external_alias_text, new)
external_meth.singleton = false
external_meth.params = params
external_comment = remove_trailing_alias(comment) + "\n\n" if comment
external_meth.comment = external_comment || ""
if nolink && token
external_meth.start_collecting_tokens
external_meth.add_token Token.new(1,1).set_text(token)
else
external_meth.comment << external_alias_text
end
return external_meth
end
|
ruby
|
{
"resource": ""
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.