_id stringlengths 2 6 | title stringlengths 9 130 | partition stringclasses 3
values | text stringlengths 66 10.5k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q17900 | OoxmlParser.DocxShapeProperties.parse | train | def parse(node)
@fill_color = DocxColor.new(parent: self).parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'xfrm'
@shape_size = DocxShapeSize.new(parent: self).parse(node_child)
when 'prstGeom'
@preset_geometry = PresetGeometry.new(parent... | ruby | {
"resource": ""
} |
q17901 | OoxmlParser.ColorProperties.parse | train | def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'alpha'
@alpha = (node_child.attribute('val').value.to_f / 1_000.0).round
when 'lumMod'
@luminance_modulation = node_child.attribute('val').value.to_f / 100_000.0
when 'lumOff'
... | ruby | {
"resource": ""
} |
q17902 | OoxmlParser.DocxShapeLine.parse | train | def parse(node)
node.attributes.each do |key, value|
case key
when 'w'
@width = OoxmlSize.new(value.value.to_f, :emu)
when 'cap'
@cap = value_to_symbol(value)
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'so... | ruby | {
"resource": ""
} |
q17903 | OoxmlParser.TableProperties.parse | train | def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'tableStyleId'
@table_style_id = node_child.text
when 'tblBorders'
@table_borders = TableBorders.new(parent: self).parse(node_child)
when 'tblStyle'
# TODO: Incorrect but to... | ruby | {
"resource": ""
} |
q17904 | OoxmlParser.CommonSlideData.parse | train | def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'spTree'
@shape_tree = ShapeTree.new(parent: self).parse(node_child)
when 'bg'
@background = Background.new(parent: self).parse(node_child)
end
end
self
end | ruby | {
"resource": ""
} |
q17905 | OoxmlParser.TableCellLine.parse | train | def parse(node)
@fill = PresentationFill.new(parent: self).parse(node)
@line_join = LineJoin.new(parent: self).parse(node)
node.attributes.each do |key, value|
case key
when 'w'
@width = OoxmlSize.new(value.value.to_f, :emu)
when 'algn'
@align = value_to_sym... | ruby | {
"resource": ""
} |
q17906 | OoxmlParser.DocxShape.parse | train | def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'nvSpPr'
@non_visual_properties = NonVisualShapeProperties.new(parent: self).parse(node_child)
when 'spPr'
@properties = DocxShapeProperties.new(parent: self).parse(node_child)
when '... | ruby | {
"resource": ""
} |
q17907 | OoxmlParser.SDTContent.parse | train | def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'p'
@elements << DocxParagraph.new(parent: self).parse(node_child)
when 'r'
@elements << ParagraphRun.new(parent: self).parse(node_child)
when 'tbl'
@elements << Table.new(p... | ruby | {
"resource": ""
} |
q17908 | OoxmlParser.CommonTiming.parse | train | def parse(node)
node.attributes.each do |key, value|
case key
when 'dur'
@duration = value.value
when 'restart'
@restart = value.value
when 'id'
@id = value.value
end
end
node.xpath('*').each do |node_child|
case node_child... | ruby | {
"resource": ""
} |
q17909 | OoxmlParser.OOXMLCustomGeometry.parse | train | def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'pathLst'
node_child.xpath('a:path', 'xmlns:a' => 'http://schemas.openxmlformats.org/drawingml/2006/main').each do |path_node|
@paths_list << DocxShapeLinePath.new(parent: self).parse(path_node)
... | ruby | {
"resource": ""
} |
q17910 | OoxmlParser.OldDocxPicture.parse | train | def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'shape'
@type = :shape
@data = OldDocxShape.new(parent: self).parse(node_child)
when 'group'
@type = :group
@data = OldDocxGroup.new(parent: self).parse(node_child)
... | ruby | {
"resource": ""
} |
q17911 | OoxmlParser.DocxFormula.parse | train | def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'r'
@formula_run << MathRun.new(parent: self).parse(node_child)
when 'box', 'borderBox'
@formula_run << Box.new(parent: self).parse(node_child)
when 'func'
@formula_run << F... | ruby | {
"resource": ""
} |
q17912 | OoxmlParser.NonVisualShapeProperties.parse | train | def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'cNvPr'
@common_properties = CommonNonVisualProperties.new(parent: self).parse(node_child)
when 'nvPr'
@non_visual_properties = NonVisualProperties.new(parent: self).parse(node_child)
... | ruby | {
"resource": ""
} |
q17913 | OoxmlParser.XlsxColumnProperties.parse | train | def parse(node)
node.attributes.each do |key, value|
case key
when 'min'
@from = value.value.to_i
when 'max'
@to = value.value.to_i
when 'style'
@style = root_object.style_sheet.cell_xfs.xf_array[value.value.to_i]
when 'width'
@width ... | ruby | {
"resource": ""
} |
q17914 | OoxmlParser.OOXMLTextBox.parse | train | def parse(node)
text_box_content_node = node.xpath('w:txbxContent').first
text_box_content_node.xpath('*').each_with_index do |node_child, index|
case node_child.name
when 'p'
@elements << DocxParagraph.new(parent: self).parse(node_child, index)
when 'tbl'
@elemen... | ruby | {
"resource": ""
} |
q17915 | OoxmlParser.DocumentStyleHelper.document_style_by_name | train | def document_style_by_name(name)
root_object.document_styles.each do |style|
return style if style.name == name
end
nil
end | ruby | {
"resource": ""
} |
q17916 | OoxmlParser.DocumentStyleHelper.document_style_by_id | train | def document_style_by_id(id)
root_object.document_styles.each do |style|
return style if style.style_id == id
end
nil
end | ruby | {
"resource": ""
} |
q17917 | OoxmlParser.Box.parse | train | def parse(node)
@borders = true if node.name == 'borderBox'
@element = MathRun.new(parent: self).parse(node)
self
end | ruby | {
"resource": ""
} |
q17918 | OoxmlParser.ImageFill.parse | train | def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'blip'
@file_reference = FileReference.new(parent: self).parse(node_child)
when 'tile'
@tile = Tile.new(OOXMLCoordinates.parse(node_child, x_attr: 'tx', y_attr: 'ty'),
... | ruby | {
"resource": ""
} |
q17919 | OoxmlParser.Timing.parse | train | def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'tnLst'
@time_node_list = TimeNode.parse_list(node_child)
end
end
self
end | ruby | {
"resource": ""
} |
q17920 | OoxmlParser.StyleParametres.parse | train | def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'name'
@name = node_child.attribute('val').value
when 'qFormat'
@q_format = option_enabled?(node_child)
end
end
self
end | ruby | {
"resource": ""
} |
q17921 | OoxmlParser.Spacing.parse | train | def parse(node)
node.xpath('*').each do |spacing_node_child|
case spacing_node_child.name
when 'lnSpc'
self.line = Spacing.parse_spacing_value(spacing_node_child)
self.line_rule = Spacing.parse_spacing_rule(spacing_node_child)
when 'spcBef'
self.before = Spaci... | ruby | {
"resource": ""
} |
q17922 | OoxmlParser.GradientStop.parse | train | def parse(node)
node.attributes.each do |key, value|
case key
when 'pos'
@position = value.value.to_i / 1_000
end
end
node.xpath('*').each do |node_child|
@color = case node_child.name
when 'prstClr'
ValuedChild.new(:string... | ruby | {
"resource": ""
} |
q17923 | OoxmlParser.AlphaModFix.parse | train | def parse(node)
node.attributes.each do |key, value|
case key
when 'amt'
@amount = OoxmlSize.new(value.value.to_f, :one_1000th_percent)
end
end
self
end | ruby | {
"resource": ""
} |
q17924 | OoxmlParser.TablePart.parse | train | def parse(node)
link_to_table_part_xml = OOXMLDocumentObject.get_link_from_rels(node.attribute('id').value)
doc = parse_xml(OOXMLDocumentObject.path_to_folder + link_to_table_part_xml.gsub('..', 'xl'))
table_node = doc.xpath('xmlns:table').first
table_node.attributes.each do |key, value|
... | ruby | {
"resource": ""
} |
q17925 | OoxmlParser.SheetView.parse | train | def parse(node)
node.attributes.each_key do |key|
case key
when 'showGridLines'
@show_gridlines = attribute_enabled?(node, key)
when 'showRowColHeaders'
@show_row_column_headers = attribute_enabled?(node, key)
end
end
node.xpath('*').each do |node_c... | ruby | {
"resource": ""
} |
q17926 | OoxmlParser.DocxDrawingPosition.parse | train | def parse(node)
node.attributes.each do |key, value|
case key
when 'relativeFrom'
@relative_from = value_to_symbol(value)
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'posOffset', 'pctPosHOffset', 'pctPosVOffset'
@o... | ruby | {
"resource": ""
} |
q17927 | OoxmlParser.OldDocxShape.parse | train | def parse(node)
@properties = OldDocxShapeProperties.new(parent: self).parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'textbox'
@text_box = TextBox.parse_list(node_child, parent: self)
when 'imagedata'
@file_reference = FileReference.ne... | ruby | {
"resource": ""
} |
q17928 | OoxmlParser.Formula.parse | train | def parse(node)
node.attributes.each do |key, value|
case key
when 'ref'
@reference = Coordinates.parser_coordinates_range(value.value.to_s)
when 'si'
@string_index = value.value.to_i
when 't'
@type = value.value.to_s
end
end
@valu... | ruby | {
"resource": ""
} |
q17929 | OoxmlParser.Relationships.parse_file | train | def parse_file(file_path)
node = parse_xml(file_path)
node.xpath('*').each do |node_child|
case node_child.name
when 'Relationships'
parse(node_child)
end
end
self
end | ruby | {
"resource": ""
} |
q17930 | OoxmlParser.Relationships.target_by_type | train | def target_by_type(type)
result = []
@relationship.each do |cur_rels|
result << cur_rels.target if cur_rels.type.include?(type)
end
result
end | ruby | {
"resource": ""
} |
q17931 | OoxmlParser.NumberingLevel.parse | train | def parse(node)
node.attributes.each do |key, value|
case key
when 'ilvl'
@ilvl = value.value.to_f
end
end
node.xpath('*').each do |num_level_child|
case num_level_child.name
when 'start'
@start = ValuedChild.new(:integer, parent: self).pars... | ruby | {
"resource": ""
} |
q17932 | OoxmlParser.CellXfs.parse | train | def parse(node)
node.attributes.each do |key, value|
case key
when 'count'
@count = value.value.to_i
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'xf'
@xf_array << Xf.new(parent: self).parse(node_child)
end
... | ruby | {
"resource": ""
} |
q17933 | OoxmlParser.DocxBlip.parse | train | def parse(node)
blip_node = node.xpath('a:blip', 'xmlns:a' => 'http://schemas.openxmlformats.org/drawingml/2006/main').first
return self if blip_node.nil?
@file_reference = FileReference.new(parent: self).parse(blip_node)
self
end | ruby | {
"resource": ""
} |
q17934 | OoxmlParser.GraphicFrame.parse | train | def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'xfrm'
@transform = DocxShapeSize.new(parent: self).parse(node_child)
when 'graphic'
graphic_data = []
node_child.xpath('*').each do |node_child_child|
case node_child_c... | ruby | {
"resource": ""
} |
q17935 | OoxmlParser.DocxShapeSize.parse | train | def parse(node)
node.attributes.each do |key, value|
case key
when 'rot'
@rotation = value.value.to_f
when 'flipH'
@flip_horizontal = attribute_enabled?(value)
when 'flipV'
@flip_vertical = attribute_enabled?(value)
end
end
node.xpa... | ruby | {
"resource": ""
} |
q17936 | OoxmlParser.DocxWrapDrawing.parse | train | def parse(node)
unless node.attribute('behindDoc').nil?
@wrap_text = :behind if node.attribute('behindDoc').value == '1'
@wrap_text = :infront if node.attribute('behindDoc').value == '0'
end
node.xpath('*').each do |node_child|
case node_child.name
when 'wrapSquare'
... | ruby | {
"resource": ""
} |
q17937 | OoxmlParser.DocxShapeLinePath.parse | train | def parse(node)
node.attributes.each do |key, value|
case key
when 'w'
@width = value.value.to_f
when 'h'
@height = value.value.to_f
when 'stroke'
@stroke = value.value.to_f
end
end
node.xpath('*').each do |node_child|
@elem... | ruby | {
"resource": ""
} |
q17938 | OoxmlParser.PresentationFill.parse | train | def parse(node)
return nil if node.xpath('*').empty?
node.xpath('*').each do |node_child|
case node_child.name
when 'gradFill'
@type = :gradient
@color = GradientColor.new(parent: self).parse(node_child)
when 'solidFill'
@type = :solid
@color ... | ruby | {
"resource": ""
} |
q17939 | OoxmlParser.ParagraphProperties.parse | train | def parse(node)
@spacing.parse(node)
node.attributes.each do |key, value|
case key
when 'algn'
@align = value_to_symbol(value)
when 'lvl'
@level = value.value.to_i
when 'indent'
@indent = OoxmlSize.new(value.value.to_f, :emu)
when 'marR'
... | ruby | {
"resource": ""
} |
q17940 | OoxmlParser.TableRow.parse | train | def parse(node)
root_object.default_font_style = FontStyle.new(true) # TODO: Add correct parsing of TableStyle.xml file and use it
node.attributes.each do |key, value|
case key
when 'h'
@height = OoxmlSize.new(value.value.to_f, :emu)
end
end
node.xpath('*').each... | ruby | {
"resource": ""
} |
q17941 | OoxmlParser.XlsxDrawingPositionParameters.parse | train | def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'col'
@column = Coordinates.get_column_name(node_child.text.to_i + 1)
when 'colOff'
@column_offset = OoxmlSize.new(node_child.text.to_f, :emu)
when 'row'
@row = node_child.t... | ruby | {
"resource": ""
} |
q17942 | OoxmlParser.Fill.parse | train | def parse(node)
node.attributes.each do |key, value|
case key
when 'color2'
@color2 = Color.new(parent: self).parse_hex_string(value.value.split(' ').first.delete('#'))
when 'id'
@id = value.value.to_s
@file = FileReference.new(parent: self).parse(node)
... | ruby | {
"resource": ""
} |
q17943 | OoxmlParser.DocumentDefaults.parse | train | def parse(node)
node.xpath('*').each do |node_child|
case node_child.name
when 'rPrDefault'
@run_properties_default = RunPropertiesDefault.new(parent: self).parse(node_child)
when 'pPrDefault'
@paragraph_properties_default = ParagraphPropertiesDefault.new(parent: self).... | ruby | {
"resource": ""
} |
q17944 | OoxmlParser.PatternFill.parse | train | def parse(node)
node.attributes.each do |key, value|
case key
when 'patternType'
@pattern_type = value.value.to_sym
end
end
node.xpath('*').each do |node_child|
case node_child.name
when 'fgColor'
@foreground_color = OoxmlColor.new(parent: s... | ruby | {
"resource": ""
} |
q17945 | CobwebModule.Crawl.set_base_url | train | def set_base_url(redis)
if redis.get("base_url").nil?
unless !defined?(content.redirect_through) || content.redirect_through.empty? || !@options[:first_page_redirect_internal]
uri = Addressable::URI.parse(content.redirect_through.last)
redis.sadd("internal_urls", [uri.scheme, "://", ur... | ruby | {
"resource": ""
} |
q17946 | EmojiForJekyll.EmojiGenerator.convert | train | def convert(key, block = nil)
if block.nil? or block.call(key)
img_tag(key)
else
":#{key}:"
end
end | ruby | {
"resource": ""
} |
q17947 | Stretcher.IndexType.get | train | def get(id, options={}, raw=false)
if options == true || options == false # Support raw as second argument, legacy API
raw = true
options = {}
end
res = request(:get, id, options)
raw ? res : (res["_source"] || res["fields"])
end | ruby | {
"resource": ""
} |
q17948 | Stretcher.IndexType.delete | train | def delete(id, options={})
request :delete, id, options
rescue Stretcher::RequestError => e
raise e if e.http_response.status != 404
false
end | ruby | {
"resource": ""
} |
q17949 | Stretcher.IndexType.exists? | train | def exists?(id=nil)
request :head, id
true
rescue Stretcher::RequestError::NotFound => e
false
end | ruby | {
"resource": ""
} |
q17950 | Stretcher.EsComponent.do_search | train | def do_search(generic_opts={}, explicit_body=nil)
query_opts = {}
body = nil
if explicit_body
query_opts = generic_opts
body = explicit_body
else
body = generic_opts
end
response = request(:get, "_search", query_opts, nil, {}, :mashify => false) do |req|
... | ruby | {
"resource": ""
} |
q17951 | Stretcher.Server.check_response | train | def check_response(res, options)
if res.status >= 200 && res.status <= 299
if(options[:mashify] && res.body.instance_of?(Hash))
Hashie::Mash.new(res.body)
else
res.body
end
elsif [404, 410].include? res.status
err_str = "Error processing request: (#{res.st... | ruby | {
"resource": ""
} |
q17952 | Stretcher.Alias.create | train | def create(options = {})
request(:put) do |req|
req.body = {
actions: [
add: options.merge(:alias => @name)
]
}
end
end | ruby | {
"resource": ""
} |
q17953 | Flo.Task.call | train | def call(args=[])
raise ArgumentError.new("Expected Array") unless args.is_a? Array
@provider.public_send(method_sym, *merged_evaluated_args(args.dup))
end | ruby | {
"resource": ""
} |
q17954 | Flo.Task.evaluate_proc_values | train | def evaluate_proc_values(args=[])
args.collect do |arg|
case arg
when Proc
arg.call
when Hash
hsh = {}
arg.each do |k, v|
hsh[k] = v.is_a?(Proc) ? v.call : v
end
hsh
else
arg
end
end
end | ruby | {
"resource": ""
} |
q17955 | MnoEnterprise.SmtpClient.deliver | train | def deliver(template, from, to, vars={}, opts={})
@info = vars
@info[:company] = from[:name]
mail(
from: format_sender(from),
to: to[:email],
subject: humanize(template),
template_path: 'system_notifications',
template_name: template
)
end | ruby | {
"resource": ""
} |
q17956 | MnoEnterprise.IntercomEventsListener.tag_user | train | def tag_user(user)
if user.meta_data && user.meta_data[:source].present?
intercom.tags.tag(name: user.meta_data[:source], users: [{user_id: user.id}])
end
end | ruby | {
"resource": ""
} |
q17957 | MnoEnterprise::Jpi::V1::Admin.InvitesController.send_org_invite | train | def send_org_invite(user, invite)
# Generate token if not generated
user.send(:generate_confirmation_token!) if !user.confirmed? && user.confirmation_token.blank?
MnoEnterprise::SystemNotificationMailer.organization_invite(invite).deliver_later
# Update staged invite status
invite.status... | ruby | {
"resource": ""
} |
q17958 | MnoEnterprise.Jpi::V1::BaseResourceController.check_authorization | train | def check_authorization
unless current_user
render nothing: true, status: :unauthorized
return false
end
if params[:organization_id] && !parent_organization
render nothing: true, status: :forbidden
return false
end
true
end | ruby | {
"resource": ""
} |
q17959 | MnoEnterprise.BaseResource.save! | train | def save!(options={})
if perform_validations(options)
ret = super()
process_response_errors
raise_record_invalid if self.errors.any?
ret
else
raise_record_invalid
end
end | ruby | {
"resource": ""
} |
q17960 | MnoEnterprise.User.role | train | def role(organization = nil)
# Return cached version if available
return self.read_attribute(:role) if !organization
# Find in arrays if organizations have been fetched
# already. Perform remote query otherwise
org = begin
if self.organizations.loaded?
self.organizations... | ruby | {
"resource": ""
} |
q17961 | MnoEnterprise.ApplicationController.after_sign_in_path_for | train | def after_sign_in_path_for(resource)
previous_url = session.delete(:previous_url)
default_url = if resource.respond_to?(:admin_role) && resource.admin_role.present?
MnoEnterprise.router.admin_path
else
MnoEnterprise.router.dashboard_path || main_app.root_url
end
return (ret... | ruby | {
"resource": ""
} |
q17962 | MnoEnterprise.Impac::Dashboard.organizations | train | def organizations(org_list = nil)
if org_list
return org_list if dashboard_type == 'template'
org_list.to_a.select { |e| organization_ids.include?(e.uid) || organization_ids.include?(e.id) }
else
MnoEnterprise::Organization.where('uid.in' => organization_ids).to_a
end
end | ruby | {
"resource": ""
} |
q17963 | MnoEnterprise.Impac::Dashboard.filtered_widgets_templates | train | def filtered_widgets_templates
if MnoEnterprise.widgets_templates_listing
return self.widgets_templates.select do |t|
MnoEnterprise.widgets_templates_listing.include?(t[:path])
end
else
return self.widgets_templates
end
end | ruby | {
"resource": ""
} |
q17964 | Flo.Command.call | train | def call(args={})
evaluate_command_definition(args)
response = tasks.map do |task|
response = task.call(args)
# bail early if the task failed
return response unless response.success?
response
end.last
end | ruby | {
"resource": ""
} |
q17965 | Flo.Command.optional_parameters | train | def optional_parameters
definition_lambda.parameters.select { |key,_value| key == :key }.map { |_key,value| value }
end | ruby | {
"resource": ""
} |
q17966 | MnoEnterprise.Jpi::V1::Admin::ThemeController.save_previewer_style | train | def save_previewer_style(theme)
target = Rails.root.join('frontend', 'src','app','stylesheets','theme-previewer-tmp.less')
File.open(target, 'w') { |f| f.write(theme_to_less(theme)) }
end | ruby | {
"resource": ""
} |
q17967 | MnoEnterprise.Jpi::V1::Admin::ThemeController.apply_previewer_style | train | def apply_previewer_style(theme)
target = Rails.root.join('frontend', 'src','app','stylesheets','theme-previewer-published.less')
File.open(target, 'w') { |f| f.write(theme_to_less(theme)) }
reset_previewer_style
end | ruby | {
"resource": ""
} |
q17968 | MnoEnterprise.Jpi::V1::Admin::ThemeController.theme_to_less | train | def theme_to_less(theme)
out = "// Generated by the Express Theme Previewer\n"
if theme[:branding]
out += "\n//----------------------------------------\n"
out += "// General Branding\n"
out += "//----------------------------------------\n"
out += theme[:branding]... | ruby | {
"resource": ""
} |
q17969 | MnoEnterprise.InvoicePdf.generate_content | train | def generate_content
@pdf = Prawn::Document.new(
info: self.metadata,
top_margin: @format[:header_size] + @format[:top_margin],
bottom_margin: @format[:footer_size] + @format[:bottom_margin]
)
add_page_body
add_page_header
add_page_footer
add_page_numbering
... | ruby | {
"resource": ""
} |
q17970 | MnoEnterprise.InvoicePdf.add_page_header | train | def add_page_header
title = Settings.payment.disabled ? 'Account Statement - ' : 'Monthly Invoice - '
@pdf.repeat :all do
@pdf.bounding_box([0, @pdf.bounds.top+@format[:header_size]], width: 540, height: @format[:footer_size]) do
@pdf.float do
@pdf.image main_logo_white_bg_path... | ruby | {
"resource": ""
} |
q17971 | MnoEnterprise.InvoicePdf.add_page_footer | train | def add_page_footer
@pdf.repeat :all do
@pdf.bounding_box([0, @pdf.bounds.bottom], width: 540, height: @format[:footer_size]) do
@pdf.move_down 50
@pdf.stroke_color '999999'
@pdf.stroke_horizontal_rule
@pdf.move_down 10
@pdf.font_size(8) do
@pd... | ruby | {
"resource": ""
} |
q17972 | MnoEnterprise.InvoicePdf.add_page_numbering | train | def add_page_numbering
numbering_options = {
at: [@pdf.bounds.right - 150, 0-@format[:footer_size]],
width: 150,
align: :right,
start_count_at: 1,
color: "999999",
size: 8
}
@pdf.number_pages "Page <page> of <total>", numbering_options
end | ruby | {
"resource": ""
} |
q17973 | QuickSearch.BestBetsSearcher.search_best_bets_index | train | def search_best_bets_index
response = @http.get(query_url)
parsed_response = JSON.parse(response.body)
if parsed_response['response']['numFound'].to_s == '0'
return nil
else
resp = parsed_response['response']['docs'][0]
result = OpenStruct.new
result.title = title... | ruby | {
"resource": ""
} |
q17974 | QuickSearch.TypeaheadController.typeahead | train | def typeahead
# :searcher param expected to be name of a searcher with underscores, ie: ematrix_journal
searcher = params[:searcher]
query = params[:q] or ''
total = params[:total] or 3
if searcher.blank?
logger.error "Typeahead request: no searcher param provided"
head :b... | ruby | {
"resource": ""
} |
q17975 | QuickSearch.LoggingController.log_search | train | def log_search
if params[:query].present? && params[:page].present?
@session.searches.create(query: params[:query], page: params[:page])
head :ok
else
head :bad_request
end
end | ruby | {
"resource": ""
} |
q17976 | QuickSearch.LoggingController.log_event | train | def log_event
if params[:category].present? && params[:event_action].present? && params[:label].present?
# if an action isn't passed in, assume that it is a click
action = params.fetch(:action_type, 'click')
# create a new event on the current session
@session.events.create(catego... | ruby | {
"resource": ""
} |
q17977 | QuickSearch.LoggingController.new_session | train | def new_session
on_campus = on_campus?(request.remote_ip)
is_mobile = is_mobile?
session_expiry = 5.minutes.from_now
session_uuid = SecureRandom.uuid
# create session in db
@session = Session.create(session_uuid: session_uuid, expiry: session_expiry, on_campus: on_campus, is_mobile:... | ruby | {
"resource": ""
} |
q17978 | QuickSearch.LoggingController.update_session | train | def update_session
# update session expiry in the database
session_id = cookies[:session_id]
@session = Session.find_by session_uuid: session_id
@session.expiry = 5.minutes.from_now
@session.save
# update session expiry on cookie
cookies[:session_id] = { :value => session_id, ... | ruby | {
"resource": ""
} |
q17979 | QuickSearch.Searcher.no_results_link | train | def no_results_link(service_name, i18n_key, default_i18n_key = nil)
if (i18n_key.present? && I18n.exists?(i18n_key)) ||
(default_i18n_key.present? && I18n.exists?(default_i18n_key))
locale_result = I18n.t(i18n_key, default: I18n.t(default_i18n_key))
return locale_result if locale_result
... | ruby | {
"resource": ""
} |
q17980 | QuickSearch.SearchController.xhr_search | train | def xhr_search
endpoint = params[:endpoint]
if params[:template] == 'with_paging'
template = 'xhr_response_with_paging'
else
template = 'xhr_response'
end
@query = params_q_scrubbed
@page = page
@per_page = per_page(endpoint)
@offset = offset(@page,@per_... | ruby | {
"resource": ""
} |
q17981 | Surrounded.Context.private_const_set | train | def private_const_set(name, const)
unless role_const_defined?(name)
const = const_set(name, const)
private_constant name.to_sym
end
const
end | ruby | {
"resource": ""
} |
q17982 | Fourflusher.Executable.executable | train | def executable(name)
define_method(name) do |*command|
Executable.execute_command(name, Array(command).flatten, false)
end
define_method(name.to_s + '!') do |*command|
Executable.execute_command(name, Array(command).flatten, true)
end
end | ruby | {
"resource": ""
} |
q17983 | Fourflusher.SimControl.fetch_sims | train | def fetch_sims
device_list = JSON.parse(list(['-j', 'devices']))['devices']
unless device_list.is_a?(Hash)
msg = "Expected devices to be of type Hash but instated found #{device_list.class}"
fail Fourflusher::Informative, msg
end
device_list.flat_map do |runtime_str, devices|
... | ruby | {
"resource": ""
} |
q17984 | JsonSchema.Validator.get_extra_keys | train | def get_extra_keys(schema, data)
extra = data.keys - schema.properties.keys
if schema.pattern_properties
schema.pattern_properties.keys.each do |pattern|
extra -= extra.select { |k| k =~ pattern }
end
end
extra
end | ruby | {
"resource": ""
} |
q17985 | JsonPointer.Evaluator.split | train | def split(path)
parts = []
last_index = 0
while index = path.index("/", last_index)
if index == last_index
parts << ""
else
parts << path[last_index...index]
end
last_index = index + 1
end
# and also get that last segment
parts << p... | ruby | {
"resource": ""
} |
q17986 | ReportBuilder.Builder.build_report | train | def build_report
options = ReportBuilder.options
groups = get_groups options[:input_path]
json_report_path = options[:json_report_path] || options[:report_path]
if options[:report_types].include? 'JSON'
File.open(json_report_path + '.json', 'w') do |file|
file.write JSON.pret... | ruby | {
"resource": ""
} |
q17987 | Methadone.ExitNow.exit_now! | train | def exit_now!(exit_code,message=nil)
if exit_code.kind_of?(String) && message.nil?
raise Methadone::Error.new(1,exit_code)
else
raise Methadone::Error.new(exit_code,message)
end
end | ruby | {
"resource": ""
} |
q17988 | Methadone.CLI.check_and_prepare_basedir! | train | def check_and_prepare_basedir!(basedir,force)
if File.exists? basedir
if force
rm_rf basedir, :verbose => true, :secure => true
else
exit_now! 1,"error: #{basedir} exists, use --force to override"
end
end
mkdir_p basedir
end | ruby | {
"resource": ""
} |
q17989 | Methadone.CLI.add_to_file | train | def add_to_file(file,lines,options = {})
new_lines = []
found_line = false
File.open(file).readlines.each do |line|
line.chomp!
if options[:before] && options[:before] === line
found_line = true
new_lines += lines
end
new_lines << line
end
... | ruby | {
"resource": ""
} |
q17990 | Methadone.CLI.copy_file | train | def copy_file(relative_path,options = {})
options[:from] ||= :full
relative_path = File.join(relative_path.split(/\//))
template_path = File.join(template_dir(options[:from]),relative_path + ".erb")
template = ERB.new(File.open(template_path).readlines.join(''))
relative_path_parts = Fi... | ruby | {
"resource": ""
} |
q17991 | Methadone.ARGVParser.parse_string_for_argv | train | def parse_string_for_argv(string) #:nodoc:
return [] if string.nil?
args = [] # return value we are building up
current = 0 # pointer to where we are in +string+
next_arg = '' # the next arg we are building up to ultimatley put into args
inside_quote = ... | ruby | {
"resource": ""
} |
q17992 | Methadone.Main.go! | train | def go!
setup_defaults
opts.post_setup
opts.parse!
opts.check_args!
result = call_main
if result.kind_of? Integer
exit result
else
exit 0
end
rescue OptionParser::ParseError => ex
logger.error ex.message
puts
puts opts.help
exit... | ruby | {
"resource": ""
} |
q17993 | Methadone.Main.normalize_defaults | train | def normalize_defaults
new_options = {}
options.each do |key,value|
unless value.nil?
new_options[key.to_s] = value
new_options[key.to_sym] = value
end
end
options.merge!(new_options)
end | ruby | {
"resource": ""
} |
q17994 | Methadone.Main.call_main | train | def call_main
@leak_exceptions = nil unless defined? @leak_exceptions
@main_block.call(*ARGV)
rescue Methadone::Error => ex
raise ex if ENV['DEBUG']
logger.error ex.message unless no_message? ex
ex.exit_code
rescue OptionParser::ParseError
raise
rescue => ex
raise e... | ruby | {
"resource": ""
} |
q17995 | Methadone.OptionParserProxy.check_args! | train | def check_args!
::Hash[@args.zip(::ARGV)].each do |arg_name,arg_value|
if @arg_options[arg_name].include? :required
if arg_value.nil?
message = "'#{arg_name.to_s}' is required"
message = "at least one " + message if @arg_options[arg_name].include? :many
raise ... | ruby | {
"resource": ""
} |
q17996 | Methadone.OptionParserProxy.arg | train | def arg(arg_name,*options)
options << :optional if options.include?(:any) && !options.include?(:optional)
options << :required unless options.include? :optional
options << :one unless options.include?(:any) || options.include?(:many)
@args << arg_name
@arg_options[arg_name] = options
... | ruby | {
"resource": ""
} |
q17997 | Methadone.SH.sh | train | def sh(command,options={},&block)
sh_logger.debug("Executing '#{command}'")
stdout,stderr,status = execution_strategy.run_command(command)
process_status = Methadone::ProcessStatus.new(status,options[:expected])
sh_logger.warn("stderr output of '#{command}': #{stderr}") unless stderr.strip.len... | ruby | {
"resource": ""
} |
q17998 | Methadone.SH.call_block | train | def call_block(block,stdout,stderr,exitstatus)
# blocks that take no arguments have arity -1. Or 0. Ugh.
if block.arity > 0
case block.arity
when 1
block.call(stdout)
when 2
block.call(stdout,stderr)
else
# Let it fail for lambdas
bl... | ruby | {
"resource": ""
} |
q17999 | Ooor.Associations.relationnal_result | train | def relationnal_result(method_name, *arguments)
self.class.reload_fields_definition(false)
if self.class.many2one_associations.has_key?(method_name)
load_m2o_association(method_name, *arguments)
elsif self.class.polymorphic_m2o_associations.has_key?(method_name)# && @associations[method_name]
... | ruby | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.